File tree Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,6 @@ def _features_to_numpy(
154
154
parsed_example = {}
155
155
feature_map = features .feature
156
156
for key in feature_map :
157
- ragged_row_length = _RAGGED_ROW_LENGTH_REGEX .match (key )
158
157
ragged_flat_values = _RAGGED_FLAT_VALUES_REGEX .match (key )
159
158
# For ragged arrays we need to reshape the np.arrays using
160
159
# ragged_flat_values/ragged_row_lengths_*. `features` can look like:
@@ -173,14 +172,13 @@ def _features_to_numpy(
173
172
flat_example_specs [feature_name ],
174
173
key ,
175
174
)
176
- elif ragged_row_length :
177
- # Lengths are extracted later for each feature in _feature_to_numpy.
178
- continue
179
175
else :
180
- raise KeyError (
181
- f"Malformed input: { key } is found in the feature, but not in"
182
- f" { flat_example_specs } "
183
- )
176
+ # Possible cases when we land here:
177
+ # 1. Case ragged: Lengths are extracted later for each feature in
178
+ # _feature_to_numpy. So we continue.
179
+ # 2. Other case: a key was found in the feature, but not in the specs. We
180
+ # just ignore this feature and continue.
181
+ continue
184
182
return parsed_example
185
183
186
184
Original file line number Diff line number Diff line change @@ -116,11 +116,8 @@ def test_key_error_exception_if_example_specs_is_malformed():
116
116
).SerializeToString ()
117
117
example_specs = features .get_tensor_info ()
118
118
example_parser_np = example_parser .ExampleParserNp (example_specs )
119
- with pytest .raises (
120
- KeyError ,
121
- match = '(.|\n )*array_of_ints is found in the feature, but not in*' ,
122
- ):
123
- example_parser_np .parse_example (serialized_example )
119
+ deserialized_example = example_parser_np .parse_example (serialized_example )
120
+ np .testing .assert_equal (deserialized_example , {'doesnotexist' : None })
124
121
125
122
126
123
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments