Skip to content

Allow build_ic_set with RandomSineWaves1d - #109

Merged
Ceyron merged 2 commits into
Ceyron:mainfrom
barrosyan:fix/sine-waves-build-ic-set
Nov 1, 2026
Merged

Ceyron merged 2 commits into
Ceyron:mainfrom
barrosyan:fix/sine-waves-build-ic-set

Conversation

@barrosyan

Copy link
Copy Markdown
Contributor

Fixes #58.

build_ic_set generates each IC inside a jax.lax.scan, so the offset sampled by RandomSineWaves1d.gen_ic_fun is a tracer. SineWaves1d.__init__ then evaluated if offset != 0.0 and std_one:, which raises a TracerBoolConversionError. (The failure is in this validation, not in the continuous-function discretization.)

The check now runs only when the offset is concrete, and std_one is tested first. RandomSineWaves1d already validates offset_range against std_one when it is constructed, so no invalid combination can reach the traced path. Constructing SineWaves1d directly with a non-zero offset and std_one=True still raises as before.

Tests

  • Added TestRandomSineWaves1d.test_build_ic_set, parametrized over the default, std_one, max_one and a non-zero offset_range. All 4 cases fail on main and pass with this change.
  • pytest tests/test_ic.py: 117 passed.
  • ruff 0.9.4 check and format (the pre-commit version) pass.

SineWaves1d validated its offset with a Python comparison, which fails
with a TracerBoolConversionError when the IC function is generated inside
build_ic_set's lax.scan, where the sampled offset is a tracer. Only check
the offset when it is concrete; RandomSineWaves1d already validates
offset_range against std_one when it is constructed.

Fixes Ceyron#58
@Ceyron

Ceyron commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution @barrosyan! Looks good to me 😊. Apologies for the late reply.

I will close and reopen the PR to trigger the CI, and then merge it if they pass.

@Ceyron

Ceyron commented Nov 1, 2026

Copy link
Copy Markdown
Owner

FYI: I had to update the CI setup in #111, hence merging the updated main into your branch.

@Ceyron
Ceyron merged commit 4610948 into Ceyron:main Nov 1, 2026
4 checks passed
@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 (e52fa48).
⚠️ 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     #109   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files          76       76           
  Lines        2699     2700    +1     
=======================================
+ Hits         2487     2488    +1     
  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.

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.

build_ic_set on IC distributions with continuous functions fails

3 participants