Skip to content
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

Add firstindex(::AbstractDataContainer) #164

Merged
merged 2 commits into from
Aug 26, 2023
Merged

Conversation

Pangoraw
Copy link
Contributor

This enables the begin keyword when indexing an
AbstractDataContainer. Note that end already worked when indexing
because of lastindex(::AbstractDataContainer) is already implemented. For example:

julia> using MLDatasets

julia> mnist = MNIST()

julia> x, y = mnist[begin]
(features = Float32[0.0 0.0  0.0 0.0; 0.0 0.0  0.0 0.0;  ; 0.0 0.0  0.0 0.0; 0.0 0.0  0.0 0.0], targets = 5)

This enables the `begin` keyword when indexing an
`AbstractDataContainer`. Note that `end` already worked when indexing
because of `lastindex(::AbstractDataContainer)` is already implemented. For example:

```julia
julia> using MLDatasets

julia> mnist = MNIST()

julia> x, y = mnist[begin]
(features = Float32[0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0], targets = 5)
```
@ToucheSir
Copy link
Contributor

Could you add a test? Maybe one that uses begin. Otherwise LGTM.

@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

Merging #164 (619ef01) into main (03f8fb1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
+ Coverage   88.50%   88.51%   +0.01%     
==========================================
  Files          15       15              
  Lines         600      601       +1     
==========================================
+ Hits          531      532       +1     
  Misses         69       69              
Files Changed Coverage Δ
src/observation.jl 87.75% <100.00%> (+0.25%) ⬆️

Copy link
Contributor

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ToucheSir ToucheSir merged commit 3a7d3e3 into JuliaML:main Aug 26, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants