Repository navigation
Updates to bounding box interface and cleanup - #4264
Merged
Merged
Conversation
a bounding box on a model. The format of the bounding box itself (as a tuple of tuples) is not changed. This is motivated in large part by wanting the API to more closely resemble the API for inverses which is somewhat simiar--model.inverse is a property of a model that returns something based on a model instance *if* the inverse is defined on that model's class. Otherwise it raises NotImplementedError. Regardless of whether a default inverse is defined on the class, the user can assign their own inverse to any model instance. The user-defined inverse can unset (as of PR astropy#4236) by calling del model.inverse, which will reset it back to the inverse defined at the class level. This PR makes bounding_box work entirely analogously to the above. The bounding_box_default() method is removed--instead, in order to define a bounding box for a specific model class, simply define a property called bounding_box on the class (the metaclass will then handle) wrapping that property in the standard getter/setter for Model.bounding_box defined in the Model base class). The one extra complexity for bounding_box is that we want *some* cases of bounding_box to be *callable* with adjustable parameters (such as how Gaussian1D.bounding_box_default() takes an optional "factor" argument). To this end, the object returned by model.bounding_box is actually a subclass of tuple that looks like a normal bounding box tuple. But on a model whose bounding_box takes arguments (and is a method instead of a property) one can *call* model.bounding_box like ``model.bounding_box(factor=1.2)`` to adjust the bounding box.
…interface, and some minor code style cleanup to go with it.
Member
Author
Contributor
|
👍 |
Member
Author
There was a problem hiding this comment.
At some point something needs to be done with these assertions--really there's no reason to use assert and then catch AssertionErrors and reraise them. This should just raise a ValueError something after checking the condtion, and not use assert at all. I don't think I have time to fix it now though.
Member
Author
|
FWIW the Sphinx build for this failed due to a failure to fetch the matplotlib object.inv. Didn't appear to have any failures actually related to PR, but I've restarted it anyways. |
Member
There was a problem hiding this comment.
"Note:" is not necessary in a warning (and perhaps confusing, because .. note:: means something different)
astrofrog
added a commit
that referenced
this pull request
Nov 9, 2015
Updates to bounding box interface and cleanup
5 tasks done
astrofrog
added a commit
that referenced
this pull request
Nov 9, 2015
Updates to bounding box interface and cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the update to #4040--it includes all the fixes from #4040, but also includes my updates to the bounding box interface.
The purpose of these updates, as explained in the commit message of 779ef3e, is to make the interface for
bounding_boxfairly consistent with the interface forModel.inverse. To that end thebounding_box_defaultmethod is eliminated, and model classes that define a bounding box can do so as a class-level attribute, method, or property simply calledbounding_box, which is then wrapped by the Model metaclass to incorporate the default getter/setter behavior for theModel.bounding_boxproperty. This is similar to howModel.inverseworks.One downside to this that I just noticed while testing the documentation is that if a
Modelsubclass has abounding_boxwith its own docstring, that docstring usually gets thrown away. We definitely don't want that, so I am going to open a separate issue to fix that later.