本文整理汇总了Python中numpy.lib.type_check.isreal函数的典型用法代码示例。如果您正苦于以下问题:Python isreal函数的具体用法?Python isreal怎么用?Python isreal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isreal函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _fix_real_lt_zero
def _fix_real_lt_zero(x):
"""Convert `x` to complex if it has real, negative components.
Otherwise, output is just the array version of the input (via asarray).
Parameters
----------
x : array_like
Returns
-------
array
Examples
--------
>>> np.lib.scimath._fix_real_lt_zero([1,2])
array([1, 2])
>>> np.lib.scimath._fix_real_lt_zero([-1,2])
array([-1.+0.j, 2.+0.j])
"""
x = asarray(x)
if any(isreal(x) & (x<0)):
x = _tocomplex(x)
return x
开发者ID:arthornsby,项目名称:numpy,代码行数:25,代码来源:scimath.py
示例2: _fix_real_abs_gt_1
def _fix_real_abs_gt_1(x):
"""Convert `x` to complex if it has real components x_i with abs(x_i)>1.
Otherwise, output is just the array version of the input (via asarray).
Parameters
----------
x : array_like
Returns
-------
array
Examples
--------
>>> np.lib.scimath._fix_real_abs_gt_1([0,1])
array([0, 1])
>>> np.lib.scimath._fix_real_abs_gt_1([0,2])
array([ 0.+0.j, 2.+0.j])
"""
x = asarray(x)
if any(isreal(x) & (abs(x)>1)):
x = _tocomplex(x)
return x
开发者ID:arthornsby,项目名称:numpy,代码行数:25,代码来源:scimath.py
示例3: _fix_int_lt_zero
def _fix_int_lt_zero(x):
"""Convert `x` to double if it has real, negative components.
Otherwise, output is just the array version of the input (via asarray).
Parameters
----------
x : array_like
Returns
-------
array
Examples
--------
>>> _fix_int_lt_zero([1,2])
array([1, 2])
>>> _fix_int_lt_zero([-1,2])
array([-1., 2.])
"""
x = asarray(x)
if any(isreal(x) & (x < 0)):
x = x * 1.0
return x
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:25,代码来源:scimath.py
示例4: manhattan
def manhattan(subplot, p_values, p=0.05, threshold='bonferroni', title=None, colors=('r', 'g', 'b'),
min_p_value=1e-16):
'''Generate a Manahattan plot from a list of 22 p-value data sets. Entry data[i] corresponds
to chromosome i-1, and should be tuple (snp_bp_coordinate, p_value).'''
# Prepare plot
subplot.set_yscale('log')
if title:
P.title(title)
P.xlabel('Chromosome')
P.ylabel(r'$p^{-1}$')
P.hold(True)
offset = genome_bp_offset()[:NUM_CHROMOSOMES]
(xmin, xmax) = (np.inf, -np.inf)
chr_label = []
for (index, (snp_chr, p_chr)) in enumerate(p_values):
x = snp_chr + offset[index]
color = colors[np.mod(index, len(colors))]
P.scatter(x, 1.0 / np.maximum(min_p_value, p_chr), c=color, marker='o', edgecolor=color)
xmin = min(xmin, np.min(x))
xmax = max(xmax, np.max(x))
chr_label.append('%s' % (index + 1,))
P.xlim((xmin, xmax))
# Set the locations and labels of the x-label ticks
P.xticks(ndimage.convolve(offset, [0.5, 0.5]), chr_label)
# Calculate significance threshold
if threshold == 'bonferroni':
# Bonferroni correction: divide by the number of SNPs we are considering
num_snps = sum(len(chr_data[0]) for chr_data in p_values)
threshold = p / num_snps
elif isreal(threshold):
# Custom threshold
pass
elif not threshold:
raise ValueError('Unsupported threshold %s' % (threshold,))
if threshold is not None:
# Draw threshold
P.axhline(y=1.0 / threshold, color='red')
开发者ID:orenlivne,项目名称:ober,代码行数:39,代码来源:plots.py
示例5: test_fail
def test_fail(self):
z = np.array([-1j, 1, 0])
res = isreal(z)
assert_array_equal(res, [0, 1, 1])
开发者ID:dyao-vu,项目名称:meta-core,代码行数:4,代码来源:test_type_check.py
示例6: test_pass
def test_pass(self):
z = np.array([-1, 0, 1j])
res = isreal(z)
assert_array_equal(res, [1, 1, 0])
开发者ID:dyao-vu,项目名称:meta-core,代码行数:4,代码来源:test_type_check.py
示例7: _fix_real_abs_gt_1
def _fix_real_abs_gt_1(x):
x = asarray(x)
if any(isreal(x) & (abs(x) > 1)):
x = _tocomplex(x)
return x
开发者ID:animesh,项目名称:scripts,代码行数:5,代码来源:scimath.py
示例8: _fix_int_lt_zero
def _fix_int_lt_zero(x):
x = asarray(x)
if any(isreal(x) & (x < 0)):
x = x * 1.0
return x
开发者ID:animesh,项目名称:scripts,代码行数:5,代码来源:scimath.py
示例9: _fix_real_lt_zero
def _fix_real_lt_zero(x):
x = asarray(x)
if any(isreal(x) & (x < 0)):
x = _tocomplex(x)
return x
开发者ID:animesh,项目名称:scripts,代码行数:5,代码来源:scimath.py
注:本文中的numpy.lib.type_check.isreal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论