Skip to content

Commit f15e0c0

Browse files
committed
np.norm has axis kw only >1.9
1 parent d06f76a commit f15e0c0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

nipype/algorithms/mesh.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
import numpy as np
16-
from numpy.linalg import norm
16+
from numpy import linalg as nla
1717
import os.path as op
1818
from nipype.external import six
1919

@@ -83,7 +83,7 @@ def _triangle_area(self, A, B, C):
8383
A = np.array(A)
8484
B = np.array(B)
8585
C = np.array(C)
86-
ABxAC = norm(A - B) * norm(A - C)
86+
ABxAC = nla.norm(A - B) * nla.norm(A - C)
8787
prod = np.dot(B - A, C - A)
8888
angle = np.arccos(prod / ABxAC)
8989
area = 0.5 * ABxAC * np.sin(angle)
@@ -119,7 +119,12 @@ def _run_interface(self, runtime):
119119
diff = points2 - points1
120120
weights = np.ones(len(diff))
121121

122-
errvector = norm(diff, axis=1)
122+
try:
123+
errvector = nla.norm(diff, axis=1)
124+
except TypeError: # numpy < 1.9
125+
errvector = np.apply_along_axis(nla.norm, 1, diff)
126+
pass
127+
123128
if self.inputs.metric == 'sqeuclidean':
124129
errvector = errvector ** 2
125130

0 commit comments

Comments
 (0)