Skip to content

Commit 33654a4

Browse files
committed
Unused keyword args bugfixes and error silencing
1 parent c2c5c58 commit 33654a4

7 files changed

Lines changed: 40 additions & 35 deletions

File tree

proplot/axes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,11 +3338,12 @@ def __init__(self, *args, map_projection=None, **kwargs):
33383338
else:
33393339
self.set_global()
33403340

3341-
def _format_apply(
3341+
def _format_apply( # noqa: U100
33423342
self, patch_kw, lonlim, latlim, boundinglat,
33433343
lonlines, latlines, latmax, lonarray, latarray
33443344
):
33453345
"""Apply formatting to cartopy axes."""
3346+
# NOTE: Cartopy seems to handle latmax automatically.
33463347
import cartopy.feature as cfeature
33473348
import cartopy.crs as ccrs
33483349
from cartopy.mpl import gridliner
@@ -3400,8 +3401,10 @@ def _format_apply(
34003401
eps = 1e-10 # bug with full -180, 180 range when lon_0 != 0
34013402
lat0 = (90 if north else -90)
34023403
lon0 = self.projection.proj4_params.get('lon_0', 0)
3403-
extent = [lon0 - 180 + eps,
3404-
lon0 + 180 - eps, boundinglat, lat0]
3404+
extent = [
3405+
lon0 - 180 + eps, lon0 + 180 - eps,
3406+
boundinglat, lat0
3407+
]
34053408
self.set_extent(extent, crs=ccrs.PlateCarree())
34063409
self._boundinglat = boundinglat
34073410
else:

proplot/axistools.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class AutoFormatter(mticker.ScalarFormatter):
394394
"""
395395
def __init__(
396396
self, *args,
397-
zerotrim=None, precision=None, tickrange=None,
397+
zerotrim=None, tickrange=None,
398398
prefix=None, suffix=None, negpos=None, **kwargs
399399
):
400400
"""
@@ -477,7 +477,7 @@ def __call__(self, x, pos=None):
477477
return sign + self._prefix + string + self._suffix + tail
478478

479479

480-
def SimpleFormatter(*args, precision=6, zerotrim=True, **kwargs):
480+
def SimpleFormatter(precision=6, zerotrim=True):
481481
"""
482482
Return a `~matplotlib.ticker.FuncFormatter` instance that replicates the
483483
`zerotrim` feature from `AutoFormatter`. This is more suitable for
@@ -540,7 +540,7 @@ def f(x, pos): # must accept location argument
540540
return mticker.FuncFormatter(f)
541541

542542

543-
def _scale_factory(scale, axis, *args, **kwargs):
543+
def _scale_factory(scale, axis, *args, **kwargs): # noqa: U100
544544
"""If `scale` is a `~matplotlib.scale.ScaleBase` instance, do nothing. If
545545
it is a registered scale name, look up and instantiate that scale."""
546546
if isinstance(scale, mscale.ScaleBase):
@@ -938,7 +938,7 @@ class PowerScale(_ScaleBase, mscale.ScaleBase):
938938
name = 'power'
939939
"""The registered scale name."""
940940

941-
def __init__(self, power=1, inverse=False, *, minpos=1e-300, **kwargs):
941+
def __init__(self, power=1, inverse=False, *, minpos=1e-300):
942942
"""
943943
Parameters
944944
----------
@@ -1025,7 +1025,7 @@ class ExpScale(_ScaleBase, mscale.ScaleBase):
10251025
"""The registered scale name."""
10261026

10271027
def __init__(
1028-
self, a=np.e, b=1, c=1, inverse=False, minpos=1e-300, **kwargs
1028+
self, a=np.e, b=1, c=1, inverse=False, minpos=1e-300,
10291029
):
10301030
"""
10311031
Parameters
@@ -1134,7 +1134,7 @@ def __init__(self, thresh=85.0):
11341134
self._default_major_formatter = Formatter('deg')
11351135
self._default_smart_bounds = True
11361136

1137-
def limit_range_for_scale(self, vmin, vmax, minpos):
1137+
def limit_range_for_scale(self, vmin, vmax, minpos): # noqa: U100
11381138
"""Return *vmin* and *vmax* limited to some range within
11391139
+/-90 degrees (exclusive)."""
11401140
return max(vmin, -self._thresh), min(vmax, self._thresh)
@@ -1208,7 +1208,7 @@ def __init__(self):
12081208
self._default_major_formatter = Formatter('deg')
12091209
self._default_smart_bounds = True
12101210

1211-
def limit_range_for_scale(self, vmin, vmax, minpos):
1211+
def limit_range_for_scale(self, vmin, vmax, minpos): # noqa: U100
12121212
"""Return *vmin* and *vmax* limited to some range within
12131213
+/-90 degrees (inclusive)."""
12141214
return max(vmin, -90), min(vmax, 90)
@@ -1267,7 +1267,7 @@ class CutoffScale(_ScaleBase, mscale.ScaleBase):
12671267
name = 'cutoff'
12681268
"""The registered scale name."""
12691269

1270-
def __init__(self, *args, **kwargs):
1270+
def __init__(self, *args):
12711271
"""
12721272
Parameters
12731273
----------
@@ -1382,7 +1382,7 @@ class InverseScale(_ScaleBase, mscale.ScaleBase):
13821382
name = 'inverse'
13831383
"""The registered scale name."""
13841384

1385-
def __init__(self, **kwargs):
1385+
def __init__(self):
13861386
super().__init__()
13871387
self._transform = InverseTransform()
13881388
# self._default_major_formatter = Fromatter('log')

proplot/rctools.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def _update_from_file(file):
648648
rcParams.update(rc)
649649

650650

651-
def _write_defaults(filename, comment=True, overwrite=False):
651+
def _write_defaults(filename, comment=True):
652652
"""
653653
Save a file to the specified path containing the default `rc` settings.
654654
@@ -658,8 +658,6 @@ def _write_defaults(filename, comment=True, overwrite=False):
658658
The path.
659659
comment : bool, optional
660660
Whether to "comment out" each setting.
661-
overwrite : bool, optional
662-
Whether to overwrite existing files.
663661
"""
664662
def _tabulate(rcdict):
665663
string = ''
@@ -815,7 +813,7 @@ def _update(rcdict, newdict):
815813
_update(rcParamsLong, rc_long)
816814
_update(rcParams, rc)
817815

818-
def __exit__(self, *args):
816+
def __exit__(self, *args): # noqa: U100
819817
"""Restore settings from the most recent context block."""
820818
if not self._context:
821819
raise RuntimeError(
@@ -829,11 +827,11 @@ def __exit__(self, *args):
829827
rcParams.update(rc)
830828
del self._context[-1]
831829

832-
def __delitem__(self, *args):
830+
def __delitem__(self, item): # noqa: 100
833831
"""Raise an error. This enforces pseudo-immutability."""
834832
raise RuntimeError('rc settings cannot be deleted.')
835833

836-
def __delattr__(self, *args):
834+
def __delattr__(self, item): # noqa: 100
837835
"""Raise an error. This enforces pseudo-immutability."""
838836
raise RuntimeError('rc settings cannot be deleted.')
839837

proplot/styletools.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def punched(self, cut=None, name=None, **kwargs):
944944
right_center = 0.5 + cut / 2
945945
cmap_left = self.truncated(0, left_center)
946946
cmap_right = self.truncated(right_center, 1)
947-
return cmap_left.concatenate(cmap_right, name=name)
947+
return cmap_left.concatenate(cmap_right, name=name, **kwargs)
948948

949949
def reversed(self, name=None, **kwargs):
950950
"""
@@ -1090,7 +1090,8 @@ def shifted(self, shift=None, name=None, **kwargs):
10901090
cmap_left = self.truncated(shift, 1)
10911091
cmap_right = self.truncated(0, shift)
10921092
return cmap_left.concatenate(
1093-
cmap_right, ratios=(1 - shift, shift), name=name)
1093+
cmap_right, ratios=(1 - shift, shift), name=name, **kwargs
1094+
)
10941095

10951096
def truncated(self, left=None, right=None, name=None, **kwargs):
10961097
"""
@@ -1325,6 +1326,8 @@ def concatenate(self, *args, name=None, N=None, **kwargs):
13251326
N : int, optional
13261327
The number of colors in the colormap lookup table. Default is
13271328
the number of colors in the concatenated lists.
1329+
**kwargs
1330+
Passed to `~ListedColormap.updated`.
13281331
"""
13291332
if not args:
13301333
raise ValueError(
@@ -1338,7 +1341,7 @@ def concatenate(self, *args, name=None, N=None, **kwargs):
13381341
if name is None:
13391342
name = '_'.join(cmap.name for cmap in cmaps)
13401343
colors = [color for cmap in cmaps for color in cmap.colors]
1341-
return self.updated(colors, name, N or len(colors))
1344+
return self.updated(colors, name, N or len(colors), **kwargs)
13421345

13431346
def save(self, path=None):
13441347
"""
@@ -2456,8 +2459,8 @@ def Norm(norm, levels=None, **kwargs):
24562459
Key(s) Class
24572460
=============================== ===============================
24582461
``'midpoint'``, ``'zero'`` `MidpointNorm`
2459-
``'segments'``, ``'segmented'`` `LinearSegmentedNorm`
2460-
``'none'``, ``'null'`` `~matplotlib.colors.NoNorm`
2462+
``'segmented'``, ``'segments'`` `LinearSegmentedNorm`
2463+
``'null'``, ``'none'`` `~matplotlib.colors.NoNorm`
24612464
``'linear'`` `~matplotlib.colors.Normalize`
24622465
``'log'`` `~matplotlib.colors.LogNorm`
24632466
``'power'`` `~matplotlib.colors.PowerNorm`
@@ -2516,7 +2519,7 @@ class BinNorm(mcolors.BoundaryNorm):
25162519
If it is ``None``, they are not changed. Possible normalizers include
25172520
`~matplotlib.colors.LogNorm`, which makes color transitions linear in
25182521
the logarithm of the value, or `LinearSegmentedNorm`, which makes
2519-
color transitions linear in the **index** of the level array.
2522+
color transitions linear in the *index* of the level array.
25202523
2. Possible colormap coordinates, corresponding to bins delimited by the
25212524
normalized `levels` array, are calculated. In this case, the bin
25222525
centers are simply ``[1.5, 4.5, 7.5, 10.5, 13.5]``, which gives us
@@ -2528,7 +2531,7 @@ class BinNorm(mcolors.BoundaryNorm):
25282531
color as the nearest in-bounds values. For `extend` equal to ``'both'``,
25292532
the bins are ``[0, 0.16, 0.33, 0.5, 0.66, 0.83, 1]`` --
25302533
out-of-bounds values are given distinct colors. This makes sure your
2531-
colorbar always shows the **full range of colors** in the colormap.
2534+
colorbar always shows the *full range of colors* in the colormap.
25322535
4. Whenever `BinNorm.__call__` is invoked, the input value normalized by
25332536
`norm` is compared against the normalized `levels` array. Its bin index
25342537
is determined with `numpy.searchsorted`, and its corresponding

proplot/subplots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def __init__(self, objs, n=1, order='C'):
101101
def __repr__(self):
102102
return 'subplot_grid([' + ', '.join(str(ax) for ax in self) + '])'
103103

104-
def __setitem__(self, key, value):
105-
"""Pseudo immutability. Raises error."""
104+
def __setitem__(self, key, value): # noqa: U100
105+
"""Raise an error. This enforces pseudo immutability."""
106106
raise LookupError('subplot_grid is immutable.')
107107

108108
def __getitem__(self, key):
@@ -803,7 +803,7 @@ def __enter__(self):
803803
for label in self._labels:
804804
label.set_visible(False)
805805

806-
def __exit__(self, *args):
806+
def __exit__(self, *args): # noqa: U100
807807
for label in self._labels:
808808
label.set_visible(True)
809809

proplot/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __enter__(self):
2929
if BENCHMARK:
3030
self.time = time.perf_counter()
3131

32-
def __exit__(self, *args):
32+
def __exit__(self, *args): # noqa: U100
3333
if BENCHMARK:
3434
print(f'{self.message}: {time.perf_counter() - self.time}s')
3535

@@ -47,7 +47,7 @@ def __enter__(self):
4747
for key, value in self._kwargs.items():
4848
setattr(self._obj, key, value)
4949

50-
def __exit__(self, *args):
50+
def __exit__(self, *args): # noqa: U100
5151
for key in self._kwargs.keys():
5252
if key in self._kwargs_orig:
5353
setattr(self._obj, key, self._kwargs_orig[key])
@@ -89,7 +89,7 @@ def decorator(*args, **kwargs):
8989
return decorator
9090

9191

92-
def _format_warning(message, category, filename, lineno, line=None):
92+
def _format_warning(message, category, filename, lineno, line=None): # noqa: U100, E501
9393
"""Simple format for warnings issued by ProPlot. See the
9494
`internal warning call signature \
9595
<https://docs.python.org/3/library/warnings.html#warnings.showwarning>`__

proplot/wrappers.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def hist_wrapper(self, func, x, bins=None, **kwargs):
10601060
return func(self, x, bins=bins, **kwargs)
10611061

10621062

1063-
def barh_wrapper(
1063+
def barh_wrapper( # noqa: U100
10641064
self, func, y=None, width=None, height=0.8, left=None, **kwargs
10651065
):
10661066
"""Wraps %(methods)s, usage is same as `bar_wrapper`."""
@@ -1403,8 +1403,10 @@ def text_wrapper(
14031403
facecolor, bgcolor = kwargs['color'], bordercolor
14041404
if invert:
14051405
facecolor, bgcolor = bgcolor, facecolor
1406-
kwargs = {'linewidth': linewidth,
1407-
'foreground': bgcolor, 'joinstyle': 'miter'}
1406+
kwargs = {
1407+
'linewidth': linewidth,
1408+
'foreground': bgcolor, 'joinstyle': 'miter'
1409+
}
14081410
obj.update({
14091411
'color': facecolor,
14101412
'zorder': 100,
@@ -1417,7 +1419,6 @@ def text_wrapper(
14171419
def cycle_changer(
14181420
self, func, *args,
14191421
cycle=None, cycle_kw=None,
1420-
markers=None, linestyles=None,
14211422
label=None, labels=None, values=None,
14221423
legend=None, legend_kw=None,
14231424
colorbar=None, colorbar_kw=None,

0 commit comments

Comments
 (0)