Skip to content

Commit 4e289b1

Browse files
committed
BF - inplace division raising error for new numpy
The ufunc casting rules recently changed to disallow in-place operations that change the array types. Here integer input becomes float output after dividing by the square root.
1 parent 57099b6 commit 4e289b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nibabel/quaternions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ def angle_axis2quat(theta, vector, is_normalized=False):
392392
'''
393393
vector = np.array(vector)
394394
if not is_normalized:
395-
vector /= math.sqrt(np.dot(vector, vector))
395+
# Cannot divide in-place because input vector may be integer type,
396+
# whereas output will be float type; this may raise an error in versions
397+
# of numpy > 1.6.1
398+
vector = vector / math.sqrt(np.dot(vector, vector))
396399
t2 = theta / 2.0
397400
st2 = math.sin(t2)
398401
return np.concatenate(([math.cos(t2)],

0 commit comments

Comments
 (0)