Skip to content

Commit 3e160d2

Browse files
mroeschkejreback
authored andcommitted
CLN: ASV plotting (#18916)
1 parent 0660c0a commit 3e160d2

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

asv_bench/benchmarks/plotting.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
from .pandas_vb_common import *
2-
try:
3-
from pandas import date_range
4-
except ImportError:
5-
def date_range(start=None, end=None, periods=None, freq=None):
6-
return DatetimeIndex(start, end, periods=periods, offset=freq)
1+
import numpy as np
2+
from pandas import DataFrame, Series, DatetimeIndex, date_range
73
try:
84
from pandas.plotting import andrews_curves
95
except ImportError:
106
from pandas.tools.plotting import andrews_curves
7+
import matplotlib
8+
matplotlib.use('Agg')
9+
10+
from .pandas_vb_common import setup # noqa
1111

1212

1313
class Plotting(object):
14+
1415
goal_time = 0.2
1516

1617
def setup(self):
17-
import matplotlib
18-
matplotlib.use('Agg')
1918
self.s = Series(np.random.randn(1000000))
2019
self.df = DataFrame({'col': self.s})
2120

@@ -27,18 +26,17 @@ def time_frame_plot(self):
2726

2827

2928
class TimeseriesPlotting(object):
29+
3030
goal_time = 0.2
3131

3232
def setup(self):
33-
import matplotlib
34-
matplotlib.use('Agg')
3533
N = 2000
3634
M = 5
3735
idx = date_range('1/1/1975', periods=N)
3836
self.df = DataFrame(np.random.randn(N, M), index=idx)
3937

40-
idx_irregular = pd.DatetimeIndex(np.concatenate((idx.values[0:10],
41-
idx.values[12:])))
38+
idx_irregular = DatetimeIndex(np.concatenate((idx.values[0:10],
39+
idx.values[12:])))
4240
self.df2 = DataFrame(np.random.randn(len(idx_irregular), M),
4341
index=idx_irregular)
4442

@@ -53,16 +51,14 @@ def time_plot_irregular(self):
5351

5452

5553
class Misc(object):
54+
5655
goal_time = 0.6
5756

5857
def setup(self):
59-
import matplotlib
60-
matplotlib.use('Agg')
61-
self.N = 500
62-
self.M = 10
63-
data_dict = {x: np.random.randn(self.N) for x in range(self.M)}
64-
data_dict["Name"] = ["A"] * self.N
65-
self.df = DataFrame(data_dict)
58+
N = 500
59+
M = 10
60+
self.df = DataFrame(np.random.randn(N, M))
61+
self.df['Name'] = ["A"] * N
6662

6763
def time_plot_andrews_curves(self):
6864
andrews_curves(self.df, "Name")

0 commit comments

Comments
 (0)