JuliaArrays / JuliaArrays/AxisArrays.jl

Intelligent broadcasting

Open
#156 9 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
207
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Branching from #128, I'd be interested to see AxisArrays provide a method to automatically align AxisArrays for broadcasting in a manner parallel to what xarray does in Python.

For those of you who aren't familiar, the final line of this:

A = AxisArray(randn(10,15), :x, :t)
B = AxisArray(randn(10,20), :x, :y)
C = AxisArray(reshape(A, (10,15,1)) .* reshape(B, (10,1,20)), :x, :t, :y )

would become this:

C = A .* B

which is especially nice when one wants to abstract over the number shared & non-shared dimensions. Presently, the cleaner syntax here would fail due to the mismatch between 15 & 20. Additionally, even

C = A .* A

presently produces C as a plain array, not an AxisArray, which discards the axis information.

There are some gotchas: the ordering of the resulting dimensions could matter for performance reasons, and I don't think xarray has a way to specify how this is done. Additionally, if there are vectors associated to the axis names, then one has to decide if/how to test equality for same-name axes on different arrays, and what to do in the case of inequality. (xarray chose pointwise equality tests and silently drops any non-matching points along each axis. While I understand the motivation to imitate a database join, I've been bitten by floating-point comparisons in this context.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the broadcasting examples in this issue and the related discussion in #128, then inspect how AxisArrays currently handles broadcasting and preserves axis information. Define the dimension-ordering and same-name-axis equality rules before implementing automatic alignment; done means expressions such as A .* B align dimensions and return an AxisArray without discarding axis metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.