当前位置: 首页>>代码示例>>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;未经允许,请勿转载。