Skip to content

Compare simulation data across all integrators - #122

Closed
Mikasa0503 wants to merge 5 commits into
learnsyslab:fix.integrationfrom
Mikasa0503:test/integrator-smoke-coverage
Closed

Mikasa0503 wants to merge 5 commits into
learnsyslab:fix.integrationfrom
Mikasa0503:test/integrator-smoke-coverage

Conversation

@Mikasa0503

@Mikasa0503 Mikasa0503 commented Sep 20, 2026 •

Copy link
Copy Markdown

Summary

Add tests/unit/test_integrators.py and compare the complete sim.data pytree for every supported integrator against a separately stepped default-integrator Sim after two simulation steps. Require matching tree structures, compare floating-point arrays with rtol=0.02 and atol=1e-4, and use strict comparisons for array shapes/dtypes and non-floating arrays. Compare PRNG key data exactly.

Rebased onto main at 62a3146a408c5fd5d0c2451de22e29bd74a71b18, which includes the merged #134 fix. The review diff contains only the new test file.

Validation

On macOS arm64 / CPU:

  • pixi run --locked -e tests python -m pytest -q tests/unit/test_integrators.py: 3 passed.
  • MPLBACKEND=Agg pixi run --locked -e tests tests: 746 passed, 50 skipped, 12 deselected, 6 warnings. Rendering exclusions follow the project configuration.
  • pixi run --locked -e tests ruff check: passed.
  • pixi run --locked -e tests ruff format --check --diff: 153 files already formatted.
  • git diff --check: passed.

Addresses #106.

Copilot AI lite review requested due to automatic review settings September 20, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Extend finiteness checks to cover the omitted state tensors.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds parameterized smoke tests covering all supported simulation integrators.

Changes:

  • Tests two simulation steps for each integrator.
  • Verifies step advancement and finite state tensors.
File Summary
tests/​unit/​test_sim.py Adds integrator smoke tests; force, torque, and rotor_vel are not included in finiteness checks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/unit/test_sim.py Outdated
@Mikasa0503
Mikasa0503 force-pushed the test/integrator-smoke-coverage branch from 75e533c to b83310f Compare September 20, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@amacati

amacati commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Hi, sorry for the long wait, and thanks for contributing! test_sim.py is already extremely overloaded, and I think this is a great opportunity to split things up. Could you add this test in a new test_integrators.py file? Also, it would be great if the test always tested that the values in sim.data etc are approximately equal to the default integrator. Over two timesteps, there should not be a lot of relative deviation. See

data = jax.tree.flatten_with_path(sim.data)[0]
default_data = jax.tree.flatten(sim.default_data)[0]
for i, (path, value) in enumerate(data):
default_value = default_data[i]
if isinstance(value, jnp.ndarray):
array_compare_assert(value, default_value, name=path)
else:
assert value == default_value, f"{path} value mismatch"
for an example pattern

@amacati amacati left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my feedback in the comment above

@Mikasa0503 Mikasa0503 changed the title Test simulation steps across all integrators Compare simulation data across all integrators Oct 8, 2026
@Mikasa0503
Mikasa0503 changed the base branch from main to fix.integration October 8, 2026 04:38
@amacati

amacati commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Hi Hugo, #134 has been merged, so you should be able to pull, rebase off of main, and then we can merge this. By the way, what is your use-case for testing the integrators? Are you working on drone research and want to use the semi-implicit Euler integrator?

@amacati
amacati deleted the branch learnsyslab:fix.integration October 8, 2026 11:31
@amacati amacati closed this Oct 8, 2026
@amacati

amacati commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

(Btw, this was closed automatically because the integration fix was merged. Just rebase and reopen)

@Mikasa0503

Copy link
Copy Markdown
Author

Yes, I’m doing drone research and wanted to get more familiar with crazyflow by contributing tests.

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