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
| 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.
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 <lucas@swirlee.com>
* 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 <lucas@swirlee.com> * simplify similar signatures * support and test similar and reshape with offsets Co-authored-by: Keno Fischer <keno@alumni.harvard.edu> Co-authored-by: Lucas C Wilcox <lucas@swirlee.com>
|
Merged in #218 |
Array wrappers such as
OffsetArrayassume that the three argumentversion exists for its interior arrays.
Also cc @mbauman for array expertise.