MCPcopy Create free account
hub / github.com/tensorflow/datasets / _populate_shape

Function _populate_shape

tensorflow_datasets/core/dataset_info.py:1089–1103  ·  view source on GitHub ↗

Populates shape in the schema.

(shape_or_dict, prefix, schema_features)

Source from the content-addressed store, hash-verified

1087
1088
1089def _populate_shape(shape_or_dict, prefix, schema_features):
1090 """Populates shape in the schema."""
1091 if isinstance(shape_or_dict, (tuple, list)):
1092 feature_name = "/".join(prefix)
1093 if shape_or_dict and feature_name in schema_features:
1094 schema_feature = schema_features[feature_name]
1095 schema_feature.ClearField("shape")
1096 for dim in shape_or_dict:
1097 # We denote `None`s as -1 in the shape proto.
1098 schema_feature.shape.dim.add().size = -1 if dim is None else dim
1099 return
1100 for name, val in shape_or_dict.items():
1101 prefix.append(name)
1102 _populate_shape(val, prefix, schema_features)
1103 prefix.pop()
1104
1105
1106def get_dataset_info_json(

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
addMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected