From d0d250a3c9d7d90e75701c32d7d435640e6b02eb Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Wed, 24 Jul 2019 16:19:43 -0700 Subject: REV: "ENH: Improved performance of PyArray_FromAny for sequences of array-like" This reverts commit 71fc59d587016d6f36007ba06e074d4d4a6b483d which was part of gh-13399 and the followup commit ba53a63ee9be7a7bad7685b051a0ef984caa321e from gh-13663. The issue is that we mix Sequence protocol and `__array__` usage when coercing arrays. It seems easiest to revert this for the 1.17.x release and make a larger breaking change in the 1.18.x release cycle. Since this only occurs for stranger array-likes. This revert is limited to the 1.17.x branch for now. --- numpy/core/tests/test_regression.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index d5de0f2b2..3880b1394 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -2484,26 +2484,6 @@ class TestRegression(object): np.array([T()]) - def test_2d__array__shape(self): - class T(object): - def __array__(self): - return np.ndarray(shape=(0,0)) - - # Make sure __array__ is used instead of Sequence methods. - def __iter__(self): - return iter([]) - - def __getitem__(self, idx): - raise AssertionError("__getitem__ was called") - - def __len__(self): - return 0 - - - t = T() - #gh-13659, would raise in broadcasting [x=t for x in result] - np.array([t]) - @pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python') @pytest.mark.skipif(sys.platform == 'win32' and sys.version_info[:2] < (3, 8), reason='overflows on windows, fixed in bpo-16865') -- cgit v1.2.1