-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 58-pre-commit
- Loading branch information
Showing
24 changed files
with
145 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import pytest | ||
import matplotlib | ||
|
||
matplotlib.use("Template") | ||
|
||
|
||
def pytest_addoption(parser): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
pybop/optimisation/BaseOptimisation.py → pybop/optimisers/BaseOptimiser.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
pybop/optimisation/NLoptOptimize.py → pybop/optimisers/NLoptOptimize.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pybop | ||
import numpy as np | ||
import pytest | ||
import runpy | ||
import os | ||
|
||
|
||
class TestExamples: | ||
""" | ||
A class to test the example scripts. | ||
""" | ||
|
||
@pytest.mark.unit | ||
def test_example_scripts(self): | ||
path_to_example_scripts = os.path.join( | ||
pybop.script_path, "..", "examples", "scripts" | ||
) | ||
for example in os.listdir(path_to_example_scripts): | ||
if example.endswith(".py"): | ||
runpy.run_path(os.path.join(path_to_example_scripts, example)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pybop | ||
import numpy as np | ||
import pytest | ||
import runpy | ||
import os | ||
|
||
|
||
class TestModels: | ||
""" | ||
A class to test the models. | ||
""" | ||
|
||
@pytest.mark.unit | ||
def test_simulate_without_build_model(self): | ||
# Define model | ||
model = pybop.lithium_ion.SPM() | ||
|
||
with pytest.raises( | ||
ValueError, match="Model must be built before calling simulate" | ||
): | ||
model.simulate(None, None) | ||
|
||
@pytest.mark.unit | ||
def test_build(self): | ||
model = pybop.lithium_ion.SPM() | ||
model.build() | ||
assert model.built_model is not None | ||
|
||
@pytest.mark.unit | ||
def test_n_parameters(self): | ||
model = pybop.BaseModel() | ||
n = model.n_outputs() | ||
assert isinstance(n, int) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pybop | ||
import numpy as np | ||
import pytest | ||
import runpy | ||
import os | ||
|
||
|
||
class TestParameterSets: | ||
""" | ||
A class to test parameter sets. | ||
""" | ||
|
||
@pytest.mark.unit | ||
def test_parameter_set(self): | ||
# Tests parameter set creation | ||
with pytest.raises(ValueError): | ||
pybop.ParameterSet("pybamms", "Chen2020") | ||
|
||
parameter_test = pybop.ParameterSet("pybamm", "Chen2020") | ||
np.testing.assert_allclose( | ||
parameter_test["Negative electrode active material volume fraction"], 0.75 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pybop | ||
import numpy as np | ||
import pytest | ||
import runpy | ||
import os | ||
|
||
|
||
class TestPriors: | ||
""" | ||
A class to test the priors. | ||
""" | ||
|
||
@pytest.mark.unit | ||
def test_priors(self): | ||
# Tests priors | ||
Gaussian = pybop.Gaussian(0.5, 1) | ||
Uniform = pybop.Uniform(0, 1) | ||
Exponential = pybop.Exponential(1) | ||
|
||
np.testing.assert_allclose(Gaussian.pdf(0.5), 0.3989422804014327, atol=1e-4) | ||
np.testing.assert_allclose(Uniform.pdf(0.5), 1, atol=1e-4) | ||
np.testing.assert_allclose(Exponential.pdf(1), 0.36787944117144233, atol=1e-4) |