From 581e87fdd1110bfeab0c461111c77460572634d1 Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Thu, 22 Jun 2023 15:41:45 +0200 Subject: [PATCH] MNT support array functions in numpy>=1.25 --- skops/io/_numpy.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/skops/io/_numpy.py b/skops/io/_numpy.py index ec474ec4..fb0dd80d 100644 --- a/skops/io/_numpy.py +++ b/skops/io/_numpy.py @@ -256,6 +256,17 @@ def _construct(self): (np.random.RandomState, random_state_get_state), (np.random.Generator, random_generator_get_state), ] + +try: + # From numpy=1.25.0 dispatching for `__array_function__` is done via + # a C wrapper: https://github.com/numpy/numpy/pull/23020 + from numpy.core._multiarray_umath import _ArrayFunctionDispatcher + + GET_STATE_DISPATCH_FUNCTIONS.append((_ArrayFunctionDispatcher, function_get_state)) +except ImportError: + pass + + # tuples of type and function that creates the instance of that type NODE_TYPE_MAPPING = { ("NdArrayNode", PROTOCOL): NdArrayNode,