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

Method check_function

numpy/core/tests/test_numeric.py:2728–2755  ·  view source on GitHub ↗
(self, func, fill_value=None)

Source from the content-addressed store, hash-verified

2726 self.ndims = 10
2727
2728 def check_function(self, func, fill_value=None):
2729 par = ((0, 1, 2),
2730 range(self.ndims),
2731 self.orders,
2732 self.dtypes)
2733 fill_kwarg = {}
2734 if fill_value is not None:
2735 fill_kwarg = {'fill_value': fill_value}
2736
2737 for size, ndims, order, dtype in itertools.product(*par):
2738 shape = ndims * [size]
2739
2740 # do not fill void type
2741 if fill_kwarg and dtype.str.startswith('|V'):
2742 continue
2743
2744 arr = func(shape, order=order, dtype=dtype,
2745 **fill_kwarg)
2746
2747 assert_equal(arr.dtype, dtype)
2748 assert_(getattr(arr.flags, self.orders[order]))
2749
2750 if fill_value is not None:
2751 if dtype.str.startswith('|S'):
2752 val = str(fill_value)
2753 else:
2754 val = fill_value
2755 assert_equal(arr, dtype.type(val))
2756
2757 def test_zeros(self):
2758 self.check_function(np.zeros)

Callers 4

test_zerosMethod · 0.95
test_onesMethod · 0.95
test_emptyMethod · 0.95
test_fullMethod · 0.95

Calls 4

assert_equalFunction · 0.90
assert_Function · 0.90
startswithMethod · 0.80
funcFunction · 0.50

Tested by

no test coverage detected