mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-28 14:12:24 +08:00
Pandas commit c6d07a8 uses iloc for head and tail, which cause these tests to fail. Skip them. The test for iloc is already being skipped.
85 lines
2.5 KiB
Python
85 lines
2.5 KiB
Python
import unittest
|
|
from shapely.geometry import Point
|
|
from pandas import Series, DataFrame
|
|
from geopandas import GeoSeries, GeoDataFrame
|
|
|
|
|
|
class TestSeries(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
N = self.N = 10
|
|
r = 0.5
|
|
self.pts = GeoSeries([Point(x, y) for x, y in zip(range(N), range(N))])
|
|
self.polys = self.pts.buffer(r)
|
|
|
|
def test_slice(self):
|
|
assert type(self.pts[:2]) is GeoSeries
|
|
assert type(self.pts[::2]) is GeoSeries
|
|
assert type(self.polys[:2]) is GeoSeries
|
|
|
|
@unittest.skip('not yet implemented')
|
|
def test_head(self):
|
|
assert type(self.pts.head()) is GeoSeries
|
|
|
|
@unittest.skip('not yet implemented')
|
|
def test_tail(self):
|
|
assert type(self.pts.tail()) is GeoSeries
|
|
|
|
def test_sort_index(self):
|
|
assert type(self.pts.sort_index()) is GeoSeries
|
|
|
|
def test_sort_order(self):
|
|
assert type(self.pts.order()) is GeoSeries
|
|
|
|
@unittest.skip('not yet implemented')
|
|
def test_loc(self):
|
|
assert type(self.pts.loc[5:]) is GeoSeries
|
|
|
|
@unittest.skip('not yet implemented')
|
|
def test_iloc(self):
|
|
assert type(self.pts.iloc[5:]) is GeoSeries
|
|
|
|
def test_fancy(self):
|
|
idx = (self.pts.index % 2).astype(bool)
|
|
assert type(self.pts[idx]) is GeoSeries
|
|
|
|
def test_take(self):
|
|
assert type(self.pts.take(range(0, self.N, 2))) is GeoSeries
|
|
|
|
def test_select(self):
|
|
assert type(self.pts.select(lambda x: x % 2 == 0)) is GeoSeries
|
|
|
|
@unittest.skip('not yet implemented')
|
|
def test_groupby(self):
|
|
for f, s in self.pts.groupby(lambda x: x % 2):
|
|
assert type(s) is GeoSeries
|
|
|
|
|
|
class TestDataFrame(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
N = 10
|
|
self.df = GeoDataFrame([
|
|
{'geometry' : Point(x, y), 'value1': x + y, 'value2': x*y}
|
|
for x, y in zip(range(N), range(N))])
|
|
|
|
def test_geometry(self):
|
|
assert type(self.df['geometry']) is GeoSeries
|
|
|
|
def test_nongeometry(self):
|
|
assert type(self.df['value1']) is Series
|
|
|
|
def test_geometry_multiple(self):
|
|
assert type(self.df[['geometry', 'value1']]) is GeoDataFrame
|
|
|
|
def test_nongeometry_multiple(self):
|
|
assert type(self.df[['value1', 'value2']]) is DataFrame
|
|
|
|
def test_slice(self):
|
|
assert type(self.df[:2]) is GeoDataFrame
|
|
assert type(self.df[::2]) is GeoDataFrame
|
|
|
|
def test_fancy(self):
|
|
idx = (self.df.index % 2).astype(bool)
|
|
assert type(self.df[idx]) is GeoDataFrame
|