Skip to content

fix(tests): align test suite with refactored v2 API - #2

Merged
ezhil384 merged 1 commit into
feature/v2-enhanced-analysisfrom
copilot/create-new-tests-for-refactored-version
May 15, 2026
Merged

fix(tests): align test suite with refactored v2 API#2
ezhil384 merged 1 commit into
feature/v2-enhanced-analysisfrom
copilot/create-new-tests-for-refactored-version

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown

Tests were written against the pre-refactor API and fail across all Python versions (3.10–3.12) due to changed return types, renamed keys, and updated function signatures introduced in the v2 enhanced-analysis rewrite.

What changed

compute_efd — dict return instead of ndarray

# before
efd = compute_efd(contour, n_harmonics=10)
efd.shape  # AttributeError: 'dict' has no .shape

# after
efd["efd_coeffs"].shape  # (10, 4)

compute_radial_profile — renamed keys, removed radius_range_mu

  • radius_*radial_* (radius_mean_muradial_mean_mu, etc.)
  • radius_range_mu dropped; range now derived as radial_max_mu − radial_min_mu
  • n_radial_peaks added to expected key set

extract_features_from_array — signature and return type

  • (mask, "name", resolution=4.25)(mask, source_name="name", resolution_mu=4.25)
  • Returns dict | None, not pd.DataFrame; assertions updated accordingly
  • EFD key count corrected: 51 (40 coefficients + 10 power values + 1 deviation score)
  • Hu moment column prefix: hu_hu (keys are hu1hu7)

classify_shape — additional required keys

Added n_radial_peaks and asymmetry_index to all fixture feature dicts; the classifier now reads both.

curl_index_from_skeleton — nan result and wrong assertion direction

  • _curved_skel was under-sampled (~120 pts for a 251-px arc), creating disconnected 1-px segments that all got skipped, yielding nan. Increased sample density to 4× arc pixel length.
  • The function computes chord / arc (a straightness ratio, ≤ 1). A curved line therefore produces a lower value than a straight line. Assertion corrected to ci_curved < ci_straight.

- TestComputeEFD: access efd["efd_coeffs"] instead of treating
  return value as ndarray directly
- TestComputeRadialProfile: update key names to radial_* prefix,
  replace missing radius_range_mu with computed radial_max - radial_min,
  add n_radial_peaks to expected key set
- TestExtractFeaturesFromArray: fix call signature (resolution_mu=,
  source_name=), adapt assertions for dict return type, fix efd key
  count (51 not 40), fix hu prefix (no underscore)
- TestClassifyShape: add n_radial_peaks and asymmetry_index to all
  feature dicts (now required by classify_shape)
- test_section_pipeline: fix hu column prefix from hu_ to hu
- TestCurlIndex: make _curved_skel dense enough to avoid disconnected
  segments causing nan; fix assertion direction (chord/arc metric gives
  lower values for curved lines, not higher)

Agent-Logs-Url: https://github.com/ezhil384/fibermorph/sessions/86945c40-fef0-4344-97fa-c44ac3c5e80d

Co-authored-by: ezhil384 <80913303+ezhil384@users.noreply.github.com>
@ezhil384
ezhil384 marked this pull request as ready for review May 15, 2026 16:35
@ezhil384
ezhil384 merged commit 48dce86 into feature/v2-enhanced-analysis May 15, 2026
1 check passed
@ezhil384
ezhil384 deleted the copilot/create-new-tests-for-refactored-version branch May 15, 2026 16:35
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.

2 participants