-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement SubDataset * fix test on view(::Dataset,...) * test equal dimensions in views * update CHANGELOG and version * upodated definitions to abstract Co-authored-by: Datseris <[email protected]>
- Loading branch information
Showing
15 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
SubDataset{D, T, <:AbstractDataset{D,T}, <:SubArray{<:SVector{D,T},1}} <: AbstractDataset{D,T} | ||
A view of an `AbstractDataset`, as returned by the `view` function | ||
or the `@view` macro. A `SubDataset` is an `AbstractDataset` | ||
of the same type as its parent, so indexing and most functions | ||
can be expected to work in the same way for both the parent and the view. | ||
""" | ||
struct SubDataset{D, T, P<:AbstractDataset{D,T}, S<:SubArray{<:SVector{D,T},1}} <: AbstractDataset{D,T} | ||
parent::P | ||
data::S | ||
function SubDataset(par, data) | ||
@assert parent(data) === par.data | ||
P = typeof(par) | ||
S = typeof(data) | ||
SV = eltype(P) | ||
T = eltype(SV) | ||
D = length(SV) | ||
new{D,T,P,S}(par, data) | ||
end | ||
end | ||
|
||
function Base.summary(sd::SubDataset{D, T}) where {D, T} | ||
N = length(sd) | ||
return "$N-element view of $D-dimensional Dataset{$(T)}" | ||
end | ||
|
||
Base.parent(sd::SubDataset) = sd.parent | ||
Base.parentindices(sd::SubDataset) = parentindices(sd.data) | ||
|
||
""" | ||
view(d::Dataset, indices) | ||
Return a view into the parent dataset `d`, as a [`SubDataset`](@ref) | ||
that contains the datapoints of `d` referred to by `indices`. | ||
""" | ||
Base.view(d::AbstractDataset, i) = SubDataset(d, view(d.data, i)) | ||
|
||
function Base.view(::AbstractDataset, ::Any, ::Any, ::Vararg) | ||
throw(ArgumentError("Dataset views only accept indices on one dimension")) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters