MCPcopy Create free account
hub / github.com/numpy/numpy / test_basic

Method test_basic

numpy/lib/tests/test_function_base.py:49–79  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47
48class TestRot90:
49 def test_basic(self):
50 assert_raises(ValueError, rot90, np.ones(4))
51 assert_raises(ValueError, rot90, np.ones((2,2,2)), axes=(0,1,2))
52 assert_raises(ValueError, rot90, np.ones((2,2)), axes=(0,2))
53 assert_raises(ValueError, rot90, np.ones((2,2)), axes=(1,1))
54 assert_raises(ValueError, rot90, np.ones((2,2,2)), axes=(-2,1))
55
56 a = [[0, 1, 2],
57 [3, 4, 5]]
58 b1 = [[2, 5],
59 [1, 4],
60 [0, 3]]
61 b2 = [[5, 4, 3],
62 [2, 1, 0]]
63 b3 = [[3, 0],
64 [4, 1],
65 [5, 2]]
66 b4 = [[0, 1, 2],
67 [3, 4, 5]]
68
69 for k in range(-3, 13, 4):
70 assert_equal(rot90(a, k=k), b1)
71 for k in range(-2, 13, 4):
72 assert_equal(rot90(a, k=k), b2)
73 for k in range(-1, 13, 4):
74 assert_equal(rot90(a, k=k), b3)
75 for k in range(0, 13, 4):
76 assert_equal(rot90(a, k=k), b4)
77
78 assert_equal(rot90(rot90(a, axes=(0,1)), axes=(1,0)), a)
79 assert_equal(rot90(a, k=1, axes=(1,0)), rot90(a, k=-1, axes=(0,1)))
80
81 def test_axes(self):
82 a = np.ones((50, 40, 3))

Callers

nothing calls this directly

Calls 3

assert_raisesFunction · 0.90
assert_equalFunction · 0.90
rot90Function · 0.90

Tested by

no test coverage detected