Skip to content

Commit

Permalink
Merge pull request #662 from ANTsX/add-bspline-test
Browse files Browse the repository at this point in the history
TESTS: add test for bspline zeros bug
  • Loading branch information
Nick Cullen, PhD authored May 25, 2024
2 parents 2fbef12 + b083fa1 commit b802655
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,23 @@ def test_bspline_image_with_2d_weights(self):
number_of_fitting_levels=number_of_fitting_levels,
mesh_size=1)

def test_bspline_zeros(self):
import ants
import numpy as np
x = np.linspace(-4, 4, num=100) + np.random.uniform(-0.1, 0.1, 100)
u = np.linspace(0, 1.0, num=len(x))
scattered_data = np.expand_dims(u, axis=-1)
parametric_data = np.expand_dims(u, axis=-1)
spacing = 1/(len(x)-1) * 1.0
bspline_curve = ants.fit_bspline_object_to_scattered_data(
scattered_data, parametric_data,
parametric_domain_origin=[0.0], parametric_domain_spacing=[spacing],
parametric_domain_size=[len(x)], is_parametric_dimension_closed=None,
number_of_fitting_levels=5, mesh_size=1)

# Erroneously returns all zeros.
self.assertNotEqual(bspline_curve.sum(), 0)


if __name__ == '__main__':
run_tests()

0 comments on commit b802655

Please sign in to comment.