Ejemplo n.º 1
0
    def test_setup_windows_partitions_window(self):
        nwindows = 5
        window = (0, 1)
        piecewisecheb = PiecewiseChebyshevApproximant(
            np.sin, window_breakpoints=np.linspace(*window, nwindows + 1))
        windows = piecewisecheb._setup_windows()

        np.random.seed(72)
        x = np.random.rand(101) * np.ptp(window) + window[0]
        masks = [piecewisecheb._mask_window(x, w) for w in windows]
        number_of_masks_contained = np.sum(masks, axis=0)
        self.assertTrue(np.all(number_of_masks_contained == 1))
Ejemplo n.º 2
0
 def test_mask_window(self):
     window = (0, 1)
     x = np.linspace(0, 2, 101)
     mask = PiecewiseChebyshevApproximant._mask_window(x, window)
     self.assertLess(x[mask].max(), 1.0)
     self.assertGreaterEqual(x[~mask].min(), 1.0)