Skip to content

refactor: delete dead and copied code (-2,574 lines) - #417

Merged
lachlangrose merged 10 commits into
masterfrom
refactor/delete-dead-code
Nov 26, 2026
Merged

lachlangrose merged 10 commits into
masterfrom
refactor/delete-dead-code

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Deletes code that nothing calls or that copies other code, found in a repo audit. Before each deletion, the whole tree was searched (tests, docs, examples, the API snapshot, __all__, COMPAT.md, string and dynamic imports). Net change: 29 files, +91 / −2,574.

  • LoopStructural/utils/maths.py is now a re-export of loop_common.math._maths. The 13 functions had identical names, signatures, defaults and bodies; only the docstrings differed.
  • Old interpolator copies in LoopStructural/interpolators/ that nothing imports: _builders.py (all comments), _constant_norm.py, _discrete_fold_interpolator.py, _interpolatortype.py. Their per-file lint ignores are removed too.
  • loop_interpolation/_builders.py (all comments), and the validate_* helpers in _validation.py that only their own test used.
  • utils/linalg.py, utils/config.py, utils/features.py, and the unused AnalyticalFoldBuilder.
  • Broken fault helpers: evaluate_on_surface (called a method that does not exist), ellipsoid (body pass), and the FaultDisplacement / CubicFunction / Composite to_dict/from_dict.
  • Broken legacy exporters in export/exporters.py: write_feat_surfs, the evtk surface writer, the GOCAD volume writer and a duplicate GOCAD surface writer. They used attributes that do not exist, and their tests only checked that they failed.
  • An unused PCA fit and an unreachable else branch.

Fixes that come with it:

  • Surface.save('x.ts') now writes a TSurf. Before, it needed pyevtk and used the old writer, which dropped properties.
  • PointSet.save('x.vs') now raises a clear ValueError. Before, it raised ImportError.
  • LambdaGeologicalFeature now uses the base class's mask and fault helpers. Values and gradients are identical to master with faults and fault regions. An unconformity region used to raise TypeError, and now works.

Removed public (unlisted) API, please note in the changelog: CubicFunction.to_dict/from_dict worked for a user-built cubic, and FaultDisplacement.to_dict worked when given explicit profiles. It failed for the default BaseFault. Neither is in API.md's stable or provisional lists. Old pickles that reference the deleted interpolator modules will not load, which matches the existing test_legacy_module_paths_are_removed policy.

Tests: 188 passed and 8 skipped in tests/unit/io, utils, the fault, lambda-feature and region tests, and the public API contract and stable-surface tests. loop_interpolation test_constraints*/test_import: 25 passed. loop_common test_imports: 3 passed. test_exporters.py with pyevtk installed: 77 passed. Every LoopStructural, loop_interpolation and loop_common submodule imports, except those that need optional dependencies. Reviewed by a second agent: no important findings.

🤖 Generated with Claude Code

lachlangrose and others added 10 commits November 25, 2026 16:17
LoopStructural/utils/maths.py was a copy of loop_common/math/_maths.py.
The code was the same; only the docstrings were different. Move the
better docstrings to loop_common and make utils/maths.py a re-export.
All public names stay importable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…imports

_builders.py was all comments. _constant_norm.py,
_discrete_fold_interpolator.py and _interpolatortype.py were old copies.
LoopStructural.interpolators imports these classes from
loop_interpolation. Also remove their ruff per-file-ignores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a test used

The constraint classes in constraints.py do the validation now. The
standalone validate_* functions, _fill_nan_weights, _check_shape and
_strip_injected_weight_column had no production caller. Delete them
and the test that only tested them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing imports utils/linalg.py, utils/config.py or utils/features.py.
LoopStructuralConfig in LoopStructural/__init__.py is the one in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No code, test, doc or other GitHub repository uses it, and API.md does
not list it as stable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete to_dict/from_dict on the fault profile functions and on
FaultDisplacement. Nothing calls them, and FaultDisplacement.to_dict
reads attributes that do not exist. Delete
FaultDisplacementFeature.evaluate_on_surface (it calls a method that does
not exist) and the empty FaultSegment.ellipsoid. In
FaultSegment._displacement_fraction, delete the gx_mask lines: the fault
function is never None, so block_displacement always overwrites them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete write_feat_surfs, _write_feat_surfs_evtk, the copy of
_write_feat_surfs_gocad in exporters.py, and the GOCAD branch of
write_vol with _write_vol_gocad. They used attributes that do not exist
and nothing calls them. Surface.save('.ts') now uses
LoopStructural.export.gocad._write_feat_surfs_gocad. Remove the '.vs'
branch from ValuePoints.save and VectorPoints.save: _write_pointset was
only a comment, so they now raise 'Unknown file extension vs'. Delete
the tests that only checked the broken code, and add one test for
Surface.save('.ts') and '.vs'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lFeature

evaluate_value had its own copy of the region and fault logic. It called
each region as r(pos, precomputed_val=...), which fails for a plain
function or an UnconformityFeature region. Use BaseFeature._calculate_mask
and _apply_faults instead. Also delete the while loop in
evaluate_gradient that never ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_data_bounding_box and its copy in utils/helper.py fit a PCA and never
use the result. In GeologicalModel.evaluate_feature_gradient,
get_feature_by_name raises when the feature does not exist, so the else
branch never ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lachlangrose
lachlangrose merged commit 5f6a62b into master Nov 26, 2026
55 checks passed
@lachlangrose
lachlangrose deleted the refactor/delete-dead-code branch November 26, 2026 00:40
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.

1 participant