當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。