nion-software / nionswift-instrumentation-kit

Base classes for Nion Swift STEM microscope instrumentation
GNU General Public License v3.0
1 stars 12 forks source link

Minor problem when unregistering non-stem_controller instruments #153

Open yvesauad opened 1 year ago

yvesauad commented 1 year ago

Hi guys, how you doing?

In this chunk of code:

def unregister_instrument(self, instrument: typing.Any) -> None:
        probe_view = self.__m.get(instrument, dict()).pop("probe_view")
        if probe_view:
            probe_view.close()
        subscan_view = self.__m.get(instrument, dict()).pop("subscan_view")
        if subscan_view:
            subscan_view.close()
        line_scan_view = self.__m.get(instrument, dict()).pop("line_scan_view")
        if line_scan_view:
            line_scan_view.close()
        drift_view = self.__m.get(instrument, dict()).pop("drift_view")
        if drift_view:
            drift_view.close()

A KeyError rises when self.__m.get(instrument, dict()) returns dict(), as there is nothing to pop($key). This happens with my instruments classes non_derived from stem_controller.STEMController, which is the case for my EELS spectrometer, lenses, etc.

best,