Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Scikit-learn 0.21.1 strange failure using nosetests with import train_test_split #13943

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

Closed
trevorstephens opened this issue May 25, 2019 · 6 comments · Fixed by #13951
Closed

Comments

@trevorstephens
Copy link
Contributor

Description

Hey there, I run a simple test suite using nose over my package gplearn and the CRON scheduled tests came up with a failure today. I narrowed the test scopes and removed the test that used that function in a dummy PR on my package and it appears simply importing test_train_split in the test code causes a failure. This only occurs with nosetests, pytest shows no failures locally, while pytest passes cleanly locally. My local configuration is linux, built from source. My travis config is all on pre-built conda packages.

This issue does not occur when running things as code, only through nosetest that I can tell. Tests using test_train_split pass just fine, but then a new "test" appears automagically that fails right after the test file has completed all other tests in the file.

The reason this is happening is a bit of a mystery to me, I don't think I'm doing anything unusual in my test configuration. #13483 appears to be the only recent PR to touch this code. I don't see any reason why that should produce these results though.

See here for the failures which only occur on 0.21.1: https://travis-ci.org/trevorstephens/gplearn/builds/537063072 which is running trevorstephens/gplearn#167

Steps/Code to Reproduce

from sklearn.model_selection import train_test_split

def test_unrelated_fail():

    return None

nosetest -v -s test.py

Expected Results

No error is thrown due to simply importing test_train_split

Actual Results

======================================================================
ERROR: Split arrays or matrices into random train and test subsets
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/trev/.virtualenvs/ve3/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/trev/.virtualenvs/ve3/lib/python3.6/site-packages/nose/util.py", line 620, in newfunc
    return func(*arg, **kw)
  File "/bigdrive/git/scikit-learn/sklearn/model_selection/_split.py", line 2086, in train_test_split
    raise ValueError("At least one array required as input")
ValueError: At least one array required as input

----------------------------------------------------------------------

Versions

Seems to only affect 0.21.1 on both python 3.6, 3.7

@jnothman
Copy link
Member

jnothman commented May 25, 2019 via email

@trevorstephens
Copy link
Contributor Author

Never heard of bisect @jnothman ... Fast way to find a bug, thanks!

41aa3ed is the offending commit from #12974 on my local machine (linux python 3.6)

@trevorstephens
Copy link
Contributor Author

Unfortunately the discussion is quite brief so I don't know what the context of its removal was

@trevorstephens
Copy link
Contributor Author

Looks like it was removed in #9840, then re-introduced with #10223... 😱

@jnothman
Copy link
Member

Whoops. Thanks for pointing it out. I made a PR.

@trevorstephens
Copy link
Contributor Author

NP. I just migrated my package to pytest today as a result of this. Nose, I guess, was just picking up on the word test in the function name, maybe? So for me, the issue is gone, but I assume lots of packages rely on test_train_split in tests and may still use nose. Could be a bunch of failures popping up around the ecosystem. I guess there needs to be a point where old frameworks need to retire though. Could be the push we all need?

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

Successfully merging a pull request may close this issue.

2 participants