# Path: enn/extra/kmeans.py
# class KMeansOutput(NamedTuple):
# class KMeansCluster:
# class _TrainingState(NamedTuple):
#   def fit(self, x: chex.Array) -> KMeansOutput:
# def get_classes_and_distances(
#     x: chex.Array, centroids: chex.Array) -> Tuple[chex.Array, chex.Array]:
# def _safe_divide(numerator: chex.Array, denominator: chex.Array) -> chex.Array:
# def kmeans_iteration(x: chex.Array, state: _TrainingState) -> _TrainingState:
# def compute_output(x: chex.Array, state: _TrainingState) -> KMeansOutput:


from absl.testing import absltest
from absl.testing import parameterized
from enn.extra import kmeans
import chex
import haiku as hk
import jax
import jax.numpy as jnp
# Copyright 2021 DeepMind Technologies Limited. All Rights Reserved.
#
# 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 ENN Networks."""



class KmeansTest(parameterized.TestCase):

  @parameterized.product(
      num_x=[10, 100],
      dim_x=[1, 5],
      num_centroids=[1, 3],
  )
  def test_kmeans_runs(self, num_x: int, dim_x: int, num_centroids: int):
    """Test that KMeans clustering runs and has no nan."""
    rng = hk.PRNGSequence(999)
    x = jax.random.normal(next(rng), [num_x, dim_x])

# Path: enn/extra/kmeans.py
# class KMeansOutput(NamedTuple):
# class KMeansCluster:
# class _TrainingState(NamedTuple):
#   def fit(self, x: chex.Array) -> KMeansOutput:
# def get_classes_and_distances(
#     x: chex.Array, centroids: chex.Array) -> Tuple[chex.Array, chex.Array]:
# def _safe_divide(numerator: chex.Array, denominator: chex.Array) -> chex.Array:
# def kmeans_iteration(x: chex.Array, state: _TrainingState) -> _TrainingState:
# def compute_output(x: chex.Array, state: _TrainingState) -> KMeansOutput:


# Path: enn/extra/kmeans_test.py
from absl.testing import absltest
from absl.testing import parameterized
from enn.extra import kmeans
import chex
import haiku as hk
import jax
import jax.numpy as jnp

# Copyright 2021 DeepMind Technologies Limited. All Rights Reserved.
#
# 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 ENN Networks."""



class KmeansTest(parameterized.TestCase):

  @parameterized.product(
      num_x=[10, 100],
      dim_x=[1, 5],
      num_centroids=[1, 3],
  )
  def test_kmeans_runs(self, num_x: int, dim_x: int, num_centroids: int):
    """Test that KMeans clustering runs and has no nan."""
    rng = hk.PRNGSequence(999)
    x = jax.random.normal(next(rng), [num_x, dim_x])

    kmeans_cluster = kmeans.KMeansCluster(