-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
STY: Enforce Ruff rule B905 for pandas/tests #62564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the files you modified from pyproject.toml
.
if isinstance(key, np.ndarray) and key.dtype == "bool": | ||
# masking | ||
for i, (k, v) in enumerate(zip(key, value)): | ||
for i, (k, v) in enumerate(zip(key, value, strict=False)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When value
is assigned to cycle
it should be strict=False
otherwise, I think it can be strict=True
.
self.data[i] = v | ||
else: | ||
for k, v in zip(key, value): | ||
for k, v in zip(key, value, strict=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
# non-unique - wheee! | ||
nu_df = DataFrame( | ||
list(zip(range(3), range(-3, 1), list("abc"))), columns=["a", "a", "b"] | ||
list(zip(range(3), range(-3, 1), list("abc"), strict=False)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list(zip(range(3), range(-3, 1), list("abc"), strict=False)), | |
list(zip(range(3), range(-3, 0), list("abc"), strict=True)), |
result = gb.apply(lambda grp: pd.DataFrame({"values": range(len(grp))})) | ||
|
||
mi_tuples = tuple(zip(data["groups"], selected_data["values"])) | ||
mi_tuples = tuple(zip(data["groups"], selected_data["values"], strict=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
expecteds = [DataFrame(values, index=index) for (values, index) in expected] | ||
|
||
for expected, actual in zip(expecteds, df.expanding(min_periods)): | ||
for expected, actual in zip(expecteds, df.expanding(min_periods), strict=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which test cases require this to be marked as False?
|
||
for expected, actual in zip(expecteds, df.rolling(window, min_periods=min_periods)): | ||
for expected, actual in zip( | ||
expecteds, df.rolling(window, min_periods=min_periods), strict=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which test cases require this to be marked as False?
DataFrame(values, index=df.loc[index, "C"]) for (values, index) in expected | ||
] | ||
for expected, actual in zip(expecteds, df.rolling(window, on="C")): | ||
for expected, actual in zip(expecteds, df.rolling(window, on="C"), strict=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which test cases require this to be marked as False?
Part of #62434
This PR enforces Ruff rule B905 (
zip-without-explicit-strict
) across the pandas test suite by addingstrict=True
to all relevantzip()
calls inpandas/tests
.zip(...)
in test files to usezip(..., strict=True)
where appropriate.Checklist:
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Please let me know if any changes are needed!