dataeval-plots 0.0.12__tar.gz → 0.0.13__tar.gz

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.
Files changed (17) hide show
  1. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/PKG-INFO +1 -1
  2. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/__init__.py +40 -17
  3. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/_version.py +2 -2
  4. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/.gitignore +0 -0
  5. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/README.md +0 -0
  6. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/pyproject.toml +0 -0
  7. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/_registry.py +0 -0
  8. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/__init__.py +0 -0
  9. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_altair.py +0 -0
  10. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_base.py +0 -0
  11. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_feasibility_layout.py +0 -0
  12. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_matplotlib.py +0 -0
  13. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_plotly.py +0 -0
  14. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_seaborn.py +0 -0
  15. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/backends/_shared.py +0 -0
  16. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/protocols.py +0 -0
  17. {dataeval_plots-0.0.12 → dataeval_plots-0.0.13}/src/dataeval_plots/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dataeval-plots
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: DataEval companion package for plotting utilities
5
5
  Project-URL: Homepage, https://dataeval.ai/
6
6
  Project-URL: Repository, https://github.com/aria-ml/dataeval/
@@ -198,7 +198,26 @@ def plot(
198
198
  >>> plot(result, images=dataset) # Uses seaborn
199
199
  """
200
200
  plotting_backend = get_backend(backend)
201
- return plotting_backend.plot(output, figsize=figsize, **kwargs)
201
+ return _display_once(plotting_backend.plot(output, figsize=figsize, **kwargs))
202
+
203
+
204
+ def _display_once(result: Any) -> Any:
205
+ """
206
+ Close a returned matplotlib figure under the notebook inline backend, so the notebook draws it once.
207
+
208
+ The inline backend draws every open pyplot figure when a cell ends, and the notebook draws a returned figure as
209
+ the cell's value, so an open returned figure appears twice. Closing it leaves the returned value as the only
210
+ drawing. Under any other backend the figure stays open for ``plt.show()``, and a list of figures is left open
211
+ because a notebook shows a list as text.
212
+ """
213
+ import matplotlib
214
+ from matplotlib.figure import Figure
215
+
216
+ if isinstance(result, Figure) and "inline" in matplotlib.get_backend().lower():
217
+ import matplotlib.pyplot as plt
218
+
219
+ plt.close(result)
220
+ return result
202
221
 
203
222
 
204
223
  def project(
@@ -319,14 +338,16 @@ def project(
319
338
  )
320
339
  for m in methods
321
340
  ]
322
- return plotting_backend.project_grid(
323
- reduced_list,
324
- methods=methods,
325
- labels=labels_array,
326
- label_names=label_names,
327
- dimensions=dimensions,
328
- figsize=figsize,
329
- title=title,
341
+ return _display_once(
342
+ plotting_backend.project_grid(
343
+ reduced_list,
344
+ methods=methods,
345
+ labels=labels_array,
346
+ label_names=label_names,
347
+ dimensions=dimensions,
348
+ figsize=figsize,
349
+ title=title,
350
+ )
330
351
  )
331
352
 
332
353
  # Single method
@@ -347,12 +368,14 @@ def project(
347
368
  )
348
369
  dimensions = embeddings_array.shape[1] # type: ignore[assignment]
349
370
 
350
- return plotting_backend.project(
351
- embeddings_array,
352
- labels=labels_array,
353
- label_names=label_names,
354
- method=method or "custom",
355
- dimensions=dimensions,
356
- figsize=figsize,
357
- title=title,
371
+ return _display_once(
372
+ plotting_backend.project(
373
+ embeddings_array,
374
+ labels=labels_array,
375
+ label_names=label_names,
376
+ method=method or "custom",
377
+ dimensions=dimensions,
378
+ figsize=figsize,
379
+ title=title,
380
+ )
358
381
  )
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.0.12'
22
- __version_tuple__ = version_tuple = (0, 0, 12)
21
+ __version__ = version = '0.0.13'
22
+ __version_tuple__ = version_tuple = (0, 0, 13)
23
23
 
24
24
  __commit_id__ = commit_id = None