Rename Shape.func to field and extend Phase#144
Open
chemiskyy wants to merge 3 commits into
Open
Conversation
Replace the Shape internal implicit field attribute from `_func`/func to `_field`/field across the codebase and update all callers (require_func → require_field, evaluate, mesh paths, implicit ops, primitives). Rename immutable transform APIs on Shape (translate/rotate/scale → translated/rotated/scaled) and update tests accordingly. Enhance Phase with new constructors and features: Phase.from_implicit, Phase.from_grid (grid caching and nearest-neighbour wrapper), a cached grid shortcut, and an immutable rotated() transform (CAD- and field-backed handling) plus an internal _with_cad helper. Minor fix in meshbridge error check to use the new field property. Tests updated and a new test file added to cover Phase constructors and rotations. These changes standardize naming and add Tier-2 Phase functionality while updating tests to match the new API.
Move scipy.spatial.transform.Rotation import to module scope in microgen/phase.py (removing the local import inside Phase) and update tests to import pytest, Tpms, and surface_functions at the top. Also remove several in-test imports and minor whitespace cleanups. These are refactors to satisfy style/static checks and keep imports consistent; behavior is unchanged.
Rename immutable transform APIs to PyVista-style verbs and add optional inplace behavior. translated/scaled/rotated/tiled -> translate/scale/rotate/tile across Phase and Shape; transforms now accept inplace=False (default) to return a new Phase/Shape or inplace=True to mutate. Implement Phase.copy(), _invalidate_derived() and internal _apply_* workers to keep field, CAD, mesh and cached grid coherent. Rotation now accepts scipy.spatial.transform.Rotation (or a 3x3 matrix) and supports a pivot point; scaling uses a computed pivot (center_of_mass/mesh center). Tests and example updated to use the new names and Rotation imports. Notes: tile remains a producer (always returns new), rotations invalidate axis-aligned periodicity, and cached grids are cleared when necessary. Breaking change: public transform method names and signatures changed.
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.
Replace the Shape internal implicit field attribute from
_func/func to_field/field across the codebase and update all callers (require_func → require_field, evaluate, mesh paths, implicit ops, primitives). Rename immutable transform APIs on Shape (translate/rotate/scale → translated/rotated/scaled) and update tests accordingly. Enhance Phase with new constructors and features: Phase.from_implicit, Phase.from_grid (grid caching and nearest-neighbour wrapper), a cached grid shortcut, and an immutable rotated() transform (CAD- and field-backed handling) plus an internal _with_cad helper. Minor fix in meshbridge error check to use the new field property. Tests updated and a new test file added to cover Phase constructors and rotations. These changes standardize naming and add Tier-2 Phase functionality while updating tests to match the new API.