From b28d2cffed406282734576621ea43c1374e25ca1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Sep 2025 16:58:37 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](https://github.com/pre-commit/mirrors-clang-format/compare/v20.1.8...v21.1.0) - [github.com/astral-sh/ruff-pre-commit: v0.12.5 → v0.12.12](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.5...v0.12.12) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4eb34133a..ea11aea0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: # Standard hooks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-merge-conflict @@ -39,7 +39,7 @@ repos: # Clang format - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v20.1.8 + rev: v21.1.0 hooks: - id: clang-format types_or: [c++, c, cuda] @@ -55,7 +55,7 @@ repos: # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.5 + rev: v0.12.12 hooks: - id: ruff args: ["--fix", "--show-fixes"] From e9c29d298e0bff2c86afa1272e0c3af31e18bf93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Sep 2025 16:58:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xcsf/pybind_callback.h | 8 +++----- xcsf/pybind_callback_checkpoint.h | 13 +++++-------- xcsf/pybind_callback_earlystop.h | 16 ++++++---------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/xcsf/pybind_callback.h b/xcsf/pybind_callback.h index 6a67954df..e0d306e9b 100644 --- a/xcsf/pybind_callback.h +++ b/xcsf/pybind_callback.h @@ -38,12 +38,10 @@ extern "C" { */ class Callback { - public: +public: virtual ~Callback() {} - virtual bool - run(struct XCSF *xcsf, py::dict metrics) = 0; + virtual bool run(struct XCSF * xcsf, py::dict metrics) = 0; - virtual void - finish(struct XCSF *xcsf) = 0; + virtual void finish(struct XCSF * xcsf) = 0; }; diff --git a/xcsf/pybind_callback_checkpoint.h b/xcsf/pybind_callback_checkpoint.h index eea88a4c3..f2fee5f26 100644 --- a/xcsf/pybind_callback_checkpoint.h +++ b/xcsf/pybind_callback_checkpoint.h @@ -41,7 +41,7 @@ extern "C" { */ class CheckpointCallback : public Callback { - public: +public: /** * @brief Constructs a new checkpoint callback. * @param [in] monitor Name of the metric to monitor: {"train", "val"}. @@ -74,8 +74,7 @@ class CheckpointCallback : public Callback * @brief Saves the state of XCSF. * @param [in] xcsf The XCSF data structure. */ - void - save(struct XCSF *xcsf) + void save(struct XCSF * xcsf) { xcsf_save(xcsf, filename.c_str()); std::ostringstream status; @@ -90,8 +89,7 @@ class CheckpointCallback : public Callback * @param [in] metrics Dictionary of performance metrics. * @return Whether to terminate training. */ - bool - run(struct XCSF *xcsf, py::dict metrics) override + bool run(struct XCSF * xcsf, py::dict metrics) override { py::list data = metrics[monitor]; py::list trials = metrics["trials"]; @@ -113,15 +111,14 @@ class CheckpointCallback : public Callback * @brief Executes any tasks at the end of fitting. * @param [in] xcsf The XCSF data structure. */ - void - finish(struct XCSF *xcsf) override + void finish(struct XCSF * xcsf) override { if (!save_best_only) { save(xcsf); } } - private: +private: py::str monitor; //!< Name of the metric to monitor std::string filename; //!< Name of the file to save XCSF bool save_best_only; //!< Whether to only save the best population diff --git a/xcsf/pybind_callback_earlystop.h b/xcsf/pybind_callback_earlystop.h index 22da07164..e65d0bf78 100644 --- a/xcsf/pybind_callback_earlystop.h +++ b/xcsf/pybind_callback_earlystop.h @@ -41,7 +41,7 @@ extern "C" { */ class EarlyStoppingCallback : public Callback { - public: +public: /** * @brief Constructs a new early stopping callback. * @param [in] monitor Name of the metric to monitor: {"train", "val"}. @@ -82,8 +82,7 @@ class EarlyStoppingCallback : public Callback * @brief Stores best XCSF population in memory. * @param [in] xcsf The XCSF data structure. */ - void - store(struct XCSF *xcsf) + void store(struct XCSF * xcsf) { do_restore = true; xcsf_store_pset(xcsf); @@ -100,8 +99,7 @@ class EarlyStoppingCallback : public Callback * @brief Retrieves best XCSF population in memory. * @param [in] xcsf The XCSF data structure. */ - void - retrieve(struct XCSF *xcsf) + void retrieve(struct XCSF * xcsf) { do_restore = false; xcsf_retrieve_pset(xcsf); @@ -121,8 +119,7 @@ class EarlyStoppingCallback : public Callback * @param [in] metrics Dictionary of performance metrics. * @return whether early stopping criteria has been met. */ - bool - run(struct XCSF *xcsf, py::dict metrics) override + bool run(struct XCSF * xcsf, py::dict metrics) override { py::list data = metrics[monitor]; py::list trials = metrics["trials"]; @@ -156,15 +153,14 @@ class EarlyStoppingCallback : public Callback * @brief Executes any tasks at the end of fitting. * @param [in] xcsf The XCSF data structure. */ - void - finish(struct XCSF *xcsf) override + void finish(struct XCSF * xcsf) override { if (restore && do_restore) { retrieve(xcsf); } } - private: +private: py::str monitor; //!< Name of the metric to monitor int patience; //!< Stop training after this many trials with no improvement bool restore; //!< Whether to restore the best population