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

Method format_attrs

graphlearn/python/data/decoder.py:209–228  ·  view source on GitHub ↗

Reshape and format attributes with int_attr_num, float_attr_num and string_attr_num calculated by decoder.attr_types. Return: Reshaped int_attrs, float_attrs, string_attrs

(self, int_attrs, float_attrs, string_attrs)

Source from the content-addressed store, hash-verified

207 return self._fspec
208
209 def format_attrs(self, int_attrs, float_attrs, string_attrs):
210 """ Reshape and format attributes with int_attr_num, float_attr_num
211 and string_attr_num calculated by decoder.attr_types.
212
213 Return:
214 Reshaped int_attrs, float_attrs, string_attrs
215 """
216 if int_attrs is not None:
217 int_attrs = int_attrs.reshape(-1, self._int_attr_num)
218
219 if float_attrs is not None:
220 float_attrs = float_attrs.reshape(-1, self._float_attr_num)
221
222 if string_attrs is not None:
223 string_attrs = np.array([s.decode('utf-8', errors='ignore') for s in string_attrs])
224 if (sys.version_info[0] == '3'):
225 # For Python 3.X, encode string attributes as Unicode.
226 string_attrs = string_attrs.astype('U')
227
228 return int_attrs, float_attrs, string_attrs

Callers 2

lookup_nodesMethod · 0.80
lookup_edgesMethod · 0.80

Calls 1

reshapeMethod · 0.80

Tested by

no test coverage detected