Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp98 committed Nov 16, 2022
2 parents b279646 + 10a2c7e commit 34c688d
Show file tree
Hide file tree
Showing 5 changed files with 16 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.1.1"
version = "1.2.2"

[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
5 changes: 5 additions & 0 deletions src/functions_math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ function Base.inv(nda::NamedDimsArray{L,T,2}) where {L,T}
return NamedDimsArray{names}(data)
end

function Base.diff(nda::NamedDimsArray{L}; dims) where {L}
data = diff(parent(nda); dims=dim(L, dims))
return NamedDimsArray{L}(data)
end

# Statistics
for fun in (:cor, :cov)
@eval function Statistics.$fun(a::NamedDimsArray{L,T,2}; dims=1, kwargs...) where {L,T}
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
7 changes: 7 additions & 0 deletions test/functions_math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ end
@test inv(nda) * nda NamedDimsArray{(:b, :b)}([1.0 0; 0 1])
end

@testset "diff" begin
arr = [1.0 2; 3 4]
nda = NamedDimsArray{(:a, :b)}(arr)
@test diff(nda; dims=:a) == diff(arr; dims=1)
@test typeof(diff(nda; dims=:a)) == typeof(nda)
@test diff(nda; dims=:b) == diff(nda; dims=2)
end

@testset "cov/cor" begin
@testset "symmetric_names" begin
Expand Down

0 comments on commit 34c688d

Please sign in to comment.