def test_coeffs_z4(): z4 = Series(5, { 0: ufloat(-1, 0.4), 1: ufloat(-2, .004), 3: ufloat(999, .1) }) assert z4.coeffs() == [-1, -2, 0, 999, 0]
def test_coeffs_z3(): z3 = Series(4, { 0: ufloat(-1, 0.4), 1: ufloat(-2, .004), 3: ufloat(999, .1) }) assert z3.coeffs() == [-1, -2, 0, 999]
def test__add(): z1 = Series(2, {0: ufloat(1, 0.3), 1: ufloat(2, .003)}) z2 = Series(3, { 0: ufloat(-1, 0.4), 1: ufloat(-2, .004), 2: ufloat(999, .1) }) z3 = Series(2, {0: ufloat(0, 0.5), 1: ufloat(0, .005)}) assert z1 + z2 == z3
def zero(): """ Returns zero series """ return Series(1)
def test__add_simple(z1, z2): z3 = Series(2, {0: ufloat(0, 0.5), 1: ufloat(0, .005)}) z12 = z1 + z2 assert str(z12) == str(z3)
def test__eq(zero): # TODO: implement `__eq__` via properly implemented `__repr__` assert str(Series(1)) == str(zero)
def z2(): return Series(2, {0: ufloat(-1, 0.4), 1: ufloat(-2, .004)})
def z1(): return Series(2, {0: ufloat(1, 0.3), 1: ufloat(2, .003)})
def one_two_three(): """ Analytic series: z(g) = 1 + 2g² + 3g⁴ """ return Series(4, {0: 1, 1: 2, 4: 3})