Skip to content

Commit

Permalink
Change doctest array to match numpy v1.14.0
Browse files Browse the repository at this point in the history
Printing algo changed.
  • Loading branch information
has2k1 committed Jan 17, 2018
1 parent ea88203 commit b5cd5f7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions mizani/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def rescale(x, to=(0, 1), _from=None):
--------
>>> x = [0, 2, 4, 6, 8, 10]
>>> rescale(x)
array([ 0. , 0.2, 0.4, 0.6, 0.8, 1. ])
array([0. , 0.2, 0.4, 0.6, 0.8, 1. ])
>>> rescale(x, to=(0, 2))
array([ 0. , 0.4, 0.8, 1.2, 1.6, 2. ])
array([0. , 0.4, 0.8, 1.2, 1.6, 2. ])
>>> rescale(x, to=(0, 2), _from=(0, 20))
array([ 0. , 0.2, 0.4, 0.6, 0.8, 1. ])
array([0. , 0.2, 0.4, 0.6, 0.8, 1. ])
"""
if _from is None:
_from = np.min(x), np.max(x)
Expand Down Expand Up @@ -96,9 +96,9 @@ def rescale_mid(x, to=(0, 1), _from=None, mid=0):
Examples
--------
>>> rescale_mid([1, 2, 3], mid=1)
array([ 0.5 , 0.75, 1. ])
array([0.5 , 0.75, 1. ])
>>> rescale_mid([1, 2, 3], mid=2)
array([ 0. , 0.5, 1. ])
array([0. , 0.5, 1. ])
"""
array_like = True

Expand Down Expand Up @@ -150,21 +150,21 @@ def rescale_max(x, to=(0, 1), _from=None):
--------
>>> x = [0, 2, 4, 6, 8, 10]
>>> rescale_max(x, (0, 3))
array([ 0. , 0.6, 1.2, 1.8, 2.4, 3. ])
array([0. , 0.6, 1.2, 1.8, 2.4, 3. ])
Only the 2nd (max) element of the parameters ``to``
and ``_from`` are essential to the output.
>>> rescale_max(x, (1, 3))
array([ 0. , 0.6, 1.2, 1.8, 2.4, 3. ])
array([0. , 0.6, 1.2, 1.8, 2.4, 3. ])
>>> rescale_max(x, (0, 20))
array([ 0., 4., 8., 12., 16., 20.])
array([ 0., 4., 8., 12., 16., 20.])
If :python:`max(x) < _from[1]` then values will be
scaled beyond the requested (:python:`to[1]`) maximum.
>>> rescale_max(x, to=(1, 3), _from=(-1, 6))
array([ 0., 1., 2., 3., 4., 5.])
array([0., 1., 2., 3., 4., 5.])
"""
array_like = True
Expand Down
8 changes: 4 additions & 4 deletions mizani/breaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class mpl_breaks(object):
>>> x = range(10)
>>> limits = (0, 9)
>>> mpl_breaks()(limits)
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
>>> mpl_breaks(nbins=2)(limits)
array([ 0., 5., 10.])
"""
Expand Down Expand Up @@ -170,7 +170,7 @@ class minor_breaks(object):
>>> major = [1, 2, 3, 4]
>>> limits = [0, 5]
>>> minor_breaks()(major, limits)
array([ 0.5, 1.5, 2.5, 3.5, 4.5])
array([0.5, 1.5, 2.5, 3.5, 4.5])
"""
def __init__(self, n=1):
self.n = n
Expand Down Expand Up @@ -248,12 +248,12 @@ class trans_minor_breaks(object):
>>> major = [1, 2, 3, 4]
>>> limits = [0, 5]
>>> sqrt_trans().minor_breaks(major, limits)
array([ 0.5, 1.5, 2.5, 3.5, 4.5])
array([0.5, 1.5, 2.5, 3.5, 4.5])
>>> class sqrt_trans2(sqrt_trans):
... def __init__(self):
... self.minor_breaks = trans_minor_breaks(sqrt_trans2)
>>> sqrt_trans2().minor_breaks(major, limits)
array([ 1.58113883, 2.54950976, 3.53553391])
array([1.58113883, 2.54950976, 3.53553391])
"""
def __init__(self, trans, n=1):
self.trans = trans
Expand Down
8 changes: 4 additions & 4 deletions mizani/palettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ def rescale_pal(range=(0.1, 1)):
--------
>>> palette = rescale_pal()
>>> palette([0, .2, .4, .6, .8, 1])
array([ 0.1 , 0.28, 0.46, 0.64, 0.82, 1. ])
array([0.1 , 0.28, 0.46, 0.64, 0.82, 1. ])
The returned palette expects inputs in the ``[0, 1]``
range. Any value outside those limits is clipped to
``range[0]`` or ``range[1]``.
>>> palette([-2, -1, 0.2, .4, .8, 2, 3])
array([ 0.1 , 0.1 , 0.28, 0.46, 0.82, 1. , 1. ])
array([0.1 , 0.1 , 0.28, 0.46, 0.82, 1. , 1. ])
"""
def _rescale(x):
return rescale(x, range, _from=(0, 1))
Expand Down Expand Up @@ -181,7 +181,7 @@ def area_pal(range=(1, 6)):
>>> x = np.arange(0, .6, .1)**2
>>> palette = area_pal()
>>> palette(x)
array([ 1. , 1.5, 2. , 2.5, 3. , 3.5])
array([1. , 1.5, 2. , 2.5, 3. , 3.5])
The results are equidistant because the input ``x`` is in
area space, i.e it is squared.
Expand Down Expand Up @@ -212,7 +212,7 @@ def abs_area(max):
>>> x = np.arange(0, .8, .1)**2
>>> palette = abs_area(5)
>>> palette(x)
array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5])
array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5])
Compared to :func:`area_pal`, :func:`abs_area` will handle values
in the range ``[-1, 0]`` without returning ``np.nan``. And values
Expand Down
4 changes: 2 additions & 2 deletions mizani/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ class trans(object):
>>> major = [0, 1, 2]
>>> t = trans()
>>> t.minor_breaks(major)
array([ 0.5, 1.5])
array([0.5, 1.5])
Create a trans that returns 4 minor breaks
>>> t = trans(minor_breaks=minor_breaks(4))
>>> t.minor_breaks(major)
array([ 0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8])
array([0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8])
"""
#: Aesthetic that the transform works on
aesthetic = None
Expand Down

0 comments on commit b5cd5f7

Please sign in to comment.