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

Modifying dictionary during iteration #19

Closed
jvines opened this issue Apr 11, 2020 · 2 comments
Closed

Modifying dictionary during iteration #19

jvines opened this issue Apr 11, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jvines
Copy link

jvines commented Apr 11, 2020

Hi,

In fit.py, line 1303, you have the following:

for pname in out['posterior_samples'].keys():
                    if 'sigma_w_rv' == pname[:10]:
                        instrument = pname.split('_')[-1]
                        out['posterior_samples']['sigma_w_'+instrument] = out['posterior_samples'][pname]

That last line is effectively modifying the dictionary you're currently iterating through in the case where RV datasets are analysed, this induces the error RuntimeError: dictionary changed size during iteration

This error is showing up when reading the output of runs made with Juliet before it became a package

I fixed it by changing it like this:

out_new = dict()
                out_new['posterior_samples'] = dict()
                for pname in out['posterior_samples'].keys():
                    if 'sigma_w_rv' == pname[:10]:
                        instrument = pname.split('_')[-1]
                        out_new['posterior_samples']['sigma_w_'+instrument] = out['posterior_samples'][pname]

                for pname in out_new['posterior_samples'].keys():
                    out['posterior_samples'][pname] = out_new['posterior_samples'][pname]

It's just an ad-hoc solution though. I'll open a PR for this, just in case.

Cheers,

@nespinoza
Copy link
Owner

nespinoza commented May 28, 2020

Hey @jvines --- thanks for this! I'll take a deeper look soon to this to include it. Marking it as an "enhancement" because in theory, the new and old versions of juliet are different codes.

@nespinoza nespinoza self-assigned this May 28, 2020
@nespinoza nespinoza added the enhancement New feature or request label May 28, 2020
nespinoza added a commit that referenced this issue Aug 10, 2020
@nespinoza
Copy link
Owner

Fixed in 2160e0d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants