From 153e25b458cbe6d1770b48586f3884ebae84b063 Mon Sep 17 00:00:00 2001 From: Di Jin Date: Thu, 11 Jul 2024 11:47:40 +0200 Subject: [PATCH] Simplify syntax with 'prod' --- baybe/searchspace/continuous.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/baybe/searchspace/continuous.py b/baybe/searchspace/continuous.py index 5c38973cb..8ed977aba 100644 --- a/baybe/searchspace/continuous.py +++ b/baybe/searchspace/continuous.py @@ -2,9 +2,9 @@ from __future__ import annotations +import math import warnings from collections.abc import Collection, Iterable, Sequence -from functools import reduce from itertools import chain, product from typing import TYPE_CHECKING, Any, cast @@ -122,13 +122,11 @@ def n_combinatorial_inactive_parameters(self) -> int: if not self.constraints_cardinality: return 0 - return reduce( - lambda x, y: x * y, - [ - con.n_combinatorial_inactive_parameters - for con in self.constraints_cardinality - ], - ) + n_combinatorial_inactive_params = [ + con.n_combinatorial_inactive_parameters + for con in self.constraints_cardinality + ] + return math.prod(n_combinatorial_inactive_params) @property def combinatorial_inactive_parameters(