Why did Python give me this strange warning about visible danger? Find out something here?

I could not remember if np.zeros(x) automatically hide float x to int or not, so I tried it in IDLE. The first thing I got was a “Warning” message, which refers to a script that I used earlier in the same session, and then warns me “using a non-integer instead of an integer will lead to an error in the future”.

I tried again and the warning did not repeat, and the array was created as expected using dtype=float .

Why does the warning say that there will be an error (as opposed to what may be), and what will it be? And why did he refer to the first non-empty line in the script that I would run much earlier, insert it into the warning today?

It may be the window that IDLE is running in, so I hope to learn some of this. I read here that I can suppress the warning, but first I would like to understand its behavior.

 >>> >>> equator = np.zeros(3.14) Warning (from warnings module): File "/Users/xxxxxx/Documents/xxxxxx/CYGNSS/CYGNSS TLE interpolator v00.py", line 2 CYGNSS_BLOB = """1 41884U 16078A 16350.61686218 -.00000033 00000-0 00000+0 0 9996 VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future >>> >>> equator = np.zeros(3.14) >>> equator array([ 0., 0., 0.]) >>> 
0
source share
1 answer

"In the future" means "in a future version of NumPy." So far you get a warning, not an error. The assignment was completed (you did not need to run the command a second time, the equator already assigned at your request), and the execution continued normally.

But some future version of NumPy throws an error, stopping execution.

The warning does not repeat again in one session; there was some kind of logic to avoid too much.

I can not explain the link to the string; for me this applies to __main__:1:

+2
source

All Articles