Skip to content

Commit 30dab9f

Browse files
committed
change structures in basic_hello_structure_interactive.py to be more different so swapping them in callback is more obvious
cleanup unused and unsorted imports
1 parent 9e88155 commit 30dab9f

File tree

4 files changed

+33
-41
lines changed

4 files changed

+33
-41
lines changed

crystal_toolkit/apps/examples/basic_hello_structure.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# as explained in "preamble" section in documentation
22
import dash
33
from dash import html
4-
from dash import dcc
4+
from pymatgen.core.lattice import Lattice
5+
from pymatgen.core.structure import Structure
6+
57
import crystal_toolkit.components as ctc
68

79
# app = dash.Dash(external_stylesheets=['https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css'])
810
app = dash.Dash()
911

1012
# create our crystal structure using pymatgen
11-
from pymatgen.core.structure import Structure
12-
from pymatgen.core.lattice import Lattice
13-
1413
structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]])
1514

1615
# create the Crystal Toolkit component

crystal_toolkit/apps/examples/basic_hello_structure_interactive.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# as above
22
import dash
33
from dash import html
4-
from dash import dcc
5-
import crystal_toolkit.components as ctc
64

75
# standard Dash imports for callbacks (interactivity)
8-
from dash.dependencies import Input, Output, State
6+
from dash.dependencies import Input, Output
97
from dash.exceptions import PreventUpdate
10-
11-
from pymatgen.core.structure import Structure
128
from pymatgen.core.lattice import Lattice
9+
from pymatgen.core.structure import Structure
10+
11+
import crystal_toolkit.components as ctc
1312

1413
app = dash.Dash()
1514

1615
# now we give a list of structures to pick from
1716
structures = [
18-
Structure(Lattice.cubic(4), ["Na", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]),
17+
Structure(Lattice.hexagonal(5, 3), ["Na", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]),
1918
Structure(Lattice.cubic(5), ["K", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]),
2019
]
2120

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
1-
from crystal_toolkit.core.mpcomponent import MPComponent
2-
3-
register_app = MPComponent.register_app
4-
register_cache = MPComponent.register_cache
5-
register_crystal_toolkit = MPComponent.register_crystal_toolkit
6-
crystal_toolkit_layout = MPComponent.crystal_toolkit_layout
7-
8-
from crystal_toolkit.components.search import SearchComponent
9-
from crystal_toolkit.components.structure import StructureMoleculeComponent
10-
11-
from crystal_toolkit.components.robocrys import RobocrysComponent
12-
13-
from crystal_toolkit.components.diffraction import (
14-
XRayDiffractionComponent,
15-
TEMDiffractionComponent,
16-
)
17-
18-
# from crystal_toolkit.components.xas import XASComponent, XASPanelComponent
19-
20-
# from crystal_toolkit.components.submit_snl import SubmitSNLPanel
21-
from crystal_toolkit.components.symmetry import SymmetryPanel
22-
from crystal_toolkit.components.upload import StructureMoleculeUploadComponent
23-
241
from crystal_toolkit.components.bandstructure import (
252
BandstructureAndDosComponent,
263
BandstructureAndDosPanelComponent,
274
)
5+
from crystal_toolkit.components.diffraction import (
6+
TEMDiffractionComponent,
7+
XRayDiffractionComponent,
8+
)
9+
from crystal_toolkit.components.localenv import LocalEnvironmentPanel
2810

2911
# from crystal_toolkit.components.phase_diagram import (
3012
# PhaseDiagramComponent,
3113
# PhaseDiagramPanelComponent,
3214
# )
3315
from crystal_toolkit.components.pourbaix import PourbaixDiagramComponent
34-
from crystal_toolkit.components.localenv import LocalEnvironmentPanel
16+
from crystal_toolkit.components.robocrys import RobocrysComponent
17+
from crystal_toolkit.components.search import SearchComponent
18+
from crystal_toolkit.components.structure import StructureMoleculeComponent
3519

36-
from crystal_toolkit.components.transformations.core import AllTransformationsComponent
20+
# from crystal_toolkit.components.submit_snl import SubmitSNLPanel
21+
from crystal_toolkit.components.symmetry import SymmetryPanel
3722
from crystal_toolkit.components.transformations.autooxistatedecoration import (
3823
AutoOxiStateDecorationTransformationComponent,
3924
)
25+
from crystal_toolkit.components.transformations.core import AllTransformationsComponent
4026

4127
# from crystal_toolkit.components.transformations.cubic import (
4228
# CubicSupercellTransformationComponent,
@@ -51,7 +37,18 @@
5137
from crystal_toolkit.components.transformations.supercell import (
5238
SupercellTransformationComponent,
5339
)
40+
from crystal_toolkit.components.upload import StructureMoleculeUploadComponent
41+
from crystal_toolkit.core.mpcomponent import MPComponent
42+
43+
# from crystal_toolkit.components.xas import XASComponent, XASPanelComponent
44+
5445

5546
# from crystal_toolkit.components.transformations.rattle import (
5647
# MonteCarloRattleTransformationComponent,
5748
# )
49+
50+
51+
register_app = MPComponent.register_app
52+
register_cache = MPComponent.register_cache
53+
register_crystal_toolkit = MPComponent.register_crystal_toolkit
54+
crystal_toolkit_layout = MPComponent.crystal_toolkit_layout

crystal_toolkit/components/phase_diagram.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
from typing import Optional
2-
31
import dash
4-
from dash import dcc
5-
from dash import html
62
import dash_table
73
import plotly.graph_objs as go
4+
from dash import dcc, html
85
from dash.dependencies import Input, Output, State
96
from dash.exceptions import PreventUpdate
10-
from pymatgen.ext.matproj import MPRester
117
from pymatgen.analysis.phase_diagram import PDEntry, PDPlotter, PhaseDiagram
128
from pymatgen.core.composition import Composition
9+
from pymatgen.ext.matproj import MPRester
1310

1411
from crystal_toolkit.core.mpcomponent import MPComponent
1512
from crystal_toolkit.core.panelcomponent import PanelComponent
@@ -758,7 +755,7 @@ def title(self):
758755
def description(self):
759756
return (
760757
"Display the compositional phase diagram for the"
761-
" chemical system containing this structure (between 24 species)."
758+
" chemical system containing this structure (between 2-4 species)."
762759
)
763760

764761
def update_contents(self, new_store_contents, *args):

0 commit comments

Comments
 (0)