tfds.testing.FeatureExpectationItem
Stay organized with collections
Save and categorize content based on your preferences.
Test item of a FeatureExpectation.
tfds.testing.FeatureExpectationItem(
value: Any,
expected: Optional[Any] = None,
expected_np: Optional[np.ndarray] = None,
expected_serialized: Optional[Any] = None,
decoders: Optional[utils.TreeDict[Any]] = None,
dtype: Optional[tf.dtypes.DType] = None,
shape: Optional[utils.Shape] = None,
raise_cls: Optional[Type[Exception]] = None,
raise_cls_np: Optional[Type[Exception]] = None,
raise_msg: Optional[str] = None,
atol: Optional[float] = None
)
Should be passed to assertFeature
method of FeatureExpectationsTestCase
.
Each FeatureExpectationItem
test an example serialization/deserialization (
feature.encode_example
-> example_serializer.serialize_example
->
example_parse.parse_example
-> feature.decode_example
).
Attributes |
value
|
Input to features.encode_example
|
expected
|
Expected output after features.decode_example
|
expected_np
|
Expected output after features.decode_example_np
|
expected_serialized
|
Optional
|
decoders
|
Optional tfds.decode.Decoder objects (to overwrite the default
features.decode_example ). See
https://www.tensorflow.org/datasets/decode.
|
dtype
|
If decoders is provided, the output of decode_example is checked
against this value (otherwise, output is checked against features.dtype )
|
shape
|
If decoders is provided, the output of decode_example is checked
against this value (otherwise, output is checked against features.shape )
|
raise_cls
|
Expected error raised during features.encode_example . When set
expected and expected_serialized should be None .
|
raise_cls_np
|
Expected error raised during features.encode_example_np .
When set expected_np and expected_serialized_np should be None .
|
raise_msg
|
Expected error message regex.
|
atol
|
If provided, compare float values with this precision (use default
otherwise).
|
Methods
__eq__
__eq__(
other
)
Class Variables |
atol
|
None
|
decoders
|
None
|
dtype
|
None
|
expected
|
None
|
expected_np
|
None
|
expected_serialized
|
None
|
raise_cls
|
None
|
raise_cls_np
|
None
|
raise_msg
|
None
|
shape
|
None
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tfds.testing.FeatureExpectationItem\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/testing/feature_test_case.py#L36-L81) |\n\nTest item of a FeatureExpectation. \n\n tfds.testing.FeatureExpectationItem(\n value: Any,\n expected: Optional[Any] = None,\n expected_np: Optional[np.ndarray] = None,\n expected_serialized: Optional[Any] = None,\n decoders: Optional[utils.TreeDict[Any]] = None,\n dtype: Optional[tf.dtypes.DType] = None,\n shape: Optional[utils.Shape] = None,\n raise_cls: Optional[Type[Exception]] = None,\n raise_cls_np: Optional[Type[Exception]] = None,\n raise_msg: Optional[str] = None,\n atol: Optional[float] = None\n )\n\nShould be passed to `assertFeature` method of `FeatureExpectationsTestCase`.\n\nEach `FeatureExpectationItem` test an example serialization/deserialization (\n`feature.encode_example` -\\\u003e `example_serializer.serialize_example` -\\\u003e\n`example_parse.parse_example` -\\\u003e `feature.decode_example`).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `value` | Input to `features.encode_example` |\n| `expected` | Expected output after `features.decode_example` |\n| `expected_np` | Expected output after `features.decode_example_np` |\n| `expected_serialized` | Optional |\n| `decoders` | Optional [`tfds.decode.Decoder`](../../tfds/decode/Decoder) objects (to overwrite the default `features.decode_example`). See https://www.tensorflow.org/datasets/decode. |\n| `dtype` | If `decoders` is provided, the output of `decode_example` is checked against this value (otherwise, output is checked against `features.dtype`) |\n| `shape` | If `decoders` is provided, the output of `decode_example` is checked against this value (otherwise, output is checked against `features.shape`) |\n| `raise_cls` | Expected error raised during `features.encode_example`. When set `expected` and `expected_serialized` should be `None`. |\n| `raise_cls_np` | Expected error raised during `features.encode_example_np`. When set `expected_np` and `expected_serialized_np` should be `None`. |\n| `raise_msg` | Expected error message regex. |\n| `atol` | If provided, compare float values with this precision (use default otherwise). |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `__eq__`\n\n __eq__(\n other\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Class Variables --------------- ||\n|---------------------|--------|\n| atol | `None` |\n| decoders | `None` |\n| dtype | `None` |\n| expected | `None` |\n| expected_np | `None` |\n| expected_serialized | `None` |\n| raise_cls | `None` |\n| raise_cls_np | `None` |\n| raise_msg | `None` |\n| shape | `None` |\n\n\u003cbr /\u003e"]]