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

Method setup

benchmarks/benchmarks/bench_ufunc_strides.py:71–97  ·  view source on GitHub ↗
(self, ufunc, stride_in, stride_out, dtype)

Source from the content-addressed store, hash-verified

69 data_zeros = False
70
71 def setup(self, ufunc, stride_in, stride_out, dtype):
72 arr_in = get_data(
73 stride_in*self.arrlen, dtype,
74 zeros=self.data_zeros,
75 finite=self.data_finite,
76 denormal=self.data_denormal,
77 )
78 self.ufunc_args = [arr_in[::stride_in]]
79
80 ufunc_insig = f'{dtype}->'
81 if ufunc_insig+dtype not in ufunc.types:
82 test = [sig for sig in ufunc.types if sig.startswith(ufunc_insig)]
83 if not test:
84 raise NotImplementedError(
85 f"Ufunc {ufunc} doesn't support "
86 f"unary input of dtype {dtype}"
87 ) from None
88 tout = test[0].split('->')[1]
89 else:
90 tout = dtype
91
92 for dt in tout:
93 self.ufunc_args += [
94 np.empty(stride_out*self.arrlen, dt)[::stride_out]
95 ]
96
97 np.seterr(all='ignore')
98
99 def time_unary(self, ufunc, stride_in, stride_out, dtype):
100 ufunc(*self.ufunc_args)

Callers

nothing calls this directly

Calls 3

get_dataFunction · 0.85
startswithMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected