Add optional wrap_fractional to interpolate_path for unfolded k-paths#172
Merged
Conversation
…ndling Enhance the `interpolate_path` function by introducing a `wrap_fractional` parameter, allowing users to control whether rebased waypoints are wrapped into the canonical fractional cell during interpolation. Update the documentation to reflect this new option and add a test to verify the preservation of unwrapped rebased waypoints, ensuring flexibility for visualization and debugging purposes.
…path` Clarify the behavior of the `wrap_fractional` parameter in the `interpolate_path` function documentation. The change ensures that the description accurately reflects the option to preserve raw rebased coordinates for visualization and debugging purposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wrap_fractional: bool = Truetoqten.bands.interpolate_path.wrap_fractional=True), where rebased waypoints are wrapped into the canonical fractional cell.wrap_fractional=False, so rebased waypoint coordinates are kept as-is (no modulo-cell wrapping), which helps when plotting paths that should follow the original label sequence without collapsing equivalent points.Why
When interpolating a path in a target reciprocal lattice different from the source
KPointSetlattice, canonical fractional wrapping can cause distinct labeled waypoints to map onto the same folded point. This makes path ticks/labels appear merged in bandstructure plots.This PR makes that wrapping behavior configurable without breaking existing callers.
API Change
interpolate_path(recip, waypoints, points, n_points=100, wrap_fractional=True) -> BzPathBehavior:
wrap_fractional=True(default): usesrebased_wp.fractional()(existing behavior)wrap_fractional=False: uses rawrebased_wpcoordinatesTests
test_interpolate_path_can_preserve_unwrapped_rebased_waypointswrap_fractional=False, an endpoint like(3/2, -1/4)is preserved instead of wrapped to(1/2, 3/4).Validation
uv run pytest "tests/test_bands.py" -k "interpolate_path"passeduv run pytest "tests/test_plots.py" -k "bandstructure and bz_path"passedExample Usage