diff --git a/NEWS.md b/NEWS.md index 7aa726480..f43335f76 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,11 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.13.1] - Unreleased +## [0.13.1] - 2020-7-24 ### Fixed - - Bug associated with `LinCom` kernel and triangulations with 0 cells. Since PR [#331](/~https://github.com/gridap/Gridap.jl/pull/331/). + - Bugs associated with the degenerated case of 0-length arrays. Since PR [#331](/~https://github.com/gridap/Gridap.jl/pull/331/) and [#332](/~https://github.com/gridap/Gridap.jl/pull/332/). ## [0.13.0] - 2020-07-23 diff --git a/src/Arrays/Apply.jl b/src/Arrays/Apply.jl index 5bc9d1fbe..ae801ca2a 100644 --- a/src/Arrays/Apply.jl +++ b/src/Arrays/Apply.jl @@ -226,9 +226,7 @@ function testitem(a::AppliedArray) cg = array_cache(a.g) gi = testitem(a.g) fi = testitems(a.f...) - cf = array_caches(a.f...) - ai = kernel_testitem(gi,fi...) - ai + kernel_testitem(gi,fi...) end function getindex!(cache,a::AppliedArray,i::Integer...) diff --git a/src/Arrays/CompressedArrays.jl b/src/Arrays/CompressedArrays.jl index 846dc6443..81691b1b3 100644 --- a/src/Arrays/CompressedArrays.jl +++ b/src/Arrays/CompressedArrays.jl @@ -30,7 +30,11 @@ struct CompressedArray{T,N,A,P} <: AbstractArray{T,N} end function testitem(a::CompressedArray) - testitem(a.values) + if length(a.ptrs) == 0 + testitem(a.values) + else + a.values[first(a.ptrs)] + end end size(a::CompressedArray) = size(a.ptrs) diff --git a/src/Arrays/Interface.jl b/src/Arrays/Interface.jl index 4be55eb72..e324cc577 100644 --- a/src/Arrays/Interface.jl +++ b/src/Arrays/Interface.jl @@ -193,6 +193,10 @@ function test_array( end @test t @test IndexStyle(a) == IndexStyle(b) + @test isa(testitem(a),eltype(a)) + if length(a) > 0 + @test testitem(a) == first(a) + end true end diff --git a/src/Arrays/Kernels.jl b/src/Arrays/Kernels.jl index 5ed8f4f4c..0fba25073 100644 --- a/src/Arrays/Kernels.jl +++ b/src/Arrays/Kernels.jl @@ -30,10 +30,10 @@ abstract type Kernel <: GridapType end Returns the type of the result of calling kernel `f` with arguments of the types of the objects `x`. -It defaults to `typeof(apply_kernel(f,x...))` +It defaults to `typeof(kernel_testitem(f,x...))` """ function kernel_return_type(f,x...) - typeof(apply_kernel(f,x...)) + typeof(kernel_testitem(f,x...)) end """ diff --git a/src/Arrays/LocalToGlobalArrays.jl b/src/Arrays/LocalToGlobalArrays.jl index ff952df6c..a82e078e8 100644 --- a/src/Arrays/LocalToGlobalArrays.jl +++ b/src/Arrays/LocalToGlobalArrays.jl @@ -21,12 +21,6 @@ struct LocalToGlobalArray{T,M,N,L,V} <: AbstractArray{Array{T,M},N} end end -function testitem(a::LocalToGlobalArray) - val = testitem(a.gid_to_val) - gids = testitem(a.lid_to_gid) - fill(val,size(gids)) -end - size(a::LocalToGlobalArray) = size(a.lid_to_gid) function IndexStyle(::Type{LocalToGlobalArray{T,M,N,L,V}}) where {T,M,N,L,V} diff --git a/src/Arrays/LocalToGlobalPosNegArrays.jl b/src/Arrays/LocalToGlobalPosNegArrays.jl index d4cd1e970..c0bc1be98 100644 --- a/src/Arrays/LocalToGlobalPosNegArrays.jl +++ b/src/Arrays/LocalToGlobalPosNegArrays.jl @@ -23,12 +23,6 @@ struct LocalToGlobalPosNegArray{T,M,N,L,V,W} <: AbstractArray{Array{T,M},N} end end -function testitem(a::LocalToGlobalPosNegArray) - val = testitem(a.gid_to_val_pos) - gids = testitem(a.lid_to_gid) - fill(val,size(gids)) -end - size(a::LocalToGlobalPosNegArray) = size(a.lid_to_gid) function IndexStyle(::Type{<:LocalToGlobalPosNegArray{T,M,N,L}}) where {T,M,N,L} diff --git a/src/Arrays/Reindex.jl b/src/Arrays/Reindex.jl index b7757faca..8048643d3 100644 --- a/src/Arrays/Reindex.jl +++ b/src/Arrays/Reindex.jl @@ -48,8 +48,6 @@ end a.i_to_v[i]=v end - - function testitem(a::Reindexed) if length(a.j_to_i) == 0 testitem(a.i_to_v) diff --git a/test/ArraysTests/ApplyTests.jl b/test/ArraysTests/ApplyTests.jl index 6a80384d5..b7b25d7dd 100644 --- a/test/ArraysTests/ApplyTests.jl +++ b/test/ArraysTests/ApplyTests.jl @@ -128,6 +128,53 @@ r = map(+,a,b) test_array(c,r) @test isa(c,Fill) +l = 10 +ai = [8 0; 0 4] +a = Fill(ai,l) +c = apply(inv,a) +r = map(inv,a) +test_array(c,r) +@test isa(c,Fill) + +l = 10 +ai = [8 0; 0 4] +a = fill(ai,l) +c = apply(inv,a) +r = map(inv,a) +test_array(c,r) + +l = 0 +ai = [8 0; 0 4] +a = fill(ai,l) +c = apply(inv,a) +r = map(inv,a) +test_array(c,r) + +ai = [8 0; 0 4] +a = CompressedArray([ai,],Int[]) +c = apply(inv,a) +r = map(inv,a) +test_array(c,r) + +l = 10 +ai = [8, 0] +a = fill(ai,l) +f(ai) = ai[2]-ai[1] +c = apply(f,a) +r = map(f,a) +test_array(c,r) + +g(ai) = ai[2]-ai[1] +import Gridap.Arrays: kernel_testitem! +kernel_testitem!(c,::typeof(g),ai) = zero(eltype(ai)) +l = 0 +ai = [8, 0] +a = fill(ai,l) +c = apply(g,a) +r = map(g,a) +test_array(c,r) + + #f = rand(10) #a = rand(10) #@test apply(f,a) === f diff --git a/test/ArraysTests/LocalToGlobalArraysTests.jl b/test/ArraysTests/LocalToGlobalArraysTests.jl index 467f41911..8580a0a2d 100644 --- a/test/ArraysTests/LocalToGlobalArraysTests.jl +++ b/test/ArraysTests/LocalToGlobalArraysTests.jl @@ -18,13 +18,11 @@ r = reindex(ca,ids) @test isa(r,LocalToGlobalArray) test_array(r,ca[ids]) - i_to_v=[[1, 2], [5, 6], [1, 5], [2, 6], [2, 3], [6, 7], [3, 7], [3, 4], [7, 8], [4, 8], [9, 10], [5, 9], [6, 10], [10, 11], [7, 11], [11, 12], [8, 12], [13, 14], [9, 13], [10, 14], [14, 15], [11, 15], [15, 16], [12, 16]] j_to_i=Int64[] lid_to_gid=reindex(i_to_v,j_to_i) gid_to_val=VectorValue{2,Float64}[(0.0, 0.25), (0.25, 0.25), (0.5, 0.25), (0.75, 0.25), (0.0, 0.5), (0.25, 0.5), (0.5, 0.5), (0.75, 0.5), (0.0, 0.75), (0.25, 0.75), (0.5, 0.75), (0.75, 0.75), (0.0, 1.0), (0.25, 1.0), (0.5, 1.0), (0.75, 1.0)] f2=LocalToGlobalArray(lid_to_gid,gid_to_val) -@test 2 == length(testitem(f2)) - +test_array(f2,Vector{VectorValue{2,Float64}}[]) end # module diff --git a/test/ArraysTests/LocalToGlobalPosNegArraysTests.jl b/test/ArraysTests/LocalToGlobalPosNegArraysTests.jl index 61dcc360b..c31f715e8 100644 --- a/test/ArraysTests/LocalToGlobalPosNegArraysTests.jl +++ b/test/ArraysTests/LocalToGlobalPosNegArraysTests.jl @@ -19,6 +19,6 @@ j_to_i=Int64[] lid_to_gid=reindex(i_to_v,j_to_i) gid_to_val=VectorValue{2,Float64}[(0.0, 0.25), (0.25, 0.25), (0.5, 0.25), (0.75, 0.25), (0.0, 0.5), (0.25, 0.5), (0.5, 0.5), (0.75, 0.5), (0.0, 0.75), (0.25, 0.75), (0.5, 0.75), (0.75, 0.75), (0.0, 1.0), (0.25, 1.0), (0.5, 1.0), (0.75, 1.0)] f2=LocalToGlobalPosNegArray(lid_to_gid,gid_to_val,gid_to_val) -@test 2 == length(testitem(f2)) +test_array(f2,Vector{VectorValue{2,Float64}}[]) end # module diff --git a/test/FESpacesTests/ExtendedFESpacesTests.jl b/test/FESpacesTests/ExtendedFESpacesTests.jl index 1cbb968e0..0f2f90e20 100644 --- a/test/FESpacesTests/ExtendedFESpacesTests.jl +++ b/test/FESpacesTests/ExtendedFESpacesTests.jl @@ -52,6 +52,14 @@ incell_to_cell = findall(oldcell_to_is_in) outcell_to_cell = findall(collect(Bool, .! oldcell_to_is_in)) model_in = DiscreteModel(model,incell_to_cell) + +V = TestFESpace( + model=model_in,valuetype=Float64,reffe=:Lagrangian, + order=1,conformity=:H1,dof_space=:physical) +@test isa(V,ExtendedFESpace) + + + model_out = DiscreteModel(model,outcell_to_cell) trian_in = RestrictedTriangulation(trian, incell_to_cell)