It looks like the signature= keyword argument to np.vectorize doesn't ignore white space characters (see the reproducer below). Based on the description of gufunc signatures, I would have expected white space to also be ignored in the signature= keyword to np.vectorize.
This was originally noticed in dask/dask#7972
Reproducing code example:
import numpy as np
np.vectorize(np.convolve, signature='(n),(m )->(k)') # NOTE there is a space after `m`
Note that if we remove the space after m, then no error is raised
Error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-0f1af5e625a4> in <module>
----> 1 np.vectorize(np.convolve, signature='(n),(m )->(k)')
~/mambaforge/envs/dask/lib/python3.9/site-packages/numpy/lib/function_base.py in __init__(self, pyfunc, otypes, doc, excluded, cache, signature)
2129
2130 if signature is not None:
-> 2131 self._in_and_out_core_dims = _parse_gufunc_signature(signature)
2132 else:
2133 self._in_and_out_core_dims = None
~/mambaforge/envs/dask/lib/python3.9/site-packages/numpy/lib/function_base.py in _parse_gufunc_signature(signature)
1865 """
1866 if not re.match(_SIGNATURE, signature):
-> 1867 raise ValueError(
1868 'not a valid gufunc signature: {}'.format(signature))
1869 return tuple([tuple(re.findall(_DIMENSION_NAME, arg))
ValueError: not a valid gufunc signature: (n),(m )->(k)
NumPy/Python version information:
In [4]: import sys, numpy; print(numpy.__version__, sys.version)
1.21.1 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:36:15)
[Clang 11.1.0 ]
It looks like the
signature=keyword argument tonp.vectorizedoesn't ignore white space characters (see the reproducer below). Based on the description of gufunc signatures, I would have expected white space to also be ignored in thesignature=keyword tonp.vectorize.This was originally noticed in dask/dask#7972
Reproducing code example:
Note that if we remove the space after
m, then no error is raisedError message:
NumPy/Python version information: