summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Junjie <z572@z572.online>2025-07-06 15:41:22 +0800
committerAndreas Enge <andreas@enge.fr>2025-07-06 10:58:47 +0200
commit5b43b112f8bd046d2ca8021c5057390cd048903d (patch)
tree9152ab2d548c24767b0322de46711de752d226e3
parent7d0d3182ca5b0b8969c5b2e4aad3136b00e5ad30 (diff)
gnu: python-pandas-2: Fix test with new tzdata.
Fixes: guix/guix#1025 * gnu/packages/patches/python-pandas-2-no-pytz_datetime.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/python-science.scm (python-pandas-2): Use it. Change-Id: I0e3689c28f11a5f69362caf0e31890a5efe6febe Signed-off-by: Andreas Enge <andreas@enge.fr>
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/patches/python-pandas-2-no-pytz_datetime.patch47
-rw-r--r--gnu/packages/python-science.scm3
3 files changed, 50 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 36c6fd9406..dca0426564 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2166,6 +2166,7 @@ dist_patch_DATA = \
%D%/packages/patches/python-memcached-syntax-warnings.patch \
%D%/packages/patches/python-mox3-python3.6-compat.patch \
%D%/packages/patches/python-packaging-test-arch.patch \
+ %D%/packages/patches/python-pandas-2-no-pytz_datetime.patch \
%D%/packages/patches/python-property-cached-asyncio-3_11.patch \
%D%/packages/patches/python-pyan3-fix-absolute-path-bug.patch \
%D%/packages/patches/python-pyan3-fix-positional-arguments.patch \
diff --git a/gnu/packages/patches/python-pandas-2-no-pytz_datetime.patch b/gnu/packages/patches/python-pandas-2-no-pytz_datetime.patch
new file mode 100644
index 0000000000..637bf4aa6c
--- /dev/null
+++ b/gnu/packages/patches/python-pandas-2-no-pytz_datetime.patch
@@ -0,0 +1,47 @@
+from https://salsa.debian.org/science-team/pandas/-/raw/main/debian/patches/no_pytz_datetime.patch
+
+Description: datetime does not work with non-constant pytz.timezone
+
+This has always been the case (and is explicitly warned about
+in the pytz documentation), but became a test fail when
+tzdata 2024b changed 'CET' and similar to aliases.
+
+Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
+Forwarded: no
+
+--- a/pandas/tests/arrays/test_array.py
++++ b/pandas/tests/arrays/test_array.py
+@@ -272,7 +272,8 @@ def test_array_copy():
+ assert tm.shares_memory(a, b)
+
+
+-cet = pytz.timezone("CET")
++cetfixed = pytz.timezone("Etc/GMT-1") # the wrong-looking sign is because Etc/* use posix convention, as described in the tzdata source
++cetwithdst = pytz.timezone("Europe/Brussels")
+
+
+ @pytest.mark.parametrize(
+@@ -313,11 +314,20 @@ cet = pytz.timezone("CET")
+ ),
+ (
+ [
+- datetime.datetime(2000, 1, 1, tzinfo=cet),
+- datetime.datetime(2001, 1, 1, tzinfo=cet),
++ datetime.datetime(2000, 1, 1, tzinfo=cetfixed),
++ datetime.datetime(2001, 1, 1, tzinfo=cetfixed),
+ ],
+ DatetimeArray._from_sequence(
+- ["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cet, unit="ns")
++ ["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cetfixed, unit="ns")
++ ),
++ ),
++ (
++ [
++ cetwithdst.localize(datetime.datetime(2000, 1, 1)),
++ cetwithdst.localize(datetime.datetime(2001, 1, 1)),
++ ],
++ DatetimeArray._from_sequence(
++ ["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cetwithdst, unit="ns")
+ ),
+ ),
+ # timedelta
diff --git a/gnu/packages/python-science.scm b/gnu/packages/python-science.scm
index e45d3e3fff..da13989c54 100644
--- a/gnu/packages/python-science.scm
+++ b/gnu/packages/python-science.scm
@@ -3094,7 +3094,8 @@ doing practical, real world data analysis in Python.")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
- (base32 "00f6jnplwg7iffnxdm4hpfls0ncbarc23933xq1rm5nk5g8dcldx"))))
+ (base32 "00f6jnplwg7iffnxdm4hpfls0ncbarc23933xq1rm5nk5g8dcldx"))
+ (patches (search-patches "python-pandas-2-no-pytz_datetime.patch"))))
(build-system pyproject-build-system)
(arguments
(list