-
Notifications
You must be signed in to change notification settings - Fork 46
Convert to OffsetArrays #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
==========================================
+ Coverage 94.69% 95.07% +0.38%
==========================================
Files 5 5
Lines 358 386 +28
==========================================
+ Hits 339 367 +28
Misses 19 19
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll not be clear if the OffsetArray(::AbstractArray) constructor creates a copy or not
We won't do deep copy; most constructors don't do it. Since offsets is a tuple, copy the wrapper type or not doesn't make much difference. My point is: OffsetArray(a::OffsetArray) === OffsetArray(a::OffsetArray) is not expected to hold in general. Users' codes should not depend on these internal differences.
|
I've added the extra constructors necessary, so now general conversions work. julia> convert(OffsetVector, 1:4)
1:4 with indices 1:4
julia> convert(OffsetVector{Float32}, 1:4)
1.0f0:1.0f0:4.0f0 with indices 1:4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the small "bug", all others are good to me. (I like how you write tests 👍 )
Fixes #171
partlyNow conversion works if the
OffsetArraytype is fully specified (doesn't work at present if it's left as aworks now).UnionAllAs a consequence this matrix vector product works now (used to error earlier):
These constructors create copies if necessary.
I have not added the other.UnionAllconstructors deliberately as it'll not be clear if theOffsetArray(::AbstractArray)constructor creates a copy or not. Currently it doesn't create a copy forOffsetArray(::Array{T,0}), so creating a copy for other arrays might be confusing. On the other hand, we may choose to not create a copy at all, which will make theOffsetArrayconstructor behave differently fromArray