labscript-suite / blacs

𝗯𝗹𝗮𝗰𝘀 supervises the execution of experiments controlled by the 𝘭𝘢𝘣𝘴𝘤𝘳𝘪𝘱𝘵 𝘴𝘶𝘪𝘵𝘦. It manages experiment queuing and hardware-timed execution, and provides manual control over devices between shots.
http://labscriptsuite.org
Other
4 stars 48 forks source link

Fix Bug in AO.__init__() When Unit Conversion Import Fails #81

Closed zakv closed 2 years ago

zakv commented 3 years ago

AO.__init__() is supposed to log an error if it can't import the specified unit conversion class. This is designed to work by setting cls = None if the class can't be imported, which should then trigger the 'The unit conversion class {cls} could not be imported...' error message to be logged.

Previously this failed due to cls mistakenly being replaced with calib_class, so the if statement to generate that error message didn't get triggered. That would cause the cls.base_unit != default_units statement in the later elif clause to raise AttributeError: 'NoneType' object has no attribute 'base_unit'.

It's clear that this is a simple mixup since the if calib_class is None: statement occurs inside a if calib_class is not None: block so it could never get triggered. This PR corrects this little mixup.

dihm commented 2 years ago

Agreed that this is a pretty obvious typo. I'm going to go ahead and merge it.