Skip to content

Commit

Permalink
Attempting to remove defaultdict from the collation functions (#2398)
Browse files Browse the repository at this point in the history
* Attempting to remove defaultdict from the collation functions

* Any(thing) goes
  • Loading branch information
calebrob6 committed Dec 8, 2024
1 parent 56eeada commit a38dae6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torchgeo/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,11 @@ def _list_dict_to_dict_list(
.. versionadded:: 0.2
"""
collated = collections.defaultdict(list)
collated: dict[Any, list[Any]] = dict()
for sample in samples:
for key, value in sample.items():
if key not in collated:
collated[key] = []
collated[key].append(value)
return collated

Expand Down

0 comments on commit a38dae6

Please sign in to comment.