plopp 25.7.1__py3-none-any.whl → 25.9.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.
@@ -68,6 +68,8 @@ class Tiled:
68
68
  nrows: int,
69
69
  ncols: int,
70
70
  figsize: tuple[float, float] | None = None,
71
+ hspace: float = 0.05,
72
+ wspace: float = 0.1,
71
73
  **kwargs: Any,
72
74
  ) -> None:
73
75
  self.nrows = nrows
@@ -81,7 +83,9 @@ class Tiled:
81
83
  layout='constrained',
82
84
  )
83
85
 
84
- self.gs = gridspec.GridSpec(nrows, ncols, figure=self.fig, **kwargs)
86
+ self.gs = gridspec.GridSpec(
87
+ nrows, ncols, figure=self.fig, wspace=wspace, hspace=hspace, **kwargs
88
+ )
85
89
  self.figures = np.full((nrows, ncols), None)
86
90
  self._history = []
87
91
 
plopp/data/examples.py CHANGED
@@ -98,7 +98,9 @@ def three_bands(npeaks=200, per_peak=500, spread=30.0):
98
98
  data=sc.ones(sizes=xcoord.sizes, unit='counts'),
99
99
  coords={'x': xcoord, 'y': ycoord},
100
100
  )
101
- return table.hist(y=300, x=300) + sc.scalar(1.0, unit='counts')
101
+ xedges = sc.linspace('x', -50, 350, num=nx + 1, unit='cm')
102
+ yedges = sc.linspace('y', -50, 350, num=ny + 1, unit='cm')
103
+ return table.hist(y=yedges, x=xedges) + sc.scalar(1.0, unit='counts')
102
104
 
103
105
 
104
106
  def clusters3d(nclusters=100, npercluster=2000):
@@ -17,28 +17,58 @@ from ..core.limits import find_limits, fix_empty_range
17
17
  from ..core.utils import maybe_variable_to_number, merge_masks
18
18
 
19
19
 
20
- def _get_cmap(name: str, nan_color: str | None = None) -> Colormap:
20
+ def _shift_color(color: float, delta: float) -> float:
21
+ """
22
+ Shift a color (number from 0 to 1) by delta. If the result is out of bounds,
23
+ the color is shifted in the opposite direction.
24
+ """
25
+ shifted = color + delta
26
+ if shifted > 1.0 or shifted < 0.0:
27
+ return color - delta
28
+ return shifted
29
+
30
+
31
+ def _get_cmap(colormap: str | Colormap, nan_color: str | None = None) -> Colormap:
21
32
  """
22
33
  Get a colormap object from a colormap name.
34
+ We also set the 'over', 'under' and 'bad' colors. The 'bad' color is set to
35
+ ``nan_color`` if it is not None. The 'over' and 'under' colors are set to be
36
+ slightly lighter or darker than the first and last colors in the colormap.
23
37
 
24
38
  Parameters
25
39
  ----------
26
- name:
40
+ colormap:
27
41
  Name of the colormap. If the name is just a single html color, this will
28
- create a colormap with that single color.
42
+ create a colormap with that single color. If ``cmap`` is already a Colormap,
43
+ it will be used as is.
29
44
  nan_color:
30
45
  The color to use for NAN values.
31
46
  """
32
47
 
48
+ if isinstance(colormap, Colormap):
49
+ return colormap
50
+
33
51
  try:
34
52
  if hasattr(mpl, 'colormaps'):
35
- cmap = copy(mpl.colormaps[name])
53
+ cmap = copy(mpl.colormaps[colormap])
36
54
  else:
37
- cmap = mpl.cm.get_cmap(name)
55
+ cmap = mpl.cm.get_cmap(colormap)
38
56
  except (KeyError, ValueError):
39
- cmap = LinearSegmentedColormap.from_list('tmp', [name, name])
40
- # TODO: we need to set under and over values for the cmap with
41
- # `cmap.set_under` and `cmap.set_over`. Ideally these should come from a config?
57
+ cmap = LinearSegmentedColormap.from_list('tmp', [colormap, colormap])
58
+
59
+ # Add under and over values to the cmap
60
+ delta = 0.15
61
+ cmap = cmap.copy()
62
+ over = cmap.get_over()
63
+ under = cmap.get_under()
64
+ # Note that we only shift the first 3 RGB values, leaving alpha unchanged.
65
+ cmap.set_over(
66
+ [_shift_color(c, delta * (-1 + 2 * (np.mean(over) > 0.5))) for c in over[:3]]
67
+ )
68
+ cmap.set_under(
69
+ [_shift_color(c, delta * (-1 + 2 * (np.mean(under) > 0.5))) for c in under[:3]]
70
+ )
71
+
42
72
  if nan_color is not None:
43
73
  cmap.set_bad(color=nan_color)
44
74
  return cmap
@@ -90,8 +120,8 @@ class ColorMapper:
90
120
  self,
91
121
  canvas: Any | None = None,
92
122
  cbar: bool = True,
93
- cmap: str = 'viridis',
94
- mask_cmap: str = 'gray',
123
+ cmap: str | Colormap = 'viridis',
124
+ mask_cmap: str | Colormap = 'gray',
95
125
  norm: Literal['linear', 'log'] = 'linear',
96
126
  vmin: sc.Variable | float | None = None,
97
127
  vmax: sc.Variable | float | None = None,
plopp/plotting/common.py CHANGED
@@ -133,11 +133,14 @@ def check_not_binned(da: sc.DataArray) -> None:
133
133
  )
134
134
 
135
135
 
136
- def check_allowed_dtypes(da: sc.DataArray) -> None:
136
+ def to_allowed_dtypes(da: sc.DataArray) -> sc.DataArray:
137
137
  """
138
138
  Currently, Plopp cannot plot data that contains vector and matrix dtypes.
139
139
  This function will raise an error if the input data type is not supported.
140
140
 
141
+ We also convert boolean data to integers, as some operations downstream
142
+ may not support boolean data types.
143
+
141
144
  Parameters
142
145
  ----------
143
146
  da:
@@ -147,6 +150,9 @@ def check_allowed_dtypes(da: sc.DataArray) -> None:
147
150
  raise TypeError(
148
151
  f'The input has dtype {da.dtype} which is not supported by Plopp.'
149
152
  )
153
+ if da.dtype == bool:
154
+ da = da.to(dtype='int32')
155
+ return da
150
156
 
151
157
 
152
158
  def _all_dims_sorted(var, order='ascending') -> bool:
@@ -283,7 +289,7 @@ def preprocess(
283
289
 
284
290
  out = to_data_array(obj)
285
291
  check_not_binned(out)
286
- check_allowed_dtypes(out)
292
+ out = to_allowed_dtypes(out)
287
293
  if name is not None:
288
294
  out.name = str(name)
289
295
  if not ignore_size:
plopp/widgets/slice.py CHANGED
@@ -27,15 +27,14 @@ class DimSlicer(ipw.VBox):
27
27
  )
28
28
  widget_args = {
29
29
  'step': 1,
30
- 'description': dim,
31
30
  'min': 0,
32
31
  'max': size - 1,
33
32
  'value': (size - 1) // 2 if slider_constr is ipw.IntSlider else None,
34
33
  'continuous_update': True,
35
34
  'readout': False,
36
35
  'layout': {"width": "200px", "margin": "0px 0px 0px 10px"},
37
- 'style': {'description_width': 'initial'},
38
36
  }
37
+ self.dim_label = ipw.Label(value=dim)
39
38
  self.slider = slider_constr(**widget_args)
40
39
  self.continuous_update = ipw.Checkbox(
41
40
  value=True,
@@ -50,7 +49,7 @@ class DimSlicer(ipw.VBox):
50
49
  (self.continuous_update, 'value'), (self.slider, 'continuous_update')
51
50
  )
52
51
 
53
- children = [self.slider, self.continuous_update, self.label]
52
+ children = [self.dim_label, self.slider, self.continuous_update, self.label]
54
53
  if enable_player:
55
54
  self.player = ipw.Play(
56
55
  value=self.slider.value,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plopp
3
- Version: 25.7.1
3
+ Version: 25.9.0
4
4
  Summary: Visualization library for Scipp
5
5
  Author: Scipp contributors
6
6
  License-Expression: BSD-3-Clause
@@ -12,13 +12,12 @@ Classifier: Natural Language :: English
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: Topic :: Scientific/Engineering
20
19
  Classifier: Typing :: Typed
21
- Requires-Python: >=3.10
20
+ Requires-Python: >=3.11
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: lazy-loader>=0.4
@@ -41,7 +40,7 @@ Requires-Dist: mpltoolbox>=24.6.0; extra == "test"
41
40
  Requires-Dist: pandas>=2.2.2; extra == "test"
42
41
  Requires-Dist: plotly>=5.15.0; extra == "test"
43
42
  Requires-Dist: pooch>=1.5; extra == "test"
44
- Requires-Dist: pyarrow>=10.0.0; extra == "test"
43
+ Requires-Dist: pyarrow>=13.0.0; extra == "test"
45
44
  Requires-Dist: pytest>=7.0; extra == "test"
46
45
  Requires-Dist: pythreejs>=2.4.1; extra == "test"
47
46
  Requires-Dist: scipp>=25.5.0; extra == "test"
@@ -11,7 +11,7 @@ plopp/backends/matplotlib/image.py,sha256=YnczwdxsGmh0Nvrk1A8xL93ap2rzKI-0G428OC
11
11
  plopp/backends/matplotlib/line.py,sha256=xWZx_3j7_O1IoNjVOu-KM4Ue9haQ5IqHjRsY-VhyKak,8779
12
12
  plopp/backends/matplotlib/mesh_image.py,sha256=4ndrauA71asWJdA6ZDkh6iPnQPk07kNd3m1h0_bTM6U,8542
13
13
  plopp/backends/matplotlib/scatter.py,sha256=NuYi9G4csQTklUjB7WXSjothrH77C0NY0KHiMPHBqcw,6739
14
- plopp/backends/matplotlib/tiled.py,sha256=BfFHNQ-or19X44N-XaaUf9A3trdSSaCfC2CIAR1WTPg,6127
14
+ plopp/backends/matplotlib/tiled.py,sha256=dy5bKixJP7MYoFJ-bAU4vc6baZaw6aKenD-WoahF_ZM,6238
15
15
  plopp/backends/matplotlib/utils.py,sha256=24gmT2sBHS_wUitUThSLavwSK95uqbLAhadNdxC19I0,3479
16
16
  plopp/backends/plotly/__init__.py,sha256=QNPZgWV3wO8psaMkSB-GtTOP-OIe9jSfwDdEt2xgbZg,107
17
17
  plopp/backends/plotly/canvas.py,sha256=JQXl8c23Ju-DTame2rZ4T_lgrArgH1WElUGJIaGyEbU,8943
@@ -33,7 +33,7 @@ plopp/core/typing.py,sha256=JL_mMdFq2dNu6LuZYSBfOXGZSEn0VIJK_lr-LbC11t4,2903
33
33
  plopp/core/utils.py,sha256=qxdOLRODgv3b0dDywT0JomsVrgifS_siC-ZpzJqgblo,7120
34
34
  plopp/core/view.py,sha256=9WulgLHg8aPjePz967WLWieTM40dvqlgJitu-AS3WdM,1972
35
35
  plopp/data/__init__.py,sha256=sOTLyBuiH-dxmpiVsZxd7L7YTkFMfAQUvah1g04AiQk,581
36
- plopp/data/examples.py,sha256=ysXNnZRywZUU9xDrACaFNK-8UCY_v70ZB169XXvToF4,3726
36
+ plopp/data/examples.py,sha256=OoMKhxBvz_YaWfCJWXJmxSrXYFwI8sBbvE3YnPnd3fU,3858
37
37
  plopp/data/factory.py,sha256=A9plNosKSdKFfQdeY538EHcjK7IU4yqsSoj9p1-5Q-k,7026
38
38
  plopp/data/testing.py,sha256=g1PT5o7omwucdtRp37ep1fjr__kVBjpMkP4fz5xC2So,430
39
39
  plopp/graphics/__init__.py,sha256=s25RIbKplHSRn0jjtLADPQl72JLf_KLRMRCfeMDI_UA,205
@@ -41,13 +41,13 @@ plopp/graphics/__init__.pyi,sha256=yZQkWxUfP9eKHSP47WjrBiu59Z-uhP5gE2eUrPDa6jU,6
41
41
  plopp/graphics/basefig.py,sha256=N5gBQE8w2968biRV7a3wkxxq-BM14ncfX52y5HziWiQ,824
42
42
  plopp/graphics/bbox.py,sha256=3WeMgu5LgWIXLJTYVT7_USwaAcS7cQPNCk6B0gvuNGo,3596
43
43
  plopp/graphics/camera.py,sha256=fXc1YH7Tp-rwKkcYeE-mHrxMz3SKauj5xJCRuKv-QPs,5323
44
- plopp/graphics/colormapper.py,sha256=u5cADKU9lrRkJ_a969i_5z-mdT0-lBnEonc0PW_xSXA,9643
44
+ plopp/graphics/colormapper.py,sha256=SEr68k3nRJW2VPV_42SwtQq7-gJHPA3n37YWoXNtgJs,10685
45
45
  plopp/graphics/figures.py,sha256=PLWQLnQNWz8epubYlK7HLSkvPGJmTAmHjJM2DqpvLe8,2735
46
46
  plopp/graphics/graphicalview.py,sha256=07xpJVnvuNlaWGsJshg_wL81jG57JhRxI23E7_WYI2M,9435
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=dwtOpmMNY8deLWskiByKXficZUqX1pPGrkT_ieDN36c,10984
50
+ plopp/plotting/common.py,sha256=L4qWscC6u8bgViecysVUi0mV6DHxycObkq_-nNdJb28,11182
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
@@ -64,12 +64,12 @@ plopp/widgets/clip3d.py,sha256=L90HUd3bjEU3BaPdK8DnUbeeFNqfFyBWDEwaG9nP-M8,14602
64
64
  plopp/widgets/debounce.py,sha256=V5aIcnb465oqXZX-UG_DR7GjvoG6D_C2jjEUBmguGDA,1292
65
65
  plopp/widgets/drawing.py,sha256=Pcozffq7I5H9x57GNBJVvkCjVR6eaPBuxyHlFkEEjzQ,6252
66
66
  plopp/widgets/linesave.py,sha256=s5QcY-31x7Hvf9iLHmzfFIzodXTD9BX0Av3NlG8GS88,2458
67
- plopp/widgets/slice.py,sha256=hG1QzLsjmxjY4fjQwtlu8GxK6zzalrZsZxZzhwIaskg,5499
67
+ plopp/widgets/slice.py,sha256=rWBxvNru7m9PDWSjUUb-WGPCTDfOcNDQBjP88HFEqbc,5474
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.7.1.dist-info/licenses/LICENSE,sha256=fCqnkzCwkGneGtgOidkO2b3ed6SGZT0yhuworuJG0K0,1553
72
- plopp-25.7.1.dist-info/METADATA,sha256=noV3Jq7bY-J5VfnuPJ9kqXjYryD7ExTFR4pjDi3Q9Yk,2900
73
- plopp-25.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
74
- plopp-25.7.1.dist-info/top_level.txt,sha256=Lk_GLFh37eX-3PO3c6bPkDpir7GjJmbQHYza3IpIphc,6
75
- plopp-25.7.1.dist-info/RECORD,,
71
+ plopp-25.9.0.dist-info/licenses/LICENSE,sha256=fCqnkzCwkGneGtgOidkO2b3ed6SGZT0yhuworuJG0K0,1553
72
+ plopp-25.9.0.dist-info/METADATA,sha256=M-OflE2x859M-foyGiW1pCHiH-cXd7Y7jZQ-wreNwkU,2849
73
+ plopp-25.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
74
+ plopp-25.9.0.dist-info/top_level.txt,sha256=Lk_GLFh37eX-3PO3c6bPkDpir7GjJmbQHYza3IpIphc,6
75
+ plopp-25.9.0.dist-info/RECORD,,
File without changes