diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b93554b..a1327c8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -51,7 +51,7 @@ jobs: os: windows-latest postgis: false dev: false - - env: ci/envs/37-dev.yaml + - env: ci/envs/38-dev.yaml os: ubuntu-latest dev: true diff --git a/ci/envs/37-dev.yaml b/ci/envs/38-dev.yaml similarity index 86% rename from ci/envs/37-dev.yaml rename to ci/envs/38-dev.yaml index 0f5a270..5b060fc 100644 --- a/ci/envs/37-dev.yaml +++ b/ci/envs/38-dev.yaml @@ -1,8 +1,8 @@ name: test channels: - - defaults + - conda-forge dependencies: - - python=3.7.3 + - python=3.8 - cython # required - fiona @@ -23,6 +23,7 @@ dependencies: - geopy - mapclassify>=2.2.0 # dev versions of packages + - git+https://github.com/numpy/numpy.git@master - git+https://github.com/pydata/pandas.git@master - git+https://github.com/matplotlib/matplotlib.git@master - git+https://github.com/Toblerity/Shapely.git@master diff --git a/geopandas/array.py b/geopandas/array.py index 114141c..ea2accc 100644 --- a/geopandas/array.py +++ b/geopandas/array.py @@ -783,7 +783,9 @@ class GeometryArray(ExtensionArray): "Value should be either a BaseGeometry or None, got %s" % str(value) ) # self.data[idx] = value - self.data[idx] = np.array([value], dtype=object) + value_arr = np.empty(1, dtype=object) + value_arr[:] = [value] + self.data[idx] = value_arr return self def fillna(self, value=None, method=None, limit=None): diff --git a/geopandas/io/tests/test_file.py b/geopandas/io/tests/test_file.py index 96b11a1..5951122 100644 --- a/geopandas/io/tests/test_file.py +++ b/geopandas/io/tests/test_file.py @@ -159,7 +159,6 @@ def test_to_file_types(tmpdir, df_points): """ Test various integer type columns (GH#93) """ tempfilename = os.path.join(str(tmpdir), "int.shp") int_types = [ - np.int, np.int8, np.int16, np.int32, @@ -169,7 +168,6 @@ def test_to_file_types(tmpdir, df_points): np.uint16, np.uint32, np.uint64, - np.long, ] geometry = df_points.geometry data = dict( diff --git a/geopandas/tests/test_array.py b/geopandas/tests/test_array.py index 3f128f9..9b0f0e0 100644 --- a/geopandas/tests/test_array.py +++ b/geopandas/tests/test_array.py @@ -52,8 +52,8 @@ def equal_geometries(result, expected): def test_points(): - x = np.arange(10).astype(np.float) - y = np.arange(10).astype(np.float) ** 2 + x = np.arange(10).astype(np.float64) + y = np.arange(10).astype(np.float64) ** 2 points = points_from_xy(x, y) assert isinstance(points, GeometryArray) @@ -500,7 +500,7 @@ def test_unary_float(attr): na_value = np.nan result = getattr(T, attr) assert isinstance(result, np.ndarray) - assert result.dtype == np.float + assert result.dtype == np.dtype("float64") expected = [getattr(t, attr) if t is not None else na_value for t in triangles] np.testing.assert_allclose(result, expected) diff --git a/geopandas/tests/test_extension_array.py b/geopandas/tests/test_extension_array.py index 5c2a01d..37d37a3 100644 --- a/geopandas/tests/test_extension_array.py +++ b/geopandas/tests/test_extension_array.py @@ -16,6 +16,7 @@ expected to be available to pytest by the inherited pandas tests). import operator import numpy as np +from numpy.testing import assert_array_equal import pandas as pd from pandas.tests.extension import base as extension_tests @@ -46,7 +47,8 @@ def dtype(): def make_data(): - a = np.array([shapely.geometry.Point(i, i) for i in range(100)], dtype=object) + a = np.empty(100, dtype=object) + a[:] = [shapely.geometry.Point(i, i) for i in range(100)] ga = from_shapely(a) return ga @@ -287,6 +289,19 @@ class TestDtype(extension_tests.BaseDtypeTests): class TestInterface(extension_tests.BaseInterfaceTests): + def test_array_interface(self, data): + # we are overriding this base test because the creation of `expected` + # potentionally doesn't work for shapely geometries + # TODO can be removed with Shapely 2.0 + result = np.array(data) + assert result[0] == data[0] + + result = np.array(data, dtype=object) + # expected = np.array(list(data), dtype=object) + expected = np.empty(len(data), dtype=object) + expected[:] = list(data) + assert_array_equal(result, expected) + def test_contains(self, data, data_missing): # overrided due to the inconsistency between # GeometryDtype.na_value = np.nan