Skip to content

Commit

Permalink
Change deprecated np.alltrue to np.all
Browse files Browse the repository at this point in the history
  • Loading branch information
tboggs committed Aug 9, 2024
1 parent c620527 commit bbc36af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spectral/algorithms/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def principal_components(image):
(L, V) = np.linalg.eig(stats.cov)

# numpy says eigenvalues may not be sorted so we'll sort them, if needed.
if not np.alltrue(np.diff(L) <= 0):
if not np.all(np.diff(L) <= 0):
ii = list(reversed(np.argsort(L)))
L = L[ii]
V = V[:, ii]
Expand Down Expand Up @@ -1683,7 +1683,7 @@ def mnf(signal, noise):
C = noise.sqrt_inv_cov.dot(signal.cov).dot(noise.sqrt_inv_cov)
(L, V) = np.linalg.eig(C)
# numpy says eigenvalues may not be sorted so we'll sort them, if needed.
if not np.alltrue(np.diff(L) <= 0):
if not np.all(np.diff(L) <= 0):
ii = list(reversed(np.argsort(L)))
L = L[ii]
V = V[:, ii]
Expand Down
4 changes: 2 additions & 2 deletions spectral/tests/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_map_classes_isomorphic(self):
gt2 = gt + 1
d = map_class_ids(gt2, gt)
result = map_classes(gt2, d)
assert (np.alltrue(result == gt))
assert (np.all(result == gt))

def test_map_fails_allow_unmapped_false(self):
'''map_classes should raise ValueError if image has unmapped value.'''
Expand All @@ -180,7 +180,7 @@ def test_map_allow_unmapped_true(self):
d = map_class_ids(gt2, gt)
d.pop(1)
result = map_classes(gt2, d, allow_unmapped=True)
assert (np.alltrue(result[gt2 == 1] == 1))
assert (np.all(result[gt2 == 1] == 1))


def run():
Expand Down
2 changes: 1 addition & 1 deletion spectral/tests/spymath.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setup(self):

def test_evals_sorted(self):
'''Eigenvalues should be sorted in descending order.'''
assert (np.alltrue(np.diff(self.pc.eigenvalues) <= 0))
assert (np.all(np.diff(self.pc.eigenvalues) <= 0))

def test_evecs_orthonormal(self):
'''Eigenvectors should be orthonormal.'''
Expand Down

0 comments on commit bbc36af

Please sign in to comment.