-
Notifications
You must be signed in to change notification settings - Fork 28
Update rt_categorical.py #114
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
base: master
Are you sure you want to change the base?
Update rt_categorical.py #114
Conversation
Handles passing empty list by actually checking if there is one element;
>>>>rt.Cat([1]).isin([])
_categorical_compare_check raise ValueError("List was empty.")
>>> rt.Cat([1]).isin([1])
FastArray([ True])
>>> rt.Cat([1]).isin([2])
FastArray([False])
>>> rt.Cat([1]).isin([1,2])
FastArray([ True])
|
Thanks! Looks like this is to fix #105, is that right? Would you mind adding a quick unit test for this case (of the empty input list), both to demonstrate it works correctly and also to ensure it stays working correctly if anyone's making changes to the |
|
I'll work on it this week
…On Tue, Mar 23, 2021, 1:42 PM Jack Pappas ***@***.***> wrote:
Thanks! Looks like this is to fix #105
<#105>, is that right?
Would you mind adding a quick unit test for this case (of the empty input
list), both to demonstrate it works correctly and also to ensure it
*stays* working correctly if anyone's making changes to the Categorical
code in the future?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADQS5K5675DD7AOTVW7K7TTFDHJJANCNFSM4YXV4OTA>
.
|
|
@jack-pappas it is a fix for #105, working on unit test now |
|
@jack-pappas it fails under test_categorical.py line 1606-1611:
Is there something else I can do? Do you want it to be more explicit? |
|
File "", line 1, in |
|
@3keepmovingforward3 Sorry about taking so long to respond to your question, I was caught up with some other projects this past week. The test at test_categorical.py line 1606-1611 is for creating a @pytest.mark.parametrize(
'cat',
[
pytest.param(rt.Cat(['red' , 'green', 'blue', 'green', 'red', 'red', 'blue', 'green']), id="single-key string cat"),
]
)
@pytest.mark.parametrize(
'seq',
[
pytest.param([], id='list'),
pytest.param(set(), id='set'),
pytest.param(rt.FA([]), id='FastArray'),
]
)
def test_categorical_isin_empty(cat: rt.Categorical, seq) -> None:
# Test the .isin() method on a Categorical produces an empty result when called with an empty array-like input.
result = cat.isin(seq)
assert_array_equal(rt.FA([]), result) |
Handles passing empty list by actually checking if there is one element;