You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have found that when I make the following call using apply_along_axis and return an int rather than a float, the field with the incorrect type is cast to the right type and put into the array properly, but the value of the subsequent field is set to zero:
def f0(m,l,val):
return np.apply_along_axis(f1,0,m,m,l,val)
def f1(v,m,l,val):
return np.apply_along_axis(f2,0,m,v,l,val)
def f2(v1,v2,l,val):
l[0] += 1
if l[0] <= 2:
return 1.
if l[0] == 3:
return val
if l[0] == 4:
return .34151
print f0(np.array(np.ones((1,2))),list([0]),0) <-- int
print f0(np.array(np.ones((1,2))),list([0]),0.) <-- float
print f0(np.array(np.ones((1,2))),list([0]),1) <-- int
print f0(np.array(np.ones((1,2))),list([0]),1.) <-- float
print type(f0(np.array(np.ones((1,2))),list([0]),1)[0][1])
print numpy.__version__
output:
[[ 1. 0.] <-- correctly zero
[ 1. 0.]] <-- value dropped
[[ 1. 0. ] <-- correctly zero
[ 1. 0.34151]] <-- value correct
[[ 1. 1.] <-- correctly 1
[ 1. 0.]] <-- value dropped
[[ 1. 1. ] <-- correctly 1
[ 1. 0.34151]] <-- value correct
<type 'numpy.float64'> <-- type is float64, this was correctly cast
1.8.2 <-- numpy version
apply_along_axis looks at the return type of the first function call, and then casts all future calls to that same type. This is basically the same issue as #8352
Hello,
I have found that when I make the following call using apply_along_axis and return an int rather than a float, the field with the incorrect type is cast to the right type and put into the array properly, but the value of the subsequent field is set to zero:
discovered with @asna1005
The text was updated successfully, but these errors were encountered: