Skip to content

Commit

Permalink
Merge e8c7d1a into f2fb5d4
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 21, 2020
2 parents f2fb5d4 + e8c7d1a commit dbc1e11
Show file tree
Hide file tree
Showing 8 changed files with 814 additions and 181 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ holoviews.rc
ghostdriver.log
holoviews/.version
.dir-locals.el
.doit.db
.vscode/settings.json
holoviews/.vscode/settings.json
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ notifications:
env:
global:
- PKG_TEST_PYTHON="--test-python=py37 --test-python=py27"
- CHANS_DEV="-c pyviz/label/dev -c bokeh"
- CHANS_DEV="-c pyviz/label/dev -c bokeh -c conda-forge"
- CHANS="-c pyviz"
- MPLBACKEND="Agg"
- PYTHON_VERSION=3.7
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
install:
- doit env_create $CHANS_DEV --python=$PYTHON_VERSION
- source activate test-environment
- travis_wait 30 doit develop_install $CHANS_DEV -o $HV_REQUIREMENTS
- travis_wait 45 doit develop_install $CHANS_DEV -o $HV_REQUIREMENTS
- doit env_capture
- hash -r
script:
Expand Down
1 change: 1 addition & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ dependencies:
- bzip2
- dask
- scipy
- ibis-framework >= 1.3
83 changes: 21 additions & 62 deletions holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import numpy as np
import param
import pandas as pd # noqa

from param.parameterized import add_metaclass, ParameterizedMetaclass

Expand All @@ -21,57 +22,24 @@
from ..element import Element
from ..ndmapping import OrderedDict, MultiDimensionalMapping
from ..spaces import HoloMap, DynamicMap
from .interface import Interface, iloc, ndloc
from .array import ArrayInterface
from .dictionary import DictInterface
from .grid import GridInterface

from .array import ArrayInterface # noqa (API import)
from .cudf import cuDFInterface # noqa (API import)
from .dask import DaskInterface # noqa (API import)
from .dictionary import DictInterface # noqa (API import)
from .grid import GridInterface # noqa (API import)
from .ibis import IbisInterface # noqa (API import)
from .interface import Interface, iloc, ndloc # noqa (API import)
from .multipath import MultiInterface # noqa (API import)
from .image import ImageInterface # noqa (API import)
from .pandas import PandasInterface # noqa (API import)
from .spatialpandas import SpatialPandasInterface # noqa (API import)
from .xarray import XArrayInterface # noqa (API import)

default_datatype = 'dictionary'
datatypes = ['dictionary', 'grid']

try:
import pandas as pd # noqa (Availability import)
from .pandas import PandasInterface
default_datatype = 'dataframe'
datatypes.insert(0, 'dataframe')
DFColumns = PandasInterface
except ImportError:
pd = None
except Exception as e:
pd = None
param.main.param.warning('Pandas interface failed to import with '
'following error: %s' % e)
default_datatype = 'dataframe'

try:
from .spatialpandas import SpatialPandasInterface # noqa (API import)
datatypes.append('spatialpandas')
except ImportError:
pass

try:
from .xarray import XArrayInterface # noqa (Conditional API import)
datatypes.append('xarray')
except ImportError:
pass

try:
from .cudf import cuDFInterface # noqa (Conditional API import)
datatypes.append('cuDF')
except ImportError:
pass

try:
from .dask import DaskInterface # noqa (Conditional API import)
datatypes.append('dask')
except ImportError:
pass

if 'array' not in datatypes:
datatypes.append('array')
if 'multitabular' not in datatypes:
datatypes.append('multitabular')
datatypes = ['dataframe', 'dictionary', 'grid', 'xarray', 'dask',
'cuDF', 'spatialpandas', 'array', 'multitabular', 'ibis']


def concat(datasets, datatype=None):
Expand Down Expand Up @@ -441,7 +409,7 @@ def closest(self, coords=[], **kwargs):
if xs.dtype.kind in 'SO':
raise NotImplementedError("Closest only supported for numeric types")
idxs = [np.argmin(np.abs(xs-coord)) for coord in coords]
return [xs[idx] for idx in idxs]
return [type(s)(xs[idx]) for s, idx in zip(coords, idxs)]


def sort(self, by=None, reverse=False):
Expand Down Expand Up @@ -594,15 +562,13 @@ def select(self, selection_expr=None, selection_specs=None, **selection):
# Handle selection dim expression
if selection_expr is not None:
mask = selection_expr.apply(self, compute=False, keep_index=True)
dataset = self[mask]
else:
dataset = self
selection = {'selection_mask': mask}

# Handle selection kwargs
if selection:
data = dataset.interface.select(dataset, **selection)
data = self.interface.select(self, **selection)
else:
data = dataset.data
data = self.data

if np.isscalar(data):
return data
Expand Down Expand Up @@ -678,7 +644,7 @@ def __getitem__(self, slices):
if not len(slices) == len(self):
raise IndexError("Boolean index must match length of sliced object")
return self.clone(self.select(selection_mask=slices))
elif slices in [(), Ellipsis]:
elif (isinstance(slices, ()) and len(slices) == 1) or slices is Ellipsis:
return self
if not isinstance(slices, tuple): slices = (slices,)
value_select = None
Expand Down Expand Up @@ -770,7 +736,7 @@ def sample(self, samples=[], bounds=None, closest=True, **kwargs):
# may be replaced with more general handling
# see https://github.com/ioam/holoviews/issues/1173
from ...element import Table, Curve
datatype = ['dataframe', 'dictionary', 'dask']
datatype = ['dataframe', 'dictionary', 'dask', 'ibis']
if len(samples) == 1:
sel = {kd.name: s for kd, s in zip(self.kdims, samples[0])}
dims = [kd for kd, v in sel.items() if not np.isscalar(v)]
Expand Down Expand Up @@ -1241,10 +1207,3 @@ def ndloc(self):
dataset.ndloc[[1, 2, 3], [0, 2, 3]]
"""
return ndloc(self)


# Aliases for pickle backward compatibility
Columns = Dataset
ArrayColumns = ArrayInterface
DictColumns = DictInterface
GridColumns = GridInterface

0 comments on commit dbc1e11

Please sign in to comment.