# Path: envlogger/converters/codec.py
# _SCALAR_DIM_SIZE = -438
# def _python_int_to_bytes(py_int: int) -> bytes:
# def _set_datum_values_from_scalar(scalar: Union[ScalarNumber, bool, str, bytes],
#                                   datum: storage_pb2.Datum) -> bool:
# def _set_datum_values_from_array(array: np.ndarray,
#                                  values: storage_pb2.Datum.Values) -> None:
# def encode(
#     user_data: Union[np.ndarray, List[Any], Tuple[Any, ...], Dict[str, Any]]
# ) -> storage_pb2.Data:
# def decode_datum(
#     datum: storage_pb2.Datum
# ) -> Union[np.ndarray, ScalarNumber, bool, str, bytes]:
#     def from_bigint(int_bytes):
# def decode(
#     user_data: storage_pb2.Data
# ) -> Optional[Union[ScalarNumber, bool, str, bytes, np.ndarray, List[Any],


from absl.testing import absltest
from absl.testing import parameterized
from envlogger.converters import codec
from envlogger.proto import storage_pb2
import numpy as np
    user_data.datum.values.uint16_values = b'\xa1\xb2'
    np.testing.assert_equal(
        codec.decode(user_data), np.array([41394], dtype=np.uint16))

  def test_decode_two_uint16_elem_ndarray(self):
    user_data = storage_pb2.Data()
    user_data.datum.shape.dim.add().size = 2
    user_data.datum.values.uint16_values = b'\xa1\xb2\xc3\xd4'
    np.testing.assert_equal(
        codec.decode(user_data), np.array([41394, 50132], dtype=np.uint16))

  # Multi-dimensional arrays.

  def test_encode_2d_int64_elem_ndarray(self):
    """A 2D np int64 array should also be reprentable."""
    expected = storage_pb2.Data()
    datum = expected.datum
    datum.shape.dim.add().size = 2
    datum.shape.dim.add().size = 3
    datum.values.int64_values.extend([1, 3, 5, 7, 9, 11])
    self.assertEqual(codec.encode(np.array([[1, 3, 5], [7, 9, 11]])), expected)

  def test_encode_2d_double_elem_ndarray(self):
    """A 2D np float64 array should also be reprentable."""
    expected = storage_pb2.Data()
    datum = expected.datum
    datum.shape.dim.add().size = 3
    datum.shape.dim.add().size = 2
    datum.values.double_values.extend([10.0, 8.0, 6.0, 4.0, 2.0, 0.0])
    self.assertEqual(

# Path: envlogger/converters/codec.py
# _SCALAR_DIM_SIZE = -438
# def _python_int_to_bytes(py_int: int) -> bytes:
# def _set_datum_values_from_scalar(scalar: Union[ScalarNumber, bool, str, bytes],
#                                   datum: storage_pb2.Datum) -> bool:
# def _set_datum_values_from_array(array: np.ndarray,
#                                  values: storage_pb2.Datum.Values) -> None:
# def encode(
#     user_data: Union[np.ndarray, List[Any], Tuple[Any, ...], Dict[str, Any]]
# ) -> storage_pb2.Data:
# def decode_datum(
#     datum: storage_pb2.Datum
# ) -> Union[np.ndarray, ScalarNumber, bool, str, bytes]:
#     def from_bigint(int_bytes):
# def decode(
#     user_data: storage_pb2.Data
# ) -> Optional[Union[ScalarNumber, bool, str, bytes, np.ndarray, List[Any],


# Path: envlogger/converters/codec_test.py
from absl.testing import absltest
from absl.testing import parameterized
from envlogger.converters import codec
from envlogger.proto import storage_pb2
import numpy as np

    user_data.datum.values.uint16_values = b'\xa1\xb2'
    np.testing.assert_equal(
        codec.decode(user_data), np.array([41394], dtype=np.uint16))

  def test_decode_two_uint16_elem_ndarray(self):
    user_data = storage_pb2.Data()
    user_data.datum.shape.dim.add().size = 2
    user_data.datum.values.uint16_values = b'\xa1\xb2\xc3\xd4'
    np.testing.assert_equal(
        codec.decode(user_data), np.array([41394, 50132], dtype=np.uint16))

  # Multi-dimensional arrays.

  def test_encode_2d_int64_elem_ndarray(self):
    """A 2D np int64 array should also be reprentable."""
    expected = storage_pb2.Data()
    datum = expected.datum
    datum.shape.dim.add().size = 2
    datum.shape.dim.add().size = 3
    datum.values.int64_values.extend([1, 3, 5, 7, 9, 11])
    self.assertEqual(codec.encode(np.array([[1, 3, 5], [7, 9, 11]])), expected)

  def test_encode_2d_double_elem_ndarray(self):
    """A 2D np float64 array should also be reprentable."""
    expected = storage_pb2.Data()
    datum = expected.datum
    datum.shape.dim.add().size = 3
    datum.shape.dim.add().size = 2
    datum.values.double_values.extend([10.0, 8.0, 6.0, 4.0, 2.0, 0.0])
    self.assertEqual(

        codec.encode(np.array([[10.0, 8.0], [6.0, 4.0], [2.0, 0.0]])), expected)