Skip to content

Commit dad47f0

Browse files
committed
black formatting
1 parent c014aa5 commit dad47f0

3 files changed

Lines changed: 24 additions & 62 deletions

File tree

ultraplot/axes/plot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,15 +2479,15 @@ def _parse_cycle(
24792479
"""
24802480
cycle_kw = cycle_kw or {}
24812481
cycle_manually = cycle_manually or {}
2482-
cycle_kw.setdefault('N', ncycle)
2482+
cycle_kw.setdefault("N", ncycle)
24832483

24842484
# Match-case for cycle resolution
24852485
match cycle:
24862486
case None if not cycle_kw:
24872487
resolved_cycle = None
24882488
case True:
2489-
resolved_cycle = constructor.Cycle(rc['axes.prop_cycle'])
2490-
case str() if cycle.lower() == 'none':
2489+
resolved_cycle = constructor.Cycle(rc["axes.prop_cycle"])
2490+
case str() if cycle.lower() == "none":
24912491
resolved_cycle = None
24922492
case str() | int():
24932493
resolved_cycle = constructor.Cycle(cycle, **cycle_kw)
@@ -2507,16 +2507,15 @@ def _parse_cycle(
25072507
# Apply manual cycle properties
25082508
if cycle_manually:
25092509
current_prop = self._get_lines._cycler_items[self._get_lines._idx]
2510-
self._get_lines._idx = (self._get_lines._idx + 1) % len(self._get_lines._cycler_items)
2510+
self._get_lines._idx = (self._get_lines._idx + 1) % len(
2511+
self._get_lines._cycler_items
2512+
)
25112513
for prop, key in cycle_manually.items():
25122514
if kwargs.get(key) is None and prop in current_prop:
25132515
value = current_prop[prop]
2514-
kwargs[key] = pcolors.to_hex(value) if key == 'c' else value
2516+
kwargs[key] = pcolors.to_hex(value) if key == "c" else value
25152517
return kwargs
25162518

2517-
2518-
2519-
25202519
def _parse_level_lim(
25212520
self,
25222521
*args,

ultraplot/constructor.py

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@
155155
"lat": partial(pticker.SimpleFormatter, negpos="SN"),
156156
"lon": partial(pticker.SimpleFormatter, negpos="WE", wraprange=(-180, 180)),
157157
"deg": partial(pticker.SimpleFormatter, suffix="\N{DEGREE SIGN}"),
158-
"deglat": partial(
159-
pticker.SimpleFormatter, suffix="\N{DEGREE SIGN}", negpos="SN"
160-
),
158+
"deglat": partial(pticker.SimpleFormatter, suffix="\N{DEGREE SIGN}", negpos="SN"),
161159
"deglon": partial(
162160
pticker.SimpleFormatter,
163161
suffix="\N{DEGREE SIGN}",
@@ -862,9 +860,7 @@ def __init__(self, *args, N=None, samples=None, name=None, **kwargs):
862860
elif self._is_all_cyclers(args):
863861
self._handle_cycler_args(args, cycler_props, kwargs)
864862
else:
865-
self._handle_colormap_args(
866-
args, cycler_props, kwargs, samples, name
867-
)
863+
self._handle_colormap_args(args, cycler_props, kwargs, samples, name)
868864

869865
self._iterator = None # internal reference for cycle
870866

@@ -887,17 +883,13 @@ def _handle_empty_args(self, props, kwargs):
887883
"""Handle case when no positional arguments are provided."""
888884
props.setdefault("color", "black")
889885
if kwargs:
890-
warnings._warn_ultraplot(
891-
f"Ignoring Cycle() keyword arg(s) {kwargs}."
892-
)
886+
warnings._warn_ultraplot(f"Ignoring Cycle() keyword arg(s) {kwargs}.")
893887
self._build_cycler(())
894888

895889
def _handle_cycler_args(self, args, props, kwargs):
896890
"""Handle case when arguments are cycler objects."""
897891
if kwargs:
898-
warnings._warn_ultraplot(
899-
f"Ignoring Cycle() keyword arg(s) {kwargs}."
900-
)
892+
warnings._warn_ultraplot(f"Ignoring Cycle() keyword arg(s) {kwargs}.")
901893
if len(args) == 1 and not props:
902894
self._build_cycler((args[0].by_key(),))
903895
else:
@@ -912,11 +904,7 @@ def _handle_colormap_args(self, args, props, kwargs, samples, name):
912904
)
913905

914906
cmap = self._create_colormap(args, name, samples, kwargs)
915-
dict_ = {
916-
"color": [
917-
c if isinstance(c, str) else to_hex(c) for c in cmap.colors
918-
]
919-
}
907+
dict_ = {"color": [c if isinstance(c, str) else to_hex(c) for c in cmap.colors]}
920908
self._build_cycler((dict_, props))
921909
self.name = _not_none(name, cmap.name)
922910

@@ -946,9 +934,7 @@ def _build_cycler(self, dicts):
946934
# Build cycler with matching property lengths
947935
lengths = [len(value) for value in props.values()]
948936
maxlen = np.lcm.reduce(lengths)
949-
props = {
950-
key: value * (maxlen // len(value)) for key, value in props.items()
951-
}
937+
props = {key: value * (maxlen // len(value)) for key, value in props.items()}
952938
mcycler = cycler.cycler(**props)
953939
super().__init__(mcycler)
954940

@@ -1286,9 +1272,7 @@ def Formatter(formatter, *args, date=False, index=False, **kwargs):
12861272
elif formatter is False:
12871273
formatter = mticker.NullFormatter(*args, **kwargs)
12881274
elif np.iterable(formatter):
1289-
formatter = (mticker.FixedFormatter, pticker.IndexFormatter)[index](
1290-
formatter
1291-
)
1275+
formatter = (mticker.FixedFormatter, pticker.IndexFormatter)[index](formatter)
12921276
elif callable(formatter):
12931277
formatter = mticker.FuncFormatter(formatter, *args, **kwargs)
12941278
else:
@@ -1594,9 +1578,7 @@ def Proj(
15941578
if backend is not None:
15951579
kwargs["backend"] = backend
15961580
if kwargs:
1597-
warnings._warn_ultraplot(
1598-
f"Ignoring Proj() keyword arg(s): {kwargs!r}."
1599-
)
1581+
warnings._warn_ultraplot(f"Ignoring Proj() keyword arg(s): {kwargs!r}.")
16001582
proj = name
16011583
backend = "cartopy" if is_crs else "basemap"
16021584

@@ -1621,19 +1603,14 @@ def Proj(
16211603
message = f"{name!r} is an unknown cartopy projection class.\n"
16221604
message += "The known cartopy projection classes are:\n"
16231605
message += "\n".join(
1624-
" "
1625-
+ key
1626-
+ " " * (max(map(len, PROJS)) - len(key) + 10)
1627-
+ cls.__name__
1606+
" " + key + " " * (max(map(len, PROJS)) - len(key) + 10) + cls.__name__
16281607
for key, cls in PROJS.items()
16291608
)
16301609
if include_axes:
16311610
from . import axes as paxes # avoid circular imports
16321611

16331612
message = message.replace("class.", "class or axes subclass.")
1634-
message += (
1635-
"\nThe known axes subclasses are:\n" + paxes._cls_table
1636-
)
1613+
message += "\nThe known axes subclasses are:\n" + paxes._cls_table
16371614
raise ValueError(message) from None
16381615
if name == "geos": # fix common mistake
16391616
kwargs.pop("central_latitude", None)
@@ -1687,12 +1664,8 @@ def Proj(
16871664
if include_axes:
16881665
from . import axes as paxes # avoid circular imports
16891666

1690-
message = message.replace(
1691-
"projection.", "projection or axes subclass."
1692-
)
1693-
message += (
1694-
"\nThe known axes subclasses are:\n" + paxes._cls_table
1695-
)
1667+
message = message.replace("projection.", "projection or axes subclass.")
1668+
message += "\nThe known axes subclasses are:\n" + paxes._cls_table
16961669
raise ValueError(message) from None
16971670

16981671
proj._proj_backend = backend

ultraplot/tests/test_1dplots.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,7 @@ def test_scatter_inbounds():
303303
N = 100
304304
fig.format(xlim=(0, 20))
305305
for i, ax in enumerate(axs):
306-
c = ax.scatter(
307-
np.arange(N), np.arange(N), c=np.arange(N), inbounds=bool(i)
308-
)
306+
c = ax.scatter(np.arange(N), np.arange(N), c=np.arange(N), inbounds=bool(i))
309307
ax.colorbar(c, loc="b")
310308
return fig
311309

@@ -321,9 +319,7 @@ def test_scatter_alpha():
321319
ax.scatter(data, alpha=alpha)
322320
ax.scatter(data + 1, c=np.arange(data.size), cmap="BuRd", alpha=alpha)
323321
ax.scatter(data + 2, color="k", alpha=alpha)
324-
ax.scatter(
325-
data + 3, color=[f"red{i}" for i in range(data.size)], alpha=alpha
326-
)
322+
ax.scatter(data + 3, color=[f"red{i}" for i in range(data.size)], alpha=alpha)
327323
return fig
328324

329325

@@ -362,9 +358,7 @@ def test_scatter_sizes():
362358
kw = {"absolute_size": i == 2}
363359
if i == 1:
364360
kw["smin"] = 0
365-
kw["smax"] = (
366-
size**2
367-
) # should be same as relying on lines.markersize
361+
kw["smax"] = size**2 # should be same as relying on lines.markersize
368362
ax.scatter(np.arange(5), [0.25 * (1 + i)] * 5, size**2, **kw)
369363
# Test various size arguments
370364
ax = fig.subplot(122, margin=0.15)
@@ -377,12 +371,8 @@ def test_scatter_sizes():
377371
area_size=False,
378372
absolute_size=True,
379373
)
380-
ax.scatter(
381-
np.arange(5), [0.50] * 5, c="red7", sizes=data, absolute_size=True
382-
)
383-
ax.scatter(
384-
np.arange(5), [0.75] * 5, c="red7", sizes=data, absolute_size=False
385-
)
374+
ax.scatter(np.arange(5), [0.50] * 5, c="red7", sizes=data, absolute_size=True)
375+
ax.scatter(np.arange(5), [0.75] * 5, c="red7", sizes=data, absolute_size=False)
386376
for i, d in enumerate(data):
387377
ax.text(i, 0.5, format(d, ".0f"), va="center", ha="center")
388378
return fig

0 commit comments

Comments
 (0)