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


Python numpy.sctypeDict方法代码示例

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


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

示例1: _get_umf_family

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctypeDict [as 别名]
def _get_umf_family(A):
    """Get umfpack family string given the sparse matrix dtype."""
    _families = {
        (np.float64, np.int32): 'di',
        (np.complex128, np.int32): 'zi',
        (np.float64, np.int64): 'dl',
        (np.complex128, np.int64): 'zl'
    }

    f_type = np.sctypeDict[A.dtype.name]
    i_type = np.sctypeDict[A.indices.dtype.name]

    try:
        family = _families[(f_type, i_type)]

    except KeyError:
        msg = 'only float64 or complex128 matrices with int32 or int64' \
            ' indices are supported! (got: matrix: %s, indices: %s)' \
            % (f_type, i_type)
        raise ValueError(msg)

    return family 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:linsolve.py

示例2: test_longdouble

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctypeDict [as 别名]
def test_longdouble(self):
        assert_(np.sctypeDict['f8'] is not np.longdouble)
        assert_(np.sctypeDict['c16'] is not np.clongdouble) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_numerictypes.py

示例3: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctypeDict [as 别名]
def __init__(self, floating=None, shared_memory=False, numpy_dtype=None):
        if numpy_dtype:
            log.debug('Using numpy')
            if numpy_dtype in NUMPY_DEFAULTS:
                numpy_dtype = 'float32'
            if numpy_dtype not in numpy.sctypeDict:
                raise ValueError(BAD_NUMPY_TYPE_ERROR % numpy_dtype)

        if shared_memory and numpy_dtype:
            log.error('Shared memory for numpy arrays is not yet supported.')
            numpy_dtype = None

        if floating is None:
            floating = not shared_memory

        c_type = c_float if floating else c_uint8

        if shared_memory:
            self.bytes = lambda size: RawArray(c_uint8, size)
            self.color_list = lambda size: RawArray(3 * c_type, size)
            # Note https://stackoverflow.com/questions/37705974/

        elif numpy_dtype:
            self.bytes = bytearray
            self.color_list = lambda size: numpy.zeros((size, 3), numpy_dtype)

        else:
            self.bytes = bytearray
            self.color_list = lambda size: [(0, 0, 0)] * size 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:31,代码来源:data_maker.py

示例4: impl

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctypeDict [as 别名]
def impl(self, x, y):
        x = numpy.asarray(x)
        y = numpy.asarray(y)
        if all(a.dtype in discrete_types for a in (x, y)):
            return numpy.sctypeDict[config.floatX](float(x) / y)
        else:
            return x / y 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:9,代码来源:basic.py

示例5: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import sctypeDict [as 别名]
def __init__(self, A):
        if not (isspmatrix_csc(A) or isspmatrix_csr(A)):
            A = csc_matrix(A)
            warn('spsolve requires A be CSC or CSR matrix format',
                    SparseEfficiencyWarning)

        A.sort_indices()
        A = A.asfptype()  # upcast to a floating point format

        M, N = A.shape
        if (M != N):
            raise ValueError("matrix must be square (has shape %s)" % ((M, N),))

        f_type = np.sctypeDict[A.dtype.name]
        i_type = np.sctypeDict[A.indices.dtype.name]
        try:
            family = _families[(f_type, i_type)]

        except KeyError:
            msg = 'only float64 or complex128 matrices with int32 or int64' \
                ' indices are supported! (got: matrix: %s, indices: %s)' \
                % (f_type, i_type)
            raise ValueError(msg)

        self.umf = UmfpackContext(family)
        self.umf.numeric(A)

        self._A = A
        self._L = None
        self._U = None
        self._P = None
        self._Q = None
        self._R = None 
开发者ID:scikit-umfpack,项目名称:scikit-umfpack,代码行数:35,代码来源:interface.py


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