Skip to content

Commit

Permalink
Merge pull request #29 from spglib/python/len
Browse files Browse the repository at this point in the history
Use uv in CI
  • Loading branch information
lan496 authored Dec 9, 2024
2 parents c0a6e4a + f5e9878 commit c86ec61
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
51 changes: 30 additions & 21 deletions .github/workflows/ci-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -43,8 +45,8 @@ jobs:
shell: bash
run: |
set -e
pip install moyopy --no-index --find-links dist
pip install moyopy[interface]
uv pip install --system --no-index --find-links dist moyopy
uv pip install --system moyopy[interface]
python moyopy/examples/basic.py
python moyopy/examples/pymatgen_structure.py
Expand All @@ -56,6 +58,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -76,24 +80,25 @@ jobs:
shell: bash
run: |
set -e
pip install moyopy --no-index --find-links dist
pip install moyopy[testing]
uv pip install --system --no-index --find-links dist moyopy
uv pip install --system moyopy[testing]
pytest -v
- name: pytest
if: ${{ !startsWith(matrix.target, 'x86_64') }}
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt-get update -q -y
apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu build-essential python3 python3-dev python3-pip
run: |
set -e
pip3 install moyopy --no-index --find-links dist
pip3 install moyopy[testing]
pytest -v
# TODO: too long to build...
# - name: pytest
# if: ${{ !startsWith(matrix.target, 'x86_64') }}
# uses: uraimo/run-on-arch-action@v2
# with:
# arch: ${{ matrix.target }}
# distro: ubuntu22.04
# githubToken: ${{ github.token }}
# install: |
# apt-get update -q -y
# apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu build-essential python3 python3-dev python3-pip
# run: |
# set -e
# pip install --no-index --find-links dist moyopy
# pip install moyopy[testing]
# pytest -v

windows:
runs-on: windows-latest
Expand All @@ -103,6 +108,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -122,7 +129,7 @@ jobs:
shell: bash
run: |
set -e
pip install -e moyopy[dev] --find-links dist --force-reinstall
uv pip install --system --find-links dist --force-reinstall -e moyopy[dev]
cd moyopy && pytest -v
macos:
Expand All @@ -133,6 +140,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -152,7 +161,7 @@ jobs:
shell: bash
run: |
set -e
pip install -e moyopy[dev] --find-links dist --force-reinstall
uv pip install --system --find-links dist --force-reinstall -e moyopy[dev]
cd moyopy && pytest -v
sdist:
Expand Down
4 changes: 3 additions & 1 deletion moyopy/python/tests/test_symmetry_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def _is_close(site1, site2):

def test_operations_from_number():
operations = operations_from_number(number=230) # Ia-3d
assert operations.num_operations == 48 * 2
num_operations = 48 * 2
assert operations.num_operations == num_operations
assert len(operations) == num_operations

assert len(_unique_sites_in_cell([1 / 8, 1 / 8, 1 / 8], operations)) == 16
4 changes: 4 additions & 0 deletions moyopy/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ impl PyOperations {
pub fn num_operations(&self) -> usize {
self.0.num_operations()
}

fn __len__(&self) -> usize {
self.0.num_operations()
}
}

impl From<PyOperations> for Operations {
Expand Down

0 comments on commit c86ec61

Please sign in to comment.