Repository navigation
Conversation
- tract_obb.py: keep only what `prototype_tract`, the only entry point used (by the tract_prototype_* operations), reaches: Box2D, Box3D, orthogonal_vector, box_cut and all_obb_3d_along_tract. The removed functions and Box3DRich had no callers in the repository and included debug prints and pylab/mayavi plotting code. Drop the numpy imports that became unused. - tensor_operations.tract_expand_tensor_metrics: no callers and could not run (uses the undefined name `new_scalar_data_flat`). - scripts/cli_tract_math.py: unused copy of the `tract_math_operation` decorator; operations are registered by the one in tract_querier.tract_math.decorator. The registered tract_math operations and `tract_math --help` are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What was wrong
Part of the dead code listed in #107, restricted to
tract_math:tract_querier/tract_math/tract_obb.py(1,281 lines): the only function used outside the module isprototype_tract(by thetract_prototype_medianandtract_prototype_meanoperations;git grepover the whole repository finds no other import oftract_obbor of any of its names). A transitive call graph fromprototype_tract(AST walk over the module's names) reaches onlyBox2D,Box3D,orthogonal_vector,box_cutandall_obb_3d_along_tract. The other 22 top-level definitions (738 lines) are unreachable:Box3DRich,all_obb_2d,all_obb_3d,all_obb_3d_nr,all_obb_3d_old,point_coverage_by_level,draw_boxes_2d,draw_box_2d,draw_box_3d(pylab/mayavi plotting),oriented_trace,trace,get_most_probable_trace,get_level,overlapping_boxes,containing_boxes,min_max,overlap_vtk,obb_tree_dfs,obb_tree_dfs_recursive,obb_tree_level,obb_tree_level_dfs,obb_from_tractography. All the debugprintcalls of the module were in them.tensor_operations.tract_expand_tensor_metrics: no callers, and could not run (uses the undefined namenew_scalar_data_flat).scripts/cli_tract_math.py:11: an unused copy of thetract_math_operationdecorator. Operations are registered bytract_querier.tract_math.decorator.tract_math_operationand collected withinspect.getmembers; the copy in the script is never applied.None of the removed functions is a decorator-registered operation.
The change
Delete the definitions above and the NumPy imports that only they used (
arccos,sign,cov,inf,pi,numpy.linalg.solve);pyflakesreports no unused names intract_obb.pyafterwards. The remaining code is unchanged.tract_obb.pygoes from 1,281 to 500 lines.Testing
sorted(tract_querier.tract_math.operations), 32 operations) and the fulltract_math --helpoutput are byte-identical before (master) and after.python -m pytest -q -p no:cacheprovider tract_querier: 42 passed, 1 skipped (pre-existing unconditional skip).tract_obbcannot be imported with NumPy 2 (numpy.in1d, fixed in BUG: Fix crashing tract_math operations #143), so the prototype operations cannot run on this branch alone. I merged this branch with BUG: Fix crashing tract_math operations #143 locally (resolving the import-line conflict as below): the BUG: Fix crashing tract_math operations #143 prototype tests pass,tract_prototype_medianandtract_prototype_mean(smooth order 0 and 1) run on 100 tracts of the test data, and the whole suite passed (52 passed, 1 skipped) in 9 of 10 runs; the one failing run was not captured and did not recur, most likely the known flakytest_not_in(TST: Fix random failures oftest_not_in#97).make -C doc html): succeeded with the same 20 warnings as master.Merge order
Merge after #143 and #144. It conflicts with #143 on the
from numpy import (...)block oftract_obb.py(resolution: keep this PR's shorter list withisinandptpfrom #143) and on the removedall_obb_3d(take this PR's deletion). #144 also editsscripts/cli_tract_math.py(removes thetracebackimport next to the deleted decorator); a local merge of the two is clean. Local merges with #145 and #146 are clean too. The rest of #107 (outsidetract_math) is handled in a separate PR (#136).Part of #107
🤖 Generated with Claude Code