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

Method test_basic

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

Source from the content-addressed store, hash-verified

847class TestDiff:
848
849 def test_basic(self):
850 x = [1, 4, 6, 7, 12]
851 out = np.array([3, 2, 1, 5])
852 out2 = np.array([-1, -1, 4])
853 out3 = np.array([0, 5])
854 assert_array_equal(diff(x), out)
855 assert_array_equal(diff(x, n=2), out2)
856 assert_array_equal(diff(x, n=3), out3)
857
858 x = [1.1, 2.2, 3.0, -0.2, -0.1]
859 out = np.array([1.1, 0.8, -3.2, 0.1])
860 assert_almost_equal(diff(x), out)
861
862 x = [True, True, False, False]
863 out = np.array([False, True, False])
864 out2 = np.array([True, True])
865 assert_array_equal(diff(x), out)
866 assert_array_equal(diff(x, n=2), out2)
867
868 def test_axis(self):
869 x = np.zeros((10, 20, 30))

Callers

nothing calls this directly

Calls 3

assert_array_equalFunction · 0.90
diffFunction · 0.90
assert_almost_equalFunction · 0.90

Tested by

no test coverage detected