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

Method test_basic

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

Source from the content-addressed store, hash-verified

712class TestDiff:
713
714 def test_basic(self):
715 x = [1, 4, 6, 7, 12]
716 out = np.array([3, 2, 1, 5])
717 out2 = np.array([-1, -1, 4])
718 out3 = np.array([0, 5])
719 assert_array_equal(diff(x), out)
720 assert_array_equal(diff(x, n=2), out2)
721 assert_array_equal(diff(x, n=3), out3)
722
723 x = [1.1, 2.2, 3.0, -0.2, -0.1]
724 out = np.array([1.1, 0.8, -3.2, 0.1])
725 assert_almost_equal(diff(x), out)
726
727 x = [True, True, False, False]
728 out = np.array([False, True, False])
729 out2 = np.array([True, True])
730 assert_array_equal(diff(x), out)
731 assert_array_equal(diff(x, n=2), out2)
732
733 def test_axis(self):
734 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