Skip to content

TST/CLN: parameterize/dedup replace test2 #41501

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

Merged
merged 3 commits into from
May 19, 2021

Conversation

mzeitlin11
Copy link
Member

No description provided.

@mzeitlin11 mzeitlin11 added Clean replace replace method Testing pandas testing functions or related to the test suite labels May 16, 2021
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mzeitlin11 generally lgtm. can you rename the variables to avoid confusion and maybe move the result assignment outside a conditional (by either conditional setting arguments or skipping to avoid the redundant permutation )

],
)
@pytest.mark.parametrize(
"regex,value", [(r"\s*\.\s*", np.nan), (r"\s*(\.)\s*", r"\1\1\1")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regex -> to_replace to match DataFrame.replace parameter name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

"regex,value", [(r"\s*\.\s*", np.nan), (r"\s*(\.)\s*", r"\1\1\1")]
)
@pytest.mark.parametrize("compile_regex", [True, False])
@pytest.mark.parametrize("use_regex_value_arg", [True, False])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_regex_value_arg -> regex (or regex_kwarg)

There's also a redundant permutation here can maybe add a skip for that case instead of calling with regex=True explictily.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed arg. Could you please elaborate on the redundant permutation here? Are you referring to when compile_regex=True and regex_kwarg=False (so regex=True does not really need to be specified?)

assert return_value is None
tm.assert_frame_equal(dfobj, res.fillna("."))
if use_regex_value_arg:
result = df.replace(regex=regex, value=value, inplace=inplace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put the arguments in the same order as the parameters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@simonjayhawkins simonjayhawkins added this to the 1.3 milestone May 16, 2021
@jreback
Copy link
Contributor

jreback commented May 17, 2021

wow, lgtm.

@jreback jreback merged commit bda839c into pandas-dev:master May 19, 2021
@jreback
Copy link
Contributor

jreback commented May 19, 2021

thanks @mzeitlin11

TLouf pushed a commit to TLouf/pandas that referenced this pull request Jun 1, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean replace replace method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants