Skip to content

Commit

Permalink
Merge pull request #73 from tpgillam/tg/named_array_dimname
Browse files Browse the repository at this point in the history
Convert NamedArray dimnames to Symbol
  • Loading branch information
mcabbott authored Jul 8, 2021
2 parents 0b8a82a + 7f68679 commit d57b37e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AxisKeys"
uuid = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
license = "MIT"
version = "0.1.17"
version = "0.1.18"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down Expand Up @@ -33,9 +33,10 @@ julia = "1"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
NamedArrays = "86f7a689-2022-50b4-a561-43c23ac3c673"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UniqueVectors = "2fbcfb34-fd0c-5fbb-b5d7-e826d8f5b0a9"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["BenchmarkTools", "Dates", "FFTW", "Test", "UniqueVectors", "Unitful"]
test = ["BenchmarkTools", "Dates", "FFTW", "NamedArrays", "Test", "UniqueVectors", "Unitful"]
4 changes: 2 additions & 2 deletions src/wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ function wrapdims_import(A::AbstractArray)
v
end
if nameouter() == false
return KeyedArray(NamedDimsArray(A.array, A.dimnames), keys)
return KeyedArray(NamedDimsArray(A.array, Symbol.(A.dimnames)), keys)
else
return NamedDimsArray(KeyedArray(A.array, keys), A.dimnames)
return NamedDimsArray(KeyedArray(A.array, keys), Symbol.(A.dimnames))
end

elseif fields == (:data, :axes) # then it's an AxisArray
Expand Down
12 changes: 12 additions & 0 deletions test/_packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ end
@test n(y=k) == n[:,7]

end
@testset "namedarrays" begin
using NamedArrays

# NamedArrays lets us have strings as well as symbols for dimension names. Make sure
# we can handle both.
for dimension_name in (:aa, "aa")
x = NamedArray([1])
setdimnames!(x, dimension_name, 1)
k = wrapdims(x)
@test dimnames(k) == (:aa,)
end
end
@testset "tables" begin
using Tables

Expand Down

2 comments on commit d57b37e

@mcabbott
Copy link
Owner 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/40505

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 v0.1.18 -m "<description of version>" d57b37e5f8e0d8d00f8d5119cc44890adfc70762
git push origin v0.1.18

Please sign in to comment.