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

Refactoring #29

Merged
merged 3 commits into from
Oct 16, 2023
Merged

Refactoring #29

merged 3 commits into from
Oct 16, 2023

Conversation

reubenharry
Copy link
Collaborator

@reubenharry reubenharry commented Oct 16, 2023

I wrote a few refactors, to remove a bit of code.

I don't know if this will break anything on @JakobRobnik 's ensemble branch, so you should probably try merging it in, and checking.

Main changes:

  1. output == "normal" -> output == OutputType.normal: this way you don't pass in arbitrary strings as arguments. The possible options are given by OutputType = Enum('Output', ['normal', 'detailed', 'expectation', 'ess'])
  2. Instead of passing in 'MN' or 'LF', directly pass in the integrator function. This meant I could remove hamiltonian entirely.
  3. if ... else replaced in some places by case, e.g.
match output:
            case OutputType.normal:
                X, _, E = self.sample_normal(num_steps, x, u, l, g, key, L, eps, sigma, thinning)
                return X
            case OutputType.detailed:
                X, _, E = self.sample_normal(num_steps, x, u, l, g, key, L, eps, sigma, thinning)
                return X, E, L, eps
...

@JakobRobnik JakobRobnik merged commit 5f95e24 into master Oct 16, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants