Beispiel #1
0
 def test_new_ssf(self):
     sf = SF.SizeFunction()
     ssf = sf.new_ssf(cl=-2, m=5, points=((0, 1), (1, 2)))
     self.assertIsInstance(ssf, SimpleSizeFunction)
     self.assertEqual(ssf, SimpleSizeFunction(-2, 5, ((0, 1), (1, 2))))
     ssf = sf.new_ssf(cl=-2, points=((0, 1), (1, 2)))
     self.assertEqual(ssf, SimpleSizeFunction(-2, None, ((0, 1), (1, 2))))
Beispiel #2
0
 def test_copy(self):
     ssf1 = SimpleSizeFunction(-2, 5, [(1, 2), (2, 3)])
     ssf2 = ssf1.copy()
     self.assertIsInstance(ssf2, SimpleSizeFunction)
     self.assertEqual(ssf1, ssf2)
     self.assertFalse(ssf1 is ssf2)
     ap = ssf1._points[0]
     for p in ssf2._points:
         self.assertFalse(ap is p)
Beispiel #3
0
 def test_copy(self):
     ssf1 = SimpleSizeFunction(-2, 5, [(1, 2), (2, 3)])
     ssf2 = ssf1.copy()
     self.assertIsInstance(ssf2, SimpleSizeFunction)
     self.assertEqual(ssf1, ssf2)
     self.assertFalse(ssf1 is ssf2)
     ap = ssf1._points[0]
     for p in ssf2._points:
         self.assertFalse(ap is p)
Beispiel #4
0
 def test_add_point(self):
     ssf = SimpleSizeFunction(-2, 5)
     ssf.add_point(1, 2)
     ap = AP(1, 2)
     self.assertIn(ap, ssf.get_points())
     self.assertRaises(ValueError, ssf.add_point, -3, 2)
     self.assertRaises(ValueError, ssf.add_point, -1, 6)
     ssf.add_point(1.1, 2.2)
     self.assertIn(AP(1.1, 2.2), ssf.points)
     ssf.add_point(1, 2)
     self.assertEqual(2, ssf.points.count(ap))
Beispiel #5
0
 def test_add(self):
     sf = SF.SizeFunction()
     ssf = SimpleSizeFunction(cl=-2, m=5, points=((0, 1), (1, 2)))
     sf.add(ssf)
     self.assertEqual(ssf, sf._ssfs[0])
     self.assertFalse(ssf is sf._ssfs[0])
     self.assertRaises(ValueError, sf.add,
                       SimpleSizeFunctionOld(-1, ((1, 2), (1.5, 2.5))))
Beispiel #6
0
 def test_add_point(self):
     ssf = SimpleSizeFunction(-2, 5)
     ssf.add_point(1, 2)
     ap = AP(1, 2)
     self.assertIn(ap, ssf.get_points())
     self.assertRaises(ValueError, ssf.add_point, -3, 2)
     self.assertRaises(ValueError, ssf.add_point, -1, 6)
     ssf.add_point(1.1, 2.2)
     self.assertIn(AP(1.1, 2.2), ssf.points)
     ssf.add_point(1, 2)
     self.assertEqual(2, ssf.points.count(ap))
Beispiel #7
0
 def test_add(self):
     sf = SF.SizeFunctionOld()
     ssf = SimpleSizeFunctionOld(cl=-2, points=((0, 1), (1, 2)))
     ssf2 = sf.add(ssf)
     self.assertEqual(ssf, sf._ssfs[0])
     self.assertFalse(ssf is sf._ssfs[0])
     self.assertIsInstance(ssf2, SimpleSizeFunctionOld)
     self.assertEqual(ssf, ssf2)
     self.assertIs(ssf2, sf._ssfs[0])
     self.assertRaises(ValueError, sf.add,
                       SimpleSizeFunction(-1, 5, ((1, 2), (1.5, 2.5))))
Beispiel #8
0
 def test_Create_nominal_args(self):
     ssf1 = SimpleSizeFunction(cl=-2, m=5, points=[(1, 2), (2, 3)])
     ssf2 = SimpleSizeFunction(points=[(1, 2), (2, 3)], cl=-2, m=5)
     self.assertEqual(ssf1, ssf2)
Beispiel #9
0
 def test_equal(self):
     ssf1 = SimpleSizeFunction(-2, 5)
     ssf1.add_point(1, 2)
     ssf2 = SimpleSizeFunction(-2, 5)
     ssf2.add_point(1, 2)
     self.assertEqual(ssf1, ssf2)
     ssf2.add_point(2, 3)
     self.assertNotEqual(ssf1, ssf2)
     ssf1.add_point(2, 3)
     self.assertEqual(ssf1, ssf2)
     ssf2.add_point(2, 3)
     self.assertNotEqual(ssf1, ssf2)
     ssf1.add_point(2, 3)
     self.assertEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0)
     ssf2 = SimpleSizeFunction(0)
     self.assertEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0, 3)
     ssf2 = SimpleSizeFunction(0, 4)
     self.assertNotEqual(ssf1, ssf2)
     ssf2 = SimpleSizeFunction(0)
     self.assertNotEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0)
     ssf2 = SimpleSizeFunctionOld(0)
     self.assertEqual(ssf1, ssf2)
     self.assertEqual(ssf2, ssf1)
     ssf1 = SimpleSizeFunction(0, 3)
     self.assertNotEqual(ssf1, ssf2)
     self.assertNotEqual(ssf2, ssf1)
Beispiel #10
0
 def test_maximum(self):
     ssf = SimpleSizeFunction(2)
     self.assertIsNone(ssf.maximum)
Beispiel #11
0
 def test_Create(self):
     ssf = SimpleSizeFunction(-2, 3)
     self.assertIsInstance(ssf, SimpleSizeFunctionOld)
     self.assertRaises(TypeError, SimpleSizeFunction)
     self.assertRaises(ValueError, SimpleSizeFunction, "pluto", 3)
     self.assertRaises(ValueError, SimpleSizeFunction, 3, "pluto")
Beispiel #12
0
 def test_equal(self):
     ssf1 = SimpleSizeFunction(-2, 5)
     ssf1.add_point(1, 2)
     ssf2 = SimpleSizeFunction(-2, 5)
     ssf2.add_point(1, 2)
     self.assertEqual(ssf1, ssf2)
     ssf2.add_point(2, 3)
     self.assertNotEqual(ssf1, ssf2)
     ssf1.add_point(2, 3)
     self.assertEqual(ssf1, ssf2)
     ssf2.add_point(2, 3)
     self.assertNotEqual(ssf1, ssf2)
     ssf1.add_point(2, 3)
     self.assertEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0)
     ssf2 = SimpleSizeFunction(0)
     self.assertEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0, 3)
     ssf2 = SimpleSizeFunction(0, 4)
     self.assertNotEqual(ssf1, ssf2)
     ssf2 = SimpleSizeFunction(0)
     self.assertNotEqual(ssf1, ssf2)
     ssf1 = SimpleSizeFunction(0)
     ssf2 = SimpleSizeFunctionOld(0)
     self.assertEqual(ssf1, ssf2)
     self.assertEqual(ssf2, ssf1)
     ssf1 = SimpleSizeFunction(0, 3)
     self.assertNotEqual(ssf1, ssf2)
     self.assertNotEqual(ssf2, ssf1)