-
Notifications
You must be signed in to change notification settings - Fork 13
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
Confusing levels
fallback
#54
Comments
The problem is different. The function is correct, but it is defined for all collections, e.g.:
The problem is, that many collections, like The same problem is with What we maybe could do is changing that |
There are also arrays commonly perceived as individual values - most notably, My point is that "levels of a collection" and "levels of a value" are fundamentally different functions, if talking about their generic versions, not specific |
Let me summarize the discussion, so that I am clear what problem we want to resolve (I think you raised it in Slack but I do not remember the details, and soon it will be lost on Slack). Current state is the following:
In what cases the current behavior is problematic (I mean in practice; I understand your conceptual concerns so there is no need to comment on this). |
First, I saw the So, currently it looks like |
I understand the current design the opposite way (I do not want to say that it should not be changed, but I want to express my current understanding of the design):
So, you should not call Therefore, what you essentially ask for is how to check that a non-collection is An alternative would be to add something like |
Yes, I do understand the levels-of-collection PoV, maybe it's more common indeed. I'm talking from the perspective of someone who only needed "parent levels" of a single value, and found that the |
Agreed. That is why maybe adding |
Yes, I think the best solution would be to add an API that allows checking whether a value or array is categorical, whose only implementations (currently) would be It's true that the fact that the |
And for the mean time having CategoricalArrays.jl as a dependency is a temporary solution. |
Looking at the concrete implementation of
levels
inCategoricalArrays
, I see that this function conveniently extracts possible levels from both arrays and individual values:However, the fallback implemented in
DataAPI
itself is only correct for collections, not individual values:Maybe, the fallback shouldn't exist at all, and something like
haslevels(x)::Bool
added instead?The text was updated successfully, but these errors were encountered: