File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 1
- import collections
1
+ import collections . abc
2
2
3
3
from torch .utils .data .dataloader import default_collate
4
4
@@ -27,7 +27,7 @@ def __call__(self, batch):
27
27
Returns:
28
28
batch values filtered by `keys`
29
29
"""
30
- if isinstance (batch [0 ], collections .Mapping ):
30
+ if isinstance (batch [0 ], collections .abc . Mapping ):
31
31
result = {}
32
32
for key in batch [0 ]:
33
33
items = [d [key ] for d in batch ]
Original file line number Diff line number Diff line change 2
2
import argparse
3
3
from base64 import urlsafe_b64encode
4
4
import collections
5
+ import collections .abc
5
6
import copy
6
7
from datetime import datetime
7
8
from hashlib import sha256
@@ -203,7 +204,7 @@ def merge_dicts(*dicts: dict) -> dict:
203
204
if (
204
205
k in dict_
205
206
and isinstance (dict_ [k ], dict )
206
- and isinstance (merge_dict [k ], collections .Mapping )
207
+ and isinstance (merge_dict [k ], collections .abc . Mapping )
207
208
):
208
209
dict_ [k ] = merge_dicts (dict_ [k ], merge_dict [k ])
209
210
else :
@@ -230,7 +231,7 @@ def flatten_dict(
230
231
items = []
231
232
for key , value in dictionary .items ():
232
233
new_key = parent_key + separator + key if parent_key else key
233
- if isinstance (value , collections .MutableMapping ):
234
+ if isinstance (value , collections .abc . MutableMapping ):
234
235
items .extend (flatten_dict (value , new_key , separator = separator ).items ())
235
236
else :
236
237
items .append ((new_key , value ))
You can’t perform that action at this time.
0 commit comments