Skip to content

Commit 9323d6a

Browse files
authored
Merge branch 'main' into update-plotly-kaleido
2 parents e20dfa2 + 2418032 commit 9323d6a

4 files changed

Lines changed: 11 additions & 18 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ repos:
6767
- id: yamllint
6868
exclude: tests/optimagic/optimizers/_pounders/fixtures
6969
- repo: https://github.com/PyCQA/docformatter
70-
rev: eb1df34
70+
rev: v1.7.7
7171
hooks:
7272
- id: docformatter
7373
args:
@@ -79,7 +79,7 @@ repos:
7979
- --blank
8080
exclude: src/optimagic/optimization/algo_options.py
8181
- repo: https://github.com/astral-sh/ruff-pre-commit
82-
rev: v0.11.8
82+
rev: v0.12.2
8383
hooks:
8484
# Run the linter.
8585
- id: ruff
@@ -131,7 +131,7 @@ repos:
131131
args:
132132
- --drop-empty-cells
133133
- repo: https://github.com/pre-commit/mirrors-mypy
134-
rev: v1.15.0
134+
rev: v1.14.1
135135
hooks:
136136
- id: mypy
137137
files: src|tests
@@ -143,8 +143,6 @@ repos:
143143
- types-cffi
144144
- types-openpyxl
145145
- types-jinja2
146-
args:
147-
- --config=pyproject.toml
148146
ci:
149147
autoupdate_schedule: monthly
150148
skip:

src/optimagic/deprecations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ def throw_dict_constraints_future_warning_if_required(
371371
if not isinstance(constraints, list):
372372
constraints = [constraints]
373373

374-
types = [
374+
types_or_none = [
375375
constraint.get("type", None) if isinstance(constraint, dict) else None
376376
for constraint in constraints
377377
]
378-
types = list(set(types) - {None})
378+
types = [t for t in types_or_none if t is not None]
379379

380380
if types:
381381
msg = (

src/optimagic/examples/criterion_functions.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,11 @@ def rosenbrock_scalar(params: PyTree) -> float:
105105
def rosenbrock_gradient(params: PyTree) -> PyTree:
106106
"""Calculate gradient of rosenbrock function."""
107107
x = _get_x(params)
108-
l1 = np.delete(x, [-1])
109-
l1 = np.append(l1, 0)
110-
l2 = np.insert(x, 0, 0)
111-
l2 = np.delete(l2, [1])
112-
l3 = np.insert(x, 0, 0)
113-
l3 = np.delete(l3, [-1])
114-
l4 = np.delete(x, [0])
115-
l4 = np.append(l4, 0)
116-
l5 = np.full((len(x) - 1), 2)
117-
l5 = np.append(l5, 0) # type: ignore[assignment]
108+
l1 = np.append(np.delete(x, [-1]), 0)
109+
l2 = np.delete(np.insert(x, 0, 0), [1])
110+
l3 = np.delete(np.insert(x, 0, 0), [-1])
111+
l4 = np.append(np.delete(x, [0]), 0)
112+
l5 = np.append(np.full((len(x) - 1), 2), 0)
118113
flat = 100 * (4 * (l1**3) + 2 * l2 - 2 * (l3**2) - 4 * (l4 * x)) + 2 * l1 - l5
119114
return _unflatten_gradient(flat, params)
120115

src/optimagic/logging/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def _extract_best_history(
242242
best_idx, level="step"
243243
)
244244

245-
def _to_dict(pandas_obj: pd.DataFrame | pd.Series) -> dict[str, Any]: # type:ignore
245+
def _to_dict(pandas_obj: pd.DataFrame | pd.Series) -> dict[str, Any]:
246246
if isinstance(pandas_obj, pd.DataFrame):
247247
result = pandas_obj.to_dict(orient="list")
248248
else:

0 commit comments

Comments
 (0)