Skip to content

Commit

Permalink
Merge pull request #81 from ab5424/restructure-testing
Browse files Browse the repository at this point in the history
Restructure testing
  • Loading branch information
ab5424 authored Aug 14, 2024
2 parents 50de194 + 99b9902 commit 25e9374
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
File renamed without changes.
18 changes: 12 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,36 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.11"]
version:
- { python: "3.9", resolution: lowest-direct, extra: "tests,ovito,ase,pymatgen" }
- { python: "3.11", resolution: highest, extra: "tests,ovito,ase,pymatgen" }
# Add macOS without optional dependencies, running only on python 3.10
include:
- os: macos-latest
version: { python: "3.10", resolution: highest, extra: "tests,strict" }

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.version.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.version.python }}
cache: pip
- name: Install dependencies
run: |
pip install uv
uv pip install packaging -e .[strict,dev,ovito,ase,pymatgen] --system
uv pip install -e .[${{ matrix.version.extra }}] --resolution=${{ matrix.version.resolution }} --system
# Fix ImportError: libEGL.so.1: ...
- if: runner.os == 'Linux'
- name: Install libegl1-mesa-dev on Linux
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install -y libegl1-mesa-dev
- name: pytest
run: |
pytest --cov=agility --cov-report=xml tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion agility/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

import numpy as np
import pandas as pd
from typing_extensions import Self

from agility.minimiser import minimise_lmp

if TYPE_CHECKING:
from collections.abc import Sequence

from typing_extensions import Self

available_backends = Literal["ovito", "pymatgen", "babel", "pyiron", "ase", "lammps"]
# https://github.com/pyiron/pylammpsmpi

Expand Down
18 changes: 7 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.0.3"
description = "Analysis tool for simulations of grain boundaries and interfaces"
authors = [{name = "Alexander Bonkowski", email = "[email protected]"}]
maintainers = [{name = "Alexander Bonkowski"}]
dependencies = ["numpy", "pandas", "scipy", "seaborn"]
dependencies = ["numpy>=1.25", "pandas>=2", "scipy>=1.12", "seaborn>=0.13"]
requires-python = ">=3.9"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down Expand Up @@ -39,23 +39,19 @@ strict = [
"scipy==1.13.1",
"seaborn==0.13.2",
]
dev = [
"mypy",
"coverage",
"pre-commit",
"pytest-cov",
"pytest-split",
"pytest",
"ruff",
tests = [
"pytest-cov>=5",
"pytest-split>=0.9",
"pytest>=8",
]
ovito = [
"ovito",
"ovito>=3.8",
]
ase = [
"ase>=3.23",
]
pymatgen = [
"pymatgen",
"pymatgen>=2024",
]

[tool.setuptools.packages.find]
Expand Down
3 changes: 3 additions & 0 deletions tests/analysis/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

from importlib.util import find_spec
from pathlib import Path
from unittest import TestCase

Expand All @@ -15,6 +16,7 @@
TEST_FILES_DIR = Path(MODULE_DIR / ".." / ".." / "tests" / "files")


@pytest.mark.skipif(not find_spec("ovito"), reason="ovito not installed")
class TestGBStructure(TestCase):
"""Test the GBStructure class."""

Expand Down Expand Up @@ -62,6 +64,7 @@ def test_grain_segmentation(self) -> None:
assert self.data.pipeline.compute().attributes["GrainSegmentation.grain_count"] == 6


@pytest.mark.skipif(not find_spec("ovito"), reason="ovito not installed")
class TestGBStructureOxide(TestCase):
"""Test the GBStructure class for an oxide."""

Expand Down
6 changes: 5 additions & 1 deletion tests/plotting/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from __future__ import annotations

from importlib.util import find_spec
from pathlib import Path
from unittest import TestCase

from PySide6.QtGui import QImage
import pytest

from agility.analysis import GBStructure
from agility.plotting import render_ovito
Expand All @@ -14,6 +15,7 @@
TEST_FILES_DIR = Path(MODULE_DIR / ".." / ".." / "tests" / "files")


@pytest.mark.skipif(not find_spec("ovito"), reason="ovito not installed")
class TestPlotting(TestCase):
"""Test the Plotting class."""

Expand All @@ -26,6 +28,8 @@ def setUp(self) -> None:
def test_render_ovito(self) -> None:
"""Test the render_ovito method."""
image = render_ovito(self.data.pipeline)
from PySide6.QtGui import QImage

assert isinstance(image, QImage)
assert image.width() == 282
assert image.height() == 262

0 comments on commit 25e9374

Please sign in to comment.