Skip to content

Commit

Permalink
Merge branch 'linking_arrayfuncs'
Browse files Browse the repository at this point in the history
Conflicts:
	setup.py
	sklearn/__init__.py
  • Loading branch information
GaelVaroquaux committed Jul 26, 2012
2 parents 066108e + 9457f0c commit b5519f0
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 68 deletions.
16 changes: 15 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
import os
import shutil

if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins

# This is a bit (!) hackish: we are setting a global variable so that the main
# sklearn __init__ can detect if it is being loaded by the setup routine, to
# avoid attempting to load components that aren't built yet.
builtins.__SKLEARN_SETUP__ = True

DISTNAME = 'scikit-learn'
DESCRIPTION = 'A set of python modules for machine learning and data mining'
LONG_DESCRIPTION = open('README.rst').read()
Expand All @@ -17,7 +27,11 @@
URL = 'http://scikit-learn.sourceforge.net'
LICENSE = 'new BSD'
DOWNLOAD_URL = 'http://sourceforge.net/projects/scikit-learn/files/'
VERSION = '0.12-git'

# We can actually import a restricted version of sklearn that
# does not need the compiled code
import sklearn
VERSION = sklearn.__version__

from numpy.distutils.core import setup

Expand Down
88 changes: 50 additions & 38 deletions sklearn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,63 @@
See http://scikit-learn.sourceforge.net for complete documentation.
"""

from . import __check_build
from .base import clone

import sys
__version__ = '0.12-git'

try:
from numpy.testing import nosetester

class _NoseTester(nosetester.NoseTester):
""" Subclass numpy's NoseTester to add doctests by default
"""

def test(self, label='fast', verbose=1, extra_argv=['--exe'],
doctests=True, coverage=False):
"""Run the full test suite
Examples
--------
This will run the test suite and stop at the first failing
example
>>> from sklearn import test
>>> test(extra_argv=['--exe', '-sx']) #doctest: +SKIP
"""
return super(_NoseTester, self).test(label=label, verbose=verbose,
extra_argv=extra_argv,
doctests=doctests, coverage=coverage)
# This variable is injected in the __builtins__ by the build
# process. It used to enable importing subpackages of sklearn when
# the binaries are not built
__SKLEARN_SETUP__
except NameError:
__SKLEARN_SETUP__ = False

if __SKLEARN_SETUP__:
sys.stderr.write('Partial import of sklearn during the build process.\n')
# We are not importing the rest of the scikit during the build
# process, as it may not be compiled yet
else:
from . import __check_build
from .base import clone

try:
test = _NoseTester(raise_warnings="release").test
except TypeError:
# Older versions of numpy do not have a raise_warnings argument
test = _NoseTester().test
del nosetester
except:
pass
from numpy.testing import nosetester

class _NoseTester(nosetester.NoseTester):
""" Subclass numpy's NoseTester to add doctests by default
"""

__all__ = ['cross_validation', 'cluster', 'covariance',
'datasets', 'decomposition', 'feature_extraction',
'feature_selection', 'semi_supervised',
'gaussian_process', 'grid_search', 'hmm', 'lda', 'linear_model',
'metrics', 'mixture', 'naive_bayes', 'neighbors', 'pipeline',
'preprocessing', 'qda', 'svm', 'test', 'clone', 'pls']
def test(self, label='fast', verbose=1, extra_argv=['--exe'],
doctests=True, coverage=False):
"""Run the full test suite
Examples
--------
This will run the test suite and stop at the first failing
example
>>> from sklearn import test
>>> test(extra_argv=['--exe', '-sx']) #doctest: +SKIP
"""
return super(_NoseTester, self).test(label=label, verbose=verbose,
extra_argv=extra_argv,
doctests=doctests, coverage=coverage)

try:
test = _NoseTester(raise_warnings="release").test
except TypeError:
# Older versions of numpy do not have a raise_warnings argument
test = _NoseTester().test
del nosetester
except:
pass

__all__ = ['cross_validation', 'cluster', 'covariance',
'datasets', 'decomposition', 'feature_extraction',
'feature_selection', 'semi_supervised',
'gaussian_process', 'grid_search', 'hmm', 'lda', 'linear_model',
'metrics', 'mixture', 'naive_bayes', 'neighbors', 'pipeline',
'preprocessing', 'qda', 'svm', 'test', 'clone', 'pls']

__version__ = '0.12-git'

def setup_module(module):
"""Fixture for the tests to assure globally controllable seeding of RNGs
Expand Down
31 changes: 31 additions & 0 deletions sklearn/_build_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Utilities useful during the build.
"""
# author: Andy Mueller, Gael Varoquaux
# license: BSD

from numpy.distutils.system_info import get_info

def get_blas_info():

def atlas_not_found(blas_info_):
def_macros = blas_info.get('define_macros', [])
for x in def_macros:
if x[0] == "NO_ATLAS_INFO":
# if x[1] != 1 we should have lapack
# how do we do that now?
return True
if x[0] == "ATLAS_INFO":
if "None" in x[1]:
# this one turned up on FreeBSD
return True
return False

blas_info = get_info('blas_opt', 0)
if (not blas_info) or atlas_not_found(blas_info):
cblas_libs = ['cblas']
blas_info.pop('libraries', None)
else:
cblas_libs = blas_info.pop('libraries', [])

return cblas_libs, blas_info
13 changes: 4 additions & 9 deletions sklearn/cluster/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@

import numpy

from sklearn._build_utils import get_blas_info

def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info

blas_info = get_info('blas_opt', 0)
if (not blas_info) or (
('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', [])):
cblas_libs = ['cblas']
blas_info.pop('libraries', None)
else:
cblas_libs = blas_info.pop('libraries', [])

cblas_libs, blas_info = get_blas_info()

libraries = []
if os.name == 'posix':
cblas_libs.append('m')
Expand Down
13 changes: 4 additions & 9 deletions sklearn/linear_model/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@

import numpy

from sklearn._build_utils import get_blas_info

def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info

config = Configuration('linear_model', parent_package, top_path)

# cd fast needs CBLAS
blas_info = get_info('blas_opt', 0)
if (not blas_info) or (
('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', [])):
cblas_libs = ['cblas']
blas_info.pop('libraries', None)
else:
cblas_libs = blas_info.pop('libraries', [])
cblas_libs, blas_info = get_blas_info()

libraries = []
if os.name == 'posix':
cblas_libs.append('m')
Expand Down
13 changes: 2 additions & 11 deletions sklearn/utils/setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import os
from os.path import join

from numpy.distutils.system_info import get_info

from sklearn._build_utils import get_blas_info

def configuration(parent_package='', top_path=None):
import numpy
from numpy.distutils.misc_util import Configuration

config = Configuration('utils', parent_package, top_path)

config.add_subpackage('sparsetools')

# cd fast needs CBLAS
blas_info = get_info('blas_opt', 0)
if (not blas_info) or (
('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', [])):
cblas_libs = ['cblas']
blas_info.pop('libraries', None)
else:
cblas_libs = blas_info.pop('libraries', [])
cblas_libs, blas_info = get_blas_info()

libraries = []
if os.name == 'posix':
Expand Down

0 comments on commit b5519f0

Please sign in to comment.