From f0cf667924c1f46950b36d0e88ca4f5d802cf2d8 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:24:11 -0400 Subject: [PATCH 1/4] Revert "BLD: Add pyproject.toml to wheels (#50330)" This reverts commit 802322533d9d602aca40f9a58cf14d428353acb6. --- .github/workflows/wheels.yml | 4 ++-- ci/test_wheels.py | 2 -- ci/test_wheels_windows.bat | 4 ++-- pandas/conftest.py | 14 +++++++------- pandas/tests/frame/indexing/test_setitem.py | 3 +-- pandas/tests/series/methods/test_nlargest.py | 7 +------ pandas/tests/test_common.py | 7 ------- pyproject.toml | 6 +----- 8 files changed, 14 insertions(+), 33 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7eae93a6a27e9..31ed5096991a6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -173,8 +173,8 @@ jobs: pip install hypothesis>=6.34.2 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 cd .. # Not a good idea to test within the src tree python -c "import pandas; print(pandas.__version__); - pandas.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2', '--no-strict-data-files']); - pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files'])" + pandas.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']); + pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db'])" - uses: actions/upload-artifact@v3 with: name: sdist diff --git a/ci/test_wheels.py b/ci/test_wheels.py index d6f843d7b2c68..f861c1cbedcad 100644 --- a/ci/test_wheels.py +++ b/ci/test_wheels.py @@ -41,12 +41,10 @@ multi_args = [ "-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", - "--no-strict-data-files", ] pd.test(extra_args=multi_args) pd.test( extra_args=[ "-m not clipboard and single_cpu and not slow and not network and not db", - "--no-strict-data-files", ] ) diff --git a/ci/test_wheels_windows.bat b/ci/test_wheels_windows.bat index b8724d6d31cb5..6364169e53924 100644 --- a/ci/test_wheels_windows.bat +++ b/ci/test_wheels_windows.bat @@ -1,6 +1,6 @@ set test_command=import pandas as pd; print(pd.__version__); ^ -pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '--no-strict-data-files', '-n=2']); ^ -pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files']) +pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']); ^ +pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db']) python --version pip install pytz six numpy python-dateutil tzdata>=2022.1 diff --git a/pandas/conftest.py b/pandas/conftest.py index 68f3c575ee93d..95bb2078d151c 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -103,9 +103,9 @@ def pytest_addoption(parser) -> None: parser.addoption( - "--no-strict-data-files", - action="store_false", - help="Don't fail if a test is skipped for missing data file.", + "--strict-data-files", + action="store_true", + help="Fail if a test is skipped for missing data file.", ) @@ -1112,9 +1112,9 @@ def all_numeric_accumulations(request): @pytest.fixture def strict_data_files(pytestconfig): """ - Returns the configuration for the test setting `--no-strict-data-files`. + Returns the configuration for the test setting `--strict-data-files`. """ - return pytestconfig.getoption("--no-strict-data-files") + return pytestconfig.getoption("--strict-data-files") @pytest.fixture @@ -1134,7 +1134,7 @@ def datapath(strict_data_files: str) -> Callable[..., str]: Raises ------ ValueError - If the path doesn't exist and the --no-strict-data-files option is not set. + If the path doesn't exist and the --strict-data-files option is set. """ BASE_PATH = os.path.join(os.path.dirname(__file__), "tests") @@ -1143,7 +1143,7 @@ def deco(*args): if not os.path.exists(path): if strict_data_files: raise ValueError( - f"Could not find file {path} and --no-strict-data-files is not set." + f"Could not find file {path} and --strict-data-files is set." ) pytest.skip(f"Could not find {path}.") return path diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index b20375c673679..998ac9c8395ce 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -61,8 +61,7 @@ class mystring(str): "dtype", ["int32", "int64", "uint32", "uint64", "float32", "float64"] ) def test_setitem_dtype(self, dtype, float_frame): - # Use randint since casting negative floats to uints is undefined - arr = np.random.randint(1, 10, len(float_frame)) + arr = np.random.randn(len(float_frame)) float_frame[dtype] = np.array(arr, dtype=dtype) assert float_frame[dtype].dtype.name == dtype diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index ecc5d3060c0a2..146ba2c42e0be 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -217,12 +217,7 @@ def test_nlargest_boolean(self, data, expected): def test_nlargest_nullable(self, any_numeric_ea_dtype): # GH#42816 dtype = any_numeric_ea_dtype - 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) + arr = np.random.randn(10).astype(dtype.lower(), copy=False) ser = Series(arr.copy(), dtype=dtype) ser[1] = pd.NA diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 15fa10b9e4289..d31f617b9be15 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -1,6 +1,5 @@ import collections from functools import partial -import os import string import numpy as np @@ -175,12 +174,6 @@ def test_version_tag(): ) -def test_pyproject_present(): - # Check pyproject.toml is present(relevant for wheels) - pyproject_loc = os.path.join(os.path.dirname(__file__), "../../pyproject.toml") - assert os.path.exists(pyproject_loc) - - @pytest.mark.parametrize( "obj", [(obj,) for obj in pd.__dict__.values() if callable(obj)] ) diff --git a/pyproject.toml b/pyproject.toml index 1bc530df74e87..04c87e3d10a86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,9 +125,6 @@ include-package-data = true include = ["pandas", "pandas.*"] namespaces = false -[tool.setuptools.package-data] -pandas = ["../pyproject.toml"] - [tool.setuptools.exclude-package-data] "*" = ["*.c", "*.h"] @@ -409,7 +406,7 @@ disable = [ [tool.pytest.ini_options] # sync minversion with pyproject.toml & install.rst minversion = "7.0" -addopts = "--strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" +addopts = "--strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" empty_parameter_set_mark = "fail_at_collect" xfail_strict = true testpaths = "pandas" @@ -419,7 +416,6 @@ doctest_optionflags = [ "ELLIPSIS", ] filterwarnings = [ - "error::_pytest.warning_types.PytestUnknownMarkWarning", "error:::pandas", "error::ResourceWarning", "error::pytest.PytestUnraisableExceptionWarning", From cfc7a871901357ecdae764f87dbbad6c7af5c6bb Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:34:25 -0400 Subject: [PATCH 2/4] don't revert test fixes --- pandas/tests/frame/indexing/test_setitem.py | 3 ++- pandas/tests/series/methods/test_nlargest.py | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index 998ac9c8395ce..b20375c673679 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -61,7 +61,8 @@ class mystring(str): "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 diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 146ba2c42e0be..7c9cde8629b24 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -32,13 +32,11 @@ def s_main_dtypes(): """ A DataFrame with many dtypes - * datetime * datetimetz * timedelta * [u]int{8,16,32,64} * float{32,64} - The columns are the name of the dtype. """ df = pd.DataFrame( @@ -217,7 +215,12 @@ def test_nlargest_boolean(self, data, expected): 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 @@ -240,4 +243,4 @@ def test_nsmallest_nan_when_keep_is_all(self): s = Series([1, 2, None, None, None]) result = s.nsmallest(3, keep="all") expected = Series([1, 2, None, None, None]) - tm.assert_series_equal(result, expected) + tm.assert_series_equal(result, expected) \ No newline at end of file From 163ba0f9e52157028dda11fdc35d1df6524718f0 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:35:22 -0400 Subject: [PATCH 3/4] fix whitespace --- pandas/tests/series/methods/test_nlargest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 7c9cde8629b24..4d4ab57108c31 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -243,4 +243,4 @@ def test_nsmallest_nan_when_keep_is_all(self): s = Series([1, 2, None, None, None]) result = s.nsmallest(3, keep="all") expected = Series([1, 2, None, None, None]) - tm.assert_series_equal(result, expected) \ No newline at end of file + tm.assert_series_equal(result, expected) From e4702394cdf6e34c057a28d8f8f390a4e305f53f Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:36:22 -0400 Subject: [PATCH 4/4] more accidental whitespace --- pandas/tests/series/methods/test_nlargest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 4d4ab57108c31..ecc5d3060c0a2 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -32,11 +32,13 @@ def s_main_dtypes(): """ A DataFrame with many dtypes + * datetime * datetimetz * timedelta * [u]int{8,16,32,64} * float{32,64} + The columns are the name of the dtype. """ df = pd.DataFrame(