File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import importlib
2
+ import sys
3
+
1
4
import matplotlib
2
5
import numpy as np
6
+ import pkg_resources
3
7
4
8
from pandas import (
5
9
DataFrame ,
6
10
DatetimeIndex ,
7
11
Series ,
12
+ __file__ as pd_file ,
8
13
date_range ,
9
14
)
10
15
13
18
except ImportError :
14
19
from pandas .tools .plotting import andrews_curves
15
20
21
+ from pandas .plotting ._core import _get_plot_backend
22
+
16
23
matplotlib .use ("Agg" )
17
24
18
25
@@ -99,4 +106,29 @@ def time_plot_andrews_curves(self):
99
106
andrews_curves (self .df , "Name" )
100
107
101
108
109
+ class BackendLoading :
110
+ def setup (self ):
111
+ dist = pkg_resources .get_distribution ("pandas" )
112
+ if dist .module_path not in pd_file :
113
+ # We are running from a non-installed pandas, and this benchmark is
114
+ # invalid
115
+ raise NotImplementedError ("Testing a non-installed pandas" )
116
+
117
+ spec = importlib .machinery .ModuleSpec ("my_backend" , None )
118
+ mod = importlib .util .module_from_spec (spec )
119
+ mod .plot = lambda * args , ** kwargs : 1
120
+
121
+ backends = pkg_resources .get_entry_map ("pandas" )
122
+ my_entrypoint = pkg_resources .EntryPoint (
123
+ "pandas_plotting_backend" , mod .__name__ , dist = dist
124
+ )
125
+ backends ["pandas_plotting_backends" ][mod .__name__ ] = my_entrypoint
126
+ for i in range (1000 ):
127
+ backends ["pandas_plotting_backends" ][str (i )] = my_entrypoint
128
+ sys .modules ["my_backend" ] = mod
129
+
130
+ def time_get_plot_backend (self ):
131
+ _get_plot_backend ("my_backend" )
132
+
133
+
102
134
from .pandas_vb_common import setup # noqa: F401 isort:skip
You can’t perform that action at this time.
0 commit comments