def test_exposure_parser_exposure_time(): """Test the behaviour of the exposure time/image number parser's exposure flag.""" for flag in "-e", "--exposure-time": args = exposure_parser.parse_args([flag, ".1"]) assert args.exposure_time == pint.Quantity(100, "ms") assert args.num_images is None for exposure in ".1s", "ms", "100µs": args = exposure_parser.parse_args(["-e", exposure]) assert args.exposure_time == pint.Quantity(exposure)
def test_energy_units_issue79(fourc): # issue #79 fourc.energy_units.put("eV") fourc.energy_offset.put(0) eV = 1746 fourc.energy.put(eV) numpy.testing.assert_almost_equal(fourc.calc.energy, eV / 1000) numpy.testing.assert_almost_equal( # fmt: off pint.Quantity(fourc.calc.energy, "keV").to(fourc.energy_units.get()).magnitude, fourc.energy.get(), # fmt: on )
def test_vapor_pressure(self, simple_material, temperature): T = temperature.to("celsius").magnitude value = 2.71828**(1 + 2 / (3 + T)) pressure = pint.Quantity(pytest.approx(value), "Pa") assert pressure == simple_material.vapor_pressure(temperature)
def test_vaporization_heat_loaded(self, simple_material): vh = simple_material.vaporization_heat assert pint.Quantity("1 british_thermal_unit/lb") == vh
def test_molar_mass_loaded(self, simple_material): mm = simple_material.molar_mass assert pint.Quantity("1 g/mol") == mm
def temperature(self): return (pint.Quantity("293 kelvin"))
def test_change_component_list_moles(self, component_list): addition = pint.Quantity("300 moles") component_list["simple material"].moles += addition assert component_list["simple material"].moles == addition