Allow calib_analyze_all to run when there are no previous analyzed bumps, etc.
authorW. Trevor King <wking@drexel.edu>
Fri, 2 Mar 2012 18:57:14 +0000 (13:57 -0500)
committerW. Trevor King <wking@drexel.edu>
Fri, 2 Mar 2012 18:57:20 +0000 (13:57 -0500)
This avoids:

  Traceback (most recent call last):
    ...
    File ".../calibcant/analyze.py", line 410, in calib_analyze_all
      bumps[i] = sensitivity
  TypeError: 'NoneType' object does not support item assignment

which can happen if you construct the calibration datafile by hand and
have not yet analyzed it with calibcant.

calibcant/analyze.py

index f4e90ddb7380dcc071a62100a96bd940efd44bcf..0b4c347a68c5b1f31a56a34e35ce67d716291b64 100644 (file)
@@ -395,6 +395,12 @@ def calib_analyze_all(filename, group='/', maximum_relative_error=1e-5,
     assert group.endswith('/'), group
     bumps,temperatures,vibrations,calibration_config,k,k_s = calib_load(
         filename, group+'calibration/')
+    if bumps is None:
+        bumps = [None]*calibration_config['num-bumps']
+    if temperatures is None:
+        temperatures = [None]*calibration_config['num-temperatures']
+    if vibrations is None:
+        vibrations = [None]*calibration_config['num-vibrations']
     changed_bump = changed_temperature = changed_vibration = False
     for i in range(calibration_config['num-bumps']):
         bump_group = '%sbump/%d/' % (group, i)