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))))
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)
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))))
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)
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))))
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))
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)
def test_maximum(self): ssf = SimpleSizeFunction(2) self.assertIsNone(ssf.maximum)
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")