From 91a92cf40c852dfcdd34830e83ddf6da74700585e2878104ffc8a17f711dc275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Thu, 23 Jul 2020 06:35:55 +0000 Subject: [PATCH] Accepting request 822301 from home:bnavigator:branches:devel:languages:python:numeric - support newest numpy by removing old test gh#pandas-dev/pandas#34991 pandas-pr34991-npconstructor.patch - move testing to multibuild flavor - run slow tests only on x86_64 - replace gcc10-skip-one-test.patch with pytest -k deselection - tidy SKIP_TESTS declarations - add pandas-pytest.ini as pytest.ini in order to support the custom marks and filter some warnings - remove random hash seed OBS-URL: https://build.opensuse.org/request/show/822301 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pandas?expand=0&rev=46 --- _multibuild | 3 ++ gcc10-skip-one-test.patch | 12 ----- pandas-pr34991-npconstructor.patch | 78 ++++++++++++++++++++++++++++++ pandas-pytest.ini | 13 +++++ python-pandas.changes | 13 +++++ python-pandas.spec | 73 +++++++++++++++++++++------- 6 files changed, 162 insertions(+), 30 deletions(-) create mode 100644 _multibuild delete mode 100644 gcc10-skip-one-test.patch create mode 100644 pandas-pr34991-npconstructor.patch create mode 100644 pandas-pytest.ini diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/gcc10-skip-one-test.patch b/gcc10-skip-one-test.patch deleted file mode 100644 index 339eefa..0000000 --- a/gcc10-skip-one-test.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/pandas/tests/reshape/merge/test_merge.py b/pandas/tests/reshape/merge/test_merge.py -index 8465e2c..f53d2ad 100644 ---- a/pandas/tests/reshape/merge/test_merge.py -+++ b/pandas/tests/reshape/merge/test_merge.py -@@ -1459,6 +1459,7 @@ class TestMergeDtypes: - ) - tm.assert_frame_equal(result, expected) - -+ @pytest.mark.xfail - def test_merge_on_ints_floats_warning(self): - # GH 16572 - # merge will produce a warning when merging on int and diff --git a/pandas-pr34991-npconstructor.patch b/pandas-pr34991-npconstructor.patch new file mode 100644 index 0000000..c4507ba --- /dev/null +++ b/pandas-pr34991-npconstructor.patch @@ -0,0 +1,78 @@ +Index: pandas-1.0.5/pandas/core/internals/construction.py +=================================================================== +--- pandas-1.0.5.orig/pandas/core/internals/construction.py ++++ pandas-1.0.5/pandas/core/internals/construction.py +@@ -292,7 +292,7 @@ def prep_ndarray(values, copy=True) -> n + if values.ndim == 1: + values = values.reshape((values.shape[0], 1)) + elif values.ndim != 2: +- raise ValueError("Must pass 2-d input") ++ raise ValueError(f"Must pass 2-d input. shape={values.shape}") + + return values + +Index: pandas-1.0.5/pandas/tests/frame/test_constructors.py +=================================================================== +--- pandas-1.0.5.orig/pandas/tests/frame/test_constructors.py ++++ pandas-1.0.5/pandas/tests/frame/test_constructors.py +@@ -9,7 +9,7 @@ import numpy.ma.mrecords as mrecords + import pytest + + from pandas.compat import is_platform_little_endian +-from pandas.compat.numpy import _is_numpy_dev ++from pandas.compat.numpy import _np_version_under1p19 + + from pandas.core.dtypes.common import is_integer_dtype + +@@ -145,14 +145,20 @@ class TestDataFrameConstructors: + assert df.loc[1, 0] is None + assert df.loc[0, 1] == "2" + +- @pytest.mark.xfail(_is_numpy_dev, reason="Interprets list of frame as 3D") +- def test_constructor_list_frames(self): +- # see gh-3243 +- result = DataFrame([DataFrame()]) +- assert result.shape == (1, 0) +- +- result = DataFrame([DataFrame(dict(A=np.arange(5)))]) +- assert isinstance(result.iloc[0, 0], DataFrame) ++ @pytest.mark.skipif(_np_version_under1p19, reason="NumPy change.") ++ def test_constructor_list_of_2d_raises(self): ++ # https://github.com/pandas-dev/pandas/issues/32289 ++ a = pd.DataFrame() ++ b = np.empty((0, 0)) ++ with pytest.raises(ValueError, match=r"shape=\(1, 0, 0\)"): ++ pd.DataFrame([a]) ++ ++ with pytest.raises(ValueError, match=r"shape=\(1, 0, 0\)"): ++ pd.DataFrame([b]) ++ ++ a = pd.DataFrame({"A": [1, 2]}) ++ with pytest.raises(ValueError, match=r"shape=\(2, 2, 1\)"): ++ pd.DataFrame([a, a]) + + def test_constructor_mixed_dtypes(self): + def _make_mixed_dtypes_df(typ, ad=None): +@@ -498,22 +504,6 @@ class TestDataFrameConstructors: + with pytest.raises(ValueError, match=msg): + DataFrame({"a": False, "b": True}) + +- @pytest.mark.xfail(_is_numpy_dev, reason="Interprets embedded frame as 3D") +- def test_constructor_with_embedded_frames(self): +- +- # embedded data frames +- df1 = DataFrame({"a": [1, 2, 3], "b": [3, 4, 5]}) +- df2 = DataFrame([df1, df1 + 10]) +- +- df2.dtypes +- str(df2) +- +- result = df2.loc[0, 0] +- tm.assert_frame_equal(result, df1) +- +- result = df2.loc[1, 0] +- tm.assert_frame_equal(result, df1 + 10) +- + def test_constructor_subclass_dict(self, float_frame, dict_subclass): + # Test for passing dict subclass to constructor + data = { diff --git a/pandas-pytest.ini b/pandas-pytest.ini new file mode 100644 index 0000000..4606935 --- /dev/null +++ b/pandas-pytest.ini @@ -0,0 +1,13 @@ +[pytest] +minversion = 4.0.2 +markers = + single: mark a test as single cpu only + slow: mark a test as slow + network: mark a test as network + db: tests requiring a database (mysql or postgres) + high_memory: mark a test as a high-memory only + clipboard: mark a pd.read_clipboard test +filterwarnings = + error:Sparse:FutureWarning + error:The SparseArray:FutureWarning +junit_family = xunit2 diff --git a/python-pandas.changes b/python-pandas.changes index fe7066b..410936e 100644 --- a/python-pandas.changes +++ b/python-pandas.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Wed Jul 22 10:04:49 UTC 2020 - Benjamin Greiner + +- support newest numpy by removing old test + gh#pandas-dev/pandas#34991 pandas-pr34991-npconstructor.patch +- move testing to multibuild flavor +- run slow tests only on x86_64 +- replace gcc10-skip-one-test.patch with pytest -k deselection +- tidy SKIP_TESTS declarations +- add pandas-pytest.ini as pytest.ini in order to support the + custom marks and filter some warnings +- remove random hash seed + ------------------------------------------------------------------- Tue Jun 30 13:03:14 UTC 2020 - Matej Cepl diff --git a/python-pandas.spec b/python-pandas.spec index 86e3458..ee3246a 100644 --- a/python-pandas.spec +++ b/python-pandas.spec @@ -18,7 +18,15 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 -Name: python-pandas +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +Name: python-pandas%{psuffix} Version: 1.0.5 Release: 0 Summary: Python data structures for data analysis, time series, and statistics @@ -26,7 +34,9 @@ License: BSD-3-Clause Group: Development/Libraries/Python URL: https://pandas.pydata.org/ Source0: https://files.pythonhosted.org/packages/source/p/pandas/pandas-%{version}.tar.gz -Patch0: gcc10-skip-one-test.patch +Source99: pandas-pytest.ini +# PATCH-FIX-UPSTREAM gh#pandas-dev/pandas#34991 +Patch0: pandas-pr34991-npconstructor.patch BuildRequires: %{python_module Cython >= 0.28.2} # test requirements BuildRequires: %{python_module Jinja2} @@ -73,13 +83,14 @@ Recommends: xclip Recommends: xsel Obsoletes: python-pandas-doc < %{version} Provides: python-pandas-doc = %{version} -# SECTION test requirements +%if %{with test} BuildRequires: %{python_module SQLAlchemy >= 1.1.4} BuildRequires: %{python_module XlsxWriter >= 0.9.8} BuildRequires: %{python_module beautifulsoup4 >= 4.6.0} BuildRequires: %{python_module hypothesis} BuildRequires: %{python_module lxml >= 3.8.0} BuildRequires: %{python_module openpyxl >= 2.4.8} +BuildRequires: %{python_module pandas = %{version}} BuildRequires: %{python_module pytest >= 4.0.2} BuildRequires: %{python_module pytest-mock} BuildRequires: %{python_module pytest-xdist} @@ -88,7 +99,7 @@ BuildRequires: %{python_module pytz >= 2015.4} BuildRequires: %{python_module xlrd >= 1.1.0} BuildRequires: %{python_module xlwt >= 1.2.0} BuildRequires: xvfb-run -# /SECTION +%endif %python_subpackages %description @@ -98,47 +109,73 @@ heterogeneous) and time series data. It is a high-level building block for doing data analysis in Python. %prep +%if !%{with test} %setup -q -n pandas-%{version} sed -i -e 's/\r//g' pandas/tests/reshape/merge/test_merge.py %patch0 -p1 sed -i -e '/^#!\//, 1d' pandas/core/computation/eval.py sed -i -e '/^#!\//, 1d' pandas/tests/io/generate_legacy_storage_files.py sed -i -e '/^#!\//, 1d' pandas/tests/plotting/common.py +%endif %build +%if !%{with test} export CFLAGS="%{optflags} -fno-strict-aliasing" %python_build +%endif %install +%if !%{with test} %python_install -%python_expand sed -i -e 's|"python", "-c",|"%{__$python}", "-c",|' %{buildroot}%{$python_sitearch}/pandas/tests/io/test_compression.py -%python_expand %fdupes %{buildroot}%{$python_sitearch} +%{python_expand sed -i -e 's|"python", "-c",|"%{__$python}", "-c",|' %{buildroot}%{$python_sitearch}/pandas/tests/io/test_compression.py +%fdupes %{buildroot}%{$python_sitearch} +# can be removed for pandas >= 1.1 https://github.com/pandas-dev/pandas/pull/35146 +install %SOURCE99 %{buildroot}%{$python_sitearch}/pandas/pytest.ini +} +%endif %check -# skip test that tries to compile stuff in buildroot test_oo_optimizable -# test_encode_non_c_locale - skip test as it overflows on 32bit -# test_maybe_promote_int_with_int https://github.com/pandas-dev/pandas/issues/31856 -export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))') +%if %{with test} export http_proxy=http://1.2.3.4 https_proxy=http://1.2.3.4; export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export PYTHONDONTWRITEBYTECODE=1 -export SKIP_TESTS="test_oo_optimizable or test_encode_non_c_locale or test_maybe_promote_int_with_int" -# Skip test_raw_roundtrip on i586, gh#pandas-dev/pandas#29712 +# Workaround for pytest-xdist flaky collection order +# https://github.com/pytest-dev/pytest/issues/920 +# https://github.com/pytest-dev/pytest/issues/1075 +export PYTHONHASHSEED=1 +# tries to compile stuff in buildroot test_oo_optimizable +SKIP_TESTS+=" or test_oo_optimizable" %ifarch %{ix86} -SKIP_TESTS="$SKIP_TESTS or test_raw_roundtrip" +# https://github.com/pandas-dev/pandas/issues/29712 +SKIP_TESTS+=" or test_raw_roundtrip" +# overflows on i586 +SKIP_TESTS+=" or test_encode_non_c_locale" +# fails on i586 (was gcc10-skip-one-test.patch) +SKIP_TESTS+=" or test_merge_on_ints_floats_warning" %endif -mv pandas pandas_temp -%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} -$python -c 'import pandas; print(pandas.show_versions())' -xvfb-run py.test-%{$python_version} -n auto -v %{buildroot}%{$python_sitearch}/pandas/tests -k "not ($SKIP_TESTS)" +# https://github.com/pandas-dev/pandas/issues/31856 +[ $(getconf LONG_BIT) = "32" ] && SKIP_TESTS+=" or test_maybe_promote_int_with_int" +%ifnarch x86_64 +# run the slow tests only on x86_64 +%define test_fast --skip-slow --skip-db +%endif +%{python_expand $python -c 'import pandas; print(pandas.__path__); print(pandas.show_versions())' +# need to specify test path directly instead of --pyargs pandas in order +# to find pytest.ini and all conftest.py files +xvfb-run pytest-%{$python_bin_suffix} -v -n auto %{?test_fast} \ + -p no:cacheprovider \ + -k "not (${SKIP_TESTS:4})" \ + %{$python_sitearch}/pandas } -mv pandas_temp pandas +%endif +%if !%{with test} %files %{python_files} %license LICENSE %doc doc/README.rst RELEASE.md %{python_sitearch}/pandas/ %{python_sitearch}/pandas-%{version}-py*.egg-info +%endif %changelog