Skip to content

Commit

Permalink
Merge eca1747 into 20baa25
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus89 committed Oct 8, 2019
2 parents 20baa25 + eca1747 commit 7837470
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 56 deletions.
2 changes: 0 additions & 2 deletions binder/requirements.txt
@@ -1,8 +1,6 @@
cartoframes==1.0b3
# Additional dependencies from examples
matplotlib
pandas
geopandas
dask
# needed for pandas.read_excel in data obs notebook
xlrd
9 changes: 2 additions & 7 deletions cartoframes/utils/geom_utils.py
Expand Up @@ -4,17 +4,12 @@
from warnings import warn
from copy import deepcopy
import geojson
import geopandas

from carto.exceptions import CartoException

from ..lib import context

try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False


GEOM_COLUMN_NAMES = [
'geometry',
Expand Down Expand Up @@ -58,7 +53,7 @@ def compute_query(dataset):


def compute_geodataframe(dataset):
if HAS_GEOPANDAS and dataset.dataframe is not None:
if dataset.dataframe is not None:
if isinstance(dataset.dataframe, geopandas.GeoDataFrame):
return dataset.dataframe

Expand Down
14 changes: 1 addition & 13 deletions cartoframes/utils/utils.py
Expand Up @@ -8,6 +8,7 @@
import base64
import hashlib
import requests
import geopandas
import numpy as np

from functools import wraps
Expand Down Expand Up @@ -197,19 +198,6 @@ def get_query_bounds(context, query):


def load_geojson(input_data):
try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False

if not HAS_GEOPANDAS:
raise ValueError(
'''
GeoJSON source only works with GeoDataFrames from
the geopandas package http://geopandas.org/data_structures.html#geodataframe
''')

if isinstance(input_data, str):
# File name
data = geopandas.read_file(input_data)
Expand Down
10 changes: 2 additions & 8 deletions cartoframes/viz/layer.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import

import pandas
import geopandas

from .source import Source
from .style import Style
Expand All @@ -11,12 +12,6 @@
from ..data import Dataset
from ..utils.utils import merge_dicts

try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False


class Layer(object):
"""Layer to display data on a map. This class can be used as one or more
Expand Down Expand Up @@ -167,8 +162,7 @@ def _repr_html_(self):

def _set_source(source, credentials, bounds):
"""Set a Source class from the input"""
if isinstance(source, (str, list, dict, Dataset, pandas.DataFrame)) or \
HAS_GEOPANDAS and isinstance(source, geopandas.GeoDataFrame):
if isinstance(source, (str, list, dict, Dataset, pandas.DataFrame)) or isinstance(source, geopandas.GeoDataFrame):
return Source(source, credentials, bounds)
elif isinstance(source, Source):
return source
Expand Down
6 changes: 0 additions & 6 deletions cartoframes/viz/source.py
Expand Up @@ -4,12 +4,6 @@
from ..data import Dataset
from ..utils.utils import get_query_bounds, get_geodataframe_bounds, encode_geodataframe

try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False


class SourceType:
QUERY = 'Query'
Expand Down
1 change: 0 additions & 1 deletion docs/developers/documentation.rst
Expand Up @@ -8,7 +8,6 @@ Requirements

- sphinx>=1.6.5
- sphinxcontrib-napoleon>=0.7.0
- geopandas>=0.5.1

This can be installed with the following command:

Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Expand Up @@ -2,4 +2,3 @@

sphinx>=1.6.5
sphinxcontrib-napoleon>=0.7.0
geopandas>=0.5.1
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -22,8 +22,7 @@ def walk_subpkg(name):
'appdirs>=1.4.3,<2.0',
'carto>=1.7.0,<2.0',
'jinja2>=2.10.1,<3.0',
'pandas>=0.24.2<1.0',
'shapely>=1.6.4,<2.0',
'geopandas>=0.6.0,<1.0',
'tqdm>=4.32.1,<5.0',
'unidecode>=1.1.0,<2.0',
'pyarrow>=0.14.1,<1.0',
Expand Down
11 changes: 2 additions & 9 deletions test/data/dataset/test_dataset.py
Expand Up @@ -7,6 +7,7 @@
import json
import warnings
import pandas as pd
import geopandas as gpd

from carto.exceptions import CartoException

Expand All @@ -33,12 +34,6 @@

from test.helpers import _UserUrlLoader

try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False

WILL_SKIP = False
warnings.filterwarnings('ignore')

Expand Down Expand Up @@ -323,7 +318,6 @@ def test_dataset_write_geopandas(self):

from cartoframes.examples import read_taxi
import shapely
import geopandas as gpd
df = read_taxi(limit=50)
df.drop(['the_geom'], axis=1, inplace=True)
gdf = gpd.GeoDataFrame(df.drop(['dropoff_longitude', 'dropoff_latitude'], axis=1),
Expand Down Expand Up @@ -608,10 +602,9 @@ def test_creation_from_valid_dataframe(self):
df = pd.DataFrame.from_dict({'test': [True, [1, 2]]})
self.assertIsDataFrameDatasetInstance(df)

@unittest.skipIf(not HAS_GEOPANDAS, 'no geopandas imported, skipping this test')
def test_creation_from_valid_geodataframe(self):
df = pd.DataFrame.from_dict({'test': [True, [1, 2]]})
gdf = geopandas.GeoDataFrame(df)
gdf = gpd.GeoDataFrame(df)
self.assertIsDataFrameDatasetInstance(gdf)

def test_creation_from_valid_localgeojson(self):
Expand Down
6 changes: 0 additions & 6 deletions test/data/services/test_geocoding.py
Expand Up @@ -21,12 +21,6 @@

from cartoframes.data.services import Geocoding

try:
import geopandas
HAS_GEOPANDAS = True
except ImportError:
HAS_GEOPANDAS = False

from test.helpers import _UserUrlLoader, _ReportQuotas

warnings.filterwarnings('ignore')
Expand Down
1 change: 0 additions & 1 deletion test/test_requirements.txt
@@ -1,5 +1,4 @@
pytest
geopandas
matplotlib
coveralls
mock

0 comments on commit 7837470

Please sign in to comment.