# Path: sunds/core/spec_dict.py
# class SpecDict(dict):
#   def maybe_set(
#       self,
#       key: str,
#       value: Union[FeaturesOrBool, Any],
#       default: Union[FeaturesOrBool, _Factory] = False,
#   ) -> None:
#   def maybe_update(
#       self,
#       other: FeaturesOrBool,
#       default: FeaturesOrBool = False,
#   ) -> None:
# def labeled_image(
#     labels: LabelArg,
#     **kwargs: Any,
# ) -> tfds.features.LabeledImage:
# def _is_features(features: FeatureSpecs) -> bool:


from typing import Any, NamedTuple
from sunds.core import spec_dict
import pytest
import tensorflow as tf
import tensorflow_datasets as tfds
class _Param(NamedTuple):
  """`pytest.mark.parametrize` single param."""
  value: Any
  default: Any
  expected: Any


@pytest.mark.parametrize(
    'value, default, expected',
    [
        _Param(False, tfds.features.Image(), {}),
        _Param(
            value=True,  # True: use default
            default=tfds.features.Image(),
            expected={'a': tfds.features.Image()},
        ),
        _Param(
            value=True,
            default=tf.int32,  # Also works with dtype
            expected={
                'a': tf.int32,
            },
        ),
        _Param(
            value=tfds.features.Text(),  # Feature give, use it
            default=tfds.features.Image(),
            expected={'a': tfds.features.Text()},
        ),
        _Param(
            value=['cat', 'dog'],  # Label to use

# Path: sunds/core/spec_dict.py
# class SpecDict(dict):
#   def maybe_set(
#       self,
#       key: str,
#       value: Union[FeaturesOrBool, Any],
#       default: Union[FeaturesOrBool, _Factory] = False,
#   ) -> None:
#   def maybe_update(
#       self,
#       other: FeaturesOrBool,
#       default: FeaturesOrBool = False,
#   ) -> None:
# def labeled_image(
#     labels: LabelArg,
#     **kwargs: Any,
# ) -> tfds.features.LabeledImage:
# def _is_features(features: FeatureSpecs) -> bool:


# Path: sunds/core/spec_dict_test.py
from typing import Any, NamedTuple
from sunds.core import spec_dict
import pytest
import tensorflow as tf
import tensorflow_datasets as tfds

class _Param(NamedTuple):
  """`pytest.mark.parametrize` single param."""
  value: Any
  default: Any
  expected: Any


@pytest.mark.parametrize(
    'value, default, expected',
    [
        _Param(False, tfds.features.Image(), {}),
        _Param(
            value=True,  # True: use default
            default=tfds.features.Image(),
            expected={'a': tfds.features.Image()},
        ),
        _Param(
            value=True,
            default=tf.int32,  # Also works with dtype
            expected={
                'a': tf.int32,
            },
        ),
        _Param(
            value=tfds.features.Text(),  # Feature give, use it
            default=tfds.features.Image(),
            expected={'a': tfds.features.Text()},
        ),
        _Param(
            value=['cat', 'dog'],  # Label to use

            default=spec_dict.labeled_image(shape=(28, 28, 1)),