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

Error revealed by numpy 1.9.0r1 #1803

Closed
charris opened this issue Jul 4, 2014 · 8 comments

Comments

Projects
None yet
3 participants
@charris
Copy link

commented Jul 4, 2014


======================================================================
ERROR: statsmodels.emplike.tests.test_aft.Test_AFTModel.test_beta_vect
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27-x64\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\tests\test_aft.py", line 34, in test_beta_vect
    assert_almost_equal(self.res1.test_beta([3.5, -.035], [0, 1]),
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\aft_el.py", line 481, in test_beta
    llr, pval, new_weights = reg_model.el_test(b0_vals, param_nums, return_weights=True)  # Needs to be changed
  File "X:\Python27-x64\lib\site-packages\statsmodels\regression\linear_model.py", line 1519, in el_test
    stochastic_exog=stochastic_exog)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\elregress.py", line 58, in _opt_nuis_regress
    params[nuis_param_index] = nuisance_params
ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,)

======================================================================
ERROR: statsmodels.emplike.tests.test_origin.TestOrigin.test_ci_beta
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27-x64\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\tests\test_origin.py", line 35, in test_ci_beta
    ci = self.res1.conf_int_el(1)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 256, in conf_int_el
    lowerl = optimize.brentq(f, lower_bound, self.params[param_num])
  File "X:\Python27-x64\lib\site-packages\scipy\optimize\zeros.py", line 415, in brentq
    r = _zeros._brentq(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 255, in <lambda>
    stochastic_exog=stochastic_exog)[0] - r0
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 202, in el_test
    return_weights=return_weights)
  File "X:\Python27-x64\lib\site-packages\statsmodels\regression\linear_model.py", line 1519, in el_test
    stochastic_exog=stochastic_exog)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\elregress.py", line 58, in _opt_nuis_regress
    params[nuis_param_index] = nuisance_params
ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,)

======================================================================
ERROR: statsmodels.emplike.tests.test_origin.TestOrigin.test_hypothesis_beta1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27-x64\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\tests\test_origin.py", line 31, in test_hypothesis_beta1
    assert_almost_equal(self.res1.el_test([.0034],[1])[0],
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 202, in el_test
    return_weights=return_weights)
  File "X:\Python27-x64\lib\site-packages\statsmodels\regression\linear_model.py", line 1519, in el_test
    stochastic_exog=stochastic_exog)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\elregress.py", line 58, in _opt_nuis_regress
    params[nuis_param_index] = nuisance_params
ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,)

Not sure what is going on here, whether this is a mistake on the stats-models end or a deliberate use of numpy's old indexing behavior.

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Jul 4, 2014

already fixed #1754

assignment of an arbitrary array to an empty slice.

replaced essentially
arr[[]] = np.arange(5)
by arr[[]] = []

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Jul 4, 2014

it's not tested, since I haven't installed a 1.9rc

@charris

This comment has been minimized.

Copy link
Author

commented Jul 4, 2014

Ah, great. I can test it here on linux... OK, those errors are fixed, so I'll close this. There are other errors and failures in master but I don't know if any of them are new. I'll add them here just FYI.

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'f_gen')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/charris/.local/lib/python2.7/site-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/sandbox/distributions/tests/testtransf.py", line 48, in <module>
    stats.distributions.f_gen._stats = f_stats
AttributeError: 'module' object has no attribute 'f_gen'

======================================================================
FAIL: test_robust_kurtosis (statsmodels.stats.tests.test_statstools.TestStattools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/charris/.local/lib/python2.7/site-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/stats/tests/test_statstools.py", line 267, in test_robust_kurtosis
    assert_almost_equal(np.array(robust_kurtosis(x)), self.expected_kurtosis)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 473, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 839, in assert_array_almost_equal
    precision=decimal)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 663, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 7 decimals

(mismatch 25.0%)
 x: array([ 0.0606862, -0.1281954,  0.0052702,  0.0523092])
 y: array([ 0.0606862, -0.0043429,  0.0052702,  0.0523092])

======================================================================
FAIL: test_robust_kurtosis_3d (statsmodels.stats.tests.test_statstools.TestStattools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/charris/.local/lib/python2.7/site-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/stats/tests/test_statstools.py", line 273, in test_robust_kurtosis_3d
    assert_almost_equal(r * np.ones((10, 10)), kurtosis[i])
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 473, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 839, in assert_array_almost_equal
    precision=decimal)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 663, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 7 decimals

(mismatch 100.0%)
 x: array([[-0.0043429, -0.0043429, -0.0043429, -0.0043429, -0.0043429,
        -0.0043429, -0.0043429, -0.0043429, -0.0043429, -0.0043429],
       [-0.0043429, -0.0043429, -0.0043429, -0.0043429, -0.0043429,...
 y: array([[-0.1281954, -0.1281954, -0.1281954, -0.1281954, -0.1281954,
        -0.1281954, -0.1281954, -0.1281954, -0.1281954, -0.1281954],
       [-0.1281954, -0.1281954, -0.1281954, -0.1281954, -0.1281954,...

======================================================================
FAIL: test_robust_kurtosis_excess_false (statsmodels.stats.tests.test_statstools.TestStattools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/charris/.local/lib/python2.7/site-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/stats/tests/test_statstools.py", line 280, in test_robust_kurtosis_excess_false
    assert_almost_equal(expected, kurtosis)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 473, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 839, in assert_array_almost_equal
    precision=decimal)
  File "/home/charris/.local/lib/python2.7/site-packages/numpy/testing/utils.py", line 663, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 7 decimals

(mismatch 25.0%)
 x: array([ 3.0606862,  1.2287522,  2.5904973,  2.9581561])
 y: array([ 3.0606862,  1.1048997,  2.5904973,  2.9581561])

----------------------------------------------------------------------
Ran 3037 tests in 216.503s

FAILED (SKIP=23, errors=1, failures=3)

@charris charris closed this Jul 4, 2014

@josef-pkt josef-pkt reopened this Jul 4, 2014

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Jul 4, 2014

Thanks Chuck,

The first one is known, f_gen got misplaced in scipy 0.14.0, and I have an open issue.

However, I've never seen the three failures with test_robust_kurtosis.
It's relatively recent code in master, but has never failed so far. I will look at it to see if I find an obvious candidate for a bug, or changed behavior.

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Jul 5, 2014

I installed numpy 1.9.0b1 (on Windows 32bit Python 2.7), but don't get any errors or failures.

The only thing that I can see in the above failing tests for robust kurtosis is np.percentile, everything else are simple operations.

However, the tests use numpy random numbers without a seed, so we cannot exactly replicate. I will add seeds.

@charris

This comment has been minimized.

Copy link
Author

commented Jul 5, 2014

That's interesting, I just put in a PR that fixed a bug in np.partition and that would affect percentile. Let's see if it changes things... OK, I don't see any errors now apart from the one you know about. May be the random numbers chosen, maybe in combination with the bug fix.

@yarikoptic

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2014

grr... just updated packaging to avoid that precision failure on i386 and build failed due to f_gen breakage in scipy... @josef-pkt -- where have you reported it to scipy people? I do not see an issue among https://github.com/scipy/scipy/issues . Are you going to address it anyhow within statsmodels?

@yarikoptic

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2014

ok -- as you see I have filed a report above and also for now will just remove 'sandbox' from testing while building debian packages. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.