-
Notifications
You must be signed in to change notification settings - Fork 370
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
implement firstindex, lastindex, axes, size, and ndims consistently #2573
Conversation
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.
Sure, looks good. Though if Base adds a fallback maybe we won't need all of these?
We need them, because earlier versions of Julia will not have them so this way we maintain consistency and make sure DataFrames.jl codes work on all versions of Julia post 1.0. Also the major decision is if we really want all those methods defined. What I mean is that in Julia Base you now have for example:
so the question is if we define them now for objects in DataFrames.jl - can we have some problems with consistency with Julia Base in the future. @mbauman, @StefanKarpinski - could you please give some guidance when non-array types are allowed to safely define a method for Thank you! |
@nalimilan - this should be good for a review. I have come to the following conclusion that for array interface ( The issue is that Julia Base sometimes is not clear in distinction between using term "index" and "key" for
Also I am strict with |
CI passes |
Makes sense. Just a few comments. |
src/abstractdataframe/iteration.jl
Outdated
Base.firstindex(itr::DataFrameColumns, i::Integer) = first(axes(itr, i)) | ||
Base.lastindex(itr::DataFrameColumns, i::Integer) = last(axes(itr, i)) | ||
Base.axes(itr::DataFrameColumns, i::Integer) = Base.OneTo(size(itr, i)) |
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 we need these in the end given that a fallback was added to Base?
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.
this fallback is only in 1.6. I added it to have it also e.g. in 1.0 in case someone in the future uses these functions in user code explicitly.
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.
Maybe add a VERSION
check? It's always nice to be able to remove code at some point in the future. :-)
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.
added - checking if I did it correctly is welcome ;). Thank you!
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.
@nalimilan - does the version check look good to you now?
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Does this PR look OK now? |
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.
Yes, sorry, for some reason I had missed the notifications.
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
I have added NEWS.md entry. |
Thank you! |
This makes sure we have a complete indexing API for all types we expose. I hope I have not missed anything.
@nalimilan - if you are OK with this approach I will add tests and make it ready for a review.