class_docstr: Test Cases for VoxelGrid FeatureConnector.
class_docstr_tok: ["Test","Cases","for","VoxelGrid","FeatureConnector","."]
docstr: Tests voxel I/O and encoding/decoding to DatasetFeature.
docstr_tok: ["Tests","voxel","I\/O","and","encoding\/decoding","to","DatasetFeature","."]
code: def test_voxel(self):
      """Tests voxel I/O and encoding/decoding to DatasetFeature."""
  
      mat_file_path = os.path.join(_TEST_DATA_DIR, "cube.mat")
      expected_voxel = np.zeros((16, 16, 16), dtype=np.float32)
      expected_voxel[4:12, 4:12, 4:12] = 1.0
  
      mat_dict = {"path": mat_file_path, "key": "voxels"}
      raising_inputs = {"path": mat_file_path, "foo": "voxels"}
      wrong_key = {"path": mat_file_path, "key": "foo"}
      wrong_path = {"path": "/somewhere/wrong", "key": "voxels"}
      wrong_dim = np.ones((1, 1, 1, 1))
      self.assertFeature(
          feature=voxel_feature.VoxelGrid((16, 16, 16)),
          shape=(16, 16, 16),
          dtype=tf.float32,
          tests=[
              # mat file
              tfds.testing.FeatureExpectationItem(
                  value=mat_dict,
                  expected=expected_voxel,
              ),
              # Voxel Grid
              tfds.testing.FeatureExpectationItem(
                  value=expected_voxel,
                  expected=expected_voxel,
              ),
              tfds.testing.FeatureExpectationItem(
                  value=raising_inputs,
                  raise_cls=ValueError,
                  raise_msg="Missing keys in provided dictionary!",
              ),
              tfds.testing.FeatureExpectationItem(
                  value=wrong_key,
                  raise_cls=ValueError,
                  raise_msg="Key `foo` not found in .mat file",
              ),
              tfds.testing.FeatureExpectationItem(
                  value=wrong_path,
                  raise_cls=FileNotFoundError,
                  raise_msg="File `/somewhere/wrong` does not exist.",
              ),
              tfds.testing.FeatureExpectationItem(
                  value=wrong_dim,
                  raise_cls=ValueError,
                  raise_msg="Only 3D Voxel Grids are supported.",
              ),
          ],
      )
  
file_path: graphics/tensorflow_graphics/datasets/features/voxel_feature_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import numpy
  import tensorflow
  import tensorflow_datasets
  from tensorflow_graphics.datasets.features import voxel_feature
label_desc: Use image node_id 1 for calling the VoxelGridFeatureTest obj's underlying member method code with example usage: obj.test_voxel() without return types