core.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:sparse 作者: mrocklin 项目源码 文件源码
def broadcast_to(self, shape):
        """
        Performs the equivalent of np.broadcast_to for COO.
        Parameters
        ----------
        shape : tuple[int]
            The shape to broadcast the data to.
        Returns
        -------
            The broadcasted sparse array.
        Raises
        ------
        ValueError
            If the operand cannot be broadcast to the given shape.
        """
        result_shape = self._get_broadcast_shape(self.shape, shape, is_result=True)
        params = self._get_broadcast_parameters(self.shape, result_shape)
        coords, data = self._get_expanded_coords_data(self.coords, self.data, params, result_shape)

        return COO(coords, data, shape=result_shape, has_duplicates=self.has_duplicates,
                   sorted=self.sorted)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号