pik-copan / pyunicorn

Unified Complex Network and Recurrence Analysis Toolbox
http://pik-potsdam.de/~donges/pyunicorn/
Other
200 stars 87 forks source link

BUG: `PartialCorrelationClimateNetwork._calculate_correlation()` throws dubious divide-by-zero warning on Windows builds only #235

Open fkuehlein opened 4 months ago

fkuehlein commented 4 months ago

Warning has been showing up since Travis Windows builds were established:

tests/test_generic.py::test_init_str
C:\Users\travis\build\pik-copan\pyunicorn\src\pyunicorn\climate\partial_correlation.py:131: RuntimeWarning: divide by zero encountered in divide

    return - C_inv / norm

tests/test_generic.py::test_init_str

  C:\Users\travis\build\pik-copan\pyunicorn\src\pyunicorn\climate\partial_correlation.py:131: RuntimeWarning: invalid value encountered in divide

    return - C_inv / norm

What test_init_str() does there is basically just

from pyunicorn.climate import ClimateData, PartialCorrelationClimateNetwork

PartialCorrelationClimateNetwork(ClimateData.SmallTestData(), winter_only=False, threshold=.2)

which doesn't produce any warning on my macOS, as there are no zeros or NaNs in the denominator. This might indicate a bug on windows, a test should therefore be added to back up test_init_str() and check whether the method produces correct results on all platforms.