-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
[Bug] Comparison between two PeriodIndexes doesn't validate length (GH #23078) #23896
Changes from all commits
9bca2c9
d64c7df
2892ee3
83c619f
154e279
ac94453
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 |
---|---|---|
|
@@ -119,6 +119,12 @@ def test_direct_arith_with_series_returns_not_implemented(self, data): | |
"{} does not implement add".format(data.__class__.__name__) | ||
) | ||
|
||
def test_arith_diff_lengths(self, data, all_arithmetic_operators): | ||
op = self.get_op_from_name(all_arithmetic_operators) | ||
other = data[:3] | ||
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 test actually wouldn't catch the behavior in #23078, which is caused specifically by comparisons of PeriodIndex with length-1 objects. 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. The issue in #23078 was treated in the function test_comp_op (pandas/tests/indexes/period/test_period.py). |
||
with pytest.raises(ValueError): | ||
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. can you match the message as well |
||
op(data, other) | ||
|
||
|
||
class BaseComparisonOpsTests(BaseOpsUtil): | ||
"""Various Series and DataFrame comparison ops methods.""" | ||
|
@@ -164,3 +170,9 @@ def test_direct_arith_with_series_returns_not_implemented(self, data): | |
raise pytest.skip( | ||
"{} does not implement __eq__".format(data.__class__.__name__) | ||
) | ||
|
||
def test_compare_diff_lengths(self, data, all_compare_operators): | ||
op = self.get_op_from_name(all_compare_operators) | ||
other = data[:3] | ||
with pytest.raises(ValueError): | ||
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. match the message |
||
op(data, other) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,13 @@ def _check_divmod_op(self, s, op, other, exc=NotImplementedError): | |
def test_error(self): | ||
pass | ||
|
||
# TODO | ||
# Raise ValueError when carrying out arithmetic operation | ||
# on two decimal arrays of different lengths | ||
@pytest.mark.xfail(reason="raise of ValueError not implemented") | ||
def test_arith_diff_lengths(self, data, all_compare_operators): | ||
super().test_arith_diff_lengths(data, all_compare_operators) | ||
|
||
|
||
class TestComparisonOps(BaseDecimal, base.BaseComparisonOpsTests): | ||
|
||
|
@@ -324,6 +331,12 @@ def test_compare_array(self, data, all_compare_operators): | |
for i in alter] | ||
self._compare_other(s, data, op_name, other) | ||
|
||
# TODO: | ||
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. why are these xfail? make the change as needed in the decimal code |
||
# Raise ValueError when comparing decimal arrays of different lenghts | ||
@pytest.mark.xfail(reason="raise of ValueError not implemented") | ||
def test_compare_diff_lengths(self, data, all_compare_operators): | ||
super().test_compare_diff_lenths(data, all_compare_operators) | ||
|
||
|
||
class DecimalArrayWithoutFromSequence(DecimalArray): | ||
"""Helper class for testing error handling in _from_sequence.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,9 +291,13 @@ def _check_divmod_op(self, s, op, other, exc=NotImplementedError): | |
s, op, other, exc=TypeError | ||
) | ||
|
||
def test_arith_diff_lengths(self): | ||
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. why are these added? |
||
pass | ||
|
||
|
||
class TestComparisonOps(BaseJSON, base.BaseComparisonOpsTests): | ||
pass | ||
def test_compare_diff_lengths(self): | ||
pass | ||
|
||
|
||
class TestPrinting(BaseJSON, base.BasePrintingTests): | ||
|
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.
use double backticks around ValueError