|
| 1 | +From 8b298aa6f666449fff1844253cd6e0be5fbf3612 Mon Sep 17 00:00:00 2001 |
| 2 | +From: ryanking13 < [email protected]> |
| 3 | +Date: Sun, 11 May 2025 11:05:05 +0900 |
| 4 | +Subject: [PATCH 1/1] TST: Prevent import error when tests are not included in |
| 5 | + |
| 6 | +https://github.com/numpy/numpy/pull/28936 |
| 7 | + |
| 8 | +--- |
| 9 | + numpy/_core/tests/_natype.py | 7 +++++++ |
| 10 | + numpy/conftest.py | 4 ++-- |
| 11 | + numpy/testing/_private/utils.py | 9 --------- |
| 12 | + 3 files changed, 9 insertions(+), 11 deletions(-) |
| 13 | + |
| 14 | +diff --git a/numpy/_core/tests/_natype.py b/numpy/_core/tests/_natype.py |
| 15 | +index e529e548cf..86eb68801d 100644 |
| 16 | +--- a/numpy/_core/tests/_natype.py |
| 17 | ++++ b/numpy/_core/tests/_natype.py |
| 18 | +@@ -196,3 +196,10 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): |
| 19 | + |
| 20 | + |
| 21 | + pd_NA = NAType() |
| 22 | ++ |
| 23 | ++def get_stringdtype_dtype(na_object, coerce=True): |
| 24 | ++ # explicit is check for pd_NA because != with pd_NA returns pd_NA |
| 25 | ++ if na_object is pd_NA or na_object != "unset": |
| 26 | ++ return np.dtypes.StringDType(na_object=na_object, coerce=coerce) |
| 27 | ++ else: |
| 28 | ++ return np.dtypes.StringDType(coerce=coerce) |
| 29 | +\ No newline at end of file |
| 30 | +diff --git a/numpy/conftest.py b/numpy/conftest.py |
| 31 | +index 0eb42d1103..5105b43b03 100644 |
| 32 | +--- a/numpy/conftest.py |
| 33 | ++++ b/numpy/conftest.py |
| 34 | +@@ -14,8 +14,8 @@ |
| 35 | + import numpy as np |
| 36 | + |
| 37 | + from numpy._core._multiarray_tests import get_fpu_mode |
| 38 | +-from numpy._core.tests._natype import pd_NA |
| 39 | +-from numpy.testing._private.utils import NOGIL_BUILD, get_stringdtype_dtype |
| 40 | ++from numpy._core.tests._natype import pd_NA, get_stringdtype_dtype |
| 41 | ++from numpy.testing._private.utils import NOGIL_BUILD |
| 42 | + |
| 43 | + try: |
| 44 | + from scipy_doctest.conftest import dt_config |
| 45 | +diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py |
| 46 | +index 42e43e21f3..a1a6f4f1ff 100644 |
| 47 | +--- a/numpy/testing/_private/utils.py |
| 48 | ++++ b/numpy/testing/_private/utils.py |
| 49 | +@@ -28,7 +28,6 @@ |
| 50 | + from numpy import isfinite, isnan, isinf |
| 51 | + import numpy.linalg._umath_linalg |
| 52 | + from numpy._utils import _rename_parameter |
| 53 | +-from numpy._core.tests._natype import pd_NA |
| 54 | + |
| 55 | + from io import StringIO |
| 56 | + |
| 57 | +@@ -2750,11 +2749,3 @@ def run_threaded(func, max_workers=8, pass_count=False, |
| 58 | + barrier.abort() |
| 59 | + for f in futures: |
| 60 | + f.result() |
| 61 | +- |
| 62 | +- |
| 63 | +-def get_stringdtype_dtype(na_object, coerce=True): |
| 64 | +- # explicit is check for pd_NA because != with pd_NA returns pd_NA |
| 65 | +- if na_object is pd_NA or na_object != "unset": |
| 66 | +- return np.dtypes.StringDType(na_object=na_object, coerce=coerce) |
| 67 | +- else: |
| 68 | +- return np.dtypes.StringDType(coerce=coerce) |
| 69 | +-- |
| 70 | +2.29.2.windows.2 |
| 71 | + |
0 commit comments