diff options
author | Ankit Dwivedi <adwivedi@microsoft.com> | 2021-08-07 06:09:47 +0000 |
---|---|---|
committer | Ankit Dwivedi <adwivedi@microsoft.com> | 2021-08-07 06:09:47 +0000 |
commit | 943729592b380dc58368b6774ad7baa53469466c (patch) | |
tree | b11151cb9a77176fcd6253a1612b029269ed25d3 /numpy/lib/function_base.py | |
parent | 82ce76c0e7011f4cd88fb4cc5be7b83f8a07f3c9 (diff) | |
download | numpy-943729592b380dc58368b6774ad7baa53469466c.tar.gz |
ignore whitespaces while parsing gufunc signatures
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b43a1d666..93aea46c7 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1844,9 +1844,9 @@ def disp(mesg, device=None, linefeed=True): # See https://docs.scipy.org/doc/numpy/reference/c-api.generalized-ufuncs.html -_DIMENSION_NAME = r'\w+' +_DIMENSION_NAME = r'\s*\w+\s*' _CORE_DIMENSION_LIST = '(?:{0:}(?:,{0:})*)?'.format(_DIMENSION_NAME) -_ARGUMENT = r'\({}\)'.format(_CORE_DIMENSION_LIST) +_ARGUMENT = r'\s*\({}\s*\)\s*'.format(_CORE_DIMENSION_LIST) _ARGUMENT_LIST = '{0:}(?:,{0:})*'.format(_ARGUMENT) _SIGNATURE = '^{0:}->{0:}$'.format(_ARGUMENT_LIST) @@ -1869,7 +1869,7 @@ def _parse_gufunc_signature(signature): if not re.match(_SIGNATURE, signature): raise ValueError( 'not a valid gufunc signature: {}'.format(signature)) - return tuple([tuple(re.findall(_DIMENSION_NAME, arg)) + return tuple([tuple([dim.strip() for dim in re.findall(_DIMENSION_NAME, arg)]) for arg in re.findall(_ARGUMENT, arg_list)] for arg_list in signature.split('->')) |