Пример #1
0
 def test_joint_upsample_and_downsample_shape(self):
     kwargs = dict(
         array=np.arange(10 * 20 * 30).reshape(10, 20, 30),
         new_shape=(10, 23, 27),
     )
     output = sinc_resample(**kwargs)
     assert np.array_equal(output.shape, kwargs["new_shape"])
Пример #2
0
 def test_preserves_trends(self):
     kwargs = dict(
         array=np.array([
             [0, 1, 2, 3, 4, 3, 2, 1, 0],
             [2, 3, 4, 5, 6, 5, 4, 3, 2],
             [0, 1, 2, 3, 4, 3, 2, 1, 0],
         ]),  # Shape: (3, 9).
         new_shape=(5, 7),
     )
     output = sinc_resample(**kwargs)
     # Check that the first half of rows are ascending.
     for row in range((output.shape[0] - 1) // 2):
         assert np.all(output[row, :] <= output[row + 1, :])
     # Check that the second half of rows are descending.
     for row in range(output.shape[0] // 2, output.shape[0] - 1):
         assert np.all(output[row, :] >= output[row + 1, :])
     # Check that the first half of columns are ascending.
     for col in range((output.shape[1] - 1) // 2):
         assert np.all(output[:, col] <= output[:, col + 1])
     # Check that the second half of columns are descending.
     for col in range(output.shape[1] // 2, output.shape[1] - 1):
         assert np.all(output[:, col] >= output[:, col + 1])