def test_eq(self): curve_a = swprepost.Curve(x=[1, 2, 3], y=[4, 5, 6]) curve_b = "I am not a Curve object" curve_c = swprepost.Curve(x=[2, 4, 4], y=[4, 5, 6]) curve_d = swprepost.Curve(x=[1, 2, 3, 4], y=[1, 2, 3, 7]) curve_e = swprepost.Curve(x=[1, 2, 3], y=[4, 5, 6]) self.assertTrue(curve_a != curve_b) self.assertTrue(curve_a != curve_c) self.assertTrue(curve_a != curve_b) self.assertTrue(curve_a != curve_d) self.assertTrue(curve_a == curve_e)
def test_str_and_repr(self): x = [4, 5, 6] y = [7, 8, 9] curve = swprepost.Curve(x, y) # __repr__ expected = f"Curve(x={curve._x}, y={curve._y})" returned = curve.__repr__() self.assertEqual(expected, returned) # __str__ expected = "Curve with 3 points." returned = curve.__str__() self.assertEqual(expected, returned)
def test_resample(self): x = [1, 2, 4, 5] y = [0, 1, 3, 4] curve = swprepost.Curve(x, y) xx = [1, 2, 3, 4, 5] expected = np.array([0, 1, 2, 3, 4]) # Inplace = False xx, returned = curve.resample(xx, inplace=False) self.assertArrayEqual(expected, returned) # Inplace = True curve.resample(xx, inplace=True) returned = curve._y self.assertArrayEqual(expected, returned)