Skip to content

Commit 0e76b38

Browse files
committed
fix: move optree to pypi dependencies
1 parent 1415d54 commit 0e76b38

6 files changed

Lines changed: 16 additions & 20 deletions

File tree

pixi.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"sqlalchemy>=2.0",
1616
"annotated-types>=0.4",
1717
"typing-extensions>=4.5",
18+
"optree>=0.19",
1819
]
1920
dynamic = ["version"]
2021
keywords = [
@@ -437,7 +438,6 @@ cma = ">=3.3"
437438
pygad = ">=3.2"
438439
pytorch-cpu = ">=2.2"
439440
ruff = ">=0.15.5,<0.16"
440-
optree = ">=0.19.0,<0.20"
441441

442442
[tool.pixi.pypi-dependencies]
443443
optimagic = { path = ".", editable = true }

src/optimagic/parameters/bounds.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Any, Literal, Sequence
55

66
import numpy as np
7-
import optree
87
from numpy.typing import NDArray
98
from scipy.optimize import Bounds as ScipyBounds
109

@@ -180,20 +179,17 @@ def _update_bounds_and_flatten(
180179
np.ndarray: The updated and flattened bounds.
181180
182181
"""
183-
with optree.dict_insertion_ordered(True, namespace=kind):
184-
flat_nan_tree = tree_leaves(nan_tree, namespace=kind)
182+
flat_nan_tree = tree_leaves(nan_tree, namespace=kind)
185183
if bounds is not None:
186-
with optree.dict_insertion_ordered(True, namespace=VALUE_NAMESPACE):
187-
flat_bounds = tree_leaves(bounds, namespace=VALUE_NAMESPACE)
184+
flat_bounds = tree_leaves(bounds, namespace=VALUE_NAMESPACE)
188185

189186
seperator = 10 * "$"
190-
with optree.dict_insertion_ordered(True, namespace=VALUE_NAMESPACE):
191-
params_names = leaf_names(
192-
nan_tree, namespace=VALUE_NAMESPACE, separator=seperator
193-
)
194-
bounds_names = leaf_names(
195-
bounds, namespace=VALUE_NAMESPACE, separator=seperator
196-
)
187+
params_names = leaf_names(
188+
nan_tree, namespace=VALUE_NAMESPACE, separator=seperator
189+
)
190+
bounds_names = leaf_names(
191+
bounds, namespace=VALUE_NAMESPACE, separator=seperator
192+
)
197193

198194
flat_nan_dict = dict(zip(params_names, flat_nan_tree, strict=False))
199195

src/optimagic/parameters/tree_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _flatten_df(df, data_col):
182182

183183

184184
def _unflatten_df(aux_data, leaves, data_col):
185-
"""Reconstrut a dataframe."""
185+
"""Reconstruct a dataframe."""
186186
if aux_data["is_value_df"]:
187187
out = aux_data["df"].assign(**{data_col: leaves})
188188
else:
@@ -204,7 +204,7 @@ def _flatten_series(series):
204204

205205

206206
def _unflatten_series(aux_data, leaves):
207-
"""Reconstrut a series."""
207+
"""Reconstruct a series."""
208208
return pd.Series(leaves, **aux_data)
209209

210210

src/optimagic/typing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from numpy._typing import NDArray
1919

2020
PyTree = Any
21-
PyTreeRegistry = dict[type | str, dict[str, Callable[[Any], Any]]]
2221
Scalar = Any
2322

2423
T = TypeVar("T")

tests/optimagic/parameters/test_tree_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def test_dict_insertion_ordering_is_respected_for_registered_namespaces():
156156
assert names == ["b_0", "b_1", "a_0", "a_1"]
157157

158158

159-
def test_dict_ordering_is_default_behaviour_is_by_name():
159+
def test_dict_ordering_default_behaviour_is_by_name():
160160
params = {"b": [1, 4], "a": [8, 9]}
161161
leaves, _ = tree_flatten(params)
162162
assert leaves == [8, 9, 1, 4]

0 commit comments

Comments
 (0)