def temperature_set(self, newval): # the set temperature is always in celsius newval = convert_temperature(newval, u.degC).magnitude if newval < 20.0 or newval > self.max_temperature: raise ValueError("Temperature set is out of range.") out_query = "tset={}".format(newval) self.sendcmd(out_query)
def temperature_set(self, newval): # the set temperature is always in celsius newval = convert_temperature(newval, pq.degC).magnitude if newval < 20.0 or newval > self.max_temperature: raise ValueError("Temperature set is out of range.") out_query = "tset={}".format(newval) self.sendcmd(out_query)
def test_temperature_conversion(): blo = 70.0 * pq.degF out = convert_temperature(blo, pq.degC) eq_(out.magnitude, 21.11111111111111) out = convert_temperature(blo, pq.degK) eq_(out.magnitude, 294.2055555555555) out = convert_temperature(blo, pq.degF) eq_(out.magnitude, 70.0) blo = 20.0 * pq.degC out = convert_temperature(blo, pq.degF) eq_(out.magnitude, 68) out = convert_temperature(blo, pq.degC) eq_(out.magnitude, 20.0) out = convert_temperature(blo, pq.degK) eq_(out.magnitude, 293.15) blo = 270 * pq.degK out = convert_temperature(blo, pq.degC) eq_(out.magnitude, -3.1499999999999773) out = convert_temperature(blo, pq.degF) eq_(out.magnitude, 141.94736842105263) out = convert_temperature(blo, pq.K) eq_(out.magnitude, 270)
def test_temperature_conversion(): blo = 70.0 * u.degF out = convert_temperature(blo, u.degC) assert out.magnitude == 21.11111111111111 out = convert_temperature(blo, u.degK) assert out.magnitude == 294.2055555555555 out = convert_temperature(blo, u.degF) assert out.magnitude == 70.0 blo = 20.0 * u.degC out = convert_temperature(blo, u.degF) assert out.magnitude == 68 out = convert_temperature(blo, u.degC) assert out.magnitude == 20.0 out = convert_temperature(blo, u.degK) assert out.magnitude == 293.15 blo = 270 * u.degK out = convert_temperature(blo, u.degC) assert out.magnitude == -3.1499999999999773 out = convert_temperature(blo, u.degF) assert out.magnitude == 141.94736842105263 out = convert_temperature(blo, u.K) assert out.magnitude == 270
def test_temperater_conversion_failure(): blo = 70.0 * pq.degF convert_temperature(blo, pq.V)
def temperature(self, newval): newval = convert_temperature(newval, pq.degC).magnitude self.sendcmd("stt:" + str(newval))
def temperature(self, newval): newval = convert_temperature(newval, u.degC).magnitude self.sendcmd("stt:" + str(newval))
def test_temperater_conversion_failure(): with pytest.raises(ValueError): blo = 70.0 * u.degF convert_temperature(blo, u.V)