本文整理汇总了Python中numpy.ma.log方法的典型用法代码示例。如果您正苦于以下问题:Python ma.log方法的具体用法?Python ma.log怎么用?Python ma.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.ma
的用法示例。
在下文中一共展示了ma.log方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_non_affine
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def transform_non_affine(self, a):
# Ignore invalid values due to nans being passed to the transform
with np.errstate(divide="ignore", invalid="ignore"):
out = np.log(a)
out /= np.log(self.base)
if self._clip:
# SVG spec says that conforming viewers must support values up
# to 3.4e38 (C float); however experiments suggest that
# Inkscape (which uses cairo for rendering) runs into cairo's
# 24-bit limit (which is apparently shared by Agg).
# Ghostscript (used for pdf rendering appears to overflow even
# earlier, with the max value around 2 ** 15 for the tests to
# pass. On the other hand, in practice, we want to clip beyond
# np.log10(np.nextafter(0, 1)) ~ -323
# so 1000 seems safe.
out[a <= 0] = -1000
return out
示例2: transform_non_affine
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def transform_non_affine(self, a):
"""
This transform takes an Nx1 ``numpy`` array and returns a
transformed copy. Since the range of the Mercator scale
is limited by the user-specified threshold, the input
array must be masked to contain only valid values.
``matplotlib`` will handle masked arrays and remove the
out-of-range data from the plot. Importantly, the
``transform`` method *must* return an array that is the
same shape as the input array, since these values need to
remain synchronized with values in the other dimension.
"""
masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
if masked.mask.any():
return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
else:
return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
示例3: transform_non_affine
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def transform_non_affine(self, a):
# Ignore invalid values due to nans being passed to the transform
with np.errstate(divide="ignore", invalid="ignore"):
out = np.log(a)
out /= np.log(self.base)
if self._clip:
# SVG spec says that conforming viewers must support values up
# to 3.4e38 (C float); however experiments suggest that
# Inkscape (which uses cairo for rendering) runs into cairo's
# 24-bit limit (which is apparently shared by Agg).
# Ghostscript (used for pdf rendering appears to overflow even
# earlier, with the max value around 2 ** 15 for the tests to
# pass. On the other hand, in practice, we want to clip beyond
# np.log10(np.nextafter(0, 1)) ~ -323
# so 1000 seems safe.
out[a <= 0] = -1000
return out
示例4: countTags
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def countTags(infile, outfile):
'''count number of tags in bed-file.
`outfile` will contain the number of tags in `infile`
counted per chromosome.
Arguments
=========
infile : string
Input filename in :term:`bed` format
outfile : string
Output filename in :term:`tsv` format.
'''
statement = '''zcat %(infile)s
| cgat bed2stats
--per-contig
--log=%(outfile)s.log
>& %(outfile)s'''
P.run()
示例5: geoMean
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def geoMean(array):
'''
Generate the geometric mean of a list or array,
removing all zero-values but retaining total length
'''
if isinstance(array, pandas.core.frame.DataFrame):
array = array.as_matrix()
else:
pass
non_zero = ma.masked_values(array,
0)
log_a = ma.log(non_zero)
geom_mean = ma.exp(log_a.mean())
return geom_mean
示例6: limit_range_for_scale
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def limit_range_for_scale(self, vmin, vmax, minpos):
"""
Returns the range *vmin*, *vmax*, possibly limited to the
domain supported by this scale.
*minpos* should be the minimum positive value in the data.
This is used by log scales to determine a minimum value.
"""
return vmin, vmax
示例7: transform_non_affine
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def transform_non_affine(self, a):
a = self._handle_nonpos(a * 2.0)
if isinstance(a, ma.MaskedArray):
return ma.log(a) / np.log(2)
return np.log2(a)
示例8: set_default_locators_and_formatters
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def set_default_locators_and_formatters(self, axis):
"""
Set the locators and formatters to specialized versions for
log scaling.
"""
axis.set_major_locator(LogLocator(self.base))
axis.set_major_formatter(LogFormatterMathtext(self.base))
axis.set_minor_locator(LogLocator(self.base, self.subs))
axis.set_minor_formatter(NullFormatter())
示例9: gmean
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def gmean(a, axis=0):
a, axis = _chk_asarray(a, axis)
log_a = ma.log(a)
return ma.exp(log_a.mean(axis=axis))
示例10: linregress
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def linregress(*args):
if len(args) == 1: # more than 1D array?
args = ma.array(args[0], copy=True)
if len(args) == 2:
x = args[0]
y = args[1]
else:
x = args[:,0]
y = args[:,1]
else:
x = ma.array(args[0]).flatten()
y = ma.array(args[1]).flatten()
m = ma.mask_or(ma.getmask(x), ma.getmask(y))
if m is not nomask:
x = ma.array(x,mask=m)
y = ma.array(y,mask=m)
n = len(x)
(xmean, ymean) = (x.mean(), y.mean())
(xm, ym) = (x-xmean, y-ymean)
(Sxx, Syy) = (ma.add.reduce(xm*xm), ma.add.reduce(ym*ym))
Sxy = ma.add.reduce(xm*ym)
r_den = ma.sqrt(Sxx*Syy)
if r_den == 0.0:
r = 0.0
else:
r = Sxy / r_den
if (r > 1.0):
r = 1.0 # from numerical error
# z = 0.5*log((1.0+r+TINY)/(1.0-r+TINY))
df = n-2
t = r * ma.sqrt(df/(1.0-r*r))
prob = betai(0.5*df,0.5,df/(df+t*t))
slope = Sxy / Sxx
intercept = ymean - slope*xmean
sterrest = ma.sqrt(1.-r*r) * y.std()
return slope, intercept, r, prob, sterrest
示例11: _kolmog1
# 需要导入模块: from numpy import ma [as 别名]
# 或者: from numpy.ma import log [as 别名]
def _kolmog1(x,n):
if x <= 0:
return 0
if x >= 1:
return 1
j = np.arange(np.floor(n*(1-x))+1)
return 1 - x * np.sum(np.exp(np.log(misc.comb(n,j))
+ (n-j) * np.log(1-x-j/float(n))
+ (j-1) * np.log(x+j/float(n))))