def test_sub(self, a_str: str, b_str: str, expected_result_str: str):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)
        expected_result = quant.from_string(expected_result_str)

        assert quant.isclose(quant.sub(a, b), expected_result)
        assert quant.isclose(a - b, expected_result)
    def test_greater_equal(self, a_str: str, b_str: str,
                           expected_result: bool):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.greater_equal(a, b) == expected_result
        assert (a >= b) == expected_result
    def test_neg(self, a_str: str, b_str: str):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.isclose(quant.neg(a), b)
        assert quant.isclose(-a, b)
        assert quant.isclose(quant.neg(b), a)
        assert quant.isclose(-b, a)
    def test_add(self, a_str: str, b_str: str, expected_result_str: str):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)
        expected_result = quant.from_string(expected_result_str)

        assert quant.isclose(quant.add(a, b), expected_result)
        assert quant.isclose(a + b, expected_result)

        assert quant.isclose(quant.add(b, a), expected_result)
        assert quant.isclose(b + a, expected_result)
Beispiel #5
0
 def test_from_string_exception_invalid(self,
                                        input_str: str,
                                        val_min: float,
                                        val_max: float,
                                        eq_min: bool,
                                        eq_max: bool,
                                        units: str):
     with pytest.raises(ValueError):
         _ = quant.from_string(input_str)
Beispiel #6
0
    def test_from_string(self,
                         input_str: str,
                         val_min: float,
                         val_max: float,
                         eq_min: bool,
                         eq_max: bool,
                         units: str):
        quantity = quant.from_string(input_str)

        assert np.isclose(quantity.val_min, val_min).all()
        assert np.isclose(quantity.val_max, val_max).all()
        assert quantity.eq_min == eq_min
        assert quantity.eq_max == eq_max
    def test_equality(self, a_str: str, b_str: str, expected_result: bool):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert (a == b) == expected_result
    def test_isclose(self, a_str: str, b_str: str, expected_result: bool):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.isclose(a, b) == expected_result
        assert quant.isclose(b, a) == expected_result
    def test_pos(self, a_str: str, b_str: str):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.isclose(+a, b)
    def test_pow(self, a: float, b_str: str, result_str: str):
        b = quant.from_string(b_str)
        result = quant.from_string(result_str)

        assert quant.isclose(quant.pow(a, b), result)
    def test_less_equal(self, a_str: str, b_str: str, expected_result: bool):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.less_equal(a, b) == expected_result
        assert (a <= b) == expected_result
    def test_absolute(self, a_str: str, b_str: str):
        a = quant.from_string(a_str)
        b = quant.from_string(b_str)

        assert quant.isclose(quant.abs(a), b)
        assert quant.isclose(abs(a), b)
    def test_log10(self, a_str: str, result_str: str):
        a = quant.from_string(a_str)
        result = quant.from_string(result_str)

        assert quant.isclose(quant.log10(a), result)