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


Python numpy.issubsctype方法代码示例

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


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

示例1: test_reconstruction

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def test_reconstruction(projector):
    """Test RayTransform for reconstruction."""
    if (
        isinstance(projector.geometry, odl.tomo.ConeBeamGeometry)
        and projector.geometry.pitch != 0
    ):
        pytest.skip('reconstruction with CG is hopeless with so few angles')

    # Create Shepp-Logan phantom
    vol = odl.phantom.shepp_logan(projector.domain, modified=True)

    # Project data
    projections = projector(vol)

    # Reconstruct using ODL
    recon = projector.domain.zero()
    odl.solvers.conjugate_gradient_normal(projector, recon, projections,
                                          niter=20)

    # Make sure the result is somewhat close to the actual result
    maxerr = vol.norm() * 0.5
    if np.issubsctype(projector.domain.dtype, np.complexfloating):
        # Error has double the amount of components practically
        maxerr *= np.sqrt(2)
    assert recon.dist(vol) < maxerr 
开发者ID:odlgroup,项目名称:odl,代码行数:27,代码来源:ray_transform_slow_test.py

示例2: _copy_array_if_base_present

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def _copy_array_if_base_present(a):
    """
    Copy the array if its base points to a parent array.
    """
    if a.base is not None:
        return a.copy()
    elif np.issubsctype(a, np.float32):
        return np.array(a, dtype=np.double)
    else:
        return a 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:hierarchy.py

示例3: _copy_array_if_base_present

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def _copy_array_if_base_present(a):
    """
    Copies the array if its base points to a parent array.
    """
    if a.base is not None:
        return a.copy()
    elif np.issubsctype(a, np.float32):
        return np.array(a, dtype=np.double)
    else:
        return a 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:distance.py

示例4: is_numeric_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def is_numeric_dtype(dtype):
    """Return ``True`` if ``dtype`` is a numeric type."""
    dtype = np.dtype(dtype)
    return np.issubsctype(getattr(dtype, 'base', None), np.number) 
开发者ID:odlgroup,项目名称:odl,代码行数:6,代码来源:utility.py

示例5: is_int_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def is_int_dtype(dtype):
    """Return ``True`` if ``dtype`` is an integer type."""
    dtype = np.dtype(dtype)
    return np.issubsctype(getattr(dtype, 'base', None), np.integer) 
开发者ID:odlgroup,项目名称:odl,代码行数:6,代码来源:utility.py

示例6: is_real_floating_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def is_real_floating_dtype(dtype):
    """Return ``True`` if ``dtype`` is a real floating point type."""
    dtype = np.dtype(dtype)
    return np.issubsctype(getattr(dtype, 'base', None), np.floating) 
开发者ID:odlgroup,项目名称:odl,代码行数:6,代码来源:utility.py

示例7: is_complex_floating_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def is_complex_floating_dtype(dtype):
    """Return ``True`` if ``dtype`` is a complex floating point type."""
    dtype = np.dtype(dtype)
    return np.issubsctype(getattr(dtype, 'base', None), np.complexfloating) 
开发者ID:odlgroup,项目名称:odl,代码行数:6,代码来源:utility.py

示例8: slice

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import issubsctype [as 别名]
def slice(self, columns_specifier):
        """Locate a subset of design matrix columns, specified symbolically.

        A patsy design matrix has two levels of structure: the individual
        columns (which are named), and the :ref:`terms <formulas>` in
        the formula that generated those columns. This is a one-to-many
        relationship: a single term may span several columns. This method
        provides a user-friendly API for locating those columns.

        (While we talk about columns here, this is probably most useful for
        indexing into other arrays that are derived from the design matrix,
        such as regression coefficients or covariance matrices.)

        The `columns_specifier` argument can take a number of forms:

        * A term name
        * A column name
        * A :class:`Term` object
        * An integer giving a raw index
        * A raw slice object

        In all cases, a Python :func:`slice` object is returned, which can be
        used directly for indexing.

        Example::

          y, X = dmatrices("y ~ a", demo_data("y", "a", nlevels=3))
          betas = np.linalg.lstsq(X, y)[0]
          a_betas = betas[X.design_info.slice("a")]

        (If you want to look up a single individual column by name, use
        ``design_info.column_name_indexes[name]``.)
        """
        if isinstance(columns_specifier, slice):
            return columns_specifier
        if np.issubsctype(type(columns_specifier), np.integer):
            return slice(columns_specifier, columns_specifier + 1)
        if (self.term_slices is not None
            and columns_specifier in self.term_slices):
            return self.term_slices[columns_specifier]
        if columns_specifier in self.term_name_slices:
            return self.term_name_slices[columns_specifier]
        if columns_specifier in self.column_name_indexes:
            idx = self.column_name_indexes[columns_specifier]
            return slice(idx, idx + 1)
        raise PatsyError("unknown column specified '%s'"
                            % (columns_specifier,)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:49,代码来源:design_info.py


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