Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

scipy 0.13.0 beta 1: ERROR: test_distributions.TestFitMethod.test_fix_fit_beta #2771

Closed
WarrenWeckesser opened this Issue · 4 comments

2 participants

@WarrenWeckesser
Collaborator

Christoph Gohlke reported this test failure in scipy 0.13.0 beta 1 on the mailing list:

I built and tested scipy 0.13.0b1 on Windows 8 with Visual Studio 2008 &
2010, Intel Studio XE 2013 Fortran and MKL, Python 2.7 & 3.3 (32 & 64
bit), and numpy 1.7.1.

On 32 bit Python test_distributions.TestFitMethod.test_fix_fit_beta
fails with an error:

======================================================================
ERROR: test_distributions.TestFitMethod.test_fix_fit_beta
----------------------------------------------------------------------
Traceback (most recent call last):
   File "X:\Python33-x32\lib\site-packages\nose\case.py", line 198, in
runTest
     self.test(*self.arg)
   File
"X:\Python33-x32\lib\site-packages\scipy\stats\tests\test_distributions.py",
line 928, in test_fix_fit_beta
     assert_raises(ValueError, stats.beta.fit, x, floc=0.5, fscale=1)
   File "X:\Python33-x32\lib\site-packages\numpy\testing\utils.py", line
1019, in assert_raises
     return nose.tools.assert_raises(*args,**kwargs)
   File "X:\Python33-x32\lib\unittest\case.py", line 570, in assertRaises
     return context.handle('assertRaises', callableObj, args, kwargs)
   File "X:\Python33-x32\lib\unittest\case.py", line 135, in handle
     callable_obj(*args, **kwargs)
   File
"X:\Python33-x32\lib\site-packages\scipy\stats\distributions.py", line
2533, in fit
     raise FitSolverError(mesg=mesg)
scipy.stats.distributions.FitSolverError: Solver for the MLE equations
failed to converge: The iteration is not making good progress, as
measured by the   improvement from the last ten iterations.
@WarrenWeckesser
Collaborator

The assert_raises function where the error occurs is checking that a call to the fit method of the beta distriibution raises a ValueError when called with bad data. (The actual error that should be raised is FitDataError, which is a subclass of ValueError.) Apparently the error was not raised, and the function failed when it tried to do the MLE fit with invalid data.

@cgohlke (or anyone else with a 32 bit Windows installation of scipy 0.13.0 beta 1): what does the following do when run with the python installation where this test failed?

import numpy as np

data = np.array([-0.375, -0.25, 0.0])
s = np.log(data)
@cgohlke

I get array([ nan, nan, -inf]) on all Python platforms. On 64 bit, not on 32 bit, two RuntimeWarnings are printed during s = np.log(data):

RuntimeWarning: divide by zero encountered in log
RuntimeWarning: invalid value encountered in log

I am using numpy 1.7.1 compiled with Visual Studio compilers and Intel's MKL.

@WarrenWeckesser
Collaborator

Thanks for checking.

So it does not generate the warnings in the 32 bit environment. That's the problem. The inconsistency might be a numpy bug. I guess the fit code will have to work around it by explicitly checking that the data is in bounds, rather than catching the warnings or errors triggered by np.log.

@WarrenWeckesser
Collaborator

This issue should be fixed by #2801, but I don't have a 32 bit Windows installation on which to test it.

@WarrenWeckesser WarrenWeckesser closed this issue from a commit
@WarrenWeckesser WarrenWeckesser BUG: stats: When handling the arguments to beta_gen.fit, don't rely o…
…n np.log

to generate a warning when its argument is less than or equal to 0.
Fixes gh-2771.
f5bbbc4
@WarrenWeckesser WarrenWeckesser referenced this issue from a commit
@WarrenWeckesser WarrenWeckesser BUG: stats: When handling the arguments to beta_gen.fit, don't rely o…
…n np.log

to generate a warning when its argument is less than or equal to 0.
Fixes gh-2771.
ce3d576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.