def test_ratfunc_quadratic(): xs = np.arange(-10, 11) ys = np.array([ 1.231638418079096, 1.1917808219178083, 1.1440677966101696, 1.086021505376344, 1.0140845070422535, 0.9230769230769231, 0.8055555555555556, 0.6521739130434783, 0.46153846153846156, 0.3333333333333333, 1.5, 9.0, 6.666666666666667, 4.5, 3.5625, 3.074074074074074, 2.7804878048780486, 2.586206896551724, 2.448717948717949, 2.3465346534653464, 2.267716535433071, ]) coeffs = dict() coeffs["a"] = 5 coeffs["b"] = 7 coeffs["c"] = 6 coeffs["d"] = 3 coeffs["e"] = -5 coeffs["f"] = 4 rf = functions.RatFunc(coeffs) assert np.array_equal(rf.physical_to_int(xs), ys)
def test_ratfunc_linear_inv(): xs = np.arange(-10, 11) ys = np.array( [-6.4, -5.6, -4.8, -4., -3.2, -2.4, -1.6, -0.8, 0., 0.8, 1.6, 2.4, 3.2, 4., 4.8, 5.6, 6.4, 7.2, 8., 8.8, 9.6], dtype = "float" ) coeffs = Value() coeffs.a = 0 coeffs.b = 4 coeffs.c = 8 coeffs.d = 0 coeffs.e = 0 coeffs.f = 5 rf = functions.RatFunc(coeffs) rf = functions.RatFunc(coeffs) assert np.array_equal(rf.inv(ys), xs)
def test_ratfunc_identity(): coeffs = Value() coeffs.a = 0 coeffs.b = 1 coeffs.c = 0 coeffs.d = 0 coeffs.e = 0 coeffs.f = 1 rf = functions.RatFunc(coeffs) assert rf(21845) == 21845
def test_ratfunc_identity(): coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 1 coeffs["c"] = 0 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 1 rf = functions.RatFunc(coeffs) assert rf.int_to_physical(21845) == 21845 assert rf.physical_to_int(21845) == 21845
def test_ratfunc_linear_inv_scalar(): x = -10 y = -6.4 coeffs = Value() coeffs.a = 0 coeffs.b = 4 coeffs.c = 8 coeffs.d = 0 coeffs.e = 0 coeffs.f = 5 rf = functions.RatFunc(coeffs) assert rf.inv(y) == x
def test_ratfunc_quadratic_inv_scalar(): x = -10 coeffs = Value() coeffs.a = 5 coeffs.b = 7 coeffs.c = 6 coeffs.d = 3 coeffs.e = -5 coeffs.f = 4 rf = functions.RatFunc(coeffs) with pytest.raises(NotImplementedError): rf.inv(x)
def test_ratfunc_quadratic_inv(): xs = np.arange(-10, 11) coeffs = Value() coeffs.a = 5 coeffs.b = 7 coeffs.c = 6 coeffs.d = 3 coeffs.e = -5 coeffs.f = 4 rf = functions.RatFunc(coeffs) with pytest.raises(NotImplementedError): rf.inv(xs)
def test_ratfunc_constant_scalar(): x = -10 y = 10.0 coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 0 coeffs["c"] = 20 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 2 rf = functions.RatFunc(coeffs) assert rf.physical_to_int(x) == y
def test_ratfunc_constant(): xs = np.arange(-10, 11) ys = np.full((21,), 10.0) coeffs = Value() coeffs.a = 0 coeffs.b = 0 coeffs.c = 20 coeffs.d = 0 coeffs.e = 0 coeffs.f = 2 rf = functions.RatFunc(coeffs) assert np.array_equal(rf(xs), ys)
def test_ratfunc_quadratic_scalar(): x = -10 y = 1.231638418079096 coeffs = Value() coeffs.a = 5 coeffs.b = 7 coeffs.c = 6 coeffs.d = 3 coeffs.e = -5 coeffs.f = 4 rf = functions.RatFunc(coeffs) assert rf(x) == y
def test_ratfunc_constant_scalar(): x = -10 y = 10.0 coeffs = Value() coeffs.a = 0 coeffs.b = 0 coeffs.c = 20 coeffs.d = 0 coeffs.e = 0 coeffs.f = 2 rf = functions.RatFunc(coeffs) assert rf(x) == y
def test_ratfunc_linear_inv_scalar(): x = -10 y = -6.4 coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 4 coeffs["c"] = 8 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 5 rf = functions.RatFunc(coeffs) assert rf.int_to_physical(y) == x
def test_ratfunc_quadratic_inv_scalar(): x = -10 coeffs = dict() coeffs["a"] = 5 coeffs["b"] = 7 coeffs["c"] = 6 coeffs["d"] = 3 coeffs["e"] = -5 coeffs["f"] = 4 rf = functions.RatFunc(coeffs) with pytest.raises(NotImplementedError): rf.int_to_physical(x)
def test_ratfunc_quadratic_scalar(): x = -10 y = 1.231638418079096 coeffs = dict() coeffs["a"] = 5 coeffs["b"] = 7 coeffs["c"] = 6 coeffs["d"] = 3 coeffs["e"] = -5 coeffs["f"] = 4 rf = functions.RatFunc(coeffs) assert rf.physical_to_int(x) == y
def test_ratfunc_constant(): xs = np.arange(-10, 11) ys = np.full((21, ), 10.0) coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 0 coeffs["c"] = 20 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 2 rf = functions.RatFunc(coeffs) assert np.array_equal(rf.physical_to_int(xs), ys)
def test_ratfunc_constant_inv_scalar(): x = -10 y = 10.0 coeffs = Value() coeffs.a = 0 coeffs.b = 0 coeffs.c = 20 coeffs.d = 0 coeffs.e = 0 coeffs.f = 20 rf = functions.RatFunc(coeffs) with pytest.raises(exceptions.MathError): rf.inv(y)
def test_ratfunc_constant_inv(): xs = np.arange(-10, 11) ys = np.full((21,), 10.0) coeffs = Value() coeffs.a = 0 coeffs.b = 0 coeffs.c = 20 coeffs.d = 0 coeffs.e = 0 coeffs.f = 20 rf = functions.RatFunc(coeffs) with pytest.raises(exceptions.MathError): rf.inv(ys)
def test_ratfunc_constant_inv(): xs = np.arange(-10, 11) ys = np.full((21, ), 10.0) coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 0 coeffs["c"] = 20 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 20 rf = functions.RatFunc(coeffs) with pytest.raises(exceptions.MathError): rf.int_to_physical(ys)
def test_ratfunc_constant_inv_scalar(): x = -10 y = 10.0 coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 0 coeffs["c"] = 20 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 20 rf = functions.RatFunc(coeffs) with pytest.raises(exceptions.MathError): rf.int_to_physical(y)
def test_ratfunc_quadratic(): xs = np.arange(-10, 11) ys = np.array([1.231638418079096, 1.1917808219178083, 1.1440677966101696, 1.086021505376344, 1.0140845070422535, 0.9230769230769231, 0.8055555555555556, 0.6521739130434783, 0.46153846153846156,0.3333333333333333, 1.5, 9.0, 6.666666666666667, 4.5, 3.5625, 3.074074074074074, 2.7804878048780486, 2.586206896551724, 2.448717948717949, 2.3465346534653464, 2.267716535433071 ]) coeffs = Value() coeffs.a = 5 coeffs.b = 7 coeffs.c = 6 coeffs.d = 3 coeffs.e = -5 coeffs.f = 4 rf = functions.RatFunc(coeffs) assert np.array_equal(rf(xs), ys)
def test_ratfunc_linear_inv(): xs = np.arange(-10, 11) ys = np.array( [ -6.4, -5.6, -4.8, -4.0, -3.2, -2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4, 3.2, 4.0, 4.8, 5.6, 6.4, 7.2, 8.0, 8.8, 9.6, ], dtype="float", ) coeffs = dict() coeffs["a"] = 0 coeffs["b"] = 4 coeffs["c"] = 8 coeffs["d"] = 0 coeffs["e"] = 0 coeffs["f"] = 5 rf = functions.RatFunc(coeffs) assert np.array_equal(rf.int_to_physical(ys), xs)