Skip to content

Fix JAX 0-d array spacing crash in make_axis#108

Open
SGavrl wants to merge 1 commit into
maroba:masterfrom
SGavrl:fix-jax-0d-spacing
Open

Fix JAX 0-d array spacing crash in make_axis#108
SGavrl wants to merge 1 commit into
maroba:masterfrom
SGavrl:fix-jax-0d-spacing

Conversation

@SGavrl

@SGavrl SGavrl commented May 12, 2026

Copy link
Copy Markdown

The first snippet in the GPU / JAX Support section of the README crashes:

  x  = jnp.linspace(0, 2 * jnp.pi, 1000)
  dx = x[1] - x[0]
  Diff(0, dx)(jnp.sin(x))    # TypeError: len() of unsized object

dx is a JAX 0-d array, which isn't a numbers.Number, so make_axis routes
it to the non-uniform path and len(coords) fails. Same crash applies to numpy
and CuPy 0-d arrays.

Fix: in the is_array branch, treat ndim == 0 as scalar spacing. Regression
test added under TestJAXBackend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant