Skip to content

Commit 39a2935

Browse files
authored
Merge pull request #273 from materialsproject/follow-up-#272
Follow up to #272
2 parents 616608f + 84283b1 commit 39a2935

File tree

15 files changed

+47
-43
lines changed

15 files changed

+47
-43
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ default_stages: [commit]
66
default_install_hook_types: [pre-commit, commit-msg]
77

88
# ignore generated doc and dependency lock files
9-
exclude: ^(docs/.+|.*lock.*)$
9+
exclude: ^(docs/.+|.*lock.*|.*\.(svg|js|css))$
1010

1111
repos:
1212
- repo: https://github.com/PyCQA/isort
@@ -23,6 +23,7 @@ repos:
2323
rev: 4.0.1
2424
hooks:
2525
- id: flake8
26+
additional_dependencies: [flake8-bugbear]
2627

2728
- repo: https://github.com/asottile/pyupgrade
2829
rev: v2.34.0
@@ -41,9 +42,7 @@ repos:
4142
- id: check-case-conflict
4243
- id: check-symlinks
4344
- id: check-yaml
44-
- id: destroyed-symlinks
4545
- id: end-of-file-fixer
46-
exclude: ^assets/.+\.(svg|html)$
4746
- id: mixed-line-ending
4847
- id: trailing-whitespace
4948

@@ -54,14 +53,6 @@ repos:
5453
stages: [commit, commit-msg]
5554
exclude_types: [csv, svg, html, yaml, jupyter]
5655

57-
- repo: local
58-
hooks:
59-
- id: svg-assets
60-
name: SVG assets
61-
entry: Files under assets/* must end in .(svg|html)
62-
language: fail
63-
files: ^assets/.*(?<!\.svg)(?<!\.html)$
64-
6556
- repo: https://github.com/myint/autoflake
6657
rev: v1.4
6758
hooks:

crystal_toolkit/apps/main.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,16 @@
281281
html.Div(
282282
[
283283
dcc.Markdown(
284-
f"App created by [Crystal Toolkit Development Team](https://github.com/materialsproject/crystaltoolkit/graphs/contributors). \n"
285-
f"Bug reports and feature requests gratefully accepted, please send them to [@mkhorton](mailto:[email protected]). \n"
286-
f"Powered by [The Materials Project](https://materialsproject.org), "
287-
f"[pymatgen v{pmg_version}](http://pymatgen.org) and "
288-
f"[Dash by Plotly](https://plot.ly/products/dash/). "
289-
f"Deployed on [Spin](http://www.nersc.gov/users/data-analytics/spin/)."
284+
f"""
285+
App created by [Crystal Toolkit Development Team][contributors].\nBug reports and feature
286+
requests gratefully accepted, please send them to [@mkhorton](mailto:[email protected]).\n
287+
Powered by [The Materials Project](https://materialsproject.org),
288+
[pymatgen v{pmg_version}](http://pymatgen.org) and
289+
[Dash by Plotly](https://plot.ly/products/dash/).
290+
Deployed on [Spin](http://www.nersc.gov/users/data-analytics/spin/).
291+
292+
[contributors]: https://github.com/materialsproject/crystaltoolkit/graphs/contributors
293+
"""
290294
)
291295
],
292296
className="content has-text-centered",
@@ -513,7 +517,7 @@ def master_update_structure(search_mpid: str | None, upload_data: dict | None):
513517
# triggered by both on initial load
514518
load_by = "mpid"
515519
elif (
516-
dash.callback_context.triggered[0]["prop_id"] == search_component.id() + ".data"
520+
dash.callback_context.triggered[0]["prop_id"] == f"{search_component.id()}.data"
517521
):
518522
load_by = "mpid"
519523
else:

crystal_toolkit/components/diffraction.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
from crystal_toolkit.core.mpcomponent import MPComponent
1414
from crystal_toolkit.helpers.layouts import Box, Column, Columns, Loading
1515

16-
# Scherrer equation:
17-
# Langford, J. Il, and A. J. C. Wilson. "Scherrer after sixty years: a survey and some new results in the determination of crystallite size." Journal of applied crystallography 11.2 (1978): 102-113.
16+
# Scherrer equation: Langford, J. Il, and A. J. C. Wilson. "Scherrer after sixty years:
17+
# a survey and some new results in the determination of crystallite size." Journal of
18+
# applied crystallography 11.2 (1978): 102-113.
1819
# https://doi.org/10.1107/S0021889878012844
1920

2021

crystal_toolkit/components/phase_diagram.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ def _sub_layouts(self):
514514
css=[
515515
{
516516
"selector": ".dash-cell div.dash-cell-value",
517-
"rule": "display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;",
517+
"rule": "display: inline; white-space: inherit; overflow: inherit; "
518+
"text-overflow: inherit;",
518519
}
519520
],
520521
style_cell_conditional=[

crystal_toolkit/components/structure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,13 @@ def generate_callbacks(self, app, cache):
289289
"""
290290
function (colorScheme, radiusStrategy, drawOptions, displayOptions) {
291291
292-
const newDisplayOptions = Object.assign({}, displayOptions);
292+
const newDisplayOptions = {...displayOptions}
293293
newDisplayOptions.color_scheme = colorScheme
294294
newDisplayOptions.radius_strategy = radiusStrategy
295295
newDisplayOptions.draw_image_atoms = drawOptions.includes('draw_image_atoms')
296-
newDisplayOptions.bonded_sites_outside_unit_cell = drawOptions.includes('bonded_sites_outside_unit_cell')
296+
newDisplayOptions.bonded_sites_outside_unit_cell = drawOptions.includes(
297+
'bonded_sites_outside_unit_cell'
298+
)
297299
newDisplayOptions.hide_incomplete_bonds = drawOptions.includes('hide_incomplete_bonds')
298300
299301
return newDisplayOptions

crystal_toolkit/components/transformations/grainboundary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def options_layouts(self, state=None, structure=None):
9191
kwarg_label="expand_times",
9292
state=state,
9393
help_str="""The multiple number of times to expand one unit grain into a larger grain. This is
94-
useful to avoid self-interaction issues when using the grain boundary as an input to further simulations.""",
94+
useful to avoid self-interaction issues when using the grain boundary as an input to further
95+
simulations.""",
9596
is_int=True,
9697
shape=(),
9798
min=1,

crystal_toolkit/core/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def get_legend(self) -> dict[str, Any]:
427427

428428
# first get all our colors for different species
429429
for site in self.site_collection:
430-
for sp, occu in site.species.items():
430+
for sp in site.species:
431431
legend[self.get_color(sp, site)].append(label(site, sp))
432432

433433
legend = {k: ", ".join(sorted(list(set(v)))) for k, v in legend.items()}

crystal_toolkit/core/mpcomponent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def __init__(
215215
MPComponent._all_id_basenames.add(id)
216216

217217
self._id = id
218-
self._all_ids = set()
218+
self._all_ids: set[str] = set()
219219
self._stores = {}
220220
self._initial_data = {}
221221

@@ -497,9 +497,9 @@ def matrix_element(idx, value=0):
497497

498498
# arrange the input boxes in two dimensions (rows, columns)
499499
matrix_div_contents = []
500-
for row_idx, columns in sorted(matrix_contents.items()):
500+
for columns in sorted(matrix_contents.values()):
501501
row = []
502-
for column_idx, element in sorted(columns.items()):
502+
for element in sorted(columns.values()):
503503
row.append(element)
504504
matrix_div_contents.append(html.Div(row))
505505

crystal_toolkit/core/scene.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ class Ellipsoids(Primitive):
240240
:param scale: This is the scale to apply to the x,y and z axis of the ellipsoid prior to rotation to the target axes
241241
:param positions: This is a list of lists corresponding to the vector
242242
positions of the ellipsoids.
243-
:param rotate_to: This is a list of vectors that specify the direction the major axis of the ellipsoid should point towards. The major axis is the z-axis: (0,0,1)
243+
:param rotate_to: This is a list of vectors that specify the direction the major axis of the ellipsoid should point
244+
towards. The major axis is the z-axis: (0,0,1)
244245
:param color: Ellipsoid color as a hexadecimal string, e.g. #ff0000
245246
:param phiStart: Start angle in radians if drawing only a section of the
246247
ellipsoid, defaults to 0
@@ -554,7 +555,7 @@ class Label:
554555

555556
label: str
556557
labelHover: str | None = None
557-
position: list[list[float]] = None
558+
position: list[list[float]] | None = None
558559
type: str = field(default="labels", init=False) # private field
559560
visible: bool | None = None
560561
clickable: bool = False

crystal_toolkit/helpers/asymptote_renderer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Since ASY does not have the nested tree structure of threejs,
55
we just have to traverse the tree and draw each material as we see them.
66
7-
TODO The code should also appends a set of special points at the end in case the user wants to add more "hand drawn" features to the plot
7+
TODO The code should also appends a set of special points at the end in case the user wants to add
8+
more "hand drawn" features to the plot
89
910
"""
1011
import logging

0 commit comments

Comments
 (0)