Skip to content

Commit be83638

Browse files
Copilotthinkall
andcommitted
Apply pre-commit formatting fixes
Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
1 parent 9639156 commit be83638

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

flaml/automl/automl.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def custom_metric(
156156
"pred_time": pred_time,
157157
}
158158
```
159-
**Note:** When passing a custom metric function, pass the function itself
160-
(e.g., `metric=custom_metric`), not the result of calling it
161-
(e.g., `metric=custom_metric(...)`). FLAML will call your function
159+
**Note:** When passing a custom metric function, pass the function itself
160+
(e.g., `metric=custom_metric`), not the result of calling it
161+
(e.g., `metric=custom_metric(...)`). FLAML will call your function
162162
internally during the training process.
163163
task: A string of the task type, e.g.,
164164
'classification', 'regression', 'ts_forecast', 'rank',
@@ -471,11 +471,11 @@ def __setstate__(self, state):
471471
@staticmethod
472472
def _validate_metric_parameter(metric, allow_auto=True):
473473
"""Validate that the metric parameter is either a string or a callable function.
474-
474+
475475
Args:
476476
metric: The metric parameter to validate.
477477
allow_auto: Whether to allow "auto" as a valid string value.
478-
478+
479479
Raises:
480480
ValueError: If metric is not a string or callable function.
481481
"""
@@ -1838,9 +1838,9 @@ def custom_metric(
18381838
"pred_time": pred_time,
18391839
}
18401840
```
1841-
**Note:** When passing a custom metric function, pass the function itself
1842-
(e.g., `metric=custom_metric`), not the result of calling it
1843-
(e.g., `metric=custom_metric(...)`). FLAML will call your function
1841+
**Note:** When passing a custom metric function, pass the function itself
1842+
(e.g., `metric=custom_metric`), not the result of calling it
1843+
(e.g., `metric=custom_metric(...)`). FLAML will call your function
18441844
internally during the training process.
18451845
task: A string of the task type, e.g.,
18461846
'classification', 'regression', 'ts_forecast_regression',

test/automl/test_multiclass.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,26 +281,28 @@ def test_custom_metric(self):
281281
def test_invalid_custom_metric(self):
282282
"""Test that proper error is raised when custom_metric is called instead of passed."""
283283
from sklearn.datasets import load_iris
284-
284+
285285
X_train, y_train = load_iris(return_X_y=True)
286-
286+
287287
# Test with non-callable metric in __init__
288288
with self.assertRaises(ValueError) as context:
289289
automl = AutoML(metric=123) # passing an int instead of function
290290
self.assertIn("must be either a string or a callable function", str(context.exception))
291291
self.assertIn("but got int", str(context.exception))
292-
292+
293293
# Test with non-callable metric in fit
294294
automl = AutoML()
295295
with self.assertRaises(ValueError) as context:
296296
automl.fit(X_train=X_train, y_train=y_train, metric=[], task="classification", time_budget=1)
297297
self.assertIn("must be either a string or a callable function", str(context.exception))
298298
self.assertIn("but got list", str(context.exception))
299-
299+
300300
# Test with tuple (simulating result of calling a function that returns tuple)
301301
with self.assertRaises(ValueError) as context:
302302
automl = AutoML()
303-
automl.fit(X_train=X_train, y_train=y_train, metric=(0.5, {"loss": 0.5}), task="classification", time_budget=1)
303+
automl.fit(
304+
X_train=X_train, y_train=y_train, metric=(0.5, {"loss": 0.5}), task="classification", time_budget=1
305+
)
304306
self.assertIn("must be either a string or a callable function", str(context.exception))
305307
self.assertIn("but got tuple", str(context.exception))
306308

0 commit comments

Comments
 (0)