Thanks to visit codestin.com
Credit goes to github.com

Skip to content

whitespace(-mostly) style cleanup. #12026

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

Merged
merged 3 commits into from
Sep 6, 2018
Merged

whitespace(-mostly) style cleanup. #12026

merged 3 commits into from
Sep 6, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 5, 2018

I intentionally left in nearly all commented out dead code.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

I intentionally left in nearly all commented out dead code.
@@ -295,7 +297,7 @@ def __call__(self, direction, factor, values):
l_hm = self.fmt_d_m_partial % (s, d1, m1)
if l_hm != l_hm_old:
l_hm_old = l_hm
l = l_hm + s1 #l_s
Copy link
Contributor Author

Choose a reason for hiding this comment

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

l_s doesn't appear anywhere else in the codebase so I just killed the comment.

Copy link
Member

@phobson phobson left a comment

Choose a reason for hiding this comment

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

i think the commented out code in general should be removed, but i understand why we'd want to keep it around.

#dd += np.pi
#dd = np.arctan2(xx2-xx1, angle_tangent-yy1)
# dd += np.pi
# dd = np.arctan2(xx2-xx1, angle_tangent-yy1)
Copy link
Member

Choose a reason for hiding this comment

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

should these just go away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole block came in commented out with the surrounding code in 4fa9271 so yes.

@@ -245,30 +235,21 @@ def __init__(self, aux_trans, extremes,
tick_formatter1=tick_formatter1,
tick_formatter2=tick_formatter2)


Copy link
Member

Choose a reason for hiding this comment

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

should these go away as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's an update_grid_finder in grid_helper_curvelinear so I'll leave this one in

lon_lines, lat_lines = grid_finder._get_raw_grid_lines(extremes[:2],
extremes[2:],
*extremes)
#lon_min, lon_max,
# lon_min, lon_max,
# lat_min, lat_max)
Copy link
Member

Choose a reason for hiding this comment

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

perhaps this should be bumped up to previous line

@@ -140,7 +138,7 @@ def update_lim(self, axes):

grid_finder = self.grid_helper.grid_finder

#e1, e2 = self._extremes # ranges of other coordinates
# e1, e2 = self._extremes # ranges of other coordinates
Copy link
Member

Choose a reason for hiding this comment

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

goes away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

duplicated just a bit before in the same function so yes

# dd = np.arctan2(yy2-yy1, xx2-xx1) # angle normal
# dd2 = np.arctan2(yy3-yy1, xx3-xx1) # angle tangent
# mm = ((yy2-yy1)==0.) & ((xx2-xx1)==0.) # mask where dd1 is not defined
# dd[mm] = dd2[mm] + np.pi / 2
Copy link
Member

Choose a reason for hiding this comment

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

goes away?

Copy link
Contributor Author

@anntzer anntzer Sep 5, 2018

Choose a reason for hiding this comment

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

came in commented in 3b48ebb, and there's no yy2 and friends as local variables anymore, so I guess sure.

@anntzer
Copy link
Contributor Author

anntzer commented Sep 5, 2018

I agree with removing dead code in general, but I think someone should first figure out what a given line was intended to do before killing it.

@WeatherGod
Copy link
Member

WeatherGod commented Sep 5, 2018 via email

@anntzer
Copy link
Contributor Author

anntzer commented Sep 5, 2018

I hadn't heard of the "if there's no space after the hash it's commented out code" convention; I guess it could be a valuable one but we're already far from doing that in the rest of the codebase (yes, this PR makes things "worse" in that respect).
(Also that's basically arguing "we don't care about this specific item of the style guide", which is fine but another discussion...)

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Marked some obviously stale commented code segments. There are probably more, but I didn't want to check all right now. Even without these, this is an improvement.

Technically it's better to check them now and remove them instead of reformatting them. Reformatting makes it harder to go back in history and find out why the code was commented in the first place.

@@ -600,11 +583,10 @@ def _select_locator(self, formatter):
locator = ticker.MaxNLocator(nbins=5)
else:
b = self._boundaries[self._inside]
locator = ticker.FixedLocator(b) #, nbins=10)
locator = ticker.FixedLocator(b) # nbins=10)
Copy link
Member

Choose a reason for hiding this comment

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

This comment can be removed completely as it was just commented out code.

#self.transform_xy = transform_xy
#self.inv_transform_xy = inv_transform_xy
# self.transform_xy = transform_xy
# self.inv_transform_xy = inv_transform_xy
Copy link
Member

Choose a reason for hiding this comment

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

Stale commented code. Should be removed.

c[self.nth_coord] = x

# check if the tick point is inside axes
c2 = tr2ax.transform_point(c)
#delta=0.00001
# delta=0.00001
Copy link
Member

Choose a reason for hiding this comment

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

Stale code comment?

super().__init__(grid_helper, nth_coord, value, axis_direction=side)
#self.grid_helper = grid_helper
# self.grid_helper = grid_helper
Copy link
Member

Choose a reason for hiding this comment

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

Stale code comment. Remove.

@@ -123,7 +116,7 @@ def transform_xy(x, y):
xx0 = np.empty_like(yy0)
xx0.fill(self.value)

#yy0_ = yy0.copy()
# yy0_ = yy0.copy()
Copy link
Member

Choose a reason for hiding this comment

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

Stale code comment. Remove.

@@ -144,10 +137,9 @@ def transform_xy(x, y):
yy0 = np.empty_like(xx0)
yy0.fill(self.value)

#xx0_ = xx0.copy()
# xx0_ = xx0.copy()
Copy link
Member

Choose a reason for hiding this comment

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

Stale code comment. Remove.

def adjust_axes_lim(self):

#t = self.get_boundary()
# t = self.get_boundary()
Copy link
Member

Choose a reason for hiding this comment

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

Stale code comment. Remove.

@anntzer
Copy link
Contributor Author

anntzer commented Sep 5, 2018

All cases you pointed out look reasonable (except perhaps FixedLocator(nbins=10) because who knows whether there was a real need to set nbins=10, OTOH that just seems unlikely), removed them all.

@jklymak jklymak merged commit 1a40221 into matplotlib:master Sep 6, 2018
@anntzer anntzer deleted the style branch September 6, 2018 21:44
@QuLogic QuLogic added this to the v3.1 milestone Sep 6, 2018
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.

6 participants