AdsorPy 1.1.5__tar.gz → 1.2.0__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.
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- {adsorpy-1.1.5 → adsorpy-1.2.0}/CHANGELOG.md +17 -1
- {adsorpy-1.1.5 → adsorpy-1.2.0}/PKG-INFO +9 -8
- {adsorpy-1.1.5 → adsorpy-1.2.0}/README.md +6 -6
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.rst +1 -0
- adsorpy-1.2.0/docs/source/adsorpy.typing.rst +7 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/conf.py +1 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/index.rst +1 -1
- {adsorpy-1.1.5 → adsorpy-1.2.0}/pyproject.toml +30 -23
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/molecule_lib.py +71 -73
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/randomsequentialadsorption.py +64 -65
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/rsa_calculator.py +66 -61
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/rsa_config.py +1 -1
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/run_simulation.py +116 -130
- adsorpy-1.2.0/src/adsorpy/typing.py +39 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/rsa_test.py +8 -29
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/run_simulation_test.py +14 -13
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tox.toml +7 -2
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/dependabot.yml +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/workflows/docs-ci.yml +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/workflows/publish_to_PyPI.yml +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/.github/workflows/tests-ci.yml +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/CODE_OF_CONDUCT.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/CONTRIBUTING.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/LICENSE.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/SECURITY.md +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/Makefile +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/make.bat +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.molecule_lib.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.randomsequentialadsorption.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.rsa_calculator.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.rsa_config.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/adsorpy.run_simulation.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/docs/source/modules.rst +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/images/AdsorPy_Covered_Surface.png +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/py.typed +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/__init__.py +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/__main__.py +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/VdW_Radii.csv +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/__init__.py +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/config.json +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/src/adsorpy/molecule_colour.json +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/__init__.py +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/test_data/config_test_hard.json +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/test_data/config_test_periodic.json +0 -0
- {adsorpy-1.1.5 → adsorpy-1.2.0}/tests/test_data/config_test_soft.json +0 -0
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
### New Feature Submissions:
|
|
9
9
|
|
|
10
|
-
1. [ ] Does your submission pass tests?
|
|
10
|
+
1. [ ] Does your submission pass all ``pytest`` tests?
|
|
11
11
|
2. [ ] Have you lint your code locally before submission?
|
|
12
|
-
3. [ ] Does your code pass the ``mypy`` and ``ruff`` checks?
|
|
12
|
+
3. [ ] Does your code pass the ``mypy``, ``pyright``, and ``ruff`` checks?
|
|
13
13
|
|
|
14
14
|
### Changes to Core Features:
|
|
15
15
|
|
|
@@ -10,8 +10,19 @@ This format is based on [Keep a Changelog](http://keepachangelog.com/) and this
|
|
|
10
10
|
### Fixed
|
|
11
11
|
### Removed
|
|
12
12
|
|
|
13
|
+
## 1.2.0 - 2026-05-06
|
|
14
|
+
### Added
|
|
15
|
+
- Add ``pyright`` linting in strict mode.
|
|
16
|
+
- Add ``typing.py``.
|
|
17
|
+
### Changed
|
|
18
|
+
- Move all ``TypeAlias`` to the new ``typing.py``.
|
|
19
|
+
### Fixed
|
|
20
|
+
- Fix flux: was an ``np.ndarray``, is now a tuple of arrays. Beware: this changes the type of that return value of ``run_simulation()``.
|
|
21
|
+
### Removed
|
|
22
|
+
|
|
13
23
|
## 1.1.5 - 2026-05-04
|
|
14
24
|
### Added
|
|
25
|
+
- Installation can now use ``[test]``, ``[lint]``, and ``[docs]`` as optional dependencies.
|
|
15
26
|
- Add final ``ci-success`` step to the ``tests-ci.yml``.
|
|
16
27
|
- Add ``dependabot.yml`` with permission for minor/patch update pull requests.
|
|
17
28
|
- Add ``CODE_OF_CONDUCT.md``.
|
|
@@ -21,11 +32,16 @@ This format is based on [Keep a Changelog](http://keepachangelog.com/) and this
|
|
|
21
32
|
- Change ``test-ci.yml`` order: first on pull_requests, then push. Change push filter from paths to paths-ignore. Now ignores all ``.md`` files and everything in docs. Tests run whenever anything else is changed. Also puts ``main`` on ignore for push. Direct pushing to ``main`` is not allowed, and not ignoring ``main`` would result in duplicate tests.
|
|
22
33
|
- Lower ``test_gapsize_analysis()`` in ``rsa_test.py`` to 100.
|
|
23
34
|
- Change parametrised tests in ``rsa_tests.py`` to improve readability of code and test results.
|
|
24
|
-
- Move from ``tox.ini`` to ``tox.toml``.
|
|
35
|
+
- Move from ``tox.ini`` to ``tox.toml``.
|
|
25
36
|
### Fixed
|
|
26
37
|
- Fix potential vulnerabilities in the CI by reducing the scope of permissions.
|
|
27
38
|
- All tests are now ``mypy`` and ``ruff`` compliant.
|
|
39
|
+
- Fix the link to the adsorpy image. The image can now be seen on PyPI.
|
|
28
40
|
### Removed
|
|
41
|
+
- ``requirements.txt``
|
|
42
|
+
- ``requirements_dev.txt``
|
|
43
|
+
- ``requirements_lint.txt``
|
|
44
|
+
- ``requirements_docs.txt``
|
|
29
45
|
|
|
30
46
|
## 1.1.4 - 2026-04-28
|
|
31
47
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: adsorpy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Random sequential adsorption (RSA) simulation, 2D lattice-based.
|
|
5
5
|
Project-URL: github, https://github.com/JoostFWMaas/AdsorPy
|
|
6
6
|
Project-URL: Documentation, https://joostfwmaas.github.io/AdsorPy
|
|
@@ -43,7 +43,8 @@ Requires-Dist: sphinx-design>=0.7.0; extra == 'docs'
|
|
|
43
43
|
Requires-Dist: sphinx-pyproject>=0.3.0; extra == 'docs'
|
|
44
44
|
Requires-Dist: sphinx>=9.1.0; extra == 'docs'
|
|
45
45
|
Provides-Extra: lint
|
|
46
|
-
Requires-Dist: mypy>=
|
|
46
|
+
Requires-Dist: mypy>=2.0.0; extra == 'lint'
|
|
47
|
+
Requires-Dist: pyright>=1.1.409; extra == 'lint'
|
|
47
48
|
Requires-Dist: ruff>=0.15.12; extra == 'lint'
|
|
48
49
|
Provides-Extra: test
|
|
49
50
|
Requires-Dist: codecov>=2.1.13; extra == 'test'
|
|
@@ -81,7 +82,7 @@ Run the `adsorpy.run_simulation.run_simulation()` function with the molecule foo
|
|
|
81
82
|
User friendliness will be updated at a later stage, allowing the user to define simulation modes, surfaces, and
|
|
82
83
|
molecules more easily.
|
|
83
84
|
|
|
84
|
-
Documentation (generated with `
|
|
85
|
+
Documentation (generated with `sphinx`): https://joostfwmaas.github.io/AdsorPy/
|
|
85
86
|
|
|
86
87
|
## Future additions
|
|
87
88
|
|
|
@@ -90,11 +91,11 @@ In a future update, the code will be expanded with diffusion, desorption, and sp
|
|
|
90
91
|
## Design philosophy
|
|
91
92
|
|
|
92
93
|
Because AdsorPy has been made with scientific rigour in mind, the package is tested in multiple ways:
|
|
93
|
-
- Unit tests (`
|
|
94
|
-
- Property tests (`
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
94
|
+
- Unit tests (`pytest`) of the code ensure correct behaviour for expected input.
|
|
95
|
+
- Property tests (`hypothesis`) of the most critical code components ensure correct behaviour for unexpected input as well.
|
|
96
|
+
- `mypy` (in `--strict` mode) and `pyright` (`strict`) ensure that the package is correctly-typed, as if it were static. The `py.typed` file, a promise that the code is type-hinted properly, is added because the code passes this test.
|
|
97
|
+
- `ruff` is used as a linter with almost all rules enabled (see the pyproject.toml for the list of exclusions and reasons).
|
|
98
|
+
- `tox` is used to run all of the aforementioned tests in parallel for multiple Python versions to ensure correct behaviour.
|
|
98
99
|
- CI is used for automated testing.
|
|
99
100
|
|
|
100
101
|
The package also makes use of an optional config file that falls back on standard behaviour, because configs are often used in scientific software (set-and-forget).
|
|
@@ -25,7 +25,7 @@ Run the `adsorpy.run_simulation.run_simulation()` function with the molecule foo
|
|
|
25
25
|
User friendliness will be updated at a later stage, allowing the user to define simulation modes, surfaces, and
|
|
26
26
|
molecules more easily.
|
|
27
27
|
|
|
28
|
-
Documentation (generated with `
|
|
28
|
+
Documentation (generated with `sphinx`): https://joostfwmaas.github.io/AdsorPy/
|
|
29
29
|
|
|
30
30
|
## Future additions
|
|
31
31
|
|
|
@@ -34,11 +34,11 @@ In a future update, the code will be expanded with diffusion, desorption, and sp
|
|
|
34
34
|
## Design philosophy
|
|
35
35
|
|
|
36
36
|
Because AdsorPy has been made with scientific rigour in mind, the package is tested in multiple ways:
|
|
37
|
-
- Unit tests (`
|
|
38
|
-
- Property tests (`
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
37
|
+
- Unit tests (`pytest`) of the code ensure correct behaviour for expected input.
|
|
38
|
+
- Property tests (`hypothesis`) of the most critical code components ensure correct behaviour for unexpected input as well.
|
|
39
|
+
- `mypy` (in `--strict` mode) and `pyright` (`strict`) ensure that the package is correctly-typed, as if it were static. The `py.typed` file, a promise that the code is type-hinted properly, is added because the code passes this test.
|
|
40
|
+
- `ruff` is used as a linter with almost all rules enabled (see the pyproject.toml for the list of exclusions and reasons).
|
|
41
|
+
- `tox` is used to run all of the aforementioned tests in parallel for multiple Python versions to ensure correct behaviour.
|
|
42
42
|
- CI is used for automated testing.
|
|
43
43
|
|
|
44
44
|
The package also makes use of an optional config file that falls back on standard behaviour, because configs are often used in scientific software (set-and-forget).
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "adsorpy"
|
|
7
7
|
#dynamic = ["version"] # The Python guide says that this will use the Git tag to fill it in.
|
|
8
|
-
version = "1.
|
|
8
|
+
version = "1.2.0" # The Python guide says that this will use the Git tag to fill it in.
|
|
9
9
|
description = "Random sequential adsorption (RSA) simulation, 2D lattice-based."
|
|
10
10
|
authors = [{ name = "J.F.W. Maas", email = "j.f.w.maas@tue.nl" }]
|
|
11
11
|
readme = "README.md"
|
|
@@ -75,8 +75,9 @@ test = [
|
|
|
75
75
|
"codecov>=2.1.13",
|
|
76
76
|
]
|
|
77
77
|
lint = [
|
|
78
|
-
"mypy>=
|
|
78
|
+
"mypy>=2.0.0",
|
|
79
79
|
"ruff>=0.15.12",
|
|
80
|
+
"pyright>=1.1.409",
|
|
80
81
|
]
|
|
81
82
|
docs = [
|
|
82
83
|
"sphinx>=9.1.0",
|
|
@@ -92,26 +93,6 @@ Documentation = "https://joostfwmaas.github.io/AdsorPy"
|
|
|
92
93
|
Changelog = "https://github.com/JoostFWMaas/AdsorPy/blob/main/CHANGELOG.md"
|
|
93
94
|
|
|
94
95
|
|
|
95
|
-
#[project.optional-dependencies]
|
|
96
|
-
#testing = [
|
|
97
|
-
# "pytest",
|
|
98
|
-
# "pytest-cov",
|
|
99
|
-
# "hypothesis",
|
|
100
|
-
# "mypy",
|
|
101
|
-
# "ruff",
|
|
102
|
-
# "scipy==1.15.3; python_version <= '3.10'",
|
|
103
|
-
# "scipy>=1.16.3; python_version > '3.10'",
|
|
104
|
-
#]
|
|
105
|
-
#
|
|
106
|
-
#docs = [
|
|
107
|
-
# "sphinx",
|
|
108
|
-
# "furo",
|
|
109
|
-
# "sphinx_design",
|
|
110
|
-
# "sphinx-autodoc-typehints",
|
|
111
|
-
# "sphinx-pyproject",
|
|
112
|
-
#]
|
|
113
|
-
|
|
114
|
-
|
|
115
96
|
[tool.hatch.package_data]
|
|
116
97
|
"adsorpy" = ["py.typed"]
|
|
117
98
|
|
|
@@ -230,4 +211,30 @@ ignore = [
|
|
|
230
211
|
|
|
231
212
|
[tool.ruff.lint.per-file-ignores]
|
|
232
213
|
"__init__.py" = ["D104"] # Missing docstring in public package. Not needed, package is empty.
|
|
233
|
-
"test*.py" = ["S101", "TC"] # Assert should not be used in production code! But this is test code, so here it is expected.
|
|
214
|
+
"test*.py" = ["S101", "TC"] # Assert should not be used in production code! But this is test code, so here it is expected.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
[tool.pyright]
|
|
218
|
+
include = ["src", "tests"]
|
|
219
|
+
|
|
220
|
+
typeCheckingMode = "strict"
|
|
221
|
+
|
|
222
|
+
useLibraryCodeForTypes = true
|
|
223
|
+
|
|
224
|
+
# Avoid penalising third-party libraries.
|
|
225
|
+
reportMissingTypeStubs = "none"
|
|
226
|
+
|
|
227
|
+
# Suppress "partially unknown" noise from deps like numpy, shapely, matplotlib, etc..
|
|
228
|
+
reportUnknownMemberType = "none"
|
|
229
|
+
reportUnknownVariableType = "none"
|
|
230
|
+
reportUnknownParameterType = "none"
|
|
231
|
+
reportUnknownArgumentType = "none"
|
|
232
|
+
reportUnnecessaryCast = "none" # These are needed for mypy.
|
|
233
|
+
reportUnnecessaryIsInstance = "none" # These are needed for mypy.
|
|
234
|
+
|
|
235
|
+
# Keep useful strict checks.
|
|
236
|
+
reportImplicitOverride = "error"
|
|
237
|
+
reportPrivateUsage = "warning"
|
|
238
|
+
reportUnnecessaryTypeIgnoreComment = "warning"
|
|
239
|
+
reportUnnecessaryComparison = "warning" # These are usually included to prevent the user from breaking things.
|
|
240
|
+
|
|
@@ -8,7 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import json
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import TYPE_CHECKING, Literal, ParamSpec,
|
|
11
|
+
from typing import TYPE_CHECKING, Literal, ParamSpec, cast
|
|
12
12
|
|
|
13
13
|
import matplotlib.pyplot as plt
|
|
14
14
|
import numpy as np
|
|
@@ -17,7 +17,6 @@ import shapely.affinity as aff
|
|
|
17
17
|
from matplotlib.collections import PatchCollection
|
|
18
18
|
from matplotlib.patches import Circle
|
|
19
19
|
from matplotlib.widgets import Slider, TextBox
|
|
20
|
-
from numpy.typing import NDArray
|
|
21
20
|
from shapely import MultiPoint, MultiPolygon, Point, Polygon
|
|
22
21
|
from shapely.ops import unary_union
|
|
23
22
|
|
|
@@ -25,6 +24,12 @@ if TYPE_CHECKING:
|
|
|
25
24
|
from matplotlib import axes, figure
|
|
26
25
|
from matplotlib.axes import Axes
|
|
27
26
|
from matplotlib.figure import Figure
|
|
27
|
+
from numpy.typing import NDArray
|
|
28
|
+
|
|
29
|
+
from src.adsorpy.typing import BoolArray, FloatArray, InDict, RotMatrix
|
|
30
|
+
|
|
31
|
+
P = ParamSpec("P") # Helps with static type checkers.
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
plt.rcParams.update(
|
|
30
35
|
{
|
|
@@ -43,20 +48,6 @@ plt.rcParams.update(
|
|
|
43
48
|
},
|
|
44
49
|
)
|
|
45
50
|
|
|
46
|
-
P = ParamSpec("P") # Helps with static type checkers.
|
|
47
|
-
InDict: TypeAlias = dict[str, str | float | list[str] | Path | None]
|
|
48
|
-
InInDict: TypeAlias = dict[str, InDict]
|
|
49
|
-
|
|
50
|
-
# mypy: plugins = numpy.typing.mypy_plugin
|
|
51
|
-
# Definition of some frequently-used types. Not used by the compiler, just for the user and mypy. Hello user!
|
|
52
|
-
IdxArray = np.ndarray[tuple[int], np.dtype[np.int_]] # Flat index aray of integers.
|
|
53
|
-
BoolArray = np.ndarray[tuple[int], np.dtype[np.bool_]] # Flat Boolean array.
|
|
54
|
-
CoordPair = np.ndarray[tuple[Literal[2], Literal[1]], np.dtype[np.float64]] # 2x1 array of coordinates
|
|
55
|
-
CoordsArray = np.ndarray[tuple[Literal[2], int], np.dtype[np.float64]] # 2xN array of coords.
|
|
56
|
-
Bools2D = np.ndarray[tuple[int, int], np.dtype[np.bool_]]
|
|
57
|
-
GeoArray = np.ndarray[tuple[int], np.dtype[Polygon]]
|
|
58
|
-
FloatArray = NDArray[np.float64]
|
|
59
|
-
RotMatrix = np.ndarray[tuple[Literal[3], Literal[3]], np.dtype[np.float64]]
|
|
60
51
|
|
|
61
52
|
# Van der Waals radii of atoms. Source: https://doi.org/10.1039/C3DT50599E
|
|
62
53
|
current_dir_file = Path(__file__).parent / "VdW_Radii.csv"
|
|
@@ -71,9 +62,9 @@ RADII: dict[str, float] = dict(
|
|
|
71
62
|
|
|
72
63
|
|
|
73
64
|
def discorectangle(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
params: list[float],
|
|
66
|
+
offx: float = 0.0,
|
|
67
|
+
offy: float = 0.0,
|
|
77
68
|
) -> Polygon:
|
|
78
69
|
"""Create a discorectangle using the union of two circles and a rectangle.
|
|
79
70
|
|
|
@@ -102,14 +93,14 @@ def discorectangle(
|
|
|
102
93
|
],
|
|
103
94
|
)
|
|
104
95
|
|
|
105
|
-
return unary_union([rectangle, circles])
|
|
96
|
+
return cast("Polygon", unary_union([rectangle, circles]))
|
|
106
97
|
|
|
107
98
|
|
|
108
99
|
def circulium(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
radius: float,
|
|
101
|
+
x_offset: float = 0.0,
|
|
102
|
+
y_offset: float = 0.0,
|
|
103
|
+
quad_segs: int = 8,
|
|
113
104
|
) -> Polygon:
|
|
114
105
|
"""Create a simple circular polygon.
|
|
115
106
|
|
|
@@ -135,17 +126,17 @@ def dogbonium(scale: float = 1) -> Polygon:
|
|
|
135
126
|
positions[[1, 2], 0] *= -1.0
|
|
136
127
|
positions[[2, 3], 1] *= -1.0
|
|
137
128
|
positions[:, 1] *= 0.5
|
|
138
|
-
balls: MultiPolygon = MultiPoint(positions).buffer(0.5 * scale)
|
|
129
|
+
balls: MultiPolygon = cast("MultiPolygon", MultiPoint(positions).buffer(0.5 * scale))
|
|
139
130
|
rod: Polygon = Polygon(positions)
|
|
140
|
-
dogbone: Polygon = unary_union((rod, balls))
|
|
131
|
+
dogbone: Polygon = cast("Polygon", unary_union((rod, balls)))
|
|
141
132
|
|
|
142
133
|
return dogbone
|
|
143
134
|
|
|
144
135
|
|
|
145
136
|
def polygonium(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
verts: int = 3,
|
|
138
|
+
scale: float = 1.0,
|
|
139
|
+
roundedness: float = 0.0,
|
|
149
140
|
) -> Polygon:
|
|
150
141
|
"""Create a simple regular polygon with optional rounding.
|
|
151
142
|
|
|
@@ -169,20 +160,20 @@ def polygonium(
|
|
|
169
160
|
fact /= molecule.exterior.hausdorff_distance(center)
|
|
170
161
|
molecule = aff.scale(molecule, xfact=fact, yfact=fact, origin=center)
|
|
171
162
|
|
|
172
|
-
return shapely.make_valid(molecule)
|
|
163
|
+
return cast("Polygon", shapely.make_valid(molecule))
|
|
173
164
|
|
|
174
165
|
|
|
175
166
|
def xyz_reader(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
167
|
+
file_name: str | Path,
|
|
168
|
+
ignore_atoms: str | list[str] | None = None,
|
|
169
|
+
x_offset: float = 0.0,
|
|
170
|
+
y_offset: float = 0.0,
|
|
171
|
+
roll: float = 0.0,
|
|
172
|
+
pitch: float = 0.0,
|
|
173
|
+
yaw: float = 0.0,
|
|
174
|
+
z_trim: float | None = None,
|
|
175
|
+
# *args: P.args,
|
|
176
|
+
# **kwargs: P.kwargs,
|
|
186
177
|
) -> Polygon:
|
|
187
178
|
"""Read files in the xyz format of VASP.
|
|
188
179
|
|
|
@@ -225,27 +216,26 @@ def xyz_reader(
|
|
|
225
216
|
atom_vdw: Polygon = Point(coords).buffer(RADII[atm])
|
|
226
217
|
atom_list[idx] = atom_vdw
|
|
227
218
|
|
|
228
|
-
molecule = MultiPolygon(atom_list)
|
|
229
|
-
molecule = unary_union(molecule)
|
|
219
|
+
molecule: Polygon = cast("Polygon", unary_union(MultiPolygon(atom_list)))
|
|
230
220
|
centre = -np.mean(atompos, axis=0)
|
|
231
221
|
if x_offset is not None:
|
|
232
222
|
centre[0] -= x_offset
|
|
233
223
|
if y_offset is not None:
|
|
234
224
|
centre[1] -= y_offset
|
|
235
225
|
|
|
236
|
-
return aff.translate(molecule, *centre)
|
|
226
|
+
return cast("Polygon", aff.translate(molecule, *centre))
|
|
237
227
|
|
|
238
228
|
|
|
239
229
|
def first_time_loader( # noqa: PLR0915
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
230
|
+
file_name: str | Path,
|
|
231
|
+
ignore_atoms: str | list[str] | None = None,
|
|
232
|
+
x_offset: float | None = None,
|
|
233
|
+
y_offset: float | None = None,
|
|
234
|
+
roll: float | None = None,
|
|
235
|
+
pitch: float | None = None,
|
|
236
|
+
yaw: float | None = None,
|
|
237
|
+
z_trim: float | None = None,
|
|
238
|
+
reference_lattice_spacing: float = 4.74,
|
|
249
239
|
) -> InDict:
|
|
250
240
|
"""Script to run when you first load the molecule. Shows the molecule in xy, zy, and xz perspective, and vdwaals.
|
|
251
241
|
|
|
@@ -267,7 +257,15 @@ def first_time_loader( # noqa: PLR0915
|
|
|
267
257
|
with (Path(__file__).parent / "molecule_colour.json").open("r") as file:
|
|
268
258
|
colourdict: dict[str, str] = dict(json.load(file))
|
|
269
259
|
|
|
270
|
-
|
|
260
|
+
def _map_name_to_hexhtml(name: str) -> str:
|
|
261
|
+
"""Map the molecule shorthand name string to the hexagonal HTML colour string.
|
|
262
|
+
|
|
263
|
+
:param name: Name of the molecule, e.g., H, He, Li, Be.
|
|
264
|
+
:returns: #FFFFFF by default, otherwise the valid colour code.
|
|
265
|
+
"""
|
|
266
|
+
return colourdict.get(name, "#FFFFFF")
|
|
267
|
+
|
|
268
|
+
map_to_colour = np.vectorize(_map_name_to_hexhtml)
|
|
271
269
|
atomcolours: NDArray[np.str_] = map_to_colour(atomkeys)
|
|
272
270
|
|
|
273
271
|
roll = 0.0 if roll is None else roll
|
|
@@ -462,23 +460,23 @@ def first_time_loader( # noqa: PLR0915
|
|
|
462
460
|
|
|
463
461
|
|
|
464
462
|
def _update( # noqa: PLR0913
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
463
|
+
val: float,
|
|
464
|
+
ang_x: Slider,
|
|
465
|
+
ang_y: Slider,
|
|
466
|
+
ang_z: Slider,
|
|
467
|
+
translate_x: Slider,
|
|
468
|
+
translate_y: Slider,
|
|
469
|
+
box_x: TextBox,
|
|
470
|
+
box_y: TextBox,
|
|
471
|
+
box_z: TextBox,
|
|
472
|
+
box_xoff: TextBox,
|
|
473
|
+
box_yoff: TextBox,
|
|
474
|
+
atompos: FloatArray,
|
|
475
|
+
axs: list[axes.Axes],
|
|
476
|
+
fig: figure.Figure,
|
|
477
|
+
atomcolours: NDArray[np.str_],
|
|
478
|
+
atomkeys: NDArray[np.str_],
|
|
479
|
+
reference_lattice_spacing: float,
|
|
482
480
|
) -> None:
|
|
483
481
|
roll = ang_z.val
|
|
484
482
|
pitch = ang_y.val
|
|
@@ -603,9 +601,9 @@ def _update( # noqa: PLR0913
|
|
|
603
601
|
|
|
604
602
|
|
|
605
603
|
def _initialise_reader(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
604
|
+
file_name: str | Path,
|
|
605
|
+
ignore_atoms: str | list[str] | None = None,
|
|
606
|
+
z_trim: float | None = None,
|
|
609
607
|
) -> tuple[np.ndarray[tuple[int], np.dtype[np.str_]], np.ndarray[tuple[int, Literal[3]], np.dtype[np.float64]]]:
|
|
610
608
|
"""Initialise the xyz_reader and first_time_loader.
|
|
611
609
|
|