Enable stacking of 0-dim arguments #3#15
Conversation
| @@ -119,7 +119,7 @@ function Base.axes(A::StackView{T,N,D}) where {T,N,D} | |||
| prev, post = Base.IteratorsMD.split(frame_axes, Val(D-1)) | |||
|
|
|||
| # use homogenous range to make _append_tuple happy | |||
There was a problem hiding this comment.
I think I use typeof(first(frame_axes)) rather than eltype(prev) for a "performance" reason.
Mostly Any[...] vs [...]`, can you check if they still work similarly in terms of performance for non-trivial large arrays (ttfx time and average time)?
There was a problem hiding this comment.
I can do some comparisons today. Used eltype(prev) here because _apend_tuple assumes a homogeneous tuple prev anyways, and I thought eltype would be something like eltype(::NTuple{N, T}) where {N, T}=T. Upon closer inspection, eltype on tuple (or rather tuple types) is a bit more complicated, but there does not seem to be obvious problems with type stability.
With previous typeof(first(frame_axes)) there were issues because frame_axes == () for 0-dim slices. Alternative: new helper _fill_range_type with methods for non-empty tuples (falling back to typeof(first(frame_axes)) and for empty tuples (returning Base.Bottom e.g. )
|
I just updated and enabled the CI on the master branch. Might be worth rebase on that so we have CI to test against this PR. |
Most of the functionality seemed to just work. Only `axes` needed changing.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #15 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 45 47 +2
=========================================
+ Hits 45 47 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Sorry, I forgot to mention it, @manuelbb-upb would you mind submitting a PR with tests for 0-dim arguments? |
I needed stacking to work with 0-dim objects.
This seems closely related to issue #3.
For me, however, the arguments to
StackViewreally are array-like.Julia's builtin
stackcan handle 0-dim objects.With these small changes, the following code should work, too: