docstr: Re-use of the step method instance with cores=1 must not leak tuning information between chains.
docstr_tok: ["Re-use","of","the","step","method","instance","with","cores=1","must","not","leak","tuning","information","between","chains","."]
code: def test_tuning_reset(self):
      """Re-use of the step method instance with cores=1 must not leak tuning information between chains."""
      with pm.Model() as pmodel:
          D = 3
          pm.Normal("n", 0, 2, size=(D,))
          idata = pm.sample(
              tune=1000,
              draws=500,
              step=DEMetropolisZ(tune="scaling", scaling=0.002),
              cores=1,
              chains=3,
              discard_tuned_samples=False,
              random_seed=1,
          )
      for c in idata.posterior.chain:
          # check that the tuned settings changed and were reset
          warmup = (
              idata.warmup_sample_stats["scaling"].sel(chain=c).values
          )
          assert warmup[0] == 0.002
          assert warmup[-1] != 0.002
          # check that the variance of the first 50 iterations is much lower than the last 100
          samples = idata.warmup_posterior["n"].sel(chain=c).values
          for d in range(D):
              var_start = np.var(samples[:50, d])
              var_end = np.var(samples[-100:, d])
              assert var_start < 0.1 * var_end
  
imports: import warnings
  import arviz
  import numpy
  import numpy.testing
  import pytensor
  import pytest
  import pymc
  from pymc.step_methods.metropolis import BinaryGibbsMetropolis, CategoricalGibbsMetropolis, DEMetropolis, DEMetropolisZ, Metropolis, MultivariateNormalProposal, NormalProposal
  from pymc.testing import fast_unstable_sampling_mode
  from tests import sampler_fixtures
  from tests.helpers import RVsAssignmentStepsTester, StepMethodTester
  from tests.models import mv_simple, mv_simple_discrete, simple_categorical
label_desc: Use image node_id 4 for calling the TestDEMetropolisZ obj's underlying member method code with example usage: obj.test_tuning_reset() without return types