deltakit.explorer.types.DataString#
- class deltakit.explorer.types.DataString(data: bytes | str = b'')#
Bases:
objectData string is a normal string which encodes arbitrary binary data (e.g. Stim circuit file, or measurements data). These strings may be used instead of file names in any calls to QEC Explorer client. The server recognises these strings by detecting a prefix, and treats them as data.
DataString class provides methods to generate such string from files, strings and byte strings, as well as methods to parse them when the server responds with a data string.
To generate a data string from a file:
dstring_object = DataString.from_file(path_to_file) dstring = str(dstring_object) # generate a data string len(dstring_object.data) # raw data is stored in `DataString.data` fieldTo parse a data string:
dstring_object = DataString.from_data_string(datastring)To generate a data string from a variable:
bytes_content = b"1,1,0,1,0\n1,1,1,0,1\n" csv_measurements = DataString(bytes_content) b8_measurements = qec_client.convert_format( input_file=csv_measurements, input_format="csv", output_format="b8", ) b8_measurements.to_file("data.b8")To convert the content of a DataString object to a string:
string = data_string.to_string()Data strings result in additional processing on client and server side, they introduce redundancy in data, and they also increase network traffic between client and server nodes.
Construct an object from the data.
- Parameters:
data (bytes | str, optional) – bytes data to be encode, or a string, interpreted as UTF-8. Defaults to b””.
Methods#
Parse the data string into a bytes object. |
|
Create a data string from a file name. |
|
Check that the string corresponds to a data string syntax. |
|
Dump data to a file. |
|
Converts DataString object to string. |