-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adding CompoundBoundingBox
#11942
Adding CompoundBoundingBox
#11942
Conversation
CompoundBoundingBox
ba3f8f9
to
6872d95
Compare
Hello @WilliamJamieson 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2021-10-30 00:07:20 UTC |
ced9a35
to
398a3f4
Compare
1b62f1a
to
bba32e0
Compare
106c51f
to
789ae6d
Compare
789ae6d
to
a0cd416
Compare
069b3d5
to
06371ae
Compare
06371ae
to
f69aa8d
Compare
f3d597d
to
61c1f2e
Compare
61c1f2e
to
049cf68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a general comment about my lack of a good sense of how this all ties together, which I can't easy grok from the source code or the test cases. (It is said that the test cases are a good place to see how a class or module should be used, but I don't think that is true here necessarily). So this is a bit of a conundrum. I see this as mostly a documentation issue, and as such, such things can be deferred after the freeze (as I understand it). On the other hand, the lack of this really prevents me from doing as complete review as I would like. Perhaps Nadia is in a better position to review the usage case since she has applied it to a JWST case. I'll try taking a look at her implementation, but I figured I would get these comments in first.
In looking at the examples in test_core.py
I find the examples pretty artificial and still wonder about how it is to be used. For example, suppose I define a model that has extra inputs that specify a spectral order, or slit id, say model(x, y, slit_id). Can I call that as follows: model(100, 200, 23, with_bounding_box=True
) and have the bounding box associated with 23 automatically used, or must I assign 23 to the bounding box keyword? (e.g., model(100, 200, 23, with_bounding_box=23
). If not current, does the current design preclude that in the future? That is the interface I would like to have (that is, the compound bounding box is told what input values are used to select the correct one, and when it is used by the model, it is given that information automatically to select the appropriate case).
Also is it eventually possible to automatically associate the model to the bounding box when assigning it to the model's bounding box attribute. Currently it seems redundant, but I haven't studied it enough to see if it avoidable in the future. At the moment it seems unnecessarily circular. That is, define a model, then define a bounding box referring to that model, then assign the bounding box to the model.
Again, if the current design doesn't preclude these future interfaces, then I don't see it as a problem for now. If one wants to see what the bounding box is for specific inputs, then give them to the method to retrieve them.
8ce5c07
to
bf5a997
Compare
2047992
to
5df6fb0
Compare
I think the current CI failures in this PR are from #12324, not this PR itself. |
372f801
to
7291c7f
Compare
This is ready to be merged after the unrelated CI failures are resolved. |
7291c7f
to
a993f61
Compare
Most changes to integrate new bounding box Fixed broken tests Updated bounding_box and its unit tests to include equality Added pseudo support for model set bounding boxes Updated bounding_box to be better able to accept auto-generated bounding_box Integrated new bounding_box into automatic bounding_boxes Fixed final broken test. Removed an accidental print. Fixed asdf bug. Refactored order handling for bounding_box Removed references to the old _BoundingBox. Finished TODO to remove check on bounding box input processing. Moved more i/o handling for bounding box into bounding box class Switched RuntimeError to RuntimeWarning for interval bounds validation. Fixed warning to be warning not exception Added documentation Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Fixed doctest failure Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Fixed unknown error in asdf round-trip for bounding_box Added `__all__` to bounding_box.py Moved changelog to correct folder. Addressed perrygreenfield's comments. Removed all references to `nan_index`. Changed `_model` to `model` in BoundingBox Added bounding_box to API reference. Updated docstrings for read-the-docs. Fixed more docstrings More docstring fixes New attempt at fixing docstring Most changes to integrate new bounding box Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Added `__all__` to bounding_box.py Fixed more docstrings Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added `__all__` to bounding_box.py Fixed more docstrings Refactored generic_call Removed generic_call from core.py Refactored _generic_evaluate into Model class Moved get_bounding_box into model class Moved _prepare_inputs_* functions into model class Refactored _prepare_outputs_* into model. Refactored validate_input_shapes into model Refactored some helper functions into model. Fixed codestyle errors. Added changelog entry. Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Moved changelog to correct folder Fixed rebase issue Refactored and added tests to increase test coverage. Added initial new bounding box Most changes to integrate new bounding box Fixed broken tests Updated bounding_box and its unit tests to include equality Added pseudo support for model set bounding boxes Updated bounding_box to be better able to accept auto-generated bounding_box Integrated new bounding_box into automatic bounding_boxes Fixed final broken test. Removed an accidental print. Fixed asdf bug. Refactored order handling for bounding_box Removed references to the old _BoundingBox. Finished TODO to remove check on bounding box input processing. Moved more i/o handling for bounding box into bounding box class Switched RuntimeError to RuntimeWarning for interval bounds validation. Fixed warning to be warning not exception Added documentation Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Fixed doctest failure Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Fixed unknown error in asdf round-trip for bounding_box Added `__all__` to bounding_box.py Moved changelog to correct folder. Addressed perrygreenfield's comments. Removed all references to `nan_index`. Changed `_model` to `model` in BoundingBox Added bounding_box to API reference. Updated docstrings for read-the-docs. Fixed more docstrings More docstring fixes New attempt at fixing docstring Most changes to integrate new bounding box Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Added `__all__` to bounding_box.py Fixed more docstrings Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added `__all__` to bounding_box.py Fixed more docstrings Refactored generic_call Removed generic_call from core.py Refactored _generic_evaluate into Model class Moved get_bounding_box into model class Moved _prepare_inputs_* functions into model class Refactored _prepare_outputs_* into model. Refactored validate_input_shapes into model Refactored some helper functions into model. Fixed codestyle errors. Added changelog entry. Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Moved changelog to correct folder Fixed rebase issue Refactored and added tests to increase test coverage. Added initial new bounding box Most changes to integrate new bounding box Fixed broken tests Updated bounding_box and its unit tests to include equality Added pseudo support for model set bounding boxes Updated bounding_box to be better able to accept auto-generated bounding_box Integrated new bounding_box into automatic bounding_boxes Fixed final broken test. Removed an accidental print. Fixed asdf bug. Refactored order handling for bounding_box Removed references to the old _BoundingBox. Finished TODO to remove check on bounding box input processing. Moved more i/o handling for bounding box into bounding box class Switched RuntimeError to RuntimeWarning for interval bounds validation. Fixed warning to be warning not exception Added documentation Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Fixed doctest failure Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Fixed unknown error in asdf round-trip for bounding_box Added `__all__` to bounding_box.py Moved changelog to correct folder. Addressed perrygreenfield's comments. Removed all references to `nan_index`. Changed `_model` to `model` in BoundingBox Added bounding_box to API reference. Updated docstrings for read-the-docs. Fixed more docstrings More docstring fixes New attempt at fixing docstring Most changes to integrate new bounding box Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Added `__all__` to bounding_box.py Fixed more docstrings Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added `__all__` to bounding_box.py Fixed more docstrings Refactored generic_call Removed generic_call from core.py Refactored _generic_evaluate into Model class Moved get_bounding_box into model class Moved _prepare_inputs_* functions into model class Refactored _prepare_outputs_* into model. Refactored validate_input_shapes into model Refactored some helper functions into model. Fixed codestyle errors. Added changelog entry. Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Moved changelog to correct folder Fixed rebase issue Refactored and added tests to increase test coverage. Most changes to integrate new bounding box Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added changelog entry. Added `__all__` to bounding_box.py Fixed more docstrings Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Added `__all__` to bounding_box.py Fixed more docstrings Refactored generic_call Removed generic_call from core.py Refactored _generic_evaluate into Model class Moved get_bounding_box into model class Moved _prepare_inputs_* functions into model class Refactored _prepare_outputs_* into model. Refactored validate_input_shapes into model Refactored some helper functions into model. Fixed codestyle errors. Added changelog entry. Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Moved changelog to correct folder Fixed rebase issue Most changes to integrate new bounding box Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Updated _fix_input_bounding_box to be in line with PR astropy#11908. Made fix_inputs_with_bounding_box more robust Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Fixed unknown error in asdf round-trip for bounding_box Added `__all__` to bounding_box.py Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Fixed more docstrings Added changelog entry. Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Integrated new bounding_box into automatic bounding_boxes Finished TODO to remove check on bounding box input processing. Improved test_custom_model_bounding_box test to test with_bounding_box=True Removed debugging print from a test. Fixed unknown error in asdf round-trip for bounding_box Added `__all__` to bounding_box.py Fixed more docstrings Minor refactoring and additional documentation. More documentation added. Fixed get_bounding_box in asdf Fixed rebase issue Minor refactoring and additional documentation. More documentation added. Moved changelog to correct folder Added changelog entry. Minor refactoring and additional documentation. More documentation added. Moved changelog to correct folder Added changelog entry. Minor refactoring and additional documentation. More documentation added. Minor refactoring and additional documentation. More documentation added. Minor refactoring and additional documentation. More documentation added. Introduced ignored bounding box inputs Added slice argument handling for compound bounding box Cleaned up rebase Factored evaluation methods out of bounding box Finished documenting BoundingDomain class. Added in basic compound bounding box class Integrated compound bounding box partially into core.py Finished integrating CompoundBoundingBox with core.py Finished adding tests for compound bounding box Added documentation for CompoundBoundingBox Cleaned up SliceArgument a bit Removed `add_ignored_axes` and related methods as these are no longer required. Added order notes to CompoundBoundingBox Added changelog entry. Updated model evaluation to be simpler Updated `__all__` in bounding_box.py Fixed a misspelling Moved changelog to correct place. Removed bad file. Updated docstrings Fixed more docstring errors. Removed bad file from docs. Fixed docstring serialize compound bounding box fix flake8 Mostly working fix_inputs Fixed broken fix_inputs cases Changed `slice_arg` to `selector_arg` and related throughout compound bounding box Addressed some of perrygreenfield's review comments. Fix for Azure test failure Updated asdf to used `selector` and `slice`. Intermediate work to diagnose issue Removed all the debugging statements. Increased test coverage. Fixed copy for models with a compound bounding box Fix for normal models Further fix for other mixed scalar-array cases. Changed bounding box tests to reflect changes to fix mixed scalar-array bug. Fixed copy bug with compound models
a993f61
to
afc3f0f
Compare
Description
Often one ends of with models for images with many slices have a dependency on that slice. These models can be extremely complex, being comprised of ~100 models, which are nearly identical for all slices, but have different bounding boxes for each slice. The bounding box calculations for each slice can become expensive if there is a need to run the model multiple times. For this reason, it is useful to be able to bind a "compound" bounding box to the model, which can select the "correct" bounding box based on a slice argument.
In this pull request, I introduce a
CompoundBoundingBox
which essentially is a dictionary of bounding boxes with keys given by the slice values. When thebounding_box
is used to evaluate the model, theCompoundBoundingBox
first selects the correct bounding_box and then uses that bounding_box to evaluate the model.This PR depends on PR #11930 and PR #11931 so a rebase should be performed after these PRs have been merged.
Note that this PR closes the draft PR #11699 as it accomplishes the same end goal.
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.