diff --git a/instruments/tests/test_thorlabs/test_thorlabs_tc200.py b/instruments/tests/test_thorlabs/test_thorlabs_tc200.py index a9084db4..48dcd6c6 100644 --- a/instruments/tests/test_thorlabs/test_thorlabs_tc200.py +++ b/instruments/tests/test_thorlabs/test_thorlabs_tc200.py @@ -110,6 +110,14 @@ def test_tc200_temperature_set(): tc.temperature_set = u.Quantity(40, u.degC) +def test_tc200_temperature_set_celsius(): + """Ensure celsius is stripped if returned by instrument, see issue #331""" + with expected_protocol( + ik.thorlabs.TC200, ["tset?"], ["tset?", "30 Celsius", "> "], sep="\r" + ) as tc: + assert tc.temperature_set == u.Quantity(30.0, u.degC) + + def test_tc200_temperature_range(): with pytest.raises(ValueError), expected_protocol( ik.thorlabs.TC200, ["tmax?"], ["tmax?", "40", "> "], sep="\r" diff --git a/instruments/thorlabs/tc200.py b/instruments/thorlabs/tc200.py index 76daec8d..5096ef4e 100644 --- a/instruments/thorlabs/tc200.py +++ b/instruments/thorlabs/tc200.py @@ -198,7 +198,11 @@ def temperature_set(self): :rtype: `~pint.Quantity` """ response = ( - self.query("tset?").replace(" C", "").replace(" F", "").replace(" K", "") + self.query("tset?") + .replace(" Celsius", "") + .replace(" C", "") + .replace(" F", "") + .replace(" K", "") ) return u.Quantity(float(response), u.degC)