Skip to content

Commit 5255f4b

Browse files
committed
fix docs build error
ReferenceError: elem is not defined at file:///home/runner/work/pymatviz/pymatviz/site/.svelte-kit/output/server/entries/pages/api/_page.svelte.js:444:565
1 parent 4a983a5 commit 5255f4b

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

citation.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ authors:
88
99
orcid: https://orcid.org/0000-0001-5233-3462
1010
github: janosh
11+
- family-names: Yang
12+
given-names: Haoyu (Daniel)
13+
14+
github: DanielYang59
1115
- family-names: Goodall
1216
given-names: Rhys
1317
affiliation: University of Cambridge
@@ -18,10 +22,6 @@ authors:
1822
affiliation: University of Utah
1923
orcid: https://orcid.org/0000-0002-4491-6876
2024
github: sgbaird
21-
- family-names: Yang
22-
given-names: Haoyu (Daniel)
23-
24-
github: DanielYang59
2525
license: MIT
2626
license-url: https://github.com/janosh/pymatviz/blob/main/license"
2727
repository-code: https://github.com/janosh/pymatviz

pymatviz/ptable.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,17 @@ def add_child_plots(
450450

451451
def add_ele_symbols(
452452
self,
453-
text: Callable[[Element], str] = lambda elem: elem.symbol,
453+
text: str | Callable[[Element], str] = lambda elem: elem.symbol,
454454
pos: tuple[float, float] = (0.5, 0.5),
455455
kwargs: dict[str, Any] | None = None,
456456
) -> None:
457457
"""Add element symbols for each tile.
458458
459459
Args:
460-
text: A callable or string specifying how to display
461-
the element symbol. If a callable is provided,
462-
it should accept an Element object and return a string.
463-
If a string is provided, it can contain a format
464-
specifier for the element symbol, e.g., "{elem.symbol}".
460+
text (str | Callable): The text to add to the tile.
461+
If a callable, it should accept a pymatgen Element object and return a
462+
string. If a string, it can contain a format
463+
specifier for an `elem` variable which will be replaced by the element.
465464
pos: The position of the text relative to the axes.
466465
kwargs: Additional keyword arguments to pass to the `ax.text`.
467466
"""
@@ -476,13 +475,9 @@ def add_ele_symbols(
476475
row, column = df_ptable.loc[symbol, ["row", "column"]]
477476
ax: plt.Axes = self.axes[row - 1][column - 1]
478477

478+
anno = text(element) if callable(text) else text.format(elem=element)
479479
ax.text(
480-
*pos,
481-
text(element) if callable(text) else text.format(elem=element), # type: ignore[attr-defined]
482-
ha="center",
483-
va="center",
484-
transform=ax.transAxes,
485-
**kwargs,
480+
*pos, anno, ha="center", va="center", transform=ax.transAxes, **kwargs
486481
)
487482

488483
def add_colorbar(
@@ -998,7 +993,7 @@ def ptable_heatmap_splits(
998993

999994
# Add element symbols
1000995
plotter.add_ele_symbols(
1001-
text=symbol_text, # type: ignore[arg-type]
996+
text=symbol_text,
1002997
pos=symbol_pos,
1003998
kwargs=symbol_kwargs,
1004999
)
@@ -1623,7 +1618,7 @@ def ptable_scatters(
16231618

16241619
# Add element symbols
16251620
plotter.add_ele_symbols(
1626-
text=symbol_text, # type: ignore[arg-type]
1621+
text=symbol_text,
16271622
pos=symbol_pos,
16281623
kwargs=symbol_kwargs,
16291624
)
@@ -1697,7 +1692,7 @@ def ptable_lines(
16971692

16981693
# Add element symbols
16991694
plotter.add_ele_symbols(
1700-
text=symbol_text, # type: ignore[arg-type]
1695+
text=symbol_text,
17011696
pos=symbol_pos,
17021697
kwargs=symbol_kwargs,
17031698
)

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ See [`citation.cff`](citation.cff) or cite the [Zenodo record](https://zenodo.or
213213
```bib
214214
@software{riebesell_pymatviz_2022,
215215
title = {Pymatviz: visualization toolkit for materials informatics},
216-
author = {Riebesell, Janosh and Goodall, Rhys and Baird, Sterling G. and Yang, Haoyu},
216+
author = {Riebesell, Janosh and Yang, Haoyu and Goodall, Rhys and Baird, Sterling G.},
217217
date = {2022-10-01},
218218
year = {2022},
219219
doi = {10.5281/zenodo.7486816},

0 commit comments

Comments
 (0)