From 923c3eb899ba6becd020e295d70a03613236aa83 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 4 Apr 2020 21:08:05 -0700 Subject: [PATCH 01/18] Add first and last index interface methods --- src/core/time_arrays.jl | 11 ++++++++++- test/test_timesteparrays.jl | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/time_arrays.jl b/src/core/time_arrays.jl index 9b91c10af..bef303ca8 100644 --- a/src/core/time_arrays.jl +++ b/src/core/time_arrays.jl @@ -110,6 +110,16 @@ function _get_ts_indices(ts_array::Array{TimestepValue{T}, 1}, times::Union{Tupl return [_get_time_value_position(times, ts) for ts in ts_array] end +# Base.firstindex and Base.lastindex +Base.firstindex(arr::TimestepArray) = Mimi.TimestepIndex(1) +Base.lastindex(arr::TimestepArray) = Mimi.TimestepIndex(length(arr)) + +Base.firstindex(arr::TimestepVector) = Mimi.TimestepIndex(1) +Base.lastindex(arr::TimestepVector) = Mimi.TimestepIndex(length(arr)) + +Base.firstindex(arr::TimestepMatrix) = Mimi.TimestepIndex(1) +Base.lastindex(arr::TimestepMatrix) = Mimi.TimestepIndex(length(arr)) + # # b. TimestepVector # @@ -250,7 +260,6 @@ function Base.getindex(mat::TimestepMatrix{FixedTimestep{FIRST, STEP}, T, 2}, id end function Base.getindex(mat::TimestepMatrix{VariableTimestep{TIMES}, T, 2}, idx::AnyIndex, ts::VariableTimestep{TIMES}) where {T, TIMES} - # WAS THIS: data = mat.data[ts.t, idx, ts.t] data = mat.data[idx, ts.t] _missing_data_check(data, ts.t) end diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 8160d89c6..fe0a32111 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,6 +611,11 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) +@test x_vec[begin:end] == time_dim_val[:,1,1] +@test x_mat[begin:end] == time_dim_val[:,:,1] +@test y_vec[begin:end] == time_dim_val[:,2,2] +@test y_mat[begin:end] == time_dim_val[:,:,2] + #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` # values during `run` that haven't been computed yet. From b580897bc00d0afbee8734542c68e4e516db32f5 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 4 Apr 2020 22:07:33 -0700 Subject: [PATCH 02/18] Work on colon methods --- src/core/time.jl | 2 +- test/test_timesteparrays.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/time.jl b/src/core/time.jl index dba24f471..e3dc15a14 100644 --- a/src/core/time.jl +++ b/src/core/time.jl @@ -180,7 +180,7 @@ function Base.:(:)(start::T, step::Int, stop::T) where {T<:TimestepIndex} return TimestepIndex.(indices) end -function Base.:(:)(start::T, stop::T) where {T<:TimestepIndex} +function Base.:(:)(start::T, stop::T) where {T<:Union{TimestepIndex, TimestepValue, AbstractTimestep} return Base.:(:)(start, 1, stop) end diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index fe0a32111..7c8aa3d51 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,6 +611,7 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) +# try begin and end (in the methods begin and end are converted into TimestepIndex types @test x_vec[begin:end] == time_dim_val[:,1,1] @test x_mat[begin:end] == time_dim_val[:,:,1] @test y_vec[begin:end] == time_dim_val[:,2,2] From 4f58a727c6e21c05191e1469a52ee0e21180960c Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 4 Apr 2020 23:04:18 -0700 Subject: [PATCH 03/18] Fix syntax bug --- src/core/time.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/time.jl b/src/core/time.jl index e3dc15a14..f2dd47942 100644 --- a/src/core/time.jl +++ b/src/core/time.jl @@ -180,7 +180,7 @@ function Base.:(:)(start::T, step::Int, stop::T) where {T<:TimestepIndex} return TimestepIndex.(indices) end -function Base.:(:)(start::T, stop::T) where {T<:Union{TimestepIndex, TimestepValue, AbstractTimestep} +function Base.:(:)(start::T, stop::T) where {T<:Union{TimestepIndex, TimestepValue, AbstractTimestep}} return Base.:(:)(start, 1, stop) end From 35dc467f1fdfd60a72e17f5505493673897a7aeb Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 4 Apr 2020 23:05:59 -0700 Subject: [PATCH 04/18] Remove duplicate method --- src/core/time_arrays.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/time_arrays.jl b/src/core/time_arrays.jl index bef303ca8..fa853da1c 100644 --- a/src/core/time_arrays.jl +++ b/src/core/time_arrays.jl @@ -226,8 +226,6 @@ function Base.length(v::TimestepVector) return length(v.data) end -Base.lastindex(v::TimestepVector) = length(v) - # # c. TimestepMatrix # From 3ceb0d0abfc708ce53c3834cc11967cbb09a19c0 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sun, 5 Apr 2020 00:43:48 -0700 Subject: [PATCH 05/18] Fix bugs --- src/core/time_arrays.jl | 10 +++------- test/test_timesteparrays.jl | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/core/time_arrays.jl b/src/core/time_arrays.jl index fa853da1c..758fa3b76 100644 --- a/src/core/time_arrays.jl +++ b/src/core/time_arrays.jl @@ -112,13 +112,9 @@ end # Base.firstindex and Base.lastindex Base.firstindex(arr::TimestepArray) = Mimi.TimestepIndex(1) -Base.lastindex(arr::TimestepArray) = Mimi.TimestepIndex(length(arr)) - -Base.firstindex(arr::TimestepVector) = Mimi.TimestepIndex(1) -Base.lastindex(arr::TimestepVector) = Mimi.TimestepIndex(length(arr)) - -Base.firstindex(arr::TimestepMatrix) = Mimi.TimestepIndex(1) -Base.lastindex(arr::TimestepMatrix) = Mimi.TimestepIndex(length(arr)) +# TODO Base.lastindex(arr::TimestepArray, d::Int) = +Base.lastindex(arr::TimestepArray) = Mimi.TimestepIndex(length(arr.data)) +# TODO Base.lastindex(arr::TimestepArray, dim::Int) = # # b. TimestepVector diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 7c8aa3d51..624c87c3c 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -44,7 +44,7 @@ idx4 = TimestepIndex(4) x = TimestepVector{FixedTimestep{2000, 1}, Int}([9, 10, 11, 12]) @test length(x) == 4 -@test lastindex(x) == 4 +@test lastindex(x) == TimestepIndex(4) time_dim_val = [9, 10, 11, 12] temp_dim_val = [100, 101, 102, 103] @@ -613,9 +613,9 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) # try begin and end (in the methods begin and end are converted into TimestepIndex types @test x_vec[begin:end] == time_dim_val[:,1,1] -@test x_mat[begin:end] == time_dim_val[:,:,1] +@test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) @test y_vec[begin:end] == time_dim_val[:,2,2] -@test y_mat[begin:end] == time_dim_val[:,:,2] +@test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` From b73f91f3b36aebb34d09e5ade26769f7d2ae831a Mon Sep 17 00:00:00 2001 From: lrennels Date: Sun, 5 Apr 2020 01:12:27 -0700 Subject: [PATCH 06/18] Add space --- test/test_timesteparrays.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 624c87c3c..8fbe3b661 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -612,6 +612,7 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) # try begin and end (in the methods begin and end are converted into TimestepIndex types + @test x_vec[begin:end] == time_dim_val[:,1,1] @test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) @test y_vec[begin:end] == time_dim_val[:,2,2] From a746269a316f3776d47172a76cc7c5ca52fe9860 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sun, 5 Apr 2020 01:28:12 -0700 Subject: [PATCH 07/18] Add version check --- test/test_timesteparrays.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 8fbe3b661..d725c9362 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,13 +611,14 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# try begin and end (in the methods begin and end are converted into TimestepIndex types - -@test x_vec[begin:end] == time_dim_val[:,1,1] -@test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) -@test y_vec[begin:end] == time_dim_val[:,2,2] -@test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) - +# try begin and end (in the methods begin and end are converted into TimestepIndex types which +# is actually only enabled starting in Julia 1.2.0 +if(VERSION > v"1.2.0") + @test x_vec[begin:end] == time_dim_val[:,1,1] + @test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) + @test y_vec[begin:end] == time_dim_val[:,2,2] + @test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) +end #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` # values during `run` that haven't been computed yet. From 5def56c9a9a63ca7313c54dc18ca026f6a539976 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sun, 5 Apr 2020 01:46:58 -0700 Subject: [PATCH 08/18] Remove extra methods --- src/core/time.jl | 2 +- test/test_timesteparrays.jl | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/time.jl b/src/core/time.jl index f2dd47942..21652fe23 100644 --- a/src/core/time.jl +++ b/src/core/time.jl @@ -180,7 +180,7 @@ function Base.:(:)(start::T, step::Int, stop::T) where {T<:TimestepIndex} return TimestepIndex.(indices) end -function Base.:(:)(start::T, stop::T) where {T<:Union{TimestepIndex, TimestepValue, AbstractTimestep}} +function Base.:(:)(start::T, stop::T) where {T<:TimestepIndex} return Base.:(:)(start, 1, stop) end diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index d725c9362..e3fb86e30 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,14 +611,14 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# try begin and end (in the methods begin and end are converted into TimestepIndex types which -# is actually only enabled starting in Julia 1.2.0 -if(VERSION > v"1.2.0") - @test x_vec[begin:end] == time_dim_val[:,1,1] - @test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) - @test y_vec[begin:end] == time_dim_val[:,2,2] - @test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) -end +# this fails for lower versions of Julia +# if(VERSION > v"1.2.0") +# @test x_vec[begin:end] == time_dim_val[:,1,1] +# @test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) +# @test y_vec[begin:end] == time_dim_val[:,2,2] +# @test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) +# end + #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` # values during `run` that haven't been computed yet. From ccf31f68f2acf1bfacf6ec4047e0211248ab7eb3 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sun, 5 Apr 2020 02:00:34 -0700 Subject: [PATCH 09/18] Add tests --- src/core/time.jl | 2 +- test/test_timesteparrays.jl | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/time.jl b/src/core/time.jl index 21652fe23..dba24f471 100644 --- a/src/core/time.jl +++ b/src/core/time.jl @@ -180,7 +180,7 @@ function Base.:(:)(start::T, step::Int, stop::T) where {T<:TimestepIndex} return TimestepIndex.(indices) end -function Base.:(:)(start::T, stop::T) where {T<:TimestepIndex} +function Base.:(:)(start::T, stop::T) where {T<:TimestepIndex} return Base.:(:)(start, 1, stop) end diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index e3fb86e30..78af6cbdd 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,13 +611,11 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# this fails for lower versions of Julia -# if(VERSION > v"1.2.0") -# @test x_vec[begin:end] == time_dim_val[:,1,1] -# @test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) -# @test y_vec[begin:end] == time_dim_val[:,2,2] -# @test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) -# end +# TODO this fails for lower versions of Julia, PASSES on 1.4.0 +@test x_vec[begin:end] == time_dim_val[:,1,1] +@test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) +@test y_vec[begin:end] == time_dim_val[:,2,2] +@test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` From 9e90cf235b8c384e6624a6df7537924cdf26cbb0 Mon Sep 17 00:00:00 2001 From: lrennels Date: Mon, 6 Apr 2020 15:39:40 -0700 Subject: [PATCH 10/18] Fix begin and end indexing; add tests --- src/core/time_arrays.jl | 55 ++++++++++++++++++++++++++++++++++--- test/test_timesteparrays.jl | 19 +++++++++---- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/src/core/time_arrays.jl b/src/core/time_arrays.jl index 758fa3b76..37e2ba86d 100644 --- a/src/core/time_arrays.jl +++ b/src/core/time_arrays.jl @@ -111,10 +111,57 @@ function _get_ts_indices(ts_array::Array{TimestepValue{T}, 1}, times::Union{Tupl end # Base.firstindex and Base.lastindex -Base.firstindex(arr::TimestepArray) = Mimi.TimestepIndex(1) -# TODO Base.lastindex(arr::TimestepArray, d::Int) = -Base.lastindex(arr::TimestepArray) = Mimi.TimestepIndex(length(arr.data)) -# TODO Base.lastindex(arr::TimestepArray, dim::Int) = +function Base.firstindex(arr::TimestepArray{T_TS, T, N, ti}) where {T_TS, T, N, ti} + if ti == 1 + return Mimi.TimestepIndex(1) + else + return 1 + end +end + +function Base.lastindex(arr::TimestepArray{T_TS, T, N, ti}) where {T_TS, T, N, ti} + if ti == length(size(arr.data)) + return Mimi.TimestepIndex(length(arr.data)) + else + return length(arr.data) + end +end + +function Base.lastindex(arr::TimestepArray{T_TS, T, N, ti}, dim::Int) where {T_TS, T, N, ti} + if ti == dim + return Mimi.TimestepIndex(size(arr.data, dim)) + else + return size(arr.data, dim) + end +end + +function Base.firstindex(arr::TimestepArray{T_TS, T, N, ti}, dim::Int) where {T_TS, T, N, ti} + if ti == dim + return Mimi.TimestepIndex(1) + else + return 1 + end +end + +# add axes methos copied from abstarctarray.jl:56 +function Base.axes(A::TimestepArray{T_TS, T, N, ti}, d::Int) where {T_TS, T, N, ti} + _d_lessthan_N = d <= N; + if d == ti + if _d_lessthan_N + return Tuple(TimestepIndex.(1:size(A,d))) + else + return TimestepIndex(1) + end + else + if _d_lessthan_N + if _d_lessthan_N + return 1:size(A,d) + else + return 1 + end + end + end +end # # b. TimestepVector diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 78af6cbdd..b8588614f 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,11 +611,20 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# TODO this fails for lower versions of Julia, PASSES on 1.4.0 -@test x_vec[begin:end] == time_dim_val[:,1,1] -@test x_mat[begin:end] == reshape(time_dim_val[:,:,1], (16)) -@test y_vec[begin:end] == time_dim_val[:,2,2] -@test y_mat[begin:end] == reshape(time_dim_val[:,:,2], (16)) +# TODO failures +@test x_vec[begin] == time_dim_val[:,1,1][begin] +@test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] +@test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] +@test y_vec[begin] == time_dim_val[:,2,2][begin] +@test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] +@test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] + +@test x_vec[end] == time_dim_val[:,1,1][end] +@test x_mat[end,1] == time_dim_val[:,:,1][end,1] +@test x_mat[end,2] == time_dim_val[:,:,1][end,2] +@test y_vec[end] == time_dim_val[:,2,2][end] +@test y_mat[end,1] == time_dim_val[:,:,2][end,1] +@test y_mat[end,2] == time_dim_val[:,:,2][end,2] #------------------------------------------------------------------------------ # 6. Test that getindex for TimestepArrays doesn't allow access to `missing` From f3c15f8ff9ef0a28a04cb28d64e3b25f695c20b5 Mon Sep 17 00:00:00 2001 From: lrennels Date: Mon, 6 Apr 2020 15:47:59 -0700 Subject: [PATCH 11/18] Remove begin tests --- test/test_timesteparrays.jl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index b8588614f..15005e221 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,13 +611,16 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# TODO failures -@test x_vec[begin] == time_dim_val[:,1,1][begin] -@test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] -@test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] -@test y_vec[begin] == time_dim_val[:,2,2][begin] -@test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] -@test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] +# These tests are temporarily removed because the begin syntax was deprecated for +# a few versions and thus causes CI errors. We can bring it back in when we are +# testing only v1.4.0 and above. + +# @test x_vec[begin] == time_dim_val[:,1,1][begin] +# @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] +# @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] +# @test y_vec[begin] == time_dim_val[:,2,2][begin] +# @test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] +# @test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] @test x_vec[end] == time_dim_val[:,1,1][end] @test x_mat[end,1] == time_dim_val[:,:,1][end,1] From e92c54401ad7aa4437386c81f2c188211e341e4a Mon Sep 17 00:00:00 2001 From: lrennels Date: Tue, 7 Apr 2020 09:31:36 -0700 Subject: [PATCH 12/18] Add tests for begin --- test/test_timesteparrays.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 15005e221..908cd32f0 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,16 +611,15 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# These tests are temporarily removed because the begin syntax was deprecated for -# a few versions and thus causes CI errors. We can bring it back in when we are -# testing only v1.4.0 and above. - -# @test x_vec[begin] == time_dim_val[:,1,1][begin] -# @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] -# @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] -# @test y_vec[begin] == time_dim_val[:,2,2][begin] -# @test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] -# @test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] +# begin syntax is depreacated v1.0.0 - v1.2.0 +if(VERSION > v"1.2.0") + @test x_vec[begin] == time_dim_val[:,1,1][begin] + @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] + @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] + @test y_vec[begin] == time_dim_val[:,2,2][begin] + @test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] + @test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] +end @test x_vec[end] == time_dim_val[:,1,1][end] @test x_mat[end,1] == time_dim_val[:,:,1][end,1] From 441bbbf500c5e3ed0f1dc286bb03bc08c2e06d73 Mon Sep 17 00:00:00 2001 From: Lisa Rennels <31779240+lrennels@users.noreply.github.com> Date: Tue, 7 Apr 2020 09:41:40 -0700 Subject: [PATCH 13/18] Update version bounds for testing --- test/test_timesteparrays.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 908cd32f0..e0d42e566 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,8 +611,8 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# begin syntax is depreacated v1.0.0 - v1.2.0 -if(VERSION > v"1.2.0") +# begin syntax is depreacated v1.0.0 - v1.3.0 +if(VERSION > v"1.3.0") @test x_vec[begin] == time_dim_val[:,1,1][begin] @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] From df9cf2716a40be6da404ccaa5b5b0027279db5ec Mon Sep 17 00:00:00 2001 From: lrennels Date: Wed, 8 Apr 2020 22:07:39 -0700 Subject: [PATCH 14/18] Try using @static macro --- test/test_timesteparrays.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 908cd32f0..fa5eeebdc 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,8 +611,8 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# begin syntax is depreacated v1.0.0 - v1.2.0 -if(VERSION > v"1.2.0") +# begin syntax is depreacated v1.0.0 - v1.3.0 +@static if(VERSION > v"1.3.0") @test x_vec[begin] == time_dim_val[:,1,1][begin] @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] From 1b56fe326f804dcf4c9e33338c5ffce16c8b4481 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 6 Jun 2020 14:16:55 -0700 Subject: [PATCH 15/18] Move begin keyword tests to separate file --- test/test_timesteparrays.jl | 7 +------ test/test_timesteparrays_v1.4.jl | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 test/test_timesteparrays_v1.4.jl diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index fa5eeebdc..0887d581f 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -613,12 +613,7 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) # begin syntax is depreacated v1.0.0 - v1.3.0 @static if(VERSION > v"1.3.0") - @test x_vec[begin] == time_dim_val[:,1,1][begin] - @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] - @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] - @test y_vec[begin] == time_dim_val[:,2,2][begin] - @test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] - @test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] + include("test_timesteparrays_v1.4.jl") end @test x_vec[end] == time_dim_val[:,1,1][end] diff --git a/test/test_timesteparrays_v1.4.jl b/test/test_timesteparrays_v1.4.jl new file mode 100644 index 000000000..78794648a --- /dev/null +++ b/test/test_timesteparrays_v1.4.jl @@ -0,0 +1,9 @@ +using Mimi +using Test + +@test x_vec[begin] == time_dim_val[:,1,1][begin] +@test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] +@test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] +@test y_vec[begin] == time_dim_val[:,2,2][begin] +@test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] +@test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] From 4d8e52c81ad1929d796473d278f6e89c00c333db Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 6 Jun 2020 14:20:12 -0700 Subject: [PATCH 16/18] Fix version test --- test/test_timesteparrays.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 0887d581f..b8f994342 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -612,7 +612,7 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) # begin syntax is depreacated v1.0.0 - v1.3.0 -@static if(VERSION > v"1.3.0") +if VERSION > v"1.3.0" include("test_timesteparrays_v1.4.jl") end From 8e0763c6186f5d61c914d3061dd3d55c41e62f78 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 6 Jun 2020 14:28:05 -0700 Subject: [PATCH 17/18] Add static macro --- test/test_timesteparrays.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index b8f994342..8f2e462f0 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -612,9 +612,7 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) # begin syntax is depreacated v1.0.0 - v1.3.0 -if VERSION > v"1.3.0" - include("test_timesteparrays_v1.4.jl") -end +@static (VERSION > v"1.3.0") ? include("test_timesteparrays_v1.4.jl") : Nothing @test x_vec[end] == time_dim_val[:,1,1][end] @test x_mat[end,1] == time_dim_val[:,:,1][end,1] From 95ddb297496485c7b7feb908f44fcd1527486c2d Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 6 Jun 2020 14:39:24 -0700 Subject: [PATCH 18/18] Remove begin tests --- test/test_timesteparrays.jl | 11 +++++++++-- test/test_timesteparrays_v1.4.jl | 9 --------- 2 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 test/test_timesteparrays_v1.4.jl diff --git a/test/test_timesteparrays.jl b/test/test_timesteparrays.jl index 8f2e462f0..5a93a1aac 100644 --- a/test/test_timesteparrays.jl +++ b/test/test_timesteparrays.jl @@ -611,8 +611,15 @@ y_mat = TimestepMatrix{VariableTimestep{y_years}, Int, 1}(time_dim_val[:,:,2]) @test eltype(x_vec) == eltype(y_vec) == eltype(y_vec) == eltype(y_mat) == eltype(time_dim_val) -# begin syntax is depreacated v1.0.0 - v1.3.0 -@static (VERSION > v"1.3.0") ? include("test_timesteparrays_v1.4.jl") : Nothing +# TODO begin syntax is depreacated v1.0.0 - v1.3.0, so enable the tests after +# after we disable Julia versions below v1.4.0 + +# @test x_vec[begin] == time_dim_val[:,1,1][begin] +# @test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] +# @test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] +# @test y_vec[begin] == time_dim_val[:,2,2][begin] +# @test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] +# @test y_mat[begin,2] == time_dim_val[:,:,2][begin,2] @test x_vec[end] == time_dim_val[:,1,1][end] @test x_mat[end,1] == time_dim_val[:,:,1][end,1] diff --git a/test/test_timesteparrays_v1.4.jl b/test/test_timesteparrays_v1.4.jl deleted file mode 100644 index 78794648a..000000000 --- a/test/test_timesteparrays_v1.4.jl +++ /dev/null @@ -1,9 +0,0 @@ -using Mimi -using Test - -@test x_vec[begin] == time_dim_val[:,1,1][begin] -@test x_mat[begin,1] == time_dim_val[:,:,1][begin,1] -@test x_mat[begin,2] == time_dim_val[:,:,1][begin,2] -@test y_vec[begin] == time_dim_val[:,2,2][begin] -@test y_mat[begin,1] == time_dim_val[:,:,2][begin,1] -@test y_mat[begin,2] == time_dim_val[:,:,2][begin,2]