From 908778078736bd36f7a60a2d576d415cb8e000fa Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 22 May 2021 07:31:18 +0100 Subject: gentoo resync : 22.05.2021 --- dev-python/numpy/Manifest | 3 +- .../files/numpy-1.20.3-float-hashing-py310.patch | 129 +++++++++++++++++++++ dev-python/numpy/numpy-1.20.3.ebuild | 3 +- 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 dev-python/numpy/files/numpy-1.20.3-float-hashing-py310.patch (limited to 'dev-python/numpy') diff --git a/dev-python/numpy/Manifest b/dev-python/numpy/Manifest index b05ab8a7f266..d4c5625d88de 100644 --- a/dev-python/numpy/Manifest +++ b/dev-python/numpy/Manifest @@ -1,5 +1,6 @@ AUX numpy-1.20.1-no-hardcode-blasv2.patch 2582 BLAKE2B 5057f925a12e6703ab5d9d4c342db80f7f5a7f02a5b5884bd9fac574dcadb9234901b08b1b2ca5bc5ba0345a58e896a241e3a48b4b050b2f5a1063324359d84c SHA512 4418b9c5ed3842848bc06a56ebbd7cd9261657e407775374f2f060944522128d8a5178888def6e4cf42ff6d81082d9cc1425d9553c5334ad4e728d0df9b86bc8 AUX numpy-1.20.2-fix-ccompiler-tests.patch 1616 BLAKE2B 3e2796029854207187322b1061201e7f014472c64d8c66a2dd3f82ec2eed7311f5cc3351d98aeb4b8b75d95608853066a30394e5316bb91e443744f33d66966b SHA512 5ed01b466a0da96b5d7c56b78e420d6c589c48c20053b9da66344384fa93048f90e281d3ed5caa9325f6afe00ff48841b24abc926c75aacb8a6bd5418ed32117 +AUX numpy-1.20.3-float-hashing-py310.patch 4677 BLAKE2B 410438f8b9ba7bc346cd9fbb4d3087d60af6cc54b7ba4a839a1d9559d5b09db623932089ca8c34a70d30622d6260f3bff13fd2d97c94f6af437502f2e5b3c27d SHA512 a7605bf4db0886f4e7d4edd65c7b46d6b47ccb43140555cc86b35c2f003cdf29e8704593d77f7cc551f3be1550af209e7910a95e1421fe45b5d0ea5716d62588 DIST numpy-1.20.2.zip 7756879 BLAKE2B 8b76942e04701e164029b145fed1747de72142ea4f5a8aa7472a01caeeed5e0b5b6d9e543106f9786e231df5a8afe3b7ad9256e69873e4f8876c659114bc494e SHA512 337a66d68c965da06f757a89b58d30b83ec0b2f3c7a3bb39496e5031e50fee6c4f2ec090202c3da9a20613864ea46d032ae75af1de5c33eebe515133ef37d40c DIST numpy-1.20.3.zip 7761912 BLAKE2B a4da49f7c1aadca299acb1b6d92deb4f50b1881c4b131cd389524a88ffc70179b2acdc88235dccd1ffd09879893db45b16bf2f54ced9b9639b806e85f7346285 SHA512 897be1cd6f3880711149dcedd838357e2d937a3c5f36b2a0db6ceed341654acf96b8b775610e1b43bdb6eacb987bbc51aaa8906244ca02cc8c2eae359ccef405 DIST numpy-html-1.16.4.zip 12097069 BLAKE2B db1f897342fbc80a761fbaee7b0eee3761dbfa04ef6c46a137bb2392caaec8256580467ce06498cceeada2639151a1ec75dafab484d64cb897c008727d6d32a5 SHA512 c44c5e1e0cb22f9dd46fe9e302030292d85e567456178fee296746a414271634e906509fb6665ac63fbfebdd13c5383574f0aa47b4fbc639063da31addc3316a @@ -9,5 +10,5 @@ DIST numpy-ref-1.20.3.pdf 7362241 BLAKE2B bf17564d7aea0db25ca9ef6b24dbbd25093c09 DIST numpy-user-1.16.4.pdf 596203 BLAKE2B da3ad1f0ec1c965d20656f73a970911cbb58efa73a5df89e2e6485e0dd763f483e35eea1395ac919bf35d496fb216cee954fc5d31edebc1796a24a2a7a2d12b9 SHA512 3083008547213bfa98ffa5cd8e2cea13f6947f42d83aef61502a2a852b0d5f27d727c76b42d281d7a2f4f76c78e88b12ee3d9b164b39fe1f0213ace7097357d6 DIST numpy-user-1.20.3.pdf 4977046 BLAKE2B 3548463cc878645bb169255d3332681685d0f05e02abf4cfcdd03773826d34f5a25c020240652839867a76258b25ca601ed292462f80bdf18b92ecfb46710487 SHA512 f6c37152228eac1fb69ddfc3a37454066ed678d57f12a587e0edcfe0adb390cc0b470384c2751033f7407bac44df9f69b0da4f3da1c300e6fc02231035ff634c EBUILD numpy-1.20.2.ebuild 3734 BLAKE2B 2a4dd063c94eb074c8ce3f60039710d4426f1f8e0be2be1419af23a791bdee32cb52aaf03084741fdb4d6a849b9e6c4f08aea3d642178361e5d1dd8329ca9f3d SHA512 541e3a324ef2f06236c78b5578a338b0084e1067b2fdd214f95bb579f706e6db91fe00513999deaffd5e7bb4736e49326c8f919e4c1b3b7b8c1dd473364032b9 -EBUILD numpy-1.20.3.ebuild 3620 BLAKE2B cecd9f66ae407dfde773acab8599b03039ec5aebd4cc6d7f7595487a40b4b940ddd4d40ef73b81ee5750037204849ba1d4c22c36cc567f4124bbf041249597be SHA512 607134d85ccd121f581cbedf8f46a0adbe843193a96b9b4341adcd1d0253f154b2be19bdd4a54ab7b4c8daa8c031141d8fdf35aa0be631b0d36a89eb887f7407 +EBUILD numpy-1.20.3.ebuild 3675 BLAKE2B ca4e67e97798cd46444cb49587a6e9549fe8bb67e4ff8f8d1da400ad3b8b03823e767cd936b58ae6abc307e1a2c49857c58e2d2d428fe102e0959f72ca37197a SHA512 cb0a52a6c41db0097413117363d1e243e3b56b13f0d731939f556795f9c68ecd2e274b89ec675e0b6f72100c775e4d92137547527b32e27dc6ecaf0b941495fc MISC metadata.xml 934 BLAKE2B 948b9a948cddc46d20d672992bf73ddb1e59ba18f470acf805c78f561249e7bce2cec1cb1affe63aad447f2f0ad627147cf05ca04ac3c321781255357de92d63 SHA512 404bc31423a1093c19dd535aa3cd5a6b925f4ef1699f9991ae19b46495c46ac4ab3b0b1995f62ea8bc5de15889b975dfcdc416360978508b837d4d5d518dfeeb diff --git a/dev-python/numpy/files/numpy-1.20.3-float-hashing-py310.patch b/dev-python/numpy/files/numpy-1.20.3-float-hashing-py310.patch new file mode 100644 index 000000000000..f3b2ea3ef0ca --- /dev/null +++ b/dev-python/numpy/files/numpy-1.20.3-float-hashing-py310.patch @@ -0,0 +1,129 @@ +From ad2a73c18dcff95d844c382c94ab7f73b5571cf3 Mon Sep 17 00:00:00 2001 +From: Sebastian Berg +Date: Tue, 4 May 2021 17:43:26 -0500 +Subject: [PATCH] MAINT: Adjust NumPy float hashing to Python's slightly + changed hash + +This is necessary, since we use the Python double hash and the +semi-private function to calculate it in Python has a new signature +to return the identity-hash when the value is NaN. + +closes gh-18833, gh-18907 +--- + numpy/core/src/common/npy_pycompat.h | 16 ++++++++++ + numpy/core/src/multiarray/scalartypes.c.src | 13 ++++---- + numpy/core/tests/test_scalarmath.py | 34 +++++++++++++++++++++ + 3 files changed, 57 insertions(+), 6 deletions(-) + +diff --git a/numpy/core/src/common/npy_pycompat.h b/numpy/core/src/common/npy_pycompat.h +index aa0b5c1224d..9e94a971090 100644 +--- a/numpy/core/src/common/npy_pycompat.h ++++ b/numpy/core/src/common/npy_pycompat.h +@@ -3,4 +3,20 @@ + + #include "numpy/npy_3kcompat.h" + ++ ++/* ++ * In Python 3.10a7 (or b1), python started using the identity for the hash ++ * when a value is NaN. See https://bugs.python.org/issue43475 ++ */ ++#if PY_VERSION_HEX > 0x030a00a6 ++#define Npy_HashDouble _Py_HashDouble ++#else ++static NPY_INLINE Py_hash_t ++Npy_HashDouble(PyObject *NPY_UNUSED(identity), double val) ++{ ++ return _Py_HashDouble(val); ++} ++#endif ++ ++ + #endif /* _NPY_COMPAT_H_ */ +diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src +index a001500b0a9..9930f7791d6 100644 +--- a/numpy/core/src/multiarray/scalartypes.c.src ++++ b/numpy/core/src/multiarray/scalartypes.c.src +@@ -3172,7 +3172,7 @@ static npy_hash_t + static npy_hash_t + @lname@_arrtype_hash(PyObject *obj) + { +- return _Py_HashDouble((double) PyArrayScalar_VAL(obj, @name@)); ++ return Npy_HashDouble(obj, (double)PyArrayScalar_VAL(obj, @name@)); + } + + /* borrowed from complex_hash */ +@@ -3180,14 +3180,14 @@ static npy_hash_t + c@lname@_arrtype_hash(PyObject *obj) + { + npy_hash_t hashreal, hashimag, combined; +- hashreal = _Py_HashDouble((double) +- PyArrayScalar_VAL(obj, C@name@).real); ++ hashreal = Npy_HashDouble( ++ obj, (double)PyArrayScalar_VAL(obj, C@name@).real); + + if (hashreal == -1) { + return -1; + } +- hashimag = _Py_HashDouble((double) +- PyArrayScalar_VAL(obj, C@name@).imag); ++ hashimag = Npy_HashDouble( ++ obj, (double)PyArrayScalar_VAL(obj, C@name@).imag); + if (hashimag == -1) { + return -1; + } +@@ -3202,7 +3202,8 @@ c@lname@_arrtype_hash(PyObject *obj) + static npy_hash_t + half_arrtype_hash(PyObject *obj) + { +- return _Py_HashDouble(npy_half_to_double(PyArrayScalar_VAL(obj, Half))); ++ return Npy_HashDouble( ++ obj, npy_half_to_double(PyArrayScalar_VAL(obj, Half))); + } + + static npy_hash_t +diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py +index d91b4a39146..09a734284a7 100644 +--- a/numpy/core/tests/test_scalarmath.py ++++ b/numpy/core/tests/test_scalarmath.py +@@ -712,6 +712,40 @@ def test_shift_all_bits(self, type_code, op): + assert_equal(res_arr, res_scl) + + ++class TestHash: ++ @pytest.mark.parametrize("type_code", np.typecodes['AllInteger']) ++ def test_integer_hashes(self, type_code): ++ scalar = np.dtype(type_code).type ++ for i in range(128): ++ assert hash(i) == hash(scalar(i)) ++ ++ @pytest.mark.parametrize("type_code", np.typecodes['AllFloat']) ++ def test_float_and_complex_hashes(self, type_code): ++ scalar = np.dtype(type_code).type ++ for val in [np.pi, np.inf, 3, 6.]: ++ numpy_val = scalar(val) ++ # Cast back to Python, in case the NumPy scalar has less precision ++ if numpy_val.dtype.kind == 'c': ++ val = complex(numpy_val) ++ else: ++ val = float(numpy_val) ++ assert val == numpy_val ++ print(repr(numpy_val), repr(val)) ++ assert hash(val) == hash(numpy_val) ++ ++ if hash(float(np.nan)) != hash(float(np.nan)): ++ # If Python distinguises different NaNs we do so too (gh-18833) ++ assert hash(scalar(np.nan)) != hash(scalar(np.nan)) ++ ++ @pytest.mark.parametrize("type_code", np.typecodes['Complex']) ++ def test_complex_hashes(self, type_code): ++ # Test some complex valued hashes specifically: ++ scalar = np.dtype(type_code).type ++ for val in [np.pi+1j, np.inf-3j, 3j, 6.+1j]: ++ numpy_val = scalar(val) ++ assert hash(complex(numpy_val)) == hash(numpy_val) ++ ++ + @contextlib.contextmanager + def recursionlimit(n): + o = sys.getrecursionlimit() diff --git a/dev-python/numpy/numpy-1.20.3.ebuild b/dev-python/numpy/numpy-1.20.3.ebuild index 10bbd07b87e7..5b772a58a6f9 100644 --- a/dev-python/numpy/numpy-1.20.3.ebuild +++ b/dev-python/numpy/numpy-1.20.3.ebuild @@ -3,7 +3,7 @@ EAPI=7 -PYTHON_COMPAT=( python3_{7..9} ) +PYTHON_COMPAT=( python3_{7..10} ) PYTHON_REQ_USE="threads(+)" FORTRAN_NEEDED=lapack @@ -46,6 +46,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/numpy-1.20.1-no-hardcode-blasv2.patch "${FILESDIR}"/numpy-1.20.2-fix-ccompiler-tests.patch + "${FILESDIR}"/numpy-1.20.3-float-hashing-py310.patch ) distutils_enable_tests pytest -- cgit v1.2.3