Skip to content

Commit 9eedb90

Browse files
authored
Merge pull request #321 from openml/enable_doctests
enable doctests on travis-ci; fix doctests
2 parents d0f591f + b55e7a8 commit 9eedb90

8 files changed

Lines changed: 156 additions & 115 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
- DISTRIB="conda" PYTHON_VERSION="3.5" SKLEARN_VERSION="0.18.2"
2121
- DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="true" SKLEARN_VERSION="0.18.2"
2222
- DISTRIB="conda" PYTHON_VERSION="3.6" EXAMPLES="true" SKLEARN_VERSION="0.18.2"
23+
- DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2"
2324

2425
install: source ci_scripts/install.sh
2526
script: bash ci_scripts/test.sh

ci_scripts/install.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ popd
2626
# provided versions
2727
conda create -n testenv --yes python=$PYTHON_VERSION pip
2828
source activate testenv
29-
pip install nose numpy scipy cython scikit-learn==$SKLEARN_VERSION oslo.concurrency
29+
pip install nose numpy scipy cython scikit-learn==$SKLEARN_VERSION \
30+
oslo.concurrency
3031

3132
if [[ "$EXAMPLES" == "true" ]]; then
3233
pip install matplotlib jupyter notebook nbconvert nbformat jupyter_client \
3334
ipython ipykernel pandas seaborn
3435
fi
35-
36+
if [[ "$DOCTEST" == "true" ]]; then
37+
pip install pandas sphinx_bootstrap_theme
38+
fi
3639
if [[ "$COVERAGE" == "true" ]]; then
3740
pip install codecov
3841
fi

ci_scripts/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ mkdir -p $TEST_DIR
66

77
cwd=`pwd`
88
test_dir=$cwd/tests
9+
doctest_dir=$cwd/doc
910

1011
cd $TEST_DIR
1112

1213
if [[ "$EXAMPLES" == "true" ]]; then
1314
nosetests -sv $test_dir/test_examples/
15+
elif [[ "$DOCTEST" == "true" ]]; then
16+
python -m doctest $doctest_dir/usage.rst
1417
elif [[ "$COVERAGE" == "true" ]]; then
1518
nosetests --processes=4 --process-timeout=600 -sv --ignore-files="test_OpenMLDemo\.py" --with-coverage --cover-package=$MODULE $test_dir
1619
else

doc/usage.rst

Lines changed: 120 additions & 108 deletions
Large diffs are not rendered by default.

openml/datasets/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, dataset_id=None, name=None, version=None, description=None,
8383
xmlfeature['oml:name'],
8484
xmlfeature['oml:data_type'],
8585
None, #todo add nominal values (currently not in database)
86-
int(xmlfeature['oml:number_of_missing_values']))
86+
int(xmlfeature.get('oml:number_of_missing_values', 0)))
8787
if idx != feature.index:
8888
raise ValueError('Data features not provided in right order')
8989
self.features[feature.index] = feature

openml/datasets/functions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ def list_datasets(offset=None, size=None, tag=None):
150150
151151
Returns
152152
-------
153-
datasets : list of dicts
154-
A list of datasets having the given tag (if applicable).
153+
datasets : dict of dicts
154+
A mapping from dataset ID to dict.
155155
156156
Every dataset is represented by a dictionary containing
157157
the following information:
158158
- dataset id
159+
- name
160+
- format
159161
- status
160162
161163
If qualities are calculated for the dataset, some of

openml/tasks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .task import OpenMLTask
22
from .split import OpenMLSplit
3-
from .functions import (get_task, list_tasks)
3+
from .functions import (get_task, get_tasks, list_tasks)
44

5-
__all__ = ['OpenMLTask', 'get_task', 'list_tasks', 'OpenMLSplit']
5+
__all__ = ['OpenMLTask', 'get_task', 'get_tasks', 'list_tasks', 'OpenMLSplit']

openml/tasks/functions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,26 @@ def _list_tasks(api_call):
192192
return tasks
193193

194194

195+
def get_tasks(task_ids):
196+
"""Download tasks.
197+
198+
This function iterates :meth:`openml.tasks.get_task`.
199+
200+
Parameters
201+
----------
202+
task_ids : iterable
203+
Integers representing task ids.
204+
205+
Returns
206+
-------
207+
list
208+
"""
209+
tasks = []
210+
for task_id in task_ids:
211+
tasks.append(get_task(task_id))
212+
return tasks
213+
214+
195215
def get_task(task_id):
196216
"""Download the OpenML task for a given task ID.
197217

0 commit comments

Comments
 (0)