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

run_checks_compute() bugfix #837

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

aprsa
Copy link
Contributor

@aprsa aprsa commented Mar 28, 2024

The run_checks_compute() function included the internal "_default" compute parameter set in checking the ck2004 model atmosphere table existence in the passband files. This caused the checks to fail even if ck2004 was never needed.

The run_checks_compute() function included the internal "_default" compute parameter set in checking the ck2004 model atmosphere table existence in the passband files. This caused the checks to fail even if ck2004 was never needed.
@aprsa aprsa requested a review from kecnry March 28, 2024 02:46
@aprsa
Copy link
Contributor Author

aprsa commented Mar 28, 2024

Note that this fix had to be applied to the blending-dev branch so that other commits can be tested/applied.

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any place we can add a quick regression test?

phoebe/frontend/bundle.py Outdated Show resolved Hide resolved
phoebe/frontend/bundle.py Outdated Show resolved Hide resolved
@@ -1,6 +1,7 @@
import sys
import subprocess
import os
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be unused in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but np is used throughout bundle and we rely on a circular import, which isn't good practice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we get it from importing all from parameters, right? (Not really a circular import... but importing * surely isn't the best, let's make a ticket for that to refactor and explicitly import things, but that definitely shouldn't happen here)

phoebe/frontend/bundle.py Outdated Show resolved Hide resolved
@kecnry
Copy link
Member

kecnry commented Mar 28, 2024

We will also need to make sure to update any changes made to #826 so changes made during review here are not later reverted.

@aprsa
Copy link
Contributor Author

aprsa commented Mar 28, 2024

Any place we can add a quick regression test?

It's implicitly tested in the blackbody extinction test in PR #826, so we do have coverage.

# NOTE: atmparam includes a '_default' compute pset, which depends on the
# ck2004 atmospheres; the checks should not include it. This is achieved
# by filtering check_visible=True in the line below:
for atmparam in self.filter(qualifier='atm', kind='phoebe', compute=computes, check_visible=True, check_default=False).to_list() + self.filter(qualifier='ld_coeffs_source').to_list():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, I actually think I got these Trues and Falses backwards. We want to skip the visible checks but include the default checks so that _default are excluded from the returned parameters entirely (didn't notice it until I saw your comment explanation! 😬 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so do we want to do it this way then? As this way buries the logic deeper, it might be difficult to parse. Even now I'm not sure: if check_visible=True, I'd interpret that to only take visible psets, which would exclude _default. Now you're saying that check_visible should be False? And then that check_default should be True? That seems counter-intuitive to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be (marginally) cheaper, so I think since this runs often it is worth the explanatory comment and keeping the code as efficient as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that even the explanatory comment doesn't help me understand the logic. ;) But okay, I'll recommit with the fix and move on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_visible checks whether a parameter is visible, and if it is not, excludes it from the results. check_default similarly checks whether a parameter has any tag (compute, component, dataset, etc) as _default, and if so, excludes it from the results. In this case you do NOT want parameters that are tagged default, so we need to use check_default=True (or skip the parameters with a continue). We are not worried about parameters that are not visible/relevant, so we can save some time by passing check_visible=False.

@kecnry
Copy link
Member

kecnry commented Mar 28, 2024

It's implicitly tested in the blackbody extinction test in PR #826, so we do have coverage.

We'll have coverage whenever that is released... but I guess its unlikely this will be reintroduced, especially with the comment explaining the reason for using the default checks.

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just for peace of mind - can you please copy this finalized version over to the other branch and confirm that it passes the test coverage there before we merge?

@aprsa
Copy link
Contributor Author

aprsa commented Mar 28, 2024

Thanks! Just for peace of mind - can you please copy this finalized version over to the other branch and confirm that it passes the test coverage there before we merge?

Yep, it passes. Merge away.

@kecnry kecnry merged commit 9c6e78f into phoebe-project:bugfix-2.4.13 Mar 28, 2024
10 checks passed
@aprsa aprsa deleted the run_checks_bugfix branch March 28, 2024 14:35
@kecnry kecnry mentioned this pull request Mar 28, 2024
kecnry added a commit that referenced this pull request Apr 1, 2024
* Import from within source tree overly restrictive (#819)

In order to avoid same-name module conflicts with the system module (such as io.py), phoebe shouldn't be imported from its own source tree. The original test eliminated the entire package tree, including all auxiliary directories, which is overly restrictive and it prevented pytest from running when phoebe was installed with `pip -e`. This PR fixes that by blocking imports from the root directory and from the root/phoebe tree (the actual sources). Closes #806.

* update tests for changes to pytest (#820)

* Fixing up all pytests
The new pytest version raises an error instead of warning when tests return a value, and when assert is used incorrectly. All tests have been touched up to not have issues with the latest pytest.

* Update f-string to be compatible with python 3.7

f-string format f'{var=}' has been introduced in python 3.8, and it caused the 3.7 tests to fail. This fixes that issue.

---------

Co-authored-by: Andrej Prsa <[email protected]>

* Dynamical RVs now avoid meshing (#823)

* Dynamical RVs now avoid meshing
Calling b.compute_pblums() built the mesh and treated dynamical RVs as mesh-dependent. This fixes that for both run_compute() and for direct compute_pblums(), compute_l3(), and compute_ld_coeffs bundle methods. A new function, b._datasets_that_require_meshing(), filters datasets that require a mesh, i.e. 'lc', 'lp' and flux-weighted 'rv'. Closes #812.

* Generalized dataset filtering with b._datasets_where()

* Adding backend exception to mesh computation
Even if phoebe backend didn't need meshes for a particular dataset, other backends do. This is now handled in the `_datasets_where()` function.


---------

Co-authored-by: Kyle Conroy <[email protected]>

* run_checks_compute() bugfix (#837)

* run_checks_compute() bugfix
The run_checks_compute() function included the internal "_default" compute parameter set in checking the ck2004 model atmosphere table existence in the passband files. This caused the checks to fail even if ck2004 was never needed.

* Incorporating @kecnry's comments into the PR (along with additional comments)

* Fixing the if statement per @kecnry's instructions.

* Fix treatment of distance for alternate backends (#832)

* regression test

* don't duplicate distance handling for alt backends

* temporarily skip jktebop

* use top-level default_binary in test

* version and changelog for 2.4.13 release

* update setup-python to v5

to avoid deprecation warning

---------

Co-authored-by: Andrej Prsa <[email protected]>
Co-authored-by: Andrej Prsa <[email protected]>
aprsa added a commit that referenced this pull request Apr 1, 2024
* Import from within source tree overly restrictive (#819)

In order to avoid same-name module conflicts with the system module (such as io.py), phoebe shouldn't be imported from its own source tree. The original test eliminated the entire package tree, including all auxiliary directories, which is overly restrictive and it prevented pytest from running when phoebe was installed with `pip -e`. This PR fixes that by blocking imports from the root directory and from the root/phoebe tree (the actual sources). Closes #806.

* update tests for changes to pytest (#820)

* Fixing up all pytests
The new pytest version raises an error instead of warning when tests return a value, and when assert is used incorrectly. All tests have been touched up to not have issues with the latest pytest.

* Update f-string to be compatible with python 3.7

f-string format f'{var=}' has been introduced in python 3.8, and it caused the 3.7 tests to fail. This fixes that issue.

---------

Co-authored-by: Andrej Prsa <[email protected]>

* Dynamical RVs now avoid meshing (#823)

* Dynamical RVs now avoid meshing
Calling b.compute_pblums() built the mesh and treated dynamical RVs as mesh-dependent. This fixes that for both run_compute() and for direct compute_pblums(), compute_l3(), and compute_ld_coeffs bundle methods. A new function, b._datasets_that_require_meshing(), filters datasets that require a mesh, i.e. 'lc', 'lp' and flux-weighted 'rv'. Closes #812.

* Generalized dataset filtering with b._datasets_where()

* Adding backend exception to mesh computation
Even if phoebe backend didn't need meshes for a particular dataset, other backends do. This is now handled in the `_datasets_where()` function.

---------

Co-authored-by: Kyle Conroy <[email protected]>

* run_checks_compute() bugfix (#837)

* run_checks_compute() bugfix
The run_checks_compute() function included the internal "_default" compute parameter set in checking the ck2004 model atmosphere table existence in the passband files. This caused the checks to fail even if ck2004 was never needed.

* Incorporating @kecnry's comments into the PR (along with additional comments)

* Fixing the if statement per @kecnry's instructions.

* Fix treatment of distance for alternate backends (#832)

* regression test

* don't duplicate distance handling for alt backends

* temporarily skip jktebop

* use top-level default_binary in test

* version and changelog for 2.4.13 release

* update setup-python to v5

to avoid deprecation warning

---------

Co-authored-by: Andrej Prsa <[email protected]>
Co-authored-by: Andrej Prsa <[email protected]>
aprsa added a commit that referenced this pull request Apr 1, 2024
* Import from within source tree overly restrictive (#819)

In order to avoid same-name module conflicts with the system module (such as io.py), phoebe shouldn't be imported from its own source tree. The original test eliminated the entire package tree, including all auxiliary directories, which is overly restrictive and it prevented pytest from running when phoebe was installed with `pip -e`. This PR fixes that by blocking imports from the root directory and from the root/phoebe tree (the actual sources). Closes #806.

* update tests for changes to pytest (#820)

* Fixing up all pytests
The new pytest version raises an error instead of warning when tests return a value, and when assert is used incorrectly. All tests have been touched up to not have issues with the latest pytest.

* Update f-string to be compatible with python 3.7

f-string format f'{var=}' has been introduced in python 3.8, and it caused the 3.7 tests to fail. This fixes that issue.

---------

Co-authored-by: Andrej Prsa <[email protected]>

* Dynamical RVs now avoid meshing (#823)

* Dynamical RVs now avoid meshing
Calling b.compute_pblums() built the mesh and treated dynamical RVs as mesh-dependent. This fixes that for both run_compute() and for direct compute_pblums(), compute_l3(), and compute_ld_coeffs bundle methods. A new function, b._datasets_that_require_meshing(), filters datasets that require a mesh, i.e. 'lc', 'lp' and flux-weighted 'rv'. Closes #812.

* Generalized dataset filtering with b._datasets_where()

* Adding backend exception to mesh computation
Even if phoebe backend didn't need meshes for a particular dataset, other backends do. This is now handled in the `_datasets_where()` function.

---------

Co-authored-by: Kyle Conroy <[email protected]>

* run_checks_compute() bugfix (#837)

* run_checks_compute() bugfix
The run_checks_compute() function included the internal "_default" compute parameter set in checking the ck2004 model atmosphere table existence in the passband files. This caused the checks to fail even if ck2004 was never needed.

* Incorporating @kecnry's comments into the PR (along with additional comments)

* Fixing the if statement per @kecnry's instructions.

* Fix treatment of distance for alternate backends (#832)

* regression test

* don't duplicate distance handling for alt backends

* temporarily skip jktebop

* use top-level default_binary in test

* version and changelog for 2.4.13 release

* update setup-python to v5

to avoid deprecation warning

---------

Co-authored-by: Andrej Prsa <[email protected]>
Co-authored-by: Andrej Prsa <[email protected]>
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