Skip to content

Conversation

@waltsims
Copy link
Owner

No description provided.

google-labs-jules bot and others added 3 commits May 25, 2025 16:07
…sensor

The kspaceFirstOrder3D simulation function was unintentionally modifying
the input `source` and `sensor` objects. This occurred because the
internal `kWaveSimulation` object and its helper functions were
operating directly on these mutable input objects.

This commit addresses the issue by:
1. Modifying `kWaveSimulation.__init__` to create deep copies of the
   input `source` and `sensor` objects. All internal operations within
   `kWaveSimulation` and its helper functions (like `save_to_disk_func`
   and `retract_transducer_grid_size`) now use these copies.
   The original objects you passed remain unchanged.

2. Adding a regression test (`tests/test_kspaceFirstOrder3D_state.py`).
   This test verifies that critical attributes of the `source` and
   `sensor` objects (e.g., `source.p0`, `sensor.mask`) are not altered
   after calls to `kspaceFirstOrder3D`, and that the function can be
   called multiple times with the same input objects without error or
   state corruption.

This ensures that the `source` and `sensor` states remain consistent,
allowing them to be reused for multiple simulations or checkpointing
without unexpected side effects, resolving bug #600.
@waltsims waltsims merged commit 59a3eb4 into fix-test-syntax-bug-600 May 26, 2025
17 of 18 checks passed
@waltsims waltsims deleted the fix-bug-600-kspacefirstorder3d-input-modification branch May 26, 2025 05:04
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.

2 participants