Skip to content

Commit

Permalink
Merge pull request #114 from SciML/generatedfuncslast
Browse files Browse the repository at this point in the history
Get tests to pass when running Julia with `--compiled-modules=no`.
  • Loading branch information
chriselrod authored Feb 2, 2021
2 parents de8f865 + 44b06f2 commit 854a4b8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ArrayInterface"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.0.0"
version = "3.0.1"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ end

include("static.jl")
include("ranges.jl")
include("dimensions.jl")
include("indexing.jl")
include("dimensions.jl")
include("stridelayout.jl")

function __init__()
Expand Down
40 changes: 30 additions & 10 deletions src/dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,27 @@ end
@inline function axes_types(::Type{T}) where {P,I,T<:SubArray{<:Any,<:Any,P,I}}
return _sub_axes_types(Val(ArrayStyle(T)), I, axes_types(P))
end
@inline function axes_types(::Type{T}) where {T<:Base.ReinterpretArray}
return _reinterpret_axes_types(
axes_types(parent_type(T)),
eltype(T),
eltype(parent_type(T)),
)
end
function axes_types(::Type{T}) where {N,T<:Base.ReshapedArray{<:Any,N}}
return Tuple{Vararg{OptionallyStaticUnitRange{One,Int},N}}
end

# These methods help handle identifying axes that don't directly propagate from the
# parent array axes. They may be worth making a formal part of the API, as they provide
# a low traffic spot to change what axes_types produces.
@inline function sub_axis_type(::Type{A}, ::Type{I}) where {A,I}
if known_length(I) === nothing
return OptionallyStaticUnitRange{One,Int}
else
return OptionallyStaticUnitRange{One,StaticInt{known_length(I)}}
end
end
@generated function _sub_axes_types(
::Val{S},
::Type{I},
Expand All @@ -264,13 +285,15 @@ end
end
Expr(:block, Expr(:meta, :inline), out)
end

@inline function axes_types(::Type{T}) where {T<:Base.ReinterpretArray}
return _reinterpret_axes_types(
axes_types(parent_type(T)),
eltype(T),
eltype(parent_type(T)),
)
@inline function reinterpret_axis_type(::Type{A}, ::Type{T}, ::Type{S}) where {A,T,S}
if known_length(A) === nothing
return OptionallyStaticUnitRange{One,Int}
else
return OptionallyStaticUnitRange{
One,
StaticInt{Int(known_length(A) / (sizeof(T) / sizeof(S)))},
}
end
end
@generated function _reinterpret_axes_types(
::Type{I},
Expand All @@ -288,9 +311,6 @@ end
Expr(:block, Expr(:meta, :inline), out)
end

function axes_types(::Type{T}) where {N,T<:Base.ReshapedArray{<:Any,N}}
return Tuple{Vararg{OptionallyStaticUnitRange{One,Int},N}}
end


"""
Expand Down
20 changes: 0 additions & 20 deletions src/stridelayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,27 +313,7 @@ end
_known_length(::Nothing, _, __) = nothing
@inline _known_length(L::Integer, ::Type{T}, ::Type{P}) where {T,P} = L * sizeof(P) ÷ sizeof(T)

# These methods help handle identifying axes that dont' directly propagate from the
# parent array axes. They may be worth making a formal part of the API, as they provide
# a low traffic spot to change what axes_types produces.
@inline function sub_axis_type(::Type{A}, ::Type{I}) where {A,I}
if known_length(I) === nothing
return OptionallyStaticUnitRange{One,Int}
else
return OptionallyStaticUnitRange{One,StaticInt{known_length(I)}}
end
end

@inline function reinterpret_axis_type(::Type{A}, ::Type{T}, ::Type{S}) where {A,T,S}
if known_length(A) === nothing
return OptionallyStaticUnitRange{One,Int}
else
return OptionallyStaticUnitRange{
One,
StaticInt{Int(known_length(A) / (sizeof(T) / sizeof(S)))},
}
end
end

"""
known_offsets(::Type{T}[, d]) -> Tuple
Expand Down

2 comments on commit 854a4b8

@chriselrod
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29206

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.0.1 -m "<description of version>" 854a4b81f306d1f668ae8c9ab12160f0a1dbd923
git push origin v3.0.1

Please sign in to comment.