Here are the examples of the python api numpy.__version__ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
144 Examples
5
Source : setupext.py
with MIT License
from ktraunmueller
with MIT License
from ktraunmueller
def check(self):
min_version = extract_versions()['__version__numpy__']
try:
import numpy
except ImportError:
return 'not found. pip may install it below.'
if not is_min_version(numpy.__version__, min_version):
raise SystemExit(
"Requires numpy %s or later to build. (Found %s)" %
(min_version, numpy.__version__))
return 'version %s' % numpy.__version__
def add_flags(self, ext):
3
Source : nosetester.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def _numpy_tester():
if hasattr(np, "__version__") and ".dev0" in np.__version__:
mode = "develop"
else:
mode = "release"
return NoseTester(raise_warnings=mode, depth=1,
check_fpu_mode=True)
3
Source : test_ujson.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_npy_nat(self):
from distutils.version import LooseVersion
if LooseVersion(np.__version__) < LooseVersion('1.7.0'):
pytest.skip("numpy version < 1.7.0, is "
"{0}".format(np.__version__))
input = np.datetime64('NaT')
assert ujson.encode(input) == 'null', "Expected null"
def test_datetime_units(self):
3
Source : test_stats.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def __init__(self, min_numpy_version, warning_type, num_warnings):
if NumpyVersion(np.__version__) < min_numpy_version:
self.numpy_is_old = True
self.warning_type = warning_type
self.num_warnings = num_warnings
self.delegate = warnings.catch_warnings(record = True)
else:
self.numpy_is_old = False
def __enter__(self):
3
Source : msvc.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def msvc14_gen_lib_options(*args, **kwargs):
"""
Patched "distutils._msvccompiler.gen_lib_options" for fix
compatibility between "numpy.distutils" and "distutils._msvccompiler"
(for Numpy < 1.11.2)
"""
if "numpy.distutils" in sys.modules:
import numpy as np
if LegacyVersion(np.__version__) < LegacyVersion('1.11.2'):
return np.distutils.ccompiler.gen_lib_options(*args, **kwargs)
return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs)
def _augment_exception(exc, version, arch=''):
3
Source : collect_env_details.py
with GNU General Public License v3.0
from aehrc
with GNU General Public License v3.0
from aehrc
def info_packages():
return {
"numpy": numpy.__version__,
"pyTorch_version": torch.__version__,
"pyTorch_debug": torch.version.debug,
"pytorch-lightning": pytorch_lightning.__version__,
"tqdm": tqdm.__version__,
}
def nice_print(details, level=0):
3
Source : category.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def _text(value):
"""Converts text values into `utf-8` or `ascii` strings
"""
if LooseVersion(np.__version__) < LooseVersion('1.7.0'):
if (isinstance(value, (six.text_type, np.unicode))):
value = value.encode('utf-8', 'ignore').decode('utf-8')
if isinstance(value, (np.bytes_, six.binary_type)):
value = value.decode(encoding='utf-8')
elif not isinstance(value, (np.str_, six.string_types)):
value = str(value)
return value
class UnitData(object):
3
Source : test_axes.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def test_formatter_large_small():
# github issue #617, pull #619
if LooseVersion(np.__version__) >= LooseVersion('1.11.0'):
pytest.skip("Fall out from a fixed numpy bug")
fig, ax = plt.subplots(1)
x = [0.500000001, 0.500000002]
y = [1e64, 1.1e64]
ax.plot(x, y)
@image_comparison(baseline_images=["twin_axis_locaters_formatters"])
3
Source : pytesttester.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def _show_numpy_info():
import numpy as np
print("NumPy version %s" % np.__version__)
relaxed_strides = np.ones((10, 1), order="C").flags.f_contiguous
print("NumPy relaxed strides checking option:", relaxed_strides)
class PytestTester(object):
3
Source : nosetester.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def _show_system_info(self):
nose = import_nose()
import numpy
print("NumPy version %s" % numpy.__version__)
npdir = os.path.dirname(numpy.__file__)
print("NumPy is installed in %s" % npdir)
if 'scipy' in self.package_name:
import scipy
print("SciPy version %s" % scipy.__version__)
spdir = os.path.dirname(scipy.__file__)
print("SciPy is installed in %s" % spdir)
pyversion = sys.version.replace('\n', '')
print("Python version %s" % pyversion)
print("nose version %d.%d.%d" % nose.__versioninfo__)
def _get_custom_doctester(self):
3
Source : tools.py
with MIT License
from ASPP
with MIT License
from ASPP
def sysinfo():
import sys
import time
import numpy as np
import scipy as sp
import matplotlib
print("Date: %s" % (time.strftime("%D")))
version = sys.version_info
major, minor, micro = version.major, version.minor, version.micro
print("Python: %d.%d.%d" % (major, minor, micro))
print("Numpy: ", np.__version__)
print("Scipy: ", sp.__version__)
print("Matplotlib:", matplotlib.__version__)
def timeit(stmt, globals=globals()):
3
Source : test_scooby.py
with MIT License
from banesullivan
with MIT License
from banesullivan
def test_get_version():
name, version = scooby.get_version(numpy)
assert version == numpy.__version__
assert name == "numpy"
name, version = scooby.get_version("no_version")
assert version == scooby.report.VERSION_NOT_FOUND
assert name == "no_version"
name, version = scooby.get_version("does_not_exist")
assert version == scooby.report.MODULE_NOT_FOUND
assert name == "does_not_exist"
def test_plain_vs_html():
3
Source : _pytesttester.py
with Apache License 2.0
from dashanji
with Apache License 2.0
from dashanji
def _show_numpy_info():
import numpy as np
print("NumPy version %s" % np.__version__)
relaxed_strides = np.ones((10, 1), order="C").flags.f_contiguous
print("NumPy relaxed strides checking option:", relaxed_strides)
class PytestTester:
3
Source : misc.py
with GNU General Public License v3.0
from DayuanTan
with GNU General Public License v3.0
from DayuanTan
def random_choice_dist(n, b):
"""
Returns the absolute distribution of a random choice sample of size n
having the choice between len(b) options where each option has
the probability represented in vector b.
"""
if np.__version__ >= '1.7.0':
return np.bincount(np.random.choice(b.size, n, p=b.flat),
minlength=b.size).reshape(b.shape)
else:
return np.bincount(np.searchsorted(np.cumsum(b), np.random.random(n)), minlength=b.size).reshape(b.shape)
def random_choice(n, b):
3
Source : misc.py
with GNU General Public License v3.0
from DayuanTan
with GNU General Public License v3.0
from DayuanTan
def random_choice(n, b):
"""
Returns the random choice sample of size n
having the choice between len(b) options where each option has
the probability represented in vector b.
"""
if np.__version__ >= '1.7.0':
return np.random.choice(b.size, n, p=b.flat)
else:
return np.searchsorted(np.cumsum(b), np.random.random(n))
def filepathlist_to_filepathstring(filepathlist, sep=',', is_primed=False):
3
Source : utils.py
with Apache License 2.0
from didi
with Apache License 2.0
from didi
def np_load(data_dir):
if np.__version__ >= '1.16.2':
data = np.load(data_dir, allow_pickle=True)
else:
data = np.load(data_dir)
return data
def get_npz_arrays_name(npz_data):
3
Source : make_sample.py
with Apache License 2.0
from didi
with Apache License 2.0
from didi
def np_load(data_dir):
if np.__version__ >= '1.16.2':
data = np.load(data_dir, allow_pickle=True)
else:
data = np.load(data_dir)
return data
def print_npz(the_npz):
3
Source : extra_ops.py
with MIT License
from dmitriy-serdyuk
with MIT License
from dmitriy-serdyuk
def __init__(self, return_index=False, return_inverse=False,
return_counts=False):
self.return_index = return_index
self.return_inverse = return_inverse
self.return_counts = return_counts
numpy_ver = [int(n) for n in numpy.__version__.split('.')[:2]]
if self.return_counts and bool(numpy_ver < [1, 9]):
raise RuntimeError(
"Numpy version = " + np.__version__ +
". Option 'return_counts=True' works starting"
" from version 1.9.0.")
def make_node(self, x):
3
Source : subtensor.py
with MIT License
from dmitriy-serdyuk
with MIT License
from dmitriy-serdyuk
def perform(self, node, inputs, out_):
out, = out_
# TODO: in general, we need to re-pack the inputs into a valid
# index, just like subtensor
out[0] = inputs[0].__getitem__(inputs[1:])
if (numpy.__version__ < = '1.6.1' and
out[0].size != numpy.uint32(out[0].size)):
warnings.warn(
'Numpy versions 1.6.1 and below have a bug preventing '
'advanced indexing from correctly filling arrays that '
'are too big (>= 2^32 elements). It is possible that '
'out[0] (%s), with shape %s, is not correctly filled.'
% (out[0], out[0].shape))
def connection_pattern(self, node):
3
Source : test_regression.py
with GNU General Public License v3.0
from dnn-security
with GNU General Public License v3.0
from dnn-security
def test_numpy_version_attribute(self):
# Check that self.module has an attribute named "__f2py_numpy_version__"
assert_(hasattr(self.module, "__f2py_numpy_version__"),
msg="Fortran module does not have __f2py_numpy_version__")
# Check that the attribute __f2py_numpy_version__ is a string
assert_(isinstance(self.module.__f2py_numpy_version__, str),
msg="__f2py_numpy_version__ is not a string")
# Check that __f2py_numpy_version__ has the value numpy.__version__
assert_string_equal(np.__version__, self.module.__f2py_numpy_version__)
3
Source : _pytesttester.py
with GNU General Public License v3.0
from dnn-security
with GNU General Public License v3.0
from dnn-security
def _show_numpy_info():
import numpy as np
print("NumPy version %s" % np.__version__)
relaxed_strides = np.ones((10, 1), order="C").flags.f_contiguous
print("NumPy relaxed strides checking option:", relaxed_strides)
info = np.lib.utils._opt_info()
print("NumPy CPU features: ", (info if info else 'nothing enabled'))
class PytestTester:
3
Source : _test_decorators.py
with GNU General Public License v3.0
from dnn-security
with GNU General Public License v3.0
from dnn-security
def skip_if_np_lt(ver_str: str, *args, reason: str | None = None):
if reason is None:
reason = f"NumPy {ver_str} or greater required"
return pytest.mark.skipif(
Version(np.__version__) < Version(ver_str),
*args,
reason=reason,
)
def parametrize_fixture_doc(*args):
3
Source : test_least_angle.py
with GNU General Public License v3.0
from HHHHhgqcdxhg
with GNU General Public License v3.0
from HHHHhgqcdxhg
def test_lars_lstsq():
# Test that Lars gives least square solution at the end
# of the path
X1 = 3 * diabetes.data # use un-normalized dataset
clf = linear_model.LassoLars(alpha=0.)
clf.fit(X1, y)
# Avoid FutureWarning about default value change when numpy >= 1.14
rcond = None if LooseVersion(np.__version__) >= '1.14' else -1
coef_lstsq = np.linalg.lstsq(X1, y, rcond=rcond)[0]
assert_array_almost_equal(clf.coef_, coef_lstsq)
@pytest.mark.filterwarnings('ignore:`rcond` parameter will change')
3
Source : arrays.py
with Apache License 2.0
from JohnGoertz
with Apache License 2.0
from JohnGoertz
def cov(self, stdzd=True, whiten=1e-10):
"""Covariance matrix (only supported for 0-D MVUParrays)"""
# TODO: numpy versions > 1.19.3 can have bizarre inscrutable errors when handling mvup.cov. Monitor for fixes.
if np.__version__ > '1.19.3':
warnings.warn('numpy version >1.19.3 may lead to inscrutable linear algebra errors with mvup.cov. May just be on Windows/WSL. Hopefully fixed soon.')
if self.ndim != 0:
raise NotImplementedError('Multidimensional multivariate covariance calculations are not yet supported.')
σ = self.z.σ.values() if stdzd else self.t.σ.values()
cov = np.diag(σ) @ self.cor @ np.diag(σ)
if whiten:
cov += whiten*np.eye(*cov.shape)
return cov
@property
3
Source : arrays.py
with Apache License 2.0
from JohnGoertz
with Apache License 2.0
from JohnGoertz
def dist(self) -> MultivariateNormalish:
"""Scipy :func:`multivariate_normal` object (only supported for 0-D MVUParrays)"""
# TODO: numpy versions > 1.19.3 can have bizarre inscrutable errors when handling mvup.dist. Monitor for fixes.
if np.__version__ > '1.19.3':
warnings.warn('numpy version >1.19.3 may lead to inscrutable linear algebra errors with mvup.dist. May just be on Windows/WSL. Hopefully fixed soon.')
if self.ndim != 0:
raise NotImplementedError('Multidimensional multivariate distributions are not yet supported.')
return MultivariateNormalish(mean=self.μ, cov=self.cov(stdzd=True))
def mahalanobis(self, parray: ParameterArray) -> float:
3
Source : test_ujson.py
with MIT License
from ktraunmueller
with MIT License
from ktraunmueller
def test_npy_nat(self):
from distutils.version import LooseVersion
if LooseVersion(np.__version__) < '1.7.0':
raise nose.SkipTest("numpy version < 1.7.0, is "
"{0}".format(np.__version__))
input = np.datetime64('NaT')
assert ujson.encode(input) == 'null', "Expected null"
def test_datetime_units(self):
3
Source : _test_decorators.py
with BSD 3-Clause "New" or "Revised" License
from leobago
with BSD 3-Clause "New" or "Revised" License
from leobago
def skip_if_np_lt(ver_str: str, *args, reason: Optional[str] = None):
if reason is None:
reason = f"NumPy {ver_str} or greater required"
return pytest.mark.skipif(
np.__version__ < LooseVersion(ver_str), *args, reason=reason
)
def parametrize_fixture_doc(*args):
3
Source : conftest.py
with MIT License
from LukasBommes
with MIT License
from LukasBommes
def use_legacy_numpy_printoptions():
"""Ensure numpy use legacy print formant."""
if LooseVersion(np.__version__).version[:2] > [1, 13]:
np.set_printoptions(legacy="1.13")
@pytest.fixture(scope="module")
3
Source : test_requirements_utils.py
with Apache License 2.0
from mlflow
with Apache License 2.0
from mlflow
def test_get_installed_version(tmpdir):
import numpy as np
import pandas as pd
import sklearn
assert _get_installed_version("mlflow") == mlflow.__version__
assert _get_installed_version("numpy") == np.__version__
assert _get_installed_version("pandas") == pd.__version__
assert _get_installed_version("scikit-learn", module="sklearn") == sklearn.__version__
not_found_package = tmpdir.join("not_found.py")
not_found_package.write("__version__ = '1.2.3'")
sys.path.insert(0, tmpdir.strpath)
with pytest.raises(importlib_metadata.PackageNotFoundError, match=r".+"):
importlib_metadata.version("not_found")
assert _get_installed_version("not_found") == "1.2.3"
def test_get_pinned_requirement(tmpdir):
3
Source : nosetester.py
with GNU Affero General Public License v3.0
from nccgroup
with GNU Affero General Public License v3.0
from nccgroup
def _numpy_tester():
if hasattr(np, "__version__") and ".dev0" in np.__version__:
mode = "develop"
else:
mode = "release"
return NoseTester(raise_warnings=mode, depth=1)
3
Source : __init__.py
with Apache License 2.0
from opendilab
with Apache License 2.0
from opendilab
def __init__(self, module):
ModuleType.__init__(self, module.__name__)
for name in filter(lambda x: x.startswith('__') and x.endswith('__'), dir(module)):
setattr(self, name, getattr(module, name))
self.__origin__ = module
self.__numpy_version__ = np.__version__
self.__version__ = __VERSION__
def __getattr__(self, name):
3
Source : setup.py
with Apache License 2.0
from openvinotoolkit
with Apache License 2.0
from openvinotoolkit
def check_and_update_numpy(min_acceptable='1.15'):
try:
import numpy as np # pylint:disable=C0415
update_required = LooseVersion(np.__version__) < LooseVersion(min_acceptable)
except ImportError:
update_required = True
if update_required:
subprocess.call([sys.executable, '-m', 'pip', 'install', 'numpy>={}'.format(min_acceptable)])
def install_dependencies_with_pip(dependencies):
3
Source : test_regression.py
with MIT License
from osamhack2021
with MIT License
from osamhack2021
def test_numpy_version_attribute(self):
# Check that self.module has an attribute named "__f2py_numpy_version__"
assert_(hasattr(self.module, "__f2py_numpy_version__"),
msg="Fortran module does not have __f2py_numpy_version__")
# Check that the attribute __f2py_numpy_version__ is a string
assert_(isinstance(self.module.__f2py_numpy_version__, str),
msg="__f2py_numpy_version__ is not a string")
# Check that __f2py_numpy_version__ has the value numpy.__version__
assert_string_equal(np.__version__, self.module.__f2py_numpy_version__)
def test_include_path():
3
Source : test_least_angle.py
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
def test_lars_lstsq():
# Test that Lars gives least square solution at the end
# of the path
X1 = 3 * X # use un-normalized dataset
clf = linear_model.LassoLars(alpha=0.)
clf.fit(X1, y)
# Avoid FutureWarning about default value change when numpy >= 1.14
rcond = None if LooseVersion(np.__version__) >= '1.14' else -1
coef_lstsq = np.linalg.lstsq(X1, y, rcond=rcond)[0]
assert_array_almost_equal(clf.coef_, coef_lstsq)
@pytest.mark.filterwarnings('ignore:`rcond` parameter will change')
3
Source : test_xfail.py
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
def test_particle_splitting():
initialize_physics()
import numpy
if numpy.__version__ < "1.13":
pytest.xfail("split computation fails with numpy < 1.13")
...
3
Source : pytyphoon.py
with GNU General Public License v3.0
from pderian
with GNU General Public License v3.0
from pderian
def print_versions():
print("\n* Module versions:")
print('Python:', sys.version)
print('Numpy:', numpy.__version__)
print('Scipy:', scipy.__version__)
print('PyWavelet:', pywt.__version__)
print('Matplotlib:', matplotlib.__version__)
print('PyTyphoon (this):', __version__)
def demo_particles():
3
Source : test_ujson.py
with Apache License 2.0
from pierreant
with Apache License 2.0
from pierreant
def test_npy_nat(self):
from distutils.version import LooseVersion
if LooseVersion(np.__version__) < '1.7.0':
pytest.skip("numpy version < 1.7.0, is "
"{0}".format(np.__version__))
input = np.datetime64('NaT')
assert ujson.encode(input) == 'null', "Expected null"
def test_datetime_units(self):
3
Source : python_utils.py
with MIT License
from rockNroll87q
with MIT License
from rockNroll87q
def logEveryPackageLoad(log):
log.info('%10s : %s' % ('Running on', os.uname()[1]))
log.info('%10s : %s' % ('Python', sys.version.split('\n')[0]))
log.info('%10s : %s' % ('Numpy', np.__version__))
log.info('%10s : %s' % ('json', json.__version__))
log.info('%10s : %s' % ('nibabel', nib.__version__))
log.info('%10s : %s' % ('Keras', keras.__version__))
log.info('%10s : %s \n' % ('Tensorflow', tf.__version__))
def checkGPUsAvailability(n_gpus=1):
3
Source : _util.py
with BSD 3-Clause "New" or "Revised" License
from scikit-hep
with BSD 3-Clause "New" or "Revised" License
from scikit-hep
def numpy_at_least(version):
import numpy
return parse_version(numpy.__version__) >= parse_version(version)
def in_module(obj, modulename):
3
Source : mangampl.py
with BSD 3-Clause "New" or "Revised" License
from sdss
with BSD 3-Clause "New" or "Revised" License
from sdss
def get_environment_versions(self):
# These will throw KeyErrors if the appropriate environmental variables do not exist
try:
accessver_env = os.environ['SDSS_ACCESS_DIR'].split('/')[-1]
except KeyError:
accessver_env = None
try:
idlver_env = os.environ['IDLUTILS_DIR'].split('/')[-1]
except KeyError:
idlver_env = None
python_ver = '.'.join([ str(v) for v in sys.version_info[:3]])
return [ accessver_env, idlver_env, os.getenv('MANGACORE_VER'),
os.getenv('MANGADRP_VER'), os.getenv('MANGADAP_VER'),
python_ver, numpy.__version__, scipy.__version__, matplotlib.__version__,
astropy.__version__, pydl.__version__]
def verify_versions(self, quiet=True):
3
Source : callbacks.py
with GNU General Public License v3.0
from SNL-NERL
with GNU General Public License v3.0
from SNL-NERL
def on_train_begin(self, logs=None):
# Create metadata files that store sharpener params and copy of exemplar set.
with open(os.path.join(self.logdir, 'sharpener_params.pkl'), 'wb') as f:
pickle.dump(self.sharpener.get_config(), f, protocol=1)
environ_info = {'time':time.time()}
try:
environ_info['whetstone_version'] = pkg_resources.get_distribution('whetstone').version
environ_info['keras_version'] = keras.__version__
environ_info['numpy_version'] = np.__version__
environ_info['python_version'] = sys.version
environ_info['backend'] = str(K._backend)
if environ_info['backend'] == 'tensorflow':
environ_info['tensorflow_version'] = K.tf.__version__
except:
pass
with open(os.path.join(self.logdir, 'environ.pkl'), 'wb') as f:
pickle.dump(environ_info, f, protocol=1)
def on_epoch_end(self, epoch, logs=None):
3
Source : setuptools_msvc.py
with MIT License
from soIu
with MIT License
from soIu
def msvc14_gen_lib_options(*args, **kwargs):
"""
Patched "distutils._msvccompiler.gen_lib_options" for fix
compatibility between "numpy.distutils" and "distutils._msvccompiler"
(for Numpy < 1.11.2)
"""
if "numpy.distutils" in sys.modules:
import numpy as np
from pkg_resources.extern.packaging.version import LegacyVersion
if LegacyVersion(np.__version__) < LegacyVersion('1.11.2'):
return np.distutils.ccompiler.gen_lib_options(*args, **kwargs)
return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs)
def _augment_exception(exc, version, arch=''):
3
Source : helper.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def _get_numpy_errors():
numpy_version = numpy.lib.NumpyVersion(numpy.__version__)
errors = [
AttributeError, Exception, IndexError, TypeError, ValueError,
NotImplementedError, DeprecationWarning,
]
if numpy_version >= '1.13.0':
errors.append(numpy.AxisError)
if numpy_version >= '1.15.0':
errors.append(numpy.linalg.LinAlgError)
return errors
_numpy_errors = _get_numpy_errors()
3
Source : test_ndarray_elementwise_op.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_ifloordiv_array(self):
if '1.16.1' < = numpy.lib.NumpyVersion(numpy.__version__) < '1.18.0':
self.skipTest("NumPy Issue #12927")
with testing.NumpyError(divide='ignore'):
self.check_array_array_op(operator.ifloordiv, no_complex=True)
def test_pow_array(self):
3
Source : test_ndarray_elementwise_op.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_broadcasted_ifloordiv(self):
if '1.16.1' < = numpy.lib.NumpyVersion(numpy.__version__) < '1.18.0':
self.skipTest("NumPy Issue #12927")
with testing.NumpyError(divide='ignore'):
self.check_array_broadcasted_op(operator.ifloordiv,
no_complex=True)
def test_broadcasted_pow(self):
3
Source : test_fft2_fftn.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_fft2_param_array_U21(self, a):
if np.__version__ < np.lib.NumpyVersion('1.19.0'):
with pytest.raises(ValueError):
nlcpy.fft.fft2(a)
else:
assert_allclose(nlcpy.fft.fft2(a), np.fft.fft2(a))
@pytest.mark.parametrize('a', (1, 1 + 2j,
3
Source : test_fft2_fftn.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_ifft2_param_array_U21(self, a):
if np.__version__ < np.lib.NumpyVersion('1.19.0'):
with pytest.raises(ValueError):
nlcpy.fft.ifft2(a)
else:
assert_allclose(nlcpy.fft.ifft2(a), np.fft.ifft2(a))
@pytest.mark.parametrize('param', (
3
Source : test_fft2_fftn.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_rfft2(self, xp, dtype, order):
# the scaling of old Numpy is incorrect
if np.__version__ < np.lib.NumpyVersion('1.13.0'):
if self.s is not None:
return xp.empty(0)
a = testing.shaped_random(self.shape, xp, dtype)
a = xp.asarray(a, order=order)
out = xp.fft.rfft2(a, s=self.s, norm=self.norm)
if xp == np and dtype is np.float32:
out = out.astype(np.complex64)
return out
@testing.for_all_dtypes()
3
Source : config.py
with MIT License
from twni2016
with MIT License
from twni2016
def check_numpy_version():
if distutils.version.LooseVersion(
numpy.__version__
) < distutils.version.LooseVersion("1.10.4"):
raise error.MujocoDependencyError(
"You are running with numpy {}, but you must use >= 1.10.4. (In particular, earlier versions of numpy have been seen to cause mujoco-py to return different results from later ones.)".format(
numpy.__version__, "1.10.4"
)
)
3
Source : test_estimator_checks.py
with MIT License
from yoonkt200
with MIT License
from yoonkt200
def test_not_an_array_array_function():
np_version = _parse_version(np.__version__)
if np_version < (1, 17):
raise SkipTest("array_function protocol not supported in numpy < 1.17")
not_array = _NotAnArray(np.ones(10))
msg = "Don't want to call array_function sum!"
assert_raises_regex(TypeError, msg, np.sum, not_array)
# always returns True
assert np.may_share_memory(not_array, None)
def test_check_fit_score_takes_y_works_on_deprecated_fit():
See More Examples