Skip to content

Commit d12dd0b

Browse files
committed
ruff formatting
1 parent 026f182 commit d12dd0b

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

pymc_extras/distributions/discrete.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import numpy as np
1616
import pymc as pm
1717

18-
from pymc.distributions.distribution import Discrete
1918
from pymc.distributions.dist_math import betaln, check_parameters, factln, logpow
19+
from pymc.distributions.distribution import Discrete
2020
from pymc.distributions.shape_utils import rv_size_is_none
2121
from pytensor import tensor as pt
2222
from pytensor.tensor.random.op import RandomVariable
@@ -432,10 +432,10 @@ def sim_data(lam):
432432
lam, # For small lambda, p ≈ lambda
433433
1 - np.exp(-lam) # Standard formula for larger lambda
434434
)
435-
435+
436436
# Ensure p is in valid range for geometric distribution
437437
p = np.clip(p, 1e-5, 1.)
438-
438+
439439
t = rng.geometric(p)
440440
return np.array([t])
441441

@@ -529,15 +529,15 @@ def logcdf(value, r, alpha):
529529

530530
def support_point(rv, size, r, alpha):
531531
"""Calculate a reasonable starting point for sampling.
532-
532+
533533
For the GrassiaIIGeometric distribution, we use a point estimate based on
534534
the expected value of the mixing distribution. Since the mixing distribution
535535
is Gamma(r, 1/alpha), its mean is r/alpha. We then transform this through
536536
the geometric link function and round to ensure an integer value.
537537
"""
538538
mean = pt.ceil(pt.exp(alpha/r))
539-
539+
540540
if not rv_size_is_none(size):
541541
mean = pt.full(size, mean)
542-
543-
return mean
542+
543+
return mean

tests/distributions/test_discrete.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
from pymc_extras.distributions import (
3434
BetaNegativeBinomial,
3535
GeneralizedPoisson,
36-
Skellam,
3736
GrassiaIIGeometric,
37+
Skellam,
3838
)
3939

4040

@@ -233,7 +233,7 @@ def test_random_basic_properties(self):
233233
1 - np.exp(-np.random.gamma(r, 1/alpha, size=size)), size=size
234234
),
235235
)
236-
236+
237237
# Test small parameter values that could generate small lambda values
238238
discrete_random_tester(
239239
dist=self.pymc_dist,
@@ -278,14 +278,14 @@ def test_logp_basic(self):
278278
test_value = np.array([1, 2, 3, 4, 5])
279279
test_r = 1.0
280280
test_alpha = 1.0
281-
281+
282282
logp_vals = logp_fn(test_value, test_r, test_alpha)
283283
assert not np.any(np.isnan(logp_vals))
284284
assert np.all(np.isfinite(logp_vals))
285285

286286
# Test invalid values
287287
assert logp_fn(np.array([0]), test_r, test_alpha) == np.inf # Value must be > 0
288-
288+
289289
with pytest.raises(TypeError):
290290
logp_fn(np.array([1.5]), test_r, test_alpha) == -np.inf # Value must be integer
291291

@@ -328,16 +328,16 @@ def test_support_point(self, r, alpha, size, expected_shape):
328328
"""Test that support_point returns reasonable values with correct shapes"""
329329
with pm.Model() as model:
330330
GrassiaIIGeometric("x", r=r, alpha=alpha, size=size)
331-
331+
332332
init_point = model.initial_point()["x"]
333-
333+
334334
# Check shape
335335
assert init_point.shape == expected_shape
336-
336+
337337
# Check values are positive integers
338338
assert np.all(init_point > 0)
339339
assert np.all(init_point.astype(int) == init_point)
340-
340+
341341
# Check values are finite and reasonable
342342
assert np.all(np.isfinite(init_point))
343343
assert np.all(init_point < 1e6) # Should not be extremely large

0 commit comments

Comments
 (0)