Skip to content

Commit fd37ecc

Browse files
authored
Merge pull request #164 from openml/fix163
fixed get tasks by type.
2 parents 41a4a74 + ddc5f79 commit fd37ecc

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

examples/OpenMLDemo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
"source": [
570570
"task_list = openml.tasks.list_tasks()\n",
571571
"\n",
572-
"tasks = pd.DataFrame(task_list)\n",
572+
"tasks = pd.DataFrame(task_list).transpose()\n",
573573
"print(\"First 5 of %s tasks:\" % len(tasks))\n",
574574
"print(tasks[:5][['tid','did','name','task_type','estimation_procedure']])"
575575
]
@@ -695,7 +695,7 @@
695695
"name": "python",
696696
"nbconvert_exporter": "python",
697697
"pygments_lexer": "ipython3",
698-
"version": "3.5.1"
698+
"version": "3.4.3"
699699
}
700700
},
701701
"nbformat": 4,

openml/tasks/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def list_tasks(task_type_id=None, offset=None, size=None, tag=None):
115115
"""
116116
api_call = "task/list"
117117
if task_type_id is not None:
118-
api_call += "/task_type_id/%d" % int(task_type_id)
118+
api_call += "/type/%d" % int(task_type_id)
119119

120120
if offset is not None:
121121
api_call += "/offset/%d" % int(offset)

tests/tasks/test_task_functions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ def _check_task(self, task):
5151
['in_preparation', 'active', 'deactivated'])
5252

5353
def test_list_tasks_by_type(self):
54-
tasks = openml.tasks.list_tasks(task_type_id=3)
54+
ttid=3
55+
tasks = openml.tasks.list_tasks(task_type_id=ttid)
5556
self.assertGreaterEqual(len(tasks), 300)
5657
for tid in tasks:
58+
print(tasks[tid])
59+
self.assertEquals(ttid, tasks[tid]["ttid"])
5760
self._check_task(tasks[tid])
5861

5962
def test_list_tasks_by_tag(self):
@@ -86,6 +89,7 @@ def test_list_tasks_per_type_paginate(self):
8689
tasks = openml.tasks.list_tasks(task_type_id=j, offset=i, size=size)
8790
self.assertGreaterEqual(size, len(tasks))
8891
for tid in tasks:
92+
self.assertEquals(j, tasks[tid]["ttid"])
8993
self._check_task(tasks[tid])
9094

9195
def test__get_task(self):

0 commit comments

Comments
 (0)