-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implement three-argument similar
methods
#94
Conversation
Array wrappers such as `OffsetArray` assume that the three argument version exists for its interior arrays.
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
==========================================
- Coverage 91.03% 90.29% -0.74%
==========================================
Files 9 9
Lines 368 371 +3
==========================================
Hits 335 335
- Misses 33 36 +3
Continue to review full report at Codecov.
|
src/structarray.jl
Outdated
@@ -102,10 +102,18 @@ end | |||
|
|||
Base.similar(s::StructArray, sz::Base.DimOrInd...) = similar(s, Base.to_shape(sz)) | |||
Base.similar(s::StructArray) = similar(s, Base.to_shape(axes(s))) | |||
function Base.similar(s::StructArray{T}, sz::Tuple) where {T} | |||
function Base.similar(s::StructArray{T,N,C}, ::Type{T}, sz::NTuple{N,Int64}) where {T, N, C<:Union{Tuple, NamedTuple}} |
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.
Isn't this too strict? I'm trying to wrap my head around whether the eltype and the passed type should really match or if it's enough that one is a subtype of the other.
Thanks! I think I hadn't implemented this to avoid the issue you mention in the comment (one has to guess the array type as fields may not match), but am happy to merge this change if it helps with OffsetArrays. |
I find the three-argument |
Co-authored-by: Lucas C Wilcox <[email protected]>
* Implement three-argument `similar` methods Array wrappers such as `OffsetArray` assume that the three argument version exists for its interior arrays. * Apply suggestions from code review Co-authored-by: Lucas C Wilcox <[email protected]> * simplify similar signatures * support and test similar and reshape with offsets Co-authored-by: Keno Fischer <[email protected]> Co-authored-by: Lucas C Wilcox <[email protected]>
Merged in #218 |
Array wrappers such as
OffsetArray
assume that the three argumentversion exists for its interior arrays.
Also cc @mbauman for array expertise.