def run(): (fname, datum, value) = ('92AV3C.lan', (99, 99, 99), 2057.0) image = spy.open_image(fname) print('\n' + '-' * 72) print('Running LinearTransform tests on SpyFile object.') print('-' * 72) test = LinearTransformTest(image, datum, value) test.run() data = image.load() print('\n' + '-' * 72) print('Running LinearTransform tests on ImageArray object.') print('-' * 72) test = LinearTransformTest(data, datum, value) test.run() image.scale_factor = 10000.0 print('\n' + '-' * 72) print('Running LinearTransform tests on SpyFile object with scale factor.') print('-' * 72) test = LinearTransformTest(image, datum, value / 10000.0) test.run() if __name__ == '__main__': from spectral.tests.run import parse_args, reset_stats, print_summary parse_args() reset_stats() run() print_summary()
'''Test spatial averaging near border with shifted window.''' from spectral.algorithms.spatial import map_window f = lambda X, ij: np.mean(X.reshape((-1, X.shape[-1])), axis=0) X = self.data y = map_window(f, X, (3, 5), (100, None), (100, None), border='shift') t = np.mean(X[-3:, -5:].reshape((-1, X.shape[-1])), axis=0) assert_allclose(y[-1, -1], t) def test_map_window_stepped(self): '''Test spatial averaging with non-unity row/column step sizes.''' from spectral.algorithms.spatial import map_window f = lambda X, ij: np.mean(X.reshape((-1, X.shape[-1])), axis=0) X = self.data y = map_window(f, X, (3, 5), (30, 60, 3), (70, 100, 4), border='shift') t = np.mean(X[32:35, 72:77].reshape((-1, X.shape[-1])), axis=0) assert_allclose(y[1, 1], t) def run(): print('\n' + '-' * 72) print('Running spatial tests.') print('-' * 72) for T in [SpatialWindowTest]: T().run() if __name__ == '__main__': from spectral.tests.run import parse_args, reset_stats, print_summary parse_args() reset_stats() run() print_summary()