-
Notifications
You must be signed in to change notification settings - Fork 373
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
Configure + enable stickler testing. #970
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
linters: | ||
flake8: { } | ||
flake8: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ | |
from shapely.prepared import prep | ||
import six | ||
|
||
from cartopy._crs import CRS, Geocentric, Geodetic, Globe, PROJ4_VERSION | ||
from cartopy._crs import CRS, Geodetic, Globe, PROJ4_VERSION | ||
from cartopy._crs import Geocentric # noqa: F401 (unused import) | ||
import cartopy.trace | ||
|
||
|
||
|
@@ -746,7 +747,6 @@ def quick_vertices_transform(self, vertices, src_crs): | |
mod = np.diff(src_crs.x_limits)[0] | ||
bboxes, proj_offset = self._bbox_and_offset(src_crs) | ||
x_lim = xs.min(), xs.max() | ||
y_lim = ys.min(), ys.max() | ||
for poly in bboxes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pp-mo What's happened to y_lim? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'y_lim' was not used, so flake8 complained about it, so I got rid of it. There's a lot of that going on in this PR ! |
||
# Arbitrarily choose the number of moduli to look | ||
# above and below the -180->180 range. If data is beyond | ||
|
@@ -1184,7 +1184,6 @@ def __init__(self, central_longitude=0.0, central_latitude=0.0, | |
globe=globe) | ||
|
||
a = np.float(self.globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS) | ||
b = np.float(self.globe.semiminor_axis or WGS84_SEMIMINOR_AXIS) | ||
lon, lat = central_longitude + 180, - central_latitude + 0.01 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pp-mo And also what's happened to b (the semiminor axis)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'b' also not used anywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identical to what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identical to 'a'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not identical to 'a', though. But I'm not sure it needs to be used anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, it is not after all : more care required ! |
||
x, max_y = self.transform_point(lon, lat, PlateCarree()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ def _north_south_formatted(latitude, num_format='g'): | |
hemisphere=_lat_heimisphere(latitude), | ||
degree=_DEGREE_SYMBOL) | ||
|
||
|
||
#: A formatter which turns longitude values into nice longitudes such as 110W | ||
LONGITUDE_FORMATTER = mticker.FuncFormatter(lambda v, pos: | ||
_east_west_formatted(v)) | ||
|
@@ -335,9 +336,10 @@ def _draw_gridliner(self, nx=None, ny=None, background_patch=None): | |
if self.xlines: | ||
lines = [] | ||
for x in x_gridline_points: | ||
l = list(zip(np.zeros(n_steps) + x, | ||
np.linspace(min(y_ticks), max(y_ticks), n_steps))) | ||
lines.append(l) | ||
ticks = list(zip( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could've sworn I'd written some optimization for this unfortunate type conversion; maybe I never made a PR out of it, but I can see if I can dig it up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a need to connect this with the issue at hand ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, just a reminder to myself. |
||
np.zeros(n_steps) + x, | ||
np.linspace(min(y_ticks), max(y_ticks), n_steps))) | ||
lines.append(ticks) | ||
|
||
x_lc = mcollections.LineCollection(lines, **collection_kwargs) | ||
self.xline_artists.append(x_lc) | ||
|
@@ -346,9 +348,10 @@ def _draw_gridliner(self, nx=None, ny=None, background_patch=None): | |
if self.ylines: | ||
lines = [] | ||
for y in y_ticks: | ||
l = list(zip(np.linspace(min(x_ticks), max(x_ticks), n_steps), | ||
np.zeros(n_steps) + y)) | ||
lines.append(l) | ||
ticks = list(zip( | ||
np.linspace(min(x_ticks), max(x_ticks), n_steps), | ||
np.zeros(n_steps) + y)) | ||
lines.append(ticks) | ||
|
||
y_lc = mcollections.LineCollection(lines, **collection_kwargs) | ||
self.yline_artists.append(y_lc) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,7 @@ def test_global_scatter_wrap_no_transform(): | |
@ImageTesting(['global_map'], | ||
tolerance=16 if ccrs.PROJ4_VERSION < (4, 9) else 0.1) | ||
def test_global_map(): | ||
ax = plt.axes(projection=ccrs.Robinson()) | ||
plt.axes(projection=ccrs.Robinson()) | ||
# ax.coastlines() | ||
# ax.gridlines(5) | ||
|
||
|
@@ -249,7 +249,7 @@ def test_pcolormesh_global_with_wrap1(): | |
@ImageTesting(['pcolormesh_global_wrap2']) | ||
def test_pcolormesh_global_with_wrap2(): | ||
# make up some realistic data with bounds (such as data from the UM) | ||
nx, ny = 36, 18 | ||
nx = 36 | ||
xbnds, xstep = np.linspace(0, 360, nx - 1, retstep=True, endpoint=True) | ||
ybnds, ystep = np.linspace(-90, 90, nx - 1, retstep=True, endpoint=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems better to make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really probably just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, yes I hadn't spotted it -- it looks like that was the error. |
||
xbnds -= xstep / 2 | ||
|
@@ -482,7 +482,6 @@ def test_barbs(): | |
x2d, y2d = np.meshgrid(x, y) | ||
u = 40 * np.cos(np.deg2rad(y2d)) | ||
v = 40 * np.cos(2. * np.deg2rad(x2d)) | ||
mag = (u**2 + v**2)**.5 | ||
plot_extent = [-60, 40, 30, 70] | ||
plt.figure(figsize=(6, 6)) | ||
# plot on native projection | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[flake8] | ||
ignore = E402,\ # Due to conditional imports | ||
E226,\ # Due to whitespace around operators (e.g. 2*x + 3) | ||
E241 # Due to multiple spaces after comma | ||
exclude = \ | ||
build, \ | ||
setup.py, \ | ||
docs/source/conf.py, \ | ||
docs/source/sphinxext/plot_directive.py |
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.
Does this comment stop Stickler complaining?
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, it's a specific indication to the flake8 tester, actually the "pyflakes" component
The bit in brackets is just comment to the reader.
If anyone is interested ...
It's really not very clearly explained, but after a bit of digging http://flake8.pycqa.org/en/latest/user/violations.html
So, "F" numbers are errors from pyflakes, and "E" and "W" numbers are from pycodestyle (pep8-successor).
I think I'll edit to make this clearer (but it ain't always easy getting it all on one line, which seems to be required)