Skip to content

Commit

Permalink
force dims and refdims to be tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 2, 2019
1 parent b1531d2 commit 09e1f6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DimensionalData"
uuid = "0703355e-b756-11e9-17c0-8b28908087d0"
authors = ["Rafael Schouten <rafaelschouten@gmail.com>"]
version = "0.1.0"
version = "0.1.1"

[deps]
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand Down
4 changes: 2 additions & 2 deletions src/array.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract type AbstractDimensionalArray{T,N,D} <: AbstractArray{T,N} end
abstract type AbstractDimensionalArray{T,N,D<:Tuple} <: AbstractArray{T,N} end

const AbDimArray = AbstractDimensionalArray

Expand Down Expand Up @@ -123,7 +123,7 @@ A basic DimensionalArray type
Maintains and updates its dimensions through transformations
"""
struct DimensionalArray{T,N,D,R,A<:AbstractArray{T,N}} <: AbstractDimensionalArray{T,N,D}
struct DimensionalArray{T,N,D<:Tuple,R<:Tuple,A<:AbstractArray{T,N}} <: AbstractDimensionalArray{T,N,D}
data::A
dims::D
refdims::R
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ using DimensionalData: val, basetype, slicedims, dims2indices, formatdims,
# Basic dim and array initialisation

a = ones(5, 4)
# Must construct with a tuple for dims/refdims
@test_throws MethodError DimensionalArray(a, X((140, 148)))
@test_throws MethodError DimensionalArray(a, (X((140, 148)), Y((2, 11))), Z(1))
da = DimensionalArray(a, (X((140, 148)), Y((2, 11))))


dimz = dims(da)
@test slicedims(dimz, (2:4, 3)) == ((X(LinRange(142,146,3)),), (Y(8.0),))
@test name(dimz) == ("X", "Y")
Expand Down

2 comments on commit 09e1f6c

@rafaqz
Copy link
Owner Author

@rafaqz rafaqz commented on 09e1f6c Oct 2, 2019

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

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.1.1 -m "<description of version>" 09e1f6cbc98e48f35a5d5bcd8e5015b328770a62
git push origin v0.1.1

Please sign in to comment.