@@ -82,7 +82,20 @@ def mpl_test_settings(request):
82
82
83
83
@pytest .fixture
84
84
def pd ():
85
- """Fixture to import and configure pandas."""
85
+ """
86
+ Fixture to import and configure pandas.
87
+
88
+ Example
89
+ -------
90
+ Instead of importing pandas in the test file, request the pandas fixture by
91
+ passing in `pd` as an argument to the testing function ::
92
+
93
+ def test_matshow_pandas(pd):
94
+
95
+ df = pd.DataFrame({'x':[1,2,3], 'y':[4,5,6]})
96
+ im = plt.figure().subplots().matshow(df)
97
+ np.testing.assert_array_equal(im.get_array(), df)
98
+ """
86
99
pd = pytest .importorskip ('pandas' )
87
100
try :
88
101
from pandas .plotting import (
@@ -95,6 +108,20 @@ def pd():
95
108
96
109
@pytest .fixture
97
110
def xr ():
98
- """Fixture to import xarray."""
111
+ """
112
+ Fixture to import xarray.
113
+
114
+ Example
115
+ -------
116
+ Instead of importing xarray in the test file, request the xarray fixture by
117
+ passing in `xr` as an argument to the testing function ::
118
+
119
+ def test_imshow_xarray(xr):
120
+
121
+ ds = xr.DataArray(np.random.randn(2, 3))
122
+ im = plt.figure().subplots().imshow(ds)
123
+ np.testing.assert_array_equal(im.get_array(), ds)
124
+ """
125
+
99
126
xr = pytest .importorskip ('xarray' )
100
127
return xr
0 commit comments