pysindy.utils package

Submodules

pysindy.utils.axes module

class pysindy.utils.axes.AxesArray(input_array, axes)[source]

Bases: NDArrayOperatorsMixin, ndarray

A numpy-like array that keeps track of the meaning of its axes.

Parameters
  • input_array (array-like) – the data to create the array.

  • axes (dict) – A dictionary of axis labels to shape indices. Allowed keys: - ax_time: int - ax_coord: int - ax_sample: int - ax_spatial: List[int]

Raises

AxesWarning if axes does not match shape of input_array

property n_spatial
property n_time
property n_sample
property n_coord
pysindy.utils.axes.implements(numpy_function)[source]

Register an __array_function__ implementation for MyArray objects.

pysindy.utils.axes.concatenate(arrays, axis=0)[source]
pysindy.utils.axes.comprehend_axes(x)[source]
class pysindy.utils.axes.SampleConcatter[source]

Bases: TransformerMixin

fit(x_list, y_list)[source]
transform(x_list)[source]
pysindy.utils.axes.concat_sample_axis(x_list: List[AxesArray])[source]

Concatenate all trajectories and axes used to create samples.

pysindy.utils.axes.wrap_axes(axes: dict, obj)[source]

Add axes to object (usually, a sparse matrix)

pysindy.utils.base module

pysindy.utils.base.flatten_2d_tall(x)[source]
pysindy.utils.base.validate_input(x, t=<object object>)[source]

Forces input data to have compatible dimensions, if possible.

Parameters
  • x – array of input data (measured coordinates across time)

  • t – time values for measurements.

Returns

x as 2D array, with time dimension on first axis and coordinate index on second axis.

pysindy.utils.base.validate_no_reshape(x, t=<object object>)[source]

Check types and numerical sensibility of arguments.

Parameters
  • x – array of input data (measured coordinates across time)

  • t – time values for measurements.

Returns

x as 2D array, with time dimension on first axis and coordinate index on second axis.

pysindy.utils.base.validate_control_variables(x, u, trim_last_point=False)[source]

Ensure that control variables u are compatible with the data x.

Trims last control variable timepoint if set to True

pysindy.utils.base.drop_nan_samples(x, y)[source]

Drops samples from x and y where there is either has a nan value

pysindy.utils.base.reorder_constraints(c, n_features, output_order='row')[source]

Reorder constraint matrix.

pysindy.utils.base.prox_l0(x, threshold)[source]

Proximal operator for L0 regularization.

pysindy.utils.base.prox_weighted_l0(x, thresholds)[source]

Proximal operator for weighted l0 regularization.

pysindy.utils.base.prox_l1(x, threshold)[source]

Proximal operator for L1 regularization.

pysindy.utils.base.prox_weighted_l1(x, thresholds)[source]

Proximal operator for weighted l1 regularization.

pysindy.utils.base.prox_l2(x, threshold)[source]

Proximal operator for ridge regularization.

pysindy.utils.base.prox_weighted_l2(x, thresholds)[source]

Proximal operator for ridge regularization.

pysindy.utils.base.prox_cad(x, lower_threshold)[source]

Proximal operator for CAD regularization

prox_cad(z, a, b) =
    0                    if |z| < a
    sign(z)(|z| - a)   if a < |z| <= b
    z                    if |z| > b

Entries of \(x\) smaller than a in magnitude are set to 0, entries with magnitudes larger than b are untouched, and entries in between have soft-thresholding applied.

For simplicity we set \(b = 5*a\) in this implementation.

pysindy.utils.base.get_prox(regularization)[source]
pysindy.utils.base.get_regularization(regularization)[source]
pysindy.utils.base.capped_simplex_projection(trimming_array, trimming_fraction)[source]

Projection of trimming_array onto the capped simplex

pysindy.utils.base.print_model(coef, input_features, errors=None, intercept=None, error_intercept=None, precision=3, pm='±')[source]
Parameters
  • coef

  • input_features

  • errors

  • intercept

  • sigma_intercept

  • precision

  • pm

Returns:

pysindy.utils.base.equations(pipeline, input_features=None, precision=3, input_fmt=None)[source]
pysindy.utils.base.supports_multiple_targets(estimator)[source]

Checks whether estimator supports multiple targets.

pysindy.utils.odes module

pysindy.utils.odes.linear_damped_SHO(t, x)[source]
pysindy.utils.odes.cubic_damped_SHO(t, x)[source]
pysindy.utils.odes.linear_3D(t, x)[source]
pysindy.utils.odes.van_der_pol(t, x, p=[0.5])[source]
pysindy.utils.odes.duffing(t, x, p=[0.2, 0.05, 1])[source]
pysindy.utils.odes.lotka(t, x, p=[1, 10])[source]
pysindy.utils.odes.cubic_oscillator(t, x, p=[-0.1, 2, -2, -0.1])[source]
pysindy.utils.odes.rossler(t, x, p=[0.2, 0.2, 5.7])[source]
pysindy.utils.odes.hopf(t, x, mu=-0.05, omega=1, A=1)[source]
pysindy.utils.odes.logistic_map(x, mu)[source]
pysindy.utils.odes.logistic_map_control(x, mu, u)[source]
pysindy.utils.odes.logistic_map_multicontrol(x, mu, u)[source]
pysindy.utils.odes.lorenz(t, x, sigma=10, beta=2.66667, rho=28)[source]
pysindy.utils.odes.lorenz_u(t)[source]
pysindy.utils.odes.lorenz_control(t, x, u_fun, sigma=10, beta=2.66667, rho=28)[source]
pysindy.utils.odes.meanfield(t, x, mu=0.01)[source]
pysindy.utils.odes.oscillator(t, x, mu1=0.05, mu2=-0.01, omega=3.0, alpha=-2.0, beta=-5.0, sigma=1.1)[source]
pysindy.utils.odes.mhd(t, x, nu=0.0, mu=0.0, sigma=0.0)[source]
pysindy.utils.odes.burgers_galerkin(sigma=0.1, nu=0.025, U=1.0)[source]
pysindy.utils.odes.enzyme(t, x, jx=0.6, Vmax=1.5, Km=0.3)[source]
pysindy.utils.odes.bacterial(t, x, a1=0.004, a2=0.07, a3=0.04, b1=0.82, b2=1854.5)[source]
pysindy.utils.odes.yeast(t, x, c1=2.5, c2=-100, c3=13.6769, d1=200, d2=13.6769, d3=-6, d4=-6, e1=6, e2=-64, e3=6, e4=16, f1=64, f2=-13, f3=13, f4=-16, f5=-100, g1=1.3, g2=-3.1, h1=-200, h2=13.6769, h3=128, h4=-1.28, h5=-32, j1=6, j2=-18, j3=-100)[source]
pysindy.utils.odes.pendulum_on_cart(t, x, m=1, M=1, L=1, F=0, g=9.81)[source]
pysindy.utils.odes.f_steer(x, u, min_sangle=-0.91, max_sangle=0.91, min_svel=-0.4, max_svel=0.4, min_vel=-13.9, max_vel=45.8, switch_vel=4.755, amax=11.5)[source]
pysindy.utils.odes.f_acc(y, u, min_sangle=-0.91, max_sangle=0.91, min_svel=-0.4, max_svel=0.4, min_vel=-13.9, max_vel=45.8, switch_vel=4.755, amax=11.5)[source]
pysindy.utils.odes.kinematic_commonroad(t, x, u_fun, amax=11.5, lwb=2.391)[source]
pysindy.utils.odes.double_pendulum(t, x, m1=0.2704, m2=0.2056, a1=0.191, a2=0.1621, L1=0.2667, L2=0.2667, I1=0.003, I2=0.0011, g=9.81, k1=0, k2=0)[source]

Module contents

class pysindy.utils.AxesArray(input_array, axes)[source]

Bases: NDArrayOperatorsMixin, ndarray

A numpy-like array that keeps track of the meaning of its axes.

Parameters
  • input_array (array-like) – the data to create the array.

  • axes (dict) – A dictionary of axis labels to shape indices. Allowed keys: - ax_time: int - ax_coord: int - ax_sample: int - ax_spatial: List[int]

Raises

AxesWarning if axes does not match shape of input_array

property n_spatial
property n_time
property n_sample
property n_coord
class pysindy.utils.SampleConcatter[source]

Bases: TransformerMixin

fit(x_list, y_list)[source]
transform(x_list)[source]
pysindy.utils.concat_sample_axis(x_list: List[AxesArray])[source]

Concatenate all trajectories and axes used to create samples.

pysindy.utils.wrap_axes(axes: dict, obj)[source]

Add axes to object (usually, a sparse matrix)

pysindy.utils.comprehend_axes(x)[source]
pysindy.utils.capped_simplex_projection(trimming_array, trimming_fraction)[source]

Projection of trimming_array onto the capped simplex

pysindy.utils.drop_nan_samples(x, y)[source]

Drops samples from x and y where there is either has a nan value

pysindy.utils.equations(pipeline, input_features=None, precision=3, input_fmt=None)[source]
pysindy.utils.get_prox(regularization)[source]
pysindy.utils.get_regularization(regularization)[source]
pysindy.utils.print_model(coef, input_features, errors=None, intercept=None, error_intercept=None, precision=3, pm='±')[source]
Parameters
  • coef

  • input_features

  • errors

  • intercept

  • sigma_intercept

  • precision

  • pm

Returns:

pysindy.utils.prox_cad(x, lower_threshold)[source]

Proximal operator for CAD regularization

prox_cad(z, a, b) =
    0                    if |z| < a
    sign(z)(|z| - a)   if a < |z| <= b
    z                    if |z| > b

Entries of \(x\) smaller than a in magnitude are set to 0, entries with magnitudes larger than b are untouched, and entries in between have soft-thresholding applied.

For simplicity we set \(b = 5*a\) in this implementation.

pysindy.utils.prox_l0(x, threshold)[source]

Proximal operator for L0 regularization.

pysindy.utils.prox_weighted_l0(x, thresholds)[source]

Proximal operator for weighted l0 regularization.

pysindy.utils.prox_l1(x, threshold)[source]

Proximal operator for L1 regularization.

pysindy.utils.prox_weighted_l1(x, thresholds)[source]

Proximal operator for weighted l1 regularization.

pysindy.utils.prox_l2(x, threshold)[source]

Proximal operator for ridge regularization.

pysindy.utils.prox_weighted_l2(x, thresholds)[source]

Proximal operator for ridge regularization.

pysindy.utils.reorder_constraints(c, n_features, output_order='row')[source]

Reorder constraint matrix.

pysindy.utils.supports_multiple_targets(estimator)[source]

Checks whether estimator supports multiple targets.

pysindy.utils.validate_control_variables(x, u, trim_last_point=False)[source]

Ensure that control variables u are compatible with the data x.

Trims last control variable timepoint if set to True

pysindy.utils.validate_input(x, t=<object object>)[source]

Forces input data to have compatible dimensions, if possible.

Parameters
  • x – array of input data (measured coordinates across time)

  • t – time values for measurements.

Returns

x as 2D array, with time dimension on first axis and coordinate index on second axis.

pysindy.utils.validate_no_reshape(x, t=<object object>)[source]

Check types and numerical sensibility of arguments.

Parameters
  • x – array of input data (measured coordinates across time)

  • t – time values for measurements.

Returns

x as 2D array, with time dimension on first axis and coordinate index on second axis.

pysindy.utils.flatten_2d_tall(x)[source]
pysindy.utils.linear_damped_SHO(t, x)[source]
pysindy.utils.cubic_damped_SHO(t, x)[source]
pysindy.utils.linear_3D(t, x)[source]
pysindy.utils.lotka(t, x, p=[1, 10])[source]
pysindy.utils.van_der_pol(t, x, p=[0.5])[source]
pysindy.utils.duffing(t, x, p=[0.2, 0.05, 1])[source]
pysindy.utils.rossler(t, x, p=[0.2, 0.2, 5.7])[source]
pysindy.utils.cubic_oscillator(t, x, p=[-0.1, 2, -2, -0.1])[source]
pysindy.utils.hopf(t, x, mu=-0.05, omega=1, A=1)[source]
pysindy.utils.lorenz(t, x, sigma=10, beta=2.66667, rho=28)[source]
pysindy.utils.lorenz_control(t, x, u_fun, sigma=10, beta=2.66667, rho=28)[source]
pysindy.utils.lorenz_u(t)[source]
pysindy.utils.meanfield(t, x, mu=0.01)[source]
pysindy.utils.oscillator(t, x, mu1=0.05, mu2=-0.01, omega=3.0, alpha=-2.0, beta=-5.0, sigma=1.1)[source]
pysindy.utils.burgers_galerkin(sigma=0.1, nu=0.025, U=1.0)[source]
pysindy.utils.mhd(t, x, nu=0.0, mu=0.0, sigma=0.0)[source]
pysindy.utils.enzyme(t, x, jx=0.6, Vmax=1.5, Km=0.3)[source]
pysindy.utils.yeast(t, x, c1=2.5, c2=-100, c3=13.6769, d1=200, d2=13.6769, d3=-6, d4=-6, e1=6, e2=-64, e3=6, e4=16, f1=64, f2=-13, f3=13, f4=-16, f5=-100, g1=1.3, g2=-3.1, h1=-200, h2=13.6769, h3=128, h4=-1.28, h5=-32, j1=6, j2=-18, j3=-100)[source]
pysindy.utils.bacterial(t, x, a1=0.004, a2=0.07, a3=0.04, b1=0.82, b2=1854.5)[source]
pysindy.utils.pendulum_on_cart(t, x, m=1, M=1, L=1, F=0, g=9.81)[source]
pysindy.utils.kinematic_commonroad(t, x, u_fun, amax=11.5, lwb=2.391)[source]
pysindy.utils.double_pendulum(t, x, m1=0.2704, m2=0.2056, a1=0.191, a2=0.1621, L1=0.2667, L2=0.2667, I1=0.003, I2=0.0011, g=9.81, k1=0, k2=0)[source]