Skip to content

Commit

Permalink
infer reduce(*cat) (#211)
Browse files Browse the repository at this point in the history
_named_*cat funcs rely on constant propagation of names, so they need inlining to infer
  • Loading branch information
aplavin authored Oct 31, 2022
1 parent a016422 commit 10a2c7e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NamedDims"
uuid = "356022a1-0364-5f58-8944-0da4b18d706f"
authors = ["Invenia Technical Computing Corporation"]
version = "1.2.0"
version = "1.2.1"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
2 changes: 1 addition & 1 deletion src/cat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ for (f, nf, tf, tup) in
return $nf(mapreduce(dimnames, unify_names_longest, A), A)
end

function $nf(Linner, A)
@inline function $nf(Linner, A)
Louter = ($tup..., dimnames(A)...)
Lnew = unify_names_longest(Linner, Louter)
data = Base.$tf(mapreduce(eltype, promote_type, A), A) # same as Base
Expand Down
4 changes: 2 additions & 2 deletions test/cat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ for (f, d) in zip((vcat, hcat), (1, 2))
end

@testset "reduce forms" begin
@test reduce(f, [nda, nda]) == f(nda, nda)
@test reduce(f, [ndv, ndv]) == f(ndv, ndv)
@test @inferred(reduce(f, [nda, nda])) == f(nda, nda)
@test @inferred(reduce(f, [ndv, ndv])) == f(ndv, ndv)

v1 = NamedDimsArray([a, a], dimnames(nda, d))
v2 = NamedDimsArray([a, nda, a, nda], dimnames(nda, d))
Expand Down

2 comments on commit 10a2c7e

@mzgubic
Copy link
Collaborator

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/71341

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 v1.2.1 -m "<description of version>" 10a2c7e2fa398527f2e261982c593029470ef5c2
git push origin v1.2.1

Please sign in to comment.