Closed
Description
Right now a pd.set_option('display.backend', name)
will
- look for an entrypoint
- fall back to importing the module
name
and setting that to the backend
In the second case, the backend's implementation isn't validated until a plot is actually requested. We should validate that name.plot
is a thing when the backend is set.
In [16]: module = types.ModuleType("foo")
In [17]: sys.modules['foo'] = module
In [18]: pd.set_option('plotting.backend', 'foo')
In [19]: df = pd.DataFrame({"A": [1, 2]})
In [20]: df.plot()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-848b80e64df8> in <module>
----> 1 df.plot()
~/sandbox/pandas/pandas/plotting/_core.py in __call__(self, *args, **kwargs)
794 data.columns = label_name
795
--> 796 return plot_backend.plot(data, kind=kind, **kwargs)
797
798 def line(self, x=None, y=None, **kwargs):
AttributeError: module 'foo' has no attribute 'plot'
Rather than raising an AttributeError
on df.plot
, we should raise a ValueError
on pd.set_option('plotting.backend', 'foo')
.