chemparseplot 1.12.0__tar.gz → 1.13.0__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 (161) hide show
  1. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/PKG-INFO +1 -1
  2. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/_version.py +2 -2
  3. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/reaction.py +74 -0
  4. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_reaction.py +34 -0
  5. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/.gitignore +0 -0
  6. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/LICENSE +0 -0
  7. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/__init__.py +0 -0
  8. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/api.py +0 -0
  9. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/contracts/__init__.py +0 -0
  10. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/contracts/load_outcome.py +0 -0
  11. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/__init__.py +0 -0
  12. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/benchmark.py +0 -0
  13. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/chemgp_hdf5.py +0 -0
  14. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/chemgp_jsonl.py +0 -0
  15. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/converter.py +0 -0
  16. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/__init__.py +0 -0
  17. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/_trajectory_common.py +0 -0
  18. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/con_io.py +0 -0
  19. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/con_trajectory.py +0 -0
  20. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/dimer_trajectory.py +0 -0
  21. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/frame_series.py +0 -0
  22. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/gprd.py +0 -0
  23. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/min_trajectory.py +0 -0
  24. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/minimization.py +0 -0
  25. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/neb.py +0 -0
  26. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/saddle_search.py +0 -0
  27. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/eon/stitch.py +0 -0
  28. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/file_.py +0 -0
  29. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/grammar/__init__.py +0 -0
  30. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/grammar/_deps.py +0 -0
  31. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/grammar/orca_text.py +0 -0
  32. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/grammar/xyz.py +0 -0
  33. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/mlneb.py +0 -0
  34. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/neb_utils.py +0 -0
  35. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/__init__.py +0 -0
  36. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/_opi.py +0 -0
  37. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/geomscan.py +0 -0
  38. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/neb/__init__.py +0 -0
  39. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/neb/interp.py +0 -0
  40. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/orca/neb/opi_parser.py +0 -0
  41. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/patterns.py +0 -0
  42. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/plumed.py +0 -0
  43. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/projection.py +0 -0
  44. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/sella/saddle_search.py +0 -0
  45. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/surrogate/__init__.py +0 -0
  46. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/surrogate/cases.py +0 -0
  47. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/surrogate/gpr_optim.py +0 -0
  48. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/surrogate/mlneb.py +0 -0
  49. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/surrogate/model.py +0 -0
  50. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/trajectory/__init__.py +0 -0
  51. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/trajectory/hdf5.py +0 -0
  52. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/trajectory/neb.py +0 -0
  53. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/parse/types.py +0 -0
  54. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/__init__.py +0 -0
  55. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/benchmark.py +0 -0
  56. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/chemgp.py +0 -0
  57. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/con.py +0 -0
  58. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/disconnectivity.py +0 -0
  59. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/geomscan.py +0 -0
  60. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/landscape.py +0 -0
  61. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/mlneb.py +0 -0
  62. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/neb.py +0 -0
  63. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/optimization.py +0 -0
  64. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/plumed.py +0 -0
  65. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/provenance.py +0 -0
  66. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/rings.py +0 -0
  67. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/structs.py +0 -0
  68. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/surrogate.py +0 -0
  69. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/plot/theme.py +0 -0
  70. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/units.py +0 -0
  71. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/chemparseplot/util.py +0 -0
  72. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/pyproject.toml +0 -0
  73. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/readme.md +0 -0
  74. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/__init__.py +0 -0
  75. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/_optional_imports.py +0 -0
  76. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/conftest.py +0 -0
  77. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/h2mol.xyz +0 -0
  78. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/orca_energy_coords_snippet.out +0 -0
  79. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/restart_exact.con +0 -0
  80. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/restart_exact_vel.con +0 -0
  81. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/cases/baselines.csv +0 -0
  82. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/cases/cases.csv +0 -0
  83. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/mlneb/evaluated.traj +0 -0
  84. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/mlneb/ml_summary.txt +0 -0
  85. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/mlneb/ml_time.txt +0 -0
  86. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/mlneb/predicted.traj +0 -0
  87. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/baker/25_hcnh2/band/band.h5 +0 -0
  88. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/baker/25_hcnh2/band/obs-archive/kernel.txt +0 -0
  89. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/baker/25_hcnh2/result.json +0 -0
  90. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/baker/25_hcnh2/saddle/pos.con +0 -0
  91. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/birkholz/16_oxirane/result.json +0 -0
  92. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/birkholz/16_oxirane/saddle/mlflow.run.json +0 -0
  93. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/mlruns/606078088088587/7eaf5653201fe6b92f3e3831bead3063/metrics/dimer.curvature +0 -0
  94. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/mlruns/606078088088587/7eaf5653201fe6b92f3e3831bead3063/metrics/dimer.force +0 -0
  95. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/mlruns/606078088088587/7eaf5653201fe6b92f3e3831bead3063/metrics/dimer.measured_curvature +0 -0
  96. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/mlruns/606078088088587/7eaf5653201fe6b92f3e3831bead3063/metrics/dimer.oracle_calls +0 -0
  97. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/record/mlruns/606078088088587/7eaf5653201fe6b92f3e3831bead3063/metrics/dimer.surrogate_curvature +0 -0
  98. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/scaling/breakdown.csv +0 -0
  99. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/scaling/components.csv +0 -0
  100. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/scaling/counts.csv +0 -0
  101. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/scaling/pop.csv +0 -0
  102. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures/surrogate/scaling/wall.csv +0 -0
  103. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/fixtures_geomscan_snippet.txt +0 -0
  104. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/__init__.py +0 -0
  105. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/_con_fixtures.py +0 -0
  106. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/grammar/__init__.py +0 -0
  107. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/grammar/test_grammar_deps.py +0 -0
  108. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/grammar/test_orca_text_grammar.py +0 -0
  109. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/grammar/test_xyz_grammar.py +0 -0
  110. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/orca/test_geomscan.py +0 -0
  111. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/orca/test_interp.py +0 -0
  112. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_chemgp_hdf5.py +0 -0
  113. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_chemgp_jsonl_types.py +0 -0
  114. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_con_io.py +0 -0
  115. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_con_trajectory.py +0 -0
  116. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_con_units_and_corpus.py +0 -0
  117. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_converter.py +0 -0
  118. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_dimer_trajectory.py +0 -0
  119. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_eon_neb_types.py +0 -0
  120. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_eon_trajectory_common.py +0 -0
  121. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_frame_series.py +0 -0
  122. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_min_trajectory.py +0 -0
  123. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_minimization_result.py +0 -0
  124. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_neb_stitch.py +0 -0
  125. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_neb_utils.py +0 -0
  126. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_orca_public_api.py +0 -0
  127. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_parser_types.py +0 -0
  128. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_patterns.py +0 -0
  129. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_plumed.py +0 -0
  130. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_projection.py +0 -0
  131. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_readcon_boundary.py +0 -0
  132. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_saddle_results.py +0 -0
  133. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_sella_saddle.py +0 -0
  134. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_surrogate_gpr_optim.py +0 -0
  135. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_surrogate_mlneb.py +0 -0
  136. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_trajectory_hdf5.py +0 -0
  137. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/parse/test_trajectory_neb.py +0 -0
  138. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/__init__.py +0 -0
  139. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/data/sexithiophene.sdf +0 -0
  140. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_benchmark.py +0 -0
  141. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_chemgp_utils.py +0 -0
  142. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_landscape_disconnectivity.py +0 -0
  143. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_mlneb.py +0 -0
  144. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_neb_helpers.py +0 -0
  145. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_neb_renderers.py +0 -0
  146. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_optimization.py +0 -0
  147. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_orca_neb_payload.py +0 -0
  148. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_primitive_rings.py +0 -0
  149. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_projection_refactor.py +0 -0
  150. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_provenance.py +0 -0
  151. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_ring_track.py +0 -0
  152. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_ring_updater.py +0 -0
  153. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_strip_rendering.py +0 -0
  154. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_structs_units.py +0 -0
  155. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_surface_auto_thin.py +0 -0
  156. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/plot/test_surrogate_plots.py +0 -0
  157. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/test_coverage_batch.py +0 -0
  158. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/test_full_coverage.py +0 -0
  159. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/test_load_outcome.py +0 -0
  160. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/test_public_api.py +0 -0
  161. {chemparseplot-1.12.0 → chemparseplot-1.13.0}/tests/tutorials/test_chemparseplot.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: chemparseplot
3
- Version: 1.12.0
3
+ Version: 1.13.0
4
4
  Summary: Parsers and plotting tools for computational chemistry
5
5
  Project-URL: Documentation, https://chemparseplot.rgoswami.me
6
6
  Project-URL: Issues, https://github.com/HaoZeke/chemparseplot/issues
@@ -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 = '1.12.0'
22
- __version_tuple__ = version_tuple = (1, 12, 0)
21
+ __version__ = version = '1.13.0'
22
+ __version_tuple__ = version_tuple = (1, 13, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -245,3 +245,77 @@ def plot_reaction_atlas(cases, *, density=False, width=7.2):
245
245
  cbar.set_label("Wiberg bond order", fontsize=8)
246
246
  cbar.ax.tick_params(labelsize=7)
247
247
  return fig
248
+
249
+
250
+ def plot_reaction_gallery(tiles, *, columns=4, density=False, width=7.2):
251
+ """Render one structure per reaction in a grid of labelled tiles.
252
+
253
+ Each tile holds a ``title`` (the name other figures use for the
254
+ reaction), an optional ``subtitle`` naming the chemistry, the rendered
255
+ ``image`` (or ``density_image``) and the measured ``bonds`` to annotate,
256
+ in the format of :func:`plot_reaction_atlas`.
257
+ """
258
+ import matplotlib.pyplot as plt # noqa: PLC0415
259
+ from matplotlib.cm import ScalarMappable # noqa: PLC0415
260
+ from matplotlib.colors import Normalize # noqa: PLC0415
261
+
262
+ from chemparseplot.plot.neb import _crop_transparent_rgba # noqa: PLC0415
263
+
264
+ if columns < 1:
265
+ msg = "A reaction gallery needs at least one column"
266
+ raise ValueError(msg)
267
+ rows = -(-len(tiles) // columns)
268
+ tile_height = 2.35
269
+ height = tile_height * rows + 0.75
270
+ fig = plt.figure(figsize=(width, height))
271
+ left, right, gap = 0.02, 0.98, 0.015
272
+ column_width = (right - left - (columns - 1) * gap) / columns
273
+ for index, tile in enumerate(tiles):
274
+ row, col = divmod(index, columns)
275
+ top = 1 - (0.08 + row * tile_height) / height
276
+ x = left + col * (column_width + gap)
277
+ center = x + column_width / 2
278
+ fig.text(
279
+ center,
280
+ top,
281
+ tile["title"],
282
+ ha="center",
283
+ va="top",
284
+ fontsize=8.5,
285
+ fontweight="bold",
286
+ )
287
+ if tile.get("subtitle"):
288
+ fig.text(
289
+ center,
290
+ top - 0.2 / height,
291
+ tile["subtitle"],
292
+ ha="center",
293
+ va="top",
294
+ fontsize=6.5,
295
+ color="#444444",
296
+ )
297
+ ax = fig.add_axes([x, top - 1.72 / height, column_width, 1.3 / height])
298
+ img = plt.imread(tile["density_image" if density else "image"])
299
+ ax.imshow(_crop_transparent_rgba(img))
300
+ ax.axis("off")
301
+ lines = []
302
+ for bond in tile.get("bonds", []):
303
+ wbo = "n/r" if bond["wbo"] is None else f"{bond['wbo']:.2f}"
304
+ lines.append(f"{bond['label']}: {bond['distance_A']:.2f} Å / {wbo}")
305
+ fig.text(
306
+ center,
307
+ top - 1.76 / height,
308
+ "\n".join(lines),
309
+ ha="center",
310
+ va="top",
311
+ fontsize=6,
312
+ )
313
+ cax = fig.add_axes([0.30, 0.18 / height, 0.40, 0.12 / height])
314
+ cbar = fig.colorbar(
315
+ ScalarMappable(norm=Normalize(0, 3), cmap="viridis"),
316
+ cax=cax,
317
+ orientation="horizontal",
318
+ )
319
+ cbar.set_label("Wiberg bond order", fontsize=8)
320
+ cbar.ax.tick_params(labelsize=7)
321
+ return fig
@@ -68,3 +68,37 @@ def test_molecular_alignment_ignores_container_periodicity():
68
68
  assert not aligned.pbc.any()
69
69
  assert original.pbc.all()
70
70
  np.testing.assert_allclose(result[0].positions, result[1].positions, atol=1e-12)
71
+
72
+
73
+ def test_gallery_places_one_titled_tile_per_reaction(tmp_path):
74
+ import matplotlib as mpl
75
+
76
+ mpl.use("Agg")
77
+ import matplotlib.pyplot as plt
78
+
79
+ from chemparseplot.plot.reaction import plot_reaction_gallery
80
+
81
+ image = tmp_path / "tile.png"
82
+ pixels = np.zeros((20, 20, 4))
83
+ pixels[5:15, 5:15] = [0.2, 0.4, 0.6, 1.0]
84
+ plt.imsave(image, pixels)
85
+ bond = {"label": "C1\u2013O2", "distance_A": 1.94, "wbo": 0.41}
86
+ tiles = [
87
+ {
88
+ "title": f"case {i}",
89
+ "subtitle": "ring opening",
90
+ "image": str(image),
91
+ "bonds": [bond] if i % 2 else [],
92
+ }
93
+ for i in range(5)
94
+ ]
95
+ fig = plot_reaction_gallery(tiles, columns=3)
96
+ texts = [t.get_text() for t in fig.texts]
97
+ assert [f"case {i}" for i in range(5)] == [t for t in texts if t.startswith("case")]
98
+ assert texts.count("ring opening") == 5
99
+ assert texts.count("C1\u2013O2: 1.94 Å / 0.41") == 2
100
+ # five structure panels and the bond-order colour bar
101
+ assert len(fig.axes) == 6
102
+ plt.close(fig)
103
+ with pytest.raises(ValueError, match="one column"):
104
+ plot_reaction_gallery(tiles, columns=0)
File without changes
File without changes