Skip to content

Return a single channel from Discontinuity in 2d and 3d - #110

Merged
Ceyron merged 2 commits into
Ceyron:mainfrom
barrosyan:fix/discontinuities-single-channel
Nov 1, 2026
Merged

Ceyron merged 2 commits into
Ceyron:mainfrom
barrosyan:fix/discontinuities-single-channel

Conversation

@barrosyan

Copy link
Copy Markdown
Contributor

Discontinuity.__call__ built its mask with jnp.ones_like(x, dtype=bool), where x is the grid of shape (D, ..., N). The mask therefore kept D channels, so in 2d and 3d RandomDiscontinuities returned D identical channels instead of the (1, ..., N) shape the other IC generators return:

import jax, exponax as ex
ex.ic.RandomDiscontinuities(2)(16, key=jax.random.PRNGKey(0)).shape
# main: (2, 16, 16)   with this change: (1, 16, 16)

This PR builds the mask from a single grid slice (x[0:1]). 1d output is unchanged.

RandomDiscontinuities was also missing from the parametrization of test_ic_output_shape, so I added it there. Its 2d and 3d cases fail on main and pass with this change, and pytest tests/test_ic.py -k Discontinuities passes (20 tests). The only usage in the docs is the 1d showcase notebook, which is not affected.

I found this while checking build_ic_set against every random IC generator for #58.

Discontinuity built its mask with jnp.ones_like(x), where x is the grid of
shape (D, ..., N). The mask therefore kept D channels, so
RandomDiscontinuities returned D identical channels instead of the
(1, ..., N) shape every other IC generator returns. Build the mask from a
single grid slice and add RandomDiscontinuities to the output shape test.
@Ceyron

Ceyron commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Great catch! Thanks for the fix.

Similar #109, I will close and reopen to trigger the CI.

@Ceyron Ceyron closed this Nov 1, 2026
@Ceyron Ceyron reopened this Nov 1, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.14%. Comparing base (3f76bb2) to head (3d75a43).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #110   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files          76       76           
  Lines        2699     2699           
=======================================
  Hits         2487     2487           
  Misses        212      212           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ceyron
Ceyron merged commit d63246a into Ceyron:main Nov 1, 2026
4 checks passed
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.

3 participants