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


Python numpy.single方法代码示例

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


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

示例1: do

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def do(self, a, b, tags):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_linalg.py

示例2: test_floating_overflow

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_floating_overflow(self):
        """ Strings containing an unrepresentable float overflow """
        fhalf = np.half('1e10000')
        assert_equal(fhalf, np.inf)
        fsingle = np.single('1e10000')
        assert_equal(fsingle, np.inf)
        fdouble = np.double('1e10000')
        assert_equal(fdouble, np.inf)
        flongdouble = assert_warns(RuntimeWarning, np.longdouble, '1e10000')
        assert_equal(flongdouble, np.inf)

        fhalf = np.half('-1e10000')
        assert_equal(fhalf, -np.inf)
        fsingle = np.single('-1e10000')
        assert_equal(fsingle, -np.inf)
        fdouble = np.double('-1e10000')
        assert_equal(fdouble, -np.inf)
        flongdouble = assert_warns(RuntimeWarning, np.longdouble, '-1e10000')
        assert_equal(flongdouble, -np.inf) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_scalar_ctors.py

示例3: do

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def do(self, a, b):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:test_linalg.py

示例4: align

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def align(image, points):
    """
    :param image:
    :param points:
    :return: aligned image
    """
    # alignment
    origin_point = np.require(np.array(points).reshape((4, 2)), dtype=np.single)
    height = int(max(np.linalg.norm(origin_point[0] - origin_point[1]), np.linalg.norm(origin_point[2] - origin_point[3])))
    width = int(max(np.linalg.norm(origin_point[0] - origin_point[3]), np.linalg.norm(origin_point[1] - origin_point[2])))

    target_point = np.float32([[0, 0], [0, height], [width, height], [width, 0]])
    map_matrix = cv2.getPerspectiveTransform(origin_point, target_point)
    cols = width + 1
    rows = height + 1
    color = cv2.warpPerspective(image, map_matrix, (cols, rows))
    return color 
开发者ID:SunskyF,项目名称:EasyPR-python,代码行数:19,代码来源:align.py

示例5: test_mode_raw

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_mode_raw(self):
        # The factorization is not unique and varies between libraries,
        # so it is not possible to check against known values. Functional
        # testing is a possibility, but awaits the exposure of more
        # of the functions in lapack_lite. Consequently, this test is
        # very limited in scope. Note that the results are in FORTRAN
        # order, hence the h arrays are transposed.
        a = array([[1, 2], [3, 4], [5, 6]], dtype=np.double)
        b = a.astype(np.single)

        # Test double
        h, tau = linalg.qr(a, mode='raw')
        assert_(h.dtype == np.double)
        assert_(tau.dtype == np.double)
        assert_(h.shape == (2, 3))
        assert_(tau.shape == (2,))

        h, tau = linalg.qr(a.T, mode='raw')
        assert_(h.dtype == np.double)
        assert_(tau.dtype == np.double)
        assert_(h.shape == (3, 2))
        assert_(tau.shape == (2,)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:test_linalg.py

示例6: test_precision

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_precision(self):
        # not looping results in a useful stack trace upon failure
        self.do_precision(np.half, np.single)
        self.do_precision(np.half, np.double)
        self.do_precision(np.half, np.longdouble)
        self.do_precision(np.single, np.double)
        self.do_precision(np.single, np.longdouble)
        self.do_precision(np.double, np.longdouble) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_histograms.py

示例7: assert_almost_equal

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw):
    if asarray(a).dtype.type in (single, csingle):
        decimal = single_decimal
    else:
        decimal = double_decimal
    old_assert_almost_equal(a, b, decimal=decimal, **kw) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_linalg.py

示例8: get_real_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def get_real_dtype(dtype):
    return {single: single, double: double,
            csingle: single, cdouble: double}[dtype] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_linalg.py

示例9: get_complex_dtype

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def get_complex_dtype(dtype):
    return {single: csingle, double: cdouble,
            csingle: csingle, cdouble: cdouble}[dtype] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_linalg.py

示例10: get_rtol

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def get_rtol(dtype):
    # Choose a safe rtol
    if dtype in (single, csingle):
        return 1e-5
    else:
        return 1e-11


# used to categorize tests 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:test_linalg.py

示例11: test_sum_initial

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_sum_initial(self):
        # Integer, single axis
        assert_equal(np.sum([3], initial=2), 5)

        # Floating point
        assert_almost_equal(np.sum([0.2], initial=0.1), 0.3)

        # Multiple non-adjacent axes
        assert_equal(np.sum(np.ones((2, 3, 5), dtype=np.int64), axis=(0, 2), initial=2),
                     [12, 12, 12]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_ufunc.py

示例12: test_floating

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_floating(self):
        # Ticket #640, floats from string
        fsingle = np.single('1.234')
        fdouble = np.double('1.234')
        flongdouble = np.longdouble('1.234')
        assert_almost_equal(fsingle, 1.234)
        assert_almost_equal(fdouble, 1.234)
        assert_almost_equal(flongdouble, 1.234) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_scalar_ctors.py

示例13: test_singleton

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_singleton(self):
        ftype = finfo(single)
        ftype2 = finfo(single)
        assert_equal(id(ftype), id(ftype2)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_getlimits.py

示例14: test_compress_small_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def test_compress_small_type(self):
        # Ticket #789, changeset 5217.
        # compress with out argument segfaulted if cannot cast safely
        import numpy as np
        a = np.array([[1, 2], [3, 4]])
        b = np.zeros((2, 1), dtype=np.single)
        try:
            a.compress([True, False], axis=1, out=b)
            raise AssertionError("compress with an out which cannot be "
                                 "safely casted should not return "
                                 "successfully")
        except TypeError:
            pass 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_regression.py

示例15: extract_rmsmap

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import single [as 别名]
def extract_rmsmap(fbin, out_folder=None, force=False):
    """
    Wrapper for rmsmap that outputs _ibl_ephysRmsMap and _ibl_ephysSpectra ALF files

    :param fbin: binary file in spike glx format (will look for attached metatdata)
    :param out_folder: folder in which to store output ALF files. Default uses the folder in which
     the `fbin` file lives.
    :param force: do not re-extract if all ALF files already exist
    :param label: string or list of strings that will be appended to the filename before extension
    :return: None
    """
    _logger.info(str(fbin))
    sglx = spikeglx.Reader(fbin)
    # check if output ALF files exist already:
    if out_folder is None:
        out_folder = Path(fbin).parent
    else:
        out_folder = Path(out_folder)
    alf_object_time = f'_iblqc_ephysTimeRms{sglx.type.upper()}'
    alf_object_freq = f'_iblqc_ephysSpectralDensity{sglx.type.upper()}'
    if alf.io.exists(out_folder, alf_object_time) and \
            alf.io.exists(out_folder, alf_object_freq) and not force:
        _logger.warning(f'{fbin.name} QC already exists, skipping. Use force option to override')
        return
    # crunch numbers
    rms = rmsmap(fbin)
    # output ALF files, single precision with the optional label as suffix before extension
    if not out_folder.exists():
        out_folder.mkdir()
    tdict = {'rms': rms['TRMS'].astype(np.single), 'timestamps': rms['tscale'].astype(np.single)}
    fdict = {'power': rms['spectral_density'].astype(np.single),
             'freqs': rms['fscale'].astype(np.single)}
    out_time = alf.io.save_object_npy(out_folder, object=alf_object_time, dico=tdict)
    out_freq = alf.io.save_object_npy(out_folder, object=alf_object_freq, dico=fdict)
    return out_time + out_freq 
开发者ID:int-brain-lab,项目名称:ibllib,代码行数:37,代码来源:ephysqc.py


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