structuretoolkit 0.0.18__tar.gz → 0.0.19__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {structuretoolkit-0.0.18/structuretoolkit.egg-info → structuretoolkit-0.0.19}/PKG-INFO +7 -7
  2. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/pyproject.toml +6 -6
  3. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/_version.py +3 -3
  4. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/strain.py +0 -1
  5. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/symmetry.py +0 -1
  6. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/visualize.py +35 -0
  7. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19/structuretoolkit.egg-info}/PKG-INFO +7 -7
  8. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit.egg-info/requires.txt +6 -6
  9. structuretoolkit-0.0.19/tests/test_visualize.py +45 -0
  10. structuretoolkit-0.0.18/tests/test_visualize.py +0 -26
  11. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/LICENSE +0 -0
  12. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/MANIFEST.in +0 -0
  13. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/README.md +0 -0
  14. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/setup.cfg +0 -0
  15. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/setup.py +0 -0
  16. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/__init__.py +0 -0
  17. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/__init__.py +0 -0
  18. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/distance.py +0 -0
  19. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/neighbors.py +0 -0
  20. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/phonopy.py +0 -0
  21. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/pyscal.py +0 -0
  22. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/analyse/spatial.py +0 -0
  23. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/__init__.py +0 -0
  24. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/aimsgb.py +0 -0
  25. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/compound.py +0 -0
  26. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/random.py +0 -0
  27. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/sqs.py +0 -0
  28. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/build/surface.py +0 -0
  29. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/__init__.py +0 -0
  30. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/error.py +0 -0
  31. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/helper.py +0 -0
  32. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/phonopy.py +0 -0
  33. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/pymatgen.py +0 -0
  34. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit/common/pyscal.py +0 -0
  35. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit.egg-info/SOURCES.txt +0 -0
  36. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit.egg-info/dependency_links.txt +0 -0
  37. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/structuretoolkit.egg-info/top_level.txt +0 -0
  38. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_aimsgb.py +0 -0
  39. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_analyse.py +0 -0
  40. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_compound.py +0 -0
  41. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_high_index_surface.py +0 -0
  42. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_neighbors.py +0 -0
  43. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_pymatgen.py +0 -0
  44. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_pyscal.py +0 -0
  45. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_pyxtal.py +0 -0
  46. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_strain.py +0 -0
  47. {structuretoolkit-0.0.18 → structuretoolkit-0.0.19}/tests/test_symmetry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: structuretoolkit
3
- Version: 0.0.18
3
+ Version: 0.0.19
4
4
  Summary: build, analyse and visualise atomistic structures for materials science
5
5
  Author-email: Jan Janssen <janssen@mpie.de>
6
6
  License: BSD 3-Clause License
@@ -54,7 +54,7 @@ Requires-Dist: numpy<=1.26.3,>=1.23.5
54
54
  Requires-Dist: scipy<=1.12.0,>=1.9.3
55
55
  Provides-Extra: grainboundary
56
56
  Requires-Dist: aimsgb<=1.1.0,>=1.0.2; extra == "grainboundary"
57
- Requires-Dist: pymatgen<=2023.12.18,>=2022.2.1; extra == "grainboundary"
57
+ Requires-Dist: pymatgen<=2024.1.27,>=2022.2.1; extra == "grainboundary"
58
58
  Provides-Extra: pyscal
59
59
  Requires-Dist: pyscal2==2.10.18; extra == "pyscal"
60
60
  Provides-Extra: nglview
@@ -66,15 +66,15 @@ Requires-Dist: plotly<=5.18.0,>=4.14.3; extra == "plotly"
66
66
  Provides-Extra: clusters
67
67
  Requires-Dist: scikit-learn==1.4.0; extra == "clusters"
68
68
  Provides-Extra: symmetry
69
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "symmetry"
69
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "symmetry"
70
70
  Provides-Extra: surface
71
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "surface"
72
- Requires-Dist: pymatgen<=2023.12.18,>=2022.2.1; extra == "surface"
71
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "surface"
72
+ Requires-Dist: pymatgen<=2024.1.27,>=2022.2.1; extra == "surface"
73
73
  Provides-Extra: phonopy
74
74
  Requires-Dist: phonopy<=2.21.0,>=2.16.2; extra == "phonopy"
75
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "phonopy"
75
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "phonopy"
76
76
  Provides-Extra: pyxtal
77
- Requires-Dist: pyxtal<=0.6.1,>=0.5.5; extra == "pyxtal"
77
+ Requires-Dist: pyxtal<=0.6.2,>=0.5.5; extra == "pyxtal"
78
78
 
79
79
  # structuretoolkit
80
80
 
@@ -38,23 +38,23 @@ Repository = "https://github.com/pyiron/structuretoolkit"
38
38
  [project.optional-dependencies]
39
39
  grainboundary = [
40
40
  "aimsgb>=1.0.2,<=1.1.0",
41
- "pymatgen>=2022.2.1,<=2023.12.18",
41
+ "pymatgen>=2022.2.1,<=2024.1.27",
42
42
  ]
43
43
  pyscal = ["pyscal2==2.10.18"]
44
44
  nglview = ["nglview>=2.7.7,<=3.1.1"]
45
45
  matplotlib = ["matplotlib==3.8.2"]
46
46
  plotly = ["plotly>=4.14.3,<=5.18.0"]
47
47
  clusters = ["scikit-learn==1.4.0"]
48
- symmetry = ["spglib>=1.16.5,<=2.2.0"]
48
+ symmetry = ["spglib>=1.16.5,<=2.3.0"]
49
49
  surface = [
50
- "spglib>=1.16.5,<=2.2.0",
51
- "pymatgen>=2022.2.1,<=2023.12.18",
50
+ "spglib>=1.16.5,<=2.3.0",
51
+ "pymatgen>=2022.2.1,<=2024.1.27",
52
52
  ]
53
53
  phonopy = [
54
54
  "phonopy>=2.16.2,<=2.21.0",
55
- "spglib>=1.16.5,<=2.2.0",
55
+ "spglib>=1.16.5,<=2.3.0",
56
56
  ]
57
- pyxtal = ["pyxtal>=0.5.5,<=0.6.1"]
57
+ pyxtal = ["pyxtal>=0.5.5,<=0.6.2"]
58
58
 
59
59
  [tool.setuptools.packages.find]
60
60
  include = ["structuretoolkit*"]
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-01-22T09:34:21+0100",
11
+ "date": "2024-02-09T08:34:00+0100",
12
12
  "dirty": true,
13
13
  "error": null,
14
- "full-revisionid": "b27285c3dda8921aa6c6e0b85a3f0be5838b2732",
15
- "version": "0.0.18"
14
+ "full-revisionid": "e6f880b960f6aaa479844d7a76533353225d21a1",
15
+ "version": "0.0.19"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -6,7 +6,6 @@ from structuretoolkit.analyse.pyscal import get_adaptive_cna_descriptors
6
6
 
7
7
 
8
8
  class Strain:
9
-
10
9
  """
11
10
  Calculate local strain of each atom following the Lagrangian strain tensor:
12
11
 
@@ -24,7 +24,6 @@ __date__ = "Sep 1, 2017"
24
24
 
25
25
 
26
26
  class Symmetry(dict):
27
-
28
27
  """
29
28
 
30
29
  Return a class for operations related to box symmetries. Main attributes:
@@ -41,6 +41,7 @@ def plot3d(
41
41
  view_plane=np.array([0, 0, 1]),
42
42
  distance_from_camera=1.0,
43
43
  opacity=1.0,
44
+ height=None,
44
45
  ):
45
46
  """
46
47
  Plot3d relies on NGLView or plotly to visualize atomic structures. Here, we construct a string in the "protein database"
@@ -82,6 +83,8 @@ def plot3d(
82
83
  call. (Default is np.array([0, 0, 1]), which is view normal to the x-y plane.)
83
84
  distance_from_camera (float): Distance of the camera from the structure. Higher = farther away.
84
85
  (Default is 14, which also seems to be the NGLView default value.)
86
+ height (int/float/None): height of the plot area in pixel (only
87
+ available in plotly) Default: 600
85
88
 
86
89
  Possible NGLView color schemes:
87
90
  " ", "picking", "random", "uniform", "atomindex", "residueindex",
@@ -96,6 +99,8 @@ def plot3d(
96
99
  * The colour interpretation of some hex codes is weird, e.g. 'green'.
97
100
  """
98
101
  if mode == "NGLview":
102
+ if height is not None:
103
+ warnings.warn("`height` is not implemented in NGLview", SyntaxWarning)
99
104
  return _plot3d(
100
105
  structure=structure,
101
106
  show_cell=show_cell,
@@ -120,6 +125,7 @@ def plot3d(
120
125
  elif mode == "plotly":
121
126
  return _plot3d_plotly(
122
127
  structure=structure,
128
+ show_cell=show_cell,
123
129
  camera=camera,
124
130
  particle_size=particle_size,
125
131
  select_atoms=select_atoms,
@@ -127,8 +133,11 @@ def plot3d(
127
133
  view_plane=view_plane,
128
134
  distance_from_camera=distance_from_camera,
129
135
  opacity=opacity,
136
+ height=height,
130
137
  )
131
138
  elif mode == "ase":
139
+ if height is not None:
140
+ warnings.warn("`height` is not implemented in ase", SyntaxWarning)
132
141
  return _plot3d_ase(
133
142
  structure=structure,
134
143
  show_cell=show_cell,
@@ -143,8 +152,20 @@ def plot3d(
143
152
  raise ValueError("plot method not recognized")
144
153
 
145
154
 
155
+ def _get_box_skeleton(cell):
156
+ lines_dz = np.stack(np.meshgrid(*3 * [[0, 1]], indexing="ij"), axis=-1)
157
+ # eight corners of a unit cube, paired as four z-axis lines
158
+
159
+ all_lines = np.reshape(
160
+ [np.roll(lines_dz, i, axis=-1) for i in range(3)], (-1, 2, 3)
161
+ )
162
+ # All 12 two-point lines on the unit square
163
+ return all_lines @ cell
164
+
165
+
146
166
  def _plot3d_plotly(
147
167
  structure,
168
+ show_cell=True,
148
169
  scalar_field=None,
149
170
  select_atoms=None,
150
171
  particle_size=1.0,
@@ -152,6 +173,7 @@ def _plot3d_plotly(
152
173
  view_plane=np.array([1, 1, 1]),
153
174
  distance_from_camera=1,
154
175
  opacity=1,
176
+ height=None,
155
177
  ):
156
178
  """
157
179
  Make a 3D plot of the atomic structure.
@@ -170,6 +192,7 @@ def _plot3d_plotly(
170
192
  distance_from_camera (float): Distance of the camera from the structure. Higher = farther away.
171
193
  (Default is 14, which also seems to be the NGLView default value.)
172
194
  opacity (float): opacity
195
+ height (int/float/None): height of the plot area in pixel. Default: 600
173
196
 
174
197
  Returns:
175
198
  (plotly.express): The NGLView widget itself, which can be operated on further or viewed as-is.
@@ -177,6 +200,7 @@ def _plot3d_plotly(
177
200
  """
178
201
  try:
179
202
  import plotly.express as px
203
+ import plotly.graph_objects as go
180
204
  except ModuleNotFoundError:
181
205
  raise ModuleNotFoundError("plotly not installed - use plot3d instead")
182
206
  if select_atoms is None:
@@ -196,6 +220,13 @@ def _plot3d_plotly(
196
220
  scale=particle_size / (0.1 * structure.get_volume() ** (1 / 3)),
197
221
  ),
198
222
  )
223
+ if show_cell:
224
+ data = fig.data
225
+ for lines in _get_box_skeleton(structure.cell):
226
+ fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
227
+ fig.update_traces(line_color="#000000")
228
+ data = fig.data + data
229
+ fig = go.Figure(data=data)
199
230
  fig.layout.scene.camera.projection.type = camera
200
231
  rot = _get_orientation(view_plane).T
201
232
  rot[0, :] *= distance_from_camera * 1.25
@@ -206,6 +237,10 @@ def _plot3d_plotly(
206
237
  fig.update_layout(scene_camera=angle)
207
238
  fig.update_traces(marker=dict(line=dict(width=0.1, color="DarkSlateGrey")))
208
239
  fig.update_scenes(aspectmode="data")
240
+ if height is None:
241
+ height = 600
242
+ fig.update_layout(autosize=True, height=height)
243
+ fig.update_layout(legend={"itemsizing": "constant"})
209
244
  return fig
210
245
 
211
246
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: structuretoolkit
3
- Version: 0.0.18
3
+ Version: 0.0.19
4
4
  Summary: build, analyse and visualise atomistic structures for materials science
5
5
  Author-email: Jan Janssen <janssen@mpie.de>
6
6
  License: BSD 3-Clause License
@@ -54,7 +54,7 @@ Requires-Dist: numpy<=1.26.3,>=1.23.5
54
54
  Requires-Dist: scipy<=1.12.0,>=1.9.3
55
55
  Provides-Extra: grainboundary
56
56
  Requires-Dist: aimsgb<=1.1.0,>=1.0.2; extra == "grainboundary"
57
- Requires-Dist: pymatgen<=2023.12.18,>=2022.2.1; extra == "grainboundary"
57
+ Requires-Dist: pymatgen<=2024.1.27,>=2022.2.1; extra == "grainboundary"
58
58
  Provides-Extra: pyscal
59
59
  Requires-Dist: pyscal2==2.10.18; extra == "pyscal"
60
60
  Provides-Extra: nglview
@@ -66,15 +66,15 @@ Requires-Dist: plotly<=5.18.0,>=4.14.3; extra == "plotly"
66
66
  Provides-Extra: clusters
67
67
  Requires-Dist: scikit-learn==1.4.0; extra == "clusters"
68
68
  Provides-Extra: symmetry
69
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "symmetry"
69
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "symmetry"
70
70
  Provides-Extra: surface
71
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "surface"
72
- Requires-Dist: pymatgen<=2023.12.18,>=2022.2.1; extra == "surface"
71
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "surface"
72
+ Requires-Dist: pymatgen<=2024.1.27,>=2022.2.1; extra == "surface"
73
73
  Provides-Extra: phonopy
74
74
  Requires-Dist: phonopy<=2.21.0,>=2.16.2; extra == "phonopy"
75
- Requires-Dist: spglib<=2.2.0,>=1.16.5; extra == "phonopy"
75
+ Requires-Dist: spglib<=2.3.0,>=1.16.5; extra == "phonopy"
76
76
  Provides-Extra: pyxtal
77
- Requires-Dist: pyxtal<=0.6.1,>=0.5.5; extra == "pyxtal"
77
+ Requires-Dist: pyxtal<=0.6.2,>=0.5.5; extra == "pyxtal"
78
78
 
79
79
  # structuretoolkit
80
80
 
@@ -7,7 +7,7 @@ scikit-learn==1.4.0
7
7
 
8
8
  [grainboundary]
9
9
  aimsgb<=1.1.0,>=1.0.2
10
- pymatgen<=2023.12.18,>=2022.2.1
10
+ pymatgen<=2024.1.27,>=2022.2.1
11
11
 
12
12
  [matplotlib]
13
13
  matplotlib==3.8.2
@@ -17,7 +17,7 @@ nglview<=3.1.1,>=2.7.7
17
17
 
18
18
  [phonopy]
19
19
  phonopy<=2.21.0,>=2.16.2
20
- spglib<=2.2.0,>=1.16.5
20
+ spglib<=2.3.0,>=1.16.5
21
21
 
22
22
  [plotly]
23
23
  plotly<=5.18.0,>=4.14.3
@@ -26,11 +26,11 @@ plotly<=5.18.0,>=4.14.3
26
26
  pyscal2==2.10.18
27
27
 
28
28
  [pyxtal]
29
- pyxtal<=0.6.1,>=0.5.5
29
+ pyxtal<=0.6.2,>=0.5.5
30
30
 
31
31
  [surface]
32
- spglib<=2.2.0,>=1.16.5
33
- pymatgen<=2023.12.18,>=2022.2.1
32
+ spglib<=2.3.0,>=1.16.5
33
+ pymatgen<=2024.1.27,>=2022.2.1
34
34
 
35
35
  [symmetry]
36
- spglib<=2.2.0,>=1.16.5
36
+ spglib<=2.3.0,>=1.16.5
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ # Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
3
+ # Distributed under the terms of "New BSD License", see the LICENSE file.
4
+
5
+ import unittest
6
+ import numpy as np
7
+ from structuretoolkit.visualize import _get_flattened_orientation, _get_box_skeleton
8
+
9
+
10
+ class TestAtoms(unittest.TestCase):
11
+ @classmethod
12
+ def tearDownClass(cls):
13
+ pass
14
+
15
+ @classmethod
16
+ def setUpClass(cls):
17
+ pass
18
+
19
+ def test_get_flattened_orientation(self):
20
+ R = np.random.random(9).reshape(-1, 3)
21
+ R = np.array(_get_flattened_orientation(R, 1)).reshape(4, 4)
22
+ self.assertAlmostEqual(np.linalg.det(R), 1)
23
+
24
+ def test_get_frame(self):
25
+ frame = _get_box_skeleton(np.eye(3))
26
+ self.assertLessEqual(
27
+ np.unique(frame.reshape(-1, 6), axis=0, return_counts=True)[1].max(),
28
+ 1
29
+ )
30
+ dx, counts = np.unique(
31
+ np.diff(frame, axis=-2).squeeze().astype(int), axis=0, return_counts=True
32
+ )
33
+ self.assertEqual(
34
+ dx.ptp(), 1, msg="Frames not drawn along the nearest edges"
35
+ )
36
+ msg = (
37
+ "There must be four lines along each direction"
38
+ + " (4 x [1, 0, 0], 4 x [0, 1, 0] and 4 x [0, 0, 1])"
39
+ )
40
+ self.assertEqual(counts.min(), 4, msg=msg)
41
+ self.assertEqual(counts.max(), 4, msg=msg)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ unittest.main()
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- # Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
3
- # Distributed under the terms of "New BSD License", see the LICENSE file.
4
-
5
- import unittest
6
- import numpy as np
7
- from structuretoolkit.visualize import _get_flattened_orientation
8
-
9
-
10
- class TestAtoms(unittest.TestCase):
11
- @classmethod
12
- def tearDownClass(cls):
13
- pass
14
-
15
- @classmethod
16
- def setUpClass(cls):
17
- pass
18
-
19
- def test_get_flattened_orientation(self):
20
- R = np.random.random(9).reshape(-1, 3)
21
- R = np.array(_get_flattened_orientation(R, 1)).reshape(4, 4)
22
- self.assertAlmostEqual(np.linalg.det(R), 1)
23
-
24
-
25
- if __name__ == "__main__":
26
- unittest.main()