Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we remove calling initialize in sampler __repr__ method? #541

Open
3 tasks
amal-ghamdi opened this issue Sep 30, 2024 · 1 comment
Open
3 tasks
Assignees

Comments

@amal-ghamdi
Copy link
Contributor

amal-ghamdi commented Sep 30, 2024

Description:

initialize method change the state of the sampler. It is called in __repr__ which "apparently" is called behind the seen when debugging. Should we allow __repr__ to change the state of the sampler? This was a confusion point for me (@amal-ghamdi ) while debugging. For example consider this code

import cuqi
import numpy as np

uniform = cuqi.distribution.Uniform(np.array([0.0]), np.array([1.0]))
sampler = cuqi.experimental.mcmc.NUTS(uniform, initial_point=np.array([0.1]))
print(sampler._is_initialized)

Running this code will result in printing False, however, if run in debug mode, it will result in True.

DoD:

  • Make a decision on the matter above, should we allow repr to change the sampler state.
  • If the decision is to not allow repr to change the state, then update __repr__ and get the update reviewed and merged
  • If the decision is to not allow repr to change the state, make sure the code above prints False in both debug and run modes
@amal-ghamdi
Copy link
Contributor Author

@jakobsj , can you review the DoD if you got a chance. Thanks!

@amal-ghamdi amal-ghamdi self-assigned this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant