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

Update plotting API #24

Merged
merged 8 commits into from
May 17, 2016
Merged

Update plotting API #24

merged 8 commits into from
May 17, 2016

Conversation

joleroi
Copy link
Contributor

@joleroi joleroi commented May 2, 2016

This implements the plotting API as discussed in #12

  • add plot method to base class
  • Add abstract make_patch method to base class
  • Implement make_patch for Circle regions as an example

@joleroi
Copy link
Contributor Author

joleroi commented May 2, 2016

The testing should probably be done as part of #20

@joleroi joleroi changed the title WIP: Update plotting API Update plotting API May 2, 2016

Parameters
----------
ax : `~matplolib.axes`, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't actually optional, is it?

also, matplotlib

Copy link
Member

Choose a reason for hiding this comment

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

It can be optional I think (at least it was in photutils), but then it should be defined with e.g. ax = plt.gca() when not given as parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what I had in mind

@joleroi
Copy link
Contributor Author

joleroi commented May 3, 2016

Can I merge this?

@@ -161,6 +161,36 @@ def to_shapely(self):
"""
raise NotImplementedError("")

@abc.abstractmethod
def make_patch(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

I would call this as_mpl_patch (we've used this name in another package, but I can't remember which one now!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👿
#12

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I missed that... I've commented it on it :) If we do decide to change it, it's only a search and replace at least? 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 😄 I will change to as_patch for now, ok?

Copy link
Member

Choose a reason for hiding this comment

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

That works for me :)

@astrofrog
Copy link
Member

@joleroi - apart from the naming suggestion, looks good to me!

"""
import matplotlib.pyplot as plt

ax = plt.gca() if ax is None else ax
Copy link
Member

Choose a reason for hiding this comment

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

For some weird reason, this comment was collapsed:

Personnaly I prefer if/else-s to be written in multi line, rather than in this form. But either case the else statement is not needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a guideline for that (I didn't find any ) http://docs.astropy.org/en/stable/development/codeguide.html

I prefer the one liners, even if they require an useless else statement

Copy link
Member

Choose a reason for hiding this comment

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

Well, it's not written anywhere but historically there was a long argument about the support of ternary conditional operators in python. And actually none of the examples in PEP308 deal with optional agrs but list comprehensions, lambdas, etc.

Also, I cannot find any such usage of it in numpy, and astropy core (except one single case in io.fits).

Choose a reason for hiding this comment

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

You can always use a one-liner without else: if ax is None: ax=plt.gca().

Copy link
Member

Choose a reason for hiding this comment

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

That is also in the "Rather not" category in PEP8 (https://www.python.org/dev/peps/pep-0008/)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be usefully shortened to ax = ax or plt.gca()? It may be less readable than the ternary, though, so just thumbs-down this if you don't like it.

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

(@joleroi - It looks like you have both tabs and spaces used as indents. For most editors you can set to use spaces only for tabs as well, so it's worth opting in it).

@joleroi
Copy link
Contributor Author

joleroi commented May 12, 2016

@bsipocz that's very well possible 😄 I switched to vim on monday after having used emacs for almost 10 years now (I feel like a 5 year old when typing). May the editor gods have mercy upon my soul ...

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

Switching to vim from emacs? 😢
Should I call 999, or would you like to talk about it?

@joleroi
Copy link
Contributor Author

joleroi commented May 12, 2016

I would like to show you my awesome working environment that took me 4 days to set up but will make me so much more productive in the future 👍

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

Do you still believe in fairy tales? ;)

@joleroi
Copy link
Contributor Author

joleroi commented May 12, 2016

@bsipocz Can you please have a look at appveyor? Maybe one just has to restart it but I never figured out how ...

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

@joleroi -looks like a fluke, I've restarted it.

If you login to appveyor there should be a "restart-PR" button on the top right part of the actual build. If you don't see that then Christoph needs to add you appveyor admin rights.

@joleroi
Copy link
Contributor Author

joleroi commented May 12, 2016

I don't see this button. @cdeil can you give me appveyor admin rights?

Ok to merge now?

@cdeil
Copy link
Member

cdeil commented May 12, 2016

I don't see the restart button on Appveyor for the astropy/regions repo either.

Probably only @astrofrog and @keflavich have such powers?
https://github.com/orgs/astropy/teams/regions-developers

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

AFAIK appveyor has different rights to github, e.g. I have it for regions as well as most astropy repos, though not having commit rights for most of them.

@astrofrog
Copy link
Member

@cdeil - you now have appveyor privileges (actually for all astropy repos). @bsipocz - can you log in to appveyor and let me know what email address you've used to sign up? (you can let me know by email)

@cdeil
Copy link
Member

cdeil commented May 12, 2016

@astrofrog - Thanks.

Just in case others face this: I had to log out and log back in and select "Astropy account" at login to be able to get these Appveyor admin powers for Astropy repos. It still shows me logged in as Christoph Deil after though, so that is pretty confusing.

Anyways: green light from appveyor for this PR now.

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

@cdeil - Yep, that's one of the many annoying things about appveyor ;)

@astrofrog
Copy link
Member

Ah yes, @bsipocz you already have access to all repos on appveyor :)

@bsipocz
Copy link
Member

bsipocz commented May 12, 2016

@astrofrog - 👍 all, or most, it's the same as I haven't tried to do anything with many of them anyway ;)

@joleroi joleroi merged commit 07f4136 into astropy:master May 17, 2016
@joleroi joleroi deleted the plotting branch May 17, 2016 07:26
@cdeil cdeil added this to the 0.1 milestone Jun 17, 2019
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.

None yet

6 participants