Skip to content

Commit 417d961

Browse files
committed
Replace alltrue with all
1 parent cde42a4 commit 417d961

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

chaco/tests/test_border.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
import unittest
1919

20-
from numpy import array, alltrue, ravel
20+
import numpy as np
21+
from numpy import array, ravel
2122

2223
# Chaco imports
2324
from chaco.api import Plot, PlotGraphicsContext
@@ -26,7 +27,7 @@
2627
class DrawBorderTestCase(unittest.TestCase):
2728
def assertRavelEqual(self, x, y):
2829
self.assertTrue(
29-
alltrue(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y)
30+
np.all(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y)
3031
)
3132

3233
def test_draw_border_simple(self):

chaco/tests/test_datarange_2d.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import unittest
1212
import warnings
1313

14-
from numpy import alltrue, arange, array, ravel, transpose, zeros, inf, isinf
14+
import numpy as np
15+
from numpy import arange, array, ravel, transpose, zeros, inf, isinf
1516
from numpy.testing import assert_equal, assert_
1617

1718
from chaco.api import DataRange2D, GridDataSource, PointDataSource
@@ -249,7 +250,7 @@ def assert_close_(desired, actual):
249250
diff = abs(ravel(actual) - ravel(desired))
250251
for d in diff:
251252
if not isinf(d):
252-
assert_(alltrue(d <= diff_allowed))
253+
assert_(np.all(d <= diff_allowed))
253254
return
254255

255256

chaco/tests/test_plot.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest
1212

1313
import numpy as np
14-
from numpy import alltrue, arange, array
14+
from numpy import arange, array
1515

1616
from enable.api import ComponentEditor
1717
from enable.testing import EnableTestAssistant
@@ -26,6 +26,7 @@
2626

2727

2828
class PlotTestCase(unittest.TestCase):
29+
2930
def test_plot_from_unsupported_array_shape(self):
3031
arr = arange(8).reshape(2, 2, 2)
3132
data = ArrayPlotData(x=arr, y=arr)
@@ -63,7 +64,7 @@ def test_segment_plot(self):
6364
gc = PlotGraphicsContext((250, 250))
6465
gc.render_component(plot)
6566
actual = gc.bmp_array[:, :, :]
66-
self.assertFalse(alltrue(actual == 255))
67+
self.assertFalse(np.all(actual == 255))
6768

6869
def test_segment_plot_color(self):
6970
x = arange(10)
@@ -77,7 +78,7 @@ def test_segment_plot_color(self):
7778
gc = PlotGraphicsContext((250, 250))
7879
gc.render_component(plot)
7980
actual = gc.bmp_array[:, :, :]
80-
self.assertFalse(alltrue(actual == 255))
81+
self.assertFalse(np.all(actual == 255))
8182

8283
def test_segment_plot_color_width(self):
8384
x = arange(10)
@@ -94,7 +95,7 @@ def test_segment_plot_color_width(self):
9495
gc = PlotGraphicsContext((250, 250))
9596
gc.render_component(plot)
9697
actual = gc.bmp_array[:, :, :]
97-
self.assertFalse(alltrue(actual == 255))
98+
self.assertFalse(np.all(actual == 255))
9899

99100
def test_segment_plot_map_screen(self):
100101
x = arange(10)
@@ -120,7 +121,7 @@ def test_text_plot(self):
120121
gc = PlotGraphicsContext((250, 250))
121122
gc.render_component(plot)
122123
actual = gc.bmp_array[:, :, :]
123-
self.assertFalse(alltrue(actual == 255))
124+
self.assertFalse(np.all(actual == 255))
124125

125126
def check_map_screen(self, renderer):
126127
arr = arange(10)

chaco/tests/test_speedups.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
import unittest
1212

13-
from numpy import alltrue, array, ravel, zeros, isinf, linspace
13+
import numpy as np
14+
from numpy import array, ravel, zeros, isinf, linspace
1415

1516

1617
def assert_close(desired, actual):
1718
diff_allowed = 1e-5
1819
diff = abs(ravel(actual) - ravel(desired))
1920
for d in diff:
2021
if not isinf(d):
21-
assert alltrue(d <= diff_allowed)
22+
assert np.all(d <= diff_allowed)
2223
return
2324

2425

0 commit comments

Comments
 (0)