Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Feb 29, 2024
1 parent 51b0539 commit 22d1466
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
npm install
npm run build
pip install -e .
pip install "pytest<8"
- name: Test with pytest
Expand All @@ -74,6 +76,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
npm install
npm run build
python -m pip install -U jupyterlab==4.1.2 jupyter-packaging~=0.12
pip install -e .
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ viewer
<img src="docs/source/_static/images/example-phonon.gif" width="300px"/>


### Save image
Save image to a path by:
```python
viewer.save_image("/home/xing/filename.png")
```

### Download image
This will open a download panel.

```python
viewer.download_image("filename.png")
Expand Down
66 changes: 47 additions & 19 deletions docs/source/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -281,26 +281,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "36503e95",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b7d69dd0dc3a415b8a3be9d6f260b134",
"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,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from weas_widget import WeasWidget\n",
"from ase.io.cube import read_cube_data\n",
Expand Down Expand Up @@ -394,10 +378,54 @@
"viewer = WeasWidget()\n",
"viewer.from_ase(trajectory)\n",
"# set a vector field to show the arrow\n",
"viewer.vectorField = {\"origins\": \"positions\", \"vectors\": \"movement\", \"radius\": 0.1}\n",
"viewer.vectorField = [{\"origins\": \"positions\", \"vectors\": \"movement\", \"radius\": 0.1}]\n",
"viewer"
]
},
{
"cell_type": "markdown",
"id": "d8987afd",
"metadata": {},
"source": [
"### Save image\n",
"One can save the image to a path by:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d84eda36",
"metadata": {},
"outputs": [],
"source": [
"viewer.save_image(\"/home/xing/c2h6so.png\")"
]
},
{
"cell_type": "markdown",
"id": "99f6bf51",
"metadata": {},
"source": [
"If you want to save image in the save image in the save cell where you creating the viewer, you neeed use `display` to show the viewer."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9924257c",
"metadata": {},
"outputs": [],
"source": [
"from ase.build import molecule\n",
"from weas_widget import WeasWidget\n",
"atoms = molecule(\"C2H6SO\")\n",
"viewer = WeasWidget()\n",
"viewer.from_ase(atoms)\n",
"viewer.modelStyle = 1\n",
"display(viewer)\n",
"viewer.save_image(\"/home/xing/c2h6so.png\")"
]
},
{
"cell_type": "markdown",
"id": "ede9f9c6",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"scripts": {
"dev": "npm run build -- --sourcemap=inline --watch",
"build": "esbuild js/widget.js --minify --format=esm --bundle --outdir=src/weas_widget/static --watch"
"build": "esbuild js/widget.js --minify --format=esm --bundle --outdir=src/weas_widget/static",
"build-watch": "esbuild js/widget.js --minify --format=esm --bundle --outdir=src/weas_widget/static --watch=forever"
},
"dependencies": {
"dat.gui": "^0.7.9",
Expand Down

0 comments on commit 22d1466

Please sign in to comment.