Python numpy._NoValue() Examples
The following are 30
code examples of numpy._NoValue().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: utils.py From tangent with Apache License 2.0 | 7 votes |
def unreduce_array(array, shape, axis, keepdims): """Reverse summing over a dimension, NumPy implementation. Args: array: The array that was reduced. shape: The original shape of the array before reduction. axis: The axis or axes that were summed. keepdims: Whether these axes were kept as singleton axes. Returns: An array with axes broadcast to match the shape of the original array. """ # NumPy uses a special default value for keepdims, which is equivalent to # False. if axis is not None and (not keepdims or keepdims is numpy._NoValue): # pylint: disable=protected-access if isinstance(axis, int): axis = axis, for ax in sorted(axis): array = numpy.expand_dims(array, ax) return numpy.broadcast_to(array, shape) # The values are unary functions.
Example #2
Source File: test_reloading.py From coffeegrindsize with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #3
Source File: nanfunctions.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #4
Source File: test_reloading.py From recruit with Apache License 2.0 | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #5
Source File: nanfunctions.py From twitter-stock-recommendation with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #6
Source File: fromnumeric.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {k: v for k, v in kwargs.items() if v is not np._NoValue} if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #7
Source File: nanfunctions.py From recruit with Apache License 2.0 | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #8
Source File: test_reloading.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #9
Source File: test_reloading.py From vnpy_crypto with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #10
Source File: fromnumeric.py From vnpy_crypto with MIT License | 6 votes |
def sometrue(a, axis=None, out=None, keepdims=np._NoValue): """ Check whether some values are true. Refer to `any` for full documentation. See Also -------- any : equivalent function """ arr = asanyarray(a) kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims return arr.any(axis=axis, out=out, **kwargs)
Example #11
Source File: fromnumeric.py From coffeegrindsize with MIT License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {k: v for k, v in kwargs.items() if v is not np._NoValue} if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #12
Source File: test_reloading.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #13
Source File: nanfunctions.py From coffeegrindsize with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #14
Source File: nanfunctions.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #15
Source File: fromnumeric.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {k: v for k, v in kwargs.items() if v is not np._NoValue} if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #16
Source File: test_reloading.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #17
Source File: fromnumeric.py From twitter-stock-recommendation with MIT License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {} for k, v in kwargs.items(): if v is not np._NoValue: passkwargs[k] = v if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #18
Source File: nanfunctions.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #19
Source File: fromnumeric.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {} for k, v in kwargs.items(): if v is not np._NoValue: passkwargs[k] = v if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #20
Source File: test_reloading.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #21
Source File: fromnumeric.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def sometrue(a, axis=None, out=None, keepdims=np._NoValue): """ Check whether some values are true. Refer to `any` for full documentation. See Also -------- any : equivalent function """ arr = asanyarray(a) kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims return arr.any(axis=axis, out=out, **kwargs)
Example #22
Source File: nanfunctions.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #23
Source File: fromnumeric.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {k: v for k, v in kwargs.items() if v is not np._NoValue} if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #24
Source File: test_reloading.py From pySINDy with MIT License | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #25
Source File: test_reloading.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #26
Source File: nanfunctions.py From pySINDy with MIT License | 6 votes |
def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """Assumes that q is in [0, 1], and is an ndarray""" # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = function_base._ureduce( a, func=_nanquantile_ureduce_func, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation ) if keepdims and keepdims is not np._NoValue: return r.reshape(q.shape + k) else: return r
Example #27
Source File: fromnumeric.py From pySINDy with MIT License | 6 votes |
def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs): passkwargs = {} for k, v in kwargs.items(): if v is not np._NoValue: passkwargs[k] = v if type(obj) is not mu.ndarray: try: reduction = getattr(obj, method) except AttributeError: pass else: # This branch is needed for reductions like any which don't # support a dtype. if dtype is not None: return reduction(axis=axis, dtype=dtype, out=out, **passkwargs) else: return reduction(axis=axis, out=out, **passkwargs) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
Example #28
Source File: test_reloading.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_numpy_reloading(): # gh-7844. Also check that relevant globals retain their identity. import numpy as np import numpy._globals _NoValue = np._NoValue VisibleDeprecationWarning = np.VisibleDeprecationWarning ModuleDeprecationWarning = np.ModuleDeprecationWarning reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) assert_raises(RuntimeError, reload, numpy._globals) reload(np) assert_(_NoValue is np._NoValue) assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
Example #29
Source File: fromnumeric.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def sometrue(a, axis=None, out=None, keepdims=np._NoValue): """ Check whether some values are true. Refer to `any` for full documentation. See Also -------- any : equivalent function """ arr = asanyarray(a) kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims return arr.any(axis=axis, out=out, **kwargs)
Example #30
Source File: fromnumeric.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def sometrue(a, axis=None, out=None, keepdims=np._NoValue): """ Check whether some values are true. Refer to `any` for full documentation. See Also -------- any : equivalent function """ arr = asanyarray(a) kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims return arr.any(axis=axis, out=out, **kwargs)