From 1151c095d771dd2e9baaf63e616594313e584089 Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Sat, 28 Aug 2021 10:53:12 +0100 Subject: [PATCH] Hard coded evaluated np.lib.function_base._SIGNATURE --- .../src/hypothesis/extra/_array_helpers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/src/hypothesis/extra/_array_helpers.py b/hypothesis-python/src/hypothesis/extra/_array_helpers.py index 34a768d5ad..c37912c0aa 100644 --- a/hypothesis-python/src/hypothesis/extra/_array_helpers.py +++ b/hypothesis-python/src/hypothesis/extra/_array_helpers.py @@ -300,10 +300,17 @@ def _hypothesis_parse_gufunc_signature(signature, all_checks=True): "anyone who uses them! Please get in touch with us to fix that." f"\n (signature={signature!r})" ) - if re.match("^{0:}->{0:}$".format(_ARGUMENT_LIST), signature): + if re.match( + ( + # Taken from np.lib.function_base._SIGNATURE + r"^\\((?:\\w+(?:,\\w+)*)?\\)(?:,\\((?:\\w+(?:,\\w+)*)?\\))*->" + r"\\((?:\\w+(?:,\\w+)*)?\\)(?:,\\((?:\\w+(?:,\\w+)*)?\\))*$" + ), + signature, + ): raise InvalidArgument( f"signature={signature!r} matches Numpy's regex for gufunc signatures, " - "but contains shapes with more than 32 dimensions and is thus invalid." + f"but contains shapes with more than {NDIM_MAX} dimensions and is thus invalid." ) raise InvalidArgument(f"{signature!r} is not a valid gufunc signature") input_shapes, output_shapes = (