Join GitHub today
Fixes #931 : checks if nb_points=0 #932
Thanks for the fix,
Hmm. reading the code I realised that nb_points needs to be 2 or greater. If nb_points is 1, you'll end up with a division by zero!
Do you mind changing the test condition to include such case? And while at it, changing the error message accordingly and adding a new unit test.
Test error if I check nb_points < 2 using :
if nb_points < 2: raise ValueError("nb_points should be greater than or equal to 2")
The error is happening because of this :
for nb_points in [1, 5, 2*max_points]: for feature in [dipymetric.ResampleFeature(nb_points), ResampleFeature(nb_points)]: for s in [s1, s2, s3, s4]: # Test method infer_shape assert_equal(feature.infer_shape(s), (nb_points, s.shape)) # Test method extract features = feature.extract(s) assert_equal(features.shape, (nb_points, s.shape)) assert_array_almost_equal(features, set_number_of_points(s, nb_points))
Any idea why nb_points is 1 here ?
I have changed it and all test cases are passing. Please have a look.
Non-negative integers (<2) are then taken care of. For points like 2.3, numpy gives a warning. Instead of casting nb_points to an integer why not let numpy raise the error? If the user has made a mistake which is making the nb_points non integer then he should know of it right ?