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

Pytests fails - random seed error - mac os X 10.10.5 #10

Closed
nicofarr opened this issue Feb 5, 2017 · 6 comments
Closed

Pytests fails - random seed error - mac os X 10.10.5 #10

nicofarr opened this issue Feb 5, 2017 · 6 comments

Comments

@nicofarr
Copy link

nicofarr commented Feb 5, 2017

Installation seems to work all the way, up to :

py.test --pyargs modl

I've uploaded the logfile,

modl_tests_log.txt

Thanks

Nico

@arthurmensch
Copy link
Owner

Hi,

The package has never been tested on OS X (nor is it actually possible using any kind of free CI service) and I have no way of reproducing this. I may have an idea of the problem, I'll see what I can do.

@leodesigner
Copy link

I am getting the same errors under Ubuntu 14.04 Vagrant box.

modl/dict_fact.py:193: in fit
    self.prepare(n_samples=X.shape[0], X=dict_init)
modl/dict_fact.py:364: in prepare
    self.replacement, random_seed)
modl/utils/randomkit/sampler.pyx:33: in modl.utils.randomkit.sampler.Sampler.__cinit__ (modl/utils/randomkit/sampler.c:2072)
    self.random_state = RandomState(seed=random_seed)
modl/utils/randomkit/random_fast.pyx:55: in modl.utils.randomkit.random_fast.RandomState.__init__ (modl/utils/randomkit/random_fast.c:2528)
    self.seed(seed)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   raise ValueError("Wrong seed")
E   ValueError: Wrong seed

modl/utils/randomkit/random_fast.pyx:72: ValueError

Looks like we should merge two issues: https://github.com/arthurmensch/modl/issues/11:

@leodesigner
Copy link

leodesigner commented Feb 8, 2017

I was able to fix ValueError by adding to modl/utils/randomkit/random_fast.pyx

        elif isinstance(seed, (int, long)):
            rk_seed(seed, self.internal_state)
        else:
            raise ValueError("Wrong seed")

Due we have a long integer init value for seed in sampler.pyx

Now I am getting only:

================================================================= FAILURES ==================================================================
____________________________________________________________ test_scale_patches _____________________________________________________________

    def test_scale_patches(): 
        patch_size = (8, 8, 3)
        n = 100
        shape = (n, ) + patch_size
        rs = check_random_state(0)
        X = rs.randn(*shape) 
        Y = scale_patches(X, with_mean=True, with_std=True, channel_wise=True) 
        assert_array_almost_equal(Y.mean(axis=(1, 2)), 0) 
>       assert_array_almost_equal(np.sum(Y ** 2, axis=(1, 2)), 1 / 3)
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       (mismatch 100.0%)
E        x: array([[ 0.333333,  0.333333,  0.333333],
E              [ 0.333333,  0.333333,  0.333333],
E              [ 0.333333,  0.333333,  0.333333],...
E        y: array(0)

modl/preprocessing/tests/test_image.py:18: AssertionError
============================================== 1 failed, 51 passed, 4 skipped in 2.15 seconds ===============================================

Any ideas how to deal with this ? Or just ignore it ?

@arthurmensch
Copy link
Owner

Can you try it again on master ? Thanks !

@dohmatob
Copy link
Collaborator

dohmatob commented Jun 2, 2017

@nicofarr are you using python 2xx or python 3xx. The code only works for py3 AFAIK.

@nicofarr
Copy link
Author

nicofarr commented Jul 11, 2017 via email

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

No branches or pull requests

4 participants