Skip to content

Commit 6572e25

Browse files
committed
DOC/API: rename transform kwarg
Due to a conversation with someone at pydata the name "transform" was confused from "axes to data coordinate transform" to "data-aggregation-pipeline". This is fairly a "transform" but is not the transform that is meant.
1 parent 3eccc70 commit 6572e25

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

data_prototype/containers.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import pandas as pd
99

1010

11-
class _Transform(Protocol):
11+
class _MatplotlibTransform(Protocol):
1212
def transform(self, verts):
1313
...
1414

15-
def __sub__(self, other) -> "_Transform":
15+
def __sub__(self, other) -> "_MatplotlibTransform":
1616
...
1717

1818

@@ -35,7 +35,7 @@ class DataContainer(Protocol):
3535
def query(
3636
self,
3737
# TODO 3D?!!
38-
transform: _Transform,
38+
coord_transform: _MatplotlibTransform,
3939
size: Tuple[int, int],
4040
) -> Tuple[Dict[str, Any], Union[str, int]]:
4141
"""
@@ -46,7 +46,7 @@ def query(
4646
4747
Parameters
4848
----------
49-
transform : matplotlib.transform.Transform
49+
coord_transform : matplotlib.transform.Transform
5050
Must go from axes fraction space -> data space
5151
5252
size : 2 integers
@@ -88,7 +88,7 @@ def __init__(self, **data):
8888

8989
def query(
9090
self,
91-
transform: _Transform,
91+
coord_transform: _MatplotlibTransform,
9292
size: Tuple[int, int],
9393
) -> Tuple[Dict[str, Any], Union[str, int]]:
9494
return dict(self._data), self._cache_key
@@ -113,7 +113,7 @@ def __init__(self, **shapes):
113113

114114
def query(
115115
self,
116-
transform: _Transform,
116+
coord_transform: _MatplotlibTransform,
117117
size: Tuple[int, int],
118118
) -> Tuple[Dict[str, Any], Union[str, int]]:
119119
return {k: np.random.randn(*d.shape) for k, d in self._desc.items()}, str(uuid.uuid4())
@@ -166,26 +166,26 @@ def _split(input_dict):
166166

167167
def query(
168168
self,
169-
transform: _Transform,
169+
coord_transform: _MatplotlibTransform,
170170
size: Tuple[int, int],
171171
) -> Tuple[Dict[str, Any], Union[str, int]]:
172172
# TODO find a better way to compute the hash key, this is not sentative to
173173
# scale changes, only limit changes
174-
data_bounds = tuple(transform.transform([[0, 0], [1, 1]]).flatten())
174+
data_bounds = tuple(coord_transform.transform([[0, 0], [1, 1]]).flatten())
175175
hash_key = hash((data_bounds, size))
176176
if hash_key in self._cache:
177177
return self._cache[hash_key], hash_key
178178

179179
xpix, ypix = size
180-
x_data, _ = transform.transform(
180+
x_data, _ = coord_transform.transform(
181181
np.vstack(
182182
[
183183
np.linspace(0, 1, int(xpix) * 2),
184184
np.zeros(int(xpix) * 2),
185185
]
186186
).T
187187
).T
188-
_, y_data = transform.transform(
188+
_, y_data = coord_transform.transform(
189189
np.vstack(
190190
[
191191
np.zeros(int(ypix) * 2),
@@ -218,11 +218,11 @@ def __init__(self, raw_data, num_bins: int):
218218

219219
def query(
220220
self,
221-
transform: _Transform,
221+
coord_transform: _MatplotlibTransform,
222222
size: Tuple[int, int],
223223
) -> Tuple[Dict[str, Any], Union[str, int]]:
224224
dmin, dmax = self._full_range
225-
xmin, ymin, xmax, ymax = transform.transform([[0, 0], [1, 1]]).flatten()
225+
xmin, ymin, xmax, ymax = coord_transform.transform([[0, 0], [1, 1]]).flatten()
226226

227227
xmin, xmax = np.clip([xmin, xmax], dmin, dmax)
228228
hash_key = hash((xmin, xmax))
@@ -266,7 +266,7 @@ def __init__(self, series: pd.Series, *, index_name: str, col_name: str):
266266

267267
def query(
268268
self,
269-
transform: _Transform,
269+
coord_transform: _MatplotlibTransform,
270270
size: Tuple[int, int],
271271
) -> Tuple[Dict[str, Any], Union[str, int]]:
272272
return {self._index_name: self._data.index.values, self._col_name: self._data.values}, self._hash_key
@@ -305,7 +305,7 @@ def __init__(
305305

306306
def query(
307307
self,
308-
transform: _Transform,
308+
coord_transform: _MatplotlibTransform,
309309
size: Tuple[int, int],
310310
) -> Tuple[Dict[str, Any], Union[str, int]]:
311311
ret = {}
@@ -328,10 +328,10 @@ def __init__(self, data: DataContainer, mapping: Dict[str, str]):
328328

329329
def query(
330330
self,
331-
transform: _Transform,
331+
coord_transform: _MatplotlibTransform,
332332
size: Tuple[int, int],
333333
) -> Tuple[Dict[str, Any], Union[str, int]]:
334-
base, cache_key = self._data.query(transform, size)
334+
base, cache_key = self._data.query(coord_transform, size)
335335
return {v: base[k] for k, v in self._mapping.items()}, cache_key
336336

337337
def describe(self):
@@ -346,13 +346,13 @@ def __init__(self, *data: DataContainer):
346346

347347
def query(
348348
self,
349-
transform: _Transform,
349+
coord_transform: _MatplotlibTransform,
350350
size: Tuple[int, int],
351351
) -> Tuple[Dict[str, Any], Union[str, int]]:
352352
cache_keys = []
353353
ret = {}
354354
for data in self._datas:
355-
base, cache_key = data.query(transform, size)
355+
base, cache_key = data.query(coord_transform, size)
356356
ret.update(base)
357357
cache_keys.append(cache_key)
358358
return ret, hash(tuple(cache_keys))
@@ -364,7 +364,7 @@ def describe(self):
364364
class WebServiceContainer:
365365
def query(
366366
self,
367-
transform: _Transform,
367+
coord_transform: _MatplotlibTransform,
368368
size: Tuple[int, int],
369369
) -> Tuple[Dict[str, Any], Union[str, int]]:
370370
def hit_some_database():

data_prototype/wrappers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from matplotlib.collections import LineCollection as _LineCollection
1515
from matplotlib.artist import Artist as _Artist
1616

17-
from data_prototype.containers import DataContainer, _Transform
17+
from data_prototype.containers import DataContainer, _MatplotlibTransform
1818

1919

2020
class _BBox(Protocol):
@@ -30,8 +30,8 @@ class _Axes(Protocol):
3030
xaxis: _Axis
3131
yaxis: _Axis
3232

33-
transData: _Transform
34-
transAxes: _Transform
33+
transData: _MatplotlibTransform
34+
transAxes: _MatplotlibTransform
3535

3636
def get_xlim(self) -> Tuple[float, float]:
3737
...

examples/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import matplotlib.pyplot as plt
1515
from matplotlib.animation import FuncAnimation
1616

17-
from data_prototype.containers import _Transform, Desc
17+
from data_prototype.containers import _MatplotlibTransform, Desc
1818

1919
from data_prototype.wrappers import LineWrapper, FormatedText
2020

@@ -34,7 +34,7 @@ def describe(self):
3434

3535
def query(
3636
self,
37-
transform: _Transform,
37+
coord_transformtransform: _MatplotlibTransform,
3838
size: Tuple[int, int],
3939
) -> Tuple[Dict[str, Any], Union[str, int]]:
4040
th = np.linspace(0, 2 * np.pi, self.N)

examples/subsample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import numpy as np
2222

2323
from data_prototype.wrappers import ImageWrapper
24-
from data_prototype.containers import _Transform
24+
from data_prototype.containers import _MatplotlibTransform, Desc
2525

2626
from skimage.transform import downscale_local_mean
2727

@@ -45,10 +45,10 @@ def describe(self):
4545

4646
def query(
4747
self,
48-
transform: _Transform,
48+
coord_transform: _MatplotlibTransform,
4949
size: Tuple[int, int],
5050
) -> Tuple[Dict[str, Any], Union[str, int]]:
51-
(x1, y1), (x2, y2) = transform.transform([[0, 0], [1, 1]])
51+
(x1, y1), (x2, y2) = coord_transform.transform([[0, 0], [1, 1]])
5252

5353
xi1 = np.argmin(np.abs(x - x1))
5454
yi1 = np.argmin(np.abs(y - y1))

0 commit comments

Comments
 (0)