Skip to content

Commit db6c291

Browse files
committed
added "# doctest: +SKIP" for all doctests which depend on optional dependencies
1 parent 3597aa1 commit db6c291

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

larray/core/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,14 +1429,14 @@ def to_hdf(self, filepath, key=None, axis_key=None):
14291429
--------
14301430
>>> from larray import Axis
14311431
>>> a = Axis("a=a0..a2")
1432-
>>> a.to_hdf('test.h5')
1432+
>>> a.to_hdf('test.h5') # doctest: +SKIP
14331433
>>> a01 = a['a0,a1'] >> 'a01'
14341434
14351435
Save group
14361436
14371437
>>> # by default, the key is the name of the group
14381438
>>> # and axis_key the name of the associated axis
1439-
>>> a01.to_hdf('test.h5') # doctest: +SKIP
1439+
>>> a01.to_hdf('test.h5') # doctest: +SKIP
14401440
14411441
Save group with a specific key
14421442

larray/example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def get_example_filepath(fname):
4242
return fpath
4343

4444

45-
# TODO : replace # doctest: +SKIP by # doctest: +NORMALIZE_WHITESPACE once Python 2 has been dropped
45+
# Note that we skip doctests because they require pytables, which is only an optional dependency and its hard
46+
# to skip doctests selectively. The tests output is also different between Python 2 and Python 3.
47+
# CHECK: We might want to use .csv files for the example data, so that it can be loaded with any optional dependency.
4648
def load_example_data(name):
4749
r"""Load arrays used in the tutorial so that all examples in it can be reproduced.
4850
@@ -61,13 +63,13 @@ def load_example_data(name):
6163
6264
Examples
6365
--------
64-
>>> demo = load_example_data('demography')
65-
>>> print(demo.summary()) # doctest: +NORMALIZE_WHITESPACE
66+
>>> demo = load_example_data('demography') # doctest: +SKIP
67+
>>> print(demo.summary()) # doctest: +SKIP
6668
hh: time, geo, hh_type (26 x 3 x 7) [int64]
6769
pop: time, geo, age, sex, nat (26 x 3 x 121 x 2 x 2) [int64]
6870
qx: time, geo, age, sex, nat (26 x 3 x 121 x 2 x 2) [float64]
6971
>>> demo = load_example_data('demography_eurostat') # doctest: +SKIP
70-
>>> print(demo.summary()) # doctest: +SKIP
72+
>>> print(demo.summary()) # doctest: +SKIP
7173
Metadata:
7274
title: Demographic datasets for a small selection of countries in Europe
7375
source: demo_jpan, demo_fasec, demo_magec and migr_imm1ctz tables from Eurostat

larray/inout/excel.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
__all__ = ['read_excel']
2828

2929

30-
# TODO: remove '# doctest: +SKIP' next to arr.info when Python 2.7 will be dropped
30+
# We use "# doctest: +SKIP" for all tests because they work only if xlrd (an *optional* dependency) is installed
3131
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
3232
@deprecate_kwarg('sheetname', 'sheet')
3333
def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan, na=nan,
@@ -80,7 +80,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
8080
Read array from first sheet
8181
8282
>>> # The data below is derived from a subset of the demo_pjan table from Eurostat
83-
>>> read_excel(fname)
83+
>>> read_excel(fname) # doctest: +SKIP
8484
country gender\time 2013 2014 2015
8585
Belgium Male 5472856 5493792 5524068
8686
Belgium Female 5665118 5687048 5713206
@@ -92,7 +92,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
9292
Read array from a specific sheet
9393
9494
>>> # The data below is derived from a subset of the demo_fasec table from Eurostat
95-
>>> read_excel(fname, 'births')
95+
>>> read_excel(fname, 'births') # doctest: +SKIP
9696
country gender\time 2013 2014 2015
9797
Belgium Male 64371 64173 62561
9898
Belgium Female 61235 60841 59713
@@ -115,7 +115,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
115115
By default, cells associated with missing label combinations are filled with NaN. In that case, an int array
116116
is converted to a float array.
117117
118-
>>> read_excel(fname, sheet='population_missing_values')
118+
>>> read_excel(fname, sheet='population_missing_values') # doctest: +SKIP
119119
country gender\time 2013 2014 2015
120120
Belgium Male 5472856.0 5493792.0 5524068.0
121121
Belgium Female 5665118.0 5687048.0 5713206.0
@@ -126,7 +126,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
126126
127127
Using the ``fill_value`` argument, you can choose another value to use to fill missing cells.
128128
129-
>>> read_excel(fname, sheet='population_missing_values', fill_value=0)
129+
>>> read_excel(fname, sheet='population_missing_values', fill_value=0) # doctest: +SKIP
130130
country gender\time 2013 2014 2015
131131
Belgium Male 5472856 5493792 5524068
132132
Belgium Female 5665118 5687048 5713206
@@ -148,7 +148,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
148148
Germany Female 41142770 41210540 41362080
149149
150150
>>> # read the array stored in the sheet 'population_missing_axis_name' as is
151-
>>> arr = read_excel(fname, sheet='population_missing_axis_name')
151+
>>> arr = read_excel(fname, sheet='population_missing_axis_name') # doctest: +SKIP
152152
>>> # we expected a 3 x 2 x 3 array with data of type int
153153
>>> # but we got a 6 x 4 array with data of type object
154154
>>> arr.info # doctest: +SKIP
@@ -158,7 +158,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
158158
dtype: object
159159
memory used: 192 bytes
160160
>>> # using argument 'nb_axes', you can force the number of axes of the output array
161-
>>> arr = read_excel(fname, sheet='population_missing_axis_name', nb_axes=3)
161+
>>> arr = read_excel(fname, sheet='population_missing_axis_name', nb_axes=3) # doctest: +SKIP
162162
>>> # as expected, we have a 3 x 2 x 3 array with data of type int
163163
>>> arr.info # doctest: +SKIP
164164
3 x 2 x 3
@@ -181,14 +181,14 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
181181
France 2015 66458153
182182
183183
>>> # to read arrays stored in 'narrow' format, you must pass wide=False to read_excel
184-
>>> read_excel(fname, 'population_narrow_format', wide=False)
184+
>>> read_excel(fname, 'population_narrow_format', wide=False) # doctest: +SKIP
185185
country\time 2013 2014 2015
186186
Belgium 11137974 11180840 11237274
187187
France 65600350 66165980 66458153
188188
189189
Extract array from a given range (xlwings only)
190190
191-
>>> read_excel(fname, 'population_births_deaths', range='A9:E15') # doctest: +SKIP
191+
>>> read_excel(fname, 'population_births_deaths', range='A9:E15') # doctest: +SKIP
192192
country gender\time 2013 2014 2015
193193
Belgium Male 64371 64173 62561
194194
Belgium Female 61235 60841 59713

larray/inout/hdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, s
5353
Read array by passing its identifier (key) inside the HDF file
5454
5555
>>> # The data below is derived from a subset of the demo_pjan table from Eurostat
56-
>>> read_hdf(fname, 'pop')
56+
>>> read_hdf(fname, 'pop') # doctest: +SKIP
5757
country gender\time 2013 2014 2015
5858
Belgium Male 5472856 5493792 5524068
5959
Belgium Female 5665118 5687048 5713206

0 commit comments

Comments
 (0)