-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
REF: StringArray._from_sequence, use less memory #35519
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
Changes from 1 commit
df8e4d6
ac7ee27
887736a
61f3bd3
c6afa1e
ce18bb9
9ef0355
3db2884
47b5d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,12 +206,16 @@ def test_constructor_raises(): | |
|
||
@pytest.mark.parametrize("copy", [True, False]) | ||
def test_from_sequence_no_mutate(copy): | ||
a = np.array(["a", np.nan], dtype=object) | ||
original = a.copy() | ||
result = pd.arrays.StringArray._from_sequence(a, copy=copy) | ||
expected = pd.arrays.StringArray(np.array(["a", pd.NA], dtype=object)) | ||
nan_arr = np.array(["a", np.nan], dtype=object) | ||
na_arr = np.array(["a", pd.NA], dtype=object) | ||
|
||
result = pd.arrays.StringArray._from_sequence(nan_arr, copy=copy) | ||
expected = pd.arrays.StringArray(na_arr) | ||
|
||
tm.assert_extension_array_equal(result, expected) | ||
tm.assert_numpy_array_equal(a, original) | ||
|
||
expected = nan_arr if copy else na_arr | ||
tm.assert_numpy_array_equal(nan_arr, expected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this test is correctly changed. I think we should never mutate the input, whether copy is True or False (which is what it was testing before). It's also not taking a copy of the original array, so not even checking it wasn't changed (because even if it was changed, it would still compare equal to itself) |
||
|
||
|
||
def test_astype_int(): | ||
|
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.
this should return a new array
and pls
add a doc string
also i think we have a routine like this already