Skip to content

Commit

Permalink
Remove cumulative.py and associated tests + assets (#257)
Browse files Browse the repository at this point in the history
* remove cumulative.py and associated tests and assets

contained cumulative_error() and cumulative_residual() plotting functions

* move spacegroup_bar() assets into their own "Bar Plots" readme section

* add test_readme_function_names that checks functions listed in readme table match the names in source files

* remove local hook no-missing-readme-images

* include *.yml in pyproject.toml tool.setuptools.package-data (to have keys.yml in PyPI package)
  • Loading branch information
janosh committed Dec 12, 2024
1 parent 9154ae0 commit a4619c1
Show file tree
Hide file tree
Showing 22 changed files with 228 additions and 288 deletions.
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ repos:
- id: nbstripout
args: [--drop-empty-cells, --keep-output]

- repo: local
hooks:
- id: no-missing-readme-images
name: No missing readme images
entry: python -c 'from tests.test_readme import test_no_missing_images; test_no_missing_images()'
language: system
files: readme.md

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down
File renamed without changes.
57 changes: 22 additions & 35 deletions assets/scripts/coordination/coordination_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@
for strategy in (CrystalNN(), VoronoiNN()):
cls_name = type(strategy).__name__
fig = pmv.coordination_hist(structures[key1], strategy=strategy)
fig.layout.title = dict(
text=f"Coordination Histogram ({cls_name}): {key1}", x=0.5, y=0.98
)
title = f"Coordination Histogram ({cls_name}): {key1}"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.layout.margin.t = 50
fig.show()
pmv.io.save_and_compress_svg(fig, f"coordination-hist-{cls_name.lower()}")
Expand All @@ -68,29 +67,26 @@
# %% Custom analyzer example
fig = pmv.coordination_hist(structures[key1], strategy=VoronoiNN())
fig.layout.margin.t = 50
fig.layout.title = dict(
text=f"Coordination Histogram (VoronoiNN): {key1}", x=0.5, y=0.98
)
title = f"Coordination Histogram (VoronoiNN): {key1}"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-voronoi")


# %% Multiple structures example
fig = pmv.coordination_hist({key1: structures[key1], key2: structures[key2]})
fig.layout.margin.t = 50
fig.layout.title = dict(
text="Coordination Histogram: Multiple Structures", x=0.5, y=0.98
)
title = "Coordination Histogram: Multiple Structures"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-multiple")


# %% By element example (now default, but explicitly specified for clarity)
fig = pmv.coordination_hist(structures[key1], split_mode=CnSplitMode.by_element)
fig.layout.margin.t = 50
fig.layout.title = dict(
text=f"Coordination Histogram by Element: {key1}", x=0.5, y=0.98
)
title = f"Coordination Histogram by Element: {key1}"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-by-element")

Expand All @@ -100,9 +96,8 @@
{key1: structures[key1], key2: structures[key2], key3: structures[key3]},
)
fig.layout.margin.t = 50
fig.layout.title = dict(
text="Coordination Histogram by Element: Multiple Structures", x=0.5, y=0.98
)
title = "Coordination Histogram by Element: Multiple Structures"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-multiple-by-element")

Expand All @@ -113,7 +108,8 @@
split_mode=CnSplitMode.by_structure,
)
fig.layout.margin.t = 50
fig.layout.title = dict(text="Coordination Histogram by Structure", x=0.5, y=0.98)
title = "Coordination Histogram by Structure"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-by-structure")

Expand All @@ -124,9 +120,8 @@
split_mode=CnSplitMode.by_structure_and_element,
)
fig.layout.margin.t = 60
fig.layout.title = dict(
text="Coordination Histogram by Structure and Element", x=0.5, y=0.98
)
title = "Coordination Histogram by Structure and Element"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-by-structure-and-element")

Expand All @@ -137,11 +132,8 @@
hover_data=("oxidation_state", "wyckoff"),
)
fig.layout.margin.t = 50
fig.layout.title = dict(
text="Coordination Histogram by Element: Multiple Structures (with custom hover)",
x=0.5,
y=0.98,
)
title = "Coordination Histogram by Element: Multiple Structures (with custom hover)"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-multiple-by-element-custom-hover")

Expand All @@ -154,11 +146,8 @@
element_color_scheme=custom_colors,
)
fig.layout.margin.t = 60
fig.layout.title = dict(
text="Coordination Histogram by Element: Multiple Structures (with custom colors)",
x=0.5,
y=0.99,
)
title = "Coordination Histogram by Element: Multiple Structures (with custom colors)"
fig.layout.title = dict(text=title, x=0.5, y=0.99)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-multiple-by-element-custom-colors")

Expand All @@ -169,9 +158,8 @@
split_mode=CnSplitMode.none,
)
fig.layout.margin.t = 50
fig.layout.title = dict(
text="Coordination Histogram: All Structures Combined", x=0.5, y=0.98
)
title = "Coordination Histogram: All Structures Combined"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-all-combined")

Expand All @@ -184,8 +172,7 @@
bar_kwargs=dict(width=0.2),
)
fig.layout.margin.t = 50
fig.layout.title = dict(
text="Coordination Histogram: All Structures Combined (Side-by-side)", x=0.5, y=0.98
)
title = "Coordination Histogram: All Structures Combined (Side-by-side)"
fig.layout.title = dict(text=title, x=0.5, y=0.98)
fig.show()
pmv.io.save_and_compress_svg(fig, "coordination-hist-all-combined-side-by-side")
14 changes: 0 additions & 14 deletions assets/scripts/uncertainty/cumulative.py

This file was deleted.

1 change: 0 additions & 1 deletion assets/svg/cumulative-error.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/svg/cumulative-residual.svg

This file was deleted.

2 changes: 0 additions & 2 deletions pymatviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
classify,
colors,
coordination,
cumulative,
data,
enums,
io,
Expand All @@ -45,7 +44,6 @@
from pymatviz.classify import precision_recall_curve_plotly, roc_curve_plotly
from pymatviz.classify.confusion_matrix import confusion_matrix
from pymatviz.coordination import coordination_hist, coordination_vs_cutoff_line
from pymatviz.cumulative import cumulative_error, cumulative_residual
from pymatviz.enums import Key, angstrom_per_atom, cubic_angstrom, eV
from pymatviz.histogram import elements_hist, histogram, spacegroup_bar
from pymatviz.io import df_to_html, df_to_pdf, df_to_svg, save_fig
Expand Down
11 changes: 2 additions & 9 deletions pymatviz/coordination/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,8 @@ def coordination_hist(
fig.update_layout(barmode=bar_mode, bargap=0.15, bargroupgap=0.1)

# start x-axis just below the smallest observed CN
fig.update_xaxes(
tick0=int(min_cn),
dtick=1,
range=[min_cn - 0.5, max_cn + 0.5],
)
dev_fig = fig.full_figure_for_development(warn=False)
y_max = dev_fig.layout.yaxis.range[1]
# Ensure y-axis starts at 0
fig.update_yaxes(title="Count", range=[0, y_max])
fig.update_xaxes(tick0=int(min_cn), dtick=1, range=[min_cn - 0.5, max_cn + 0.5])
fig.update_yaxes(title="Count", rangemode="tozero") # Ensure y_min=0, not <0

# Add title "Coordination Number" to x axes of the last n_cols subplots
for idx in range(n_subplots - n_cols + 1, n_subplots + 1):
Expand Down
104 changes: 0 additions & 104 deletions pymatviz/cumulative.py

This file was deleted.

5 changes: 1 addition & 4 deletions pymatviz/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ def __reduce_ex__(self, proto: object) -> tuple[type, tuple[str]]:
# Structure Prototyping
protostructure = "protostructure"
prototype = "prototype"
aflow_prototype = "aflow_prototype"
canonical_proto = "canonical_proto"
uniq_proto = "uniq_proto"

# Composition
arity = "arity"
Expand Down Expand Up @@ -612,7 +609,7 @@ def __reduce_ex__(self, proto: object) -> tuple[type, tuple[str]]:
id = "id"
db_id = "db_id"
uuid = "uuid"
mat_id = "mat_id"
mat_id = "material_id"
frame_id = "frame_id"
task = "task"
job_id = "job_id"
Expand Down
Loading

0 comments on commit a4619c1

Please sign in to comment.