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):
17591759 raise TypeError ("descriptor '__init__' of 'Features' object needs an argument" )
17601760 self , * args = args
17611761 super (Features , self ).__init__ (* args , ** kwargs )
1762+ # keep track of columns which require decoding
17621763 self ._column_requires_decoding : dict [str , bool ] = {
17631764 col : require_decoding (feature ) for col , feature in self .items ()
17641765 }
17651766
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+
17661776 __setitem__ = keep_features_dicts_synced (dict .__setitem__ )
17671777 __delitem__ = keep_features_dicts_synced (dict .__delitem__ )
17681778 update = keep_features_dicts_synced (dict .update )
You can’t perform that action at this time.
0 commit comments