def test_resample(self): # Inplace = False _xx = np.array([1, 2, 3, 4, 5, 6, 7]) # Both xx, yy, yyerr, xxerr = self.ucurve_b.resample(_xx) self.assertArrayAlmostEqual(_xx, xx) self.assertArrayAlmostEqual(_xx, yy) self.assertArrayAlmostEqual(np.ones(7), xxerr) self.assertArrayAlmostEqual(np.array([2, 4, 6, 8, 10, 12, 14]), yyerr) # Neither xx, yy = self.ucurve_n.resample(_xx) self.assertArrayAlmostEqual(_xx, xx) self.assertArrayAlmostEqual(_xx, yy) # Inplace = True xy = [1, 2, 3, 5, 6, 7] _xx = [1, 2, 3, 4, 5, 6, 7] ucurve = swprepost.CurveUncertain(xy, xy, yerr=xy, xerr=xy) ucurve.resample(_xx, inplace=True) expected = np.array(_xx) for attr in ["_x", "_y", "_yerr", "_xerr"]: returned = getattr(ucurve, attr) self.assertArrayAlmostEqual(expected, returned)
def setUpClass(cls): cls.x = np.array([1, 2, 3, 5, 6, 7]) cls.y = np.array([1, 2, 3, 5, 6, 7]) cls.xerr = np.array([1, 1, 1, 1, 1, 1]) cls.yerr = np.array([2, 4, 6, 10, 12, 14]) # Define both error terms cls.ucurve_b = swprepost.CurveUncertain(x=cls.x, y=cls.y, yerr=cls.yerr, xerr=cls.xerr) # Define only yerr cls.ucurve_y = swprepost.CurveUncertain(x=cls.x, y=cls.y, yerr=cls.yerr) # Define neither cls.ucurve_n = swprepost.CurveUncertain(x=cls.x, y=cls.y)