diff --git a/LICENSE b/LICENSE index 989aaa1..5bc0eb1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2023, PyBaMM Team +Copyright (c) 2023-2024, PyBaMM Team Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/LICENSES-bundled.txt b/LICENSES-bundled.txt new file mode 100644 index 0000000..d97adec --- /dev/null +++ b/LICENSES-bundled.txt @@ -0,0 +1,7 @@ +This project and source distributions bundle several libraries that are +compatibly licensed. + + +Name: PyBaMM +Files: src/pybamm_cookiecutter/parameters/* +License: BSD-3-Clause diff --git a/noxfile.py b/noxfile.py index f4cb85c..87dc9bd 100644 --- a/noxfile.py +++ b/noxfile.py @@ -37,4 +37,4 @@ def set_dev(session): session.install("virtualenv") session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True) python = os.fsdecode(VENV_DIR.joinpath("bin/python")) - session.run(python, "-m", "pip", "install", "-e", ".[dev]") + session.run(python, "-m", "uv", "pip", "install", "-e", ".[dev]") diff --git a/pyproject.toml b/pyproject.toml index f35eaf3..dc0bda6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,20 +109,7 @@ flake8-unused-arguments.ignore-variadic-names = true [tool.ruff.lint] extend-select = [ "B", # flake8-bugbear - # "I", # isort - # "ARG", # flake8-unused-arguments - # "C4", # flake8-comprehensions - # "ICN", # flake8-import-conventions - # "ISC", # flake8-implicit-str-concat - # "PGH", # pygrep-hooks - # "PIE", # flake8-pie - # "PL", # pylint - # "PT", # flake8-pytest-style - # "PTH", # flake8-use-pathlib - # "RET", # flake8-return "RUF", # Ruff-specific - # "SIM", # flake8-simplify - # "T20", # flake8-print "UP", # pyupgrade "YTT", # flake8-2020 "TID252", # relative-imports diff --git a/src/pybamm_cookiecutter/parameters/input/Chen2020.py b/src/pybamm_cookiecutter/parameters/input/Chen2020.py index cfb0711..4f52b2c 100644 --- a/src/pybamm_cookiecutter/parameters/input/Chen2020.py +++ b/src/pybamm_cookiecutter/parameters/input/Chen2020.py @@ -2,7 +2,38 @@ import numpy as np import pybamm - +""" +This code is adopted from the PyBaMM project under the BSD 3-Clause + +Copyright (c) 2018-2024, the PyBaMM team. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" def graphite_LGM50_ocp_Chen2020(sto): """ diff --git a/src/pybamm_cookiecutter/parameters/parameter_sets.py b/src/pybamm_cookiecutter/parameters/parameter_sets.py index e61e26d..a38a99e 100644 --- a/src/pybamm_cookiecutter/parameters/parameter_sets.py +++ b/src/pybamm_cookiecutter/parameters/parameter_sets.py @@ -1,13 +1,42 @@ -from __future__ import annotations - import importlib.metadata import sys import textwrap -import warnings from collections.abc import Mapping from typing import Callable +""" +This code is adopted from the PyBaMM project under the BSD 3-Clause + +Copyright (c) 2018-2024, the PyBaMM team. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" + class ParameterSets(Mapping): """ Dict-like interface for accessing parameter sets through entry points in cookiecutter template. @@ -85,17 +114,7 @@ def __getattribute__(self, name): try: return super().__getattribute__(name) except AttributeError as error: - # For backwards compatibility, parameter sets that used to be defined in - # this file now return the name as a string, which will load the same - # parameter set as before when passed to `ParameterValues` - if name in self: - msg = ( - f"Parameter sets should be called directly by their name ({name}), " - f"instead of via pybamm_cookiecutter.parameter_sets (pybamm_cookiecutter.parameter_sets.{name})." - ) - warnings.warn(msg, DeprecationWarning, stacklevel=2) - return name - raise error + raise error #: Singleton Instance of :class:ParameterSets """ parameter_sets = ParameterSets() diff --git a/tests/test_entry_points.py b/tests/test_entry_points.py index ce0e368..3c6e374 100644 --- a/tests/test_entry_points.py +++ b/tests/test_entry_points.py @@ -1,16 +1,16 @@ import pytest import pybamm_cookiecutter -import glob import importlib.util import sys +from pathlib import Path def test_entry_points(): """Testing if the entry points are loading right""" entry_points = list(pybamm_cookiecutter.parameter_sets) - parameter_sets = glob.glob("src/pybamm_cookiecutter/parameters/input/*.py") + parameter_sets = Path("src/pybamm_cookiecutter/parameters/input/").glob("*.py") # Making a list Parameter sets in the parameters/input directory - parameter_sets = [x.split('/')[-1].split('.py')[0] for x in parameter_sets] + parameter_sets = [str(x).split('/')[-1].split('.py')[0] for x in parameter_sets] assert parameter_sets == entry_points, "Entry points missing either in pyproject.toml or in the input directory"