stan-dev/pystan — pull request #58 by kcarnold (2014-01-16 19:41:09+00:00)
Title: Obfuscate model name

Previously, same model name -> same model, even if model code changed.

Demonstration (from my mailing list post):

```
>>> import pystan
>>> m_y = pystan.StanModel(model_code='parameters {real y;} model {y ~ normal(0,1);}')
>>> m_y.optimizing()['par']['y']
array(0.0) # success.
>>> m_z = pystan.StanModel(model_code='parameters {real z;} model {z ~ normal(0,1);}')
>>> m_z.optimizing()['par']['z']
KeyError # because it's actually running m_y!
>>> m_z = pystan.StanModel(model_code='parameters {real z;} model {z ~ normal(0,1);}', model_name='m_z')
>>> m_z.optimizing()['par']['z']
array(0.0) # success.
```

This patch implements an approach that looks like it was anticipated but not implemented: adding a hash of the model code to the model name. It's a bit messy because the resulting module name gets two hashes back to back, but it makes the above test work.

Does this interfere with any use cases for model names? (I can't think of any use cases for model names at all, but then I'm bad at naming things.)