Skip to content

Commit d3cf283

Browse files
committed
Add name to CompountStep
1 parent 336d9a6 commit d3cf283

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: pymc/step_methods/compound.py

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, methods):
3333
for method in self.methods:
3434
if method.generates_stats:
3535
self.stats_dtypes.extend(method.stats_dtypes)
36+
self.name = (
37+
f"Compound[{', '.join(getattr(m, 'name', 'UNNAMED_STEP') for m in self.methods)}]"
38+
)
3639

3740
def step(self, point):
3841
if self.generates_stats:

Diff for: pymc/tests/test_step.py

+10
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ def test_blocked(self):
221221
assert not isinstance(sampler_instance, CompoundStep)
222222
assert isinstance(sampler_instance, sampler)
223223

224+
def test_name(self):
225+
with Model() as m:
226+
c1 = HalfNormal("c1")
227+
c2 = HalfNormal("c2")
228+
229+
step1 = NUTS([c1])
230+
step2 = Slice([c2])
231+
step = CompoundStep([step1, step2])
232+
assert step.name == "Compound[nuts, slice]"
233+
224234

225235
class TestAssignStepMethods:
226236
def test_bernoulli(self):

0 commit comments

Comments
 (0)