Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include a replacement for " Celsius" as the unit #333

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update this to parse the units instead of just throwing them away?

Copy link
Contributor Author

@trappitsch trappitsch Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the manual, section 6.3.2:

All temperature inputs and read backs are in °C only, regardless of what the display units are for the front panel LCD of the TC200.

I assume it would never return other units than C, but then again... didn't except Celsius either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 fair enough! haha


Expand Down