Skip to content

Commit fdf8e4c

Browse files
chore: pre-commit autoupdate (#222)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/mirrors-clang-format: v21.1.2 → v21.1.6](pre-commit/mirrors-clang-format@v21.1.2...v21.1.6) - [github.com/astral-sh/ruff-pre-commit: v0.14.2 → v0.14.6](astral-sh/ruff-pre-commit@v0.14.2...v0.14.6) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e629b47 commit fdf8e4c

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939
4040
# Clang format
4141
- repo: https://github.com/pre-commit/mirrors-clang-format
42-
rev: v21.1.2
42+
rev: v21.1.6
4343
hooks:
4444
- id: clang-format
4545
types_or: [c++, c, cuda]
@@ -55,7 +55,7 @@ repos:
5555

5656
# Ruff, the Python auto-correcting linter/formatter written in Rust
5757
- repo: https://github.com/astral-sh/ruff-pre-commit
58-
rev: v0.14.2
58+
rev: v0.14.6
5959
hooks:
6060
- id: ruff
6161
args: ["--fix", "--show-fixes"]

xcsf/pybind_callback.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ extern "C" {
3838
*/
3939
class Callback
4040
{
41-
public:
41+
public:
4242
virtual ~Callback() {}
4343

44-
virtual bool run(struct XCSF * xcsf, py::dict metrics) = 0;
44+
virtual bool
45+
run(struct XCSF *xcsf, py::dict metrics) = 0;
4546

46-
virtual void finish(struct XCSF * xcsf) = 0;
47+
virtual void
48+
finish(struct XCSF *xcsf) = 0;
4749
};

xcsf/pybind_callback_checkpoint.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" {
4141
*/
4242
class CheckpointCallback : public Callback
4343
{
44-
public:
44+
public:
4545
/**
4646
* @brief Constructs a new checkpoint callback.
4747
* @param [in] monitor Name of the metric to monitor: {"train", "val"}.
@@ -74,7 +74,8 @@ class CheckpointCallback : public Callback
7474
* @brief Saves the state of XCSF.
7575
* @param [in] xcsf The XCSF data structure.
7676
*/
77-
void save(struct XCSF * xcsf)
77+
void
78+
save(struct XCSF *xcsf)
7879
{
7980
xcsf_save(xcsf, filename.c_str());
8081
std::ostringstream status;
@@ -89,7 +90,8 @@ class CheckpointCallback : public Callback
8990
* @param [in] metrics Dictionary of performance metrics.
9091
* @return Whether to terminate training.
9192
*/
92-
bool run(struct XCSF * xcsf, py::dict metrics) override
93+
bool
94+
run(struct XCSF *xcsf, py::dict metrics) override
9395
{
9496
py::list data = metrics[monitor];
9597
py::list trials = metrics["trials"];
@@ -111,14 +113,15 @@ class CheckpointCallback : public Callback
111113
* @brief Executes any tasks at the end of fitting.
112114
* @param [in] xcsf The XCSF data structure.
113115
*/
114-
void finish(struct XCSF * xcsf) override
116+
void
117+
finish(struct XCSF *xcsf) override
115118
{
116119
if (!save_best_only) {
117120
save(xcsf);
118121
}
119122
}
120123

121-
private:
124+
private:
122125
py::str monitor; //!< Name of the metric to monitor
123126
std::string filename; //!< Name of the file to save XCSF
124127
bool save_best_only; //!< Whether to only save the best population

xcsf/pybind_callback_earlystop.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" {
4141
*/
4242
class EarlyStoppingCallback : public Callback
4343
{
44-
public:
44+
public:
4545
/**
4646
* @brief Constructs a new early stopping callback.
4747
* @param [in] monitor Name of the metric to monitor: {"train", "val"}.
@@ -82,7 +82,8 @@ class EarlyStoppingCallback : public Callback
8282
* @brief Stores best XCSF population in memory.
8383
* @param [in] xcsf The XCSF data structure.
8484
*/
85-
void store(struct XCSF * xcsf)
85+
void
86+
store(struct XCSF *xcsf)
8687
{
8788
do_restore = true;
8889
xcsf_store_pset(xcsf);
@@ -99,7 +100,8 @@ class EarlyStoppingCallback : public Callback
99100
* @brief Retrieves best XCSF population in memory.
100101
* @param [in] xcsf The XCSF data structure.
101102
*/
102-
void retrieve(struct XCSF * xcsf)
103+
void
104+
retrieve(struct XCSF *xcsf)
103105
{
104106
do_restore = false;
105107
xcsf_retrieve_pset(xcsf);
@@ -119,7 +121,8 @@ class EarlyStoppingCallback : public Callback
119121
* @param [in] metrics Dictionary of performance metrics.
120122
* @return whether early stopping criteria has been met.
121123
*/
122-
bool run(struct XCSF * xcsf, py::dict metrics) override
124+
bool
125+
run(struct XCSF *xcsf, py::dict metrics) override
123126
{
124127
py::list data = metrics[monitor];
125128
py::list trials = metrics["trials"];
@@ -153,14 +156,15 @@ class EarlyStoppingCallback : public Callback
153156
* @brief Executes any tasks at the end of fitting.
154157
* @param [in] xcsf The XCSF data structure.
155158
*/
156-
void finish(struct XCSF * xcsf) override
159+
void
160+
finish(struct XCSF *xcsf) override
157161
{
158162
if (restore && do_restore) {
159163
retrieve(xcsf);
160164
}
161165
}
162166

163-
private:
167+
private:
164168
py::str monitor; //!< Name of the metric to monitor
165169
int patience; //!< Stop training after this many trials with no improvement
166170
bool restore; //!< Whether to restore the best population

0 commit comments

Comments
 (0)