Skip to content

Commit

Permalink
Merge pull request #60 from WMD-group/gh-actions-tests
Browse files Browse the repository at this point in the history
fix tests and move to GitHub Actions
  • Loading branch information
AntObi authored Sep 20, 2022
2 parents 2802687 + ec0c387 commit 991205f
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 133 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: SMACT Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
- name: Run tests
run: python -m pytest -v
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ is also helpful, including a good model for docstrings.
- Add tests wherever possible, and use the test suite to check if you broke anything.

### Tests
Testing modules should be pass/fail and wrapped into **tests/test.py**.
Run the tests using `python -m smact.tests.test -v`.
Testing modules should be pass/fail and wrapped into **tests/test_core.py** or another **tests/test_something.py** file added, if appropriate.
Run the tests using `python -m pytest -v`.
(The final `-v` is optional and adds more detail to the output.)

We also use integrated testing on Github via [travis](https://travis-ci.org).
We also use integrated testing on Github via [GitHub Actions](hhttps://github.com/features/actions).

### List of Developers
Contributors to SMACT:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ase
pymatgen >=2022.0.0
pandas >= 0.24
pathos
pytest
pytest-subtests
15 changes: 0 additions & 15 deletions smact/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
import unittest

import smact.tests.test
from smact.tests.test_structure import CationMutatorTest, StructureDBTest, StructureTest, PredictorTest

if __name__ == "__main__":
loader = unittest.TestLoader()
suite = unittest.TestSuite()
suite.addTests(loader.loadTestsFromModule(smact.tests.test))
suite.addTests(loader.loadTestsFromTestCase(StructureTest))
suite.addTests(loader.loadTestsFromTestCase(StructureDBTest))
suite.addTests(loader.loadTestsFromTestCase(CationMutatorTest))
suite.addTests(loader.loadTestsFromTestCase(PredictorTest))
runner = unittest.TextTestRunner()
result = runner.run(suite)
1 change: 1 addition & 0 deletions smact/tests/files/CaTiO3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[5.40776, 0.0, 3.311297987278545e-16], [8.856621316385947e-16, 5.507429, 3.3723276481906544e-16], [0.0, 0.0, 7.694012]], "pbc": [true, true, true], "a": 5.40776, "b": 5.507429, "c": 7.694012, "alpha": 90.0, "beta": 90.0, "gamma": 90.0, "volume": 229.14963798636475}, "sites": [{"species": [{"element": "Ca", "oxidation_state": 2, "occu": 1}], "abc": [0.509094, 0.542875, 0.75], "xyz": [2.7530581694400005, 2.989845518375, 5.7705090000000006], "label": "Ca2+", "properties": {}}, {"species": [{"element": "Ca", "oxidation_state": 2, "occu": 1}], "abc": [0.49090599999999995, 0.457125, 0.25], "xyz": [2.65470183056, 2.517583481625, 1.9235030000000002], "label": "Ca2+", "properties": {}}, {"species": [{"element": "Ca", "oxidation_state": 2, "occu": 1}], "abc": [0.990906, 0.042874999999999996, 0.75], "xyz": [5.3585818305599995, 0.23613101837499997, 5.7705090000000006], "label": "Ca2+", "properties": {}}, {"species": [{"element": "Ca", "oxidation_state": 2, "occu": 1}], "abc": [0.009094000000000158, 0.957125, 0.25], "xyz": [0.049178169440001696, 5.2712979816250005, 1.9235030000000002], "label": "Ca2+", "properties": {}}, {"species": [{"element": "Ti", "oxidation_state": 4, "occu": 1}], "abc": [0.0, 0.5, 0.5], "xyz": [4.4283106581929737e-16, 2.7537145, 3.847006], "label": "Ti4+", "properties": {}}, {"species": [{"element": "Ti", "oxidation_state": 4, "occu": 1}], "abc": [0.0, 0.5, 0.0], "xyz": [4.4283106581929737e-16, 2.7537145, 1.6861638240953272e-16], "label": "Ti4+", "properties": {}}, {"species": [{"element": "Ti", "oxidation_state": 4, "occu": 1}], "abc": [0.5, 0.0, 0.5], "xyz": [2.70388, 0.0, 3.847006], "label": "Ti4+", "properties": {}}, {"species": [{"element": "Ti", "oxidation_state": 4, "occu": 1}], "abc": [0.5, 0.0, 0.0], "xyz": [2.70388, 0.0, 1.6556489936392726e-16], "label": "Ti4+", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.078086, 0.480194, 0.75], "xyz": [0.4222703473600004, 2.644634361226, 5.770509], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.921914, 0.519806, 0.25], "xyz": [4.985489652640001, 2.862794638774, 1.9235030000000004], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.421914, 0.980194, 0.75], "xyz": [2.2816096526400007, 5.398348861226, 5.7705090000000006], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.578086, 0.01980599999999999, 0.25], "xyz": [3.12615034736, 0.10908013877399995, 1.9235030000000002], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.790623, 0.790038, 0.9589710000000002], "xyz": [4.27549943448, 4.351078192302, 7.378334381652002], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.20937700000000004, 0.20996199999999998, 0.45897100000000024], "xyz": [1.1322605655200004, 1.156350807698, 3.531328381652002], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.20937700000000004, 0.20996199999999998, 0.04102899999999976], "xyz": [1.1322605655200004, 1.156350807698, 0.3156776183479983], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.790623, 0.790038, 0.5410289999999998], "xyz": [4.27549943448, 4.351078192302, 4.162683618347999], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.709377, 0.290038, 0.9589710000000002], "xyz": [3.8361405655200005, 1.597363692302, 7.378334381652002], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.2906230000000001, 0.709962, 0.45897100000000024], "xyz": [1.571619434480001, 3.910065307698, 3.5313283816520022], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.2906230000000001, 0.709962, 0.04102899999999976], "xyz": [1.571619434480001, 3.910065307698, 0.31567761834799846], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.709377, 0.290038, 0.5410289999999998], "xyz": [3.8361405655200005, 1.597363692302, 4.162683618347998], "label": "O2-", "properties": {}}]}
1 change: 1 addition & 0 deletions smact/tests/files/Fe3O4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[3.02352510004715, -5.236899091241436, 0.0], [3.02352510004715, 5.236899091241436, 0.0], [0.0, 0.0, 14.716012023663136]], "pbc": [true, true, true], "a": 6.0470502000943, "b": 6.0470502000943, "c": 14.716012023663136, "alpha": 90.0, "beta": 90.0, "gamma": 119.99999999999999, "volume": 466.02360338422886}, "sites": [{"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.6666666666666666, 0.3333333333333333, 0.4594153333333334], "xyz": [3.0235251000471495, -1.745633030413812, 6.760761569188542], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.6666666666666667, 0.3333333333333333, 0.20725133333333323], "xyz": [3.02352510004715, -1.7456330304138123, 3.0499131132535484], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.33333333333333326, 0.6666666666666666, 0.7927486666666668], "xyz": [3.0235251000471495, 1.7456330304138121, 11.666098910409588], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.3333333333333335, 0.6666666666666666, 0.5405846666666665], "xyz": [3.0235251000471504, 1.745633030413811, 7.955250454474593], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.0, 0.0, 0.12608200000000003], "xyz": [0.0, 0.0, 1.855424227967496], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 2, "occu": 1}], "abc": [0.0, 0.0, 0.8739179999999999], "xyz": [0.0, 0.0, 12.860587795695638], "label": "Fe2+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.5, 0.0, 0.0], "xyz": [1.511762550023575, -2.618449545620718, 0.0], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.3333333333333333, 0.16666666666666652, 0.6666666666666665], "xyz": [1.5117625500235743, -0.8728165152069067, 9.81067468244209], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.5, 0.5, 0.0], "xyz": [3.02352510004715, 0.0, 0.0], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.6666666666666665, 0.33333333333333326, 0.8333333333333331], "xyz": [3.0235251000471495, -1.7456330304138117, 12.26334335305261], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.16666666666666652, 0.3333333333333333, 0.33333333333333326], "xyz": [1.5117625500235745, 0.8728165152069067, 4.905337341221045], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.0, 0.49999999999999983, 0.9999999999999998], "xyz": [1.5117625500235745, 2.618449545620717, 14.716012023663133], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.16666666666666652, 0.8333333333333333, 0.3333333333333333], "xyz": [3.0235251000471495, 3.4912660608276243, 4.9053373412210455], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.33333333333333304, 0.6666666666666665, 0.16666666666666652], "xyz": [3.0235251000471486, 1.7456330304138128, 2.4526686706105205], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.8333333333333333, 0.6666666666666666, 0.6666666666666665], "xyz": [4.535287650070725, -0.8728165152069054, 9.81067468244209], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.6666666666666666, 0.8333333333333331, 0.33333333333333304], "xyz": [4.535287650070724, 0.8728165152069052, 4.905337341221041], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.8333333333333333, 0.16666666666666652, 0.6666666666666666], "xyz": [3.023525100047149, -3.491266060827624, 9.810674682442091], "label": "Fe3+", "properties": {}}, {"species": [{"element": "Fe", "oxidation_state": 3, "occu": 1}], "abc": [0.9999999999999998, 0.9999999999999999, 0.4999999999999998], "xyz": [6.047050200094299, 3.0676582482664517e-16, 7.358006011831565], "label": "Fe3+", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.3476766666666668, 0.1738383333333334, 0.9153713333333334], "xyz": [1.5768136925510898, -0.9103738098562595, 13.470615547449892], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.5071716666666667, 0.4928283333333332, 0.7512953333333332], "xyz": [3.0235251000471495, -0.07511458929870728, 11.056071158655335], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.6666666666666666, 0.3333333333333333, 0.5900989999999999], "xyz": [3.0235251000471495, -1.745633030413812, 8.683903979151593], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.8261616666666666, 0.1738383333333334, 0.9153713333333334], "xyz": [3.02352510004715, -3.416151471528917, 13.470615547449892], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.5071716666666667, 0.014343333333333375, 0.7512953333333332], "xyz": [1.5768136925510896, -2.580892250971365, 11.056071158655335], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.6666666666666667, 0.3333333333333333, 0.0765676666666667], "xyz": [3.02352510004715, -1.7456330304138123, 1.1267707032904983], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.9856566666666665, 0.4928283333333332, 0.7512953333333332], "xyz": [4.47023650754321, -2.580892250971365, 11.056071158655335], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.8261616666666666, 0.6523233333333331, 0.9153713333333334], "xyz": [4.47023650754321, -0.91037380985626, 13.470615547449892], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.014343333333333375, 0.5071716666666667, 0.2487046666666668], "xyz": [1.5768136925510896, 2.5808922509713645, 3.659940865007801], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.17383833333333332, 0.8261616666666665, 0.08462866666666646], "xyz": [3.023525100047149, 3.4161514715289165, 1.2453964762132435], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.33333333333333326, 0.6666666666666666, 0.9234323333333332], "xyz": [3.0235251000471495, 1.7456330304138121, 13.589241320372636], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.4928283333333332, 0.5071716666666667, 0.2487046666666668], "xyz": [3.0235251000471495, 0.07511458929870714, 3.659940865007801], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.17383833333333332, 0.3476766666666667, 0.08462866666666646], "xyz": [1.5768136925510894, 0.9103738098562594, 1.2453964762132435], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.3333333333333335, 0.6666666666666666, 0.409901], "xyz": [3.0235251000471504, 1.745633030413811, 6.032108044511544], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.6523233333333331, 0.8261616666666665, 0.08462866666666646], "xyz": [4.470236507543209, 0.9103738098562592, 1.2453964762132435], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.4928283333333332, 0.9856566666666664, 0.2487046666666668], "xyz": [4.470236507543209, 2.580892250971364, 3.659940865007801], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.6810100000000001, 0.8405050000000001, 0.582038], "xyz": [4.600338792598239, 0.8352592205575523, 8.565278206228845], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.8405050000000001, 0.15949499999999972, 0.4179619999999997], "xyz": [3.0235251000471495, -3.566380650126332, 6.150733817434288], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.0, 0.0, 0.25676566666666645], "xyz": [0.0, 0.0, 3.7785666379305445], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.15949499999999994, 0.8405050000000001, 0.582038], "xyz": [3.02352510004715, 3.566380650126331, 8.565278206228845], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.8405050000000001, 0.68101, 0.4179619999999997], "xyz": [4.600338792598239, -0.8352592205575532, 6.150733817434288], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.0, 0.0, 0.7432343333333333], "xyz": [0.0, 0.0, 10.93744538573259], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.3189899999999999, 0.15949499999999972, 0.4179619999999997], "xyz": [1.4467114074960594, -0.8352592205575537, 6.150733817434288], "label": "O2-", "properties": {}}, {"species": [{"element": "O", "oxidation_state": -2, "occu": 1}], "abc": [0.15949499999999994, 0.3189899999999999, 0.582038], "xyz": [1.44671140749606, 0.8352592205575525, 8.565278206228845], "label": "O2-", "properties": {}}]}
1 change: 1 addition & 0 deletions smact/tests/files/NaCl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[5.691694000000001, 0.0, 3.4851574194130984e-16], [9.152942036428614e-16, 5.691694000000001, 3.4851574194130984e-16], [0.0, 0.0, 5.691694000000001]], "pbc": [true, true, true], "a": 5.691694000000001, "b": 5.691694000000001, "c": 5.691694000000001, "alpha": 90.0, "beta": 90.0, "gamma": 90.0, "volume": 184.3845933297478}, "sites": [{"species": [{"element": "Na", "oxidation_state": 1, "occu": 1}], "abc": [0.0, 0.0, 0.0], "xyz": [0.0, 0.0, 0.0], "label": "Na+", "properties": {}}, {"species": [{"element": "Na", "oxidation_state": 1, "occu": 1}], "abc": [0.0, 0.5, 0.5], "xyz": [4.576471018214307e-16, 2.8458470000000005, 2.8458470000000005], "label": "Na+", "properties": {}}, {"species": [{"element": "Na", "oxidation_state": 1, "occu": 1}], "abc": [0.5, 0.0, 0.5], "xyz": [2.8458470000000005, 0.0, 2.8458470000000005], "label": "Na+", "properties": {}}, {"species": [{"element": "Na", "oxidation_state": 1, "occu": 1}], "abc": [0.5, 0.5, 0.0], "xyz": [2.845847000000001, 2.8458470000000005, 3.4851574194130984e-16], "label": "Na+", "properties": {}}, {"species": [{"element": "Cl", "oxidation_state": -1, "occu": 1}], "abc": [0.5, 0.0, 0.0], "xyz": [2.8458470000000005, 0.0, 1.7425787097065492e-16], "label": "Cl-", "properties": {}}, {"species": [{"element": "Cl", "oxidation_state": -1, "occu": 1}], "abc": [0.5, 0.5, 0.5], "xyz": [2.845847000000001, 2.8458470000000005, 2.845847000000001], "label": "Cl-", "properties": {}}, {"species": [{"element": "Cl", "oxidation_state": -1, "occu": 1}], "abc": [0.0, 0.0, 0.5], "xyz": [0.0, 0.0, 2.8458470000000005], "label": "Cl-", "properties": {}}, {"species": [{"element": "Cl", "oxidation_state": -1, "occu": 1}], "abc": [0.0, 0.5, 0.0], "xyz": [4.576471018214307e-16, 2.8458470000000005, 1.7425787097065492e-16], "label": "Cl-", "properties": {}}]}
Binary file removed smact/tests/files/mp_data
Binary file not shown.
5 changes: 0 additions & 5 deletions smact/tests/test.py → smact/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,3 @@ def test_oxidation_states(self):
Species('Fe',+3), Species('O',-2)),
0.74280230326)
self.assertEqual(len(ox.get_included_species()), 173)



if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 991205f

Please sign in to comment.