From 17c7cf012107014222606c79d8e32e4a6d17d44e Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Fri, 6 Sep 2013 18:27:53 -0400 Subject: [PATCH 1/2] BUG: _series_unary_op() should return a Series, not a GeoSeries --- geopandas/geoseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index 6f95b08..30de157 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -118,7 +118,7 @@ class GeoSeries(Series): def _series_unary_op(self, op): """Unary operation that returns a Series""" - return GeoSeries([getattr(geom, op) for geom in self], + return Series([getattr(geom, op) for geom in self], index=self.index) # From 4eccd048a3455619cd57e97ea336e61934785f7f Mon Sep 17 00:00:00 2001 From: Kelsey Jordahl Date: Fri, 6 Sep 2013 18:29:02 -0400 Subject: [PATCH 2/2] TST: Add a type test to test_area to make sure it returns a Series. --- tests/test_geoseries.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_geoseries.py b/tests/test_geoseries.py index 7d9b4ab..f0298d6 100644 --- a/tests/test_geoseries.py +++ b/tests/test_geoseries.py @@ -1,6 +1,7 @@ import unittest import numpy as np from numpy.testing import assert_array_equal +from pandas import Series from shapely.geometry import Polygon, Point, LineString from shapely.geometry.base import BaseGeometry from geopandas import GeoSeries @@ -38,6 +39,7 @@ class TestSeries(unittest.TestCase): crs={'init': 'epsg:4326', 'no_defs': True}) def test_area(self): + assert type(self.g1.area) is Series assert_array_equal(self.g1.area.values, np.array([0.5, 1.0])) def test_in(self):