Skip to content

Commit b80cc71

Browse files
authored
Merge pull request #72 from pocketpy/fix_tests
Refactor some tests
2 parents e473da5 + 088f7ca commit b80cc71

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

numpy/tests/test_numpy.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,16 @@ def test_array_std():
196196
arr = np.array([[[1.5, 2.5, 3.5], [3.5, 4.5, 5.5], [5.5, 6.5, 7.5]]])
197197
assert arr.std() == 1.8257418583505538
198198
assert arr.std(0) == np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
199-
assert np.allclose(arr.std(1), np.array([[1.632993, 1.632993, 1.632993]])) == 1
200-
assert np.allclose(arr.std(2), np.array([[0.81649658, 0.81649658, 0.81649658]])) == 1
199+
assert np.allclose(arr.std(1), np.array([[1.632993, 1.632993, 1.632993]]))
200+
assert np.allclose(arr.std(2), np.array([[0.81649658, 0.81649658, 0.81649658]]))
201201

202202

203203
def test_array_var():
204204
arr = np.array([[[1.5, 2.5, 3.5], [3.5, 4.5, 5.5], [5.5, 6.5, 7.5]]])
205205
assert arr.var() == 3.3333333333333335
206206
assert arr.var(0) == np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
207-
assert np.allclose(arr.var(1), np.array([[2.66666667, 2.66666667, 2.66666667]])) == 1
208-
assert np.allclose(arr.var(2), np.array([[0.66666667, 0.66666667, 0.66666667]])) == 1
207+
assert np.allclose(arr.var(1), np.array([[2.66666667, 2.66666667, 2.66666667]]))
208+
assert np.allclose(arr.var(2), np.array([[0.66666667, 0.66666667, 0.66666667]]))
209209

210210

211211
def test_array_argmin():
@@ -409,7 +409,7 @@ def test_array_add():
409409
assert 1.66 + arr2 == np.array([[2.99, 4.32], [5.65, 6.99]])
410410
assert arr2 + arr2 == np.array([[2.66, 5.32], [7.98, 10.66]])
411411

412-
array1 = np.ones((2, 2, 2, 2, 2))
412+
array1 = np.ones([2, 2, 2, 2, 2])
413413
array2 = np.array([[[[[1.1, 1.2], [1.3, 1.4]], [[1.5, 1.6], [1.7, 1.8]]],
414414
[[[2.1, 2.2], [2.3, 2.4]], [[2.5, 2.6], [2.7, 2.8]]]],
415415
[[[[3.1, 3.2], [3.3, 3.4]], [[3.5, 3.6], [3.7, 3.8]]],
@@ -442,7 +442,7 @@ def test_array_sub():
442442
assert np.allclose(1.66 - arr2, np.array([[0.33, -1.], [-2.33, -3.67]]))
443443
assert arr2 - arr2 == np.array([[0, 0], [0, 0]])
444444

445-
array1 = np.ones((2, 2, 2, 2, 2))
445+
array1 = np.ones([2, 2, 2, 2, 2])
446446
array2 = np.array([[[[[1.1, 1.2], [1.3, 1.4]], [[1.5, 1.6], [1.7, 1.8]]],
447447
[[[2.1, 2.2], [2.3, 2.4]], [[2.5, 2.6], [2.7, 2.8]]]],
448448
[[[[3.1, 3.2], [3.3, 3.4]], [[3.5, 3.6], [3.7, 3.8]]],
@@ -637,6 +637,7 @@ def test_array_getitem():
637637
[15, 16, 17, 18, 19]],
638638
[[20, 21, 22, 23, 24],
639639
[25, 26, 27, 28, 29]]])
640+
assert arr1[3:2:-1].shape == np.array([]).reshape([0, 2, 5]).shape
640641
assert arr1[3::-2] == np.array([[[20, 21, 22, 23, 24],
641642
[25, 26, 27, 28, 29]],
642643
[[0, 1, 2, 3, 4],

0 commit comments

Comments
 (0)