# Path: fedjax/core/serialization.py
# def save_state(state, path):
# def load_state(path):
# def _ndarray_to_bytes(arr):
# def _dtype_from_name(name):
# def _ndarray_from_bytes(data):
# def _bytes_ndarray_to_bytes(x):
# def _object_ndarray_from_bytes(data):
# def _msgpack_ext_pack(x):
# def _msgpack_ext_unpack(code, data):
# def msgpack_serialize(pytree):
# def msgpack_deserialize(encoded_pytree):
# class _MsgpackExtType(enum.IntEnum):


from absl.testing import absltest
from fedjax.core import serialization
import numpy as np
import numpy.testing as npt
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for fedjax.core.serialization."""



class SerializationTest(absltest.TestCase):

  def test_dict(self):
    original = {
        'int32':
            np.arange(4, dtype=np.int32).reshape([2, 2]),
        'float64':
            -np.arange(4, dtype=np.float64).reshape([1, 4]),
        'bytes':
            np.array([b'a', b'bc', b'def'], dtype=np.object).reshape([3, 1]),
    }
    output = serialization.msgpack_deserialize(

# Path: fedjax/core/serialization.py
# def save_state(state, path):
# def load_state(path):
# def _ndarray_to_bytes(arr):
# def _dtype_from_name(name):
# def _ndarray_from_bytes(data):
# def _bytes_ndarray_to_bytes(x):
# def _object_ndarray_from_bytes(data):
# def _msgpack_ext_pack(x):
# def _msgpack_ext_unpack(code, data):
# def msgpack_serialize(pytree):
# def msgpack_deserialize(encoded_pytree):
# class _MsgpackExtType(enum.IntEnum):


# Path: fedjax/core/serialization_test.py
from absl.testing import absltest
from fedjax.core import serialization
import numpy as np
import numpy.testing as npt

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for fedjax.core.serialization."""



class SerializationTest(absltest.TestCase):

  def test_dict(self):
    original = {
        'int32':
            np.arange(4, dtype=np.int32).reshape([2, 2]),
        'float64':
            -np.arange(4, dtype=np.float64).reshape([1, 4]),
        'bytes':
            np.array([b'a', b'bc', b'def'], dtype=np.object).reshape([3, 1]),
    }
    output = serialization.msgpack_deserialize(

        serialization.msgpack_serialize(original))