Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests #12

Merged
merged 47 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dcbdb58
Setup test framework and started adding tests
dylanbmorgan Oct 22, 2024
1ca55bf
Added ability to test with user's aims bin
dylanbmorgan Oct 24, 2024
4826ed9
Added custom aims bin output dir
dylanbmorgan Oct 24, 2024
3cd790f
Added ability to run tests with custom aims bin
dylanbmorgan Oct 24, 2024
08ef00d
Added aims_bin_loc file
dylanbmorgan Oct 24, 2024
760e04d
Removed aims_bin_loc
dylanbmorgan Oct 24, 2024
952a561
Updated dependencies and actions
dylanbmorgan Oct 25, 2024
e8ddfab
Added new functionality
lukashoermann200 Oct 28, 2024
478b581
Renamed function Added overlap for bootstrapping in get_cross_spectru…
lukashoermann200 Oct 28, 2024
d6f3eb1
Fixed minor bug in geometry.get_primitive_slab
lukashoermann200 Oct 28, 2024
c631b96
Added tutorials
lukashoermann200 Oct 28, 2024
279fcc0
Updated tutorials
lukashoermann200 Oct 28, 2024
68bef09
Refactoring of get_cross_spectrum_mem
lukashoermann200 Oct 28, 2024
d222735
Added functionality to use get_cross_spectrum_mem
lukashoermann200 Oct 28, 2024
9304df8
Update to tutorials
lukashoermann200 Oct 28, 2024
71fe4dd
Some refactoring of docstrings
lukashoermann200 Oct 28, 2024
433f34f
Reorganised parsers
dylanbmorgan Oct 28, 2024
a363895
Changes to accommodate tests
dylanbmorgan Oct 28, 2024
222ed47
Added function get_geometry_steps_of_optimisation
lukashoermann200 Oct 29, 2024
af249e1
Added new get_geometry_steps_of_optimisation
lukashoermann200 Oct 29, 2024
90c122f
fixed docs
lukashoermann200 Oct 29, 2024
7cbe7e6
fixed docs better
lukashoermann200 Oct 29, 2024
68d096a
Changed docstring in add_multipoles
lukashoermann200 Oct 29, 2024
4b2783e
Added more tests for printing KS eigenvalues
dylanbmorgan Oct 29, 2024
713ec04
Added pytest CI
dylanbmorgan Oct 29, 2024
05094de
Refactored get_symmetries
lukashoermann200 Oct 30, 2024
78f375f
fixed minor bug in get_geometry_steps_of_optimisation
lukashoermann200 Oct 30, 2024
c6eb960
Added more content to tutorials
lukashoermann200 Oct 30, 2024
36af4b6
Removed unnecessary imports from geometry
lukashoermann200 Oct 30, 2024
960134d
Renamed function get_conv_params to get_convergence_parameters
lukashoermann200 Oct 30, 2024
42c3a90
Setup test framework and started adding tests
dylanbmorgan Oct 22, 2024
031302c
Added ability to test with user's aims bin
dylanbmorgan Oct 24, 2024
803914e
Resolved gitignore conflicts
dylanbmorgan Oct 24, 2024
072207e
Rebased to master
dylanbmorgan Oct 24, 2024
440337a
Fixed gitignore conflict
dylanbmorgan Oct 24, 2024
23c6324
Removed aims_bin_loc
dylanbmorgan Oct 24, 2024
0a54c13
Fixed dependencies conflicts
dylanbmorgan Oct 25, 2024
bc2fac2
Reorganised parsers
dylanbmorgan Oct 30, 2024
13da859
Changes to accommodate tests
dylanbmorgan Oct 30, 2024
cfc3013
Added more tests for printing KS eigenvalues
dylanbmorgan Oct 29, 2024
2795fb0
Added pytest CI
dylanbmorgan Oct 30, 2024
09c03ba
Resolved rebase conflicts
dylanbmorgan Oct 30, 2024
9d499dc
Resolved conflicts
dylanbmorgan Oct 30, 2024
2f90dec
Fixed ruff lint error
dylanbmorgan Oct 30, 2024
4c06524
Enabled all tests to work locally
dylanbmorgan Oct 31, 2024
50081bb
Reformatted and added templates for workflows
dylanbmorgan Oct 31, 2024
116b0de
Changed pytest to run under poetry
dylanbmorgan Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/interrogate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
65 changes: 65 additions & 0 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build release distributions
run: |
# NOTE: put your own distribution build steps here.
poetry build

- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

pypi-publish:
runs-on: ubuntu-latest

needs:
- release-build

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

# Dedicated environments with protections for publishing are strongly recommended.
environment:
name: pypi
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
# url: https://pypi.org/p/YOURPROJECT

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@6f7e8d9c0b1a2c3d4e5f6a7b8c9d0e1f2a3b4c5d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run the pyright checker
name: pyright

on:
push:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: pytest

on:
push:
branches:
- master
pull_request:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Only run after linting has finished
# workflow_run:
# workflows: ['ruff']
# types: [completed]

jobs:
test:
runs-on: ubuntu-latest
# TODO run on all supported versions of the project
# strategy:
# matrix:
# python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: abatilo/actions-poetry@v2
- name: Install the project dependencies
run: poetry install --with=dev
- name: Run the tests
run: poetry run -- pytest tests --cov=dfttools --cov-report xml

# TODO when approved for the maurergroup organisation
# - name: Coveralls GitHub Action
# uses: coverallsapp/[email protected]
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel: true # Enable parallel support for Coveralls if needed
4 changes: 3 additions & 1 deletion .github/workflows/ruff.yml → .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run the ruff linter and formatter
name: ruff

on:
push:
Expand All @@ -12,6 +12,7 @@ on:
jobs:
ruff-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
Expand All @@ -22,6 +23,7 @@ jobs:
ruff-format:
runs-on: ubuntu-latest
needs: ruff-lint

steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and deploy Sphinx docs
name: Sphinx

on:
# Runs on pushes targeting the default branch
Expand Down Expand Up @@ -32,16 +32,13 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- uses: abatilo/actions-poetry@v2
- name: Install the project dependencies
run: poetry install --only=docs
run: poetry install --with=docs
- name: Build HTML
run: cd docs && poetry run -- make html
- name: Upload artifacts
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,10 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Tests
tests/.aims_bin_loc
tests/fixtures/custom_bin_aims_calcs

# Tutorials
tutorials/temp/
23 changes: 23 additions & 0 deletions dfttools/base_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os.path
from typing import List


class BaseParser:
Expand Down Expand Up @@ -39,3 +40,25 @@ def __init__(self, supported_files, **kwargs):
else:
with open(kwargs[kwarg], "r") as f:
self.file_contents[kwarg] = f.readlines()

def __str__(self) -> str:
if self.lines is None or self.lines == "":
raise ValueError("Could not find file contents.")
else:
return "".join(self.lines)

@property
def lines(self) -> List[str]:
return self._lines

@lines.setter
def lines(self, value: List[str]):
self._lines = value

@property
def path(self) -> str:
return self._path

@path.setter
def path(self, value: str):
self._path = value
Loading
Loading