Skip to content

[ArrowStringArray] TST/CLN: cleanup str.replace tests #41600

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 21, 2021

Conversation

simonjayhawkins
Copy link
Member

pre-cursor to #41590

@simonjayhawkins simonjayhawkins added Testing pandas testing functions or related to the test suite Clean labels May 21, 2021
@simonjayhawkins simonjayhawkins added this to the 1.3 milestone May 21, 2021
tm.assert_series_equal(result, expected)


def test_replace_regex_default_warning(any_string_dtype):
Copy link
Member Author

Choose a reason for hiding this comment

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

this one from pandas/tests/series/methods/test_replace.py and split and tested result

tm.assert_series_equal(result, expected)


def test_replace_regex_default_warning_single_character(any_string_dtype):
Copy link
Member Author

Choose a reason for hiding this comment

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

split since we don't have testing for the default behavior treating a single character as a literal

@@ -148,6 +152,81 @@ def test_contains_na_kwarg_for_nullable_string_dtype(
tm.assert_series_equal(result, expected)


def test_contains_moar(any_string_dtype):
Copy link
Member Author

Choose a reason for hiding this comment

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

moved from later in the file, collocated with other str.contains tests

ser.str.replace(pat, "", regex=False)


def test_replace_moar(any_string_dtype):
Copy link
Member Author

Choose a reason for hiding this comment

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

moved from later in the file, collocated with other str.replace tests

tm.assert_series_equal(result, expected)

expected = Series(["foo__barBAD", np.nan], dtype=any_string_dtype)
result = ser.str.replace("BAD", "", n=1, regex=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

no coverage for n with regex=False

@pep8speaks
Copy link

pep8speaks commented May 21, 2021

Hello @simonjayhawkins! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-05-21 10:53:20 UTC

# https://github.com/pandas-dev/pandas/pull/24809

# The current behavior is to treat single character patterns as literal strings,
# even when ``regex`` is set to ``True``.
Copy link
Member Author

Choose a reason for hiding this comment

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

add commit to parametrize this test.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

great!

[False, False, False, True, False, False, np.nan, False, False, False],
dtype=expected_dtype,
)
tm.assert_series_equal(result, expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

could parmaeterize at some point

Copy link
Member Author

Choose a reason for hiding this comment

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

sure. not doing too many changes in one pass to keep the diff simpler

@jreback jreback merged commit 7424f8a into pandas-dev:master May 21, 2021
@simonjayhawkins simonjayhawkins deleted the test-replace branch May 21, 2021 15:41
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 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