MCPcopy Index your code
hub / github.com/numpy/numpy / test_basic

Method test_basic

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

Source from the content-addressed store, hash-verified

84
85class TestRot90:
86 def test_basic(self):
87 assert_raises(ValueError, rot90, np.ones(4))
88 assert_raises(ValueError, rot90, np.ones((2, 2, 2)), axes=(0, 1, 2))
89 assert_raises(ValueError, rot90, np.ones((2, 2)), axes=(0, 2))
90 assert_raises(ValueError, rot90, np.ones((2, 2)), axes=(1, 1))
91 assert_raises(ValueError, rot90, np.ones((2, 2, 2)), axes=(-2, 1))
92
93 a = [[0, 1, 2],
94 [3, 4, 5]]
95 b1 = [[2, 5],
96 [1, 4],
97 [0, 3]]
98 b2 = [[5, 4, 3],
99 [2, 1, 0]]
100 b3 = [[3, 0],
101 [4, 1],
102 [5, 2]]
103 b4 = [[0, 1, 2],
104 [3, 4, 5]]
105
106 for k in range(-3, 13, 4):
107 assert_equal(rot90(a, k=k), b1)
108 for k in range(-2, 13, 4):
109 assert_equal(rot90(a, k=k), b2)
110 for k in range(-1, 13, 4):
111 assert_equal(rot90(a, k=k), b3)
112 for k in range(0, 13, 4):
113 assert_equal(rot90(a, k=k), b4)
114
115 assert_equal(rot90(rot90(a, axes=(0, 1)), axes=(1, 0)), a)
116 assert_equal(rot90(a, k=1, axes=(1, 0)), rot90(a, k=-1, axes=(0, 1)))
117
118 def test_axes(self):
119 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