From 525456b4f0ef373c36a85e2e7a2e201545cf836f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:18:12 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.5.0) - [github.com/PyCQA/isort: 5.12.0 → 5.13.2](https://github.com/PyCQA/isort/compare/5.12.0...5.13.2) - [github.com/asottile/pyupgrade: v2.37.1 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v2.37.1...v3.15.0) - [github.com/psf/black: 22.6.0 → 23.12.1](https://github.com/psf/black/compare/22.6.0...23.12.1) - [github.com/PyCQA/pylint: v2.14.5 → v3.0.3](https://github.com/PyCQA/pylint/compare/v2.14.5...v3.0.3) - [github.com/MarcoGorelli/madforhooks: 0.3.0 → 0.4.1](https://github.com/MarcoGorelli/madforhooks/compare/0.3.0...0.4.1) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6db4796..6d254cda 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-toml @@ -11,28 +11,28 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort - repo: https://github.com/asottile/pyupgrade - rev: v2.37.1 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 23.12.1 hooks: - id: black - id: black-jupyter - repo: https://github.com/PyCQA/pylint - rev: v2.14.5 + rev: v3.0.3 hooks: - id: pylint args: [--rcfile=.pylintrc] files: ^pymc_experimental/ - repo: https://github.com/MarcoGorelli/madforhooks - rev: 0.3.0 + rev: 0.4.1 hooks: - id: no-print-statements exclude: _version.py From 0dcc0c7cdf4d0b577b889ee3c33e2dc1eae9cf79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:19:41 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- notebooks/discrete_markov_chain.ipynb | 1 - pymc_experimental/inference/pathfinder.py | 1 - pymc_experimental/statespace/filters/utilities.py | 1 - pymc_experimental/statespace/models/VARMAX.py | 1 - pymc_experimental/statespace/models/structural.py | 1 - pymc_experimental/tests/model/test_marginal_model.py | 7 ++++++- pymc_experimental/tests/statespace/test_SARIMAX.py | 4 ++-- pymc_experimental/tests/statespace/test_structural.py | 8 ++++---- pymc_experimental/tests/test_pathfinder.py | 1 - pymc_experimental/utils/linear_cg.py | 2 -- pymc_experimental/utils/pytensorf.py | 1 - setup.py | 1 - 12 files changed, 12 insertions(+), 17 deletions(-) diff --git a/notebooks/discrete_markov_chain.ipynb b/notebooks/discrete_markov_chain.ipynb index b2321c14..8204b3f1 100644 --- a/notebooks/discrete_markov_chain.ipynb +++ b/notebooks/discrete_markov_chain.ipynb @@ -568,7 +568,6 @@ " ar_coefs = pm.Normal(\"coefs\", size=order, dims=[\"ar_params\"])\n", "\n", " def AR_step(s, L1_s, L2_s, L3_s, L4_s, L1_y, L2_y, L3_y, L4_y, mus, phis):\n", - "\n", " y_out = (\n", " mus[s]\n", " + phis[0] * (L1_y - mus[L1_s])\n", diff --git a/pymc_experimental/inference/pathfinder.py b/pymc_experimental/inference/pathfinder.py index 2063e950..5e5533dd 100644 --- a/pymc_experimental/inference/pathfinder.py +++ b/pymc_experimental/inference/pathfinder.py @@ -35,7 +35,6 @@ def convert_flat_trace_to_idata( postprocessing_backend="cpu", model=None, ): - model = modelcontext(model) ip = model.initial_point() ip_point_map_info = pm.blocking.DictToArrayBijection.map(ip).point_map_info diff --git a/pymc_experimental/statespace/filters/utilities.py b/pymc_experimental/statespace/filters/utilities.py index 24e76e45..cd1af6a3 100644 --- a/pymc_experimental/statespace/filters/utilities.py +++ b/pymc_experimental/statespace/filters/utilities.py @@ -40,7 +40,6 @@ def split_vars_into_seq_and_nonseq(params, param_names): seq_names, non_seq_names = [], [] for param, name in zip(params, param_names): - if decide_if_x_time_varies(param, name): sequences.append(param) seq_names.append(name) diff --git a/pymc_experimental/statespace/models/VARMAX.py b/pymc_experimental/statespace/models/VARMAX.py index 544a2f39..fb4ff451 100644 --- a/pymc_experimental/statespace/models/VARMAX.py +++ b/pymc_experimental/statespace/models/VARMAX.py @@ -148,7 +148,6 @@ def __init__( measurement_error: bool = False, verbose=True, ): - if (endog_names is None) and (k_endog is None): raise ValueError("Must specify either endog_names or k_endog") if (endog_names is not None) and (k_endog is None): diff --git a/pymc_experimental/statespace/models/structural.py b/pymc_experimental/statespace/models/structural.py index bc8f4c42..7def3f0d 100644 --- a/pymc_experimental/statespace/models/structural.py +++ b/pymc_experimental/statespace/models/structural.py @@ -1534,7 +1534,6 @@ def _get_state_names(self, k_exog, state_names, name): return k_exog, state_names def _handle_input_data(self, k_exog: int, state_names: Optional[List[str]], name) -> int: - k_exog, state_names = self._get_state_names(k_exog, state_names, name) self.state_names = state_names diff --git a/pymc_experimental/tests/model/test_marginal_model.py b/pymc_experimental/tests/model/test_marginal_model.py index b667635c..c7668b17 100644 --- a/pymc_experimental/tests/model/test_marginal_model.py +++ b/pymc_experimental/tests/model/test_marginal_model.py @@ -54,7 +54,12 @@ def test_marginalized_bernoulli_logp(): idx = pm.Bernoulli.dist(0.7, name="idx") y = pm.Normal.dist(mu=mu[idx], sigma=1.0, name="y") - marginal_rv_node = FiniteDiscreteMarginalRV([mu], [idx, y], ndim_supp=None, n_updates=0,)( + marginal_rv_node = FiniteDiscreteMarginalRV( + [mu], + [idx, y], + ndim_supp=None, + n_updates=0, + )( mu )[0].owner diff --git a/pymc_experimental/tests/statespace/test_SARIMAX.py b/pymc_experimental/tests/statespace/test_SARIMAX.py index 4d206076..c02cbed4 100644 --- a/pymc_experimental/tests/statespace/test_SARIMAX.py +++ b/pymc_experimental/tests/statespace/test_SARIMAX.py @@ -339,7 +339,7 @@ def test_interpretable_states_are_interpretable(arima_mod_interp, pymc_mod_inter ma_lags = prior.prior.coords["ma_lag"].values - 1 # Check the first p states are lags of the previous state - for (t, tm1) in zip(ar_lags[1:], ar_lags[:-1]): + for t, tm1 in zip(ar_lags[1:], ar_lags[:-1]): assert_allclose( prior_outputs.prior_latent.isel(state=t).values[1:], prior_outputs.prior_latent.isel(state=tm1).values[:-1], @@ -348,7 +348,7 @@ def test_interpretable_states_are_interpretable(arima_mod_interp, pymc_mod_inter # Check the next p+q states are lags of the innovations n = len(ar_lags) - for (t, tm1) in zip(ma_lags[1:], ma_lags[:-1]): + for t, tm1 in zip(ma_lags[1:], ma_lags[:-1]): assert_allclose( prior_outputs.prior_latent.isel(state=n + t).values[1:], prior_outputs.prior_latent.isel(state=n + tm1).values[:-1], diff --git a/pymc_experimental/tests/statespace/test_structural.py b/pymc_experimental/tests/statespace/test_structural.py index d65ac972..f9267c03 100644 --- a/pymc_experimental/tests/statespace/test_structural.py +++ b/pymc_experimental/tests/statespace/test_structural.py @@ -177,8 +177,8 @@ def create_structural_model_and_equivalent_statsmodel( params = {} sm_params = {} sm_init = {} - expected_param_dims = defaultdict(lambda: ()) - expected_coords = defaultdict(lambda: []) + expected_param_dims = defaultdict(tuple) + expected_coords = defaultdict(list) expected_param_dims["P0"] += ("state", "state_aux") default_states = [ @@ -727,7 +727,7 @@ def test_add_components(): se_mats = [se_T, se_R, se_Q] all_mats = [T, R, Q] - for (ll_mat, se_mat, all_mat) in zip(ll_mats, se_mats, all_mats): + for ll_mat, se_mat, all_mat in zip(ll_mats, se_mats, all_mats): assert_allclose(all_mat, linalg.block_diag(ll_mat, se_mat), atol=ATOL, rtol=RTOL) ll_mats = [ll_x0, ll_c, ll_Z] @@ -735,7 +735,7 @@ def test_add_components(): all_mats = [x0, c, Z] axes = [0, 0, 1] - for (ll_mat, se_mat, all_mat, axis) in zip(ll_mats, se_mats, all_mats, axes): + for ll_mat, se_mat, all_mat, axis in zip(ll_mats, se_mats, all_mats, axes): assert_allclose(all_mat, np.concatenate([ll_mat, se_mat], axis=axis), atol=ATOL, rtol=RTOL) diff --git a/pymc_experimental/tests/test_pathfinder.py b/pymc_experimental/tests/test_pathfinder.py index 7dacdb84..3ddd4a4f 100644 --- a/pymc_experimental/tests/test_pathfinder.py +++ b/pymc_experimental/tests/test_pathfinder.py @@ -29,7 +29,6 @@ def test_pathfinder(): sigma = np.array([15.0, 10.0, 16.0, 11.0, 9.0, 11.0, 10.0, 18.0]) with pm.Model() as model: - mu = pm.Normal("mu", mu=0.0, sigma=10.0) tau = pm.HalfCauchy("tau", 5.0) diff --git a/pymc_experimental/utils/linear_cg.py b/pymc_experimental/utils/linear_cg.py index 43335c78..49457cad 100644 --- a/pymc_experimental/utils/linear_cg.py +++ b/pymc_experimental/utils/linear_cg.py @@ -28,7 +28,6 @@ def masked_fill(vector, mask, fill_value): def linear_cg_updates( result, alpha, residual_inner_prod, eps, beta, residual, precond_residual, curr_conjugate_vec ): - # Everything inside _jit_linear_cg_updates result = result + alpha * curr_conjugate_vec beta = np.copy(residual_inner_prod) @@ -68,7 +67,6 @@ def linear_cg( terminate_cg_by_size=False, use_eval_tolerange=False, ): - if initial_guess is None: initial_guess = np.zeros_like(rhs) diff --git a/pymc_experimental/utils/pytensorf.py b/pymc_experimental/utils/pytensorf.py index a953b5c1..d6322caa 100644 --- a/pymc_experimental/utils/pytensorf.py +++ b/pymc_experimental/utils/pytensorf.py @@ -36,7 +36,6 @@ class StringConstant(Constant): @pytensor._as_symbolic.register(str) def as_symbolic_string(x, **kwargs): - return StringConstant(stringtype, x) diff --git a/setup.py b/setup.py index 4713ea59..0aa8206b 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,6 @@ def read_version(): if __name__ == "__main__": - setup( name="pymc-experimental", version=read_version(),