Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/tests/indexes/categorical/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_map_with_dict_or_series():
# Order of categories in result can be different
tm.assert_index_equal(result, expected)

mapper = dict(zip(orig_values[:-1], new_values[:-1]))
mapper = dict(zip(orig_values[:-1], new_values[:-1], strict=True))
result = cur_index.map(mapper)
# Order of categories in result can be different
tm.assert_index_equal(result, expected)
6 changes: 3 additions & 3 deletions pandas/tests/indexes/datetimes/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_index_convert_to_datetime_array(self):
def _check_rng(rng):
converted = rng.to_pydatetime()
assert isinstance(converted, np.ndarray)
for x, stamp in zip(converted, rng):
for x, stamp in zip(converted, rng, strict=True):
assert isinstance(x, datetime)
assert x == stamp.to_pydatetime()
assert x.tzinfo == stamp.tzinfo
Expand All @@ -258,7 +258,7 @@ def test_index_convert_to_datetime_array_explicit_pytz(self):
def _check_rng(rng):
converted = rng.to_pydatetime()
assert isinstance(converted, np.ndarray)
for x, stamp in zip(converted, rng):
for x, stamp in zip(converted, rng, strict=True):
assert isinstance(x, datetime)
assert x == stamp.to_pydatetime()
assert x.tzinfo == stamp.tzinfo
Expand All @@ -275,7 +275,7 @@ def test_index_convert_to_datetime_array_dateutil(self):
def _check_rng(rng):
converted = rng.to_pydatetime()
assert isinstance(converted, np.ndarray)
for x, stamp in zip(converted, rng):
for x, stamp in zip(converted, rng, strict=True):
assert isinstance(x, datetime)
assert x == stamp.to_pydatetime()
assert x.tzinfo == stamp.tzinfo
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/indexes/datetimes/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_dti_representation(self, unit):
)

with pd.option_context("display.width", 300):
for index, expected in zip(idxs, exp):
for index, expected in zip(idxs, exp, strict=True):
index = index.as_unit(unit)
expected = expected.replace("[ns", f"[{unit}")
result = repr(index)
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_dti_representation_to_series(self, unit):
with pd.option_context("display.width", 300):
for idx, expected in zip(
[idx1, idx2, idx3, idx4, idx5, idx6, idx7],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7], strict=True,
):
ser = Series(idx.as_unit(unit))
result = repr(ser)
Expand Down Expand Up @@ -265,6 +265,7 @@ def test_dti_summary(self):

for idx, expected in zip(
[idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6]
, strict=True
):
result = idx._summary()
assert result == expected
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/datetimes/test_partial_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def test_partial_slicing_dataframe(self):
# Timestamp with the same resolution as index
# Should be exact match for Series (return scalar)
# and raise KeyError for Frame
for timestamp, expected in zip(index, values):
for timestamp, expected in zip(index, values, strict=True):
ts_string = timestamp.strftime(formats[rnum])
# make ts_string as precise as index
result = df["a"][ts_string]
Expand Down Expand Up @@ -319,7 +319,7 @@ def test_partial_slicing_dataframe(self):

# Not compatible with existing key
# Should raise KeyError
for fmt, res in list(zip(formats, resolutions))[rnum + 1 :]:
for fmt, res in list(zip(formats, resolutions, strict=True))[rnum + 1 :]:
ts = index[1] + Timedelta("1 " + res)
ts_string = ts.strftime(fmt)
msg = rf"^'{ts_string}'$"
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/indexes/datetimes/test_scalar_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def test_day_name_month_name(self, time_locale):
"Saturday",
"Sunday",
]
for day, name, eng_name in zip(range(4, 11), expected_days, english_days):
for day, name, eng_name in zip(range(4, 11), expected_days, english_days,
strict=True):
name = name.capitalize()
assert dti.day_name(locale=time_locale)[day] == name
assert dti.day_name(locale=None)[day] == eng_name
Expand All @@ -206,7 +207,7 @@ def test_day_name_month_name(self, time_locale):

tm.assert_index_equal(result, expected)

for item, expected in zip(dti, expected_months):
for item, expected in zip(dti, expected_months, strict=True):
result = item.month_name(locale=time_locale)
expected = expected.capitalize()

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_timestamp_equality_different_timezones(self):
eastern_range = utc_range.tz_convert("US/Eastern")
berlin_range = utc_range.tz_convert("Europe/Berlin")

for a, b, c in zip(utc_range, eastern_range, berlin_range):
for a, b, c in zip(utc_range, eastern_range, berlin_range, strict=True):
assert a == b
assert b == c
assert a == c
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/interval/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"):
if len(breaks) == 0:
return {"data": breaks}

tuples = list(zip(breaks[:-1], breaks[1:]))
tuples = list(zip(breaks[:-1], breaks[1:], strict=True))
if isinstance(breaks, (list, tuple)):
return {"data": tuples}
elif isinstance(getattr(breaks, "dtype", None), CategoricalDtype):
Expand Down Expand Up @@ -386,7 +386,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"):

ivs = [
Interval(left, right, closed) if notna(left) else left
for left, right in zip(breaks[:-1], breaks[1:])
for left, right in zip(breaks[:-1], breaks[1:], strict=True)
]

if isinstance(breaks, list):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/interval/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_repr_floats(self):
Interval(left, right)
for left, right in zip(
Index([329.973, 345.137], dtype="float64"),
Index([345.137, 360.191], dtype="float64"),
Index([345.137, 360.191], dtype="float64"), strict=True,
)
]
),
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_properties(self, closed):

ivs = [
Interval(left, right, closed)
for left, right in zip(range(10), range(1, 11))
for left, right in zip(range(10), range(1, 11), strict=True)
]
expected = np.array(ivs, dtype=object)
tm.assert_numpy_array_equal(np.asarray(index), expected)
Expand All @@ -71,7 +71,7 @@ def test_properties(self, closed):

ivs = [
Interval(left, right, closed) if notna(left) else np.nan
for left, right in zip(expected_left, expected_right)
for left, right in zip(expected_left, expected_right, strict=True)
]
expected = np.array(ivs, dtype=object)
tm.assert_numpy_array_equal(np.asarray(index), expected)
Expand Down Expand Up @@ -789,14 +789,14 @@ def test_is_overlapping(self, start, shift, na_value, closed):
@pytest.mark.parametrize(
"tuples",
[
zip(range(10), range(1, 11)),
zip(range(10), range(1, 11), strict=True),
zip(
date_range("20170101", periods=10),
date_range("20170101", periods=10),
date_range("20170101", periods=10), strict=True,
),
zip(
timedelta_range("0 days", periods=10),
timedelta_range("1 day", periods=10),
timedelta_range("1 day", periods=10), strict=True,
),
],
)
Expand All @@ -811,18 +811,18 @@ def test_to_tuples(self, tuples):
@pytest.mark.parametrize(
"tuples",
[
list(zip(range(10), range(1, 11))) + [np.nan],
list(zip(range(10), range(1, 11), strict=True)) + [np.nan],
list(
zip(
date_range("20170101", periods=10),
date_range("20170101", periods=10),
date_range("20170101", periods=10), strict=True,
)
)
+ [np.nan],
list(
zip(
timedelta_range("0 days", periods=10),
timedelta_range("1 day", periods=10),
timedelta_range("1 day", periods=10), strict=True,
)
)
+ [np.nan],
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_map(idx):
@pytest.mark.parametrize(
"mapper",
[
lambda values, idx: {i: e for e, i in zip(values, idx)},
lambda values, idx: {i: e for e, i in zip(values, idx, strict=True)},
lambda values, idx: pd.Series(values, idx),
],
)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/multi/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_copy_in_constructor():
def test_from_arrays(idx):
arrays = [
np.asarray(lev).take(level_codes)
for lev, level_codes in zip(idx.levels, idx.codes)
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
]

# list of arrays as input
Expand All @@ -172,7 +172,7 @@ def test_from_arrays_iterator(idx):
# GH 18434
arrays = [
np.asarray(lev).take(level_codes)
for lev, level_codes in zip(idx.levels, idx.codes)
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
]

# iterator as input
Expand All @@ -188,7 +188,7 @@ def test_from_arrays_iterator(idx):
def test_from_arrays_tuples(idx):
arrays = tuple(
tuple(np.asarray(lev).take(level_codes))
for lev, level_codes in zip(idx.levels, idx.codes)
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
)

# tuple of tuples as input
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_from_tuples_iterator():
levels=[[1, 3], [2, 4]], codes=[[0, 1], [0, 1]], names=["a", "b"]
)

result = MultiIndex.from_tuples(zip([1, 3], [2, 4]), names=["a", "b"])
result = MultiIndex.from_tuples(zip([1, 3], [2, 4]), names=["a", "b"], strict=True)
tm.assert_index_equal(result, expected)

# input non-iterables
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_equivalence.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_equals_missing_values_differently_sorted():


def test_is_():
mi = MultiIndex.from_tuples(zip(range(10), range(10)))
mi = MultiIndex.from_tuples(zip(range(10), range(10), strict=True))
assert mi.is_(mi)
assert mi.is_(mi.view())
assert mi.is_(mi.view().view().view().view())
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def assert_matching(actual, expected, check_dtype=False):
# avoid specifying internal representation
# as much as possible
assert len(actual) == len(expected)
for act, exp in zip(actual, expected):
for act, exp in zip(actual, expected, strict=True):
act = np.asarray(act)
exp = np.asarray(exp)
tm.assert_numpy_array_equal(act, exp, check_dtype=check_dtype)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/period/methods/test_asfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_asfreq_mult_pi(self, freq):
def test_asfreq_combined_pi(self):
pi = PeriodIndex(["2001-01-01 00:00", "2001-01-02 02:00", "NaT"], freq="h")
exp = PeriodIndex(["2001-01-01 00:00", "2001-01-02 02:00", "NaT"], freq="25h")
for freq, how in zip(["1D1h", "1h1D"], ["S", "E"]):
for freq, how in zip(["1D1h", "1h1D"], ["S", "E"], strict=True):
result = pi.asfreq(freq, how=how)
tm.assert_index_equal(result, exp)
assert result.freq == exp.freq
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/period/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def test_constructor_year_and_quarter(self):
year = Series([2001, 2002, 2003])
quarter = year - 2000
idx = PeriodIndex.from_fields(year=year, quarter=quarter)
strs = [f"{t[0]:d}Q{t[1]:d}" for t in zip(quarter, year)]
strs = [f"{t[0]:d}Q{t[1]:d}" for t in zip(quarter, year, strict=True)]
lops = list(map(Period, strs))
p = PeriodIndex(lops)
tm.assert_index_equal(p, idx)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/period/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_representation(self, method):

for idx, expected in zip(
[idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9, idx10],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9, exp10],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9, exp10], strict=True,
):
result = getattr(idx, method)()
assert result == expected
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_representation_to_series(self):

for idx, expected in zip(
[idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], strict=True,
):
result = repr(Series(idx))
assert result == expected
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_summary(self):

for idx, expected in zip(
[idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9],
[exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], strict=True,
):
result = idx._summary()
assert result == expected
4 changes: 2 additions & 2 deletions pandas/tests/indexes/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ def test_fields(self, periodindex, field):

field_idx = getattr(periodindex, field)
assert len(periodindex) == len(field_idx)
for x, val in zip(periods, field_idx):
for x, val in zip(periods, field_idx, strict=True):
assert getattr(x, field) == val

if len(ser) == 0:
return

field_s = getattr(ser.dt, field)
assert len(periodindex) == len(field_s)
for x, val in zip(periods, field_s):
for x, val in zip(periods, field_s, strict=True):
assert getattr(x, field) == val

def test_is_(self):
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def test_map_with_tuples_mi(self):
# Test that returning a single object from a MultiIndex
# returns an Index.
first_level = ["foo", "bar", "baz"]
multi_index = MultiIndex.from_tuples(zip(first_level, [1, 2, 3]))
multi_index = MultiIndex.from_tuples(zip(first_level, [1, 2, 3], strict=True))
reduced_index = multi_index.map(lambda x: x[0])
tm.assert_index_equal(reduced_index, Index(first_level))

Expand Down Expand Up @@ -562,7 +562,7 @@ def test_map_tseries_indices_accsr_return_index(self):
@pytest.mark.parametrize(
"mapper",
[
lambda values, index: {i: e for e, i in zip(values, index)},
lambda values, index: {i: e for e, i in zip(values, index, strict=True)},
lambda values, index: Series(values, index),
],
)
Expand All @@ -576,7 +576,7 @@ def test_map_dictlike_simple(self, mapper):
@pytest.mark.parametrize(
"mapper",
[
lambda values, index: {i: e for e, i in zip(values, index)},
lambda values, index: {i: e for e, i in zip(values, index, strict=True)},
lambda values, index: Series(values, index),
],
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_map_callable(self, simple_index):
@pytest.mark.parametrize(
"mapper",
[
lambda values, index: {i: e for e, i in zip(values, index)},
lambda values, index: {i: e for e, i in zip(values, index, strict=True)},
lambda values, index: pd.Series(values, index, dtype=object),
],
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_old_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def test_map(self, simple_index):
@pytest.mark.parametrize(
"mapper",
[
lambda values, index: {i: e for e, i in zip(values, index)},
lambda values, index: {i: e for e, i in zip(values, index, strict=True)},
lambda values, index: Series(values, index),
],
)
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ def test_difference_incomparable_true(self, opname):
op(a)

def test_symmetric_difference_mi(self, sort):
index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3]))
index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3],
strict=True))
index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)])
result = index1.symmetric_difference(index2, sort=sort)
expected = MultiIndex.from_tuples([("bar", 2), ("baz", 3), ("bar", 3)])
Expand Down
Loading
Loading