File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1759,10 +1759,20 @@ def __init__(*args, **kwargs):
1759
1759
raise TypeError ("descriptor '__init__' of 'Features' object needs an argument" )
1760
1760
self , * args = args
1761
1761
super (Features , self ).__init__ (* args , ** kwargs )
1762
+ # keep track of columns which require decoding
1762
1763
self ._column_requires_decoding : dict [str , bool ] = {
1763
1764
col : require_decoding (feature ) for col , feature in self .items ()
1764
1765
}
1765
1766
1767
+ # backward compatibility with datasets<4 : [feature] -> List(feature)
1768
+ def _check_old_list (feature ):
1769
+ if isinstance (feature , list ):
1770
+ return List (_visit (feature [0 ], _check_old_list ))
1771
+ return feature
1772
+
1773
+ for column_name , feature in self .items ():
1774
+ self [column_name ] = _visit (feature , _check_old_list )
1775
+
1766
1776
__setitem__ = keep_features_dicts_synced (dict .__setitem__ )
1767
1777
__delitem__ = keep_features_dicts_synced (dict .__delitem__ )
1768
1778
update = keep_features_dicts_synced (dict .update )
You can’t perform that action at this time.
0 commit comments