-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ian-r-rose/multiple-input-sources
Multiple input sources
- Loading branch information
Showing
9 changed files
with
412 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
intake | ||
dask | ||
requests | ||
pandas | ||
scipy | ||
geopandas | ||
pytest |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import pytest | ||
|
||
from intake_geopandas import GeoJSONSource, ShapefileSource | ||
|
||
|
||
@pytest.fixture | ||
def shape_filenames(): | ||
basedir = os.path.dirname(__file__) | ||
return dict( | ||
stations=os.path.join(basedir, 'data', 'stations', 'stations.shp') | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def shape_datasource(shape_filenames): | ||
return ShapefileSource(shape_filenames['stations']) | ||
|
||
|
||
@pytest.fixture | ||
def geojson_filenames(): | ||
basedir = os.path.dirname(__file__) | ||
return dict(countries=os.path.join(basedir, 'data', 'countries.geo.json')) | ||
|
||
|
||
@pytest.fixture | ||
def geojson_datasource(geojson_filenames): | ||
return GeoJSONSource(geojson_filenames['countries']) | ||
|
||
|
||
def test_shape_datasource(shape_datasource): | ||
info = shape_datasource.discover() | ||
|
||
assert info['dtype'] == {'name': 'object', | ||
'marker-col': 'object', | ||
'marker-sym': 'object', | ||
'line': 'object', | ||
'geometry': 'object'} | ||
|
||
|
||
def test_countries_datasource(geojson_datasource): | ||
info = geojson_datasource.discover() | ||
print(info) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
Tests for loading data from SQL data sources. | ||
Modified from those in the GeoPandas test suite. | ||
In order to run, SpatiaLite must be installed and configured. | ||
""" | ||
import pytest | ||
|
||
import geopandas | ||
from geopandas import read_file | ||
|
||
from intake_geopandas import SpatiaLiteSource | ||
|
||
|
||
|
||
@pytest.fixture | ||
def df_nybb(): | ||
nybb_path = geopandas.datasets.get_path('nybb') | ||
df = read_file(nybb_path) | ||
return df | ||
|
||
|
||
# Expected to fail until there is a geopandas release | ||
# with geopandas/geopandas#856 | ||
@pytest.mark.xfail | ||
def test_read_spatialite_null_geom(df_nybb): | ||
"""Tests that geometry with NULL is accepted.""" | ||
try: | ||
from geopandas.tests.util import ( | ||
connect_spatialite, create_spatialite, validate_boro_df | ||
) | ||
con = connect_spatialite() | ||
except Exception: | ||
raise pytest.skip() | ||
else: | ||
geom_col = df_nybb.geometry.name | ||
df_nybb.geometry.iat[0] = None | ||
create_spatialite(con, df_nybb) | ||
sql = ('SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, ' | ||
'AsEWKB("{0}") AS "{0}" FROM nybb').format(geom_col) | ||
df = SpatiaLiteSource(con, sql_expr=sql, geopandas_kwargs={ | ||
'geom_col': geom_col}).read() | ||
validate_boro_df(df) | ||
finally: | ||
if 'con' in locals(): | ||
con.close() | ||
|
||
# Expected to fail until there is a geopandas release | ||
# with geopandas/geopandas#856 | ||
@pytest.mark.xfail | ||
def test_read_spatialite_binary(df_nybb): | ||
"""Tests that geometry read as binary is accepted.""" | ||
try: | ||
from geopandas.tests.util import ( | ||
connect_spatialite, create_spatialite, validate_boro_df | ||
) | ||
con = connect_spatialite() | ||
except Exception: | ||
raise pytest.skip() | ||
else: | ||
geom_col = df_nybb.geometry.name | ||
create_spatialite(con, df_nybb) | ||
sql = ('SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, ' | ||
'ST_AsBinary("{0}") AS "{0}" FROM nybb').format(geom_col) | ||
df = SpatiaLiteSource(con, sql_expr=sql, geopandas_kwargs={ | ||
'geom_col': geom_col}).read() | ||
validate_boro_df(df) | ||
finally: | ||
if 'con' in locals(): | ||
con.close() |