Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explain and ignore warnings during the tests #238

Merged
merged 5 commits into from
Aug 13, 2019

Conversation

dizcza
Copy link
Member

@dizcza dizcza commented Jul 10, 2019

All these UserWarnings and RuntimeWarnings at tests always confuse me. I could not understand whether the problem was in the source code, test setup, or dependency package issues.
Before

/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: invalid value encountered in true_divide
  AngCoeff = dY / dX
./home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: divide by zero encountered in true_divide
  AngCoeff = dY / dX
/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: invalid value encountered in true_divide
  AngCoeff = dY / dX
/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: divide by zero encountered in true_divide
  AngCoeff = dY / dX
/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: invalid value encountered in true_divide
  AngCoeff = dY / dX
./home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: divide by zero encountered in true_divide
  AngCoeff = dY / dX
/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: invalid value encountered in true_divide
  AngCoeff = dY / dX
....../home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: divide by zero encountered in true_divide
  AngCoeff = dY / dX
/home/travis/build/NeuralEnsemble/elephant/elephant/asset.py:687: RuntimeWarning: invalid value encountered in true_divide
  AngCoeff = dY / dX
.................................................................../home/travis/build/NeuralEnsemble/elephant/elephant/cubic.py:110: UserWarning: Test aborted, xihat= 11 > ximax= 10
  warnings.warn('Test aborted, xihat= %i > ximax= %i' % (xi, ximax))
...........................S........................................................................................................................./home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:50: FutureWarning: the 'labels' keyword is deprecated, use 'codes' instead
  names=['test1', 'test2', 'test3'])
/home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:54: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  self.assertEqual(targ.labels, res0.labels)
./home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:2760: RuntimeWarning: invalid value encountered in less
  targ[targ < targ_start] = np.nan
/home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:2761: RuntimeWarning: invalid value encountered in greater
  targ[targ > targ_stop] = np.nan
../home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:2706: RuntimeWarning: invalid value encountered in less
  targ[targ < targ_start] = np.nan
./home/travis/build/NeuralEnsemble/elephant/elephant/test/test_pandas_bridge.py:2734: RuntimeWarning: invalid value encountered in greater
  targ[targ > targ_stop] = np.nan
......................................................./home/travis/build/NeuralEnsemble/elephant/elephant/test/test_signal_processing.py:209: RuntimeWarning: invalid value encountered in true_divide
  target = (signal.magnitude - m) / s
/home/travis/build/NeuralEnsemble/elephant/elephant/signal_processing.py:129: RuntimeWarning: invalid value encountered in true_divide
  (sig.magnitude - m.magnitude) / s.magnitude,
./home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/quantities/quantity.py:321: RuntimeWarning: divide by zero encountered in true_divide
  return np.true_divide(other, self)
../home/travis/build/NeuralEnsemble/elephant/elephant/spade.py:308: UserWarning: 0<alpha<1 but p-value spectrum has not been computed (n_surr==0)
  warnings.warn('0<alpha<1 but p-value spectrum has not been '
................................/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/quantities/quantity.py:321: RuntimeWarning: divide by zero encountered in true_divide
  return np.true_divide(other, self)
............/home/travis/build/NeuralEnsemble/elephant/elephant/spike_train_generation.py:335: RuntimeWarning: divide by zero encountered in true_divide
  mean_interval = 1 / rate.magnitude
......../home/travis/build/NeuralEnsemble/elephant/elephant/spike_train_generation.py:267: RuntimeWarning: invalid value encountered in sqrt
  number = np.ceil(n + 3 * np.sqrt(n))
............................/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/scipy/signal/spectral.py:1577: RuntimeWarning: invalid value encountered in true_divide
  Cxy = np.abs(Pxy)**2 / Pxx / Pyy
............/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/neo/core/basesignal.py:132: RuntimeWarning: invalid value encountered in true_divide
  new_signal = f(other, *args)
.........................../home/travis/build/NeuralEnsemble/elephant/elephant/statistics.py:256: UserWarning: Input size is too small. Please provide an input with more than 1 entry. lv returns 'NaN'since the argument `with_nan` is True
  warnings.warn("Input size is too small. Please provide "
......../home/travis/build/NeuralEnsemble/elephant/elephant/statistics.py:867: UserWarning: Instantaneous firing rate approximation contains negative values, possibly caused due to machine precision errors.
  warnings.warn("Instantaneous firing rate approximation contains "
........................................................../home/travis/build/NeuralEnsemble/elephant/elephant/waveform_features.py:70: UserWarning: The noise was evaluated to 0.
  warnings.warn('The noise was evaluated to 0.')
..

Now

 nosetests --cover-package=elephant
......................................................................................................S..................................................................................................................................................................................................................................................................................................................................................................................
Ran 473 tests in 275.283s

OK (SKIP=1)

Future warnings can be easily caught.

Affected changes:

  • removed handwritten _xrange wrapper
  • np.arctan(y/x) -> numerically stable np.arctan2(y, x)

@coveralls
Copy link
Collaborator

coveralls commented Jul 10, 2019

Coverage Status

Coverage decreased (-0.02%) to 75.767% when pulling 0a540f1 on INM-6:warnings into 19d3c7b on NeuralEnsemble:master.

@dizcza dizcza requested a review from mdenker July 10, 2019 13:32
@pep8speaks
Copy link

pep8speaks commented Aug 1, 2019

Hello @dizcza! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-12 12:56:51 UTC

@dizcza dizcza force-pushed the warnings branch 2 times, most recently from 18f243a to 2c49122 Compare August 1, 2019 14:39
@dizcza
Copy link
Member Author

dizcza commented Aug 2, 2019

I excluded min-requirements travis test case back because of the unrelated unittest bug error with self.assertWarn(). If it failed on the first PR we merged, I imagine, it'll be hard to maintain it anyway.

Can be checked and merged.

@mdenker mdenker added the enhancement Editing an existing module, improving something label Aug 12, 2019
Copy link
Member

@mdenker mdenker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could reproduce the warning-less unit tests running locally, looks much cleaner now. The documentation of which warnings are suppressed are very helpful!
Attached a few comments...

elephant/signal_processing.py Outdated Show resolved Hide resolved
elephant/test/test_signal_processing.py Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
neo>=0.7.1,<0.8.0
numpy>=1.10.1
quantities>=0.12.1
scipy>=0.17.0
scipy>=0.19.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the bump in the requirements required for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scipy v0.17.0 has issues in its internal functions: https://travis-ci.org/NeuralEnsemble/elephant/jobs/566510125
the next stable one is 0.19.0.
locally, all tests from 'min-requirements' case are passed. But travis throws error I cannot understand so I removed the 'min-requirements' test case. At least, if someone installs dependencies locally, it should work with 0.19.0 but definitely would not work with 0.17.0.

@mdenker mdenker merged commit caa2110 into NeuralEnsemble:master Aug 13, 2019
dizcza added a commit to INM-6/elephant that referenced this pull request Aug 13, 2019
commit caa2110
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Tue Aug 13 10:03:45 2019 +0300

    explain and ignore warnings during the tests (NeuralEnsemble#238)

    * explain and ignore warnings during the tests

    * scipy v0.18.0

    * fixed min-req tests: scipy v0.19.0

    * exclude min-requirements tests back

    * fixed division by zero

commit 19d3c7b
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Thu Aug 1 15:09:34 2019 +0200

    fixed min requirements (NeuralEnsemble#235)

    * fixed min requirements

    * travis install libopenmpi-dev

    * added .coveragerc omit=elephant/test* rule not to count test files as source code

commit 36e6096
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Wed Jul 31 16:55:47 2019 +0200

    Integrated GPFA (NeuralEnsemble#233)

    * Rename neural_trajectory to gpfa and refactor the codes accordingly

    * Remove codes related to the (not fully implemented) cross-validation feature

    * added tqdm as an extra requirement

    * push coverage only for requirements-extras test

    * gpfa verbose flag; added licence in the docs

    * Fixed and extended documentation, removed misleading function outputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Editing an existing module, improving something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants