Skip to content

Commit 00f8e1c

Browse files
committed
clean up
1 parent 6577d32 commit 00f8e1c

File tree

8 files changed

+28
-40
lines changed

8 files changed

+28
-40
lines changed

crystal_toolkit/_version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = "2023.02.01"
1+
from __future__ import annotations
2+
3+
__version__ = "2023.02.01"

crystal_toolkit/apps/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@
425425
################################################################################
426426

427427

428-
@app.callback(Output(search_component.id("input"), "value"), [Input("url", "href")])
428+
@app.callback(Output(search_component.id("input"), "value"), Input("url", "href"))
429429
def update_search_term_on_page_load(href: str) -> str:
430430
"""If an mpid is provided in the url, load that mpid. Otherwise load a random mpid from the
431431
DEFAULT_MPIDS global variable.

crystal_toolkit/components/bandstructure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def _get_data_list_dict(bs, dos):
774774

775775
def generate_callbacks(self, app, cache):
776776
@app.callback(
777-
Output(self.id("bsdos-div"), "children"), [Input(self.id("traces"), "data")]
777+
Output(self.id("bsdos-div"), "children"), Input(self.id("traces"), "data")
778778
)
779779
def update_graph(traces):
780780
if traces == "error":

crystal_toolkit/components/diffraction.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,12 @@ def update_message(structure):
515515
)
516516

517517
# @app.callback(
518-
# Output(self.id("static-image"), "src"),
519-
# [Input(self.id("xrd-plot"), "figure")]
518+
# Output(self.id("static-image"), "src"), Input(self.id("xrd-plot"), "figure")
520519
# )
521520
# def update_static_image(data):
522-
#
521+
523522
# scope = PlotlyScope()
524523
# output = scope.transform(data, format="png", width=600, height=400, scale=4)
525-
# image = b64encode(output).decode('ascii')
526-
#
524+
# image = b64encode(output).decode("ascii")
525+
527526
# return f"data:image/png;base64,{image}"

crystal_toolkit/components/phase_diagram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def update_graph(figure):
579579
]
580580
return plot
581581

582-
@app.callback(Output(self.id("figure"), "data"), [Input(self.id(), "data")])
582+
@app.callback(Output(self.id("figure"), "data"), Input(self.id(), "data"))
583583
def make_figure(pd):
584584
if pd is None:
585585
raise PreventUpdate

crystal_toolkit/components/structure.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ class StructureMoleculeComponent(MPComponent):
6161

6262
default_scene_settings = {
6363
"extractAxis": True,
64-
# For visual diff testing, we change the renderer
65-
# to SVG since this WebGL support is more difficult
66-
# in headless browsers / CI.
64+
# For visual diff testing, we change the renderer to SVG since this WebGL
65+
# support is more difficult in headless browsers / CI.
6766
"renderer": "svg" if SETTINGS.TEST_MODE else "webgl",
6867
"secondaryObjectView": False,
6968
}
@@ -235,9 +234,7 @@ def __init__(
235234
self._initial_data["scene"] = scene
236235

237236
# hide axes inset for molecules
238-
if isinstance(struct_or_mol, Molecule) or isinstance(
239-
struct_or_mol, MoleculeGraph
240-
):
237+
if isinstance(struct_or_mol, (Molecule, MoleculeGraph)):
241238
self.scene_kwargs = {"axisView": "HIDDEN"}
242239
else:
243240
self.scene_kwargs = {}
@@ -268,11 +265,9 @@ def generate_callbacks(self, app, cache):
268265
}
269266
""",
270267
Output(self.id("graph_generation_options"), "data"),
271-
[
272-
Input(self.id("bonding_algorithm"), "value"),
273-
Input(self.id("bonding_algorithm_custom_cutoffs"), "data"),
274-
Input(self.id("unit-cell-choice"), "value"),
275-
],
268+
Input(self.id("bonding_algorithm"), "value"),
269+
Input(self.id("bonding_algorithm_custom_cutoffs"), "data"),
270+
Input(self.id("unit-cell-choice"), "value"),
276271
)
277272

278273
app.clientside_callback(
@@ -286,8 +281,8 @@ def generate_callbacks(self, app, cache):
286281
}
287282
""",
288283
Output(self.id("scene"), "toggleVisibility"),
289-
[Input(self.id("hide-show"), "value")],
290-
[State(self.id("hide-show"), "options")],
284+
Input(self.id("hide-show"), "value"),
285+
State(self.id("hide-show"), "options"),
291286
)
292287

293288
app.clientside_callback(
@@ -307,12 +302,10 @@ def generate_callbacks(self, app, cache):
307302
}
308303
""",
309304
Output(self.id("display_options"), "data"),
310-
[
311-
Input(self.id("color-scheme"), "value"),
312-
Input(self.id("radius_strategy"), "value"),
313-
Input(self.id("draw_options"), "value"),
314-
],
315-
[State(self.id("display_options"), "data")],
305+
Input(self.id("color-scheme"), "value"),
306+
Input(self.id("radius_strategy"), "value"),
307+
Input(self.id("draw_options"), "value"),
308+
State(self.id("display_options"), "data"),
316309
)
317310

318311
@app.callback(
@@ -411,20 +404,16 @@ def update_color_options(legend_data):
411404
# app.clientside_callback(
412405
# """
413406
# function (legendData) {
414-
#
415-
# var colorOptions = [
407+
# const colorOptions = [
416408
# {label: "Jmol", value: "Jmol"},
417409
# {label: "VESTA", value: "VESTA"},
418410
# {label: "Accessible", value: "accessible"},
419411
# ]
420-
#
421-
#
422-
#
423412
# return colorOptions
424413
# }
425414
# """,
426415
# Output(self.id("color-scheme"), "options"),
427-
# [Input(self.id("legend_data"), "data")]
416+
# Input(self.id("legend_data"), "data"),
428417
# )
429418

430419
@app.callback(
@@ -945,7 +934,7 @@ def _preprocess_input_to_graph(
945934
# we assume most uses of this class will give a structure as an input argument,
946935
# meaning we have to calculate the graph for bonding information, however if
947936
# the graph is already known and supplied, we will use that
948-
if isinstance(input, StructureGraph) or isinstance(input, MoleculeGraph):
937+
if isinstance(input, (StructureGraph, MoleculeGraph)):
949938
graph = input
950939
else:
951940
if (
@@ -1001,7 +990,7 @@ def _get_struct_or_mol(
1001990
return graph.structure
1002991
elif isinstance(graph, MoleculeGraph):
1003992
return graph.molecule
1004-
elif isinstance(graph, Structure) or isinstance(graph, Molecule):
993+
elif isinstance(graph, (Structure, Molecule)):
1005994
return graph
1006995
else:
1007996
raise ValueError

crystal_toolkit/core/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def analyze_site_props(site_collection: SiteCollection) -> dict[str, list[str]]:
366366
# (implicitly assumes all site props for a given key are same type)
367367
site_prop_names = defaultdict(list)
368368
for name, props in site_collection.site_properties.items():
369-
if isinstance(props[0], float) or isinstance(props[0], int):
369+
if isinstance(props[0], (int, float)):
370370
site_prop_names["scalar"].append(name)
371371
elif isinstance(props[0], list) and len(props[0]) == 3:
372372
if isinstance(props[0][0], list) and len(props[0][0]) == 3:

crystal_toolkit/helpers/asymptote_renderer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ def write_asy_file(renderable_object, file_name, **kwargs):
631631
renderable_object: Object to be rendered
632632
file_name: name of file
633633
"""
634-
if isinstance(renderable_object, Structure) or isinstance(
635-
renderable_object, StructureGraph
636-
):
634+
if isinstance(renderable_object, (Structure, StructureGraph)):
637635
kwargs["explicitly_calculate_polyhedra_hull"] = True
638636
write_ctk_scene_to_file(renderable_object.get_scene(**kwargs), file_name)

0 commit comments

Comments
 (0)