Skip to content

Commit ce738ac

Browse files
committed
CLN: avoid doctests which produce warnings
we cannot ignore them nicely
1 parent 0f72dc0 commit ce738ac

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

larray/core/array.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7722,31 +7722,37 @@ def growth_rate(self, axis=-1, d=1, label='upper') -> 'Array':
77227722
77237723
Examples
77247724
--------
7725-
>>> data = [[4, 5, 4, 0, 0, 4, 6], [2, 4, 3, 6, 6, 3, 9]]
7726-
>>> a = Array(data, "sex=M,F; year=2015..2021")
7725+
>>> data = [[4, 5, 4, 6, 9], [2, 4, 3, 0, 0]]
7726+
>>> a = Array(data, "sex=F,M; year=2017..2021")
77277727
>>> a
7728-
sex\year 2015 2016 2017 2018 2019 2020 2021
7729-
M 4 5 4 0 0 4 6
7730-
F 2 4 3 6 6 3 9
7728+
sex\year 2017 2018 2019 2020 2021
7729+
F 4 5 4 6 9
7730+
M 2 4 3 0 0
77317731
>>> a.growth_rate()
7732-
sex\year 2016 2017 2018 2019 2020 2021
7733-
M 0.25 -0.2 -1.0 0.0 inf 0.5
7734-
F 1.0 -0.25 1.0 0.0 -0.5 2.0
7732+
sex\year 2018 2019 2020 2021
7733+
F 0.25 -0.2 0.5 0.5
7734+
M 1.0 -0.25 -1.0 0.0
77357735
>>> a.growth_rate(label='lower')
7736-
sex\year 2015 2016 2017 2018 2019 2020
7737-
M 0.25 -0.2 -1.0 0.0 inf 0.5
7738-
F 1.0 -0.25 1.0 0.0 -0.5 2.0
7736+
sex\year 2017 2018 2019 2020
7737+
F 0.25 -0.2 0.5 0.5
7738+
M 1.0 -0.25 -1.0 0.0
77397739
>>> a.growth_rate(d=2)
7740-
sex\year 2017 2018 2019 2020 2021
7741-
M 0.0 -1.0 -1.0 inf inf
7742-
F 0.5 0.5 1.0 -0.5 0.5
7740+
sex\year 2019 2020 2021
7741+
F 0.0 0.2 1.25
7742+
M 0.5 -1.0 -1.0
7743+
7744+
It works on any axis, not just time-based axes
7745+
77437746
>>> a.growth_rate('sex')
7744-
sex\year 2015 2016 2017 2018 2019 2020 2021
7745-
F -0.5 -0.2 -0.25 inf inf -0.25 0.5
7747+
sex\year 2017 2018 2019 2020 2021
7748+
M -0.5 -0.2 -0.25 -1.0 -1.0
7749+
7750+
Or part of axes
7751+
77467752
>>> a.growth_rate(a.year[2017:])
7747-
sex\year 2018 2019 2020 2021
7748-
M -1.0 0.0 inf 0.5
7749-
F 1.0 0.0 -0.5 2.0
7753+
sex\year 2018 2019 2020 2021
7754+
F 0.25 -0.2 0.5 0.5
7755+
M 1.0 -0.25 -1.0 0.0
77507756
"""
77517757
if isinstance(axis, Group):
77527758
array = self[axis]

larray/core/checked.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,15 @@ class CheckedSession(Session, AbstractCheckedSession, metaclass=ModelMetaclass):
383383
dtype: int32
384384
memory used: 968 bytes
385385
386-
>>> # note that it still possible to add undeclared variables to a checked session
387-
>>> # but this must be done with caution.
388-
>>> m.undeclared_var = 'undeclared_var'
386+
It is possible to add undeclared variables to a checked session
387+
but this will print a warning:
388+
389+
>>> m.undeclared_var = 'my_value' # doctest: +SKIP
390+
UserWarning: 'undeclared_var' is not declared in 'ModelVariables'
389391
390392
>>> # ==== output ====
391393
>>> # save all variables in an HDF5 file
392-
>>> m.save(f'{variant_name}.h5', display=True)
394+
>>> m.save(f'{variant_name}.h5', display=True) # doctest: +SKIP
393395
dumping birth_rate ... done
394396
dumping births ... done
395397
dumping mortality_rate ... done

0 commit comments

Comments
 (0)