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

Method setup

benchmarks/benchmarks/bench_ufunc_strides.py:18–48  ·  view source on GitHub ↗
(self, ufunc, stride_in0, stride_in1, stride_out, dtype)

Source from the content-addressed store, hash-verified

16 data_zeros = False
17
18 def setup(self, ufunc, stride_in0, stride_in1, stride_out, dtype):
19 ufunc_insig = f'{dtype}{dtype}->'
20 if ufunc_insig+dtype not in ufunc.types:
21 for st_sig in (ufunc_insig, dtype):
22 test = [sig for sig in ufunc.types if sig.startswith(st_sig)]
23 if test:
24 break
25 if not test:
26 raise NotImplementedError(
27 f"Ufunc {ufunc} doesn't support "
28 f"binary input of dtype {dtype}"
29 ) from None
30 tin, tout = test[0].split('->')
31 else:
32 tin = dtype + dtype
33 tout = dtype
34
35 self.ufunc_args = []
36 for i, (dt, stride) in enumerate(zip(tin, (stride_in0, stride_in1))):
37 self.ufunc_args += [get_data(
38 self.arrlen*stride, dt, i,
39 zeros=self.data_zeros,
40 finite=self.data_finite,
41 denormal=self.data_denormal,
42 )[::stride]]
43 for dt in tout:
44 self.ufunc_args += [
45 np.empty(stride_out*self.arrlen, dt)[::stride_out]
46 ]
47
48 np.seterr(all='ignore')
49
50 def time_binary(self, ufunc, stride_in0, stride_in1, stride_out,
51 dtype):

Callers

nothing calls this directly

Calls 3

get_dataFunction · 0.85
startswithMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected