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

Method test_axis

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

Source from the content-addressed store, hash-verified

731 assert_array_equal(diff(x, n=2), out2)
732
733 def test_axis(self):
734 x = np.zeros((10, 20, 30))
735 x[:, 1::2, :] = 1
736 exp = np.ones((10, 19, 30))
737 exp[:, 1::2, :] = -1
738 assert_array_equal(diff(x), np.zeros((10, 20, 29)))
739 assert_array_equal(diff(x, axis=-1), np.zeros((10, 20, 29)))
740 assert_array_equal(diff(x, axis=0), np.zeros((9, 20, 30)))
741 assert_array_equal(diff(x, axis=1), exp)
742 assert_array_equal(diff(x, axis=-2), exp)
743 assert_raises(np.AxisError, diff, x, axis=3)
744 assert_raises(np.AxisError, diff, x, axis=-4)
745
746 x = np.array(1.11111111111, np.float64)
747 assert_raises(ValueError, diff, x)
748
749 def test_nd(self):
750 x = 20 * rand(10, 20, 30)

Callers

nothing calls this directly

Calls 3

assert_array_equalFunction · 0.90
diffFunction · 0.90
assert_raisesFunction · 0.90

Tested by

no test coverage detected