From 208384cc0bfa0ab2d049617e07c6e2f4a4bdf92f Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sat, 27 Jul 2024 13:17:29 +0100 Subject: [PATCH] update CI fix coverage delete unused code --- .github/workflows/build-test.yml | 2 +- .github/workflows/coverage.yml | 6 ++++-- .github/workflows/mpi-test.yml | 2 +- codecov.yml | 2 +- pyproject.toml | 2 +- src/Error.cpp | 21 --------------------- src/Error.h | 24 ------------------------ src/Model.cpp | 1 - src/Module.cpp | 3 +-- src/Timeline.cpp | 1 - test/test_model.py | 12 ++++++++++++ 11 files changed, 21 insertions(+), 55 deletions(-) delete mode 100644 src/Error.cpp delete mode 100644 src/Error.h diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bc9a4246..6fee7f99 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.11", "3.12", "3.13"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9c6735c9..f37b5cd2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,9 +14,11 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.11" ] + python-version: [ "3.12" ] steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: "pip: Python ${{ matrix.python-version }} coverage" uses: actions/setup-python@v5 with: @@ -27,7 +29,7 @@ jobs: python -m pip install pybind11 pytest - name: Build run: | - CFLAGS=-coverage python -m pip install . + CXXFLAGS=-coverage python -m pip install . - name: Test run: | python -m pytest diff --git a/.github/workflows/mpi-test.yml b/.github/workflows/mpi-test.yml index 1b53b90e..03d33f4b 100644 --- a/.github/workflows/mpi-test.yml +++ b/.github/workflows/mpi-test.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.12"] steps: - uses: actions/checkout@v4 - name: "pip: Python ${{ matrix.python-version }}" diff --git a/codecov.yml b/codecov.yml index 0ceb3f57..a48c11f1 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,4 +6,4 @@ coverage: threshold: 1% # leeway patch: default: - target: 80% + target: 75% diff --git a/pyproject.toml b/pyproject.toml index e24153d9..39f16507 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=42", "wheel", - "pybind11>=2.6.0", + "pybind11>=2.13", "numpy", "pytest" ] diff --git a/src/Error.cpp b/src/Error.cpp deleted file mode 100644 index 9b32838e..00000000 --- a/src/Error.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Error.h" -#include - -const char* no::NotImplementedError::what() const noexcept -{ - return m_msg.c_str(); -} - - -// map error types defined here to python exceptions -void no::exception_translator(std::exception_ptr p) -{ - try - { - if (p) std::rethrow_exception(p); - } - catch (const no::NotImplementedError& e) - { - PyErr_SetString(PyExc_NotImplementedError, e.what()); - } -} diff --git a/src/Error.h b/src/Error.h deleted file mode 100644 index 078284e2..00000000 --- a/src/Error.h +++ /dev/null @@ -1,24 +0,0 @@ -#include - -#include - -namespace no { - -// error that gets translated to a python NotImplementedError -class NotImplementedError : public std::exception -{ -public: - explicit NotImplementedError(const char* msg): m_msg(msg) { } - explicit NotImplementedError(const std::string& msg): m_msg(msg) { } - virtual ~NotImplementedError() noexcept { } - - virtual const char* what() const noexcept; - -private: - std::string m_msg; -}; - -// map error types defined here to python exceptions -void exception_translator(std::exception_ptr p); - -} \ No newline at end of file diff --git a/src/Model.cpp b/src/Model.cpp index 49a2b26f..910f81d3 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -4,7 +4,6 @@ #include "Module.h" #include "Timer.h" #include "Log.h" -#include "Error.h" #include "Helpers.h" #include diff --git a/src/Module.cpp b/src/Module.cpp index e5bb538e..f2bf6227 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -7,7 +7,6 @@ #include "NPArray.h" #include "DataFrame.h" #include "Log.h" -#include "Error.h" #include "NewOrder.h" @@ -223,6 +222,6 @@ PYBIND11_MODULE(_neworder_core, m) init_env(mpi); // Map custom C++ exceptions to python ones - py::register_exception_translator(no::exception_translator); + //py::register_exception_translator(no::exception_translator); } diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 537b5173..824a2e04 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -1,6 +1,5 @@ #include "Timeline.h" #include "Log.h" -#include "Error.h" #include diff --git a/test/test_model.py b/test/test_model.py index b7735626..e23539ca 100644 --- a/test/test_model.py +++ b/test/test_model.py @@ -18,6 +18,18 @@ def __init__(self) -> None: with pytest.raises(TypeError): _ = TestModel() +def test_not_implemented() -> None: + + class TestModel(no.Model): + def __init__(self) -> None: + super().__init__(no.NoTimeline()) + + def step(self) -> None: + raise NotImplementedError() + + with pytest.raises(NotImplementedError): + no.run(TestModel()) + def test_default_seeder() -> None: class DefaultModel(no.Model):