Skip to content

Commit 647b6ea

Browse files
Parametrize GridAV on the vector type (#29)
* Parametrize GridAV on the vector type * Update ndgrid-avect.jl fix doctest --------- Co-authored-by: Jeff Fessler <JeffFessler@users.noreply.github.com>
1 parent fc7b70b commit 647b6ea

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/ndgrid-avect.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export ndgrid
1111
The `d`th component of `D`-dimensional `ndgrid(v₁, v₂, ...)`
1212
where `1 ≤ d ≤ D` and `v_d` is an `AbstractVector`.
1313
"""
14-
struct GridAV{T,d,D} <: AbstractGrid{T,d,D}
14+
struct GridAV{T,d,D,V <: AbstractVector{T}} <: AbstractGrid{T,d,D}
1515
dims::Dims{D}
16-
v::AbstractVector{T}
16+
v::V
1717

18-
function GridAV(dims::Dims{D}, v::AbstractVector{T}, d::Int) where {D, T}
18+
function GridAV(dims::Dims{D}, v::V, d::Int) where {D, T, V <: AbstractVector{T}}
1919
1 d D || throw(ArgumentError("$d for $dims"))
20-
new{T,d,D}(dims, v)
20+
new{T,d,D,V}(dims, v)
2121
end
2222
end
2323

@@ -43,7 +43,7 @@ _grid_type(d::Int, D::Int, ::Base.OneTo{T}) where T = GridOT{T, d, D}
4343
_grid_type(d::Int, D::Int, ::UnitRange{T}) where T = GridUR{T, d, D}
4444
_grid_type(d::Int, D::Int, ::StepRangeLen{T,R,S}) where {T,R,S} = GridSL{T, d, D, R, S}
4545
_grid_type(d::Int, D::Int, v::AbstractRange{T}) where T = GridAR{T, d, D, typeof(step(v))}
46-
_grid_type(d::Int, D::Int, ::AbstractVector{T}) where T = GridAV{T, d, D}
46+
_grid_type(d::Int, D::Int, ::V) where {T, V <: AbstractVector{T}} = GridAV{T, d, D, V}
4747

4848

4949
"""
@@ -65,7 +65,7 @@ julia> xg
6565
3 3
6666
6767
julia> yg
68-
3×2 LazyGrids.GridAV{Symbol, 2, 2}:
68+
3×2 LazyGrids.GridAV{Symbol, 2, 2, Vector{Symbol}}:
6969
:a :b
7070
:a :b
7171
:a :b

0 commit comments

Comments
 (0)