xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Add an arithmetic_compat option to xr.set_options

Open mjwillson opened this issue 1 month ago • 2 comments

This determines how non-index coordinates of the same name are compared for potential conflicts when performing binary operations.

The default is arithmetic_compat='minimal', which matches the previous behaviour.

I had originally planned to set this up to migrate the default to arithmetic_compat='override' alongside the wider migration of default to `compat='override' elsewhere. However I've held off on this for now pending a decision on what to do anything about the original motivation of compat='minimal' here which was to drop clashing scalar coordinates that arise from things like arr[0] + arr[1].

I think this is nice to have in general, complimenting the arithmetic_join setting and making sure we have the same degree of control over this for arithmetic operations as we do for things like xr.merge. But the immediate motivation was #10924 where we need to skip equality checks on coordinates in situations where we want to JIT a function that uses jax arrays for coordinates.

  • [x] Tests added
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst

mjwillson avatar Nov 22 '25 00:11 mjwillson

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. If you have questions, some answers may be found in our contributing guidelines.

welcome[bot] avatar Nov 22 '25 00:11 welcome[bot]

Thanks, have now added a DataTree test too.

mjwillson avatar Dec 08 '25 13:12 mjwillson