lakeshorecryotronics / python-driver

Python package for interacting with Lake Shore instruments.
MIT License
22 stars 4 forks source link

Poor input checking in M91 fast_hall_controller.py run_complete_resistivity_manual() #8

Open jarvas24 opened 1 month ago

jarvas24 commented 1 month ago

The run_complete_resistivity_manual() function in fast_hall_controller.py currently fails silently if the user incorrectly inputs the sample_type parameter. In this case, the measurement is never started (execution skips by the if and elif blocks), and the function will return whatever resistivity results are stored on the instrument from any previous measurements.

This creates a difficult situation to debug; measurement results are being returned to the user but no measurements are actually being run. This could be fixed by adding an else block to throw a ValueError if the user enters an invalid sample_type. Here is the relevant snippet of code from the current version on github:

def run_complete_resistivity_manual(self, settings, sample_type):
        """Performs a manual resistivity measurement and then returns the corresponding measurement results.

            Args:
                settings(ResistivityManualParameters):
                    Object with settings for manual resistivity setup.
                sample_type(str):
                    Indicates sample type. Options are: "VDP" (Van der Pauw sample), or "HBAR" (Hall Bar sample).

            Returns:
                The measurement results as a dictionary.
        """

        # Run specific measurement based on sample type
        if sample_type == "VDP":
            self.start_resistivity_vdp(settings)
        elif sample_type == "HBAR":
            self.start_resistivity_hbar(settings)

        # Loop until measurement has stopped running
        while self.get_resistivity_running_status():
            pass

        # Collect and return results
        results = self.get_resistivity_measurement_results()
        return results
Noah-Lake-Shore-Cryotronics commented 1 month ago

Thank you for bringing this to our attention! I will make sure this gets fixed in our next release.