Skip to content

Add getindex(::VofA, ::Colon, ::Int) - #25

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
baggepinnen:patch-1
Nov 28, 2017
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
baggepinnen:patch-1

Conversation

@baggepinnen

Copy link
Copy Markdown
Contributor

This PR causes "matrix getindex" with a colon in the first place to return the unmodified underlying AbstractVector. Tests pass, bu I can potentially imagine unexpected behaviour if the internal AbstractArray is multidimensional. If problems like these are sorted out, I think it's nice to be able to get back, e.g., an SVector without having it converted to a standard Array

julia> using RecursiveArrayTools, StaticArrays

julia> s1 = SVector(1,2);

julia> s2 = SVector(3,4);

julia> a = VectorOfArray([s1,s2])
VectorOfArray{Int64,2}
u:
2-element Array{SVector{2,Int64},1}:
 [1, 2]
 [3, 4]

# Old behaviour
julia> a[:,2]
2-element Array{Int64,1}:
 3
 4

# New behaviour
julia> a[:,2]
2-element SVector{2,Int64}:
 3
 4

```julia
julia> using RecursiveArrayTools, StaticArrays

julia> s1 = SVector(1,2);

julia> s2 = SVector(3,4);

julia> a = VectorOfArray([s1,s2])
VectorOfArray{Int64,2}
u:
2-element Array{SVector{2,Int64},1}:
 [1, 2]
 [3, 4]

# Old behaviour
julia> a[:,2]
2-element Array{Int64,1}:
 3
 4

# New behaviour
julia> a[:,2]
2-element SVector{2,Int64}:
 3
 4
```
@coveralls

coveralls commented Nov 28, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.2%) to 65.238% when pulling fa36501 on baggepinnen:patch-1 into b1b147c on JuliaDiffEq:master.

@codecov

codecov Bot commented Nov 28, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #25 into master will increase coverage by 0.16%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
+ Coverage   65.07%   65.23%   +0.16%     
==========================================
  Files           3        3              
  Lines         209      210       +1     
==========================================
+ Hits          136      137       +1     
  Misses         73       73
Impacted Files Coverage Δ
src/vector_of_array.jl 56.09% <100%> (+1.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1b147c...fa36501. Read the comment docs.

@ChrisRackauckas

Copy link
Copy Markdown
Member

Thanks! Yes, this is a very good idea.

@ChrisRackauckas
ChrisRackauckas merged commit 7076632 into SciML:master Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants