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

Shut up the RuntimeWarnings during fitting #25

Open
jeffalstott opened this issue Jul 29, 2015 · 7 comments
Open

Shut up the RuntimeWarnings during fitting #25

jeffalstott opened this issue Jul 29, 2015 · 7 comments

Comments

@jeffalstott
Copy link
Owner

During fitting we frequently explore fits that are outside our numerical precision. This can lead to weird events like dividing by zero when we really mean to divide by a very small number. These explored fits are never taken to be good fits, and so they aren't used for the final results returned to the user. However, during the fitting we still get RuntimeWarnings when these errors occur. Like this:

import powerlaw
data = genfromtxt('blackouts.txt')
fit = powerlaw.Fit(data)
Calculating best minimal value for power law fit
/Users/jeff/powerlaw/powerlaw.py:693: RuntimeWarning: invalid value encountered in true_divide
  (Theoretical_CDF * (1 - Theoretical_CDF))

Is there a good way to stop these warnings from appearing without just making a blanket setting that we don't want to see any warnings?

@robertour
Copy link

Should I safely ignore these warnings as long as a fit is produce? Which would be the error when the package fail to produce a good fit and, then, I should discard the result? Is it possible at all that the program fail generating an appropriate fit?

I don't really mind the warning as long as there is an accompanying message indicated that the package successfully generated the fit.

@jeffalstott
Copy link
Owner Author

You can ignore the warnings as long as there's a fit. As long as the
resulting parameters don't have nans or infs, it's a valid fit.

On Wed, Oct 7, 2015 at 8:46 PM, Roberto notifications@github.com wrote:

Should I safely ignore these warnings as long as a fit is produce? Which
would be the error when the package fail to produce a good fit and, then, I
should discard the result? Is it possible at all that the program fail
generating an appropriate fit?

I don't really mind the warning as long as there is an accompanying
message indicated that the package successfully generated the fit.


Reply to this email directly or view it on GitHub
#25 (comment)
.

@robertour
Copy link

Hey, that was quick. Thanks a lot.

@albertocottica
Copy link

Hey @jeffalstott, thanks for making this. Related question: can I shut up the message:
Calculating best minimal value for power law fit?

@jeffalstott
Copy link
Owner Author

Hi @albertocottica,

I've just added an option to Fit(), verbose, that can be set to False to turn off that message and the message that data <=0 is dropped. If that works for you, I can update the package on PyPi.

@trungdong
Copy link

@jeffalstott

It would be really nice if the fix for the above is released on PyPi.

I'm running the powerlaw fittings on thousands of distributions and seeing that many "Calculating..." messages clogging the screen and drowning out all other application messages is no fun.

Thank you!

@jeffalstott
Copy link
Owner Author

@trungdong Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants