diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 301cac8..c43d603 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,45 +24,44 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+
- name: Install dependencies
run: |
- python -m pip install --upgrade pip setuptools wheel
- python -m pip install flit
- flit install
+ uv sync --all-extras --group test --group data
- name: Test with pytest
- run: pytest -v
+ run: uv run pytest -v
- name: Docstring doctest
- run: pytest --doctest-modules stringcalc -v
+ run: uv run pytest --doctest-modules stringcalc -v
- name: Test code blocks
- run: pytest --codeblocks README.md docs -v
+ run: uv run pytest --codeblocks README.md docs -v
- name: Check type annotations
run: |
- mypy --non-interactive .
+ uv run mypy --non-interactive .
- name: Check data prep scripts still work
run: |
# Copy to temp location
- mkdir -p ../tmp/stringcalc
- cp -vr data ../tmp/stringcalc/
- cp -vr stringcalc ../tmp/stringcalc/
+ mkdir -p stringcalc/data/_orig
+ cp stringcalc/data/*.csv stringcalc/data/_orig/
# Run scripts
- cd ../tmp/stringcalc/data
- for f in *.py; do
- if [ $f == "daddario_extract.py" ]; then continue; fi
- python $f
+ for f in data/*.py; do
+ if [ $(basename $f) == "daddario_extract.py" ]; then continue; fi
+ uv run python $f
done
# Compare results to those in the repo
- cd ../stringcalc/data
+ cd stringcalc/data
rc=0
for f in *.csv; do
echo $f
- cmp $f $GITHUB_WORKSPACE/stringcalc/data/$f || rc=$?
+ cmp _orig/$f $f || rc=$?
done
exit $rc
@@ -78,26 +77,45 @@ jobs:
steps:
- uses: actions/checkout@v6
- - name: Install dependencies (micromamba)
- uses: mamba-org/setup-micromamba@v2
+ - name: Set up Python
+ uses: actions/setup-python@v6
with:
- environment-file: panel/environment.yml
- cache-environment: true
- cache-downloads: true
+ python-version: "3.13"
+
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+
+ - name: Install dependencies
+ run: |
+ uv sync --group panel
- name: Install stringcalc (${{ matrix.stringcalc }})
run: |
if [ "${{ matrix.stringcalc }}" == "local" ]; then
- pip install . --no-deps
+ :
elif [ "${{ matrix.stringcalc }}" == "pypi" ]; then
- pip install stringcalc
+ uv pip install stringcalc
else
exit 1
fi
- name: Run the app script
- run: python panel/app.py
+ run: uv run python panel/app.py
+
+ - name: Check type annotations in app script
+ run: |
+ uv pip install mypy
+ uv run mypy --non-interactive panel/app.py
- - name: Run mypy
+ - name: Build app (pyodide)
run: |
- mypy --non-interactive panel/app.py
+ uv run panel convert panel/app.py --to pyodide
+ mv ./app.html ./stringcalc-panel.html
+
+ - name: Upload built app
+ if: matrix.stringcalc == 'pypi'
+ uses: actions/upload-artifact@v6
+ with:
+ name: panel
+ path: stringcalc-panel.html
+ retention-days: 1
diff --git a/.gitignore b/.gitignore
index e082d48..550f1cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@ data/*.png
docs/api/
panel/app.html
+uv.lock
+
# Byte-compiled / optimized / DLL files
__pycache__/
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
index ce5d21e..02f21ad 100644
--- a/.readthedocs.yaml
+++ b/.readthedocs.yaml
@@ -4,14 +4,22 @@ build:
os: ubuntu-lts-latest
tools:
python: "3.13"
-
-python:
- install:
- - method: pip
- path: .
- extra_requirements:
- - doc
- - cli
+ jobs:
+ pre_create_environment:
+ - asdf plugin add uv
+ - asdf install uv latest
+ - asdf global uv latest
+ create_environment:
+ - uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
+ install:
+ - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}"
+ uv sync
+ --group doc
+ --group panel
+ --extra cli
+ pre_build:
+ - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}"
+ uv run panel convert panel/app.py --to pyodide --out docs/_static/panel/
sphinx:
configuration: docs/conf.py
diff --git a/README.md b/README.md
index fee1fd8..4094cd9 100644
--- a/README.md
+++ b/README.md
@@ -12,3 +12,29 @@ stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LE
```
+
+## Development
+
+Using [uv](https://docs.astral.sh/uv/), prepare the venv:
+
+```
+uv sync --all-groups --all-extras
+```
+
+Run the tests:
+
+```
+uv run pytest
+```
+
+Build the Panel app:
+
+```
+uv run panel convert panel/app.py --to pyodide --out docs/_static/panel/
+```
+
+Build the docs:
+
+```
+uv run sphinx-build docs docs/_build/html
+```
diff --git a/data/aquila.py b/data/aquila.py
index 40f840a..865596c 100644
--- a/data/aquila.py
+++ b/data/aquila.py
@@ -10,15 +10,11 @@
sys.path.append("../")
-# import matplotlib as mpl
-import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from stringcalc.tension import load_data
-plt.close("all")
-
HERE = Path(__file__).parent
@@ -60,10 +56,10 @@
#
# What do the data suggest that we are comparing to?
-(1300 / df[["gauge_nylon_web", "gauge_nylon_pdf"]].pow(2).div(df.gauge.pow(2), axis="rows")).plot(
- ylabel="estimated nylon density",
- marker=".",
-)
+# (1300 / df[["gauge_nylon_web", "gauge_nylon_pdf"]].pow(2).div(df.gauge.pow(2), axis="rows")).plot(
+# ylabel="estimated nylon density",
+# marker=".",
+# )
# Estimate density of D'Addario NYL strings
df2 = load_data().query("group_id == 'DA:NYL'").copy()
@@ -73,7 +69,7 @@
assert df2.rho.std() / df2.rho.mean() < 0.001
rho_bar = df2.rho.mean()
-df2.plot(x="gauge", y="rho", ylabel="Computed D'Addario NYL density")
+# df2.plot(x="gauge", y="rho", ylabel="Computed D'Addario NYL density")
# rho ~ 1/gauge^2 => rho gauge^2 = c
df["gauge_da_nylon"] = np.sqrt(1300 * df.gauge**2 / rho_bar)
diff --git a/data/worth.py b/data/worth.py
index 612a448..fe5de55 100644
--- a/data/worth.py
+++ b/data/worth.py
@@ -8,15 +8,11 @@
sys.path.append("../")
-# import matplotlib as mpl
-import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
# from stringcalc.tension import load_data
-plt.close("all")
-
HERE = Path(__file__).parent
diff --git a/docs/_static/panel/.gitignore b/docs/_static/panel/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/docs/_static/panel/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/docs/conf.py b/docs/conf.py
index 0545171..0d56f19 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -54,6 +54,8 @@
""",
}
+html_static_path = ["_static"]
+
napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_preprocess_types = True
diff --git a/docs/panel.rst b/docs/panel.rst
index d1a4335..945c521 100644
--- a/docs/panel.rst
+++ b/docs/panel.rst
@@ -9,7 +9,7 @@ Panel app
.. raw:: html