Skip to content

Commit 01b5746

Browse files
committed
blindly convert 'nus' to 'converters'
1 parent 14346dc commit 01b5746

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

data_prototype/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class PatchWrapper(ProxyWrapper):
4444
"joinstyle",
4545
}
4646

47-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
48-
super().__init__(data, nus)
47+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
48+
super().__init__(data, converters)
4949
self._wrapped_instance = self._wrapped_class([0, 0], 0, 0, **kwargs)
5050

5151
@_stale_wrapper

data_prototype/wrappers.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,25 +158,25 @@ def _query_and_transform(self, renderer, *, xunits: List[str], yunits: List[str]
158158
self._cache[cache_key] = transformed_data
159159
return transformed_data
160160

161-
def __init__(self, data, nus, **kwargs):
161+
def __init__(self, data, converters, **kwargs):
162162
super().__init__(**kwargs)
163163
self.data = data
164164
self._cache = LFUCache(64)
165165
# TODO make sure mutating this will invalidate the cache!
166-
self._nus = nus or {}
166+
self._converters = converters or {}
167167
for k in self.required_keys:
168-
self._nus.setdefault(k, _make_identity(k))
168+
self._converters.setdefault(k, _make_identity(k))
169169
desc = data.describe()
170170
for k in self.expected_keys:
171171
if k in desc:
172-
self._nus.setdefault(k, _make_identity(k))
173-
self._sigs = {k: (nu, inspect.signature(nu)) for k, nu in self._nus.items()}
172+
self._converters.setdefault(k, _make_identity(k))
173+
self._sigs = {k: (nu, inspect.signature(nu)) for k, nu in self._converters.items()}
174174
self.stale = True
175175

176176
# TODO add a setter
177177
@property
178-
def nus(self):
179-
return dict(self._nus)
178+
def converters(self):
179+
return dict(self._converters)
180180

181181

182182
class ProxyWrapper(ProxyWrapperBase):
@@ -192,7 +192,7 @@ def __getattr__(self, key):
192192
return getattr(self._wrapped_instance, key)
193193

194194
def __setattr__(self, key, value):
195-
if key in ("_wrapped_instance", "data", "_cache", "_nus", "stale", "_sigs"):
195+
if key in ("_wrapped_instance", "data", "_cache", "_converters", "stale", "_sigs"):
196196
super().__setattr__(key, value)
197197
elif hasattr(self, "_wrapped_instance") and hasattr(self._wrapped_instance, key):
198198
setattr(self._wrapped_instance, key, value)
@@ -205,8 +205,8 @@ class LineWrapper(ProxyWrapper):
205205
_privtized_methods = ("set_xdata", "set_ydata", "set_data", "get_xdata", "get_ydata", "get_data")
206206
required_keys = {"x", "y"}
207207

208-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
209-
super().__init__(data, nus)
208+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
209+
super().__init__(data, converters)
210210
self._wrapped_instance = self._wrapped_class(np.array([]), np.array([]), **kwargs)
211211

212212
@_stale_wrapper
@@ -238,8 +238,8 @@ class PathCollectionWrapper(ProxyWrapper):
238238
"get_paths",
239239
)
240240

241-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
242-
super().__init__(data, nus)
241+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
242+
super().__init__(data, converters)
243243
self._wrapped_instance = self._wrapped_class([], **kwargs)
244244
self._wrapped_instance.set_transform(mtransforms.IdentityTransform())
245245

@@ -262,17 +262,17 @@ class ImageWrapper(ProxyWrapper):
262262
_wrapped_class = _AxesImage
263263
required_keys = {"xextent", "yextent", "image"}
264264

265-
def __init__(self, data: DataContainer, nus=None, /, cmap=None, norm=None, **kwargs):
266-
nus = dict(nus or {})
265+
def __init__(self, data: DataContainer, converters=None, /, cmap=None, norm=None, **kwargs):
266+
converters = dict(converters or {})
267267
if cmap is not None or norm is not None:
268-
if nus is not None and "image" in nus:
268+
if converters is not None and "image" in converters:
269269
raise ValueError("Conflicting input")
270270
if cmap is None:
271271
cmap = mpl.colormaps["viridis"]
272272
if norm is None:
273273
raise ValueError("not sure how to do autoscaling yet")
274-
nus["image"] = lambda image: cmap(norm(image))
275-
super().__init__(data, nus)
274+
converters["image"] = lambda image: cmap(norm(image))
275+
super().__init__(data, converters)
276276
kwargs.setdefault("origin", "lower")
277277
self._wrapped_instance = self._wrapped_class(None, **kwargs)
278278

@@ -293,8 +293,8 @@ class StepWrapper(ProxyWrapper):
293293
_privtized_methods = () # ("set_data", "get_data")
294294
required_keys = {"edges", "density"}
295295

296-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
297-
super().__init__(data, nus)
296+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
297+
super().__init__(data, converters)
298298
self._wrapped_instance = self._wrapped_class([], [1], **kwargs)
299299

300300
@_stale_wrapper
@@ -312,8 +312,8 @@ class FormatedText(ProxyWrapper):
312312
_wrapped_class = _Text
313313
_privtized_methods = ("set_text",)
314314

315-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
316-
super().__init__(data, nus)
315+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
316+
super().__init__(data, converters)
317317
self._wrapped_instance = self._wrapped_class(text="", **kwargs)
318318

319319
@_stale_wrapper
@@ -368,8 +368,8 @@ class ErrorbarWrapper(MultiProxyWrapper):
368368
required_keys = {"x", "y"}
369369
expected_keys = {f"{axis}{dirc}" for axis in ["x", "y"] for dirc in ["upper", "lower"]}
370370

371-
def __init__(self, data: DataContainer, nus=None, /, **kwargs):
372-
super().__init__(data, nus)
371+
def __init__(self, data: DataContainer, converters=None, /, **kwargs):
372+
super().__init__(data, converters)
373373
# TODO all of the kwarg teasing apart that is needed
374374
color = kwargs.pop("color", "k")
375375
lw = kwargs.pop("lw", 2)

examples/mapped.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Mapping Line Properties
44
=======================
55
6-
Leveraging the nu functions to transform users space data to visualization data.
6+
Leveraging the converter functions to transform users space data to visualization data.
77
88
"""
99

@@ -20,7 +20,7 @@
2020
cmap.set_under("r")
2121
norm = Normalize(1, 8)
2222

23-
line_nus = {
23+
line_converter = {
2424
# arbitrary functions
2525
"lw": lambda lw: min(1 + lw, 5),
2626
# standard color mapping
@@ -29,7 +29,7 @@
2929
"ls": lambda cat: {"A": "-", "B": ":", "C": "--"}[cat[()]],
3030
}
3131

32-
text_nus = {
32+
text_converter = {
3333
"text": lambda j, cat: f"index={j[()]} class={cat[()]!r}",
3434
"y": lambda j: j,
3535
}
@@ -53,13 +53,13 @@
5353
ax.add_artist(
5454
LineWrapper(
5555
ac,
56-
line_nus,
56+
line_converter,
5757
)
5858
)
5959
ax.add_artist(
6060
FormatedText(
6161
ac,
62-
text_nus,
62+
text_converter,
6363
x=2 * np.pi,
6464
ha="right",
6565
bbox={"facecolor": "gray", "alpha": 0.5},

0 commit comments

Comments
 (0)