From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F179D15817D for ; Mon, 10 Jun 2024 14:41:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 704D6E2B01; Mon, 10 Jun 2024 14:41:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 49AECE2B01 for ; Mon, 10 Jun 2024 14:41:48 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3D8F733BF29 for ; Mon, 10 Jun 2024 14:41:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9492A1C56 for ; Mon, 10 Jun 2024 14:41:45 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1718030496.c42eca470bc5f0f48fc90ab03865f5707c52510a.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/jsonpickle/, dev-python/jsonpickle/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/jsonpickle/files/jsonpickle-3.2.1-numpy-2.patch dev-python/jsonpickle/jsonpickle-3.2.1.ebuild X-VCS-Directories: dev-python/jsonpickle/ dev-python/jsonpickle/files/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: c42eca470bc5f0f48fc90ab03865f5707c52510a X-VCS-Branch: master Date: Mon, 10 Jun 2024 14:41:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5391f8aa-0d52-4b8b-a569-278a9754f146 X-Archives-Hash: 4058d4227c64250287a746113e720f07 commit: c42eca470bc5f0f48fc90ab03865f5707c52510a Author: Michał Górny gentoo org> AuthorDate: Mon Jun 10 14:22:59 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon Jun 10 14:41:36 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c42eca47 dev-python/jsonpickle: Add a numpy-2 patch Signed-off-by: Michał Górny gentoo.org> .../files/jsonpickle-3.2.1-numpy-2.patch | 157 +++++++++++++++++++++ dev-python/jsonpickle/jsonpickle-3.2.1.ebuild | 8 +- 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/dev-python/jsonpickle/files/jsonpickle-3.2.1-numpy-2.patch b/dev-python/jsonpickle/files/jsonpickle-3.2.1-numpy-2.patch new file mode 100644 index 000000000000..6fdc989d990e --- /dev/null +++ b/dev-python/jsonpickle/files/jsonpickle-3.2.1-numpy-2.patch @@ -0,0 +1,157 @@ +From 0ab3cf0ffcdb364a8a75e71acfb267e5aaabc0a0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Mon, 10 Jun 2024 03:55:47 +0200 +Subject: [PATCH 1/2] Fix data types in tests for NumPy 2 + +Fix a number of test compatibility issues with NumPy 2. That is: + +- replace `np.float_` with `np.float64`, +- replace `np.complex_` with `np.complex128`, +- remove `np.unicode_` as equivalent to `np.str_`. + +The LHS types are also aliases to the RHS types in NumPy 1.x, so this +is NFC on NumPy 1.x. These aliases were removed in 2.x, so the code +needs to be updated for tests to pass on NumPy 2.x. +--- + tests/numpy_test.py | 7 ++----- + tests/pandas_test.py | 13 +++++-------- + 2 files changed, 7 insertions(+), 13 deletions(-) + +diff --git a/tests/numpy_test.py b/tests/numpy_test.py +index e271725..dd50d5e 100644 +--- a/tests/numpy_test.py ++++ b/tests/numpy_test.py +@@ -32,9 +32,7 @@ def test_dtype_roundtrip(): + dtypes = [ + np.int_, + np.int32, +- np.float_, + np.float64, +- np.complex_, + np.complex128, + np.str_, + np.object_, +@@ -86,15 +84,14 @@ def test_generic_roundtrip(): + values = [ + np.int_(1), + np.int32(-2), +- np.float_(2.5), ++ np.float64(2.5), + np.nan, + -np.inf, + np.inf, + np.datetime64('2014-01-01'), + np.str_('foo'), +- np.unicode_('bar'), + np.object_({'a': 'b'}), +- np.complex_(1 - 2j), ++ np.complex128(1 - 2j), + ] + for value in values: + decoded = roundtrip(value) +diff --git a/tests/pandas_test.py b/tests/pandas_test.py +index 532563f..414bd65 100644 +--- a/tests/pandas_test.py ++++ b/tests/pandas_test.py +@@ -34,14 +34,13 @@ def test_series_roundtrip(): + ser = pd.Series( + { + 'an_int': np.int_(1), +- 'a_float': np.float_(2.5), ++ 'a_float': np.float64(2.5), + 'a_nan': np.nan, + 'a_minus_inf': -np.inf, + 'an_inf': np.inf, + 'a_str': np.str_('foo'), +- 'a_unicode': np.unicode_('bar'), + 'date': np.datetime64('2014-01-01'), +- 'complex': np.complex_(1 - 2j), ++ 'complex': np.complex128(1 - 2j), + # TODO: the following dtypes are not currently supported. + # 'object': np.object_({'a': 'b'}), + } +@@ -54,14 +53,13 @@ def test_dataframe_roundtrip(): + df = pd.DataFrame( + { + 'an_int': np.int_([1, 2, 3]), +- 'a_float': np.float_([2.5, 3.5, 4.5]), ++ 'a_float': np.float64([2.5, 3.5, 4.5]), + 'a_nan': np.array([np.nan] * 3), + 'a_minus_inf': np.array([-np.inf] * 3), + 'an_inf': np.array([np.inf] * 3), + 'a_str': np.str_('foo'), +- 'a_unicode': np.unicode_('bar'), + 'date': np.array([np.datetime64('2014-01-01')] * 3, dtype="datetime64[s]"), +- 'complex': np.complex_([1 - 2j, 2 - 1.2j, 3 - 1.3j]), ++ 'complex': np.complex128([1 - 2j, 2 - 1.2j, 3 - 1.3j]), + # TODO: the following dtypes are not currently supported. + # 'object': np.object_([{'a': 'b'}]*3), + } +@@ -76,12 +74,11 @@ def test_multindex_dataframe_roundtrip(): + 'idx_lvl0': ['a', 'b', 'c'], + 'idx_lvl1': np.int_([1, 1, 2]), + 'an_int': np.int_([1, 2, 3]), +- 'a_float': np.float_([2.5, 3.5, 4.5]), ++ 'a_float': np.float64([2.5, 3.5, 4.5]), + 'a_nan': np.array([np.nan] * 3), + 'a_minus_inf': np.array([-np.inf] * 3), + 'an_inf': np.array([np.inf] * 3), + 'a_str': np.str_('foo'), +- 'a_unicode': np.unicode_('bar'), + } + ) + df = df.set_index(['idx_lvl0', 'idx_lvl1']) + +From 8bc2bdd42bc111d90edbcef8005640d5a51627bf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Mon, 10 Jun 2024 04:02:17 +0200 +Subject: [PATCH 2/2] Fix `newbyteorder()` use for NumPy 2.x + +Replace the `arr.newbyteorder()` use with: + + arr.view(arr.dtype.newbyteorder()) + +as suggested in the exception that's raised when the tests are run +in NumPy 2.x. With this change, the code works both with NumPy 1.x +and NumPy 2.x. +--- + tests/numpy_test.py | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/tests/numpy_test.py b/tests/numpy_test.py +index dd50d5e..2e6725b 100644 +--- a/tests/numpy_test.py ++++ b/tests/numpy_test.py +@@ -306,18 +306,22 @@ def test_immutable(): + def test_byteorder(): + """Test the byteorder for text and binary encodings""" + # small arr is stored as text +- a = np.arange(10).newbyteorder() +- b = a[:].newbyteorder() +- _a, _b = roundtrip([a, b]) +- npt.assert_array_equal(a, _a) +- npt.assert_array_equal(b, _b) ++ a = np.arange(10) ++ av = a.view(a.dtype.newbyteorder()) ++ b = a[:] ++ bv = b.view(b.dtype.newbyteorder()) ++ _av, _bv = roundtrip([av, bv]) ++ npt.assert_array_equal(av, _av) ++ npt.assert_array_equal(bv, _bv) + + # bigger arr is stored as binary +- a = np.arange(100).newbyteorder() +- b = a[:].newbyteorder() +- _a, _b = roundtrip([a, b]) +- npt.assert_array_equal(a, _a) +- npt.assert_array_equal(b, _b) ++ a = np.arange(100) ++ av = a.view(a.dtype.newbyteorder()) ++ b = a[:] ++ bv = b.view(b.dtype.newbyteorder()) ++ _av, _bv = roundtrip([av, bv]) ++ npt.assert_array_equal(av, _av) ++ npt.assert_array_equal(bv, _bv) + + + def test_zero_dimensional_array(): diff --git a/dev-python/jsonpickle/jsonpickle-3.2.1.ebuild b/dev-python/jsonpickle/jsonpickle-3.2.1.ebuild index 3bed0a414fd2..155b209d25ad 100644 --- a/dev-python/jsonpickle/jsonpickle-3.2.1.ebuild +++ b/dev-python/jsonpickle/jsonpickle-3.2.1.ebuild @@ -38,8 +38,14 @@ BDEPEND=" distutils_enable_tests pytest python_prepare_all() { - sed -i -e 's:--cov::' pytest.ini || die + local PATCHES=( + # https://github.com/jsonpickle/jsonpickle/pull/512 + "${FILESDIR}/${P}-numpy-2.patch" + ) + distutils-r1_python_prepare_all + + sed -i -e 's:--cov::' pytest.ini || die export SETUPTOOLS_SCM_PRETEND_VERSION=${PV} }