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