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

Further listification of Monte Carlo iteration #194

Merged
merged 39 commits into from
Nov 19, 2024
Merged

Further listification of Monte Carlo iteration #194

merged 39 commits into from
Nov 19, 2024

Conversation

jdbuhler
Copy link
Collaborator

Extend the use of the new list idiom for Monte Carlo to the operations in emlines, and to kcorr_and_absmag. We have not yet merged the base operations with their Monte Carlo versions, as in our previous PR, because there are some issues with divergent flow control that need to be reviewed first. But this change does simplify several uses of Monte Carlo and avoids having to rename a bunch of local variables in duplicated code. The merge operations desired in the future are marked with FIXME comments.

Speaking of renaming variables, use an abbreviated idiom for the actual list comprehensions that avoids retyping the names of the variables used in each Monte Carlo iteration, since typos in these names can lead to hard-to-find bugs. Advice: always use new names for the items being iterated over when passing them to the Monte Carlo function.

NB: this change incidentally fixes a bug in Monte Carlo computation of moments.

Jeremy Buhler and others added 30 commits November 15, 2024 09:09

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
  to merge basic and Monte Carlo usage (for now)
* similarly, use new idiom for kcorr_and_absmag without trying
  to merge for now
* fix bug in moment Monte Carlo -- was using moment1, rather than
  moment1_monte, to generate moment2 and moment3
* avoid typing variable names multiple times when using list
  comprehension idiom -- typos can cause silent bugs!
put these uses together with setting the boxflux variance
  rather than earlier in the code
* don't replicate parameters that are the same in every call
  to Monte Carlo iteration
  to remove redundant code and collect operations in one place
* minor cleanup of moments Monte Carlo
* don't pass redundant values to test_broad()
* fix debug printing for getlines()
…nto monte-list

(pull in latest fixes from John)
…code

* admit that optimize() returns its input linemodel after modifying it
  in place.  Make a copy in Monte Carlo to avoid need for copies elsewhere
  in the code.
* use 'obsamps' instead of 'obsamp' consistently
* simplify line selection in moments code
moustakas and others added 9 commits November 19, 2024 09:18
…ions

(but it's probably not worth trying to deduplicate the code given the number
of things we'd have to return from a common function)
…nto monte-list

to sync with John's latest changes
@moustakas
Copy link
Member

Thanks again for the contributions @jdbuhler. The long-term maintainability is significantly improved with this PR!

@moustakas moustakas merged commit b89048e into main Nov 19, 2024
12 checks passed
@moustakas moustakas deleted the monte-list branch November 19, 2024 21:09
moustakas added a commit that referenced this pull request Nov 21, 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

Successfully merging this pull request may close these issues.

None yet

2 participants