Skip to content

Code cleanup - #51

Merged
astrofrog merged 7 commits into
astropy:masterfrom
bsipocz:code_cleanup
Nov 4, 2014
Merged

astrofrog merged 7 commits into
astropy:masterfrom
bsipocz:code_cleanup

Conversation

@bsipocz

@bsipocz bsipocz commented Nov 2, 2014

Copy link
Copy Markdown
Member

As a light exercise for a Sunday evening, I've made some code clean up involving mainly the removal of unused imports, stale looking code/comment parts, and some trivial PEP8 changes (adding/removing white spaces).

This PR builds on #47, since a significant amount of code was removed in that. Once that one is merged, I'll rebase this one to make the review easier.

@astrofrog

Copy link
Copy Markdown
Member

@bsipocz - thanks! I merged #47, so can you rebase this?

@bsipocz

bsipocz commented Nov 2, 2014

Copy link
Copy Markdown
Member Author

@astrofrog - Rebased.

@astrofrog

Copy link
Copy Markdown
Member

@leejjoon - I'll leave this open a couple of days in case you want to review this (but I think nothing here is controversial)

@bsipocz

bsipocz commented Nov 2, 2014

Copy link
Copy Markdown
Member Author

@astrofrog - Sure. There're still a handful of commented out code lines. However they may be removed later (e.g. until the code has better test coverage), as I'm not sure why they were left there, whether it was for future reuse, or they can be removed for good.

@sargas

sargas commented Nov 3, 2014

Copy link
Copy Markdown
Contributor

Nice. I've got a couple suggestions for more unused code that can be removed (this is from a WIP branch):

  • In pyregion/region_numbers.py: getSign, and get_degree functions can be removed
  • In pyregion/wcs_helper.py:
    • If you import astropy.extern.six, you can remove the is_string_like function and just use isinstance(..., six.string_types)
    • I think the unit fixing in fix_header is already done in astropy
    • At least here, both WCS.ctypes are strings in python2 and python3. So I think the as_str function (and the call(s) to it) can be removed.
    • Big one: nothing uses ProjectionPywcs, ProjectionSimple, ProjectionDefault, estimate_cdelt_trans, or estimate_angle_trans, or is_equal_coord_sys. I guess this would be a public API change, but there are no docs for these things anyways

This might change @astrofrog's comment about nothing being controversal though :/ I've been trying to figure out the code for issue #43, and finding this stuff in the way.

@astrofrog

Copy link
Copy Markdown
Member

@bsipocz @sargas - thanks to both of you for working on this!

@leejjoon - can you comment on @sargas's suggestions of code that can be removed? Are any of the functions/classes he is suggesting still needed?

@leejjoon

leejjoon commented Nov 3, 2014

Copy link
Copy Markdown
Contributor

I think @sargas suggestions are all harmless. So i have no objection in removing/replacing those things.

Got rid of a function by using astropy.extern.six
Removed a fix_header function that appears superfluous
@sargas

sargas commented Nov 3, 2014

Copy link
Copy Markdown
Contributor

@leejjoon Thanks

@bsipocz https://gist.github.com/sargas/654a6dc7f7b3d57a6464 is my changes, but I can do another PR if you'd like to keep these seperate. I was much harsher to commented out code (since it's in git's history if needed, and much is likely to be removed converting from kapteyn to astropy.coordinates)

@astrofrog

Copy link
Copy Markdown
Member

@sargas - you can actually open a PR to @bsipocz's branch with your changes if you like (but a completely separate PR is also fine).

@bsipocz

bsipocz commented Nov 3, 2014

Copy link
Copy Markdown
Member Author

@sargas - I was just about to write the same as @astrofrog. A third option is to just push your brunch to github, and then I can cherry pick your commit on top of this PR.

@sargas

sargas commented Nov 3, 2014

Copy link
Copy Markdown
Contributor

@astrofrog @bsipocz Interesting, I didn't realize you could do PR's on PR's. I added bsipocz#1 if you'd like to merge or cherry-pick.

@bsipocz

bsipocz commented Nov 3, 2014

Copy link
Copy Markdown
Member Author

Realizing that they were left out yesterday, I repeated the same cleaning exercise with the cython and test files.

Comment thread pyregion/_region_filter.pyx Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bsipocz - I think the above lines could be left - even though this is not used currently, it's good to have these here in case it's needed in future.

@astrofrog

Copy link
Copy Markdown
Member

@bsipocz @sargas - thanks for the cleanup! Just a few small comments above, then we should merge this!

@bsipocz

bsipocz commented Nov 4, 2014

Copy link
Copy Markdown
Member Author

@astrofrog - thanks for the comments, they are dealt with in the latest commit.

@astrofrog

Copy link
Copy Markdown
Member

@bsipocz @sargas - thanks to both of you for your work on this!

astrofrog added a commit that referenced this pull request Nov 4, 2014
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.

4 participants