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
closes#13109closes#13135
The precise strategy to be taken here is open for
discussion. I tried to be reasonably fine-grained rather than slap a
generic decorator over everything because it's easier to go that
direction than the reverse. The `errstate()` blocks in the tests were
added *after* fixing all of the library code. Unfortunately, these are
less fine-grained than I would like because some of the tests have
many lines of the form `assert_array_equal(pandas_expression_to_test,
expected_raw_numpy_expression)` where `expected_raw_numpy_expression`
is what is triggering the warning. It was tedious to try to rewrite
all of that to wrap just `expected_raw_numpy_expression`. I think I
got everything exercised by the test suite except for parts of the
test suite that are skipped on my machine due to dependencies. We'll
see how things go in the CI. I haven't added any new tests yet.
Could do if requested.
Author: Robert Kern <[email protected]>
Author: Robert Kern <[email protected]>
Closes#13145 from rkern/fix/errstate and squashes the following commits:
ef9c001 [Robert Kern] BUG: whoops, wrong function.
7fd2e86 [Robert Kern] ENH: More whatsnew documentation.
44805db [Robert Kern] ENH: Rearrange expression to avoid generating a warning that would need to be silenced.
1fe1bc2 [Robert Kern] pep8
bf1f662 [Robert Kern] BUG: New fixes after master rebase.
e7adc03 [Robert Kern] BUG: wrong function.
a59cfa7 [Robert Kern] ENH: Avoiding the bounds error is better than silencing the warning.
0e1ea81 [Robert Kern] BUG: A few more stragglers.
863ac93 [Robert Kern] TST: Add a new test to ensure that boolean comparisons are errstate-protected.
6932851 [Robert Kern] TST: Basic check that the global errstate remains unchanged.
c9df7b3 [Robert Kern] BUG: removed debugging print
3b12f08 [Robert Kern] ENH: Silence numpy warnings from certain expressions computed during tests.
eca512c [Robert Kern] BUG: Handle NaT explicitly.
6fbc9ce [Robert Kern] BUG: First pass at fine-grained errstate.
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.19.0.txt
+13
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@ This is a major release from 0.18.1 and includes a small number of API changes,
7
7
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
8
8
users upgrade to this version.
9
9
10
+
.. warning::
11
+
12
+
pandas >= 0.19.0 will no longer silence numpy ufunc warnings upon import, see :ref:`here <whatsnew_0190.errstate>`. (:issue:`13109`, :issue:`13145`)
13
+
10
14
Highlights include:
11
15
12
16
- :func:`merge_asof` for asof-style time-series joining, see :ref:`here <whatsnew_0190.enhancements.asof_merge>`
@@ -357,6 +361,15 @@ Google BigQuery Enhancements
357
361
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
358
362
- The :func:`pandas.io.gbq.read_gbq` method has gained the ``dialect`` argument to allow users to specify whether to use BigQuery's legacy SQL or BigQuery's standard SQL. See the :ref:`docs <io.bigquery_reader>` for more details (:issue:`13615`).
359
363
364
+
.. _whatsnew_0190.errstate:
365
+
366
+
Fine-grained numpy errstate
367
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
368
+
369
+
Previous versions of pandas would permanently silence numpy's ufunc error handling when ``pandas`` was imported (:issue:`13109`). Pandas did this in order to silence the warnings that would arise from using numpy ufuncs on missing data, which are usually represented as NaNs. Unfortunately, this silenced legitimate warnings arising in non-pandas code in the application. Starting with 0.19.0, pandas will use the ``numpy.errstate`` context manager to silence these warnings in a more fine-grained manner only around where these operations are actually used in the pandas codebase.
370
+
371
+
After upgrading pandas, you may see "new" ``RuntimeWarnings`` being issued from your code. These are likely legitimate, and the underlying cause likely existed in the code when using previous versions of pandas that simply silenced the warning. Use `numpy.errstate <http://docs.scipy.org/doc/numpy/reference/generated/numpy.errstate.html>`__ around the source of the ``RuntimeWarning`` to control how these conditions are handled.
0 commit comments