Skip to content

Commit

Permalink
Use uv instead of nox and pip-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Oct 10, 2024
1 parent 665ec0a commit 644869b
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 182 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Update pip and install nox
run: |
pip install --upgrade pip
pip install nox
- name: Run pip compile
run: nox --session=compile
- name: Install uv
run: pip install uv
- name: Sync
run: make sync
- name: Run tests
run: nox --session=${{ matrix.nox }} --python=${{ matrix.python }}
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pyrightconfig.json
*.eqx
*.parquet
*.npz
uv.lock
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: test lint

CUDA_AVAILABLE := $(shell command -v nvcc >/dev/null 2>&1 && echo 1 || echo 0)

test:
uv run pytest

lint:
uvx ruff check
uvx black src/emevo tests --check
uvx isort src/emevo tests --check


format:
uvx black src/emevo tests
uvx isort src/emevo tests


publish:
uv build
uvx twine upload dist/*


sync:
ifeq ($(CUDA_AVAILABLE),1)
uv sync --extra=analysis --extra=cuda12
else
uv sync --extra=analysis
endif


all: test lint
119 changes: 0 additions & 119 deletions noxfile.py

This file was deleted.

12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ analysis = [
"matplotlib >= 3.0",
"networkx >= 3.0",
"polars >= 0.20",
"PySide6 >= 6.5",
]
# Meta feature to install CUDA12 jax
cuda12 = ["jax[cuda12]"]
widget = ["PySide6 >= 6.5"]
video = ["imageio-ffmpeg >= 0.4"]

[project.readme]
Expand Down Expand Up @@ -76,4 +78,10 @@ ignore = ["B905"]
# For typer
"experiments/*.py" = ["B008", "UP006", "UP007"]
"smoke-tests/*.py" = ["B008", "UP006", "UP007"]
"scripts/*.py" = ["UP006", "UP035", "UP007"]
"scripts/*.py" = ["UP006", "UP035", "UP007"]


[tool.uv]
dev-dependencies = [
"pytest>=8.3.3",
]
3 changes: 0 additions & 3 deletions requirements/bench.in

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/cuda11.in

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/cuda12.in

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/format.in

This file was deleted.

12 changes: 0 additions & 12 deletions requirements/jupyter.in

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/lint.in

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/scripts.in

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/smoke.in

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/tests.in

This file was deleted.

16 changes: 0 additions & 16 deletions setup-jupterlab

This file was deleted.

4 changes: 2 additions & 2 deletions src/emevo/analysis/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def parent(self) -> Node | None:
@functools.cached_property
def n_total_children(self) -> int:
total = 0
for child, _ in self.children:
for child in self.children:
total += 1 + child.n_total_children
return total

Expand All @@ -87,7 +87,7 @@ def traverse(
) -> Iterable[Node]:
if include_self and preorder:
yield self
for child, _ in self.children:
for child in self.children:
yield from child.traverse(preorder)
if include_self and not preorder:
yield self
Expand Down
8 changes: 4 additions & 4 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def treedef() -> list[tuple[int, int]]:


def test_from_iter(treedef: list[tuple[int, int]]) -> None:
tree = Tree.from_iter(treedef)
tree = Tree.from_iter(treedef, root_idx=-1)
preorder = list(map(operator.attrgetter("index"), tree.traverse(preorder=True)))
assert preorder == [0, 1, 3, 4, 5, 8, 9, 2, 6, 7]
postorder = list(map(operator.attrgetter("index"), tree.traverse(preorder=False)))
Expand All @@ -33,7 +33,7 @@ def test_from_iter(treedef: list[tuple[int, int]]) -> None:
def test_split(treedef: list[tuple[int, int]]) -> None:
tree = Tree.from_iter(treedef)
sp1 = tree.split(min_group_size=3)
assert len(sp1) == 10
assert len(sp1) == 4
assert sp1[0] == 0
for idx in [1, 3, 4]:
assert sp1[idx] == 1
Expand All @@ -43,7 +43,7 @@ def test_split(treedef: list[tuple[int, int]]) -> None:
assert sp1[idx] == 3

sp2 = tree.split(min_group_size=4)
assert len(sp2) == 10
assert len(sp2) == 4
for idx in [0, 2, 6, 7]:
assert sp2[idx] == 0
for idx in [1, 3, 4, 5, 8, 9]:
Expand All @@ -63,7 +63,7 @@ def test_multilabel_split(treedef: list[tuple[int, int]]) -> None:
def test_from_table() -> None:
table = pq.read_table(ASSET_DIR.joinpath("profile_and_rewards.parquet"))
tree = Tree.from_table(table, 20)
for root, _ in tree.root.children:
for root in tree.root.children:
assert root.index < 10
assert root.birth_time is not None
for node in root.traverse():
Expand Down

0 comments on commit 644869b

Please sign in to comment.