Skip to content

Commit

Permalink
Merge pull request #1708 from arokem/fix-1698
Browse files Browse the repository at this point in the history
BF: Clip the values before passing to arccos, instead of fixing nans.
  • Loading branch information
skoudoro committed Dec 30, 2018
2 parents bbffb11 + 58393aa commit bae5b4c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions dipy/core/sphere.py
Expand Up @@ -540,9 +540,8 @@ def interp_rbf(data, sphere_origin, sphere_target,
from scipy.interpolate import Rbf

def angle(x1, x2):
xx = np.arccos((x1 * x2).sum(axis=0))
xx[np.isnan(xx)] = 0
return xx
xx = np.arccos(np.clip((x1 * x2).sum(axis=0), -1, 1))
return np.nan_to_num(xx)

def euclidean_norm(x1, x2):
return np.sqrt(((x1 - x2)**2).sum(axis=0))
Expand Down

0 comments on commit bae5b4c

Please sign in to comment.