question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"RuntimeWarning: invalid value encountered in true_divide" in tests

See original GitHub issue

The following tests throw a RuntimeWarning

RuntimeWarning: invalid value encountered in true_divide

in the current development version

  • test_sanity_check_pls_regression_constant_column_Y in sklearn/cross_decomposition/tests/test_pls.py
  • test_iforest_with_uniform_data in sklearn/ensemble/tests/test_iforest.py
  • test_kernel_gradient in sklearn/gaussian_process/tests/test_kernels.py
  • test_radius_neighbors_classifier_zero_distance in sklearn/neighbors/tests/test_neighbors.py
  • test_calibration_multiclass[0-True-isotonic] in sklearn/tests/test_calibration.py
  • test_estimators[LinearDiscriminantAnalysis()-check_classifiers_one_label] in sklearn/tests/test_common.py
  • test_random_choice_csc in sklearn/utils/tests/test_random.py

Those warnings are caused by matricial divisions having some element equal to zero in the denominator, either in the test itself or in the function/class called by the test.

The failure can be reproduced locally using

pytest -Werror::RuntimeWarning <test_file.py> -k <test_name>

cc @ogrisel, @reshamas

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
lorentzenchrcommented, Mar 16, 2021

The list is complete. Thank you all for your contributions.

1reaction
mbatoulcommented, Mar 16, 2021

@lorentzenchr I am still trying to figure out the right way to solve this issue, but I can surely open a PR right now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix: invalid value encountered in true_divide - Statology
This warning occurs when you attempt to divide by some invalid value (such as NaN, Inf, etc.) in a NumPy array. It's worth...
Read more >
RuntimeWarning: invalid value encountered in divide
You have nan s for rr , which is throwing that error. The issue with rr is stemming from r[i,:] which is equal,...
Read more >
NumPy Fix: Invalid Value Encountered in true_divide
In this quick breakdown, we'll look at such a case where NumPy might produce a runtime warning indicating that an invalid value was...
Read more >
invalid value encountered in true_divide return n/db/n.sum ...
[Solved]-Python RuntimeWarning: invalid value encountered in true_divide return n/db/n.sum(), bin_edges-numpy.
Read more >
Debian Bug report logs - #997081 statsmodels: FTBFS: tests fail
self = <statsmodels.imputation.tests.test_mice. ... RuntimeWarning: invalid value encountered in true_divide > B_x = (G_numer * d_fx ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found