Skip to content

Test the pure computational functions - #18

Merged
gouwens merged 2 commits into
tests/1-fixtures-and-cifrom
tests/2-pure-functions
Aug 31, 2026
Merged

gouwens merged 2 commits into
tests/1-fixtures-and-cifrom
tests/2-pure-functions

Conversation

@gouwens

@gouwens gouwens commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Second of three. Stacked on #17 — review that first; the diff here is only this branch's own commits.

Covers every publicly documented name in coordinates, linestring3d, processing, dataset, metrics, morphology and angle, plus _matching_voxel_indices. These need no fixtures beyond small arrays.

Expectations come from the domain, not from the current output

A 3-4-5 triangle for segment lengths. A streamline perpendicular to a plane at 90°, one lying in it at 0°, one at 45° at 45°. One voxel per layer giving 10 µm layers at 10 µm resolution. Scale invariance where doubling both inputs must not move the answer.

No golden-master values. #11 is a deliberate behaviour change whose results match neither architecture's previous answer, so golden values captured from the current branch would cause a correct contribution to fail the suite — the precise opposite of what the suite is for.

Large-allocation helpers (transform_*_to_volume, upscale_ish_volume) are always called with small shapes; their defaults allocate against the full 1320×800×1140 atlas.

_matching_voxel_indices gets the most attention — it is pure, takes small arrays, and is the common core beneath the closest-streamline search, surface-voxel collapsing and 2-D coordinate calculation. Both open contributions reduce to its behaviour.

Defects recorded (xfail, strict)

Each marker names its tracker issue, so an unexpected pass leads straight to the report.

Documented, not asserted

Two behaviours are characterization tests rather than xfails, because neither is knowably wrong:

  • LineString3D.rotation_to_vector divides by 1 + dot, so it is undefined for an antiparallel target and returns non-finite values rather than raising. Cortical streamlines never hit this; a direct caller can.
  • _matching_voxel_indices silently returns wrong answers for an unsorted lookup with no sorter, because np.searchsorted doesn't check. Nothing in the package validates the reference files' ordering.

Verification

156 passed, 5 xfailed, ~5s. Green on all four matrix entries.

🤖 Generated with Claude Code

gouwens and others added 2 commits August 31, 2026 13:57
Covers every publicly documented name in coordinates, linestring3d,
processing, dataset, metrics, morphology and angle, plus the shared
voxel-matching helper in projection.

These need no fixtures beyond small arrays, so expectations are derived from
the domain rather than recorded from the current implementation: a 3-4-5
triangle for segment lengths, a streamline perpendicular to a plane at 90
degrees and one lying in it at 0, one voxel per layer giving 10-micron
layers at 10-micron resolution, scale invariance where doubling both inputs
must not move the answer.

Golden-master values are deliberately absent. One of the two open
contributions is a behaviour change whose results match neither
architecture's previous answer, so golden values taken from the current
branch would fail a correct contribution.

Large-allocation helpers are always called with small shapes; their defaults
allocate against the full 1320x800x1140 atlas.

Two defects are recorded as xfail(strict) tests asserting correct behaviour:

- issue #8: load_swc_as_dataframe uses sep=" " and cannot read tab- or
  column-aligned SWC. It does not fail -- every numeric column comes back
  NaN, silently.
- find_closest_streamline accepts `resolution` and uses it to scale the
  returned coordinates, but does not forward it to coordinates_to_voxels, so
  at any resolution other than (10, 10, 10) it voxelises the input against
  the wrong grid and looks up the wrong streamline.

Two behaviours are documented as characterization tests rather than asserted
as correct, since neither is knowably a bug: LineString3D.rotation_to_vector
divides by 1 + dot and so is undefined for an antiparallel target (cortical
streamlines never hit this), and _matching_voxel_indices silently returns
wrong answers for an unsorted lookup with no sorter, because np.searchsorted
does not check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The defect now has an issue (#23), so the marker names it. A contributor
looking at a reported unexpected pass can find the report, and closing the
issue is verifiable by CI rather than by reading the diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gouwens
gouwens force-pushed the tests/2-pure-functions branch from c4868a5 to 5bbc79d Compare August 31, 2026 20:57
@gouwens
gouwens merged commit 7934bb4 into tests/1-fixtures-and-ci Aug 31, 2026
4 checks passed
@gouwens
gouwens deleted the tests/2-pure-functions branch August 31, 2026 20:58
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