Skip to content

Commit 7ce8ed5

Browse files
shapovalovfacebook-github-bot
authored andcommitted
Fix: typo in dict processing
Summary: David had his code crashed when using frame_annot["meta"] dictionary. Turns out we had a typo. The tests were passing by chance since all the keys were single-character strings. Reviewed By: bottler Differential Revision: D37503987 fbshipit-source-id: c12b0df21116cfbbc4675a0182b9b9e6d62bad2e
1 parent 7e0146e commit 7ce8ed5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pytorch3d/implicitron/dataset/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def _dataclass_list_from_dict_list(dlist, typeannot):
226226

227227
keys = np.split(list(all_keys_res), indices[:-1])
228228
vals = np.split(list(all_vals_res), indices[:-1])
229-
return [cls(zip(*k, v)) for k, v in zip(keys, vals)]
229+
return [cls(zip(k, v)) for k, v in zip(keys, vals)]
230230
elif not dataclasses.is_dataclass(typeannot):
231231
return dlist
232232

tests/implicitron/test_types.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def test_parsing(self):
7373
)
7474

7575
# dict
76-
parsed = types._dataclass_from_dict({"k": dct}, Dict[str, FrameAnnotation])
77-
self.assertEqual(parsed, {"k": self.entry})
76+
parsed = types._dataclass_from_dict({"key": dct}, Dict[str, FrameAnnotation])
77+
self.assertEqual(parsed, {"key": self.entry})
7878

7979
def test_parsing_vectorized(self):
8080
dct = dataclasses.asdict(self.entry)
@@ -83,10 +83,10 @@ def test_parsing_vectorized(self):
8383
self._compare_with_scalar(_NT(dct), _NT)
8484
self._compare_with_scalar((dct,), Tuple[FrameAnnotation])
8585
self._compare_with_scalar([dct], List[FrameAnnotation])
86-
self._compare_with_scalar({"k": dct}, Dict[str, FrameAnnotation])
86+
self._compare_with_scalar({"key": dct}, Dict[str, FrameAnnotation])
8787

8888
dct2 = dct.copy()
89-
dct2["meta"] = {"d": 76}
89+
dct2["meta"] = {"aux": 76}
9090
self._compare_with_scalar(dct2, FrameAnnotation)
9191

9292
def _compare_with_scalar(self, obj, typeannot, repeat=3):

0 commit comments

Comments
 (0)