def test_sub_same_sizes(self): """::can sub two ScalarPatternUniform that are same sized """ z1 = sp.zeros_patt_uniform(11, 10) z2 = sp.random_patt_uniform(11, 10) a = z1 - z2 b = z1 - z2 c = a - b res = True if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13: res = False self.assertTrue(res)
def test_add_same_sizes(self): """::can add two VectorPatternUniform that are same sized """ z1 = sp.zeros_patt_uniform(11, 10, patt_type=sp.vector) z2 = sp.random_patt_uniform(11, 10, patt_type=sp.vector) a = z1 + z2 b = z1 + z2 c = a - b res = True if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13: res = False self.assertTrue(res)
"""spt = sp.ones_patt_uniform(12, 12, patt_type=sp.scalar)""", """spt = sp.ones_patt_uniform(12, 13, patt_type=sp.scalar)""", """spt = sp.random_patt_uniform(11, 10, patt_type=sp.scalar)""", """spt = sp.random_patt_uniform(11, 11, patt_type=sp.scalar)""", """a = spatt + spatt2""", """a = spatt - spatt2""", """a = spatt * spatt2""", """a = spatt / spatt2""", """a = spatt + spatt3""", """a = spatt - spatt3""", """a = spatt * spatt3""", """a = spatt / spatt3""", """a = spatt4 + spatt""", """a = spatt4 - spatt""", """a = spatt4 * spatt""", """a = spatt4 / spatt""", """a = spatt4 + 2.1""", """a = spatt4 - 2.1""", """a = spatt4 * 2.1""", """a = spatt4 / 2.1""", """a = 4.5 + spatt2""", """a = 4.5 - spatt2""", """a = 4.5 * spatt2""", """a = 4.5 / spatt2""", """a = spatt / 0""" ] spatt = sp.zeros_patt_uniform(11, 8, patt_type=sp.scalar) spatt2 = sp.random_patt_uniform(11, 8, patt_type=sp.scalar) spatt3 = sp.random_patt_uniform(11, 6, patt_type=sp.scalar) spatt4 = sp.zeros_patt_uniform(12, 6, patt_type=sp.scalar) test_executes(executes_spatts) if test_vector_patt_unif: print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") print("") print(" VectorPatternUniform structure with exceptions") print("") print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") executes_vpatts = [ """vpt = sp.zeros_patt_uniform(11, 14, patt_type=sp.vector)""",
def test_div_diff_sizes(self): """::can't div two VectorPatternUniform that are different """ z1 = sp.zeros_patt_uniform(11, 10, patt_type=sp.vector) z2 = sp.ones_patt_uniform(12, 12, patt_type=sp.vector) with self.assertRaises(ValueError): _ = z1 / z2
def test_sub_diff_sizes(self): """::can't sub two VectorPatternUniform that are different """ z1 = sp.zeros_patt_uniform(11, 10, patt_type=sp.vector) z2 = sp.random_patt_uniform(11, 12, patt_type=sp.vector) with self.assertRaises(ValueError): _ = z1 - z2
def test_make_sure_even_cols_z(self): """::raise an error if I try to set ncol odd zeros""" with self.assertRaises(ValueError): _ = sp.zeros_patt_uniform(13, 17, patt_type=sp.vector)
def test_div_diff_sizes(self): """::can't divide two ScalarPatternUniform that are different """ z1 = sp.zeros_patt_uniform(11, 10) z2 = sp.ones_patt_uniform(12, 12) with self.assertRaises(ValueError): _ = z1 / z2
def test_add_diff_sizes(self): """::can't add two ScalarPatternUniform that are different """ z1 = sp.zeros_patt_uniform(11, 10) z2 = sp.random_patt_uniform(12, 10) with self.assertRaises(ValueError): _ = z1 + z2