batplot 1.7.28__py3-none-any.whl → 1.8.1__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.

Potentially problematic release.


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

batplot/session.py CHANGED
@@ -578,7 +578,10 @@ def dump_operando_session(
578
578
  # Use masked arrays to preserve NaNs if present
579
579
  data = _np.array(arr) # preserves mask where possible
580
580
  extent = tuple(map(float, im.get_extent())) if hasattr(im, 'get_extent') else None
581
- cmap_name = getattr(im.get_cmap(), 'name', None)
581
+ # Get colormap name: first check if we stored it explicitly, otherwise try to get from colormap object
582
+ cmap_name = getattr(im, '_operando_cmap_name', None)
583
+ if cmap_name is None:
584
+ cmap_name = getattr(im.get_cmap(), 'name', None)
582
585
  clim = tuple(map(float, im.get_clim())) if hasattr(im, 'get_clim') else None
583
586
  origin = getattr(im, 'origin', 'upper')
584
587
  interpolation = getattr(im, 'get_interpolation', lambda: None)() or 'nearest'
@@ -870,6 +873,8 @@ def load_operando_session(filename: str):
870
873
  cmap_name = 'viridis'
871
874
  im = ax.imshow(arr, aspect='auto', origin=op.get('origin', 'upper'), extent=extent,
872
875
  cmap=cmap_name, interpolation=op.get('interpolation', 'nearest'))
876
+ # Store the colormap name explicitly so it can be retrieved reliably when saving
877
+ setattr(im, '_operando_cmap_name', cmap_name)
873
878
  if op.get('clim'):
874
879
  try:
875
880
  im.set_clim(*op['clim'])
@@ -1315,6 +1320,18 @@ def load_operando_session(filename: str):
1315
1320
  elif ec_h_offset is not None:
1316
1321
  # EC panel doesn't exist but offset was saved - ignore it
1317
1322
  pass
1323
+
1324
+ # Apply layout with loaded offsets to ensure visual position matches saved position
1325
+ # This must happen after all offsets and geometry parameters are set
1326
+ try:
1327
+ from .operando_ec_interactive import _apply_group_layout_inches, _ensure_fixed_params
1328
+ # Get current geometry parameters (which should match what was just loaded)
1329
+ cb_w_i, cb_gap_i, ec_gap_i, ec_w_i, ax_w_i, ax_h_i = _ensure_fixed_params(fig, ax, cbar_ax, ec_ax)
1330
+ # Apply layout with loaded offsets (offsets are already set as attributes above)
1331
+ _apply_group_layout_inches(fig, ax, cbar_ax, ec_ax, ax_w_i, ax_h_i, cb_w_i, cb_gap_i, ec_gap_i, ec_w_i)
1332
+ except Exception:
1333
+ # If layout application fails, continue - better to have a slightly wrong layout than crash
1334
+ pass
1318
1335
  except Exception:
1319
1336
  pass
1320
1337
 
batplot/utils.py CHANGED
@@ -540,6 +540,46 @@ def list_files_in_subdirectory(extensions: tuple, file_type: str, base_path: str
540
540
  return sorted(files, key=lambda x: x[0])
541
541
 
542
542
 
543
+ def convert_label_shortcuts(text: str) -> str:
544
+ """Convert shortcut syntax to LaTeX format for labels.
545
+
546
+ Converts {super(...)} and {sub(...)} shortcuts to LaTeX superscript/subscript format.
547
+ This allows easier input of mathematical notation without typing full LaTeX.
548
+
549
+ Args:
550
+ text: Label text that may contain {super(...)} or {sub(...)} shortcuts
551
+
552
+ Returns:
553
+ Text with shortcuts converted to LaTeX format (uses \\mathrm{} to prevent italic rendering).
554
+
555
+ Examples:
556
+ >>> convert_label_shortcuts("g{super(-1)}")
557
+ "g$^{\\mathrm{-1}}$"
558
+ >>> convert_label_shortcuts("Li{sub(2)}FeSeO")
559
+ "Li$_{\\mathrm{2}}$FeSeO"
560
+ >>> convert_label_shortcuts("H{sub(2)}O")
561
+ "H$_{\\mathrm{2}}$O"
562
+ """
563
+ if not text:
564
+ return text
565
+
566
+ import re
567
+
568
+ # Convert {super(...)} to $^{\mathrm{...}}$ to prevent italic rendering
569
+ # Pattern matches {super(anything inside)}
570
+ # Use \mathrm{} to ensure non-italic rendering unless explicitly specified
571
+ # Need to escape backslashes in replacement string for LaTeX commands
572
+ text = re.sub(r'\{super\(([^)]+)\)\}', r'$^{\\mathrm{\1}}$', text)
573
+
574
+ # Convert {sub(...)} to $_{\mathrm{...}}$ to prevent italic rendering
575
+ # Pattern matches {sub(anything inside)}
576
+ # Use \mathrm{} to ensure non-italic rendering unless explicitly specified
577
+ # Need to escape backslashes in replacement string for LaTeX commands
578
+ text = re.sub(r'\{sub\(([^)]+)\)\}', r'$_{\\mathrm{\1}}$', text)
579
+
580
+ return text
581
+
582
+
543
583
  def normalize_label_text(text: str) -> str:
544
584
  """Normalize axis label text for proper matplotlib rendering.
545
585
 
batplot/version_check.py CHANGED
@@ -53,6 +53,54 @@ import time
53
53
  from pathlib import Path
54
54
  from typing import Optional, Tuple
55
55
 
56
+ # ====================================================================================
57
+ # UPDATE INFO CONFIGURATION
58
+ # ====================================================================================
59
+ # Edit this section to customize update notification messages and add update info.
60
+ #
61
+ # HOW TO USE:
62
+ # ----------
63
+ # When releasing a new version, edit the UPDATE_INFO dictionary below to include
64
+ # information about what's new or important in the update. This information will
65
+ # be displayed to users when they run batplot and a newer version is available.
66
+ #
67
+ # EXAMPLE:
68
+ # --------
69
+ # UPDATE_INFO = {
70
+ # 'custom_message': "This update includes important bug fixes and new features.",
71
+ # 'update_notes': [
72
+ # "- Fixed colormap preservation issue in session files",
73
+ # "- Improved legend positioning when toggling visibility",
74
+ # "- Added superscript/subscript shortcuts for labels",
75
+ # "- Enhanced version check notifications"
76
+ # ],
77
+ # 'show_update_notes': True,
78
+ # }
79
+ #
80
+ # To disable custom messages, set 'custom_message' to None.
81
+ # To disable update notes, set 'update_notes' to None or an empty list [].
82
+ # ====================================================================================
83
+
84
+ UPDATE_INFO = {
85
+ # Custom message to include in update notification
86
+ # Set to None or empty string to disable
87
+ # This will be displayed as an additional line in the update message box
88
+ 'custom_message': "This update includes important bug fixes", # Example: "This update includes important bug fixes."
89
+
90
+ # Additional notes about the update (list of strings)
91
+ # Set to None or empty list [] to disable
92
+ # Each item in the list will be displayed as a separate line
93
+ 'update_notes': None, # Example: ["- Fixed colormap preservation issue", "- Improved legend positioning"]
94
+
95
+ # Whether to show update notes if provided
96
+ # Set to False to hide update notes even if they are defined
97
+ 'show_update_notes': True,
98
+ }
99
+
100
+ # ====================================================================================
101
+ # END OF UPDATE INFO CONFIGURATION
102
+ # ====================================================================================
103
+
56
104
 
57
105
  def get_cache_file() -> Path:
58
106
  """Get the path to the version check cache file."""
@@ -160,12 +208,43 @@ def _print_update_message(current: str, latest: str) -> None:
160
208
  current: Current version
161
209
  latest: Latest available version
162
210
  """
163
- print(f"\n\033[93m╭{'─' * 68}╮\033[0m")
164
- print(f"\033[93m│\033[0m \033[1mA new version of batplot is available!\033[0m" + " " * 31 + "\033[93m│\033[0m")
165
- print(f"\033[93m│\033[0m Current: \033[91m{current}\033[0m → Latest: \033[92m{latest}\033[0m" + " " * (42 - len(current) - len(latest)) + "\033[93m│\033[0m")
166
- print(f"\033[93m│\033[0m Update with: \033[96mpip install --upgrade batplot\033[0m" + " " * 20 + "\033[93m│\033[0m")
167
- print(f"\033[93m│\033[0m To disable this check: \033[96mexport BATPLOT_NO_VERSION_CHECK=1\033[0m" + " " * 7 + "\033[93m│\033[0m")
168
- print(f"\033[93m╰{'─' * 68}╯\033[0m\n")
211
+ # Calculate box width (minimum 68, expand if needed for longer messages)
212
+ box_width = 68
213
+ custom_msg = UPDATE_INFO.get('custom_message')
214
+ update_notes = UPDATE_INFO.get('update_notes')
215
+ show_notes = UPDATE_INFO.get('show_update_notes', True)
216
+
217
+ # Calculate required width based on content
218
+ max_line_len = 68 # Default minimum width
219
+ if custom_msg:
220
+ max_line_len = max(max_line_len, len(custom_msg) + 4)
221
+ if update_notes and show_notes:
222
+ for note in update_notes:
223
+ max_line_len = max(max_line_len, len(note) + 4)
224
+ # Ensure box width is at least the calculated width
225
+ box_width = max(68, min(max_line_len, 100)) # Cap at 100 for readability
226
+
227
+ print(f"\n\033[93m╭{'─' * box_width}╮\033[0m")
228
+ print(f"\033[93m│\033[0m \033[1mA new version of batplot is available!\033[0m" + " " * max(0, box_width - 34) + "\033[93m│\033[0m")
229
+ print(f"\033[93m│\033[0m Current: \033[91m{current}\033[0m → Latest: \033[92m{latest}\033[0m" + " " * max(0, box_width - 20 - len(current) - len(latest)) + "\033[93m│\033[0m")
230
+
231
+ # Add custom message if provided
232
+ if custom_msg and custom_msg.strip():
233
+ # Truncate if too long to fit in box
234
+ msg = custom_msg[:box_width - 6] if len(custom_msg) > box_width - 6 else custom_msg
235
+ print(f"\033[93m│\033[0m {msg}" + " " * max(0, box_width - len(msg) - 4) + "\033[93m│\033[0m")
236
+
237
+ # Add update notes if provided
238
+ if update_notes and show_notes and isinstance(update_notes, list):
239
+ for note in update_notes:
240
+ if note and note.strip():
241
+ # Truncate if too long to fit in box
242
+ note_text = note[:box_width - 6] if len(note) > box_width - 6 else note
243
+ print(f"\033[93m│\033[0m {note_text}" + " " * max(0, box_width - len(note_text) - 4) + "\033[93m│\033[0m")
244
+
245
+ print(f"\033[93m│\033[0m Update with: \033[96mpip install --upgrade batplot\033[0m" + " " * max(0, box_width - 34) + "\033[93m│\033[0m")
246
+ print(f"\033[93m│\033[0m To disable this check: \033[96mexport BATPLOT_NO_VERSION_CHECK=1\033[0m" + " " * max(0, box_width - 45) + "\033[93m│\033[0m")
247
+ print(f"\033[93m╰{'─' * box_width}╯\033[0m\n")
169
248
 
170
249
 
171
250
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: batplot
3
- Version: 1.7.28
3
+ Version: 1.8.1
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
- batplot/__init__.py,sha256=-ltjJXFlBiOKZsOOZXOESTkYH2FPtkDXmHBrbMWVfVc,119
2
- batplot/args.py,sha256=6g1eHVsycDSAenwrXuCTcyuXCy_-30zy1lWtdguBG2s,34983
1
+ batplot/__init__.py,sha256=AjJgj7OxrIM-uNCR6JvGnRjpVNZgCUbmj0VE_BpFFF8,118
2
+ batplot/args.py,sha256=GXOO5jfTSmd5y_MiGyabh-mgJsCrg3mKVfTwe1eKOYc,34961
3
3
  batplot/batch.py,sha256=YQ7obCIqLCObwDbM7TXpOBh7g7BO95wZNsa2Fy84c6o,53858
4
4
  batplot/batplot.py,sha256=40lU1nY1NqeAOpzNG_vLF_L34COKhiA19pMpbvA3SJc,171885
5
5
  batplot/cif.py,sha256=JfHwNf3SHrcpALc_F5NjJmQ3lg71MBRSaIUJjGYPTx8,30120
@@ -7,22 +7,22 @@ batplot/cli.py,sha256=ScDb2je8VQ0mz_z0SLCHEigiTuFPY5pb1snnzCouKms,5828
7
7
  batplot/color_utils.py,sha256=7InQLVo1XTg7sgAbltM2KeDSFJgr787YEaV9vJbIoWY,20460
8
8
  batplot/config.py,sha256=6nGY7fKN4T5KZUGQS2ArUBgEkLAL0j37XwG5SCVQgKA,6420
9
9
  batplot/converters.py,sha256=rR2WMPM0nR5E3eZI3gWbaJf_AfbdQx3urVSbJmZXNzo,8237
10
- batplot/cpc_interactive.py,sha256=7J_aj9fYXqjTWJWM7QqfyYrQcJCtFErH6mCsluXhzj4,232888
11
- batplot/electrochem_interactive.py,sha256=W1bWrA8sqpVvYyZC6T5Y8IWQcNGgjRoVJtBWHrMdIcY,218567
12
- batplot/interactive.py,sha256=cU7i6S2MRUjUA0DwCchIdk8vmnBgpcsZuBPBVsispUI,204281
10
+ batplot/cpc_interactive.py,sha256=HrrjaB8-CNYUitgl5zWMNvWQLZfxyFAtpSm67qoi-nE,238235
11
+ batplot/electrochem_interactive.py,sha256=ti7V8BoAxUk4BD_vDRKAu5ydlHMl75htLvdVYFUUVsw,221778
12
+ batplot/interactive.py,sha256=uerVR-56g2Ur8qDZ-cXffPbpYMQXEXiMNXCxyWZZ8k0,206259
13
13
  batplot/manual.py,sha256=pbRI6G4Pm12pOW8LrOLWWu7IEOtqWN3tRHtgge50LlA,11556
14
- batplot/modes.py,sha256=qE2OsOQQKhwOWene5zxJeuuewTrZxubtahQuz5je7ok,37252
15
- batplot/operando.py,sha256=1i1kb6YKEVXFFKfLWKXr5MwA2hOOQQoVSnT3rgpnWG8,28176
16
- batplot/operando_ec_interactive.py,sha256=x-Q69AEtuTNYnDlHdgMeHsLeWSIVZ2KCR-hLNV4Kvj0,297027
14
+ batplot/modes.py,sha256=Utfal5IaV8rfoNyNFziUZpqRlpZAWJdiTc45DY-FJE8,37300
15
+ batplot/operando.py,sha256=p2Ug1mFUQxaU702cTBGgJKb3_v1C2p3LLUwfXaVBpPY,28311
16
+ batplot/operando_ec_interactive.py,sha256=TMB6rDpeolX0CgE2V7tWC24ffJrnbJomQSnTsTd8CNQ,305121
17
17
  batplot/plotting.py,sha256=hG2_EdDhF1Qpn1XfZKdCQ5-w_m9gUYFbr804UQ5QjsU,10841
18
18
  batplot/readers.py,sha256=kAI0AvYrdfGRZkvADJ4riN96IWtrH24aAoZpBtONTbw,112960
19
- batplot/session.py,sha256=xwEcCM0r_gehJdNZdSUT4Kj5joN9rZ7WsAReetcNFiw,133244
19
+ batplot/session.py,sha256=05JsVi0ygMzOxVRRZ4klhE5Eh6eE6QxKR8p7_j6slBI,134429
20
20
  batplot/style.py,sha256=ig1ozX4dhEsXf5JKaPZOvgVS3CWx-BTFSc3vfAH3Y-E,62274
21
21
  batplot/ui.py,sha256=ifpbK74juUzLMCt-sJGVaWtpDb1NMRJzs2YyiwwafzY,35302
22
- batplot/utils.py,sha256=VtCShOPD4Z_cVODBINclfFdD12pLdSe1av9ZAnE27zY,36043
23
- batplot/version_check.py,sha256=OG4LuHo5-rSqLLHQo5nWbX9lbNq6NyxRdvVUUcJRBqQ,6219
22
+ batplot/utils.py,sha256=LY2-Axr3DsQMTxuXe48vSjrLJKEnkzkZjdSFdQizbpg,37599
23
+ batplot/version_check.py,sha256=ztTHwqgWd8OlS9PLLY5A_TabWxBASDA_-5yyN15PZC8,9996
24
24
  batplot/data/USER_MANUAL.md,sha256=VYPvNZt3Fy8Z4Izr2FnQBw9vEaFTPkybhHDnF-OuKws,17694
25
- batplot-1.7.28.dist-info/licenses/LICENSE,sha256=2PAnHeCiTfgI7aKZLWr0G56HI9fGKQ0CEbQ02H-yExQ,1065
25
+ batplot-1.8.1.dist-info/licenses/LICENSE,sha256=2PAnHeCiTfgI7aKZLWr0G56HI9fGKQ0CEbQ02H-yExQ,1065
26
26
  batplot_backup_20251121_223043/__init__.py,sha256=3s2DUQuTbWs65hoN9cQQ8IiJbaFJY8fNxiCpwRBYoOA,118
27
27
  batplot_backup_20251121_223043/args.py,sha256=OH-h84QhN-IhMS8sPAsSEqccHD3wpeMgmXa_fqv5xtg,21215
28
28
  batplot_backup_20251121_223043/batch.py,sha256=oI7PONJyciHDOqNPq-8fnOQMyn9CpAdVznKaEdsy0ig,48650
@@ -45,8 +45,8 @@ batplot_backup_20251121_223043/style.py,sha256=xg-tj6bEbFUVjjxYMokiLehS4tSfKanLI
45
45
  batplot_backup_20251121_223043/ui.py,sha256=K0XZWyiuBRNkFod9mgZyJ9CLN78GR1-hh6EznnIb5S8,31208
46
46
  batplot_backup_20251121_223043/utils.py,sha256=jydA0JxsCWWAudXEwSjlxTG17y2F8U6hIAukAzi1P0g,32526
47
47
  batplot_backup_20251121_223043/version_check.py,sha256=vlHkGkgUJcD_Z4KZmwonxZvKZh0MwHLaBSxaLPc66AQ,4555
48
- batplot-1.7.28.dist-info/METADATA,sha256=AkFH5c-g0mYy7P70j7k9pFdObNP4UIHmMendhUgDwoI,7407
49
- batplot-1.7.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
- batplot-1.7.28.dist-info/entry_points.txt,sha256=73GgH3Zs-qGIvgiyQLgGsSW-ryOwPPKHveOW6TDIR5Q,82
51
- batplot-1.7.28.dist-info/top_level.txt,sha256=CgqK4RpsYnUFAcqO4bLOnEhCoPY4IPEGLPkiDlzLIxg,39
52
- batplot-1.7.28.dist-info/RECORD,,
48
+ batplot-1.8.1.dist-info/METADATA,sha256=3n6IsXn-SgLaDVHF6t4HCMmzDpf0Tkkbp23Dva98oN8,7406
49
+ batplot-1.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
+ batplot-1.8.1.dist-info/entry_points.txt,sha256=73GgH3Zs-qGIvgiyQLgGsSW-ryOwPPKHveOW6TDIR5Q,82
51
+ batplot-1.8.1.dist-info/top_level.txt,sha256=CgqK4RpsYnUFAcqO4bLOnEhCoPY4IPEGLPkiDlzLIxg,39
52
+ batplot-1.8.1.dist-info/RECORD,,