nanograv / enterprise

ENTERPRISE (Enhanced Numerical Toolbox Enabling a Robust PulsaR Inference SuitE) is a pulsar timing analysis code, aimed at noise analysis, gravitational-wave searches, and timing model analysis.
https://enterprise.readthedocs.io
MIT License
64 stars 65 forks source link

Fixed name collision in class factory definition #345

Closed vhaasteren closed 4 months ago

vhaasteren commented 1 year ago

This PR fixes #344. Inside the class factories, the class names now have a trailing underscore. This is not a user-facing change.

The main problem is that if you try to access attributes of the function (the class factory) itself, you get an UnboundLocalError, because the class that has the same name is in this scope and has not been defined yet. Making the names differ fixes that. A reason to access attributes of the class factory would be to get static variables, so one could for instance issue a warning only once, rather than every time you call a class factory. This can be done with global variables also, but it's less neat.

Currently, this PR is not exhaustive.

codecov[bot] commented 1 year ago

Codecov Report

Merging #345 (71caf7e) into master (5ef5ff4) will decrease coverage by 0.01%. The diff coverage is 93.75%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/nanograv/enterprise/pull/345/graphs/tree.svg?width=650&height=150&src=pr&token=7Sjk8cLA85&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv)](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) ```diff @@ Coverage Diff @@ ## master #345 +/- ## ========================================== - Coverage 88.37% 88.37% -0.01% ========================================== Files 13 13 Lines 3012 3010 -2 ========================================== - Hits 2662 2660 -2 Misses 350 350 ``` | [Files Changed](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) | Coverage Δ | | |---|---|---| | [enterprise/signals/parameter.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3BhcmFtZXRlci5weQ==) | `84.05% <75.00%> (ø)` | | | [enterprise/signals/deterministic\_signals.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL2RldGVybWluaXN0aWNfc2lnbmFscy5weQ==) | `100.00% <100.00%> (ø)` | | | [enterprise/signals/gp\_signals.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL2dwX3NpZ25hbHMucHk=) | `90.68% <100.00%> (ø)` | | | [enterprise/signals/selections.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3NlbGVjdGlvbnMucHk=) | `90.41% <100.00%> (ø)` | | | [enterprise/signals/signal\_base.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3NpZ25hbF9iYXNlLnB5) | `90.11% <100.00%> (ø)` | | | [enterprise/signals/white\_signals.py](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3doaXRlX3NpZ25hbHMucHk=) | `98.47% <100.00%> (ø)` | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/nanograv/enterprise/pull/345/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Last update [5ef5ff4...71caf7e](https://app.codecov.io/gh/nanograv/enterprise/pull/345?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv).
vhaasteren commented 4 months ago

I'm closing this PR. It's not necessary