Skip to content

Commit

Permalink
Merge pull request #38 from invenia/ox/strides
Browse files Browse the repository at this point in the history
Add Strided Array Interface
  • Loading branch information
oxinabox authored Feb 25, 2020
2 parents 465a01c + be2fae1 commit ecd00f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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 = "0.2.16"
version = "0.2.17"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
7 changes: 7 additions & 0 deletions src/wrapper_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ function Base.similar(
return similar(a, eltype, dims)
end

#####################################
# Strided Array interface
Base.stride(a::NamedDimsArray, k::Symbol) = stride(parent(a), dim(a, k))
Base.stride(a::NamedDimsArray, k::Integer) = stride(parent(a), k)
Base.strides(a::NamedDimsArray) = strides(parent(a))


###############################
# kwargs indexing

Expand Down
6 changes: 6 additions & 0 deletions test/wrapper_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ end
end
end

@testset "Strided Array Interface" begin
x = ones(3, 5)
nda = NamedDimsArray{(:a, :b)}(x)
@test strides(nda) == (1, 3) == strides(x)
@test stride(nda, :b) == 3 == stride(nda, 2) == stride(x, 2)
end

const cnda = NamedDimsArray([10 20; 30 40], (:x, :y))
@testset "allocations: wrapper" begin
Expand Down

2 comments on commit ecd00f0

@oxinabox
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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/10061

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.17 -m "<description of version>" ecd00f011ae67807d912aee80eeb2cc24e423567
git push origin v0.2.17

Please sign in to comment.