From ddc519d9d87740a483b515421a12e91c22428f476357b5373079e4b7b1f37d41 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dmueller@suse.com>
Date: Thu, 22 Jun 2023 11:42:54 +0000
Subject: [PATCH] Accepting request 1094617 from
 home:Guillaume_G:branches:openSUSE:Factory:ARM

- Fix tests on aarch64:
  * pandas-fix-tests.patch

OBS-URL: https://build.opensuse.org/request/show/1094617
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pandas?expand=0&rev=90
---
 pandas-fix-tests.patch | 28 ++++++++++++++++++++++++++++
 python-pandas.changes  |  6 ++++++
 python-pandas.spec     |  2 ++
 3 files changed, 36 insertions(+)
 create mode 100644 pandas-fix-tests.patch

diff --git a/pandas-fix-tests.patch b/pandas-fix-tests.patch
new file mode 100644
index 0000000..b663ce3
--- /dev/null
+++ b/pandas-fix-tests.patch
@@ -0,0 +1,28 @@
+--- pandas-2.0.2/pandas/tests/frame/indexing/test_setitem.py.orig	2023-06-22 09:00:10.272775300 +0200
++++ pandas-2.0.2/pandas/tests/frame/indexing/test_setitem.py	2023-06-22 09:00:48.663682100 +0200
+@@ -61,7 +61,8 @@ class TestDataFrameSetItem:
+         "dtype", ["int32", "int64", "uint32", "uint64", "float32", "float64"]
+     )
+     def test_setitem_dtype(self, dtype, float_frame):
+-        arr = np.random.randn(len(float_frame))
++        # Use randint since casting negative floats to uints is undefined
++        arr = np.random.randint(1, 10, len(float_frame))
+ 
+         float_frame[dtype] = np.array(arr, dtype=dtype)
+         assert float_frame[dtype].dtype.name == dtype
+--- pandas-2.0.2/pandas/tests/series/methods/test_nlargest.py.orig	2023-06-22 09:02:58.788342500 +0200
++++ pandas-2.0.2/pandas/tests/series/methods/test_nlargest.py	2023-06-22 09:03:26.743975800 +0200
+@@ -217,7 +217,12 @@ class TestSeriesNLargestNSmallest:
+     def test_nlargest_nullable(self, any_numeric_ea_dtype):
+         # GH#42816
+         dtype = any_numeric_ea_dtype
+-        arr = np.random.randn(10).astype(dtype.lower(), copy=False)
++        if dtype.startswith("UInt"):
++            # Can't cast from negative float to uint on some platforms
++            arr = np.random.randint(1, 10, 10)
++        else:
++            arr = np.random.randn(10)
++        arr = arr.astype(dtype.lower(), copy=False)
+ 
+         ser = Series(arr.copy(), dtype=dtype)
+         ser[1] = pd.NA
diff --git a/python-pandas.changes b/python-pandas.changes
index aec462e..41392b3 100644
--- a/python-pandas.changes
+++ b/python-pandas.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Thu Jun 22 09:36:06 UTC 2023 - Guillaume GARDET <guillaume.gardet@opensuse.org>
+
+- Fix tests on aarch64:
+  * pandas-fix-tests.patch
+
 -------------------------------------------------------------------
 Sun Jun 11 19:51:26 UTC 2023 - Johannes Kastl <kastl@b1-systems.de>
 
diff --git a/python-pandas.spec b/python-pandas.spec
index d83a686..707ae38 100644
--- a/python-pandas.spec
+++ b/python-pandas.spec
@@ -60,6 +60,8 @@ URL:            https://pandas.pydata.org/
 # Use GitHub Archive: Test-data
 Source0:        https://github.com/pandas-dev/pandas/archive/refs/tags/v%{version}.tar.gz#/pandas-%{version}-gh.tar.gz
 # SourceRepository: https://github.com/pandas-dev/pandas
+# https://github.com/pandas-dev/pandas/issues/53791#issuecomment-1602320315
+Patch1:         pandas-fix-tests.patch
 BuildRequires:  %{python_module Cython >= 0.29.33 with %python-Cython < 3}
 BuildRequires:  %{python_module devel >= 3.8}
 BuildRequires:  %{python_module numpy-devel >= 1.20.3}