本文整理汇总了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
示例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
示例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
示例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)
示例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)
示例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)
示例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)
示例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,))