Skip to content

Commit

Permalink
Moving sample_data imports out of cartopy namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
greglucas committed Aug 5, 2020
1 parent 477fb00 commit 297e1cb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/scalar_data/contour_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

from cartopy.examples.waves import sample_data
from waves import sample_data


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/vector_data/barbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import matplotlib.pyplot as plt

import cartopy.crs as ccrs
from cartopy.examples.arrows import sample_data
from arrows import sample_data


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/vector_data/streamplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import matplotlib.pyplot as plt

import cartopy.crs as ccrs
from cartopy.examples.arrows import sample_data
from arrows import sample_data


def main():
Expand Down
18 changes: 17 additions & 1 deletion lib/cartopy/tests/mpl/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
except ImportError:
WebMapTileService = None
import matplotlib.pyplot as plt
import numpy as np
import pytest

import cartopy.crs as ccrs
Expand All @@ -19,10 +20,25 @@
import cartopy.io.shapereader
import cartopy.mpl.geoaxes as cgeoaxes
import cartopy.mpl.patch
from cartopy.examples.waves import sample_data
from cartopy.tests.mpl import ImageTesting


def sample_data(shape=(73, 145)):
"""Return ``lons``, ``lats`` and ``data`` of some fake data."""
nlats, nlons = shape
lats = np.linspace(-np.pi / 2, np.pi / 2, nlats)
lons = np.linspace(0, 2 * np.pi, nlons)
lons, lats = np.meshgrid(lons, lats)
wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)
mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2)

lats = np.rad2deg(lats)
lons = np.rad2deg(lons)
data = wave + mean

return lons, lats, data


class CallCounter:
"""
Exposes a context manager which can count the number of calls to a specific
Expand Down

0 comments on commit 297e1cb

Please sign in to comment.