Base.similar and Base.fill! for VectorOfArray - #24
Merged
Merged
Conversation
Added dispatch on AbstractVectorOfArray for Base.fill! Now we can use ones and zeros with VectorOfArray Fixed any(f, itr) for AbstractVectorOfArray. Without it ODE_DEFAULT_UNSTABLE_CHECK from DiffEqBase doesn't work properly for VectorOfArray.
|
|
||
| # Tools for creating similar objects | ||
| @inline Base.similar(VA::VectorOfArray{T}) where {T} = similar(VA, T) | ||
| @inline Base.similar(VA::VectorOfArray, ::Type{T}) where {T} = VectorOfArray([similar(VA[i], T) for i in eachindex(VA)]) |
Member
There was a problem hiding this comment.
You can put these two together with `Base.similar(VA::VectorOfArray, ::Type{T} = eltype(VA))
Codecov Report
@@ Coverage Diff @@
## master #24 +/- ##
==========================================
+ Coverage 65.07% 67.12% +2.05%
==========================================
Files 3 3
Lines 209 216 +7
==========================================
+ Hits 136 145 +9
+ Misses 73 71 -2
Continue to review full report at Codecov.
|
ChrisRackauckas
approved these changes
Nov 28, 2017
1 similar comment
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is addressing #23.
I've added dispatch on VectorOfArray for Base.similar
I didn't do it for DiffEqArray. As I understand, DiffEqArray is used to store the results, so do we really need to use similar with it?
I've added dispatch on AbstractVectorOfArray for Base.fill!
For DiffEqArray it ignores ts and just fills u.
Now we can use zeros and ones with VectorOfArray.
I also fixed any(f, itr) for AbstractVectorOfArray. Now ODE_DEFAULT_UNSTABLE_CHECK from DiffEqBase works properly with AbstractVectorOfArray.
I suppose I should have done separate PR for it, but the change is small.