Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dtype methods to geometry interfaces #345

Merged
merged 4 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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