plopp 25.4.1__py3-none-any.whl → 25.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plopp/graphics/graphicalview.py +15 -9
- plopp/plotting/common.py +37 -12
- {plopp-25.4.1.dist-info → plopp-25.5.0.dist-info}/METADATA +1 -1
- {plopp-25.4.1.dist-info → plopp-25.5.0.dist-info}/RECORD +7 -7
- {plopp-25.4.1.dist-info → plopp-25.5.0.dist-info}/WHEEL +1 -1
- {plopp-25.4.1.dist-info → plopp-25.5.0.dist-info}/licenses/LICENSE +0 -0
- {plopp-25.4.1.dist-info → plopp-25.5.0.dist-info}/top_level.txt +0 -0
plopp/graphics/graphicalview.py
CHANGED
|
@@ -21,6 +21,15 @@ def _none_if_not_finite(x: float | None) -> float | int | None:
|
|
|
21
21
|
return x if np.isfinite(x) else None
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
def _make_range(
|
|
25
|
+
old: tuple[float, float], new: tuple[float, float]
|
|
26
|
+
) -> tuple[float | None, float | None]:
|
|
27
|
+
new = (_none_if_not_finite(new[0]), _none_if_not_finite(new[1]))
|
|
28
|
+
if (old is not None) and (None not in old) and (old[0] > old[1]):
|
|
29
|
+
new = (new[1], new[0])
|
|
30
|
+
return new
|
|
31
|
+
|
|
32
|
+
|
|
24
33
|
class GraphicalView(View):
|
|
25
34
|
"""
|
|
26
35
|
Base class for graphical 1d and 2d views.
|
|
@@ -113,18 +122,15 @@ class GraphicalView(View):
|
|
|
113
122
|
bbox = bbox.union(artist.bbox(**scales))
|
|
114
123
|
self.bbox = bbox
|
|
115
124
|
self.bbox = self.bbox.override(self.canvas.bbox)
|
|
116
|
-
self.canvas.xrange = (
|
|
117
|
-
|
|
118
|
-
_none_if_not_finite(self.bbox.xmax),
|
|
125
|
+
self.canvas.xrange = _make_range(
|
|
126
|
+
old=self.canvas.xrange, new=(self.bbox.xmin, self.bbox.xmax)
|
|
119
127
|
)
|
|
120
|
-
self.canvas.yrange = (
|
|
121
|
-
|
|
122
|
-
_none_if_not_finite(self.bbox.ymax),
|
|
128
|
+
self.canvas.yrange = _make_range(
|
|
129
|
+
old=self.canvas.yrange, new=(self.bbox.ymin, self.bbox.ymax)
|
|
123
130
|
)
|
|
124
131
|
if hasattr(self.canvas, 'zrange'):
|
|
125
|
-
self.canvas.zrange = (
|
|
126
|
-
|
|
127
|
-
_none_if_not_finite(self.bbox.zmax),
|
|
132
|
+
self.canvas.zrange = _make_range(
|
|
133
|
+
old=self.canvas.zrange, new=(self.bbox.zmin, self.bbox.zmax)
|
|
128
134
|
)
|
|
129
135
|
|
|
130
136
|
def update(self, *args, **kwargs) -> None:
|
plopp/plotting/common.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
|
|
3
3
|
|
|
4
4
|
import warnings
|
|
5
|
-
from collections.abc import Callable
|
|
5
|
+
from collections.abc import Callable, Iterable
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
@@ -76,8 +76,30 @@ def to_variable(obj) -> sc.Variable:
|
|
|
76
76
|
return out
|
|
77
77
|
|
|
78
78
|
|
|
79
|
+
def _ensure_data_array_coords(
|
|
80
|
+
da: sc.DataArray, coords: list[str] | None
|
|
81
|
+
) -> sc.DataArray:
|
|
82
|
+
if coords is None:
|
|
83
|
+
coords = list(da.dims)
|
|
84
|
+
elif missing := set(coords) - set(da.coords.keys()):
|
|
85
|
+
raise ValueError(f"Specified coords do not exist: {missing}")
|
|
86
|
+
|
|
87
|
+
# Remove unused coords
|
|
88
|
+
da = da.drop_coords(list(set(da.coords) - set(coords)))
|
|
89
|
+
# Assign dim coords where missing. The above checks ensure that all missing
|
|
90
|
+
# coords are dim coords, i.e., that `name in out.dims`.
|
|
91
|
+
da = da.assign_coords(
|
|
92
|
+
{
|
|
93
|
+
name: sc.arange(name, da.sizes[name], unit=None)
|
|
94
|
+
for name in set(coords) - set(da.coords)
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
return da
|
|
98
|
+
|
|
99
|
+
|
|
79
100
|
def to_data_array(
|
|
80
101
|
obj: Plottable | list,
|
|
102
|
+
coords: list[str] | None = None,
|
|
81
103
|
) -> sc.DataArray:
|
|
82
104
|
"""
|
|
83
105
|
Convert an input to a DataArray, potentially adding fake coordinates if they are
|
|
@@ -87,6 +109,8 @@ def to_data_array(
|
|
|
87
109
|
----------
|
|
88
110
|
obj:
|
|
89
111
|
The input object to be converted.
|
|
112
|
+
coords:
|
|
113
|
+
If supplied, use these coords instead of the input's dimension coordinates.
|
|
90
114
|
"""
|
|
91
115
|
out = _maybe_to_variable(obj)
|
|
92
116
|
if isinstance(out, sc.Variable):
|
|
@@ -94,15 +118,13 @@ def to_data_array(
|
|
|
94
118
|
out = from_compatible_lib(out)
|
|
95
119
|
if not isinstance(out, sc.DataArray):
|
|
96
120
|
raise TypeError(f"Cannot convert input of type {type(obj)} to a DataArray.")
|
|
97
|
-
out = out
|
|
98
|
-
for
|
|
99
|
-
if
|
|
100
|
-
out.coords[dim] = sc.arange(dim, size, unit=None)
|
|
101
|
-
if not out.coords[dim].dims:
|
|
121
|
+
out = _ensure_data_array_coords(out, coords)
|
|
122
|
+
for name, coord in out.coords.items():
|
|
123
|
+
if not coord.dims:
|
|
102
124
|
raise ValueError(
|
|
103
125
|
"Input data cannot be plotted: it has a scalar coordinate along "
|
|
104
|
-
f"dimension {
|
|
105
|
-
f"Use ``data.drop_coords('{
|
|
126
|
+
f"dimension {name}. Consider dropping this coordinate before plotting. "
|
|
127
|
+
f"Use ``data.drop_coords('{name}').plot()``."
|
|
106
128
|
)
|
|
107
129
|
for name in out.coords:
|
|
108
130
|
other_dims = [dim for dim in out.coords[name].dims if dim not in out.dims]
|
|
@@ -171,7 +193,7 @@ def preprocess(
|
|
|
171
193
|
obj: Plottable | list,
|
|
172
194
|
name: str | None = None,
|
|
173
195
|
ignore_size: bool = False,
|
|
174
|
-
coords:
|
|
196
|
+
coords: Iterable[str] | str | None = None,
|
|
175
197
|
) -> sc.DataArray:
|
|
176
198
|
"""
|
|
177
199
|
Pre-process input data for plotting.
|
|
@@ -192,7 +214,12 @@ def preprocess(
|
|
|
192
214
|
coords:
|
|
193
215
|
If supplied, use these coords instead of the input's dimension coordinates.
|
|
194
216
|
"""
|
|
195
|
-
|
|
217
|
+
if isinstance(coords, str):
|
|
218
|
+
coords = [coords]
|
|
219
|
+
elif coords is not None:
|
|
220
|
+
coords = list(coords)
|
|
221
|
+
|
|
222
|
+
out = to_data_array(obj, coords)
|
|
196
223
|
check_not_binned(out)
|
|
197
224
|
check_allowed_dtypes(out)
|
|
198
225
|
if name is not None:
|
|
@@ -201,8 +228,6 @@ def preprocess(
|
|
|
201
228
|
_check_size(out)
|
|
202
229
|
if coords is not None:
|
|
203
230
|
renamed_dims = {}
|
|
204
|
-
if isinstance(coords, str):
|
|
205
|
-
coords = [coords]
|
|
206
231
|
for dim in coords:
|
|
207
232
|
underlying = out.coords[dim].dims[-1]
|
|
208
233
|
if underlying in renamed_dims:
|
|
@@ -43,11 +43,11 @@ plopp/graphics/bbox.py,sha256=3WeMgu5LgWIXLJTYVT7_USwaAcS7cQPNCk6B0gvuNGo,3596
|
|
|
43
43
|
plopp/graphics/camera.py,sha256=fXc1YH7Tp-rwKkcYeE-mHrxMz3SKauj5xJCRuKv-QPs,5323
|
|
44
44
|
plopp/graphics/colormapper.py,sha256=u5cADKU9lrRkJ_a969i_5z-mdT0-lBnEonc0PW_xSXA,9643
|
|
45
45
|
plopp/graphics/figures.py,sha256=PLWQLnQNWz8epubYlK7HLSkvPGJmTAmHjJM2DqpvLe8,2735
|
|
46
|
-
plopp/graphics/graphicalview.py,sha256=
|
|
46
|
+
plopp/graphics/graphicalview.py,sha256=u5sz3CebhVLoEeKPpzlBlPfRrRORxDmruyfhLXDbH00,9436
|
|
47
47
|
plopp/graphics/tiled.py,sha256=gXYZVAs6wRFKezzN3VlEvm7_z2zx3IDYfGZQZqrpL80,1386
|
|
48
48
|
plopp/plotting/__init__.py,sha256=s25RIbKplHSRn0jjtLADPQl72JLf_KLRMRCfeMDI_UA,205
|
|
49
49
|
plopp/plotting/__init__.pyi,sha256=95wYGfM5PT0Y0Ov_ue7rBrHvHxrtex-2WEYtfFzBvE0,475
|
|
50
|
-
plopp/plotting/common.py,sha256=
|
|
50
|
+
plopp/plotting/common.py,sha256=7xR2aWUWzKyxshlPn8B-OWQ5Hy8wiMn-qtPywkLsNRs,9515
|
|
51
51
|
plopp/plotting/inspector.py,sha256=fT4v342pqTzihKaweoGD4WaQ5eDdyngK7W451Mh2Ffw,3586
|
|
52
52
|
plopp/plotting/mesh3d.py,sha256=KjAtlVlLYslwgP_uE067WtJRgNURkhaz0PPUuYLlJyw,2778
|
|
53
53
|
plopp/plotting/plot.py,sha256=WQzw1vHGljWY1tQU1InQWe2-M-vCW2IRiL-v7cnw46w,3886
|
|
@@ -68,8 +68,8 @@ plopp/widgets/slice.py,sha256=ihiGEGGva_2WZIug-kizg1I5SFdMzu4_8DDzuHWIKeA,4212
|
|
|
68
68
|
plopp/widgets/style.py,sha256=Fw4S8te0xDyT8-kWu4Ut35aLgyr98qMlWZRbXbd1-dk,184
|
|
69
69
|
plopp/widgets/toolbar.py,sha256=ueNeOZSC2suAG7nCJzqwl8DmtWD5c2J8VkuP-XzJRwI,4683
|
|
70
70
|
plopp/widgets/tools.py,sha256=9l7LmB8qG0OTt5ZJihJzqRna1ouxJthO_Ahnq7WKTtY,7172
|
|
71
|
-
plopp-25.
|
|
72
|
-
plopp-25.
|
|
73
|
-
plopp-25.
|
|
74
|
-
plopp-25.
|
|
75
|
-
plopp-25.
|
|
71
|
+
plopp-25.5.0.dist-info/licenses/LICENSE,sha256=fCqnkzCwkGneGtgOidkO2b3ed6SGZT0yhuworuJG0K0,1553
|
|
72
|
+
plopp-25.5.0.dist-info/METADATA,sha256=bFuzQ8XlAfiKyqMeiONKwEdMhN1te45ZHTGETPx8CtE,4533
|
|
73
|
+
plopp-25.5.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
74
|
+
plopp-25.5.0.dist-info/top_level.txt,sha256=Lk_GLFh37eX-3PO3c6bPkDpir7GjJmbQHYza3IpIphc,6
|
|
75
|
+
plopp-25.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|