Skip to content

Commit 020c8a4

Browse files
author
Martin Hinz
committed
added return nil for calibration if no hd_intervals present
1 parent 08ea7ff commit 020c8a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/models/calibration.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ def calibrate
5151

5252
# Force recalibration and update all attributes accordingly
5353
def recalibrate
54-
return nil unless c14_age.present? && c14_error.present? && c14_curve.present?
54+
return nil unless c14_age.present? && c14_error.present? && c14_curve.present?
5555

5656
logger.info "Calibrating #{{ c14_age: c14_age, c14_error: c14_error, c14_curve: c14_curve}}"
5757
calibration = Calibrator::Calibration.new(c14_age, c14_error, c14_curve)
5858

59-
self.taq = calibration.hd_intervals.map { |i| i["begin"] }.max
60-
self.tpq = calibration.hd_intervals.map { |i| i["end"] }.min
61-
# TODO: terrible, but currently unused, so...
62-
self.centre = self.tpq + ((self.taq - self.tpq) / 2)
59+
return nil unless calibration.hd_intervals.present?
60+
61+
self.taq = calibration.hd_intervals.map { |i| i["begin"] }.max
62+
self.tpq = calibration.hd_intervals.map { |i| i["end"] }.min
63+
# TODO: terrible, but currently unused, so...
64+
self.centre = self.tpq + ((self.taq - self.tpq) / 2)
6365

6466
# Not persisted
6567
self.prob_dist = calibration.prob_dist

0 commit comments

Comments
 (0)