-
Notifications
You must be signed in to change notification settings - Fork 286
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
Integration test for iris.plot.contour with 2d coords. #3189
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 |
---|---|---|
|
@@ -26,10 +26,16 @@ | |
# importing anything else | ||
import iris.tests as tests | ||
|
||
import cartopy.crs as ccrs | ||
import numpy as np | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
import cartopy.crs as ccrs | ||
import iris | ||
from iris.analysis.cartography import unrotate_pole | ||
from iris.cube import Cube | ||
from iris.coords import AuxCoord | ||
|
||
|
||
# Run tests in no graphics mode if matplotlib is not available. | ||
if tests.MPL_AVAILABLE: | ||
|
@@ -63,5 +69,29 @@ def test_2d_coord_bounds_northpolarstereo(self): | |
self.check_graphic() | ||
|
||
|
||
@tests.skip_plot | ||
@tests.skip_data | ||
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 you shouldn't need this decorator as you're not making use of external test data. 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. 👍 cut+paste error, I think. 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. Ah yes, that old chestnut 🌰 |
||
class Test2dContour(tests.GraphicsTest): | ||
def test_2d_coords_contour(self): | ||
ny, nx = 4, 6 | ||
x1 = np.linspace(-20, 70, nx) | ||
y1 = np.linspace(10, 60, ny) | ||
data = np.zeros((ny, nx)) | ||
data.flat[:] = np.arange(nx * ny) % 7 | ||
cube = Cube(data, long_name='Odd data') | ||
x2, y2 = np.meshgrid(x1, y1) | ||
true_lons, true_lats = unrotate_pole(x2, y2, -130., 77.) | ||
co_x = AuxCoord(true_lons, standard_name='longitude', units='degrees') | ||
co_y = AuxCoord(true_lats, standard_name='latitude', units='degrees') | ||
cube.add_aux_coord(co_y, (0, 1)) | ||
cube.add_aux_coord(co_x, (0, 1)) | ||
ax = plt.axes(projection=ccrs.PlateCarree()) | ||
qplt.contourf(cube) | ||
ax.coastlines(color='red') | ||
ax.gridlines(draw_labels=True) | ||
ax.set_extent((0, 180, 0, 90)) | ||
self.check_graphic() | ||
|
||
|
||
if __name__ == "__main__": | ||
tests.main() |
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.
@pp-mo why is the
NumPy
import separate at the top? At minimum I feel it should be after thepyplot
import. Preferably they would both be after the Iris imports.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 think this is just another slip-up 😁
But... presumably you mean "NumPy ... after the pyplot ... before the Iris imports" ??
My understanding of our guidelines for imports is to separate into 3 or 4 specific groups :
So here, numpy and pyplot should be in the same block,
but before any Iris stuff
(except iris.tests, which is required to happen first. 🤢 yech ).
This agree with your understanding @dkillick ?
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... and no, at the same time! Basically, I feel like we've slipped away from separating (2.) and (3.), even in test modules. It's not worth sweating about here, but I would still like to see the
NumPy
import at least after thepyplot
import 😉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.
👍