Skip to content

Commit

Permalink
Include a replacement for " Celsius" as the unit
Browse files Browse the repository at this point in the history
See issue #331, it seems like `tset?` returns ` Celsius` as the unit.
  • Loading branch information
trappitsch committed Mar 1, 2022
1 parent 97c528a commit af41e4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions instruments/tests/test_thorlabs/test_thorlabs_tc200.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion instruments/thorlabs/tc200.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit af41e4e

Please sign in to comment.