Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6fa9b6

Browse files
TST: Reduce ExtensionArray data testing length from 100 to 10 (#62417)
1 parent 4a51628 commit f6fa9b6

30 files changed

+97
-103
lines changed

‎pandas/tests/arrays/boolean/test_arithmetic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def data():
1212
"""Fixture returning boolean array with valid and missing values."""
1313
return pd.array(
14-
[True, False] * 4 + [np.nan] + [True, False]*44 + [np.nan] + [True, False],
14+
[True, False] * 2 + [np.nan] + [True, False] + [np.nan] + [True, False],
1515
dtype="boolean",
1616
)
1717

‎pandas/tests/arrays/boolean/test_comparison.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def data():
1212
"""Fixture returning boolean array with valid and missing data"""
1313
return pd.array(
14-
[True, False] * 4 + [np.nan] + [True, False]*44 + [np.nan] + [True, False],
14+
[True, False] * 2 + [np.nan] + [True, False] + [np.nan] + [True, False],
1515
dtype="boolean",
1616
)
1717

‎pandas/tests/arrays/boolean/test_reduction.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def data():
99
"""Fixture returning boolean array, with valid and missing values."""
1010
return pd.array(
11-
[True, False] * 4 + [np.nan] + [True, False]*44 + [np.nan] + [True, False],
11+
[True, False] * 2 + [np.nan] + [True, False] + [np.nan] + [True, False],
1212
dtype="boolean",
1313
)
1414

‎pandas/tests/arrays/floating/conftest.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import numpy as np
21
import pytest
32

43
import pandas as pd
@@ -18,11 +17,7 @@ def dtype(request):
1817
def data(dtype):
1918
"""Fixture returning 'data' array according to parametrized float 'dtype'"""
2019
return pd.array(
21-
list(np.arange(0.1, 0.9, 0.1))
22-
+ [pd.NA]
23-
+ list(np.arange(1, 9.8, 0.1))
24-
+ [pd.NA]
25-
+ [9.9, 10.0],
20+
[0.1, 0.2, 0.3, 0.4] + [pd.NA] + [1.0, 1.1] + [pd.NA] + [9.9, 10.0],
2621
dtype=dtype,
2722
)
2823

‎pandas/tests/arrays/integer/conftest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def data(dtype):
3939
Used to test dtype conversion with and without missing values.
4040
"""
4141
return pd.array(
42-
list(range(8)) + [pd.NA] + list(range(10, 98)) + [pd.NA] + [99, 100],
42+
[0, 1, 2, 3] + [pd.NA] + [10, 11] + [pd.NA] + [99, 100],
4343
dtype=dtype,
4444
)
4545

‎pandas/tests/extension/base/casting.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ def test_astype_str(self, data):
5757
)
5858
def test_astype_string(self, data, nullable_string_dtype):
5959
# GH-33465, GH#45326 as of 2.0 we decode bytes instead of calling str(obj)
60+
def as_str(x):
61+
if isinstance(x, bytes):
62+
return x.decode()
63+
elif x is data.dtype.na_value:
64+
return x
65+
else:
66+
return str(x)
67+
6068
result = pd.Series(data[:5]).astype(nullable_string_dtype)
6169
expected = pd.Series(
62-
[str(x) ifnotisinstance(x, bytes) elsex.decode() for x in data[:5]],
70+
[as_str(x) for x in data[:5]],
6371
dtype=nullable_string_dtype,
6472
)
6573
tm.assert_series_equal(result, expected)

‎pandas/tests/extension/base/getitem.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def test_take_series(self, data):
408408
result = s.take([0, -1])
409409
expected = pd.Series(
410410
data._from_sequence([data[0], data[len(data) - 1]], dtype=s.dtype),
411-
index=range(0, 198, 99),
411+
index=s.index.take([0, -1]),
412412
)
413413
tm.assert_series_equal(result, expected)
414414

‎pandas/tests/extension/base/interface.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class BaseInterfaceTests:
1919
# ------------------------------------------------------------------------
2020

2121
def test_len(self, data):
22-
assert len(data) == 100
22+
assert len(data) == 10
2323

2424
def test_size(self, data):
25-
assert data.size == 100
25+
assert data.size == 10
2626

2727
def test_ndim(self, data):
2828
assert data.ndim == 1

‎pandas/tests/extension/base/methods.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def test_value_counts_default_dropna(self, data):
3939

4040
@pytest.mark.parametrize("dropna", [True, False])
4141
def test_value_counts(self, all_data, dropna):
42-
all_data = all_data[:10]
4342
if dropna:
4443
other = all_data[~all_data.isna()]
4544
else:
@@ -52,7 +51,7 @@ def test_value_counts(self, all_data, dropna):
5251

5352
def test_value_counts_with_normalize(self, data):
5453
# GH 33172
55-
data = data[:10].unique()
54+
data = data.unique()
5655
values = np.array(data[~data.isna()])
5756
ser = pd.Series(data, dtype=data.dtype)
5857

‎pandas/tests/extension/base/ops.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ class BaseUnaryOpsTests(BaseOpsUtil):
250250
def test_invert(self, data):
251251
ser = pd.Series(data, name="name")
252252
try:
253-
# 10 is an arbitrary choice here, just avoid iterating over
254-
# the whole array to trim test runtime
255-
[~x for x in data[:10]]
253+
[~x for x in data]
256254
except TypeError:
257255
# scalars don't support invert -> we don't expect the vectorized
258256
# operation to succeed

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /