@@ -165,33 +165,24 @@ def _get_cache_directory(dataset: OpenMLDataset) -> str:
165165 return _create_cache_directory_for_id (DATASETS_CACHE_DIR_NAME , dataset .dataset_id )
166166
167167
168- def list_qualities (verbose = False ) :
168+ def list_qualities () -> list :
169169 """ Return list of data qualities available.
170170
171171 The function performs an API call to retrieve the entire list of
172- data qualities that are available are computed on the datasets uploaded.
173-
174- Parameters
175- ----------
176- verbose : bool (default=False)
177- If True, prints out the list with an index
172+ data qualities that are computed on the datasets uploaded.
178173
179174 """
180175 api_call = "data/qualities/list"
181176 xml_string = openml ._api_calls ._perform_api_call (api_call , 'get' )
182- qualities = xmltodict .parse (xml_string )
177+ qualities = xmltodict .parse (xml_string , force_list = ( 'oml:quality' ) )
183178 # Minimalistic check if the XML is useful
184179 if 'oml:data_qualities_list' not in qualities :
185180 raise ValueError ('Error in return XML, does not contain '
186181 '"oml:data_qualities_list"' )
187- assert type (qualities ['oml:data_qualities_list' ]['oml:quality' ]) == list
182+ if not isinstance (qualities ['oml:data_qualities_list' ]['oml:quality' ], list ):
183+ raise TypeError ('Error in return XML, does not contain '
184+ '"oml:quality" as a list' )
188185 qualities = qualities ['oml:data_qualities_list' ]['oml:quality' ]
189- if verbose :
190- header = "List of available data qualities:"
191- print (header )
192- print ("=" * len (header ))
193- for i , quality in enumerate (qualities ):
194- print ("{:>3}....{}" .format (i + 1 , quality ))
195186 return qualities
196187
197188
0 commit comments