Skip to content

Commit deafe95

Browse files
committed
Rename argument to signal that None propagation only happens in fast path
1 parent 1276fee commit deafe95

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/optimagic/differentiation/derivatives.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def first_derivative(
249249
# We cannot propagate None-valued bounds until the derivative code is updated to
250250
# handle None bounds.
251251
internal_lb, internal_ub = get_internal_bounds(
252-
params, bounds=bounds, propagate_none=False
252+
params, bounds=bounds, propagate_none_in_fast_path=False
253253
)
254254

255255
# handle kwargs
@@ -567,7 +567,7 @@ def second_derivative(
567567
# We cannot propagate None-valued bounds until the derivative code is updated to
568568
# handle None bounds.
569569
internal_lb, internal_ub = get_internal_bounds(
570-
params, bounds=bounds, propagate_none=False
570+
params, bounds=bounds, propagate_none_in_fast_path=False
571571
)
572572

573573
# handle kwargs

src/optimagic/parameters/bounds.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_internal_bounds(
7676
bounds: Bounds | None = None,
7777
registry: PyTreeRegistry | None = None,
7878
add_soft_bounds: bool = False,
79-
propagate_none: bool = True,
79+
propagate_none_in_fast_path: bool = True,
8080
) -> tuple[NDArray[np.float64] | None, NDArray[np.float64] | None]:
8181
"""Create consolidated and flattened bounds for params.
8282
@@ -97,9 +97,9 @@ def get_internal_bounds(
9797
add_soft_bounds: If True, the element-wise maximum (minimum) of the lower and
9898
soft_lower (upper and soft_upper) bounds are taken. If False, the lower
9999
(upper) bounds are returned.
100-
propagate_none: If True, None-valued lower and upper bounds are propagated to
101-
the output. If False, None values are replaced with -np.inf for the lower
102-
bound and np.inf for the upper bound.
100+
propagate_none_in_fast_path: If True, None-valued lower and upper bounds are
101+
propagated to the output in the fast path case. If False, None values are
102+
replaced with -np.inf for the lower bound and np.inf for the upper bound.
103103
104104
Returns:
105105
Consolidated and flattened lower_bounds.
@@ -117,7 +117,7 @@ def get_internal_bounds(
117117
return _get_fast_path_bounds(
118118
params=params,
119119
bounds=bounds,
120-
propagate_none=propagate_none,
120+
propagate_none=propagate_none_in_fast_path,
121121
)
122122

123123
# In the slow path, None bounds are currently not propagated, but replaced with

src/optimagic/parameters/tree_conversion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_tree_converter(
5454
params=params,
5555
bounds=bounds,
5656
registry=_registry,
57-
propagate_none=False,
57+
propagate_none_in_fast_path=False,
5858
)
5959

6060
if add_soft_bounds:
@@ -63,7 +63,7 @@ def get_tree_converter(
6363
bounds=bounds,
6464
registry=_registry,
6565
add_soft_bounds=add_soft_bounds,
66-
propagate_none=True,
66+
propagate_none_in_fast_path=False,
6767
)
6868
else:
6969
_soft_lower, _soft_upper = None, None

tests/optimagic/parameters/test_bounds.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ def test_get_bounds_with_upper_bounds(pytree_params):
121121

122122

123123
def test_get_bounds_numpy_propagate_none_true(array_params):
124-
got_lower, got_upper = get_internal_bounds(array_params, propagate_none=True)
124+
got_lower, got_upper = get_internal_bounds(
125+
array_params, propagate_none_in_fast_path=True
126+
)
125127

126128
assert got_lower is None
127129
assert got_upper is None
128130

129131

130132
def test_get_bounds_numpy_propagate_none_false(array_params):
131-
got_lower, got_upper = get_internal_bounds(array_params, propagate_none=False)
133+
got_lower, got_upper = get_internal_bounds(
134+
array_params, propagate_none_in_fast_path=False
135+
)
132136

133137
expected = np.array([np.inf, np.inf])
134138

0 commit comments

Comments
 (0)