@@ -304,14 +304,6 @@ def _skip_if_no_scipy():
304
304
pytest .skip ('scipy.sparse missing' )
305
305
306
306
307
- def _skip_if_scipy_0_17 ():
308
- import scipy
309
- v = scipy .__version__
310
- if v >= LooseVersion ("0.17.0" ):
311
- import pytest
312
- pytest .skip ("scipy 0.17" )
313
-
314
-
315
307
def _check_if_lzma ():
316
308
try :
317
309
return compat .import_lzma ()
@@ -2020,15 +2012,18 @@ def __init__(self, *args, **kwargs):
2020
2012
2021
2013
# Dependency checks. Copied this from Nipy/Nipype (Copyright of
2022
2014
# respective developers, license: BSD-3)
2023
- def package_check (pkg_name , version = None , app = 'pandas' , checker = LooseVersion ):
2024
- """Check that the minimal version of the required package is installed.
2015
+ def package_check (pkg_name , min_version = None , max_version = None , app = 'pandas' ,
2016
+ checker = LooseVersion ):
2017
+ """Check that the min/max version of the required package is installed.
2025
2018
2026
2019
Parameters
2027
2020
----------
2028
2021
pkg_name : string
2029
2022
Name of the required package.
2030
- version : string, optional
2023
+ min_version : string, optional
2031
2024
Minimal version number for required package.
2025
+ max_version : string, optional
2026
+ Max version number for required package.
2032
2027
app : string, optional
2033
2028
Application that is performing the check. For instance, the
2034
2029
name of the tutorial being executed that depends on specific
@@ -2040,7 +2035,6 @@ def package_check(pkg_name, version=None, app='pandas', checker=LooseVersion):
2040
2035
Examples
2041
2036
--------
2042
2037
package_check('numpy', '1.3')
2043
- package_check('networkx', '1.0', 'tutorial1')
2044
2038
2045
2039
"""
2046
2040
@@ -2049,8 +2043,10 @@ def package_check(pkg_name, version=None, app='pandas', checker=LooseVersion):
2049
2043
msg = '%s requires %s' % (app , pkg_name )
2050
2044
else :
2051
2045
msg = 'module requires %s' % pkg_name
2052
- if version :
2053
- msg += ' with version >= %s' % (version ,)
2046
+ if min_version :
2047
+ msg += ' with version >= %s' % (min_version ,)
2048
+ if max_version :
2049
+ msg += ' with version < %s' % (max_version ,)
2054
2050
try :
2055
2051
mod = __import__ (pkg_name )
2056
2052
except ImportError :
@@ -2059,7 +2055,9 @@ def package_check(pkg_name, version=None, app='pandas', checker=LooseVersion):
2059
2055
have_version = mod .__version__
2060
2056
except AttributeError :
2061
2057
pytest .skip ('Cannot find version for %s' % pkg_name )
2062
- if version and checker (have_version ) < checker (version ):
2058
+ if min_version and checker (have_version ) < checker (min_version ):
2059
+ pytest .skip (msg )
2060
+ if max_version and checker (have_version ) >= checker (max_version ):
2063
2061
pytest .skip (msg )
2064
2062
2065
2063
0 commit comments