Skip to content

Commit

Permalink
Merge pull request #1348 from NelleV/pep8_scale
Browse files Browse the repository at this point in the history
PEP8 fixes on scale.py
  • Loading branch information
dmcdougall committed Oct 12, 2012
2 parents 2705dfa + 4e9aa92 commit 978f4e9
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions lib/matplotlib/scale.py
Expand Up @@ -4,9 +4,9 @@
from numpy import ma

from matplotlib.cbook import dedent
from matplotlib.ticker import (NullFormatter, ScalarFormatter,
from matplotlib.ticker import (NullFormatter, ScalarFormatter,
LogFormatterMathtext)
from matplotlib.ticker import (NullLocator, LogLocator, AutoLocator,
from matplotlib.ticker import (NullLocator, LogLocator, AutoLocator,
SymmetricalLogLocator)
from matplotlib.transforms import Transform, IdentityTransform
from matplotlib import docstring
Expand Down Expand Up @@ -120,7 +120,7 @@ class LogTransformBase(Transform):
output_dims = 1
is_separable = True
has_inverse = True

def __init__(self, nonpos):
Transform.__init__(self)
if nonpos == 'mask':
Expand Down Expand Up @@ -208,7 +208,7 @@ class LogTransform(Transform):
output_dims = 1
is_separable = True
has_inverse = True

def __init__(self, base, nonpos):
Transform.__init__(self)
self.base = base
Expand All @@ -231,7 +231,7 @@ class InvertedLogTransform(Transform):
output_dims = 1
is_separable = True
has_inverse = True

def __init__(self, base):
Transform.__init__(self)
self.base = base
Expand All @@ -241,7 +241,7 @@ def transform_non_affine(self, a):

def inverted(self):
return LogScale.LogTransform(self.base)

def __init__(self, axis, **kwargs):
"""
*basex*/*basey*:
Expand Down Expand Up @@ -325,7 +325,7 @@ class SymmetricalLogTransform(Transform):
output_dims = 1
is_separable = True
has_inverse = True

def __init__(self, base, linthresh, linscale):
Transform.__init__(self)
self.base = base
Expand All @@ -336,7 +336,10 @@ def __init__(self, base, linthresh, linscale):

def transform_non_affine(self, a):
sign = np.sign(a)
masked = ma.masked_inside(a, -self.linthresh, self.linthresh, copy=False)
masked = ma.masked_inside(a,
-self.linthresh,
self.linthresh,
copy=False)
log = sign * self.linthresh * (
self._linscale_adj +
ma.log(np.abs(masked) / self.linthresh) / self._log_base)
Expand All @@ -354,10 +357,12 @@ class InvertedSymmetricalLogTransform(Transform):
output_dims = 1
is_separable = True
has_inverse = True

def __init__(self, base, linthresh, linscale):
Transform.__init__(self)
symlog = SymmetricalLogScale.SymmetricalLogTransform(base, linthresh, linscale)
symlog = SymmetricalLogScale.SymmetricalLogTransform(base,
linthresh,
linscale)
self.base = base
self.linthresh = linthresh
self.invlinthresh = symlog.transform(linthresh)
Expand All @@ -366,7 +371,8 @@ def __init__(self, base, linthresh, linscale):

def transform_non_affine(self, a):
sign = np.sign(a)
masked = ma.masked_inside(a, -self.invlinthresh, self.invlinthresh, copy=False)
masked = ma.masked_inside(a, -self.invlinthresh,
self.invlinthresh, copy=False)
exp = sign * self.linthresh * (
ma.power(self.base, (sign * (masked / self.linthresh))
- self._linscale_adj))
Expand Down Expand Up @@ -420,7 +426,9 @@ def __init__(self, axis, **kwargs):
assert linthresh > 0.0
assert linscale >= 1.0

self._transform = self.SymmetricalLogTransform(base, linthresh, linscale)
self._transform = self.SymmetricalLogTransform(base,
linthresh,
linscale)

self.base = base
self.linthresh = linthresh
Expand All @@ -434,7 +442,8 @@ def set_default_locators_and_formatters(self, axis):
"""
axis.set_major_locator(SymmetricalLogLocator(self.get_transform()))
axis.set_major_formatter(LogFormatterMathtext(self.base))
axis.set_minor_locator(SymmetricalLogLocator(self.get_transform(), self.subs))
axis.set_minor_locator(SymmetricalLogLocator(self.get_transform(),
self.subs))
axis.set_minor_formatter(NullFormatter())

def get_transform(self):
Expand All @@ -445,9 +454,9 @@ def get_transform(self):


_scale_mapping = {
'linear' : LinearScale,
'log' : LogScale,
'symlog' : SymmetricalLogScale
'linear': LinearScale,
'log': LogScale,
'symlog': SymmetricalLogScale
}


Expand Down Expand Up @@ -502,6 +511,6 @@ def get_scale_docs():


docstring.interpd.update(
scale = ' | '.join([repr(x) for x in get_scale_names()]),
scale_docs = get_scale_docs().strip(),
scale=' | '.join([repr(x) for x in get_scale_names()]),
scale_docs=get_scale_docs().strip(),
)

0 comments on commit 978f4e9

Please sign in to comment.