# Path: sunds/features/normal.py
# class NormalImage(tfds.features.Image):
#   def __init__(
#       self,
#       shape: Tuple[tfds.typing.Dim, tfds.typing.Dim] = (None, None),
#   ):
#   def get_tensor_info(self) -> tfds.features.TensorInfo:
#   def encode_example(self, normal_np: np.ndarray) -> bytes:
#   def decode_example(self, example: tf.Tensor) -> tf.Tensor:
#   def from_json_content(cls, value: tfds.typing.Json) -> 'NormalImage':
#   def to_json_content(self) -> tfds.typing.Json:
#   def repr_html(self, ex: np.ndarray) -> str:


import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
from sunds.features import normal
#
# 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 normal."""



def _get_encoded_img(image_array: np.ndarray) -> bytes:
  if image_array.ndim == 2:  # Expand 2d array
    image_array = image_array[..., None]
  return tf.image.encode_png(image_array).numpy()


class ImageFeaturesTest(tfds.testing.FeatureExpectationsTestCase):

  def testNormalImage(self):
    img = np.random.rand(24, 24, 3).astype(np.float32)
    img_discrete = ((img + 1.0) * 32767.5).astype(np.uint16)
    img2 = np.array([
        [[1., 0., 0.]],
        [[1e-6, 0.4, -1.]],
        [[0.9999999999999999999999999999, 0.4, -1.]],
    ])
    atol = 1e-04

    self.assertFeatureEagerOnly(

# Path: sunds/features/normal.py
# class NormalImage(tfds.features.Image):
#   def __init__(
#       self,
#       shape: Tuple[tfds.typing.Dim, tfds.typing.Dim] = (None, None),
#   ):
#   def get_tensor_info(self) -> tfds.features.TensorInfo:
#   def encode_example(self, normal_np: np.ndarray) -> bytes:
#   def decode_example(self, example: tf.Tensor) -> tf.Tensor:
#   def from_json_content(cls, value: tfds.typing.Json) -> 'NormalImage':
#   def to_json_content(self) -> tfds.typing.Json:
#   def repr_html(self, ex: np.ndarray) -> str:


# Path: sunds/features/normal_test.py
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
from sunds.features import normal

#
# 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 normal."""



def _get_encoded_img(image_array: np.ndarray) -> bytes:
  if image_array.ndim == 2:  # Expand 2d array
    image_array = image_array[..., None]
  return tf.image.encode_png(image_array).numpy()


class ImageFeaturesTest(tfds.testing.FeatureExpectationsTestCase):

  def testNormalImage(self):
    img = np.random.rand(24, 24, 3).astype(np.float32)
    img_discrete = ((img + 1.0) * 32767.5).astype(np.uint16)
    img2 = np.array([
        [[1., 0., 0.]],
        [[1e-6, 0.4, -1.]],
        [[0.9999999999999999999999999999, 0.4, -1.]],
    ])
    atol = 1e-04

    self.assertFeatureEagerOnly(

        feature=normal.NormalImage(),