Ejemplo n.º 1
0
def test_get_param_invalid_value_gt(value):
    with pytest.raises(ValueError, match=f"Value {value} must be > 0.0"):
        pt.get_param(value, 'kelvin', gt=0.0)
Ejemplo n.º 2
0
def test_get_param_invalid_value_ge():
    with pytest.raises(ValueError, match="Value -100.0 must be >= 0.0"):
        pt.get_param(-1.0, 'm', ge=0.0)
Ejemplo n.º 3
0
def test_get_param_invalid_str_units():
    with pytest.raises(ValueError, match="Invalid units for value '1 unit'"):
        pt.get_param('1 unit')
Ejemplo n.º 4
0
def test_get_param_invalid_units():
    with pytest.raises(ValueError, match="Invalid units 'unit'"):
        pt.get_param('1.0', 'unit')
Ejemplo n.º 5
0
def test_get_param_invalid_str_many_values():
    with pytest.raises(ValueError, match="Invalid value '1 3 km'"):
        pt.get_param('1 3 km')
Ejemplo n.º 6
0
def test_get_param_invalid_str_value():
    with pytest.raises(ValueError, match="Invalid value 'val'"):
        pt.get_param('val')
Ejemplo n.º 7
0
def test_get_param_none():
    assert pt.get_param(None, 'km') is None
Ejemplo n.º 8
0
def test_get_param_array():
    value = np.array([10.0, 20.0])
    np.testing.assert_allclose(pt.get_param(value, 'm'),
                               np.array([1000.0, 2000.0]))
Ejemplo n.º 9
0
def test_get_param(value, result):
    assert pt.get_param(value, 'km') == result