本文整理汇总了Python中numpy.core.getlimits.finfo函数的典型用法代码示例。如果您正苦于以下问题:Python finfo函数的具体用法?Python finfo怎么用?Python finfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了finfo函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _getmax
def _getmax(t, seen_t={}):
try:
return seen_t[t]
except KeyError:
from numpy.core import getlimits
fmax = getlimits.finfo(t).max
seen_t[t]=fmax
return fmax
开发者ID:agreen991,项目名称:refl1d,代码行数:8,代码来源:polymer.py
示例2: real_if_close
def real_if_close(a, tol=100):
"""
If complex input returns a real array if complex parts are close to zero.
"Close to zero" is defined as `tol` * (machine epsilon of the type for
`a`).
Parameters
----------
a : array_like
Input array.
tol : float
Tolerance in machine epsilons for the complex part of the elements
in the array.
Returns
-------
out : ndarray
If `a` is real, the type of `a` is used for the output. If `a`
has complex elements, the returned type is float.
See Also
--------
real, imag, angle
Notes
-----
Machine epsilon varies from machine to machine and between data types
but Python floats on most platforms have a machine epsilon equal to
2.2204460492503131e-16. You can use 'np.finfo(np.float).eps' to print
out the machine epsilon for floats.
Examples
--------
>>> np.finfo(np.float).eps
2.2204460492503131e-16
>>> np.real_if_close([2.1 + 4e-14j], tol=1000)
array([ 2.1])
>>> np.real_if_close([2.1 + 4e-13j], tol=1000)
array([ 2.1 +4.00000000e-13j])
"""
a = asanyarray(a)
if not issubclass(a.dtype.type, _nx.complexfloating):
return a
if tol > 1:
from numpy.core import getlimits
f = getlimits.finfo(a.dtype.type)
tol = f.eps * tol
if _nx.allclose(a.imag, 0, atol=tol):
a = a.real
return a
开发者ID:vkarthi46,项目名称:numpy,代码行数:54,代码来源:type_check.py
示例3: _getmaxmin
def _getmaxmin(t):
from numpy.core import getlimits
f = getlimits.finfo(t)
return f.max, f.min
开发者ID:Horta,项目名称:numpy,代码行数:4,代码来源:type_check.py
示例4: PyannoValueError
import numpy as np
from numpy import log
from numpy.core import getlimits
from scipy.special import gammaln
import time
import logging
logger = logging.getLogger(__name__)
#: In annotations arrays, this is the value used to indicate missing values
MISSING_VALUE = -1
#: Smallest possible floating point number, somtimes used instead of -np.inf
#: to make numberical calculation return a meaningful value
SMALLEST_FLOAT = getlimits.finfo(np.float).min
class PyannoValueError(ValueError):
"""ValueError subclass raised by pyAnno functions and methods.
"""
pass
def random_categorical(distr, nsamples):
"""Return an array of samples from a categorical distribution.
Arguments
---------
distr : ndarray
distr[i] is the probability of item i
开发者ID:bobye,项目名称:uchicago-pyanno,代码行数:30,代码来源:util.py
示例5: finfo
epsilon = config.getfloat('LSM', 'epsilon')
lambda1 = config.getfloat('LSM', 'lambda1')
lambda2 = config.getfloat('LSM', 'lambda2')
upsilon = config.getfloat('LSM', 'upsilon')
mu = config.getfloat('LSM', 'mu')
eta = config.getfloat('LSM', 'eta')
delta_t = config.getfloat('LSM', 'delta_t')
t_0 = config.getfloat('LSM', 't_0')
t_f = config.getfloat('LSM', 't_f')
R_min = config.getfloat('LSM', 'R_min')
R_max = config.getfloat('LSM', 'R_max')
eps = finfo(float).eps
if use_pythode:
from pythode.ivp import ConstantIVPSolver, IVPSolverModule, return_rejected
import pythode.ivp.parameters as para
from pythode.ivp.schemes import feuler
from pythode.lib import deep_copy_update, parametrizable
TOLERANCE = delta_t #1e-2
#############
logging.basicConfig(filename='lsmethod.log')
log = logging.getLogger("lsmethod")
log.setLevel(logging.DEBUG)
#############
开发者ID:kvoss,项目名称:pylsm,代码行数:30,代码来源:lsmethod.py
注:本文中的numpy.core.getlimits.finfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论