Skip to content

Commit 702623f

Browse files
rofinnmbauman
authored andcommitted
Moved axisnames earlier in core.jl (#132)
In order to include AxisArrays in system images we needed to move the `axisnames` definitions earlier in the core.jl file. This appears to be an issue with generated functions and system images. In this case, we're calling the generated similar function which reference axisdim outside of the quote block, which then referenced the axisnames methods defined later in the file.
1 parent 73fbf54 commit 702623f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Diff for: src/core.jl

+18-18
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ HasAxes(::Type{<:AxisArray}) = HasAxes{true}()
222222
HasAxes(::Type{<:AbstractArray}) = HasAxes{false}()
223223
HasAxes(::A) where A<:AbstractArray = HasAxes(A)
224224

225+
"""
226+
axisnames(A::AxisArray) -> (Symbol...)
227+
axisnames(::Type{AxisArray{...}}) -> (Symbol...)
228+
axisnames(ax::Axis...) -> (Symbol...)
229+
axisnames(::Type{Axis{...}}...) -> (Symbol...)
230+
231+
Returns the axis names of an AxisArray or list of Axises as a tuple of Symbols.
232+
"""
233+
axisnames(::AxisArray{T,N,D,Ax}) where {T,N,D,Ax} = _axisnames(Ax)
234+
axisnames(::Type{AxisArray{T,N,D,Ax}}) where {T,N,D,Ax} = _axisnames(Ax)
235+
axisnames(::Type{Ax}) where {Ax<:Tuple{Vararg{Axis}}} = _axisnames(Ax)
236+
@pure _axisnames(Ax) = axisnames(Ax.parameters...)
237+
axisnames() = ()
238+
@inline axisnames(::Axis{name}, B::Axis...) where {name} = tuple(name, axisnames(B...)...)
239+
@inline axisnames(::Type{<:Axis{name}}, B::Type...) where {name} = tuple(name, axisnames(B...)...)
240+
241+
axisname(::Union{Type{<:Axis{name}},Axis{name}}) where {name} = name
242+
225243
# Axis definitions
226244
"""
227245
axisdim(::AxisArray, ::Axis) -> Int
@@ -449,24 +467,6 @@ function Base.summary(A::AxisArray)
449467
end
450468

451469
# Custom methods specific to AxisArrays
452-
"""
453-
axisnames(A::AxisArray) -> (Symbol...)
454-
axisnames(::Type{AxisArray{...}}) -> (Symbol...)
455-
axisnames(ax::Axis...) -> (Symbol...)
456-
axisnames(::Type{Axis{...}}...) -> (Symbol...)
457-
458-
Returns the axis names of an AxisArray or list of Axises as a tuple of Symbols.
459-
"""
460-
axisnames(::AxisArray{T,N,D,Ax}) where {T,N,D,Ax} = _axisnames(Ax)
461-
axisnames(::Type{AxisArray{T,N,D,Ax}}) where {T,N,D,Ax} = _axisnames(Ax)
462-
axisnames(::Type{Ax}) where {Ax<:Tuple{Vararg{Axis}}} = _axisnames(Ax)
463-
@pure _axisnames(Ax) = axisnames(Ax.parameters...)
464-
axisnames() = ()
465-
@inline axisnames(::Axis{name}, B::Axis...) where {name} = tuple(name, axisnames(B...)...)
466-
@inline axisnames(::Type{<:Axis{name}}, B::Type...) where {name} = tuple(name, axisnames(B...)...)
467-
468-
axisname(::Union{Type{<:Axis{name}},Axis{name}}) where {name} = name
469-
470470
"""
471471
axisvalues(A::AxisArray) -> (AbstractVector...)
472472
axisvalues(ax::Axis...) -> (AbstractVector...)

0 commit comments

Comments
 (0)