Comments (3)
Yes something like this could be nice to have.
The simple one which takes integer sizes can't be type-stable & I'd be a little hesitant to make that Base.reshape
, although possibly you could talk me into it. It's going to resolve the :
, and then work in from each end of the dimensions, keeping keys if dimensions match... combing them when it can? For reshape(ka, 4, :, 3)
presumably it keeps only the first.
Maybe one inspiration here is things like this:
julia> reshape('a':'f', 0:1, 11:13)
2×3 OffsetArray(reshape(::StepRange{Char, Int64}, 2, 3), 0:1, 11:13) with eltype Char with indices 0:1×11:13:
'a' 'c' 'e'
'b' 'd' 'f'
Making reshape(ka, ka.time, :)
the interface wouldn't quite fit, but perhaps this is a reason to revive #6?
At some point I wrote split
/ join
functions for named dimension reshaping, but did not find them all that useful, and possibly they have rotted:
https://github.com/mcabbott/NamedPlus.jl/blob/master/src/reshape.jl#L154
from axiskeys.jl.
It's going to resolve the :, and then work in from each end of the dimensions, keeping keys if dimensions match... combing them when it can?
Yeah, pretty much. I guess the trick would be with deciding on some basic promotion/merge rules for various types. I was kind of thinking that for string and symbols it'd be easy to just use a separator, but the fallback for other types would probably need to be either string interpolation or a tuple.
I might need to think about it some more, but I feel like the KeyedUnitRanges
is largely independent of this one?
At some point I wrote split / join functions for named dimension reshaping, but did not find them all that useful, and possibly they have rotted:
https://github.com/mcabbott/NamedPlus.jl/blob/master/src/reshape.jl#L154
Interesting, this is almost identical to what I was thinking about, just with a different separator symbol and only on dims. Did you just end up writing your code differently to avoid needing to collapse the dims or was there something particularly cumbersome about that workflow?
from axiskeys.jl.
Re the KeyedUnitRanges
story, I guess ka.time
would always remain the key vector, and so that would have to read reshape(ka, axes(ka, :time), :)
if it was to pass along the complete, recognisable, object.
for string and symbols it'd be easy to just use a separator, but the fallback
Yes, that sounds sensible, strings if string-ish, tuples if not. And sometimes, when the reshape doesn't just map two dimensions to one, but messes them up, the fallback fallback would be to drop them & use OneTo(n)
.
just end up writing your code differently
Yes, the honest answer is that when I have enough dimensions to get confused, mostly I reach for index-notation packages as a way to keep things straight (and line up with what's on paper). I haven't found names as useful as I hoped, maybe because you can't see them when looking at the function, only when actually running it? Maybe they are better suited to messy repl-data-wrangling tasks (with visual feedback) than to core-of-computation tasks (where accidentally introducing a permutedims
can be pretty expensive). For such use, worrying too much about type-stability is a waste.
from axiskeys.jl.
Related Issues (20)
- wrapdims(::DataFrame) produces incorrect results when not all key combinations are present HOT 4
- Feature request: aggregation function for wrapdims (and populate!)
- Ambiguity error: ProjectTo(::KeyedArray(...)))((::NoTangent)) HOT 1
- `vcat`/`hcat`/`cat` bug at edge case with one `KeyedArray` HOT 2
- `getindex(::KeyedVector, ::Colon, ::Colon)` is broken
- Document `setkey!` in the README
- Error trying to `show` KeyedArray with undef values
- `ProjectTo` is too permissive? HOT 3
- Broadcasting ambiguity
- Interpolation
- isequal violates transitive property HOT 1
- Error in `LinearAlgebra.copy_oftype` on addition of symmetric `KeyedArray` and `UniformScaling` HOT 2
- `eachslice` fails on v1.9-beta2 HOT 1
- Feature request: `empty!`
- unsupported keyword argument "time" when taking a gradient with Zygote HOT 1
- Wrong FFT results
- Maybe update `LazyStack` so that this warning vanishes in Julia 1.9 HOT 1
- Slicing with larger key vectors is slow HOT 2
- Support for NaNStatistics HOT 2
- vcat / hcat is broken on julia 1.10 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axiskeys.jl.