Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow get_crystal_sys->crystal_sys_from_spg_num rename in pymatviz #78

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2
rev: v0.1.5
hooks:
- id: ruff
args: [--fix]
Expand All @@ -27,6 +27,7 @@ repos:
hooks:
- id: codespell
exclude_types: [json]
args: [--check-filenames]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pymatgen.core import Structure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatviz import sankey_from_2_df_cols, spacegroup_sunburst
from pymatviz.utils import get_crystal_sys
from pymatviz.utils import crystal_sys_from_spg_num
from tqdm import tqdm

from aviary import ROOT
Expand Down Expand Up @@ -84,13 +84,13 @@
# %%
fig = spacegroup_sunburst(df_perovskites.spglib_spg)
fig.update_layout(title=dict(text="Spglib Spacegroups", x=0.5, y=0.93))
# fig.write_image(f"{MODULE_DIR}/plots/matbench_perovskites_aflow_sunburst.png", scale=2)
# fig.write_image(f"{MODULE_DIR}/plots/matbench_perovskites_aflow_sunburst.pdf")


# %%
fig = spacegroup_sunburst(df_perovskites.aflow_spg, title="Aflow")
fig.update_layout(title=dict(text="Aflow Spacegroups", x=0.5, y=0.85))
# fig.write_image(f"{MODULE_DIR}/plots/matbench_perovskites_spglib_sunburst.png", scale=2)
# fig.write_image(f"{MODULE_DIR}/plots/matbench_perovskites_spglib_sunburst.pdf")


# %%
Expand All @@ -104,7 +104,7 @@
# %%
for src in ("aflow", "spglib"):
df_perovskites[f"{src}_crys_sys"] = df_perovskites[f"{src}_spg_num"].map(
get_crystal_sys
crystal_sys_from_spg_num
)


Expand Down
2 changes: 1 addition & 1 deletion examples/wrenformer/mat_bench/make_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
MAE = (df[y_col] - df[target]).abs().mean()
pretty_title = y_col.replace("-", " ")
R2 = r2_score(df[target], df[y_col])
labels[y_col] = f"{pretty_title}<br>{MAE = :.2f}, {R2 = :.2f}"
labels[y_col] = f"{pretty_title}<br>{MAE=:.2f}, {R2=:.2f}"

fig = px.scatter(
df.rename(columns=labels).reset_index(),
Expand Down
19 changes: 8 additions & 11 deletions examples/wrenformer/mat_bench/plotting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import plotly.express as px
import plotly.graph_objs as go
import plotly.io as pio
from matbench.constants import CLF_KEY, REG_KEY
from matbench.metadata import mbv01_metadata
Expand Down Expand Up @@ -115,16 +114,14 @@ def plot_leaderboard(
)

# add scatter for the best algorithms on scaled error
fig.add_trace(
go.Scatter(
mode="markers",
x=best_values.index,
y=best_values,
marker_color="yellow",
text=best_algos,
visible="legendonly",
name="Best algorithms",
)
fig.add_scatter(
mode="markers",
x=best_values.index,
y=best_values,
marker_color="yellow",
text=best_algos,
visible="legendonly",
name="Best algorithms",
)
fig.update_traces(marker_size=10)
fig.update_xaxes(linecolor="grey", gridcolor="grey")
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def df_matbench_phonons():
"""Returns the dataframe for the Matbench phonon DOS peak task."""

df = load_dataset("matbench_phonons")
df["material_id"] = [f"mb_phdos_{i+1}" for i in range(len(df))]
df["material_id"] = [f"mb_phdos_{i + 1}" for i in range(len(df))]
df = df.set_index("material_id", drop=False)
df["composition"] = [x.composition.formula.replace(" ", "") for x in df.structure]

Expand All @@ -30,10 +30,10 @@ def df_matbench_phonons():

@pytest.fixture(scope="session")
def df_matbench_jdft2d():
"""Returns the dataframe for the Matbench experimental band gap task. Currently unused."""
"""Returns Matbench experimental band gap task dataframe. Currently unused."""

df = load_dataset("matbench_jdft2d")
df["material_id"] = [f"mb_jdft2d_{i+1}" for i in range(len(df))]
df["material_id"] = [f"mb_jdft2d_{i + 1}" for i in range(len(df))]
df = df.set_index("material_id", drop=False)
df["composition"] = [x.composition.formula.replace(" ", "") for x in df.structure]

Expand Down