Skip to content

Commit 0ab5923

Browse files
authored
Merge pull request #279 from materialsproject/test-diffraction
Add `apps/examples/tests/test_diffraction.py` with E2E test for basic diffraction example
2 parents 6f54861 + 17f4ffd commit 0ab5923

29 files changed

+152
-122
lines changed

.github/workflows/url-check.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Check URLs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lychee-link-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out repo
14+
uses: actions/checkout@v3
15+
16+
- name: Check for broken links
17+
uses: lycheeverse/lychee-action@v1
18+
with:
19+
# exclude loopback to skip localhost URLs from checking
20+
args: --exclude-loopback './**/*.md' './**/*.rst'

.pre-commit-config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ default_stages: [commit]
55

66
default_install_hook_types: [pre-commit, commit-msg]
77

8-
# ignore generated doc and dependency lock files
9-
exclude: ^(docs/.+|.*lock.*|.*\.(svg|js|css))$
8+
# ignore generated docs and dependency lock files, the directory
9+
# jupyterlab-extension/ and all SVG, JS and CSS files
10+
exclude: ^(docs/.+|.*lock.*|jupyterlab-extension/.+|.*\.(svg|js|css))$
1011

1112
repos:
1213
- repo: https://github.com/PyCQA/isort
@@ -72,3 +73,9 @@ repos:
7273
- id: nbqa-isort
7374
- id: nbqa-flake8
7475
args: [--ignore=E402]
76+
77+
- repo: https://github.com/kynan/nbstripout
78+
rev: 0.6.0
79+
hooks:
80+
- id: nbstripout
81+
args: [--drop-empty-cells, --keep-output]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The [Crystal Toolkit Development Team](https://github.com/materialsproject/cryst
3232
* [Matt McDermott](https://github.com/mattmcdermott) contributed phase diagram, X-ray Diffraction, X-ray Absorption Spectrum components
3333
* [Jason Munro](https://github.com/munrojm) contributed band structure component
3434
* [Stephen Weitzner](https://github.com/sweitzner) contributed POV-Ray integration (in progress)
35-
* [Richard Tran](https://github.com/richardtran415) for contributing plotly-powered Wulff shapes to pymatgen, which Crystal Toolkit uses
35+
* [Richard Tran](https://github.com/CifLord) for contributing plotly-powered Wulff shapes to pymatgen, which Crystal Toolkit uses
3636
* [Guy Moore](https://github.com/guymoore13) for contributing magnetic moment visualization
3737

3838
New contributors are welcome, please see our [Code of Conduct.](code-of-conduct.md) If you are a new contributor please modify this README in your Pull Request to add your name to the list.
@@ -53,7 +53,7 @@ Thank you to all the authors and maintainers of the libraries Crystal Toolkit
5353
depends upon, and in particular [pymatgen](http://pymatgen.org) for crystallographic
5454
analysis and [Dash from Plotly](https://plot.ly/products/dash/) for their web app framework.
5555

56-
Thank you to the [NERSC Spin](http://www.nersc.gov/users/data-analytics/spin/) service for
56+
Thank you to the [NERSC Spin](https://www.nersc.gov/systems/spin) service for
5757
hosting the app and for their technical support.
5858

5959
Cross-browser Testing Platform and Open Source <3 generously provided by [Sauce Labs](https://saucelabs.com)

crystal_toolkit/apps/examples/bandstructure.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
# dos and bs data from local jsons
66
from monty.serialization import loadfn
77

8-
# standard Crystal Toolkit import
98
import crystal_toolkit.components as ctc
109
from crystal_toolkit.helpers.layouts import H1, Container
1110
from crystal_toolkit.settings import SETTINGS
1211

13-
# create Dash app as normal, assets folder set for visual styles only
12+
# assets folder set for visual styles only
1413
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
1514

1615
# If callbacks created dynamically they cannot be statically checked at app startup.

crystal_toolkit/apps/examples/basic_hello_structure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import crystal_toolkit.components as ctc
88

9-
# app = dash.Dash(external_stylesheets=['https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css'])
109
app = dash.Dash()
1110

1211
# create our crystal structure using pymatgen

crystal_toolkit/apps/examples/diffraction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
from pymatgen.core.lattice import Lattice
55
from pymatgen.core.structure import Structure
66

7-
# standard Crystal Toolkit import
87
import crystal_toolkit.components as ctc
98
from crystal_toolkit.helpers.layouts import H1, H3, Container
109
from crystal_toolkit.settings import SETTINGS
1110

12-
# create Dash app as normal
1311
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
1412

1513

crystal_toolkit/apps/examples/diffraction_dynamic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
from pymatgen.core.lattice import Lattice
66
from pymatgen.core.structure import Structure
77

8-
# standard Crystal Toolkit import
98
import crystal_toolkit.components as ctc
109
from crystal_toolkit.helpers.layouts import H1, Button, Container
1110
from crystal_toolkit.settings import SETTINGS
1211

13-
# create Dash app as normal
1412
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
1513

1614
xrd_component = ctc.XRayDiffractionComponent(id="xrd-diffraction")

crystal_toolkit/apps/examples/diffraction_empty.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
from pymatgen.core.lattice import Lattice
55
from pymatgen.core.structure import Structure
66

7-
# standard Crystal Toolkit import
87
import crystal_toolkit.components as ctc
98
from crystal_toolkit.helpers.layouts import H1, Container
109
from crystal_toolkit.settings import SETTINGS
1110

12-
# create Dash app as normal
1311
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
1412

1513
structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]])

crystal_toolkit/apps/examples/phase_diagram.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
from pymatgen.analysis.phase_diagram import PhaseDiagram
44
from pymatgen.ext.matproj import MPRester
55

6-
# standard Crystal Toolkit import
76
import crystal_toolkit.components as ctc
87

9-
# create Dash app as normal
108
app = dash.Dash()
119

1210
# If callbacks created dynamically they cannot be statically checked at app startup.
@@ -20,10 +18,10 @@
2018

2119
# first, retrieve entries from Materials Project
2220
with MPRester() as mpr:
23-
# li_entries = mpr.get_entries_in_chemsys(["Li"])
24-
# li_o_entries = mpr.get_entries_in_chemsys(["Li", "O"])
25-
li_co_o_entries = mpr.get_entries_in_chemsys(["Li", "O", "Co"])
26-
# li_co_o_fe_entries = mpr.get_entries_in_chemsys(["Li", "O", "Co", "Fe"])
21+
# li_entries = mpr.get_entries_in_chemsys("Li")
22+
# li_o_entries = mpr.get_entries_in_chemsys("Li-O")
23+
li_co_o_entries = mpr.get_entries_in_chemsys("Li-O-Co")
24+
# li_co_o_fe_entries = mpr.get_entries_in_chemsys("Li-O-Co-Fe")
2725

2826
# and then create the phase diagrams
2927
# li_phase_diagram = PhaseDiagram(li_entries)
@@ -39,7 +37,6 @@
3937
li_co_o_phase_diagram_component = ctc.PhaseDiagramComponent(li_co_o_phase_diagram)
4038
# li_co_o_fe_phase_diagram_component = ctc.PhaseDiagramComponent(li_co_o_fe_phase_diagram)
4139

42-
print(li_co_o_entries)
4340

4441
# example layout to demonstrate capabilities of component
4542
my_layout = html.Div(

crystal_toolkit/apps/examples/pourbaix.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
from dash import html
33
from pymatgen.ext.matproj import MPRester
44

5-
# standard Crystal Toolkit import
65
import crystal_toolkit.components as ctc
6+
from crystal_toolkit.settings import SETTINGS
77

8-
# create Dash app as normal
9-
app = dash.Dash()
8+
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
109

1110
# If callbacks created dynamically they cannot be statically checked at app startup.
1211
# For this simple example this is not a problem, but if creating a complicated,
@@ -27,12 +26,13 @@
2726
html.Button("Get Pourbaix Diagram", id="get-pourbaix"),
2827
pourbaix_component.layout(),
2928
html.Div(id="pourbaix-output"),
30-
]
29+
],
30+
style=dict(maxWidth="90vw", margin="2em auto"),
3131
)
3232

3333
ctc.register_crystal_toolkit(app=app, layout=my_layout)
3434

35-
# allow app to be run using "python structure.py"
35+
# allow app to be run using "python pourbaix.py"
3636
# in production, deploy behind gunicorn or similar
3737
# see Dash documentation for more information
3838
if __name__ == "__main__":

0 commit comments

Comments
 (0)