Skip to content

Commit

Permalink
Maybe Breaking (?): add missing IteratorSize method for dimensions (#822
Browse files Browse the repository at this point in the history
)

* add missing IteratorSize method for dimensions

* test generator constructor
  • Loading branch information
rafaqz authored Nov 1, 2024
1 parent 68ea50b commit aa0d4b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Dimensions/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ Base.first(d::Dimension) = val(d)
Base.first(d::Dimension{<:AbstractArray}) = first(lookup(d))
Base.last(d::Dimension) = val(d)
Base.last(d::Dimension{<:AbstractArray}) = last(lookup(d))
Base.IteratorSize(d::Dimension{<:AbstractArray}) = Base.IteratorSize(parent(d))
Base.firstindex(d::Dimension) = 1
Base.lastindex(d::Dimension) = 1
Base.firstindex(d::Dimension{<:AbstractArray}) = firstindex(lookup(d))
Expand Down
5 changes: 5 additions & 0 deletions test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ end
@test_throws ArgumentError fill(5.0, (X(:e), Y(8)))
end


@testset "generator constructor" begin
[(x, y) for x in X(10:10:50), y in Y(0.0:0.1:1.0)]
end

@testset "ones, zeros, trues, falses constructors" begin
da = @inferred zeros(X(4), Y(40.0:10.0:80.0; order=ForwardOrdered()); metadata=(a=1, b=2))
@test eltype(da) <: Float64
Expand Down

0 comments on commit aa0d4b0

Please sign in to comment.