Test failure fixed upstream

This commit is contained in:
Susi Lehtola 2022-02-09 16:56:46 +00:00
parent f3aef2af07
commit 333c4725c8
2 changed files with 176 additions and 0 deletions

173
3682.patch Normal file
View File

@ -0,0 +1,173 @@
From 116f8c7db5a11d0e1e7830de3f2bbf3e5ed1316c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Thu, 3 Feb 2022 17:41:45 +0100
Subject: [PATCH 1/2] test: Strip whitespace when comparing numpy dtypes for
1.22 compat
Strip whitespace when comparing numpy dtype str() in order to preserve
test compatibility with both numpy 1.22 and older versions whose output
differ by whitespace.
Fixes #3680
---
tests/test_numpy_dtypes.py | 44 +++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/tests/test_numpy_dtypes.py b/tests/test_numpy_dtypes.py
index 06e578329e..43480334aa 100644
--- a/tests/test_numpy_dtypes.py
+++ b/tests/test_numpy_dtypes.py
@@ -32,8 +32,8 @@ def dt_fmt():
e = "<" if byteorder == "little" else ">"
return (
"{{'names':['bool_','uint_','float_','ldbl_'],"
- " 'formats':['?','" + e + "u4','" + e + "f4','" + e + "f{}'],"
- " 'offsets':[0,4,8,{}], 'itemsize':{}}}"
+ "'formats':['?','" + e + "u4','" + e + "f4','" + e + "f{}'],"
+ "'offsets':[0,4,8,{}],'itemsize':{}}}"
)
@@ -46,7 +46,7 @@ def simple_dtype_fmt():
def packed_dtype_fmt():
from sys import byteorder
- return "[('bool_', '?'), ('uint_', '{e}u4'), ('float_', '{e}f4'), ('ldbl_', '{e}f{}')]".format(
+ return "[('bool_','?'),('uint_','{e}u4'),('float_','{e}f4'),('ldbl_','{e}f{}')]".format(
np.dtype("longdouble").itemsize, e="<" if byteorder == "little" else ">"
)
@@ -77,7 +77,7 @@ def partial_nested_fmt():
partial_size = partial_ld_off + ld.itemsize
partial_end_padding = partial_size % np.dtype("uint64").alignment
partial_nested_size = partial_nested_off * 2 + partial_size + partial_end_padding
- return "{{'names':['a'], 'formats':[{}], 'offsets':[{}], 'itemsize':{}}}".format(
+ return "{{'names':['a'],'formats':[{}],'offsets':[{}],'itemsize':{}}}".format(
partial_dtype_fmt(), partial_nested_off, partial_nested_size
)
@@ -123,25 +123,25 @@ def test_dtype(simple_dtype):
e = "<" if byteorder == "little" else ">"
- assert m.print_dtypes() == [
+ assert [x.replace(' ', '') for x in m.print_dtypes()] == [
simple_dtype_fmt(),
packed_dtype_fmt(),
- "[('a', {}), ('b', {})]".format(simple_dtype_fmt(), packed_dtype_fmt()),
+ "[('a',{}),('b',{})]".format(simple_dtype_fmt(), packed_dtype_fmt()),
partial_dtype_fmt(),
partial_nested_fmt(),
- "[('a', 'S3'), ('b', 'S3')]",
+ "[('a','S3'),('b','S3')]",
(
- "{{'names':['a','b','c','d'], "
- + "'formats':[('S4', (3,)),('"
+ "{{'names':['a','b','c','d'],"
+ + "'formats':[('S4',(3,)),('"
+ e
- + "i4', (2,)),('u1', (3,)),('"
+ + "i4',(2,)),('u1',(3,)),('"
+ e
- + "f4', (4, 2))], "
- + "'offsets':[0,12,20,24], 'itemsize':56}}"
+ + "f4',(4,2))],"
+ + "'offsets':[0,12,20,24],'itemsize':56}}"
).format(e=e),
- "[('e1', '" + e + "i8'), ('e2', 'u1')]",
- "[('x', 'i1'), ('y', '" + e + "u8')]",
- "[('cflt', '" + e + "c8'), ('cdbl', '" + e + "c16')]",
+ "[('e1','" + e + "i8'),('e2','u1')]",
+ "[('x','i1'),('y','" + e + "u8')]",
+ "[('cflt','" + e + "c8'),('cdbl','" + e + "c16')]",
]
d1 = np.dtype(
@@ -238,7 +238,7 @@ def test_recarray(simple_dtype, packed_dtype):
]
arr = m.create_rec_partial(3)
- assert str(arr.dtype) == partial_dtype_fmt()
+ assert str(arr.dtype).replace(' ', '') == partial_dtype_fmt()
partial_dtype = arr.dtype
assert "" not in arr.dtype.fields
assert partial_dtype.itemsize > simple_dtype.itemsize
@@ -246,7 +246,7 @@ def test_recarray(simple_dtype, packed_dtype):
assert_equal(arr, elements, packed_dtype)
arr = m.create_rec_partial_nested(3)
- assert str(arr.dtype) == partial_nested_fmt()
+ assert str(arr.dtype).replace(' ', '') == partial_nested_fmt()
assert "" not in arr.dtype.fields
assert "" not in arr.dtype.fields["a"][0].fields
assert arr.dtype.itemsize > partial_dtype.itemsize
@@ -285,12 +285,12 @@ def test_array_array():
e = "<" if byteorder == "little" else ">"
arr = m.create_array_array(3)
- assert str(arr.dtype) == (
- "{{'names':['a','b','c','d'], "
- + "'formats':[('S4', (3,)),('"
+ assert str(arr.dtype).replace(' ', '') == (
+ "{{'names':['a','b','c','d'],"
+ + "'formats':[('S4',(3,)),('"
+ e
- + "i4', (2,)),('u1', (3,)),('{e}f4', (4, 2))], "
- + "'offsets':[0,12,20,24], 'itemsize':56}}"
+ + "i4',(2,)),('u1',(3,)),('{e}f4',(4,2))],"
+ + "'offsets':[0,12,20,24],'itemsize':56}}"
).format(e=e)
assert m.print_array_array(arr) == [
"a={{A,B,C,D},{K,L,M,N},{U,V,W,X}},b={0,1},"
From 2c4a1e98e56a257fbc8dd0e8644181acd6d7e5a7 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Thu, 3 Feb 2022 16:45:33 +0000
Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
tests/test_numpy_dtypes.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/test_numpy_dtypes.py b/tests/test_numpy_dtypes.py
index 43480334aa..0098eccb87 100644
--- a/tests/test_numpy_dtypes.py
+++ b/tests/test_numpy_dtypes.py
@@ -123,7 +123,7 @@ def test_dtype(simple_dtype):
e = "<" if byteorder == "little" else ">"
- assert [x.replace(' ', '') for x in m.print_dtypes()] == [
+ assert [x.replace(" ", "") for x in m.print_dtypes()] == [
simple_dtype_fmt(),
packed_dtype_fmt(),
"[('a',{}),('b',{})]".format(simple_dtype_fmt(), packed_dtype_fmt()),
@@ -238,7 +238,7 @@ def test_recarray(simple_dtype, packed_dtype):
]
arr = m.create_rec_partial(3)
- assert str(arr.dtype).replace(' ', '') == partial_dtype_fmt()
+ assert str(arr.dtype).replace(" ", "") == partial_dtype_fmt()
partial_dtype = arr.dtype
assert "" not in arr.dtype.fields
assert partial_dtype.itemsize > simple_dtype.itemsize
@@ -246,7 +246,7 @@ def test_recarray(simple_dtype, packed_dtype):
assert_equal(arr, elements, packed_dtype)
arr = m.create_rec_partial_nested(3)
- assert str(arr.dtype).replace(' ', '') == partial_nested_fmt()
+ assert str(arr.dtype).replace(" ", "") == partial_nested_fmt()
assert "" not in arr.dtype.fields
assert "" not in arr.dtype.fields["a"][0].fields
assert arr.dtype.itemsize > partial_dtype.itemsize
@@ -285,7 +285,7 @@ def test_array_array():
e = "<" if byteorder == "little" else ">"
arr = m.create_array_array(3)
- assert str(arr.dtype).replace(' ', '') == (
+ assert str(arr.dtype).replace(" ", "") == (
"{{'names':['a','b','c','d'],"
+ "'formats':[('S4',(3,)),('"
+ e

View File

@ -25,6 +25,8 @@ Source0: https://github.com/pybind/pybind11/archive/v%{version}/%{name}-%{versio
# Patch out header path # Patch out header path
Patch1: pybind11-2.8.1-hpath.patch Patch1: pybind11-2.8.1-hpath.patch
# Patch to fix tests for newer numpy
Patch2: https://github.com/pybind/pybind11/pull/3682.patch
BuildRequires: make BuildRequires: make
%if %{python2_enabled} %if %{python2_enabled}
@ -108,6 +110,7 @@ This package contains the Python 3 files.
%prep %prep
%setup -q %setup -q
%patch1 -p1 -b .hpath %patch1 -p1 -b .hpath
%patch2 -p1 -b .numpy
%build %build
pys="" pys=""