Skip to content

Commit

Permalink
Fixed some Flake8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjosegarciaripoll committed Jan 21, 2024
1 parent f12e5d1 commit 9ee3b95
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/seemps/analysis/chebyshev.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
from scipy.fft import dct # type: ignore
from typing import Callable, Optional

from .mesh import ChebyshevZerosInterval, Interval
from .factories import mps_interval
Expand Down
9 changes: 5 additions & 4 deletions src/seemps/analysis/cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def random_initial_indices(
return I_g


def _ones(x):
return np.ones((x, 1), dtype=int)


def sample_initial_indices(state: MPS) -> list[np.ndarray]:
"""
Samples initial indices from a given MPS by performing a sweep of
Expand All @@ -233,7 +237,6 @@ def sample_initial_indices(state: MPS) -> list[np.ndarray]:
I_s = [np.array([[0], [1]]) for _ in range(sites)]
I_le = [np.array([], dtype=int)] * (sites + 1)
I_g = [np.array([], dtype=int)] * (sites + 1)
_ones = lambda x: np.ones((x, 1), dtype=int)

# Forward pass
R = np.ones((1, 1))
Expand Down Expand Up @@ -274,7 +277,7 @@ def sample_tensor_fiber(
i_s: np.ndarray,
i_g: np.ndarray,
) -> np.ndarray:
"""
r"""
Samples the k-th tensor fiber of the underlying MPS representation
of a function from a collection of multi-indices centered at a
given site k. I.e, samples $A\left(J_{\le k-1}, i_k, J_{\g
Expand Down Expand Up @@ -306,7 +309,6 @@ def sample_tensor_fiber(
fiber : np.ndarray
The sampled tensor fiber.
"""
_ones = lambda x: np.ones((x, 1), dtype=int)
r_le = i_le.shape[0] if i_le.size > 0 else 1
r_g = i_g.shape[0] if i_g.size > 0 else 1
s = i_s.shape[0]
Expand Down Expand Up @@ -474,7 +476,6 @@ def get_error(state: MPS):

converged = False
message = f"Maximum number of sweeps {cross_strategy.maxiter} reached"
_ones = lambda x: np.ones((x, 1), dtype=int)

for sweep in range(cross_strategy.maxiter):
start_time = perf_counter()
Expand Down
3 changes: 2 additions & 1 deletion src/seemps/optimization/descent.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def gradient_descent(
converged=False,
message=f"Maximum number of iterations {maxiter} reached",
)
weights: Any = []
for step in range(maxiter + 1):
if step:
if step > 0:
state = simplify(
MPSSum(weights, [state, H_state]), # type: ignore
strategy=normalization_strategy,
Expand Down
3 changes: 1 addition & 2 deletions src/seemps/state/_contractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def _contract_last_and_first2(A: NDArray, B: NDArray) -> NDArray:

try:
from .core import _contract_last_and_first, _contract_nrjl_ijk_klm
except:
raise Exception()
except ImportError:
_contract_last_and_first = _contract_last_and_first2
_contract_nrjl_ijk_klm = _contract_nrjl_ijk_klm2

0 comments on commit 9ee3b95

Please sign in to comment.