Skip to content

Commit 46386f0

Browse files
authored
CI/TST: Cleanups (#54362)
1 parent 292eb32 commit 46386f0

File tree

6 files changed

+83
-81
lines changed

6 files changed

+83
-81
lines changed

.circleci/setup_env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ source activate pandas-dev
4848
# downstream CI jobs that may also build pandas from source.
4949
export PANDAS_CI=1
5050

51-
if pip list | grep -q ^pandas; then
51+
if pip show pandas 1>/dev/null; then
5252
echo
5353
echo "remove any installed pandas package w/o removing anything else"
54-
pip uninstall -y pandas || true
54+
pip uninstall -y pandas
5555
fi
5656

5757
echo "Install pandas"

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ jobs:
333333
PYTEST_WORKERS: "auto"
334334
PANDAS_CI: 1
335335
PATTERN: "not slow and not network and not clipboard and not single_cpu"
336-
COVERAGE: true
337336
PYTEST_TARGET: pandas
338337

339338
steps:
@@ -351,7 +350,6 @@ jobs:
351350
python --version
352351
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.0.1 meson-python==0.13.1
353352
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
354-
python -m pip install git+https://github.com/nedbat/coveragepy.git
355353
python -m pip install versioneer[toml]
356354
python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
357355
python -m pip list

pandas/tests/arrays/test_datetimelike.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import array
43
import re
54
import warnings
65

@@ -12,7 +11,6 @@
1211
OutOfBoundsDatetime,
1312
Timestamp,
1413
)
15-
import pandas.util._test_decorators as td
1614

1715
import pandas as pd
1816
from pandas import (
@@ -1328,70 +1326,3 @@ def test_from_pandas_array(dtype):
13281326
result = idx_cls(arr)
13291327
expected = idx_cls(data)
13301328
tm.assert_index_equal(result, expected)
1331-
1332-
1333-
@pytest.fixture(
1334-
params=[
1335-
"memoryview",
1336-
"array",
1337-
pytest.param("dask", marks=td.skip_if_no("dask.array")),
1338-
pytest.param("xarray", marks=td.skip_if_no("xarray")),
1339-
]
1340-
)
1341-
def array_likes(request):
1342-
"""
1343-
Fixture giving a numpy array and a parametrized 'data' object, which can
1344-
be a memoryview, array, dask or xarray object created from the numpy array.
1345-
"""
1346-
# GH#24539 recognize e.g xarray, dask, ...
1347-
arr = np.array([1, 2, 3], dtype=np.int64)
1348-
1349-
name = request.param
1350-
if name == "memoryview":
1351-
data = memoryview(arr)
1352-
elif name == "array":
1353-
data = array.array("i", arr)
1354-
elif name == "dask":
1355-
import dask.array
1356-
1357-
data = dask.array.array(arr)
1358-
elif name == "xarray":
1359-
import xarray as xr
1360-
1361-
data = xr.DataArray(arr)
1362-
1363-
return arr, data
1364-
1365-
1366-
@pytest.mark.parametrize("dtype", ["M8[ns]", "m8[ns]"])
1367-
def test_from_obscure_array(dtype, array_likes):
1368-
# GH#24539 recognize e.g xarray, dask, ...
1369-
# Note: we dont do this for PeriodArray bc _from_sequence won't accept
1370-
# an array of integers
1371-
# TODO: could check with arraylike of Period objects
1372-
arr, data = array_likes
1373-
1374-
cls = {"M8[ns]": DatetimeArray, "m8[ns]": TimedeltaArray}[dtype]
1375-
1376-
expected = cls(arr)
1377-
result = cls._from_sequence(data)
1378-
tm.assert_extension_array_equal(result, expected)
1379-
1380-
func = {"M8[ns]": _sequence_to_dt64ns, "m8[ns]": sequence_to_td64ns}[dtype]
1381-
result = func(arr)[0]
1382-
expected = func(data)[0]
1383-
tm.assert_equal(result, expected)
1384-
1385-
if not isinstance(data, memoryview):
1386-
# FIXME(GH#44431) these raise on memoryview and attempted fix
1387-
# fails on py3.10
1388-
func = {"M8[ns]": pd.to_datetime, "m8[ns]": pd.to_timedelta}[dtype]
1389-
result = func(arr).array
1390-
expected = func(data).array
1391-
tm.assert_equal(result, expected)
1392-
1393-
# Let's check the Indexes while we're here
1394-
idx_cls = {"M8[ns]": DatetimeIndex, "m8[ns]": TimedeltaIndex}[dtype]
1395-
result = idx_cls(arr)
1396-
expected = idx_cls(data)
1397-
tm.assert_index_equal(result, expected)

pandas/tests/io/parser/test_upcast.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ def test_maybe_upcast(any_real_numpy_dtype):
3838

3939
def test_maybe_upcast_no_na(any_real_numpy_dtype):
4040
# GH#36712
41-
if any_real_numpy_dtype == "float32":
42-
pytest.skip()
43-
4441
arr = np.array([1, 2, 3], dtype=any_real_numpy_dtype)
4542
result = _maybe_upcast(arr, use_dtype_backend=True)
4643

pandas/tests/io/test_gcs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
@pytest.fixture
2323
def gcs_buffer():
2424
"""Emulate GCS using a binary buffer."""
25-
import fsspec
25+
pytest.importorskip("gcsfs")
26+
fsspec = pytest.importorskip("fsspec")
2627

2728
gcs_buffer = BytesIO()
2829
gcs_buffer.close = lambda: True
@@ -43,7 +44,6 @@ def ls(self, path, **kwargs):
4344
return gcs_buffer
4445

4546

46-
@td.skip_if_no("gcsfs")
4747
# Patches pyarrow; other processes should not pick up change
4848
@pytest.mark.single_cpu
4949
@pytest.mark.parametrize("format", ["csv", "json", "parquet", "excel", "markdown"])
@@ -131,7 +131,6 @@ def assert_equal_zip_safe(result: bytes, expected: bytes, compression: str):
131131
assert result == expected
132132

133133

134-
@td.skip_if_no("gcsfs")
135134
@pytest.mark.parametrize("encoding", ["utf-8", "cp1251"])
136135
def test_to_csv_compression_encoding_gcs(
137136
gcs_buffer, compression_only, encoding, compression_to_extension
@@ -177,10 +176,11 @@ def test_to_csv_compression_encoding_gcs(
177176
tm.assert_frame_equal(df, read_df)
178177

179178

180-
@td.skip_if_no("fastparquet")
181-
@td.skip_if_no("gcsfs")
182179
def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
183180
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
181+
pytest.importorskip("fastparquet")
182+
pytest.importorskip("gcsfs")
183+
184184
from fsspec import AbstractFileSystem
185185

186186
df1 = DataFrame(

pandas/tests/test_downstream.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Testing that we work in the downstream packages
33
"""
4+
import array
45
import importlib
56
import subprocess
67
import sys
@@ -14,9 +15,17 @@
1415
import pandas as pd
1516
from pandas import (
1617
DataFrame,
18+
DatetimeIndex,
1719
Series,
20+
TimedeltaIndex,
1821
)
1922
import pandas._testing as tm
23+
from pandas.core.arrays import (
24+
DatetimeArray,
25+
TimedeltaArray,
26+
)
27+
from pandas.core.arrays.datetimes import _sequence_to_dt64ns
28+
from pandas.core.arrays.timedeltas import sequence_to_td64ns
2029

2130

2231
def import_module(name):
@@ -277,3 +286,70 @@ def __radd__(self, other):
277286

278287
assert right.__add__(left) is NotImplemented
279288
assert right + left is left
289+
290+
291+
@pytest.fixture(
292+
params=[
293+
"memoryview",
294+
"array",
295+
pytest.param("dask", marks=td.skip_if_no("dask.array")),
296+
pytest.param("xarray", marks=td.skip_if_no("xarray")),
297+
]
298+
)
299+
def array_likes(request):
300+
"""
301+
Fixture giving a numpy array and a parametrized 'data' object, which can
302+
be a memoryview, array, dask or xarray object created from the numpy array.
303+
"""
304+
# GH#24539 recognize e.g xarray, dask, ...
305+
arr = np.array([1, 2, 3], dtype=np.int64)
306+
307+
name = request.param
308+
if name == "memoryview":
309+
data = memoryview(arr)
310+
elif name == "array":
311+
data = array.array("i", arr)
312+
elif name == "dask":
313+
import dask.array
314+
315+
data = dask.array.array(arr)
316+
elif name == "xarray":
317+
import xarray as xr
318+
319+
data = xr.DataArray(arr)
320+
321+
return arr, data
322+
323+
324+
@pytest.mark.parametrize("dtype", ["M8[ns]", "m8[ns]"])
325+
def test_from_obscure_array(dtype, array_likes):
326+
# GH#24539 recognize e.g xarray, dask, ...
327+
# Note: we dont do this for PeriodArray bc _from_sequence won't accept
328+
# an array of integers
329+
# TODO: could check with arraylike of Period objects
330+
arr, data = array_likes
331+
332+
cls = {"M8[ns]": DatetimeArray, "m8[ns]": TimedeltaArray}[dtype]
333+
334+
expected = cls(arr)
335+
result = cls._from_sequence(data)
336+
tm.assert_extension_array_equal(result, expected)
337+
338+
func = {"M8[ns]": _sequence_to_dt64ns, "m8[ns]": sequence_to_td64ns}[dtype]
339+
result = func(arr)[0]
340+
expected = func(data)[0]
341+
tm.assert_equal(result, expected)
342+
343+
if not isinstance(data, memoryview):
344+
# FIXME(GH#44431) these raise on memoryview and attempted fix
345+
# fails on py3.10
346+
func = {"M8[ns]": pd.to_datetime, "m8[ns]": pd.to_timedelta}[dtype]
347+
result = func(arr).array
348+
expected = func(data).array
349+
tm.assert_equal(result, expected)
350+
351+
# Let's check the Indexes while we're here
352+
idx_cls = {"M8[ns]": DatetimeIndex, "m8[ns]": TimedeltaIndex}[dtype]
353+
result = idx_cls(arr)
354+
expected = idx_cls(data)
355+
tm.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)