Skip to content

Commit

Permalink
unlimited dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Oct 29, 2023
1 parent 1ad7ebc commit 0b8d4db
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ end

Base.keys(a::Attributes) = attribnames(a.ds)
Base.getindex(a::Attributes,name) = attrib(a.ds,name)
Base.setindex(a::Attributes,name,data) = defAttrib(a.ds,name,data)
Base.setindex!(a::Attributes,data,name) = defAttrib(a.ds,name,data)

Check warning on line 65 in src/attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/attribute.jl#L65

Added line #L65 was not covered by tests
Base.show(io::IO,a::Attributes) = show_attrib(io,a)
2 changes: 1 addition & 1 deletion src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Base.getindex(groups::Groups,name) = group(groups.ds,name)
return Attributes(ds)
elseif (name == :dim) && !hasfield(typeof(ds),name)
return Dimensions(ds)

Check warning on line 198 in src/dataset.jl

View check run for this annotation

Codecov / codecov/patch

src/dataset.jl#L198

Added line #L198 was not covered by tests
elseif (name == :group) && !hasfield(typeof(ds),name) && (ds <: AbstractDataset)
elseif (name == :group) && !hasfield(typeof(ds),name) && (ds isa AbstractDataset)
return Groups(ds)

Check warning on line 200 in src/dataset.jl

View check run for this annotation

Codecov / codecov/patch

src/dataset.jl#L200

Added line #L200 was not covered by tests
else
return getfield(ds,name)
Expand Down
5 changes: 4 additions & 1 deletion src/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ end

Base.keys(dims::Dimensions) = dimnames(dims.ds)
Base.getindex(dims::Dimensions,name) = dim(dims.ds,name)
Base.setindex(dims::Dimensions,name,data) = defDim(dims.ds,name,data)
Base.setindex!(dims::Dimensions,data,name) = defDim(dims.ds,name,data)
Base.show(io::IO,dims::Dimensions) = show_dim(io,dims)

Check warning on line 73 in src/dimension.jl

View check run for this annotation

Codecov / codecov/patch

src/dimension.jl#L70-L73

Added lines #L70 - L73 were not covered by tests

unlimited(dims::Dimensions) = unlimited(dims.ds)

Check warning on line 75 in src/dimension.jl

View check run for this annotation

Codecov / codecov/patch

src/dimension.jl#L75

Added line #L75 was not covered by tests


Base.length(a::Iterable) = length(keys(a))

Check warning on line 78 in src/dimension.jl

View check run for this annotation

Codecov / codecov/patch

src/dimension.jl#L78

Added line #L78 was not covered by tests

function Base.iterate(a::Iterable, state = collect(keys(a)))
Expand Down
6 changes: 3 additions & 3 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ Optionally a variable can have attributes:
For a writable-dataset, one should also implement:
* `defAttrib`: define a attribute
* `Base.setindex(v,data,indices...)`: set the data in `v` at the provided indices
* `Base.setindex!(v,data,indices...)`: set the data in `v` at the provided indices
"""
abstract type AbstractVariable{T,N} <: AbstractArray{T, N}
end

"""
A collection of attributes with a Dict-like interface dispatching to
`attribnames`, `attrib`, `defAttrib` for `keys`, `getindex` and `setindex`
`attribnames`, `attrib`, `defAttrib` for `keys`, `getindex` and `setindex!`
respectively.
"""
struct Attributes{TDS<:Union{AbstractDataset,AbstractVariable}} <: AbstractDict{SymbolOrString,Any}
Expand All @@ -65,7 +65,7 @@ end

"""
A collection of dimensions with a Dict-like interface dispatching to
`dimnames`, `dim`, `defDim` for `keys`, `getindex` and `setindex`
`dimnames`, `dim`, `defDim` for `keys`, `getindex` and `setindex!`
respectively.
"""
struct Dimensions{TDS<:AbstractDataset} <: AbstractDict{SymbolOrString,Any}
Expand Down

0 comments on commit 0b8d4db

Please sign in to comment.