batplot 1.7.27__tar.gz → 1.7.28__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.

Potentially problematic release.


This version of batplot might be problematic. Click here for more details.

Files changed (60) hide show
  1. {batplot-1.7.27/batplot.egg-info → batplot-1.7.28}/PKG-INFO +1 -1
  2. {batplot-1.7.27 → batplot-1.7.28}/batplot/__init__.py +1 -1
  3. {batplot-1.7.27 → batplot-1.7.28}/batplot/operando_ec_interactive.py +68 -2
  4. {batplot-1.7.27 → batplot-1.7.28/batplot.egg-info}/PKG-INFO +1 -1
  5. {batplot-1.7.27 → batplot-1.7.28}/pyproject.toml +1 -1
  6. {batplot-1.7.27 → batplot-1.7.28}/LICENSE +0 -0
  7. {batplot-1.7.27 → batplot-1.7.28}/MANIFEST.in +0 -0
  8. {batplot-1.7.27 → batplot-1.7.28}/README.md +0 -0
  9. {batplot-1.7.27 → batplot-1.7.28}/USER_MANUAL.md +0 -0
  10. {batplot-1.7.27 → batplot-1.7.28}/batplot/args.py +0 -0
  11. {batplot-1.7.27 → batplot-1.7.28}/batplot/batch.py +0 -0
  12. {batplot-1.7.27 → batplot-1.7.28}/batplot/batplot.py +0 -0
  13. {batplot-1.7.27 → batplot-1.7.28}/batplot/cif.py +0 -0
  14. {batplot-1.7.27 → batplot-1.7.28}/batplot/cli.py +0 -0
  15. {batplot-1.7.27 → batplot-1.7.28}/batplot/color_utils.py +0 -0
  16. {batplot-1.7.27 → batplot-1.7.28}/batplot/config.py +0 -0
  17. {batplot-1.7.27 → batplot-1.7.28}/batplot/converters.py +0 -0
  18. {batplot-1.7.27 → batplot-1.7.28}/batplot/cpc_interactive.py +0 -0
  19. {batplot-1.7.27 → batplot-1.7.28}/batplot/data/USER_MANUAL.md +0 -0
  20. {batplot-1.7.27 → batplot-1.7.28}/batplot/electrochem_interactive.py +0 -0
  21. {batplot-1.7.27 → batplot-1.7.28}/batplot/interactive.py +0 -0
  22. {batplot-1.7.27 → batplot-1.7.28}/batplot/manual.py +0 -0
  23. {batplot-1.7.27 → batplot-1.7.28}/batplot/modes.py +0 -0
  24. {batplot-1.7.27 → batplot-1.7.28}/batplot/operando.py +0 -0
  25. {batplot-1.7.27 → batplot-1.7.28}/batplot/plotting.py +0 -0
  26. {batplot-1.7.27 → batplot-1.7.28}/batplot/readers.py +0 -0
  27. {batplot-1.7.27 → batplot-1.7.28}/batplot/session.py +0 -0
  28. {batplot-1.7.27 → batplot-1.7.28}/batplot/style.py +0 -0
  29. {batplot-1.7.27 → batplot-1.7.28}/batplot/ui.py +0 -0
  30. {batplot-1.7.27 → batplot-1.7.28}/batplot/utils.py +0 -0
  31. {batplot-1.7.27 → batplot-1.7.28}/batplot/version_check.py +0 -0
  32. {batplot-1.7.27 → batplot-1.7.28}/batplot.egg-info/SOURCES.txt +0 -0
  33. {batplot-1.7.27 → batplot-1.7.28}/batplot.egg-info/dependency_links.txt +0 -0
  34. {batplot-1.7.27 → batplot-1.7.28}/batplot.egg-info/entry_points.txt +0 -0
  35. {batplot-1.7.27 → batplot-1.7.28}/batplot.egg-info/requires.txt +0 -0
  36. {batplot-1.7.27 → batplot-1.7.28}/batplot.egg-info/top_level.txt +0 -0
  37. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/__init__.py +0 -0
  38. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/args.py +0 -0
  39. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/batch.py +0 -0
  40. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/batplot.py +0 -0
  41. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/cif.py +0 -0
  42. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/cli.py +0 -0
  43. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/color_utils.py +0 -0
  44. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/config.py +0 -0
  45. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/converters.py +0 -0
  46. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/cpc_interactive.py +0 -0
  47. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/electrochem_interactive.py +0 -0
  48. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/interactive.py +0 -0
  49. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/modes.py +0 -0
  50. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/operando.py +0 -0
  51. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/operando_ec_interactive.py +0 -0
  52. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/plotting.py +0 -0
  53. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/readers.py +0 -0
  54. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/session.py +0 -0
  55. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/style.py +0 -0
  56. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/ui.py +0 -0
  57. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/utils.py +0 -0
  58. {batplot-1.7.27 → batplot-1.7.28}/batplot_backup_20251121_223043/version_check.py +0 -0
  59. {batplot-1.7.27 → batplot-1.7.28}/setup.cfg +0 -0
  60. {batplot-1.7.27 → batplot-1.7.28}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: batplot
3
- Version: 1.7.27
3
+ Version: 1.7.28
4
4
  Summary: Interactive plotting tool for material science (1D plot) and electrochemistry (GC, CV, dQ/dV, CPC, operando) with batch processing
5
5
  Author-email: Tian Dai <tianda@uio.no>
6
6
  License: MIT License
@@ -1,5 +1,5 @@
1
1
  """batplot: Interactive plotting for battery data visualization."""
2
2
 
3
- __version__ = "1.7.27"
3
+ __version__ = "1.7.28"
4
4
 
5
5
  __all__ = ["__version__"]
@@ -344,6 +344,64 @@ def _update_custom_colorbar(cbar_ax, im=None, label=None, label_mode=None):
344
344
  _draw_custom_colorbar(cbar_ax, im, label, label_mode)
345
345
 
346
346
 
347
+ def _detach_mpl_colorbar_callbacks(cbar, im) -> None:
348
+ """Detach a Matplotlib Colorbar from its mappable callbacks.
349
+
350
+ Why this exists:
351
+ - In this interactive menu we draw a *custom* colorbar by clearing/redrawing `cbar.ax`.
352
+ - If `cbar` is a real `matplotlib.colorbar.Colorbar` (e.g., loaded from a session),
353
+ it remains connected to `im` via `im.callbacksSM`. Subsequent `im.set_clim()` /
354
+ `im.set_cmap()` triggers `Colorbar.update_normal()`, which can crash after we
355
+ cleared/redrew the axes (observed as: NotImplementedError: cannot remove artist).
356
+ - We therefore disconnect that callback once and always update the custom colorbar
357
+ via `_update_custom_colorbar(...)`.
358
+ """
359
+ try:
360
+ if cbar is None or im is None:
361
+ return
362
+ cax = getattr(cbar, 'ax', None)
363
+ if cax is not None and getattr(cax, '_bp_detached_mpl_colorbar', False):
364
+ return
365
+
366
+ # Matplotlib's Colorbar stores the callback id as `_cid` (most versions).
367
+ cid = None
368
+ for attr in ('_cid', '_cid_colorbar', 'cid'):
369
+ try:
370
+ v = getattr(cbar, attr, None)
371
+ if isinstance(v, int):
372
+ cid = v
373
+ break
374
+ except Exception:
375
+ pass
376
+
377
+ # Disconnect from the ScalarMappable callback registry.
378
+ if cid is not None:
379
+ try:
380
+ cbreg = getattr(im, 'callbacksSM', None)
381
+ if cbreg is not None and hasattr(cbreg, 'disconnect'):
382
+ cbreg.disconnect(cid)
383
+ except Exception:
384
+ pass
385
+
386
+ # Prevent future built-in updates (best-effort; safe for mock colorbars too).
387
+ try:
388
+ if hasattr(cbar, 'mappable'):
389
+ cbar.mappable = None
390
+ except Exception:
391
+ pass
392
+ try:
393
+ if hasattr(cbar, 'solids'):
394
+ cbar.solids = None
395
+ except Exception:
396
+ pass
397
+
398
+ if cax is not None:
399
+ setattr(cax, '_bp_detached_mpl_colorbar', True)
400
+ except Exception:
401
+ # Never let detaching break the interactive menu.
402
+ return
403
+
404
+
347
405
  def _ensure_fixed_params(fig, ax, cbar_ax, ec_ax):
348
406
  """Initialize and return fixed geometry parameters in inches.
349
407
 
@@ -540,6 +598,11 @@ def operando_ec_interactive_menu(fig, ax, im, cbar, ec_ax, file_paths=None):
540
598
  # Normalize file path list for downstream helpers
541
599
  file_paths = list(file_paths) if file_paths else []
542
600
 
601
+ # If we were given a real Matplotlib Colorbar (e.g. from session load),
602
+ # detach it from `im` immediately. This must happen before any function
603
+ # that may clear/redraw `cbar.ax` (custom colorbar) is called.
604
+ _detach_mpl_colorbar_callbacks(cbar, im)
605
+
543
606
  def _renormalize_to_visible():
544
607
  """Adjust color scale to match the intensity range of the currently visible region.
545
608
 
@@ -904,6 +967,9 @@ def operando_ec_interactive_menu(fig, ax, im, cbar, ec_ax, file_paths=None):
904
967
  # Initialize custom colorbar (replaces matplotlib's colorbar)
905
968
  cbar_label = getattr(cbar.ax, '_colorbar_label', 'Intensity')
906
969
  cbar_label_mode = getattr(fig, '_colorbar_label_mode', 'normal')
970
+ # If we were given a real Matplotlib Colorbar (e.g. from session load),
971
+ # detach it from `im` before we clear/redraw the axes for the custom colorbar.
972
+ _detach_mpl_colorbar_callbacks(cbar, im)
907
973
  _draw_custom_colorbar(cbar.ax, im, cbar_label, cbar_label_mode)
908
974
  # Decrease distance between operando and EC plots once per session
909
975
  if not getattr(ec_ax, '_ec_gap_adjusted', False):
@@ -1204,7 +1270,7 @@ def operando_ec_interactive_menu(fig, ax, im, cbar, ec_ax, file_paths=None):
1204
1270
  if snap.get('cmap'):
1205
1271
  im.set_cmap(snap['cmap'])
1206
1272
  if cbar is not None:
1207
- cbar.update_normal(im)
1273
+ _update_custom_colorbar(cbar.ax, im)
1208
1274
  except Exception:
1209
1275
  pass
1210
1276
  # Restore colorbar side (ticks/label) and redraw custom colorbar to keep position
@@ -3921,7 +3987,7 @@ def operando_ec_interactive_menu(fig, ax, im, cbar, ec_ax, file_paths=None):
3921
3987
  try:
3922
3988
  im.set_cmap(cmap)
3923
3989
  if cbar is not None:
3924
- cbar.update_normal(im)
3990
+ _update_custom_colorbar(cbar.ax, im)
3925
3991
  except Exception:
3926
3992
  pass
3927
3993
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: batplot
3
- Version: 1.7.27
3
+ Version: 1.7.28
4
4
  Summary: Interactive plotting tool for material science (1D plot) and electrochemistry (GC, CV, dQ/dV, CPC, operando) with batch processing
5
5
  Author-email: Tian Dai <tianda@uio.no>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "batplot"
7
- version = "1.7.27"
7
+ version = "1.7.28"
8
8
  description = "Interactive plotting tool for material science (1D plot) and electrochemistry (GC, CV, dQ/dV, CPC, operando) with batch processing"
9
9
  authors = [
10
10
  { name = "Tian Dai", email = "tianda@uio.no" }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes