def test_creation_errors(): with pytest.raises( ArithmeticError, match= "`width` of interval must number higher or at least equal to 0."): IntervalFactory.midpoint_width(0, -1) with pytest.raises( ValueError, match= "The interval is invalid. `minimum` must be lower or equal to `maximum`" ): IntervalFactory.infimum_supremum(3, 1) with pytest.raises( ValueError, match="`precision` should be value from range `0` to `15`"): Interval(1, 3, precision=-1) Interval(1, 3, precision=16) with pytest.warns(UserWarning, match="Using default value of precision"): Interval(1, 3, precision="pre") with pytest.raises(ValueError, match="Cannot parse Interval from this definition"): IntervalFactory.parse_string("[1, 2.5, 5]") with pytest.raises(ValueError, match="Cannot parse Interval from this definition"): IntervalFactory.parse_string("[]") with pytest.raises(ValueError, match="Cannot parse Interval from this definition"): IntervalFactory.parse_string("[\"aa\", \"b\"]")
def test_mid_point(): a = IntervalFactory.two_values(1, 2) assert a.mid_point == 1.5 b = IntervalFactory.midpoint_width(2, 2) assert b.mid_point == 2