Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d5127e

Browse files
committed
Remove 'default' formatter, code quality fixes
1 parent f1d2e9d commit 0d5127e

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

‎proplot/axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ def __init__(self, *args, **kwargs):
16681668
"""
16691669
# Impose default formatter
16701670
super().__init__(*args, **kwargs)
1671-
formatter = axistools.Formatter('default')
1671+
formatter = axistools.Formatter('auto')
16721672
self.xaxis.set_major_formatter(formatter)
16731673
self.yaxis.set_major_formatter(formatter)
16741674
self.xaxis.isDefault_majfmt = True
@@ -2491,7 +2491,7 @@ def __init__(self, *args, **kwargs):
24912491
# Set tick length to zero so azimuthal labels are not too offset
24922492
# Change default radial axis formatter but keep default theta one
24932493
super().__init__(*args, **kwargs)
2494-
formatter = axistools.Formatter('default')
2494+
formatter = axistools.Formatter('auto')
24952495
self.yaxis.set_major_formatter(formatter)
24962496
self.yaxis.isDefault_majfmt = True
24972497
for axis in (self.xaxis, self.yaxis):

‎proplot/axistools.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -165,35 +165,35 @@ def Formatter(formatter, *args, date=False, **kwargs):
165165
4. In all other cases, a dictionary lookup is performed
166166
(see below table).
167167
168-
========================= ============================================== ============================================================================================================================================
169-
Key Class Description
170-
========================= ============================================== ============================================================================================================================================
171-
``'null'``, ``'none'`` `~matplotlib.ticker.NullFormatter` No tick labels
172-
``'auto'``, ``'default'`` `AutoFormatter` New default tick labels for axes
173-
``'simple'`` `SimpleFormatter` New default tick labels for e.g. contour labels
174-
``'frac'`` `FracFormatter` Rational fractions
175-
``'date'`` `~matplotlib.dates.AutoDateFormatter` Default tick labels for datetime axes
176-
``'datestr'`` `~matplotlib.dates.DateFormatter` Date formatting with C-style ``string % format`` notation
177-
``'concise'`` `~matplotlib.dates.ConciseDateFormatter` More concise default tick labels, introduced in `matplotlib 3.1 <https://matplotlib.org/3.1.0/users/whats_new.html#concisedateformatter>`__
178-
``'scalar'`` `~matplotlib.ticker.ScalarFormatter` Old default tick labels for axes
179-
``'strmethod'`` `~matplotlib.ticker.StrMethodFormatter` From the ``string.format`` method
180-
``'formatstr'`` `~matplotlib.ticker.FormatStrFormatter` From C-style ``string % format`` notation
181-
``'log'``, ``'sci'`` `~matplotlib.ticker.LogFormatterSciNotation` For log-scale axes with scientific notation
182-
``'math'`` `~matplotlib.ticker.LogFormatterMathtext` For log-scale axes with math text
183-
``'logit'`` `~matplotlib.ticker.LogitFormatter` For logistic-scale axes
184-
``'eng'`` `~matplotlib.ticker.EngFormatter` Engineering notation
185-
``'percent'`` `~matplotlib.ticker.PercentFormatter` Trailing percent sign
186-
``'fixed'`` `~matplotlib.ticker.FixedFormatter` List of strings
187-
``'index'`` `~matplotlib.ticker.IndexFormatter` List of strings corresponding to non-negative integer positions along the axis
188-
``'theta'`` `~matplotlib.projections.polar.ThetaFormatter` Formats radians as degrees, with a degree symbol
189-
``'pi'`` `FracFormatter` preset Fractions of :math:`\pi`
190-
``'e'`` `FracFormatter` preset Fractions of *e*
191-
``'deg'`` `SimpleFormatter` preset Trailing degree symbol
192-
``'deglon'`` `SimpleFormatter` preset Trailing degree symbol and cardinal "WE" indicator
193-
``'deglat'`` `SimpleFormatter` preset Trailing degree symbol and cardinal "SN" indicator
194-
``'lon'`` `SimpleFormatter` preset Cardinal "WE" indicator
195-
``'lat'`` `SimpleFormatter` preset Cardinal "SN" indicator
196-
========================= ============================================== ============================================================================================================================================
168+
====================== ============================================== ===================================================================================================================================
169+
Key Class Description
170+
====================== ============================================== ===================================================================================================================================
171+
``'null'``, ``'none'`` `~matplotlib.ticker.NullFormatter` No tick labels
172+
``'auto'`` `AutoFormatter` New default tick labels for axes
173+
``'simple'`` `SimpleFormatter` New default tick labels for e.g. contour labels
174+
``'frac'`` `FracFormatter` Rational fractions
175+
``'date'`` `~matplotlib.dates.AutoDateFormatter` Default tick labels for datetime axes
176+
``'datestr'`` `~matplotlib.dates.DateFormatter` Date formatting with C-style ``string % format`` notation
177+
``'concise'`` `~matplotlib.dates.ConciseDateFormatter` More concise date labels introduced in `matplotlib 3.1 <https://matplotlib.org/3.1.0/users/whats_new.html#concisedateformatter>`__
178+
``'scalar'`` `~matplotlib.ticker.ScalarFormatter` Old default tick labels for axes
179+
``'strmethod'`` `~matplotlib.ticker.StrMethodFormatter` From the ``string.format`` method
180+
``'formatstr'`` `~matplotlib.ticker.FormatStrFormatter` From C-style ``string % format`` notation
181+
``'log'``, ``'sci'`` `~matplotlib.ticker.LogFormatterSciNotation` For log-scale axes with scientific notation
182+
``'math'`` `~matplotlib.ticker.LogFormatterMathtext` For log-scale axes with math text
183+
``'logit'`` `~matplotlib.ticker.LogitFormatter` For logistic-scale axes
184+
``'eng'`` `~matplotlib.ticker.EngFormatter` Engineering notation
185+
``'percent'`` `~matplotlib.ticker.PercentFormatter` Trailing percent sign
186+
``'fixed'`` `~matplotlib.ticker.FixedFormatter` List of strings
187+
``'index'`` `~matplotlib.ticker.IndexFormatter` List of strings corresponding to non-negative integer positions along the axis
188+
``'theta'`` `~matplotlib.projections.polar.ThetaFormatter` Formats radians as degrees, with a degree symbol
189+
``'pi'`` `FracFormatter` preset Fractions of :math:`\pi`
190+
``'e'`` `FracFormatter` preset Fractions of *e*
191+
``'deg'`` `SimpleFormatter` preset Trailing degree symbol
192+
``'deglon'`` `SimpleFormatter` preset Trailing degree symbol and cardinal "WE" indicator
193+
``'deglat'`` `SimpleFormatter` preset Trailing degree symbol and cardinal "SN" indicator
194+
``'lon'`` `SimpleFormatter` preset Cardinal "WE" indicator
195+
``'lat'`` `SimpleFormatter` preset Cardinal "SN" indicator
196+
====================== ============================================== ===================================================================================================================================
197197
198198
date : bool, optional
199199
Toggles the behavior when `formatter` contains a ``'%'`` sign (see
@@ -559,7 +559,7 @@ def set_default_locators_and_formatters(self, axis, only_if_default=False):
559559
axis.isDefault_majloc = True
560560
if not only_if_default or axis.isDefault_majfmt:
561561
axis.set_major_formatter(
562-
getattr(self, '_major_formatter', None) or Formatter('default')
562+
getattr(self, '_major_formatter', None) or Formatter('auto')
563563
)
564564
axis.isDefault_majfmt = True
565565
if (not only_if_default or axis.isDefault_minloc
@@ -1277,7 +1277,6 @@ def transform_non_affine(self, a):
12771277
locators['theta'] = mpolar.ThetaLocator
12781278

12791279
formatters = { # note default LogFormatter uses ugly e+00 notation
1280-
'default': AutoFormatter,
12811280
'auto': AutoFormatter,
12821281
'frac': FracFormatter,
12831282
'simple': SimpleFormatter,

‎proplot/rctools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def reset(self):
677677
return self.__init__()
678678

679679
@_timer
680-
def backend_setup(backend=None, format=None):
680+
def backend_setup(backend=None, fmt=None):
681681
"""
682682
Set up the matplotlib backend for your iPython workspace.
683683
@@ -686,16 +686,16 @@ def backend_setup(backend=None, format=None):
686686
backend : str, optional
687687
The backend name. Leave this empty or use ``'auto'`` to revert to the
688688
ProPlot defaults.
689-
format : str, optional
689+
fmt : str, optional
690690
The inline backend file format. Valid formats include ``'jpg'``,
691691
``'png'``, ``'svg'``, ``'pdf'``, and ``'retina'``. This is ignored
692692
for non-inline backends.
693693
"""
694694
# Initialize with default 'inline' settings
695695
# Reset rc object afterwards
696696
# TODO: Change nbsetup --> autobackend in add-subplot branch
697+
fmt = fmt or rcParamsShort['format']
697698
ipython = get_ipython()
698-
format = format or rcParamsShort['format']
699699
backend = backend or ('auto' if
700700
rcParamsShort.get('autobackend', rcParamsShort.get('nbsetup', True))
701701
else None) or rcParams['backend']
@@ -721,7 +721,7 @@ def backend_setup(backend=None, format=None):
721721

722722
# Configure inline backend no matter what type of session this is
723723
# Should be silently ignored for terminal ipython sessions
724-
ipython.magic("config InlineBackend.figure_formats = ['" + format + "']")
724+
ipython.magic("config InlineBackend.figure_formats = ['" + fmt + "']")
725725
ipython.magic("config InlineBackend.rc = {}") # no notebook-specific overrides
726726
ipython.magic("config InlineBackend.close_figures = True") # memory issues
727727
ipython.magic("config InlineBackend.print_figure_kwargs = {'bbox_inches':None}") # use ProPlot tight layout

‎proplot/styletools.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,9 @@ def ixyy(x, func=xyy):
11351135
kwargs[ikey] = gamma
11361136
return self.updated(name, segmentdata, **kwargs)
11371137

1138-
def updated(self, name=None, segmentdata=None, N=None,
1139-
*, alpha=None, gamma=None, cyclic=None):
1138+
def updated(self, name=None, segmentdata=None, N=None, *,
1139+
alpha=None, gamma=None, cyclic=None,
1140+
):
11401141
"""
11411142
Returns a new colormap, with relevant properties copied from this one
11421143
if they were not provided as keyword arguments.
@@ -1306,15 +1307,15 @@ def truncated(self, left=None, right=None, name=None):
13061307
colors = self.colors[left:right]
13071308
return self.updated(colors, name, len(colors))
13081309

1309-
def updated(self, colors=None, alpha=None, name=None, N=None):
1310+
def updated(self, colors=None, name=None, N=None, *, alpha=None):
13101311
"""
13111312
Creates copy of the colormap.
13121313
13131314
Parameters
13141315
----------
13151316
name : str
13161317
The colormap name. Default is ``self.name + '_updated'``.
1317-
alpha, colors, N : optional
1318+
colors, N, alpha : optional
13181319
See `ListedColormap`. If not provided,
13191320
these are copied from the current colormap.
13201321
"""
@@ -1610,9 +1611,10 @@ def set_gamma(self, gamma=None, gamma1=None, gamma2=None):
16101611
self._gamma2 = gamma2
16111612
self._init()
16121613

1613-
def updated(self, name=None, segmentdata=None, N=None,
1614-
*, alpha=None, clip=None, cyclic=None,
1615-
gamma=None, gamma1=None, gamma2=None, space=None):
1614+
def updated(self, name=None, segmentdata=None, N=None, *,
1615+
alpha=None, gamma=None, cyclic=None,
1616+
clip=None, gamma1=None, gamma2=None, space=None,
1617+
):
16161618
"""
16171619
Returns a new colormap, with relevant properties copied from this one
16181620
if they were not provided as keyword arguments.

0 commit comments

Comments
 (0)