Skip to content

Commit

Permalink
Atone for PyCharm's automatic refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis committed Sep 2, 2024
1 parent c4c4587 commit f596dc6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions desc/optimize/bound_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import functools

import desc.utils
from desc.backend import cond, jit, jnp

from .utils import evaluate_quadratic_form_hess, evaluate_quadratic_form_jac
Expand Down Expand Up @@ -362,7 +361,7 @@ def build_quadratic_1d_hess(H, g, s, diag=None, s0=None):
c : float
Free term. Returned only if `s0` is provided.
"""
a = desc.utils.dot(s)
a = H.dot(s)
if diag is not None:
a += jnp.dot(s * diag, s)
a *= 0.5
Expand Down
5 changes: 2 additions & 3 deletions desc/optimize/tr_subproblems.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np

import desc.utils
from desc.backend import (
cho_factor,
cho_solve,
Expand Down Expand Up @@ -123,7 +122,7 @@ def solve_trust_region_2d_subspace(g, H, trust_radius, initial_alpha=None, **kwa

R, lower = cho_factor(B)
q1 = -cho_solve((R, lower), g)
p1 = desc.utils.dot(q1)
p1 = S.dot(q1)

a = B[0, 0] * trust_radius**2
b = B[0, 1] * trust_radius**2
Expand All @@ -140,7 +139,7 @@ def solve_trust_region_2d_subspace(g, H, trust_radius, initial_alpha=None, **kwa
value = 0.5 * jnp.sum(q2 * B.dot(q2), axis=0) + jnp.dot(g, q2)
i = jnp.argmin(jnp.where(jnp.isnan(value), jnp.inf, value))
q2 = q2[:, i]
p2 = desc.utils.dot(q2)
p2 = S.dot(q2)

out = cond(
jnp.dot(q1, q1) <= trust_radius**2,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pytest
from numpy.random import default_rng

import desc.utils
from desc.backend import jnp
from desc.derivatives import AutoDiffDerivative, FiniteDiffDerivative

Expand Down Expand Up @@ -97,7 +96,7 @@ def test_fd_hessian(self):
g = rando.random(n)

def f(x):
return 5 + g.dot(x) + desc.utils.dot(1 / 2 * A.dot(x))
return 5 + g.dot(x) + x.dot(1 / 2 * A.dot(x))

hess = FiniteDiffDerivative(f, argnum=0, mode="hess")

Expand Down

0 comments on commit f596dc6

Please sign in to comment.