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

Method _test_gcd_inner

numpy/core/tests/test_umath.py:3998–4017  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

3996 assert_equal(np.lcm(a, b), [0, 20, 20, 60, 20, 20])
3997
3998 def _test_gcd_inner(self, dtype):
3999 # basic use
4000 a = np.array([12, 120], dtype=dtype)
4001 b = np.array([20, 200], dtype=dtype)
4002 assert_equal(np.gcd(a, b), [4, 40])
4003
4004 if not issubclass(dtype, np.unsignedinteger):
4005 # negatives are ignored
4006 a = np.array([12, -12, 12, -12], dtype=dtype)
4007 b = np.array([20, 20, -20, -20], dtype=dtype)
4008 assert_equal(np.gcd(a, b), [4]*4)
4009
4010 # reduce
4011 a = np.array([15, 25, 35], dtype=dtype)
4012 assert_equal(np.gcd.reduce(a), 5)
4013
4014 # broadcasting, and a test including 0
4015 a = np.arange(6).astype(dtype)
4016 b = 20
4017 assert_equal(np.gcd(a, b), [20, 1, 2, 1, 4, 5])
4018
4019 def test_lcm_overflow(self):
4020 # verify that we don't overflow when a*b does overflow

Callers 2

test_gcdMethod · 0.95
test_gcd_objectMethod · 0.95

Calls 3

assert_equalFunction · 0.90
astypeMethod · 0.80
reduceMethod · 0.45

Tested by

no test coverage detected