Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

x = np.arange(0.3, 12.5, 0.6)

print(x)

[ 0.3 0.9 1.5 2.1 2.7 3.3 3.9 4.5 5.1 5.7 6.3 6.9 7.5 8.1 8.7 9.3 9.9 10.5 11.1 11.7 12.3]

x = np.arange(0.3, 12.5, 0.6,int)

print(x)

[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
852 views
Welcome To Ask or Share your Answers For Others

1 Answer

When dtype = int is specified, it is converting the start, stop and step into the same.

So, it becomes int(start), int(stop), int(step).

Hence, in your case, when dtype = int is specified, the start and step remain 0 and you get an array full of 0s.

This problem has been discussed with explanation here:

https://github.com/numpy/numpy/issues/2457


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...