Discussion:
[Numpy-discussion] annoying Deprecation warnings about non-integers
j***@gmail.com
2015-07-01 03:58:12 UTC
Permalink
I'm trying to fix some code in statsmodels that creates Deprecation
Warnings from numpy

Most of it are quite easy to fix, mainly cases where we use floats to avoid
integer division

I have two problems

first, I get Deprecation warnings in the test run that don't specify where
they happen.
I try to find them with file searches, but I don't see a `np.ones` that
might cause a problem
(needle in a haystack: Close to 4000 unittests and more than 100,000 lines
of numpython)
Also, I'm not sure the warnings are only from statsmodels, they could be in
numpy, scipy or pandas, couldn't they?


second, what's wrong with non-integers in `np.r_[[np.nan] * head, x,
[np.nan] * tail]` (see below)

I tried to set the warnings filter to `error` but then Python itself
errored right away.

https://travis-ci.org/statsmodels/statsmodels/jobs/68748936
https://github.com/statsmodels/statsmodels/issues/2480


Thanks for any clues

Josef
nosetests -s --pdb-failures --pdb
"M:\j\statsmodels\statsmodels_py34\statsmodels\tsa\tests"

..................C:\WinPython-64bit-3.4.3.1\python-3.4.3.amd64\lib\sit
e-packages\numpy\core\numeric.py:183: DeprecationWarning: using a
non-integer nu
mber instead of an integer will result in an error in the future
a = empty(shape, dtype, order)
..........


.......M:\j\statsmodels\stat
smodels_py34\statsmodels\tsa\filters\filtertools.py:28: DeprecationWarning:
usin
g a non-integer number instead of an integer will result in an error in the
futu
re
return np.r_[[np.nan] * head, x, [np.nan] * tail]
..........................


...................C:\WinPython-64bit-3.4.3.1
\python-3.4.3.amd64\lib\site-packages\numpy\lib\twodim_base.py:231:
DeprecationW
arning: using a non-integer number instead of an integer will result in an
error
in the future
m = zeros((N, M), dtype=dtype)
C:\WinPython-64bit-3.4.3.1\python-3.4.3.amd64\lib\site-packages\numpy\l
ib\twodim_base.py:238: DeprecationWarning: using a non-integer number
instead of
an integer will result in an error in the future
m[:M-k].flat[i::M+1] = 1
...........
Nathaniel Smith
2015-07-01 04:15:28 UTC
Permalink
Post by j***@gmail.com
I'm trying to fix some code in statsmodels that creates Deprecation
Warnings from numpy
Post by j***@gmail.com
Most of it are quite easy to fix, mainly cases where we use floats to
avoid integer division
Post by j***@gmail.com
I have two problems
first, I get Deprecation warnings in the test run that don't specify
where they happen.
Post by j***@gmail.com
I try to find them with file searches, but I don't see a `np.ones` that
might cause a problem
Post by j***@gmail.com
(needle in a haystack: Close to 4000 unittests and more than 100,000
lines of numpython)
Post by j***@gmail.com
Also, I'm not sure the warnings are only from statsmodels, they could be
in numpy, scipy or pandas, couldn't they?
Post by j***@gmail.com
second, what's wrong with non-integers in `np.r_[[np.nan] * head, x,
[np.nan] * tail]` (see below)
Post by j***@gmail.com
I tried to set the warnings filter to `error` but then Python itself
errored right away.

I'd try using a more targeted error filter. Python trends to spit out a
bunch of ImportWarnings on startup. You can make a warnings filter that
does "error" but only for DeprecationWarning. Or only for
DeprecationWarning matching the regexp "non-integer".

-n

Loading...