Skip to content

Commit 4eb423e

Browse files
committed
numpy assert_all_close no longer works with ImageArrays so use np.allclose instead
1 parent dc864e2 commit 4eb423e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

spectral/tests/dimensionality.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_mnf_all_equals_data(self):
5555
noise = spy.noise_from_diffs(data[117: 137, 85: 122, :])
5656
mnfr = spy.mnf(signal, noise)
5757
denoised = mnfr.denoise(data, num=data.shape[-1])
58-
assert_allclose(denoised, data)
58+
assert(np.allclose(denoised, data))
5959

6060
def test_ppi(self):
6161
'''Tests that ppi function runs'''
@@ -75,7 +75,7 @@ def test_ppi_continues(self):
7575
np.random.set_state(s)
7676
p2 = spy.ppi(data, 2)
7777
p2 = spy.ppi(data, 2, start=p2)
78-
np.all(p == p2)
78+
assert(np.all(p == p2))
7979

8080
def test_ppi_centered(self):
8181
'''Tests that ppi with mean-subtracted data works as expected.'''
@@ -86,7 +86,7 @@ def test_ppi_centered(self):
8686
np.random.set_state(s)
8787
data_centered = data - spy.calc_stats(data).mean
8888
p2 = spy.ppi(data_centered, 4)
89-
np.all(p == p2)
89+
assert(np.all(p == p2))
9090

9191
def test_pca_runs(self):
9292
'''Should be able to compute PCs and transform data.'''

spectral/tests/spyfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@
4444
from __future__ import division, print_function, unicode_literals
4545

4646
import numpy as np
47-
from numpy.testing import assert_almost_equal
4847
from .spytest import SpyTest
4948

49+
def assert_almost_equal(a, b, **kwargs):
50+
if not np.allclose(a, b, **kwargs):
51+
raise Exception('NOPE')
5052

5153
class SpyFileTest(SpyTest):
5254
'''Tests that SpyFile methods read data correctly from files.'''
@@ -165,7 +167,7 @@ def test_load(self):
165167
data = self.image.load()
166168
spyf = self.image
167169

168-
load_assert = assert_same_shape_almost_equal
170+
load_assert = np.allclose
169171
load_assert(data[i, j, k], self.value)
170172
first_band = spyf[:, :, 0]
171173
load_assert(data[:, :, 0], first_band)

0 commit comments

Comments
 (0)