當前位置: 首頁>>代碼示例>>Python>>正文


Python ma.zeros方法代碼示例

本文整理匯總了Python中numpy.ma.zeros方法的典型用法代碼示例。如果您正苦於以下問題:Python ma.zeros方法的具體用法?Python ma.zeros怎麽用?Python ma.zeros使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.ma的用法示例。


在下文中一共展示了ma.zeros方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: empty

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def empty(self, process_tile):
        """
        Return empty data.

        Parameters
        ----------
        process_tile : ``BufferedTile``
            must be member of process ``TilePyramid``

        Returns
        -------
        empty data : array
            empty array with data type given in output parameters
        """
        bands = (
            self.output_params["bands"]
            if "bands" in self.output_params
            else PNG_DEFAULT_PROFILE["count"]
        )
        return ma.masked_array(
            data=ma.zeros((bands, ) + process_tile.shape),
            mask=ma.zeros((bands, ) + process_tile.shape),
            dtype=PNG_DEFAULT_PROFILE["dtype"]
        ) 
開發者ID:ungarj,項目名稱:mapchete,代碼行數:26,代碼來源:png.py

示例2: comp_g

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def comp_g(dert__, odd):
    g__ = dert__[0]
    a__ = dert__[1:]

    # loop through each pair of comparands in a kernel
    dgy__ = ma.zeros(np.subtract(g.shape, rng))
    dgx__ = ma.zeros(np.subtract(g.shape, rng))
    for x_coeff, y_coeff, (ts, _ts) in zip(X_COEFFS[rng],
                                           Y_COEFFS[rng],
                                           TRANSLATING_SLICES_PAIRS_[rng]):
        # find angle differences
        da__ = angle_diff(a__[ts], a__[_ts])

        # compute dg: dg = g - _g * cos(da) at each position
        dg__ = g__[ts] - g__[_ts] * da__[1]

        # accumulate dgy, dgx
        dgx__ += dg__ * x_coeff
        dgy__ += dg__ * y_coeff

    gg__ = ma.hypot(dgy__, dgx__)

    return ma.stack((g__, gg__, dgy__, dgx__)) 
開發者ID:boris-kz,項目名稱:CogAlg,代碼行數:25,代碼來源:intra_comp_ts.py

示例3: test_repack_fields

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_repack_fields(self):
        dt = np.dtype('u1,f4,i8', align=True)
        a = np.zeros(2, dtype=dt)

        assert_equal(repack_fields(dt), np.dtype('u1,f4,i8'))
        assert_equal(repack_fields(a).itemsize, 13)
        assert_equal(repack_fields(repack_fields(dt), align=True), dt)

        # make sure type is preserved
        dt = np.dtype((np.record, dt))
        assert_(repack_fields(dt).type is np.record) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_recfunctions.py

示例4: test_simple_flexible

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_simple_flexible(self):
        # Test recursive_fill_fields on flexible-array
        a = np.array([(1, 10.), (2, 20.)], dtype=[('A', int), ('B', float)])
        b = np.zeros((3,), dtype=a.dtype)
        test = recursive_fill_fields(a, b)
        control = np.array([(1, 10.), (2, 20.), (0, 0.)],
                           dtype=[('A', int), ('B', float)])
        assert_equal(test, control) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_recfunctions.py

示例5: test_masked_flexible

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_masked_flexible(self):
        # Test recursive_fill_fields on masked flexible-array
        a = ma.array([(1, 10.), (2, 20.)], mask=[(0, 1), (1, 0)],
                     dtype=[('A', int), ('B', float)])
        b = ma.zeros((3,), dtype=a.dtype)
        test = recursive_fill_fields(a, b)
        control = ma.array([(1, 10.), (2, 20.), (0, 0.)],
                           mask=[(0, 1), (1, 0), (0, 0)],
                           dtype=[('A', int), ('B', float)])
        assert_equal(test, control) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_recfunctions.py

示例6: test_different_field_order

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_different_field_order(self):
        # gh-8940
        a = np.zeros(3, dtype=[('a', 'i4'), ('b', 'f4'), ('c', 'u1')])
        b = np.ones(3, dtype=[('c', 'u1'), ('b', 'f4'), ('a', 'i4')])
        # this should not give a FutureWarning:
        j = join_by(['c', 'b'], a, b, jointype='inner', usemask=False)
        assert_equal(j.dtype.names, ['b', 'c', 'a1', 'a2']) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_recfunctions.py

示例7: test_duplicate_keys

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_duplicate_keys(self):
        a = np.zeros(3, dtype=[('a', 'i4'), ('b', 'f4'), ('c', 'u1')])
        b = np.ones(3, dtype=[('c', 'u1'), ('b', 'f4'), ('a', 'i4')])
        assert_raises(ValueError, join_by, ['a', 'b', 'b'], a, b) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:6,代碼來源:test_recfunctions.py

示例8: test_simple_flexible

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_simple_flexible(self):
        "Test recursive_fill_fields on flexible-array"
        a = np.array([(1, 10.), (2, 20.)], dtype=[('A', int), ('B', float)])
        b = np.zeros((3,), dtype=a.dtype)
        test = recursive_fill_fields(a, b)
        control = np.array([(1, 10.), (2, 20.), (0, 0.)],
                           dtype=[('A', int), ('B', float)])
        assert_equal(test, control)
    # 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:11,代碼來源:test_recfunctions.py

示例9: test_masked_flexible

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def test_masked_flexible(self):
        "Test recursive_fill_fields on masked flexible-array"
        a = ma.array([(1, 10.), (2, 20.)], mask=[(0, 1), (1, 0)],
                     dtype=[('A', int), ('B', float)])
        b = ma.zeros((3,), dtype=a.dtype)
        test = recursive_fill_fields(a, b)
        control = ma.array([(1, 10.), (2, 20.), (0, 0.)],
                           mask=[(0, 1), (1, 0), (0, 0)],
                           dtype=[('A', int), ('B', float)])
        assert_equal(test, control)
    # 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:test_recfunctions.py

示例10: _draw_steps_pre

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def _draw_steps_pre(self, renderer, gc, path, trans):
        vertices = self._xy
        steps = ma.zeros((2 * len(vertices) - 1, 2), np.float_)

        steps[0::2, 0], steps[1::2, 0] = vertices[:, 0], vertices[:-1, 0]
        steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1]

        path = Path(steps)
        path = path.transformed(self.get_transform())
        self._lineFunc(renderer, gc, path, IdentityTransform()) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:lines.py

示例11: _draw_steps_post

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def _draw_steps_post(self, renderer, gc, path, trans):
        vertices = self._xy
        steps = ma.zeros((2 * len(vertices) - 1, 2), np.float_)

        steps[::2, 0], steps[1:-1:2, 0] = vertices[:, 0], vertices[1:, 0]
        steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1]

        path = Path(steps)
        path = path.transformed(self.get_transform())
        self._lineFunc(renderer, gc, path, IdentityTransform()) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:lines.py

示例12: _draw_steps_mid

# 需要導入模塊: from numpy import ma [as 別名]
# 或者: from numpy.ma import zeros [as 別名]
def _draw_steps_mid(self, renderer, gc, path, trans):
        vertices = self._xy
        steps = ma.zeros((2 * len(vertices), 2), np.float_)

        steps[1:-1:2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0])
        steps[2::2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0])
        steps[0, 0] = vertices[0, 0]
        steps[-1, 0] = vertices[-1, 0]
        steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1]

        path = Path(steps)
        path = path.transformed(self.get_transform())
        self._lineFunc(renderer, gc, path, IdentityTransform()) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:lines.py


注:本文中的numpy.ma.zeros方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。