Skip to content

Commit

Permalink
Add dtype methods to geometry interfaces (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Aug 6, 2019
1 parent 9e75e8b commit a5e80e7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ before_cache:

env:
global:
- PYENV_VERSION=3.6
- PYENV_VERSION=3.7
- PYTHON_VERSION=3.6
- PKG_TEST_PYTHON="--test-python=py36 --test-python=py27"
- CHANS_DEV="-c pyviz/label/dev -c ioam"
- CHANS_REL="-c pyviz -c ioam"
- CHANS_DEV="-c pyviz/label/dev"
- CHANS_REL="-c pyviz"
- LABELS_DEV="--label dev"
- LABELS_REL="--label dev --label main"
- MPLBACKEND="Agg"
Expand Down Expand Up @@ -53,7 +54,7 @@ jobs:
- conda config --set always_yes True
- conda install -c pyviz "pyctdev>=0.5" && doit ecosystem_setup
install:
- doit env_create $CHANS_DEV --python=$PYENV_VERSION
- doit env_create $CHANS_DEV --python=$PYTHON_VERSION
- source activate test-environment
- doit develop_install $CHANS_DEV -o recommended
- doit env_capture
Expand All @@ -66,7 +67,7 @@ jobs:
# python 2 flake checking typically catches python 2 syntax
# errors where python 3's been assumed...
- <<: *default
env: DESC="py2 flakes" PYENV_VERSION=2.7
env: DESC="py2 flakes" PYTHON_VERSION=2.7
script: doit test_flakes

########## DOCS ##########
Expand Down
7 changes: 7 additions & 0 deletions geoviews/data/geom_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def validate(cls, dataset, validate_vdims):
assert len([d for d in dataset.kdims + dataset.vdims
if d.name not in dataset.data]) == 2

@classmethod
def dtype(cls, dataset, dimension):
name = dataset.get_dimension(dimension, strict=True).name
if name not in dataset.data:
return np.dtype('float') # Geometry dimension
return super(GeomDictInterface, cls).dtype(dataset, dimension)

@classmethod
def has_holes(cls, dataset):
from shapely.geometry import Polygon, MultiPolygon
Expand Down
9 changes: 9 additions & 0 deletions geoviews/data/geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def validate(cls, dataset, vdims=True):
"dimensions, the following dimensions were "
"not found: %s" % repr(not_found), cls)


@classmethod
def dtype(cls, dataset, dimension):
name = dataset.get_dimension(dimension, strict=True).name
if name not in dataset.data:
return np.dtype('float') # Geometry dimension
return dataset.data[name].dtype


@classmethod
def has_holes(cls, dataset):
from shapely.geometry import Polygon, MultiPolygon
Expand Down

0 comments on commit a5e80e7

Please sign in to comment.