Skip to content

Commit

Permalink
add tests and github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Feb 23, 2024
1 parent 04d2839 commit d52e2c7
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 31 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Test

on: [push, pull_request]

jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install -r ./docs/requirements.txt
- name: Build docs
run: |
cd docs/source
python -m sphinx -T -E -b html -d ../build/doctrees -D language=en . ../build/html
python:
name: Python
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install "pytest<8"
- name: Test with pytest
run: |
cd tests
pytest
ui-test:
name: Visual Regression
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U jupyterlab==4.0.0 jupyter-packaging~=0.10
pip install -e .
- name: Install Test Dependencies
run: |
jlpm --immutable
npx playwright install chromium
working-directory: ui-tests

- name: Execute integration tests
shell: bash -l {0}
working-directory: ui-tests
run: |
npx playwright test
- name: Upload Playwright Test assets
if: always()
uses: actions/upload-artifact@v3
with:
name: test-assets
path: |
ui-tests/test-results
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report
path: |
ui-tests/playwright-report
- name: Update snapshots
if: failure()
working-directory: ui-tests
run: |
jlpm test:update
- name: Upload updated snapshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: updated-snapshots
path: ui-tests/tests
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,37 @@ dmypy.json
# Pyre type checker
.pyre/

# javascript
docs/man/*.gz
docs/source/api/generated
docs/source/.cache
*.doit.db
_contents
node_modules
*.py[co]
__pycache__
*.egg-info
*~
*.bak
.ipynb_checkpoints
.tox
.DS_Store
\#*#
.#*
.coverage
.xunit.xml
.tern-project
npm-debug.log
.pytest_cache
.vscode/*
!.vscode/extensions.json

#
*.pdf
tests/work
/tests/**/*.png
*.xyz
test.ipynb

tests/notebooks/test-results
tests/notebooks/playwright-report
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A widget to visualize and interact with atomistic structures in Jupyter Notebook
measurement
isosurface
vector_field
selection


Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion docs/source/isosurface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ For the ``isoSetting``:
- mode=other: Only the given isosurface is drawn.


.. tips::
.. tip::

Support for multiple isosurfaces with individual properties (isovalue and color).
59 changes: 34 additions & 25 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"id": "e37d2ab4",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "eef4e918f93c44799cb17074cf84a5a2",
"model_id": "d31269ccc1ae420d9df9e9e437141111",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WeasWidget(atomScales=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], atoms={'species': {'S': ['S', 16], 'O': ['O', 8], 'C': […"
]
},
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -76,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "40d7764b",
"metadata": {},
"outputs": [
Expand All @@ -86,7 +86,7 @@
"Atoms(symbols='SOC2H6', pbc=False)"
]
},
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -129,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "add547b0",
"metadata": {},
"outputs": [],
Expand All @@ -149,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "c2dddf63",
"metadata": {},
"outputs": [],
Expand All @@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"id": "d53f98f5-5683-438e-9393-04900505f0f8",
"metadata": {
"tags": []
Expand All @@ -191,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 6,
"id": "c4dcca10-f4b5-4495-8767-24f844e9e760",
"metadata": {
"tags": []
Expand All @@ -203,7 +203,7 @@
"[]"
]
},
"execution_count": 9,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -222,7 +222,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 7,
"id": "05651abf-6e18-43a6-a653-709f8c72bb27",
"metadata": {},
"outputs": [],
Expand All @@ -241,22 +241,22 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 8,
"id": "d362b850-867b-4784-83f1-a92eb1372df0",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8d084ebe9d104ec8bab0f5f889ec1ada",
"model_id": "d3547ce9f65741319b4d584c3c85fcd9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WeasWidget(atomScales=[1, 1, 1, 1, 1, 1], atoms={'species': {'Ti': ['Ti', 22], 'O': ['O', 8]}, 'cell': [4.6532…"
]
},
"execution_count": 11,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -287,22 +287,22 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 9,
"id": "532678cc-afb6-4262-bcb7-2cf3bde67e87",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bd97be30828849d9a1e746c1146a0974",
"model_id": "0bcfba23318e40fc88ea0f97f77353ae",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WeasWidget(atomScales=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], atoms=[{'species': {'S': ['S', 16], 'O': ['O', 8], 'C': …"
]
},
"execution_count": 12,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -333,22 +333,22 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 10,
"id": "e5380bfa-2d6f-4961-8a15-9eb7bd64c54e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e7658976e9d4f80aa1dc610473b15b3",
"model_id": "cc79055786c84dbdacbd346ca6460e17",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WeasWidget(atomScales=[1, 1, 1], atoms={'species': {'O': ['O', 8], 'H': ['H', 1]}, 'cell': [10.222218836840568…"
]
},
"execution_count": 1,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -375,22 +375,22 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"id": "aa2ade62-65e6-49cc-8721-124f57b1e9ce",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "98ddae9e23ac4a04a309ba8238e969e8",
"model_id": "5990e1ae9d464efeacf998e1f0ed940a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"WeasWidget(atomScales=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], atoms={'species': {'…"
]
},
"execution_count": 2,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -408,12 +408,21 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 14,
"id": "fdb10de0-e02b-4488-a710-d81303a490d7",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Atoms(symbols='Au16C2H4', pbc=False, cell=[[5.769991334482228, 0.0, 0.0], [2.884995667241114, 4.996959075277683, 0.0], [0.0, 0.0, 17.066767294881018]])\n"
]
}
],
"source": [
"au111_co = viewer.to_ase()\n",
"print(au111_co)\n",
"au111_co.write(\"au111_co.xyz\")"
]
},
Expand Down
Loading

0 comments on commit d52e2c7

Please sign in to comment.