Skip to content

Commit 4f60c25

Browse files
committed
comments by Matthias F.
1 parent 42b9668 commit 4f60c25

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

openml/study/functions.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def list_studies(offset=None, size=None, main_entity_type=None, status=None,
292292
size : int, optional
293293
The maximum number of studies to show.
294294
main_entity_type : str, optional
295-
Can be `task` or `run`. In case of `task`, only benchmark suites are
296-
returned. In case of `run`, only studies are returned.
295+
Can be ``'task'`` or ``'run'``. In case of `task`, only benchmark
296+
suites are returned. In case of `run`, only studies are returned.
297297
status : str, optional
298298
Should be {active, in_preparation, deactivated, all}. By default active
299299
studies are returned.
@@ -361,21 +361,22 @@ def __list_studies(api_call):
361361

362362
studies = dict()
363363
for study_ in study_dict['oml:study_list']['oml:study']:
364+
# maps from xml name to a tuple of (dict name, casting fn)
364365
expected_fields = {
365-
'oml:id': 'id',
366-
'oml:alias': 'alias',
367-
'oml:main_entity_type': 'main_entity_type',
368-
'oml:benchmark_suite': 'benchmark_suite',
369-
'oml:name': 'name',
370-
'oml:status': 'status',
371-
'oml:creation_date': 'creation_date',
372-
'oml:creator': 'creator'
366+
'oml:id': ('id', int),
367+
'oml:alias': ('alias', str),
368+
'oml:main_entity_type': ('main_entity_type', str),
369+
'oml:benchmark_suite': ('benchmark_suite', int),
370+
'oml:name': ('name', str),
371+
'oml:status': ('status', str),
372+
'oml:creation_date': ('creation_date', str),
373+
'oml:creator': ('creator', int),
373374
}
374375
study_id = int(study_['oml:id'])
375376
current_study = dict()
376-
for oml_field_name, real_field_name in expected_fields.items():
377+
for oml_field_name, (real_field_name, cast_fn) in expected_fields.items():
377378
if oml_field_name in study_:
378-
current_study[real_field_name] = study_[oml_field_name]
379+
current_study[real_field_name] = cast_fn(study_[oml_field_name])
379380
current_study['id'] = int(current_study['id'])
380381
studies[study_id] = current_study
381382
return studies

0 commit comments

Comments
 (0)