-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST/BUG (string dtype): Fix and adjust indexes string tests #59544
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 2 commits
b6f7130
37252ef
093fede
fcfefdb
d716472
fb5718e
e0878ce
460e60a
5516275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,16 +76,13 @@ def test_constructor_casting(self, index): | |
tm.assert_contains_all(arr, new_index) | ||
tm.assert_index_equal(index, new_index) | ||
|
||
@pytest.mark.xfail( | ||
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)" | ||
) | ||
def test_constructor_copy(self, using_infer_string): | ||
index = Index(list("abc"), name="name") | ||
arr = np.array(index) | ||
new_index = Index(arr, copy=True, name="name") | ||
assert isinstance(new_index, Index) | ||
assert new_index.name == "name" | ||
if using_infer_string: | ||
if using_infer_string and HAS_PYARROW: | ||
tm.assert_extension_array_equal( | ||
new_index.values, pd.array(arr, dtype="str") | ||
) | ||
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. This one I don't understand. Why is 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. Yeah I thought I rolled that one back, the change was just something I tried. Updated now |
||
|
@@ -343,11 +340,6 @@ def test_constructor_empty_special(self, empty, klass): | |
def test_view_with_args(self, index): | ||
index.view("i8") | ||
|
||
@pytest.mark.xfail( | ||
using_string_dtype() and not HAS_PYARROW, | ||
reason="TODO(infer_string)", | ||
strict=False, | ||
) | ||
@pytest.mark.parametrize( | ||
"index", | ||
[ | ||
|
@@ -364,7 +356,7 @@ def test_view_with_args_object_array_raises(self, index): | |
msg = "When changing to a larger dtype" | ||
with pytest.raises(ValueError, match=msg): | ||
index.view("i8") | ||
elif index.dtype == "string": | ||
elif index.dtype == "str" and not index.dtype.storage == "python": | ||
with pytest.raises(NotImplementedError, match="i8"): | ||
index.view("i8") | ||
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. This is just testing a different error, right? (just to understand why this has a separate branch) (ideally we should also make it a TypeError, I assume, maybe can add a TODO note) 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. added a TODO |
||
else: | ||
|
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 is related to what you mentioned on slack, I assume?
Whether we consider a
set
as sequence as valid input for constructors or not (IMO it would also be fine to not do that more generally)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.
Yes, correct. It#s explicitly allowed for Index, so we shouldn't break this now
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.
I see, for
Series(..)
we disallow it explicitly, but forIndex(..)
it currently works for non-EA dtypes. Sounds good to allow that for now.