-
Notifications
You must be signed in to change notification settings - Fork 21
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
circularity in AbstractDataContainer definitions #57
Comments
I agree its very confusing to have these definitions. The way I make sense of it is that we have an equivalence: The main reason that I added these definitions to All this being said, I really like this proposal:
This will ensure that any type has indexing and For a lot of cases, this also means being able to work with the package without adding an MLUtils.jl dep. |
So we can remove these lines? Base.getindex(x::AbstractDataContainer, i) = getobs(x, i)
Base.length(x::AbstractDataContainer) = numobs(x)
Base.size(x::AbstractDataContainer) = (length(x),) |
Yeah let's do it. |
We currently have the following definitions for
AbstractDataContainer
wheregetindex
falls back togetobs
and on the other end we have the generic fallback for
getobs
I find this circularity a bit confusing and think it should be avoided. I suggest we change
AbstractDataContainer
toThen types inheriting from
AbstractDataContainer
:getindex
if they want both the "indexing" interface and the "observable" interface.getobs
if for some reason they don't want to expose an indexing interfacegetobs
andgetindex
if the two interfaces serve different purposes (e.g. as with arrays)As an addendum, let me remark that with the
getobs(x, i) = getindex(x, i)
fallback we are basically saying that we consider a Dataset any type implementinggetindex
, which is something that maybe we should document more. Should defininggetindex
be the recommended way for defining custom dataset types (even if not subtypingAbstractDataContainer
)?@darsnack
related to JuliaML/MLDatasets.jl#96
The text was updated successfully, but these errors were encountered: