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
Rename Mask class and add origin arg to plot methods #203
Conversation
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.
The PR looks good to me. It would be great if you could include a document example with a figure showing how and when you'd use the offset origin option. Maybe on cropped data?
regions/core/core.py
Outdated
""" | ||
Calls as_patch method forwarding all kwargs and adds patch | ||
to given axis. | ||
|
||
Parameters | ||
---------- | ||
origin : array_like, optional | ||
The ``(x, y)`` position of the origin of the displayed image. |
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.
could you clarify: these are x,y positions in pixel units, right? Just to make sure they're not confused with data units (e.g., WCS)
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.
yes, pixel units. Perhaps should we accept PixCoord
instead of a tuple to avoid confusion?
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.
That's... a good idea from a programmer's perspective, as it makes the code more robust, but it's really inconvenient for something as simple as a pixel coordinate, since it requires an additional import and a much longer function call. I am weakly in favor of accepting a tuple and just documenting it.
regions/shapes/circle.py
Outdated
Parameters: | ||
----------- | ||
origin : array_like, optional | ||
The ``(x, y)`` position of the origin of the displayed image. |
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.
same clarification here
regions/shapes/ellipse.py
Outdated
Parameters: | ||
----------- | ||
origin : array_like, optional | ||
The ``(x, y)`` position of the origin of the displayed image. |
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.
and here, and in all similar instances
@sushobhana - Please rebase against upstream master to resolve the merge conflicts. |
@keflavich Added an example and rebased it. Ready to merge?? |
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.
Needs some docstring cleanup, then I think it's good?
docs/plotting.rst
Outdated
You can shift the origin of the region very conveniently while plotting by simply | ||
supplying the ``origin`` pixel coordinates to :meth:`~regions.PixelRegion.plot` | ||
and :meth:`~regions.PixelRegion.as_patch`. The ``**kwargs`` argument takes any | ||
keyword argument that the `~matplotlib.patches.Patch` object accepts. For Ex: |
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.
either say "For example:" or "e.g.:"
docs/plotting.rst
Outdated
`~regions.CompundPixelRegion` don't have because there are no equivalent classes | ||
in `matplotlib.patches`. | ||
the `~regions.TextPixelRegion` and `~regions.CompoundPixelRegion` | ||
don't have because there are no equivalent classes in `matplotlib.patches`. |
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.
don't have what? don't have as_patch
methods?
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.
It is mentioned in the above line
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.
yes, but this is grammatically incorrect.
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.
I rephrased it.
regions/core/bounding_box.py
Outdated
ax : `matplotlib.axes.Axes` instance, optional | ||
If `None`, then the current `~matplotlib.axes.Axes` instance | ||
is used. | ||
kwargs |
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.
will this render correctly? I think you need kwargs: dict
?
origin : array_like, optional | ||
The ``(x, y)`` position of the origin of the displayed | ||
image. | ||
ax : `matplotlib.axes.Axes` instance, optional |
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.
whitespace is inconsistent; no
before :
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.
actually, sphinx doesn't render properly if there is no
before :
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.
Oh... my bad, you have to add spaces in other places, not remove them here
regions/core/compound.py
Outdated
""" | ||
Matplotlib patch object for annulus region (`matplotlib.patches.PathPatch`). | ||
|
||
Parameters: |
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.
no trailing :
Thanks @keflavich ! |
docs/plotting.rst
Outdated
@@ -34,7 +34,7 @@ and calls ``plt.gca()`` if no axis is passed in. | |||
You can shift the origin of the region very conveniently while plotting by simply | |||
supplying the ``origin`` pixel coordinates to :meth:`~regions.PixelRegion.plot` | |||
and :meth:`~regions.PixelRegion.as_patch`. The ``**kwargs`` argument takes any | |||
keyword argument that the `~matplotlib.patches.Patch` object accepts. For Ex: | |||
keyword argument that the `~matplotlib.patches.Patch` object accepts. For e.g.: |
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.
it's just e.g.
, not For e.g.
, but I'll handle that
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.
I did not know e.g. itself means for example, I thought it is short for example (had to google it!) ..hehe
According to discussion in astropy/photutils#684
to_region
andplot
methods toBoundingBox
Mask
toRegionMask
.Now,
RegionMask
areApertureMask
are same both API and code wise.Geometry functions and
BoundingBox
are also same in both packages.