Skip to content

Commit

Permalink
CLN: Fix black/flake8 minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Apr 16, 2024
1 parent 598ab21 commit a88a1f2
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 29 deletions.
1 change: 0 additions & 1 deletion examples/16_noise_robustness/utils.py
Expand Up @@ -169,7 +169,6 @@ def make_test_trajectories(
all_t_test = dict()

for i, equation_name in enumerate(systems_list):

dimension = all_properties[equation_name]["embedding_dimension"]
all_sols_test[equation_name] = np.zeros((n, n_trajectories, dimension))
all_t_test[equation_name] = np.zeros((n, n_trajectories))
Expand Down
8 changes: 4 additions & 4 deletions examples/17_parameterized_pattern_formation/utils.py
Expand Up @@ -38,7 +38,7 @@ def get_lorenz_trajectories(sigmas, rhos, betas, dt):
x0_train,
args=(sigmas[i], betas[i], rhos[i]),
t_eval=t_train,
**integrator_keywords
**integrator_keywords,
).y.T
x_trains = x_trains + [x_train]
t_trains = t_trains + [t_train]
Expand Down Expand Up @@ -966,7 +966,7 @@ def oregonator(
args=(b,),
y0=ut,
first_step=dt,
**integrator_keywords
**integrator_keywords,
)
if not usol.success:
print(usol.message)
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def oregonator_homogeneous(
args=(b,),
y0=ut,
first_step=dt,
**integrator_keywords
**integrator_keywords,
)
dt = np.diff(usol.t)[-1]
ut = usol.y[:, -1]
Expand Down Expand Up @@ -1267,7 +1267,7 @@ def cgle_homogeneous(t, u):
(t[i], t[i + 1]),
y0=ut,
first_step=dt,
**integrator_keywords
**integrator_keywords,
)
# print(usol.message,end='\r')
dt = np.diff(usol.t)[-1]
Expand Down
1 change: 0 additions & 1 deletion pysindy/differentiation/finite_difference.py
Expand Up @@ -66,7 +66,6 @@ def __init__(
drop_endpoints=False,
periodic=False,
):

if order <= 0 or not isinstance(order, int):
raise ValueError("order must be a positive int")
if d <= 0:
Expand Down
3 changes: 2 additions & 1 deletion pysindy/feature_library/polynomial_library.py
@@ -1,6 +1,7 @@
from itertools import chain
from math import comb
from typing import Iterator
from typing import Tuple

import numpy as np
from numpy.typing import NDArray
Expand Down Expand Up @@ -80,7 +81,7 @@ def _combinations(
include_interaction: bool,
interaction_only: bool,
include_bias: bool,
) -> Iterator[tuple[int, ...]]:
) -> Iterator[Tuple[int, ...]]:
"""
Create selection tuples of input indexes for each polynomail term
Expand Down
1 change: 0 additions & 1 deletion pysindy/feature_library/sindy_pi_library.py
Expand Up @@ -393,7 +393,6 @@ def transform(self, x_full):
f_dot.__code__.co_argcount,
self.interaction_only,
):

for i, f in enumerate(self.x_functions):
for f_combs in self._combinations(
n_input_features,
Expand Down
3 changes: 0 additions & 3 deletions pysindy/feature_library/weak_pde_library.py
Expand Up @@ -457,7 +457,6 @@ def _set_up_weights(self):
deriv = np.zeros(self.grid_ndim)
deriv[-1] = 1
for k in range(self.K):

ret = np.ones(shapes_k[k])
for i in range(self.grid_ndim):
s = [0] * (self.grid_ndim + 1)
Expand All @@ -476,7 +475,6 @@ def _set_up_weights(self):
# Product weights over the axes for pure derivative terms, shaped as inds_k
self.fullweights0 = []
for k in range(self.K):

ret = np.ones(shapes_k[k])
for i in range(self.grid_ndim):
s = [0] * (self.grid_ndim + 1)
Expand Down Expand Up @@ -922,7 +920,6 @@ def transform(self, x_full):
for deriv in derivs[
np.where(np.all(derivs <= derivs_mixed, axis=1))[0]
]:

# indices for product rule terms
j0 = np.where(np.all(derivs == deriv, axis=1))[0][0]
j1 = np.where(
Expand Down
1 change: 0 additions & 1 deletion pysindy/optimizers/sbr.py
Expand Up @@ -99,7 +99,6 @@ def __init__(
unbias: bool = False,
**kwargs,
):

if unbias:
raise ValueError("SBR is incompatible with unbiasing. Set unbias=False")

Expand Down
1 change: 0 additions & 1 deletion pysindy/optimizers/trapping_sr3.py
Expand Up @@ -539,7 +539,6 @@ def _reduce(self, x, y):
# Begin optimization loop
self.objective_history_ = []
for k in range(self.max_iter):

# update P tensor from the newest trap center
mPQ = np.tensordot(trap_ctr, self.PQ_, axes=([0], [0]))
p = self.PL_ - mPQ
Expand Down
2 changes: 0 additions & 2 deletions pysindy/utils/axes.py
Expand Up @@ -430,7 +430,6 @@ def decorator(func):
return decorator



@_implements(np.ravel)
def ravel(a, order="C"):
out = np.ravel(np.asarray(a), order=order)
Expand All @@ -455,7 +454,6 @@ def concatenate(arrays, axis=0, out=None, dtype=None, casting="same_kind"):
ax_list = [obj.axes for obj in arrays if isinstance(obj, AxesArray)]
for ax1, ax2 in zip(ax_list[:-1], ax_list[1:]):
if ax1 != ax2:

raise ValueError("Concatenating >1 AxesArray with incompatible axes")
result = np.concatenate(parents, axis, out=out, dtype=dtype, casting=casting)
if isinstance(out, AxesArray):
Expand Down
1 change: 1 addition & 0 deletions pysindy/utils/odes.py
Expand Up @@ -334,6 +334,7 @@ def burgers_galerkin(sigma=0.1, nu=0.025, U=1.0):
# Below this line are models only suitable for SINDy-PI, since they are implicit #
# and therefore require a library Theta(X, Xdot) rather than just Theta(X) #


# Michaelis–Menten model for enzyme kinetics
def enzyme(t, x, jx=0.6, Vmax=1.5, Km=0.3):
return jx - Vmax * x / (Km + x)
Expand Down
7 changes: 0 additions & 7 deletions test/conftest.py
Expand Up @@ -60,7 +60,6 @@ def data_1d_bad_shape():

@pytest.fixture(scope="session")
def data_lorenz():

t = np.linspace(0, 1, 12)
x0 = [8, 27, -7]
x = solve_ivp(lorenz, (t[0], t[-1]), x0, t_eval=t).y.T
Expand All @@ -70,7 +69,6 @@ def data_lorenz():

@pytest.fixture
def data_multiple_trajectories():

n_points = [100, 200, 500]
initial_conditions = [
[8, 27, -7],
Expand Down Expand Up @@ -120,7 +118,6 @@ def diffuse(t, u, dx, nx):

@pytest.fixture(scope="session")
def data_discrete_time():

n_steps = 100
mu = 3.6
x = np.zeros((n_steps))
Expand All @@ -133,7 +130,6 @@ def data_discrete_time():

@pytest.fixture(scope="session")
def data_discrete_time_multiple_trajectories():

n_steps = 100
mus = [1, 2.3, 3.6]
x = [np.zeros((n_steps)) for mu in mus]
Expand Down Expand Up @@ -421,7 +417,6 @@ def u_fun(t):

@pytest.fixture(scope="session")
def data_discrete_time_c():

n_steps = 100
mu = 3.6

Expand All @@ -437,7 +432,6 @@ def data_discrete_time_c():

@pytest.fixture(scope="session")
def data_discrete_time_c_multivariable():

n_steps = 100
mu = 3.6

Expand All @@ -454,7 +448,6 @@ def data_discrete_time_c_multivariable():

@pytest.fixture(scope="session")
def data_discrete_time_multiple_trajectories_c():

n_steps = 100
mus = [1, 2.3, 3.6]
u = [0.001 * np.random.randn(n_steps) for mu in mus]
Expand Down
7 changes: 0 additions & 7 deletions test/utils/test_axes.py
Expand Up @@ -29,13 +29,6 @@ def test_bad_concat():
np.concatenate((arr, arr2), axis=0)


def test_concat_out():
arr = AxesArray(np.arange(3).reshape(1, 3), {"ax_a": 0, "ax_b": 1})
arr_out = np.empty((2, 3)).view(AxesArray)
result = np.concatenate((arr, arr), axis=0, out=arr_out)
assert_equal(result, arr_out)


def test_reduce_mean_noinf_recursion():
arr = AxesArray(np.array([[1]]), {"ax_a": [0, 1]})
np.mean(arr, axis=0)
Expand Down

0 comments on commit a88a1f2

Please sign in to comment.