MCPcopy Create free account
hub / github.com/alibaba/graph-learn / _reshape

Method _reshape

graphlearn/python/data/values.py:138–151  ·  view source on GitHub ↗

Reshape for value when `shape` is not None.

(self, value, expand_shape=False)

Source from the content-addressed store, hash-verified

136 self._graph = graph
137
138 def _reshape(self, value, expand_shape=False):
139 """ Reshape for value when `shape` is not None.
140 """
141 if value is None or not value.size:
142 return value
143 if not isinstance(value, np.ndarray):
144 raise ValueError("{} must be a numpy.ndarray.".format(value))
145 if not self._shape:
146 return value
147 if not isinstance(self._shape, tuple):
148 raise ValueError("shape must be a tuple, got {}." .format(self._shape))
149 if expand_shape:
150 return np.reshape(value, self._shape + (-1, )) # pylint: disable=bad-whitespace
151 return np.reshape(value, self._shape)
152
153 def _init(self):
154 if self._inited:

Callers 11

int_attrsMethod · 0.95
float_attrsMethod · 0.95
string_attrsMethod · 0.95
weightsMethod · 0.95
labelsMethod · 0.95
__init__Method · 0.80
idsMethod · 0.80
__init__Method · 0.80
edge_idsMethod · 0.80
src_idsMethod · 0.80
dst_idsMethod · 0.80

Calls 1

reshapeMethod · 0.80

Tested by

no test coverage detected