Skip to content

Commit 4810d74

Browse files
author
Olga Matoula
authored
Remove pd_array from tests (#40267)
* Remove pd_array from tests * Add stricter check on array imports
1 parent 70c91a2 commit 4810d74

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

pandas/tests/arithmetic/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
DataFrame,
99
Index,
1010
Series,
11-
array as pd_array,
11+
array,
1212
)
1313
import pandas._testing as tm
1414
from pandas.core.arrays import PandasArray
@@ -60,7 +60,7 @@ def assert_invalid_comparison(left, right, box):
6060
# Not for tznaive-tzaware comparison
6161

6262
# Note: not quite the same as how we do this for tm.box_expected
63-
xbox = box if box not in [Index, pd_array] else np.array
63+
xbox = box if box not in [Index, array] else np.array
6464

6565
def xbox2(x):
6666
# Eventually we'd like this to be tighter, but for now we'll

pandas/tests/frame/test_constructors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1216,14 +1216,14 @@ def __len__(self, n):
12161216
def test_constructor_stdlib_array(self):
12171217
# GH 4297
12181218
# support Array
1219-
import array
1219+
from array import array as stdlib_array
12201220

1221-
result = DataFrame({"A": array.array("i", range(10))})
1221+
result = DataFrame({"A": stdlib_array("i", range(10))})
12221222
expected = DataFrame({"A": list(range(10))})
12231223
tm.assert_frame_equal(result, expected, check_dtype=False)
12241224

12251225
expected = DataFrame([list(range(10)), list(range(10))])
1226-
result = DataFrame([array.array("i", range(10)), array.array("i", range(10))])
1226+
result = DataFrame([stdlib_array("i", range(10)), stdlib_array("i", range(10))])
12271227
tm.assert_frame_equal(result, expected, check_dtype=False)
12281228

12291229
def test_constructor_range(self):

pandas/tests/indexing/test_iloc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Index,
1818
NaT,
1919
Series,
20-
array as pd_array,
20+
array,
2121
concat,
2222
date_range,
2323
isna,
@@ -93,11 +93,11 @@ def test_iloc_setitem_fullcol_categorical(self, indexer, key):
9393
else:
9494
assert cat[0] != "gamma"
9595

96-
@pytest.mark.parametrize("box", [pd_array, Series])
96+
@pytest.mark.parametrize("box", [array, Series])
9797
def test_iloc_setitem_ea_inplace(self, frame_or_series, box):
9898
# GH#38952 Case with not setting a full column
9999
# IntegerArray without NAs
100-
arr = pd_array([1, 2, 3, 4])
100+
arr = array([1, 2, 3, 4])
101101
obj = frame_or_series(arr.to_numpy("i8"))
102102
values = obj.values
103103

pandas/tests/series/methods/test_view.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pandas import (
55
Index,
66
Series,
7-
array as pd_array,
7+
array,
88
date_range,
99
)
1010
import pandas._testing as tm
@@ -31,7 +31,7 @@ def test_view_tz(self):
3131
@pytest.mark.parametrize(
3232
"second", ["m8[ns]", "M8[ns]", "M8[ns, US/Central]", "period[D]"]
3333
)
34-
@pytest.mark.parametrize("box", [Series, Index, pd_array])
34+
@pytest.mark.parametrize("box", [Series, Index, array])
3535
def test_view_between_datetimelike(self, first, second, box):
3636

3737
dti = date_range("2016-01-01", periods=3)

scripts/check_for_inconsistent_pandas_namespace.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
ERROR_MESSAGE = "Found both `pd.{name}` and `{name}` in {path}"
3131
EXCLUDE = {
32-
"array", # `import array` and `pd.array` should both be allowed
3332
"eval", # built-in, different from `pd.eval`
3433
"np", # pd.np is deprecated but still tested
3534
}

0 commit comments

Comments
 (0)