8000 Doctest failure for PowerTransformer on mac? · Issue #12584 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Doctest failure for PowerTransformer on mac? #12584

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
jnothman opened this issue Nov 14, 2018 · 7 comments
Closed

Doctest failure for PowerTransformer on mac? #12584

jnothman opened this issue Nov 14, 2018 · 7 comments

Comments

@jnothman
Copy link
Member

Subsequent to #12522 it seems I get the following test failure when running on my own machine. @NicolasHug is this level of imprecision surprising?

____________________________________ [doctest] sklearn.preprocessing.data.PowerTransformer ____________________________________
2521
2522     Examples
2523     --------
2524     >>> import numpy as np
2525     >>> from sklearn.preprocessing import PowerTransformer
2526     >>> pt = PowerTransformer()
2527     >>> data = [[1, 2], [3, 2], [4, 5]]
2528     >>> print(pt.fit(data))
2529     PowerTransformer(copy=True, method='yeo-johnson', standardize=True)
2530     >>> print(pt.lambdas_)
Expected:
    [ 1.38668178 -3.10053309]
Got:
    [ 1.38668178 -3.10053332]

show_versions


System:
    python: 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12)  [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]
   machine: Darwin-17.7.0-x86_64-i386-64bit
executable: /Users/joel/anaconda3/envs/scipy3k/bin/python

BLAS:
cblas_libs: mkl_rt, pthread
  lib_dirs: /Users/joel/anaconda3/envs/scipy3k/lib
    macros: SCIPY_MKL_H=None, HAVE_CBLAS=None

Python deps:
    pandas: 0.23.4
       pip: 18.0
   sklearn: 0.20.1 # at 19c3008
setuptools: 37.0.0
    Cython: 0.28.5
     scipy: 1.0.0
     numpy: 1.14.1
@qinhanmin2014
Copy link
Member

I can reproduce on Windows 10, so seems that it's not trivial.

System:
    python: 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]
executable: D:\ProgramData\Anaconda3\python.exe
   machine: Windows-10-10.0.16299-SP0

BLAS:
    macros: SCIPY_MKL_H=None, HAVE_CBLAS=None
  lib_dirs: D:\ProgramData\Anaconda3\Library\lib
cblas_libs: mkl_rt

Python deps:
       pip: 18.1
setuptools: 40.5.0
   sklearn: 0.21.dev0
     numpy: 1.15.4
     scipy: 1.1.0
    Cython: 0.26.1
    pandas: 0.23.4
8000

@qinhanmin2014
Copy link
Member

Maybe we should also run doctests on Appveyor.

@qinhanmin2014 qinhanmin2014 added this to the 0.20.1 milestone Nov 14, 2018
@ogrisel
Copy link
Member
ogrisel commented Nov 15, 2018

Maybe we should also run doctests on Appveyor.

I believe we cannot easily run the doctests on windows because of difference in the way the numpy array dtypes are displayed on windows and reworking the doctests to make them platform agnostic would be too tedious and hurt readability of the documentation.

I think we should consider that the goal of the doctests is only to test that the examples in the documentation are up to date with the code.

Checking that the code runs correctly on all platform should be the responsibility of the regular test suite.

@ogrisel
Copy link
Member
ogrisel commented Nov 15, 2018

Back to the original issue, a small change on one of the values of the second feature can impact lambda significantly. On my Linux machine where the doctest pass, I observe the following:

>>> PowerTransformer().fit([[1, 2], [3, 2], [4, 5]]).lambdas_
array([ 1.38668178, -3.10053309])
>>> PowerTransformer().fit([[1, 2], [3, 2], [4, 5 + 1e-15]]).lambdas_
array([ 1.38668178, -3.10053336])

So I believe this doctest should use an ellipsis.

@qinhanmin2014
Copy link
Member

I believe we cannot easily run the doctests on windows because of difference in the way the numpy array dtypes are displayed on windows and reworking the doctests.

You're right, though I need some time to figure out the differences across different platforms.
I ran all the doctests on my Windows and there's only one result mismatch (i.e., this PR).

@ogrisel
Copy link
Member
ogrisel commented Nov 15, 2018

and reworking the doctests ...

I edited my previous comment because I had not completed my sentence...

@ogrisel
Copy link
Member
ogrisel commented Nov 15, 2018

I pushed a fix in #12595.

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

3 participants
0