A version of `_fromnxfunction` that is called with multiple array arguments. Similar to `_fromnxfunction_args` except that all args are converted to arrays even if they are not so already. This makes it possible to process scalars as 1-D arrays. Only keyword arguments are passed
| 317 | |
| 318 | |
| 319 | class _fromnxfunction_allargs(_fromnxfunction): |
| 320 | """ |
| 321 | A version of `_fromnxfunction` that is called with multiple array |
| 322 | arguments. Similar to `_fromnxfunction_args` except that all args |
| 323 | are converted to arrays even if they are not so already. This makes |
| 324 | it possible to process scalars as 1-D arrays. Only keyword arguments |
| 325 | are passed through verbatim for the data and mask calls. Arrays |
| 326 | arguments are processed independently and the results are returned |
| 327 | in a list. If only one arg is present, the return value is just the |
| 328 | processed array instead of a list. |
| 329 | """ |
| 330 | def __call__(self, *args, **params): |
| 331 | func = getattr(np, self.__name__) |
| 332 | res = [] |
| 333 | for x in args: |
| 334 | _d = func(np.asarray(x), **params) |
| 335 | _m = func(getmaskarray(x), **params) |
| 336 | res.append(masked_array(_d, mask=_m)) |
| 337 | if len(args) == 1: |
| 338 | return res[0] |
| 339 | return res |
| 340 | |
| 341 | |
| 342 | atleast_1d = _fromnxfunction_allargs('atleast_1d') |