From 3a0f6cec2e0e099a8b09644e81aa84e84f82fec0 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Fri, 30 Aug 2024 06:15:02 +0200 Subject: [PATCH 1/3] chore: Update Display class in oracle.py with col_width parameter Fixes #1024 --- keras_tuner/engine/oracle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keras_tuner/engine/oracle.py b/keras_tuner/engine/oracle.py index 6198a3c24..563ff00f5 100644 --- a/keras_tuner/engine/oracle.py +++ b/keras_tuner/engine/oracle.py @@ -116,10 +116,10 @@ def wrapped_func(*args, **kwargs): # TODO: Add more extensive display. class Display(stateful.Stateful): - def __init__(self, oracle, verbose=1): + def __init__(self, oracle, verbose=1, col_width=18): self.verbose = verbose self.oracle = oracle - self.col_width = 18 + self.col_width = col_width # Start time for the overall search self.search_start = None From 83c0847dc37c56074b07c105c0a8095b3c18499e Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Fri, 30 Aug 2024 06:18:59 +0200 Subject: [PATCH 2/3] feat: Add `property` and `setter` for `col_width` --- keras_tuner/engine/oracle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/keras_tuner/engine/oracle.py b/keras_tuner/engine/oracle.py index 563ff00f5..42f681f2f 100644 --- a/keras_tuner/engine/oracle.py +++ b/keras_tuner/engine/oracle.py @@ -384,6 +384,14 @@ def verbose(self, value): value = 1 self._display.verbose = value + @property + def col_width(self): + return self._display.col_width + + @col_width.setter + def col_width(self, value): + self._display.col_width = value + def _populate_space(self, trial_id): warnings.warn( "The `_populate_space` method is deprecated, " From 338e8982cc9817855633813d1c56379f615d259b Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Fri, 30 Aug 2024 06:23:16 +0200 Subject: [PATCH 3/3] test: Add test for display col_width parameter --- keras_tuner/engine/oracle_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/keras_tuner/engine/oracle_test.py b/keras_tuner/engine/oracle_test.py index 4a584831e..8ed3e2ffe 100644 --- a/keras_tuner/engine/oracle_test.py +++ b/keras_tuner/engine/oracle_test.py @@ -450,3 +450,9 @@ def test_display_format_duration_large_d(): oracle.verbose = "auto" assert oracle_module.Display(oracle).format_duration(d) == "7d 00h 00m 00s" assert oracle.verbose == 1 + + +def test_display_col_width() -> None: + oracle = gridsearch.GridSearchOracle() + oracle.col_width = 10 + assert oracle_module.Display(oracle).col_width == 10