Populates shape in the schema.
(shape_or_dict, prefix, schema_features)
| 1087 | |
| 1088 | |
| 1089 | def _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 | |
| 1106 | def get_dataset_info_json( |