Skip to content

Commit b2852d7

Browse files
committed
doc strings
1 parent 05d3540 commit b2852d7

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed

crystal_toolkit/apps/examples/basic_hello_structure_interactive.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
Input("change_structure_button", "n_clicks"),
4141
)
4242
def update_structure(n_clicks):
43+
"""Toggle between hexagonal and cubic structures on button click."""
4344
return structures[n_clicks % 2]
4445

4546

crystal_toolkit/apps/examples/diffraction_dynamic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
@app.callback(Output(xrd_component.id(), "data"), Input(load_btn, "n_clicks"))
2626
def load_structure(n_clicks: int) -> Structure:
27+
"""Load a cubic structure on button click."""
2728
structure = Structure(Lattice.cubic(4.2), ["Na", "K"], [[0, 0, 0], [0.5, 0.5, 0.5]])
2829
return structure
2930

crystal_toolkit/apps/examples/kwarg_inputs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
Output("output", "children"), Input(your_component.get_all_kwargs_id(), "value")
6363
)
6464
def show_outputs(*args):
65+
"""Reconstruct the kwargs from the state of the component and display them as string."""
6566
kwargs = your_component.reconstruct_kwargs_from_state()
6667

6768
return str(kwargs)
@@ -71,6 +72,7 @@ def show_outputs(*args):
7172
Output("dynamic-inputs", "children"), Input("generate-inputs", "n_clicks")
7273
)
7374
def add_inputs(n_clicks):
75+
"""Add a slider input with random initial value to the layout."""
7476
if not n_clicks:
7577
raise PreventUpdate
7678

crystal_toolkit/apps/examples/mpcontribs/catalysis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def construct_grid(df, labels):
151151

152152
return fig
153153

154-
def get_catalysis_explorer(self):
154+
def get_catalysis_explorer(self) -> mpc.SearchUIContainer:
155+
"""Get the Catalysis Explorer app."""
155156
return mpc.SearchUIContainer(
156157
[
157158
self.search_bar_container(

crystal_toolkit/components/xas.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,39 @@ def _sub_layouts(self) -> dict[str, Component]:
101101

102102
@property
103103
def layout(self) -> html.Div:
104+
"""Main layout for XAS component."""
104105
return html.Div(
105106
[self._sub_layouts["graph"], self._sub_layouts["element_selector"]]
106107
)
107108

108109
def generate_callbacks(self, app, cache):
110+
"""Generate callbacks for XAS component.
111+
112+
Args:
113+
app (dash.Dash): Dash app to generate callbacks for.
114+
cache (_type_): _description_
115+
116+
Raises:
117+
PreventUpdate: If no data is available.
118+
119+
Returns:
120+
dcc.Graph | MessageContainer: XAS plot or error message.
121+
"""
122+
109123
@app.callback(Output(self.id("xas-div"), "children"), Input(self.id(), "data"))
110124
def update_graph(plotdata):
111125
if not plotdata:
112126
raise PreventUpdate
113127
if plotdata == "error":
114-
search_error = (
115-
MessageContainer(
116-
[
117-
MessageBody(
118-
dcc.Markdown(
119-
"XANES pattern not available for this selection."
120-
)
128+
search_error = MessageContainer(
129+
[
130+
MessageBody(
131+
dcc.Markdown(
132+
"XANES pattern not available for this selection."
121133
)
122-
],
123-
kind="warning",
124-
),
134+
)
135+
],
136+
kind="warning",
125137
)
126138
return search_error
127139
else:

crystal_toolkit/helpers/layouts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(
6565
gapless=False,
6666
multiline=False,
6767
**kwargs,
68-
):
68+
) -> None:
6969
_update_css_class(kwargs, "columns")
7070
if desktop_only:
7171
kwargs["className"] += " is-desktop"

crystal_toolkit/renderables/volumetric.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get_isosurface_scene(
2020
step_size (int, optional): step_size parameter for marching_cubes_lewiner. Defaults to 3.
2121
2222
Returns:
23-
[type]: [description]
23+
Scene: object containing the isosurface component
2424
"""
2525
import skimage.measure
2626

@@ -52,10 +52,10 @@ def get_volumetric_scene(self, data_key="total", isolvl=0.02, step_size=3, **kwa
5252
isolvl (float, optional): The cutoff for the isosurface to using the same units as VESTA so e/bhor
5353
and kept grid size independent
5454
step_size (int, optional): step_size parameter for marching_cubes_lewiner. Defaults to 3.
55-
**kwargs: kwargs for the Structure.get_scene function
55+
**kwargs: Passed to the Structure.get_scene() function.
5656
5757
Returns:
58-
[type]: [description]
58+
Scene: object containing the structure and isosurface components
5959
"""
6060
struct_scene = self.structure.get_scene(**kwargs)
6161
iso_scene = self.get_isosurface_scene(

0 commit comments

Comments
 (0)