Skip to content

Commit c5e4497

Browse files
pymc-botmichaelosthege
pymc-bot
authored andcommitted
⬆️ UPGRADE: Autoupdate pre-commit config
1 parent 9eaf1f2 commit c5e4497

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+8
-94
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ repos:
3434
- id: pyupgrade
3535
args: [--py37-plus]
3636
- repo: https://github.com/psf/black
37-
rev: 22.12.0
37+
rev: 23.1.0
3838
hooks:
3939
- id: black
4040
- id: black-jupyter
4141
- repo: https://github.com/PyCQA/pylint
42-
rev: v2.16.0b1
42+
rev: v2.16.1
4343
hooks:
4444
- id: pylint
4545
args: [--rcfile=.pylintrc]

docs/source/learn/core_notebooks/dimensionality.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,6 @@
16611661
" \"year\": [2020, 2021, 2022],\n",
16621662
" }\n",
16631663
") as pmodel:\n",
1664-
"\n",
16651664
" pm.Normal(\"profit\", dims=\"year\")\n",
16661665
"\n",
16671666
"pm.model_to_graphviz(pmodel)"

docs/source/learn/core_notebooks/model_comparison.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
],
136136
"source": [
137137
"with pm.Model() as pooled:\n",
138-
"\n",
139138
" # Latent pooled effect size\n",
140139
" mu = pm.Normal(\"mu\", 0, sigma=1e6)\n",
141140
"\n",
@@ -242,7 +241,6 @@
242241
],
243242
"source": [
244243
"with pm.Model() as hierarchical:\n",
245-
"\n",
246244
" eta = pm.Normal(\"eta\", 0, 1, shape=J)\n",
247245
" # Hierarchical mean and SD\n",
248246
" mu = pm.Normal(\"mu\", 0, sigma=10)\n",

docs/source/learn/core_notebooks/pymc_overview.ipynb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
"basic_model = pm.Model()\n",
206206
"\n",
207207
"with basic_model:\n",
208-
"\n",
209208
" # Priors for unknown model parameters\n",
210209
" alpha = pm.Normal(\"alpha\", mu=0, sigma=10)\n",
211210
" beta = pm.Normal(\"beta\", mu=0, sigma=10, shape=2)\n",
@@ -3417,7 +3416,6 @@
34173416
"import pytensor.tensor as at\n",
34183417
"\n",
34193418
"with pm.Model(coords={\"predictors\": X.columns.values}) as test_score_model:\n",
3420-
"\n",
34213419
" # Prior on error SD\n",
34223420
" sigma = pm.HalfNormal(\"sigma\", 25)\n",
34233421
"\n",
@@ -3752,7 +3750,6 @@
37523750
],
37533751
"source": [
37543752
"with test_score_model:\n",
3755-
"\n",
37563753
" idata = pm.sample(1000, tune=2000, random_seed=42)"
37573754
]
37583755
},
@@ -3832,7 +3829,6 @@
38323829
],
38333830
"source": [
38343831
"with test_score_model:\n",
3835-
"\n",
38363832
" idata = pm.sample(1000, tune=2000, random_seed=42, target_accept=0.99)"
38373833
]
38383834
},
@@ -4048,7 +4044,6 @@
40484044
],
40494045
"source": [
40504046
"with pm.Model() as disaster_model:\n",
4051-
"\n",
40524047
" switchpoint = pm.DiscreteUniform(\"switchpoint\", lower=years.min(), upper=years.max())\n",
40534048
"\n",
40544049
" # Priors for pre- and post-switch rates number of disasters\n",
@@ -4356,7 +4351,6 @@
43564351
"outputs": [],
43574352
"source": [
43584353
"class Beta(pm.Continuous):\n",
4359-
"\n",
43604354
" rv_op = beta\n",
43614355
"\n",
43624356
" @classmethod\n",

pymc/backends/arviz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def find_observations(model: "Model") -> Dict[str, Var]:
7171

7272
def find_constants(model: "Model") -> Dict[str, Var]:
7373
"""If there are constants available, return them as a dictionary."""
74+
7475
# The constant data vars must be either pm.Data or TensorConstant or SharedVariable
7576
def is_data(name, var, model) -> bool:
7677
observations = find_observations(model)
@@ -174,7 +175,6 @@ def __init__(
174175
save_warmup: Optional[bool] = None,
175176
include_transformed: bool = False,
176177
):
177-
178178
self.save_warmup = rcParams["data.save_warmup"] if save_warmup is None else save_warmup
179179
self.include_transformed = include_transformed
180180
self.trace = trace

pymc/backends/ndarray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def point_list_to_multitrace(
219219
with _model:
220220
chain = NDArray(model=_model, vars=[_model[vn] for vn in varnames])
221221
chain.setup(draws=len(point_list), chain=0)
222+
222223
# since we are simply loading a trace by hand, we need only a vacuous function for
223224
# chain.record() to use. This crushes the default.
224225
def point_fun(point):

pymc/blocking.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
StatsDict: TypeAlias = Dict[str, Any]
3535
StatsType: TypeAlias = List[StatsDict]
3636

37+
3738
# `point_map_info` is a tuple of tuples containing `(name, shape, dtype)` for
3839
# each of the raveled variables.
3940
class RaveledVars(NamedTuple):

pymc/distributions/bound.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ def __new__(
182182
dims=None,
183183
**kwargs,
184184
):
185-
186185
warnings.warn(
187186
"Bound has been deprecated in favor of Truncated, and will be removed in a "
188187
"future release. If Truncated is not an option, Bound can be implemented by"
@@ -234,7 +233,6 @@ def dist(
234233
shape=None,
235234
**kwargs,
236235
):
237-
238236
cls._argument_checks(dist, **kwargs)
239237
lower, upper, initval = cls._set_values(lower, upper, size, shape, initval=None)
240238
dist = ignore_logprob(dist)

pymc/distributions/censored.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def dist(cls, dist, lower, upper, **kwargs):
101101

102102
@classmethod
103103
def rv_op(cls, dist, lower=None, upper=None, size=None):
104-
105104
lower = at.constant(-np.inf) if lower is None else at.as_tensor_variable(lower)
106105
upper = at.constant(np.inf) if upper is None else at.as_tensor_variable(upper)
107106

pymc/distributions/continuous.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def bounded_cont_transform(op, rv, bound_args_indices=None):
171171
raise ValueError(f"Must specify bound_args_indices for {op} bounded distribution")
172172

173173
def transform_params(*args):
174-
175174
lower, upper = None, None
176175
if bound_args_indices[0] is not None:
177176
lower = args[bound_args_indices[0]]
@@ -3474,7 +3473,6 @@ class Interpolated(BoundedContinuous):
34743473

34753474
@classmethod
34763475
def dist(cls, x_points, pdf_points, *args, **kwargs):
3477-
34783476
interp = InterpolatedUnivariateSpline(x_points, pdf_points, k=1, ext="zeros")
34793477

34803478
Z = interp.integral(x_points[0], x_points[-1])

pymc/distributions/distribution.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class DistributionMeta(ABCMeta):
9797
"""
9898

9999
def __new__(cls, name, bases, clsdict):
100-
101100
# Forcefully deprecate old v3 `Distribution`s
102101
if "random" in clsdict:
103102

@@ -453,7 +452,6 @@ class Discrete(Distribution):
453452
"""Base class for discrete distributions"""
454453

455454
def __new__(cls, name, *args, **kwargs):
456-
457455
if kwargs.get("transform", None):
458456
raise ValueError("Transformations for discrete distributions")
459457

@@ -500,7 +498,6 @@ def dist(
500498
dtype: str = "floatX",
501499
**kwargs,
502500
):
503-
504501
dist_params = [as_tensor_variable(param) for param in dist_params]
505502

506503
# Assume scalar ndims_params
@@ -608,7 +605,6 @@ def update(self, node: Node):
608605

609606

610607
class _CustomSymbolicDist(Distribution):
611-
612608
rv_type = CustomSymbolicDistRV
613609

614610
@classmethod

pymc/distributions/mixture.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ def marginal_mixture_logprob(op, values, rng, weights, *components, **kwargs):
358358

359359
@_logcdf.register(MarginalMixtureRV)
360360
def marginal_mixture_logcdf(op, value, rng, weights, *components, **kwargs):
361-
362361
# single component
363362
if len(components) == 1:
364363
# Need to broadcast value across mixture axis

pymc/distributions/multivariate.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ def make_node(self, rng, size, dtype, nu, mu, cov):
310310
return super().make_node(rng, size, dtype, nu, mu, cov)
311311

312312
def __call__(self, nu, mu=None, cov=None, size=None, **kwargs):
313-
314313
dtype = pytensor.config.floatX if self.dtype == "floatX" else self.dtype
315314

316315
if mu is None:
@@ -326,7 +325,6 @@ def _supp_shape_from_params(self, dist_params, rep_param_idx=1, param_shapes=Non
326325

327326
@classmethod
328327
def rng_fn(cls, rng, nu, mu, cov, size):
329-
330328
mv_samples = multivariate_normal.rng_fn(rng=rng, mean=np.zeros_like(mu), cov=cov, size=size)
331329

332330
# Take chi2 draws and add an axis of length 1 to the right for correct broadcasting below
@@ -618,7 +616,6 @@ def _supp_shape_from_params(self, dist_params, rep_param_idx=1, param_shapes=Non
618616

619617
@classmethod
620618
def rng_fn(cls, rng, n, a, size):
621-
622619
if n.ndim > 0 or a.ndim > 1:
623620
n, a = broadcast_params([n, a], cls.ndims_params)
624621
size = tuple(size or ())
@@ -865,7 +862,6 @@ def make_node(self, x):
865862

866863
# Python implementation:
867864
def perform(self, node, inputs, outputs):
868-
869865
(x,) = inputs
870866
(z,) = outputs
871867
try:
@@ -1494,7 +1490,6 @@ def _supp_shape_from_params(self, dist_params, **kwargs):
14941490

14951491
@classmethod
14961492
def rng_fn(cls, rng, n, eta, size):
1497-
14981493
# We flatten the size to make operations easier, and then rebuild it
14991494
if size is None:
15001495
flat_size = 1
@@ -1651,7 +1646,6 @@ def _infer_shape(self, size, dist_params, param_shapes=None):
16511646

16521647
@classmethod
16531648
def rng_fn(cls, rng, mu, rowchol, colchol, size=None):
1654-
16551649
size = to_tuple(size)
16561650
dist_shape = to_tuple([rowchol.shape[0], colchol.shape[0]])
16571651
output_shape = size + dist_shape
@@ -1773,7 +1767,6 @@ def dist(
17731767
*args,
17741768
**kwargs,
17751769
):
1776-
17771770
cholesky = Cholesky(lower=True, on_error="raise")
17781771

17791772
# Among-row matrices
@@ -1971,7 +1964,6 @@ class KroneckerNormal(Continuous):
19711964

19721965
@classmethod
19731966
def dist(cls, mu, covs=None, chols=None, evds=None, sigma=None, *args, **kwargs):
1974-
19751967
if len([i for i in [covs, chols, evds] if i is not None]) != 1:
19761968
raise ValueError(
19771969
"Incompatible parameterization. Specify exactly one of covs, chols, or evds."
@@ -2236,7 +2228,6 @@ class StickBreakingWeightsRV(RandomVariable):
22362228
_print_name = ("StickBreakingWeights", "\\operatorname{StickBreakingWeights}")
22372229

22382230
def make_node(self, rng, size, dtype, alpha, K):
2239-
22402231
alpha = at.as_tensor_variable(alpha)
22412232
K = at.as_tensor_variable(intX(K))
22422233

@@ -2519,7 +2510,6 @@ def check_zerosum_axes(cls, zerosum_axes: Optional[int]) -> int:
25192510

25202511
@classmethod
25212512
def rv_op(cls, sigma, zerosum_axes, support_shape, size=None):
2522-
25232513
shape = to_tuple(size) + tuple(support_shape)
25242514
normal_dist = ignore_logprob(pm.Normal.dist(sigma=sigma, shape=shape))
25252515

@@ -2546,7 +2536,6 @@ def rv_op(cls, sigma, zerosum_axes, support_shape, size=None):
25462536

25472537
@_change_dist_size.register(ZeroSumNormalRV)
25482538
def change_zerosum_size(op, normal_dist, new_size, expand=False):
2549-
25502539
normal_dist, sigma, support_shape = normal_dist.owner.inputs
25512540

25522541
if expand:

pymc/distributions/simulator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ def dist( # type: ignore
167167
dtype="floatX",
168168
**kwargs,
169169
):
170-
171170
if not isinstance(distance, Op):
172171
if distance == "gaussian":
173172
distance = gaussian

pymc/distributions/timeseries.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,6 @@ def step(*args):
677677

678678
@_change_dist_size.register(AutoRegressiveRV)
679679
def change_ar_size(op, dist, new_size, expand=False):
680-
681680
if expand:
682681
old_size = dist.shape[:-1]
683682
new_size = tuple(new_size) + tuple(old_size)
@@ -850,7 +849,6 @@ def step(prev_y, prev_sigma, omega, alpha_1, beta_1, rng):
850849

851850
@_change_dist_size.register(GARCH11RV)
852851
def change_garch11_size(op, dist, new_size, expand=False):
853-
854852
if expand:
855853
old_size = dist.shape[:-1]
856854
new_size = tuple(new_size) + tuple(old_size)
@@ -1035,7 +1033,6 @@ def step(*prev_args):
10351033

10361034
@_change_dist_size.register(EulerMaruyamaRV)
10371035
def change_eulermaruyama_size(op, dist, new_size, expand=False):
1038-
10391036
if expand:
10401037
old_size = dist.shape[:-1]
10411038
new_size = tuple(new_size) + tuple(old_size)

pymc/distributions/transforms.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def log_jac_det(self, value, *inputs):
164164

165165

166166
class Chain(RVTransform):
167-
168167
__slots__ = ("param_extract_fn", "transform_list", "name")
169168

170169
def __init__(self, transform_list):

pymc/distributions/truncated.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def dist(cls, dist, lower=None, upper=None, max_n_steps: int = 10_000, **kwargs)
161161

162162
@classmethod
163163
def rv_op(cls, dist, lower, upper, max_n_steps, size=None):
164-
165164
# Try to use specialized Op
166165
try:
167166
return _truncated(dist.owner.op, lower, upper, size, *dist.owner.inputs)

pymc/initial_point.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def make_initial_point_fn(
161161
varnames.append(name)
162162

163163
def make_seeded_function(func):
164-
165164
rngs = find_rng_nodes(func.maker.fgraph.outputs)
166165

167166
@functools.wraps(func)

pymc/logprob/censoring.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class MeasurableRound(MeasurableElemwise):
178178

179179
@node_rewriter(tracks=[ceil, floor, round_half_to_even])
180180
def find_measurable_roundings(fgraph: FunctionGraph, node: Node) -> Optional[List[MeasurableRound]]:
181-
182181
rv_map_feature = getattr(fgraph, "preserve_rv_mappings", None)
183182
if rv_map_feature is None:
184183
return None # pragma: no cover

pymc/logprob/joint_logprob.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ def factorized_joint_logprob(
196196
q_logprob_vars = [q_logprob_vars]
197197

198198
for q_value_var, q_logprob_var in zip(q_value_vars, q_logprob_vars):
199-
200199
q_value_var = original_values[q_value_var]
201200

202201
if q_value_var.name:

pymc/logprob/mixture.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def expand_indices(
138138
shape_copy = list(shape)
139139
n_preceding_basics = 0
140140
for d, idx in enumerate(full_indices):
141-
142141
if not is_basic_idx(idx):
143142
s = shape_copy.pop(0)
144143

@@ -326,7 +325,6 @@ def mixture_replace(fgraph, node):
326325
# that belong to each one (by way of their indices).
327326
new_mixture_rvs = []
328327
for i, component_rv in enumerate(mixture_rvs):
329-
330328
# We create custom types for the mixture components and assign them
331329
# null `get_measurable_outputs` dispatches so that they aren't
332330
# erroneously encountered in places like `factorized_joint_logprob`.

0 commit comments

Comments
 (0)