Skip to content

Serializers

Source

A script for serializers in the careamics package.

array_to_json(arr)

Convert an array to a list and then to a JSON string.

Parameters:

  • arr (Union[ndarray, Tensor]) –

    Array to be serialized.

Returns:

  • str

    JSON string representing the array.

to_numpy(lst)

Deserialize a list or string representing a list into np.ndarray.

Parameters:

  • lst (list) –

    List or string representing a list with the array content to be deserialized.

Returns:

  • ndarray

    The deserialized array.

to_torch(lst)

Deserialize list or string representing a list into torch.Tensor.

Parameters:

  • lst (Union[str, list]) –

    List or string representing a list swith the array content to be deserialized.

Returns:

  • Tensor

    The deserialized tensor.