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


Python ndarray.tobytes方法代碼示例

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


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

示例1: __getstate__

# 需要導入模塊: from numpy import ndarray [as 別名]
# 或者: from numpy.ndarray import tobytes [as 別名]
def __getstate__(self):
        """Return the internal state of the masked array, for pickling
        purposes.

        """
        cf = 'CF'[self.flags.fnc]
        state = (1,
                 self.shape,
                 self.dtype,
                 self.flags.fnc,
                 self._data.tobytes(cf),
                 # self._data.tolist(),
                 getmaskarray(self).tobytes(cf),
                 # getmaskarray(self).tolist(),
                 self._fill_value,
                 )
        return state 
開發者ID:amoose136,項目名稱:radar,代碼行數:19,代碼來源:core.py

示例2: tostring

# 需要導入模塊: from numpy import ndarray [as 別名]
# 或者: from numpy.ndarray import tobytes [as 別名]
def tostring(self, fill_value=None, order='C'):
        """
        This function is a compatibility alias for tobytes. Despite its name it
        returns bytes not strings.
        """

        return self.tobytes(fill_value, order='C') 
開發者ID:amoose136,項目名稱:radar,代碼行數:9,代碼來源:core.py

示例3: tobytes

# 需要導入模塊: from numpy import ndarray [as 別名]
# 或者: from numpy.ndarray import tobytes [as 別名]
def tobytes(self, fill_value=None, order='C'):
        """
        Return the array data as a string containing the raw bytes in the array.

        The array is filled with a fill value before the string conversion.

        .. versionadded:: 1.9.0

        Parameters
        ----------
        fill_value : scalar, optional
            Value used to fill in the masked values. Deafult is None, in which
            case `MaskedArray.fill_value` is used.
        order : {'C','F','A'}, optional
            Order of the data item in the copy. Default is 'C'.

            - 'C'   -- C order (row major).
            - 'F'   -- Fortran order (column major).
            - 'A'   -- Any, current order of array.
            - None  -- Same as 'A'.

        See Also
        --------
        ndarray.tobytes
        tolist, tofile

        Notes
        -----
        As for `ndarray.tobytes`, information about the shape, dtype, etc.,
        but also about `fill_value`, will be lost.

        Examples
        --------
        >>> x = np.ma.array(np.array([[1, 2], [3, 4]]), mask=[[0, 1], [1, 0]])
        >>> x.tobytes()
        '\\x01\\x00\\x00\\x00?B\\x0f\\x00?B\\x0f\\x00\\x04\\x00\\x00\\x00'

        """
        return self.filled(fill_value).tobytes(order=order) 
開發者ID:amoose136,項目名稱:radar,代碼行數:41,代碼來源:core.py

示例4: __getstate__

# 需要導入模塊: from numpy import ndarray [as 別名]
# 或者: from numpy.ndarray import tobytes [as 別名]
def __getstate__(self):
        """Return the internal state of the masked array, for pickling
        purposes.

        """
        cf = 'CF'[self.flags.fnc]
        data_state = super(MaskedArray, self).__reduce__()[2]
        return data_state + (getmaskarray(self).tobytes(cf), self._fill_value) 
開發者ID:orchestor,項目名稱:deliver,代碼行數:10,代碼來源:core.py


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