Identifying freeRV variables inside an ArrayStep

So I’m continuing my quest to implement RJMCMC in pymc3 (previous post).

I’ve inherited a stepper function for Metropolis, since RJMCMC is just metropolis with some variables singled out. The variables of the model are seperated between swtich variables \Delta_i and continuous parameters k_i. I map these together on construction of my stepper by passing them as a tuple [(delta, k)].

Once in the astep(self, q0) however, I’m not sure how to identify which values of the array go to which variable. I presume the ordering of the values in q0 are the same as those in self.vars from the inherited Metropolis class, but the names of these variables are different.

[x.name for x in self.vars]
['k10_interval__', 'k01_interval__', 'delta10', 'delta01']

While as what I put in super().__init__ was the array of FreeRV with names:

['delta10', 'delta01', 'k10', 'k01']

How can I reliably map between these? Can I rely on reliable mangling of the names?
Or is there some existing function I can use to figure this out?

They are handled in the step meta class:

Note that PyMC samples in Real space, thus bounded parameter k10 and k01 are transformed into k10_interval__, k01_interval__

Thanks for the reply man! But I’m still confused
I see then that I can use something like

thing = DictToArrayBijection.rmap(q0)

To retrieve the names associated with each index that way I can account for the order being changed.
But how can I reliably know how the name has changed?
Do I just check if it’s continuous and in that case append _interval__, or is there a cleaner function that I can refer to ?

Ah so I see now that PyMC automatically transforms the bounded variables to be unbounded.
So in all my formulas i would have to apply the backwards transform then the forwards to get the right value back.

So what I’m looking for is, how can I figure out which transform and name mangling have been applied to a bounded variable?

edit: perusing the source code I’ve come up with model.k01_interval__.distribution.transform_used to get the transform. Is splitting the name at the 3rd _ starting from the right sufficiently general to retrieve the original name?