From 10b902603511dba62e93d03286304dab170cd541 Mon Sep 17 00:00:00 2001 From: Emma Johnson Date: Tue, 13 Aug 2024 17:44:33 -0600 Subject: [PATCH] black --- pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py | 2 +- pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py b/pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py index 07a0f090cd6..bc8d7a40027 100644 --- a/pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py +++ b/pyomo/contrib/piecewise/tests/test_nonlinear_to_pwl.py @@ -371,7 +371,7 @@ def test_uniform_sampling_discrete_vars(self): for x in [0, 1]: for y in [0, 1]: for z in [0, 2, 5]: - self.assertIn((x, y, z), points) + self.assertIn((x, y, z), points) @unittest.skipUnless(numpy_available, "Numpy is not available") def test_random_sampling_discrete_vars(self): diff --git a/pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py b/pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py index 03f006b66bc..a35231dd890 100644 --- a/pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py +++ b/pyomo/contrib/piecewise/transform/nonlinear_to_pwl.py @@ -99,8 +99,9 @@ def _get_random_point_grid(bounds, n, func, config, seed=42): linspaces.append(np.random.uniform(lb, ub, n)) else: size = min(n, ub - lb + 1) - linspaces.append(np.random.choice(range(lb, ub + 1), size=size, - replace=False)) + linspaces.append( + np.random.choice(range(lb, ub + 1), size=size, replace=False) + ) return list(itertools.product(*linspaces)) @@ -169,7 +170,7 @@ def _get_pwl_function_approximation(func, config, bounds): func: function to approximate config: ConfigDict for transformation, specifying domain_partitioning_method, num_points, and max_depth (if using linear trees) - bounds: list of tuples giving upper and lower bounds and a boolean indicating + bounds: list of tuples giving upper and lower bounds and a boolean indicating if the variable's domain is discrete or not, for each of func's arguments """ method = config.domain_partitioning_method