Generate a TypeDescription instance for each item in types
(types, f=None, astype=None, in_=None, out=None, cfunc_alias=None,
dispatch=None)
| 147 | return func_data |
| 148 | |
| 149 | def 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 | |
| 188 | class Ufunc: |
| 189 | """Description of a ufunc. |
no test coverage detected