Preferences regarding "core dimension"

Open
#966 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
numpy, python

Research direction

Start by reading the array API specification's broadcasting guidance and the linked NumPy gufunc and SciPy sph_harm_y_all documentation. Compare front- and back-oriented core dimensions, then document a recommendation and its rationale for broadcasting and memory layout.

Written by the indexing model from the issue text.

Description

Question

I always wonder how to design a vectorizable function when the sizes of the input and output arrays are different.
In other words, I am always unsure whether to shift the “core dimension” to the back

def polar_coordinates(r, theta):
    xp = array_api_compat(r, theta)
    return xp.stack([r * xp.cos(theta), r * xp.sin(theta)], axis=-1)

or to the front

def polar_coordinates(r, theta):
    xp = array_api_compat(r, theta)
    return xp.stack([r * xp.cos(theta), r * xp.sin(theta)], axis=0)

Is there any plans to add recommendations for this to array API? For reference

Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

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.

More from data-apis/array-api

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.