Пример #1
0
    def to_numpy(self, selector, vertex_range=None, axis=0):
        """Return context data as numpy array

        Args:
        selector (str): Describes how to select values of context.
            See more details in derived context class.
        vertex_range (dict): optional, default to None.
            Works as slicing. The expression {'begin': m, 'end': n} select a portion
            of vertices from `m` to, but not including `n`. Type of `m`, `n` must be identical with vertices'
            oid type.
            Omitting the first index starts the slice at the beginning of the vertices,
            and omitting the second index extends the slice to the end of the vertices.
            Note the comparision is not based on numeric order, but on alphabetic order.
        axis (int): optional, default to 0.

        Returns:
            numpy.ndarray.
        """
        self._check_unmodified()
        selector = self._transform_selector(selector)
        vertex_range = utils.transform_vertex_range(vertex_range)

        op = dag_utils.context_to_numpy(self, selector, vertex_range, axis)
        raw_values = op.eval()
        return decode_numpy(raw_values)
Пример #2
0
    def to_numpy(self, selector, vertex_range=None):
        """Select some elements of the graph and output to numpy.

        Args:
            selector (str): Select a portion of graph as a numpy.ndarray.
            vertex_range(dict, optional): Slice vertices. Defaults to None.
        Returns:
            `numpy.ndarray`
        """
        self.check_unmodified()
        selector = transform_labeled_vertex_property_data_selector(self, selector)
        vertex_range = transform_vertex_range(vertex_range)
        op = graph_to_numpy(self, selector, vertex_range)
        ret = op.eval()
        return decode_numpy(ret)
Пример #3
0
    def to_numpy(self, selector, vertex_range=None):
        """Select some elements of the graph and output to numpy.

        Args:
            selector (str): Select a portion of graph as a numpy.ndarray.
            vertex_range(dict, optional): Slice vertices. Defaults to None.
        Returns:
            `numpy.ndarray`
        """
        check_argument(self.graph_type == types_pb2.ARROW_PROPERTY)
        self._ensure_loaded()
        self._check_unmodified()
        selector = utils.transform_labeled_vertex_property_data_selector(
            self, selector)
        vertex_range = utils.transform_vertex_range(vertex_range)
        op = dag_utils.graph_to_numpy(self, selector, vertex_range)
        ret = op.eval()
        return utils.decode_numpy(ret)