Open jbednar opened 4 years ago
Ah, looks like hvplot/converter.py is using isinstance(data, pd.DataFrame)
for pandas, but check_library
for the rest. That explains the different behavior, leaving this as a request for hvplot to check by class in all the cases, at least if the module lookup fails. Looks tricky, as we'll now need to store a list of the (super)classes supported, not just the modules, but I think it's important.
For now a workaround is to falsely claim your subclass is defined where the superclass is, as in MyRandom.__module__= 'streamz.dataframe.core'
. Seems to work, but obviously not recommended in the long term!
It seems to be that check_library
could be replaced by:
def check_module(data, module):
if module =='dask' and module in sys.modules:
import dask.dataframe as dd
return isinstance(data, (dd.Series, dd.DataFrame))
elif ...
as we'll now need to store a list of the (super)classes supported, not just the modules, but I think it's important.
Having a mapping of modules and their supported classes wouldn't be a bad idea!
For hvplot=0.6.0, I expected to be able to use .hvplot on both library-provided classes and on user-derived classes. For instance, I expected to be able to define my own subclass of an xr.DataArray, streamz.dataframe.Dataframe, or pd.DataFrame class, and to use .hvplot() on those objects the same as on the superclass objects as long as I didn't do anything crazy in the subclass.
For a no-op derived class (just "pass"), it seems to work fine for pd.DataFrame:
But it doesn't work for the other two types:
My guess is that it's because this code in hvplot/util.py is only checking by the source module, not isinstance:
But if so I don't have any explanation for why classes derived from pd.DataFrame seem to work, given that all the classes defined above should be in module
__main__
.