8000 Merge pull request #13394 from charris/backport-13391 · numpy/numpy@dfd5764 · GitHub
[go: up one dir, main page]

Skip to content

Commit dfd5764

Browse files
authored
Merge pull request #13394 from charris/backport-13391
MAINT, DEP: Fix deprecated ``assertEquals()``
2 parents 5176a6d + 07fb76b commit dfd5764

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

tools/swig/test/testFlat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def testProcess1D(self):
3737
x = np.frombuffer(pack_output, dtype=self.typeCode)
3838
y = x.copy()
3939
process(y)
40-
self.assertEquals(np.all((x+1)==y),True)
40+
self.assertEqual(np.all((x+1)==y),True)
4141

4242
def testProcess3D(self):
4343
"Test Process function 3D array"
@@ -50,7 +50,7 @@ def testProcess3D(self):
5050
x.shape = (2,3,4)
5151
y = x.copy()
5252
process(y)
53-
self.assertEquals(np.all((x+1)==y),True)
53+
self.assertEqual(np.all((x+1)==y),True)
5454

5555
def testProcess3DTranspose(self):
5656
"Test Process function 3D array, FORTRAN order"
@@ -63,7 +63,7 @@ def testProcess3DTranspose(self):
6363
x.shape = (2,3,4)
6464
y = x.copy()
6565
process(y.T)
66-
self.assertEquals(np.all((x.T+1)==y.T),True)
66+
self.assertEqual(np.all((x.T+1)==y.T),True)
6767

6868
def testProcessNoncontiguous(self):
6969
"Test Process function with non-contiguous array, which should raise an error"

tools/swig/test/testFortran.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def testSecondElementFortran(self):
3131
second = Fortran.__dict__[self.typeStr + "SecondElement"]
3232
matrix = np.asfortranarray(np.arange(9).reshape(3, 3),
3333
self.typeCode)
34-
self.assertEquals(second(matrix), 3)
34+
self.assertEqual(second(matrix), 3)
3535

3636
def testSecondElementObject(self):
3737
"Test Fortran matrix initialized from nested list fortranarray"
3838
print(self.typeStr, "... ", end=' ', file=sys.stderr)
3939
second = Fortran.__dict__[self.typeStr + "SecondElement"]
4040
matrix = np.asfortranarray([[0, 1, 2], [3, 4, 5], [6, 7, 8]], self.typeCode)
41-
self.assertEquals(second(matrix), 3)
41+
self.assertEqual(second(matrix), 3)
4242

4343
######################################################################
4444

tools/swig/test/testMatrix.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def testDet(self):
3030
print(self.typeStr, "... ", end=' ', file=sys.stderr)
3131
det = Matrix.__dict__[self.typeStr + "Det"]
3232
matrix = [[8, 7], [6, 9]]
33-
self.assertEquals(det(matrix), 30)
33+
self.assertEqual(det(matrix), 30)
3434

3535
# Test (type IN_ARRAY2[ANY][ANY]) typemap
3636
def testDetBadList(self):
@@ -69,7 +69,7 @@ def testMax(self):
6969
print(self.typeStr, "... ", end=' ', file=sys.stderr)
7070
max = Matrix.__dict__[self.typeStr + "Max"]
7171
matrix = [[6, 5, 4], [3, 2, 1]]
72-
self.assertEquals(max(matrix), 6)
72+
self.assertEqual(max(matrix), 6)
7373

7474
# Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
7575
def testMaxBadList(self):
@@ -99,7 +99,7 @@ def testMin(self):
9999
print(self.typeStr, "... ", end=' ', file=sys.stderr)
100100
min = Matrix.__dict__[self.typeStr + "Min"]
101101
matrix = [[9, 8], [7, 6], [5, 4]]
102-
self.assertEquals(min(matrix), 4)
102+
self.assertEqual(min(matrix), 4)
103103

104104
# Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
105105
def testMinBadList(self):
@@ -130,7 +130,7 @@ def testScale(self):
130130
scale = Matrix.__dict__[self.typeStr + "Scale"]
131131
matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], self.typeCode)
132132
scale(matrix, 4)
133-
self.assertEquals((matrix == [[4, 8, 12], [8, 4, 8], [12, 8, 4]]).all(), True)
133+
self.assertEqual((matrix == [[4, 8, 12], [8, 4, 8], [12, 8, 4]]).all(), True)
134134

135135
# Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
136136
def testScaleWrongDim(self):
@@ -236,8 +236,8 @@ def testLUSplit(self):
236236
print(self.typeStr, "... ", end=' ', file=sys.stderr)
237237
luSplit = Matrix.__dict__[self.typeStr + "LUSplit"]
238238
lower, upper = luSplit([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
239-
self.assertEquals((lower == [[1, 0, 0], [4, 5, 0], [7, 8, 9]]).all(), True)
240-
self.assertEquals((upper == [[0, 2, 3], [0, 0, 6], [0, 0, 0]]).all(), True)
239+
self.assertEqual((lower == [[1, 0, 0], [4, 5, 0], [7, 8, 9]]).all(), True)
240+
self.assertEqual((upper == [[0, 2, 3], [0, 0, 6], [0, 0, 0]]).all(), True)
241241

242242
######################################################################
243243

tools/swig/test/testSuperTensor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def testMax(self):
7373
print(self.typeStr, "... ", file=sys.stderr)
7474
max = SuperTensor.__dict__[self.typeStr + "Max"]
7575
supertensor = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]
76-
self.assertEquals(max(supertensor), 8)
76+
self.assertEqual(max(supertensor), 8)
7777

7878
# Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
7979
def testMaxBadList(self):
@@ -103,7 +103,7 @@ def testMin(self):
103103
print(self.typeStr, "... ", file=sys.stderr)
104104
min = SuperTensor.__dict__[self.typeStr + "Min"]
105105
supertensor = [[[[9, 8], [7, 6]], [[5, 4], [3, 2]]], [[[9, 8], [7, 6]], [[5, 4], [3, 2]]]]
106-
self.assertEquals(min(supertensor), 2)
106+
self.assertEqual(min(supertensor), 2)
107107

108108
# Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
109109
def testMinBadList(self):
@@ -135,7 +135,7 @@ def testScale(self):
135135
supertensor = np.arange(3*3*3*3, dtype=self.typeCode).reshape((3, 3, 3, 3))
136136
answer = supertensor.copy()*4
137137
scale(supertensor, 4)
138-
self.assertEquals((supertensor == answer).all(), True)
138+
self.assertEqual((supertensor == answer).all(), True)
139139

140140
# Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
141141
def testScaleWrongType(self):
@@ -252,8 +252,8 @@ def testLUSplit(self):
252252
answer_upper = [[[[0, 0], [0, 1]], [[0, 1], [1, 1]]], [[[0, 1], [1, 1]], [[1, 1], [1, 1]]]]
253253
answer_lower = [[[[1, 1], [1, 0]], [[1, 0], [0, 0]]], [[[1, 0], [0, 0]], [[0, 0], [0, 0]]]]
254254
lower, upper = luSplit(supertensor)
255-
self.assertEquals((lower == answer_lower).all(), True)
256-
self.assertEquals((upper == answer_upper).all(), True)
255+
self.assertEqual((lower == answer_lower).all(), True)
256+
self.assertEqual((upper == answer_upper).all(), True)
257257

258258
######################################################################
259259

tools/swig/test/testTensor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def testNorm(self):
3434
tensor = [[[0, 1], [2, 3]],
3535
[[3, 2], [1, 0]]]
3636
if isinstance(self.result, int):
37-
self.assertEquals(norm(tensor), self.result)
37+
self.assertEqual(norm(tensor), self.result)
3838
else:
3939
self.assertAlmostEqual(norm(tensor), self.result, 6)
4040

@@ -79,7 +79,7 @@ def testMax(self):
7979
max = Tensor.__dict__[self.typeStr + "Max"]
8080
tensor = [[[1, 2], [3, 4]],
8181
[[5, 6], [7, 8]]]
82-
self.assertEquals(max(tensor), 8)
82+
self.assertEqual(max(tensor), 8)
8383

8484
# Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
8585
def testMaxBadList(self):
@@ -111,7 +111,7 @@ def testMin(self):
111111
min = Tensor.__dict__[self.typeStr + "Min"]
112112
tensor = [[[9, 8], [7, 6]],
113113
[[5, 4], [3, 2]]]
114-
self.assertEquals(min(tensor), 2)
114+
self.assertEqual(min(tensor), 2)
115115

116116
# Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
117117
def testMinBadList(self):
@@ -145,7 +145,7 @@ def testScale(self):
145145
[[0, 1, 0], [1, 0, 1], [0, 1, 0]],
146146
[[1, 0, 1], [0, 1, 0], [1, 0, 1]]], self.typeCode)
147147
scale(tensor, 4)
148-
self.assertEquals((tensor == [[[4, 0, 4], [0, 4, 0], [4, 0, 4]],
148+
self.assertEqual((tensor == [[[4, 0, 4], [0, 4, 0], [4, 0, 4]],
149149
[[0, 4, 0], [4, 0, 4], [0, 4, 0]],
150150
[[4, 0, 4], [0, 4, 0], [4, 0, 4]]]).all(), True)
151151

@@ -264,9 +264,9 @@ def testLUSplit(self):
264264
luSplit = Tensor.__dict__[self.typeStr + "LUSplit"]
265265
lower, upper = luSplit([[[1, 1], [1, 1]],
266266
[[1, 1], [1, 1]]])
267-
self.assertEquals((lower == [[[1, 1], [1, 0]],
267+
self.assertEqual((lower == [[[1, 1], [1, 0]],
268268
[[1, 0], [0, 0]]]).all(), True)
269-
self.assertEquals((upper == [[[0, 0], [0, 1]],
269+
self.assertEqual((upper == [[[0, 0], [0, 1]],
270270
[[0, 1], [1, 1]]]).all(), True)
271271

272272
######################################################################

tools/swig/test/testVector.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def testLength(self):
2929
"Test length function"
3030
print(self.typeStr, "... ", end=' ', file=sys.stderr)
3131
length = Vector.__dict__[self.typeStr + "Length"]
32-
self.assertEquals(length([5, 12, 0]), 13)
32+
self.assertEqual(length([5, 12, 0]), 13)
3333

3434
# Test the (type IN_ARRAY1[ANY]) typemap
3535
def testLengthBadList(self):
@@ -64,7 +64,7 @@ def testProd(self):
6464
"Test prod function"
6565
print(self.typeStr, "... ", end=' ', file=sys.stderr)
6666
prod = Vector.__dict__[self.typeStr + "Prod"]
67-
self.assertEquals(prod([1, 2, 3, 4]), 24)
67+
self.assertEqual(prod([1, 2, 3, 4]), 24)
6868

6969
# Test the (type* IN_ARRAY1, int DIM1) typemap
7070
def testProdBadList(self):
@@ -92,7 +92,7 @@ def testSum(self):
9292
"Test sum function"
9393
print(self.typeStr, "... ", end=' ', file=sys.stderr)
9494
sum = Vector.__dict__[self.typeStr + "Sum"]
95-
self.assertEquals(sum([5, 6, 7, 8]), 26)
95+
self.assertEqual(sum([5, 6, 7, 8]), 26)
9696

9797
# Test the (int DIM1, type* IN_ARRAY1) typemap
9898
def testSumBadList(self):
@@ -122,7 +122,7 @@ def testReverse(self):
122122
reverse = Vector.__dict__[self.typeStr + "Reverse"]
123123
vector = np.array([1, 2, 4], self.typeCode)
124124
reverse(vector)
125-
self.assertEquals((vector == [4, 2, 1]).all(), True)
125+
self.assertEqual((vector == [4, 2, 1]).all(), True)
126126

127127
# Test the (type INPLACE_ARRAY1[ANY]) typemap
128128
def testReverseWrongDim(self):
@@ -225,16 +225,16 @@ def testEOSplit(self):
225225
print(self.typeStr, "... ", end=' ', file=sys.stderr)
226226
eoSplit = Vector.__dict__[self.typeStr + "EOSplit"]
227227
even, odd = eoSplit([1, 2, 3])
228-
self.assertEquals((even == [1, 0, 3]).all(), True)
229-
self.assertEquals((odd == [0, 2, 0]).all(), True)
228+
self.assertEqual((even == [1, 0, 3]).all(), True)
229+
self.assertEqual((odd == [0, 2, 0]).all(), True)
230230

231231
# Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
232232
def testTwos(self):
233233
"Test twos function"
234234
print(self.typeStr, "... ", end=' ', file=sys.stderr)
235235
twos = Vector.__dict__[self.typeStr + "Twos"]
236236
vector = twos(5)
237-
self.assertEquals((vector == [2, 2, 2, 2, 2]).all(), True)
237+
self.assertEqual((vector == [2, 2, 2, 2, 2]).all(), True)
238238

239239
# Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
240240
def testTwosNonInt(self):
@@ -249,7 +249,7 @@ def testThrees(self):
249249
print(self.typeStr, "... ", end=' ', file=sys.stderr)
250250
threes = Vector.__dict__[self.typeStr + "Threes"]
251251
vector = threes(6)
252-
self.assertEquals((vector == [3, 3, 3, 3, 3, 3]).all(), True)
252+
self.assertEqual((vector == [3, 3, 3, 3, 3, 3]).all(), True)
253253

254254
# Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
255255
def testThreesNonInt(self):

0 commit comments

Comments
 (0)
0