diff --git a/.cirrus.yml b/.cirrus.yml index 0771baeb2..5f2a94c16 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -26,8 +26,8 @@ macos_task: CMAKE_OSX_ARCHITECTURES='arm64' LDFLAGS="${LDFLAGS} -Wl,-rpath,${CIRRUS_WORKING_DIR}/pyproj/proj_dir/lib" CIBW_BEFORE_ALL_MACOS: bash ./ci/proj-compile-wheels.sh - CIBW_TEST_REQUIRES: cython pytest oldest-supported-numpy pandas xarray - CIBW_BEFORE_TEST: python -m pip install shapely || echo "Shapely install failed" + CIBW_TEST_REQUIRES: cython pytest oldest-supported-numpy + CIBW_BEFORE_TEST: python -m pip install shapely pandas xarray || echo "Optional requirements install failed" CIBW_TEST_COMMAND: > pyproj -v && python -c "import pyproj; pyproj.Proj(init='epsg:4269')" && diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ce8a94ffb..2a50796fc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -137,8 +137,8 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --add-path C:/vcpkg/installed/${{ matrix.triplet }}/bin -w {dest_dir} {wheel}" CIBW_BEFORE_ALL_LINUX: bash ./ci/proj-compile-wheels.sh CIBW_BEFORE_ALL_MACOS: bash ./ci/proj-compile-wheels.sh - CIBW_TEST_REQUIRES: cython pytest oldest-supported-numpy pandas xarray - CIBW_BEFORE_TEST: python -m pip install shapely || echo "Shapely install failed" + CIBW_TEST_REQUIRES: cython pytest oldest-supported-numpy + CIBW_BEFORE_TEST: python -m pip install shapely pandas xarray || echo "Optional requirements install failed" CIBW_TEST_COMMAND: > pyproj -v && python -c "import pyproj; pyproj.Proj(init='epsg:4269')" && diff --git a/test/test_utils.py b/test/test_utils.py index 2d9d7cf05..f539ac761 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -2,8 +2,6 @@ import numpy import pytest -from pandas import Series -from xarray import DataArray from pyproj.utils import DataType, _copytobuffer, _copytobuffer_return_scalar @@ -22,7 +20,6 @@ def test__copytobuffer_return_scalar__invalid(): "in_data, data_type", [ (numpy.array(1), DataType.FLOAT), - (DataArray(numpy.array(1)), DataType.FLOAT), (1, DataType.FLOAT), ([1], DataType.LIST), ((1,), DataType.TUPLE), @@ -32,10 +29,23 @@ def test__copytobuffer(in_data, data_type): assert _copytobuffer(in_data) == (array("d", [1]), data_type) -@pytest.mark.parametrize( - "in_arr", [numpy.array([1]), DataArray(numpy.array([1])), Series(numpy.array([1]))] -) -def test__copytobuffer__numpy_array(in_arr): +def test__copytobuffer__xarray_scalar(): + xarray = pytest.importorskip("xarray") + assert _copytobuffer(xarray.DataArray(numpy.array(1))) == ( + array("d", [1]), + DataType.FLOAT, + ) + + +@pytest.mark.parametrize("arr_type", ["numpy", "xarray", "pandas"]) +def test__copytobuffer__array(arr_type): + in_arr = numpy.array([1]) + if arr_type == "xarray": + xarray = pytest.importorskip("xarray") + in_arr = xarray.DataArray(in_arr) + elif arr_type == "pandas": + pandas = pytest.importorskip("pandas") + in_arr = pandas.Series(in_arr) assert _copytobuffer(in_arr) == ( in_arr.astype("d").__array__(), DataType.ARRAY,