-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST/REF: arithmetic tests for BooleanArray + consolidate with integer masked tests #34623
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
TST/REF: arithmetic tests for BooleanArray + consolidate with integer masked tests #34623
Conversation
with pytest.raises(TypeError): | ||
ops(pd.Timestamp("20180101")) | ||
@pytest.fixture | ||
def b(): |
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.
would it be burdensome to give a and b more informative names?
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.
Do you have a suggestion what you would find clearer?
Basically, before moving it to a fixture, I had:
def test_..():
a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
b = pd.array([True, False, None] * 3, dtype="boolean")
result = op(a, b)
in each test, and I would think in such a context you would be fine with those names?
And although I like defining those variables inside the test as more explicit, it was also a bit repetitive, so I moved it to a fixture.
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 would call these left_array, right_array
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.
Renamed
small comment; LGTM |
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.
looks pretty good
pandas/_testing.py
Outdated
@@ -2758,3 +2759,28 @@ def get_cython_table_params(ndframe, func_names_and_expected): | |||
if name == func_name | |||
] | |||
return results | |||
|
|||
|
|||
def get_op_from_name(op_name): |
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.
can you type op_name and return type
with pytest.raises(TypeError): | ||
ops(pd.Timestamp("20180101")) | ||
@pytest.fixture | ||
def b(): |
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 would call these left_array, right_array
"floordiv", | ||
"mod", | ||
pytest.param( | ||
"pow", marks=pytest.mark.xfail(reason="TODO follow int8 behaviour?") |
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.
is there an issue number?
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.
Not yet, will open one.
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.
-> #34686
tm.assert_extension_array_equal(result, expected) | ||
|
||
|
||
# Test generic charachteristics / errors |
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.
sp?
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.
Does "sp" point to the typo in this title? Or did you mean something else?
tm.assert_series_equal(result, expected) | ||
|
||
|
||
# Test generic charachteristics / errors |
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.
sp?
Updated for all comments |
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.
lgtm.
@@ -2758,3 +2759,28 @@ def get_cython_table_params(ndframe, func_names_and_expected): | |||
if name == func_name | |||
] | |||
return results | |||
|
|||
|
|||
def get_op_from_name(op_name: str) -> Callable: |
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.
IIRC we have something similiar in internals, maybe we should consolidate (just a thought) and certainly. in a followon
thanks @jorisvandenbossche |
Follow-up on #34454
integer/test_arithmetic.py
tomasked/test_arithmetic.py
so those can be shared with boolean (and once merged I can add float as well in the FloatingArray PR)boolean/test_arithmetic.py
to follow the same pattern as we have ininteger/test_arithmetic.py
.pd.NA
scalar as other operand.