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;