Skip to content

Commit

Permalink
Merge pull request #386 from gridap/bugfix_issue_380
Browse files Browse the repository at this point in the history
Bugfix for issue #380
  • Loading branch information
fverdugo authored Aug 26, 2020
2 parents f1c8a07 + 9d4bbaa commit 4480be9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/CellData/CellFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ end
"""
function similar_object(cf::CellField,array::AbstractArray,cell_axes::AbstractArray,msize_style::Val)
cm = get_cell_map(cf)
GenericCellField(array,cm,RefStyle(cf),cell_axes,msize_style)
similar_object(cf,array,cm,cell_axes,msize_style)
end

function similar_object(
cf::CellField,array::AbstractArray,cell_map::AbstractArray,cell_axes::AbstractArray,msize_style::Val)
GenericCellField(array,cell_map,RefStyle(cf),cell_axes,msize_style)
end

"""
Expand Down Expand Up @@ -243,7 +248,8 @@ end
function Arrays.reindex(cf::CellField,a::AbstractVector)
array = reindex(get_array(cf),a)
cell_axes = reindex(get_cell_axes(cf),a)
similar_object(cf,array,cell_axes,MetaSizeStyle(cf))
cell_map = reindex(get_cell_map(cf),a)
similar_object(cf,array,cell_map,cell_axes,MetaSizeStyle(cf))
end

# Bases-related
Expand Down
6 changes: 6 additions & 0 deletions test/CellDataTests/CellFieldsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ zf = convert_to_cell_field(zl,ϕl)
df = af*zf
dft = trialize_cell_basis(df)

zfr = reindex(zf,[1,4,3])
@test length(zfr) == 3
@test length(get_array(zfr)) == 3
@test length(get_cell_map(zfr)) == 3
@test length(get_cell_axes(zfr)) == 3

# Check memoization
df_x1 = evaluate(df,xl)
df_x2 = evaluate(df,xl)
Expand Down

0 comments on commit 4480be9

Please sign in to comment.