def test_from_pair(start_value): cf = CalculatorComplex.from_pair(*start_value) assert cf.real == CalculatorFloat(start_value[0]) assert cf.imag == CalculatorFloat(start_value[1])
def test_complex_cast_fail(): cc = CalculatorComplex.from_pair("a", "b") with pytest.raises(ValueError): assert complex(cc)
def test_complex_abs(initial): aabs = abs(CalculatorComplex.from_pair(*initial[0])) assert aabs.isclose(initial[1])
def test_complex_arg(initial): arg = CalculatorComplex.from_pair(*initial[0]).arg() assert arg.isclose(initial[1])
def test_complex_conj(initial): t = CalculatorComplex.from_pair(*initial[0]).conj() assert t == CalculatorComplex.from_pair(*initial[1])
def test_complex_isclose(initial): t = CalculatorComplex.from_pair(initial[0][0], initial[0][1]).isclose( CalculatorComplex.from_pair(initial[1][0], initial[1][1])) assert t == initial[2]