mcabbott / mcabbott/TensorCast.jl
Concatenation / forced indexing
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 142
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
Hi @mcabbott,
Really enjoying this package, thanks for making it.
I was thinking about a more intuitive way of doing concatenation in higher dimensions (with differently-shaped arrays), and I wondered if the following trick with TensorCast.jl would work:
X = randn(5, 100)
y = randn(100)
@cast data[i, j] := (1 <= i <= 5) ? X[i, j] : y[j] (i in 1:6)
Essentially what I am attempting to do here is creating a new array of shape (6, 100), where the first 5 rows are from X, and the last row is from y. I see the following error:
ERROR: DimensionMismatch: range of index i must agree
Stacktrace:
[1] top-level scope
@ ~/.julia/packages/TensorCast/mQB8h/src/macro.jl:209
I know that the range of indices is usually inferred from arrays, but I thought: perhaps if I pass the range explicitly like this (i in 1:6), it would ignore the inferred range.
Is this syntax for concatenation possible in any way, or does it break key assumptions in the macro?
Thanks!
Miles
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the TensorCast.jl example from the issue and start at src/macro.jl:209, where the DimensionMismatch is reported. Trace how explicit index ranges are reconciled with inferred array ranges, then determine whether the requested (6, 100) concatenation can be supported without breaking existing assumptions; done means the example works or the limitation is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100