def test_ops(self): s0 = Surface(self.surface_valid) s0.assign(1.0) for v in s0: self.assertEqual(v, 1.0) s0 += 1 for v in s0: self.assertEqual(v, 2.0) s0 *= 2 for v in s0: self.assertEqual(v, 4.0) s1 = s0 + 4 for v in s1: self.assertEqual(v, 8.0) s2 = Surface(self.surface_valid2) with self.assertRaises(ValueError): s3 = s1 + s2 s4 = s1 + s0 for v in s4: self.assertEqual(v, 12.0) s5 = s4 / 12 for v in s5: self.assertEqual(v, 1.0)
def test_ops(self): s0 = Surface( self.surface_valid ) s0.assign(1.0) for v in s0: self.assertEqual(v , 1.0) s0 += 1 for v in s0: self.assertEqual(v , 2.0) s0 *= 2 for v in s0: self.assertEqual(v , 4.0) s1 = s0 + 4 for v in s1: self.assertEqual(v , 8.0) s2 = Surface( self.surface_valid2 ) with self.assertRaises(ValueError): s3 = s1 + s2 s4 = s1 + s0 for v in s4: self.assertEqual(v , 12.0) s5 = s4 / 12 for v in s5: self.assertEqual(v , 1.0)
def test_sqrt(self): s0 = Surface(self.surface_small) s0.assign(4) self.assertEqual(20 * 30, len(s0)) s_sqrt = s0.sqrt() for i in range(len(s0)): self.assertEqual(s0[i], 4) self.assertEqual(s_sqrt[i], 2) s0.inplaceSqrt() self.assertTrue(s0 == s_sqrt)
def test_sqrt(self): s0 = Surface( self.surface_small ) s0.assign(4) self.assertEqual(20*30, len(s0)) s_sqrt = s0.sqrt( ) for i in range(len(s0)): self.assertEqual(s0[i] , 4) self.assertEqual(s_sqrt[i] , 2) s0.inplaceSqrt( ) self.assertTrue( s0 == s_sqrt )