Skip to content

Commit

Permalink
Merge pull request #989 from gridap/remove-subvector
Browse files Browse the repository at this point in the history
Deprecate `SubVector` in favor of Julia's `view`.
  • Loading branch information
JordiManyer committed Mar 29, 2024
2 parents 3707376 + 1824d46 commit 1a51138
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 37 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- ODE module extensive refactor. Breaking changes! See docs and PR for details. Since PR[965](https://github.com/gridap/Gridap.jl/pull/965).
- Fixed name clash with `Statistics.mean`. Since PR[#988](https://github.com/gridap/Gridap.jl/pull/988).
- Deprecated `SubVector` in favor of Julia's `view`. Since PR[#989](https://github.com/gridap/Gridap.jl/pull/989).

### Added

Expand Down
3 changes: 1 addition & 2 deletions src/Arrays/Arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export find_local_index

export IdentityVector

export SubVector
export pair_arrays
export unpair_arrays

Expand Down Expand Up @@ -162,7 +161,7 @@ include("KeyToValMaps.jl")

include("FilteredArrays.jl")

include("SubVectors.jl")
include("SubVectors.jl") # Deprecated

include("ArrayPairs.jl")

Expand Down
4 changes: 0 additions & 4 deletions src/Arrays/PrintOpTrees.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ function get_children(n::TreeNode, a::LazyArray)
(similar_tree_node(n,a.maps),map(i->similar_tree_node(n,i),a.args)...)
end

function get_children(n::TreeNode, a::SubVector)
(similar_tree_node(n,a.vector),)
end

function get_children(n::TreeNode, a::Reindex)
(similar_tree_node(n,a.values),)
end
Expand Down
2 changes: 2 additions & 0 deletions src/Arrays/SubVectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
pini::Int
pend::Int
end
`SubVector` is deprecated, use `view` instead.
"""
struct SubVector{T,A<:AbstractVector{T}} <: AbstractVector{T}
vector::A
Expand Down
4 changes: 2 additions & 2 deletions src/MultiField/MultiFieldFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function _restrict_to_field(f,
offsets = _compute_field_offsets(U)
pini = offsets[field] + 1
pend = offsets[field] + num_free_dofs(U[field])
SubVector(free_values,pini,pend)
view(free_values,pini:pend)
end

function _restrict_to_field(f,
Expand All @@ -320,7 +320,7 @@ function _restrict_to_field(f,
offsets = compute_field_offsets(f,mfs)
pini = offsets[field] + 1
pend = offsets[field] + num_free_dofs(U[field])
return SubVector(block_free_values,pini,pend)
return view(block_free_values,pini:pend)
end

"""
Expand Down
27 changes: 0 additions & 27 deletions test/ArraysTests/SubVectorsTests.jl

This file was deleted.

2 changes: 0 additions & 2 deletions test/ArraysTests/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ using Test

@testset "IdentityVectors" begin include("IdentityVectorsTests.jl") end

@testset "SubVectors" begin include("SubVectorsTests.jl") end

@testset "ArrayPairs" begin include("ArrayPairsTests.jl") end

@testset "AppendedArrays" begin include("AppendedArraysTests.jl") end
Expand Down

0 comments on commit 1a51138

Please sign in to comment.