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

Function TD

numpy/core/code_generators/generate_umath.py:149–186  ·  view source on GitHub ↗

Generate a TypeDescription instance for each item in types

(types, f=None, astype=None, in_=None, out=None, cfunc_alias=None,
       dispatch=None)

Source from the content-addressed store, hash-verified

147 return func_data
148
149def TD(types, f=None, astype=None, in_=None, out=None, cfunc_alias=None,
150 dispatch=None):
151 """
152 Generate a TypeDescription instance for each item in types
153 """
154 if f is not None:
155 if isinstance(f, str):
156 func_data = build_func_data(types, f)
157 elif len(f) != len(types):
158 raise ValueError("Number of types and f do not match")
159 else:
160 func_data = f
161 else:
162 func_data = (None,) * len(types)
163 if isinstance(in_, str):
164 in_ = (in_,) * len(types)
165 elif in_ is None:
166 in_ = (None,) * len(types)
167 elif len(in_) != len(types):
168 raise ValueError("Number of types and inputs do not match")
169 if isinstance(out, str):
170 out = (out,) * len(types)
171 elif out is None:
172 out = (None,) * len(types)
173 elif len(out) != len(types):
174 raise ValueError("Number of types and outputs do not match")
175 tds = []
176 for t, fd, i, o in zip(types, func_data, in_, out):
177 # [(dispatch file name without extension '.dispatch.c*', list of types)]
178 if dispatch:
179 dispt = ([k for k, v in dispatch if t in v]+[None])[0]
180 else:
181 dispt = None
182 tds.append(TypeDescription(
183 t, f=fd, in_=i, out=o, astype=astype, cfunc_alias=cfunc_alias,
184 dispatch=dispt
185 ))
186 return tds
187
188class Ufunc:
189 """Description of a ufunc.

Callers 1

generate_umath.pyFile · 0.85

Calls 2

build_func_dataFunction · 0.85
TypeDescriptionClass · 0.85

Tested by

no test coverage detected