0

I couldn't remember if np.zeros(x) will automatically covert a float x to int or not, so I tried it in IDLE. What I got the first time was a Warning message that refers to the script I had run earlier in the same session, and then warns me "using a non-integer number instead of an integer will result in an error in the future".

I tried it again, and the warning did not repeat, and the array was instantiated as expected with dtype=float.

Why does the warning say there will be an error (as opposed to could be), and what will it be? And why did it refer to the first non-blank line in the script I'd run much earlier today get embedded into the warning?

This may be a window into how IDLE is working - so I'm hoping to learn something from this. I've read here that I can suppress the warning, but I would like to understand it's behavior first.

>>> 
>>> 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.])
>>> 
Community
  • 1
  • 1
uhoh
  • 3,713
  • 6
  • 42
  • 95
  • The IDLE Shell just wraps Python and has nothing to do with the warning from the numpy or scipy packages. You should see the same message, perhaps with a slightly different formatting, if you run the same code directly with Python or in any IDE that does not suppress the warning. – Terry Jan Reedy Dec 25 '16 at 17:53
  • The array should have been instantiated the first time you ran the line. A warning should not prevent execution. – Terry Jan Reedy Dec 25 '16 at 17:54
  • 1
    I see now that you asked a second subquestion, about the line reference. That might be an IDLE specific bug. What specific 2.7.z bugfix release are you runnning? – Terry Jan Reedy Dec 25 '16 at 18:00
  • @TerryJanReedy I should have included that in the question. I installed around April 2016. When I start IDLE it shows `Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin`. Laptop is running OSX 10.11.6. I've just now taken a look and it seems 2.11.13 is now available. Recently I've also had IDLE lock up or crash roughly once per week when I'm using it heavily and I've never really had that happen before. I also haven't heeded the warning about `Tcl/Tk (8.5.9)` It may be time to do some updating here and there. Thanks! – uhoh Dec 26 '16 at 02:05

1 Answers1

2

"In the future" means "in a future version of NumPy". So far you get a warning, not an error. The assignment was made (you didn't need to run the command the second time, equator was already assigned as you wanted) and execution proceeded normally.

But some future version of NumPy will throw an error, halting the execution.

The warning is not repeated again within the same session; there's some logic there intended to avoid nagging the user too much.

I can't explain the line reference; for me it refers to __main__:1:.

  • OK thank you for the explanation - makes sense, I think I have seen IDLE do this once or twice - incorporate some information in warnings or errors that don't seem to apply. Doesn't seem to be something to worry about. – uhoh Dec 24 '16 at 03:59