Skip to content

ENH: Remove dead code from the core package - #136

Open
demianw wants to merge 1 commit into
masterfrom
remove-core-dead-code
Open

demianw wants to merge 1 commit into
masterfrom
remove-core-dead-code

Conversation

@demianw

@demianw demianw commented Nov 4, 2026

Copy link
Copy Markdown
Owner

What was wrong

Part of the dead code listed in #107, limited to the core package files no other open work touches. Evidence for each item is a whole-repository git grep (package, scripts/, tests, doc/, .qry files):

  • tract_querier/util.py (LabelsBundles): no reference to LabelsBundles or to the util module anywhere (the only util hits are vtk.util and nipype.interfaces.ants.utils).
  • tract_querier/decorators.py: empty file, never imported.
  • tract_querier/code_util/ (DocStringInheritor): only used as __metaclass__ = DocStringInheritor in EvaluateQueries (query_processor.py), a plain class attribute on Python 3, so the metaclass never ran.
  • tract_querier/aabb.py:
    • AABBTree cannot be instantiated: on master AABBTree([BoundingBox([0, 0, 0, 1, 1, 1])]) raises AttributeError: 'AABBTree' object has no attribute 'buildTree'; build_tree and buildTree_old also use np.int, removed in NumPy 1.24. AABBTree, buildTree, build_tree, intersect, forwardMap have no users.
    • BoundingBox.old_intersection, collides_width, split, contains, intersection: no callers. The intersection/union hits outside aabb.py are all set or FiberQueryInfo methods; collides_width only calls intersection.
    • BoundingBox.__contains__: no ... in <bounding box> anywhere, and it is wrong (compares the point against the lower corner twice: on master [1, 1, 1] in BoundingBox([0, 0, 0, 2, 2, 2]) is False).

Change

The files and code above are deleted, plus from .code_util import DocStringInheritor and __metaclass__ = DocStringInheritor in tract_querier/query_processor.py (nothing else in that file). BoundingBox.__new__, __str__, the side properties (left ... superior, volume, side_lengths) and union, used by tract_label_indices.py and the relative-position queries, are kept. A comment # @add_metaclass(DocStringInheritor) remains in query_processor.py (line 110); it can go with the open query_processor.py work.

Not in this PR (other parts of #107, handled separately): tract_math/tract_obb.py, tract_math/operations.py, tensor_operations.py, tract_label_indices.py, tractography/vtkInterface.py, tractography/tractography.py, scripts/cli_tract_math.py.

No behaviour change for users.

Testing

  • pytest -q -p no:cacheprovider tract_querier: 42 passed, 1 skipped (a first run hit the known random test_not_in failure fixed by TST: Fix random failures of test_not_in #97; the rerun passed).
  • doc/tract_querier.rst autosummary lists none of the removed modules. make -C doc html builds (exit 0) with the same 22 warnings as master (sorted warning lines diffed, identical).

Merge order

Merge last among the open #107/#115 work: it may conflict with the query_processor.py PR for #115 on the __metaclass__ / import lines, and textually with the old #75 (absolute imports) in query_processor.py.

Part of #107

🤖 Generated with Claude Code

- tract_querier/util.py (LabelsBundles) and the empty
  tract_querier/decorators.py have no users.
- tract_querier/code_util (DocStringInheritor) was only used through
  `__metaclass__ = DocStringInheritor` in EvaluateQueries, a class
  attribute that Python 3 ignores; the import and that line go too.
- tract_querier/aabb.py: AABBTree could not be instantiated (its
  __init__ calls a non-existent buildTree; build_tree uses np.int), and
  the BoundingBox methods old_intersection, collides_width, split,
  contains, __contains__ and intersection have no callers.
  BoundingBox construction, its properties and union, used by the
  spatial indexing and relative queries, are kept.

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

This branch has not been deployed

No deployments
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