MCPcopy
hub / github.com/numpy/numpy / test_prepend

Method test_prepend

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

Source from the content-addressed store, hash-verified

932 assert_(type(out3) is type(x))
933
934 def test_prepend(self):
935 x = np.arange(5) + 1
936 assert_array_equal(diff(x, prepend=0), np.ones(5))
937 assert_array_equal(diff(x, prepend=[0]), np.ones(5))
938 assert_array_equal(np.cumsum(np.diff(x, prepend=0)), x)
939 assert_array_equal(diff(x, prepend=[-1, 0]), np.ones(6))
940
941 x = np.arange(4).reshape(2, 2)
942 result = np.diff(x, axis=1, prepend=0)
943 expected = [[0, 1], [2, 1]]
944 assert_array_equal(result, expected)
945 result = np.diff(x, axis=1, prepend=[[0], [0]])
946 assert_array_equal(result, expected)
947
948 result = np.diff(x, axis=0, prepend=0)
949 expected = [[0, 1], [2, 2]]
950 assert_array_equal(result, expected)
951 result = np.diff(x, axis=0, prepend=[[0, 0]])
952 assert_array_equal(result, expected)
953
954 assert_raises(ValueError, np.diff, x, prepend=np.zeros((3, 3)))
955
956 assert_raises(AxisError, diff, x, prepend=0, axis=3)
957
958 def test_append(self):
959 x = np.arange(5)

Callers

nothing calls this directly

Calls 5

assert_array_equalFunction · 0.90
diffFunction · 0.90
assert_raisesFunction · 0.90
cumsumMethod · 0.80
reshapeMethod · 0.80

Tested by

no test coverage detected