当前位置: 首页>>代码示例>>Python>>正文


Python numeric.asarray方法代码示例

本文整理汇总了Python中numpy.core.numeric.asarray方法的典型用法代码示例。如果您正苦于以下问题:Python numeric.asarray方法的具体用法?Python numeric.asarray怎么用?Python numeric.asarray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy.core.numeric的用法示例。


在下文中一共展示了numeric.asarray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fix_int_lt_zero

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
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
    --------
    >>> np.lib.scimath._fix_int_lt_zero([1,2])
    array([1, 2])

    >>> np.lib.scimath._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:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:scimath.py

示例2: _fix_real_abs_gt_1

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
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:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:scimath.py

示例3: _fix_real_lt_zero

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
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:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:scimath.py

示例4: _fix_real_abs_gt_1

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
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:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:scimath.py

示例5: __array__

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
def __array__(self, t=None):
        if t:
            return NX.asarray(self.coeffs, t)
        else:
            return NX.asarray(self.coeffs) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:polynomial.py

示例6: _fix_real_lt_zero

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
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:Frank-qlu,项目名称:recruit,代码行数:28,代码来源:scimath.py

示例7: iscomplexobj

# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import asarray [as 别名]
def iscomplexobj(x):
    """
    Check for a complex type or an array of complex numbers.

    The type of the input is checked, not the value. Even if the input
    has an imaginary part equal to zero, `iscomplexobj` evaluates to True.

    Parameters
    ----------
    x : any
        The input can be of any type and shape.

    Returns
    -------
    iscomplexobj : bool
        The return value, True if `x` is of a complex type or has at least
        one complex element.

    See Also
    --------
    isrealobj, iscomplex

    Examples
    --------
    >>> np.iscomplexobj(1)
    False
    >>> np.iscomplexobj(1+0j)
    True
    >>> np.iscomplexobj([3, 1+0j, True])
    True

    """
    try:
        dtype = x.dtype
        type_ = dtype.type
    except AttributeError:
        type_ = asarray(x).dtype.type
    return issubclass(type_, _nx.complexfloating) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:40,代码来源:type_check.py


注:本文中的numpy.core.numeric.asarray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。