MCPcopy Index your code
hub / github.com/apache/fory / write

Method write

python/pyfory/serializer.py:896–912  ·  view source on GitHub ↗
(self, write_context, value)

Source from the content-addressed store, hash-verified

894
895class PythonNDArraySerializer(NDArraySerializer):
896 def write(self, write_context, value):
897 dtype_info = _np_dtypes_dict.get(value.dtype)
898 if dtype_info is not None and value.ndim == 1:
899 super().write(write_context, value)
900 return
901
902 dtype = value.dtype
903 write_context.write_string(dtype.str)
904 write_context.write_var_uint32(len(value.shape))
905 for dim in value.shape:
906 write_context.write_var_uint32(dim)
907 if dtype.kind == "O":
908 write_context.write_varint32(len(value))
909 for item in value:
910 write_context.write_ref(item)
911 else:
912 write_context.write_buffer_object(NDArrayBufferObject(value))
913
914 def read(self, read_context):
915 reader_index = read_context.get_reader_index()

Callers

nothing calls this directly

Calls 8

NDArrayBufferObjectClass · 0.85
write_varint32Method · 0.80
write_refMethod · 0.80
write_buffer_objectMethod · 0.80
getMethod · 0.65
writeMethod · 0.65
write_stringMethod · 0.45
write_var_uint32Method · 0.45

Tested by

no test coverage detected