From ad65285dd7a359641c5a88a865749eea7ef4866b Mon Sep 17 00:00:00 2001 From: Teytaud Date: Wed, 12 Jan 2022 16:21:48 +0100 Subject: [PATCH 1/3] Faster ngopt --- nevergrad/optimization/optimizerlib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nevergrad/optimization/optimizerlib.py b/nevergrad/optimization/optimizerlib.py index be8500d31..7c4152df5 100644 --- a/nevergrad/optimization/optimizerlib.py +++ b/nevergrad/optimization/optimizerlib.py @@ -2406,9 +2406,9 @@ def __init__( def optim(self) -> base.Optimizer: if self._optim is None: self._optim = self._select_optimizer_cls()(self.parametrization, self.budget, self.num_workers) - optim = self._optim if not isinstance(self._optim, NGOptBase) else self._optim.optim - logger.debug("%s selected %s optimizer.", *(x.name for x in (self, optim))) - return self._optim + self.optim = self._optim if not isinstance(self._optim, NGOptBase) else self._optim.optim + logger.debug("%s selected %s optimizer.", *(x.name for x in (self, self.optim))) + return self.optim def _select_optimizer_cls(self) -> base.OptCls: # pylint: disable=too-many-nested-blocks From 3615be5934e50afbf0443d87129460c28cd59dd8 Mon Sep 17 00:00:00 2001 From: Teytaud Date: Wed, 12 Jan 2022 16:25:11 +0100 Subject: [PATCH 2/3] Update nevergrad/optimization/optimizerlib.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémy Rapin --- nevergrad/optimization/optimizerlib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nevergrad/optimization/optimizerlib.py b/nevergrad/optimization/optimizerlib.py index 7c4152df5..955d0ff1e 100644 --- a/nevergrad/optimization/optimizerlib.py +++ b/nevergrad/optimization/optimizerlib.py @@ -2406,9 +2406,9 @@ def __init__( def optim(self) -> base.Optimizer: if self._optim is None: self._optim = self._select_optimizer_cls()(self.parametrization, self.budget, self.num_workers) - self.optim = self._optim if not isinstance(self._optim, NGOptBase) else self._optim.optim - logger.debug("%s selected %s optimizer.", *(x.name for x in (self, self.optim))) - return self.optim + self._optim = self._optim if not isinstance(self._optim, NGOptBase) else self._optim.optim + logger.debug("%s selected %s optimizer.", *(x.name for x in (self, self._optim))) + return self._optim def _select_optimizer_cls(self) -> base.OptCls: # pylint: disable=too-many-nested-blocks From bde3a6e0f55f59ed66b37c2c9a00d46adf4f6ec2 Mon Sep 17 00:00:00 2001 From: Jeremy Rapin Date: Wed, 12 Jan 2022 16:48:16 +0100 Subject: [PATCH 3/3] fix --- nevergrad/common/testing.py | 2 +- nevergrad/optimization/oneshot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nevergrad/common/testing.py b/nevergrad/common/testing.py index 11a1a29c3..a46db3f22 100644 --- a/nevergrad/common/testing.py +++ b/nevergrad/common/testing.py @@ -148,7 +148,7 @@ def skip_error_on_systems(error_type: tp.Type[Exception], systems: tp.Iterable[s except error_type as e: system = platform.system() if system in systems: - raise unittest.SkipTest + raise unittest.SkipTest(f"Skipping on system {system}") if systems: # only print if the context is actually active for some system print(f'This is system "{system}" (should it be skipped for the test?)') raise e diff --git a/nevergrad/optimization/oneshot.py b/nevergrad/optimization/oneshot.py index d11376405..6d4d5de04 100644 --- a/nevergrad/optimization/oneshot.py +++ b/nevergrad/optimization/oneshot.py @@ -175,7 +175,7 @@ def _internal_ask(self) -> tp.ArrayLike: point = self.parametrization.sample().get_standardized_data(reference=self.parametrization) else: raise ValueError("Unkwnown sampler {self.sampler}") - self._opposable_data = scale * point + self._opposable_data = scale * point # type: ignore return self._opposable_data # type: ignore def _internal_provide_recommendation(self) -> tp.Optional[tp.ArrayLike]: