Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# we do not include PyQt because it is an indirect dependency. It might
# be a good idea to include those too, but the list will get long in
# that case.
print("""
python {py}
larray {la}
numexpr {ne}
numpy {np}
pandas {pd}
pytables {pt}
pyyaml {yml}
bcolz {bc}
bottleneck {bn}
matplotlib {mpl}
vitables {vt}
""".format(py=py_version, la=la.__version__, ne=ne.__version__,
np=np.__version__, pd=pd.__version__, pt=pt.__version__,
yml=yaml.__version__,
bc=bcolz_version, bn=bn_version, mpl=mpl_version, vt=vt_version,
))
parser.exit()
pass
# Check for NumPy
check_import('numpy', min_numpy_version)
# Check for Numexpr
numexpr_here = False
try:
import numexpr
except ImportError:
print_warning("Numexpr not detected. Disabling support for it.")
else:
if numexpr.__version__ >= min_numexpr_version:
numexpr_here = True
print ( "* Found %(pkgname)s %(pkgver)s package installed."
% {'pkgname': 'numexpr', 'pkgver': numexpr.__version__} )
else:
print_warning(
"Numexpr %s detected, but version is not >= %s. "
"Disabling support for it." % (
numexpr.__version__, min_numexpr_version))
########### End of version checks ##########
# carray version
VERSION = open('VERSION').read().strip()
# Create the version.py file
open('carray/version.py', 'w').write('__version__ = "%s"\n' % VERSION)
# Global variables
CFLAGS = os.environ.get('CFLAGS', '').split()
experiments = [(setup1, expr1), (setup2, expr2), (setup3, expr3),
(setup4, expr4), (setup5, expr5), (setup5, expr6),
(setup5, expr7), (setup5, expr8), (setup5, expr9),
(setup5, expr10), (setup5, expr11), (setup5, expr12),
]
total = 0
for params in experiments:
total += compare_times(*params)
print
average = total / len(experiments)
print("Average =", round(average, 2))
return average
if __name__ == '__main__':
import numexpr
print("Numexpr version: ", numexpr.__version__)
averages = []
for i in range(iterations):
averages.append(compare())
print("Averages:", ', '.join("%.2f" % x for x in averages))
from __future__ import print_function
import itertools
import numpy as np
import numexpr as ne
import bcolz
import time
import cProfile
import inspect
print("numexpr version:", ne.__version__)
bcolz.defaults.cparams['shuffle'] = bcolz.SHUFFLE
#bcolz.defaults.cparams['shuffle'] = bcolz.BITSHUFFLE
bcolz.defaults.cparams['cname'] = 'blosclz'
#bcolz.defaults.cparams['cname'] = 'lz4'
bcolz.defaults.cparams['clevel'] = 5
#bcolz.defaults.vm = "dask"
#bcolz.defaults.vm = "python"
bcolz.defaults.vm = "numexpr"
N = 1e8
LMAX = 1e3
npa = np.arange(N)
npb = np.arange(N)
ct = bcolz.ctable([npa, npb], names=["a", "b"])
if sys.version_info >= (3, 0):
xrange = range
def dict_viewkeys(d):
return d.keys()
else:
def dict_viewkeys(d):
return d.iterkeys()
min_numexpr_version = '2.2' # the minimum version of Numexpr needed
numexpr_here = False
try:
import numexpr
except ImportError:
pass
else:
if numexpr.__version__ >= min_numexpr_version:
numexpr_here = True
if numexpr_here:
import numexpr
from numexpr.expressions import functions as numexpr_functions
class Defaults(object):
"""Class to taylor the setters and getters of default values."""
def __init__(self):
self.choices = {}
# Choices setup
self.choices['vm'] = ("numexpr", "python")
SHUFFLE = 1
BITSHUFFLE = 2
# Translation of filters to strings
filters = {NOSHUFFLE: "noshuffle",
SHUFFLE: "shuffle",
BITSHUFFLE: "bitshuffle"}
min_numexpr_version = '2.5.2' # the minimum version of Numexpr needed
numexpr_here = False
try:
import numexpr
except ImportError:
pass
else:
if parse_version(numexpr.__version__) >= parse_version(min_numexpr_version):
numexpr_here = True
# Check for dask (as another virtual machine for chunked eval)
min_dask_version = '0.9.0' # the minimum version of Numexpr needed
dask_here = False
try:
import dask
except ImportError:
pass
else:
if parse_version(dask.__version__) >= parse_version(min_dask_version):
dask_here = True
# Check for pandas (for data container conversion purposes)
pandas_here = False
try:
from sklearn import __version__ as skl_version
from statsmodels import __version__ as stats_version
from pyface import __version__ as pyf_version
from envisage import __version__ as env_version
from traits import __version__ as trt_version
from traitsui import __version__ as trt_ui_version
from yapf import __version__ as yapf_version
from nbformat import __version__ as nb_version
from yaml import __version__ as yaml_version
return {"python" : sys.version,
"cytoflow" : cf_version,
"fcsparser" : fcs_version,
"pandas" : pd_version,
"numpy" : np_version,
"numexpr" : nxp_version,
"bottleneck" : btl_version,
"seaborn" : sns_version,
"matplotlib" : mpl_version,
"scipy" : scipy_version,
"scikit-learn" : skl_version,
"statsmodels" : stats_version,
"pyface" : pyf_version,
"envisage" : env_version,
"traits" : trt_version,
"traitsui" : trt_ui_version,
"nbformat" : nb_version,
"yapf" : yapf_version,
"yaml" : yaml_version}
import warnings
from distutils.version import LooseVersion
_NUMEXPR_INSTALLED = False
_MIN_NUMEXPR_VERSION = "2.4.6"
try:
import numexpr as ne
ver = ne.__version__
_NUMEXPR_INSTALLED = ver >= LooseVersion(_MIN_NUMEXPR_VERSION)
if not _NUMEXPR_INSTALLED:
warnings.warn(
"The installed version of numexpr {ver} is not supported "
"in pandas and will be not be used\nThe minimum supported "
"version is {min_ver}\n".format(
ver=ver, min_ver=_MIN_NUMEXPR_VERSION), UserWarning)
except ImportError: # pragma: no cover
pass
__all__ = ['_NUMEXPR_INSTALLED']
if sys.version_info >= (3, 0):
xrange = range
def dict_viewkeys(d):
return d.keys()
else:
def dict_viewkeys(d):
return d.iterkeys()
min_numexpr_version = '2.1' # the minimum version of Numexpr needed
numexpr_here = False
try:
import numexpr
except ImportError:
pass
else:
if numexpr.__version__ >= min_numexpr_version:
numexpr_here = True
from numexpr.expressions import functions as numexpr_functions
class Defaults(object):
"""Class to taylor the setters and getters of default values."""
def __init__(self):
self.choices = {}
# Choices setup
self.choices['eval_out_flavor'] = ("barray", "numpy")
self.choices['eval_vm'] = ("numexpr", "python")
def check_choices(self, name, value):
if value not in self.choices[name]:
print("NumPy version: %s" % (np.__version__,))
t0 = time()
z = 2*y + 4*x
t1 = time()
gbs = working_set_GB / (t1-t0)
print("Time for an algebraic expression: %.3f s / %.3f GB/s" % (t1-t0, gbs))
t0 = time()
z = np.sin(x)**2 + np.cos(y)**2
t1 = time()
gbs = working_set_GB / (t1-t0)
print("Time for a transcendental expression: %.3f s / %.3f GB/s" % (t1-t0, gbs))
print("Numexpr version: %s. Using MKL: %s" % (ne.__version__, ne.use_vml))
t0 = time()
ne.evaluate('2*y + 4*x', out = z)
t1 = time()
gbs = working_set_GB / (t1-t0)
print("Time for an algebraic expression: %.3f s / %.3f GB/s" % (t1-t0, gbs))
t0 = time()
ne.evaluate('sin(x)**2 + cos(y)**2', out = z)
t1 = time()
gbs = working_set_GB / (t1-t0)
print("Time for a transcendental expression: %.3f s / %.3f GB/s" % (t1-t0, gbs))