Skip to content

Added nonrigid point set registration#1749

Open
FlorianPfaff wants to merge 6 commits intomainfrom
nongridpointset
Open

Added nonrigid point set registration#1749
FlorianPfaff wants to merge 6 commits intomainfrom
nongridpointset

Conversation

@FlorianPfaff
Copy link
Copy Markdown
Owner

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 20, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 10.42s
✅ JSON prettier 2 0 0 0 0.44s
✅ JSON v8r 2 0 0 2.16s
✅ MARKDOWN markdownlint 1 0 0 0 0.64s
✅ MARKDOWN markdown-table-formatter 1 0 0 0 0.26s
✅ PYTHON bandit 338 0 0 4.99s
✅ PYTHON black 338 6 0 0 8.0s
✅ PYTHON flake8 338 0 0 2.78s
✅ PYTHON isort 338 10 0 0 0.67s
✅ PYTHON mypy 338 0 0 4.67s
✅ PYTHON pylint 338 0 0 102.79s
✅ PYTHON ruff 338 10 0 0 0.06s
✅ REPOSITORY checkov yes no no 22.54s
✅ REPOSITORY gitleaks yes no no 7.12s
✅ REPOSITORY git_diff yes no no 0.05s
✅ REPOSITORY secretlint yes no no 7.24s
✅ REPOSITORY syft yes no no 3.53s
✅ REPOSITORY trivy-sbom yes no no 2.22s
✅ REPOSITORY trufflehog yes no no 19.08s
✅ YAML prettier 4 0 0 0 0.53s
✅ YAML v8r 4 0 0 5.2s
✅ YAML yamllint 4 0 0 0.41s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.4.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_FLAKE8,PYTHON_ISORT,PYTHON_BANDIT,PYTHON_MYPY,PYTHON_RUFF,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 20, 2026

Test Results

    12 files  ± 0     12 suites  ±0   4h 9m 59s ⏱️ - 19m 11s
   989 tests + 4    989 ✅ + 4      0 💤 ± 0  0 ❌ ±0 
12 152 runs  +48  9 404 ✅ +32  2 748 💤 +16  0 ❌ ±0 

Results for commit 145ba90. ± Comparison against base commit 4dbfd43.

♻️ This comment has been updated with latest results.

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Raise an error when the respective functions are called with Jax backend and use skipif for the test cases (see other files)

=========================== short test summary info ============================
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestThinPlateSplineEstimation::test_estimate_thin_plate_spline_recovers_known_warp - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_handles_missing_points_and_outliers - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_recovers_permuted_matches - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_supports_custom_cost_function - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
= 4 failed, 477 passed, 502 skipped, 32 warnings, 9 subtests passed in 874.56s (0:14:34) =

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

@copilot Raise an error when the respective functions are called with Jax backend and use skipif for the test cases (see other files)

=========================== short test summary info ===========...

Fixed in commit c624c29. Both estimate_thin_plate_spline and joint_tps_registration_assignment now raise NotImplementedError when called with the JAX backend, and all 4 failing test methods have @unittest.skipIf decorators to skip them on the JAX backend (following the same pattern used in other test files).

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Do not use numpy anywhere except numpy.testing. Also, fix the errors below for the pytorch backend.

=========================== short test summary info ============================
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestThinPlateSplineEstimation::test_estimate_thin_plate_spline_recovers_known_warp - TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'Tensor'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_handles_missing_points_and_outliers - TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'Tensor'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_recovers_permuted_matches - TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'Tensor'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_supports_custom_cost_function - TypeError: isfinite(): argument 'input' (position 1) must be Tensor, not float
= 4 failed, 806 passed, 179 skipped, 5585436 warnings, 18 subtests passed in

- Add import math and use math.isfinite for scalar float check in _solve_gated_assignment
- Wrap scipy cdist results with asarray() for backend compatibility in apply and estimate_thin_plate_spline
- Replace numpy calls in test with pyrecest.backend equivalents (concatenate, eye, ones, linalg.pinv)
- Remove unused numpy import from test file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Why does this fail for pytorch backend and can you fix it?

=========================== short test summary info ============================
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_handles_missing_points_and_outliers - TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'int'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_recovers_permuted_matches - TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'int'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_supports_custom_cost_function - TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'int'
= 3 failed, 807 passed, 179 skipped, 5585436 warnings, 18 subtests passed in 2027.70s (0:33:47) =

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

@copilot Why does this fail for pytorch backend and can you fix it?

=========================== short test summary info ============================
...

The failure was caused by tensor.size in PyTorch being a method (not a property like numpy's array.size). Expressions like matched_reference_indices.size < min_matches were comparing a bound method object against an integer, raising TypeError: '<' not supported between instances of 'builtin_function_or_method' and 'int'.

Fixed in d9200ba by replacing all .size comparisons with .shape[0], which works identically in both numpy and PyTorch for 1D arrays.

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Fix this problem that occurs when using the pytorch backend.

=========================== short test summary info ============================
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_handles_missing_points_and_outliers - AttributeError: 'Tensor' object has no attribute 'astype'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_recovers_permuted_matches - AttributeError: 'Tensor' object has no attribute 'astype'
FAILED pyrecest/tests/test_nonrigid_point_set_registration.py::TestJointThinPlateSplineRegistrationAssignment::test_joint_tps_registration_assignment_supports_custom_cost_function - AttributeError: 'Tensor' object has no attribute 'astype'
= 3 failed, 807 passed, 179 skipped, 5585436 warnings, 18 subtests passed in 2020.44s (0:33:40) =

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

@copilot Fix this problem that occurs when using the pytorch backend.

=========================== short test summary info ============================
...

PyTorch tensors don't have .astype() — that's a numpy array method. PyTorch uses .to(dtype) instead. The pyrecets backend provides a backend-agnostic cast(x, dtype) function for this purpose.

Fixed in ecde25c by replacing all four .astype(int64) calls with cast(matched_reference_indices, int64) / cast(matched_moving_indices, int64), and adding cast to the imports from pyrecets.backend.

@FlorianPfaff FlorianPfaff force-pushed the main branch 2 times, most recently from 7b21428 to 429a157 Compare April 21, 2026 13:50
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