christiaanjs / treeflow

GNU General Public License v3.0
13 stars 4 forks source link

Fix ignored expections when using `estimate_log_ml_importance_sampling` with `JointDistributionCoroutine` #70

Open christiaanjs opened 3 months ago

christiaanjs commented 3 months ago

See test.vi.test_marginal_likelihood.test_marginal_likelihood_joint_distribution_coroutine (also appears in examples/rates-and-dates.ipynb):

Exception ignored in: <bound method WeakStructRef._cleanup of WeakStructRef(StructTuple(
  pop_size=HashableWeakRef(<weakref at 0x7f2718609cc0; dead>),
  tree=HashableWeakRef(<weakref at 0x7f2718609c20; dead>),
  kappa=HashableWeakRef(<weakref at 0x7f27186092c0; to 'Tensor' at 0x7f271921c160>),
  frequencies=HashableWeakRef(<weakref at 0x7f27186093b0; to 'Tensor' at 0x7f271921c940>),
  clock_rate=HashableWeakRef(<weakref at 0x7f27193d99a0; to 'Tensor' at 0x7f271921c220>),
  site_gamma_shape=HashableWeakRef(<weakref at 0x7f27193d9360; to 'Tensor' at 0x7f271921c250>)
))>
Traceback (most recent call last):
  File "[/home/christiaan/.pyenv/versions/3.8.13/envs/treeflow/lib/python3.8/site-packages/tensorflow_probability/python/internal/cache_util.py", line 151](http://localhost:8888/home/christiaan/.pyenv/versions/3.8.13/envs/treeflow/lib/python3.8/site-packages/tensorflow_probability/python/internal/cache_util.py#line=150), in _cleanup
    self._callback(self)
  File "[/home/christiaan/.pyenv/versions/3.8.13/envs/treeflow/lib/python3.8/site-packages/tensorflow_probability/python/internal/cache_util.py", line 221](http://localhost:8888/home/christiaan/.pyenv/versions/3.8.13/envs/treeflow/lib/python3.8/site-packages/tensorflow_probability/python/internal/cache_util.py#line=220), in maybe_del
    del self[key]
KeyError: WeakStructRef(StructTuple(
  pop_size=HashableWeakRef(<weakref at 0x7f2718609cc0; dead>),
  tree=HashableWeakRef(<weakref at 0x7f2718609c20; dead>),
  kappa=HashableWeakRef(<weakref at 0x7f27186092c0; to 'Tensor' at 0x7f271921c160>),
  frequencies=HashableWeakRef(<weakref at 0x7f27186093b0; to 'Tensor' at 0x7f271921c940>),
  clock_rate=HashableWeakRef(<weakref at 0x7f27193d99a0; to 'Tensor' at 0x7f271921c220>),
  site_gamma_shape=HashableWeakRef(<weakref at 0x7f27193d9360; to 'Tensor' at 0x7f271921c250>)
))