Skip to content

Commit 4f4ef79

Browse files
authored
Adding CI testing, linter and uv build system (#5)
* setup uv, format and linting via ruff * add pytest * add gitignore * decrease required python version * unable to install package below python 3.9 * sort imports * update relevant imports * update imports in the examples * add compute_energy import * clear outputs (reduce file size)
1 parent 5e41acc commit 4f4ef79

21 files changed

+4156
-2150
lines changed

.github/workflows/test.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will install Python dependencies, run tests
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: tests
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
11+
jobs:
12+
pytest:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version:
18+
- "3.13"
19+
- "3.12"
20+
- "3.11"
21+
- "3.10"
22+
- "3.9"
23+
os:
24+
- ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Install uv and set the python version
29+
uses: astral-sh/setup-uv@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- name: Install the project
33+
run: uv sync --all-extras --dev
34+
- name: Pytest
35+
run: |
36+
uv run python --version
37+
uv run pytest

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

README.ipynb

Lines changed: 117 additions & 668 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ Molecules and reactive species are both initialized as the Fragment object (base
7070
Let us initialize a molecule of dimethyl ether (DME):
7171

7272
```python
73+
from autoadsorbate import Fragment
74+
7375
f = Fragment(smile = 'COC', to_initialize = 5)
7476
```
7577

7678

7779
```python
78-
from autoadsorbate.utils import docs_plot_conformers
80+
from autoadsorbate import docs_plot_conformers
81+
7982
conformer_trajectory = f.conformers
8083
fig = docs_plot_conformers(conformer_trajectory)
8184
```
@@ -100,7 +103,7 @@ This can be also done with a function:
100103

101104

102105
```python
103-
from autoadsorbate.Smile import get_marked_smiles
106+
from autoadsorbate import get_marked_smiles
104107
marked_smile = get_marked_smiles(['COC'])[0]
105108
marked_smile
106109
```
@@ -116,7 +119,8 @@ len(f.conformers)
116119

117120
We can visualize these structures:
118121
```python
119-
from autoadsorbate.utils import docs_plot_conformers
122+
from autoadsorbate import docs_plot_conformers
123+
120124
conformer_trajectory = f.conformers
121125
fig = docs_plot_conformers(conformer_trajectory)
122126
```
@@ -131,7 +135,7 @@ Now we can use the marker atom to orient our molecule:
131135

132136

133137
```python
134-
from autoadsorbate.utils import docs_plot_sites
138+
from autoadsorbate import docs_plot_sites
135139

136140
oriented_conformer_trajectory = [f.get_conformer(i) for i, _ in enumerate(f.conformers)]
137141
fig = docs_plot_conformers(oriented_conformer_trajectory)
@@ -370,7 +374,7 @@ site_atoms.info
370374
We can visualize a few surface sites:
371375

372376
```python
373-
from autoadsorbate.utils import docs_plot_sites
377+
from autoadsorbate import docs_plot_sites
374378
fig = docs_plot_sites(s)
375379
```
376380

@@ -480,7 +484,7 @@ plot_atoms(s.view_surface(return_atoms=True))
480484
Simple methods of brute force SMILES enumeration are implemented as well. For example, only using a few lines of code we can initialize multiple conformers of all reaction intermediaries in the nitrogen hydrogenation reaction. A template of the required information can be found here:
481485

482486
```python
483-
from autoadsorbate.string_utils import _example_config
487+
from autoadsorbate import _example_config
484488
_example_config
485489
```
486490

@@ -498,7 +502,7 @@ _example_config
498502
Now we can use (or edit) this information as we see fit:
499503

500504
```python
501-
from autoadsorbate.string_utils import construct_smiles
505+
from autoadsorbate import construct_smiles
502506

503507
config = {
504508
'backbone_info': {'C': 0, 'O': 0, 'N':2},
@@ -600,11 +604,11 @@ len(trj)
600604

601605
52
602606

603-
From the list of initilazied conformers we can remove the ones that are efectively identical:
607+
From the list of initialized conformers we can remove the ones that are effectively identical:
604608

605609

606610
```python
607-
from autoadsorbate.utils import get_drop_snapped
611+
from autoadsorbate import get_drop_snapped
608612

609613
xtrj = get_drop_snapped(trj, d_cut=1.5)
610614
len(xtrj)
@@ -652,7 +656,7 @@ A autonomous mode of Fragment placement on Surface is also implemented. The meth
652656

653657
```python
654658
from ase.build import fcc211
655-
from autoadsorbate.autoadsorbate import Surface, Fragment
659+
from autoadsorbate import Surface, Fragment
656660

657661
slab = fcc211(symbol = 'Cu', size=(6,3,3), vacuum=10) # any ase.Atoms object
658662
s=Surface(slab, touch_sphere_size=2.7) # finding all surface atoms

README.rst

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)