From a50551de7b6a346d8da15d0ec7c4678c73776fa3 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Thu, 7 Sep 2023 16:52:26 -0300 Subject: [PATCH] Separate Python packages (#50) * start separating python packages * maybe CI * maybe docs * move import to geoarrow.c * with passing test * readme * fix a few references * maybe fix doctests * fix package name * fix install instructions * maybe fix doctest * move doctests to the end * maybe fix wheel name * maybe fix * actions * maybe fix doc * also ignore opt/ for coverage * maybe actually get doctests to run * maybe more portable doctest --- .env | 6 -- .github/workflows/python.yaml | 32 +++++----- README.md | 2 +- ci/scripts/build-docs.sh | 4 +- docker-compose.yml | 9 +-- docs/source/conf.py | 2 +- docs/source/python/geoarrow.rst | 2 +- docs/source/python/pyarrow.rst | 6 +- python/{ => geoarrow-c}/.coveragerc | 0 python/{ => geoarrow-c}/.gitignore | 4 +- python/{ => geoarrow-c}/MANIFEST.in | 5 +- python/{ => geoarrow-c}/README.ipynb | 42 +++++--------- python/{ => geoarrow-c}/README.md | 39 ++++--------- python/{ => geoarrow-c}/bootstrap.py | 4 +- python/{ => geoarrow-c}/pyproject.toml | 2 +- python/{ => geoarrow-c}/setup.py | 12 ++-- .../src/geoarrow/c}/__init__.py | 4 +- .../src/geoarrow/c}/_lib.pyx | 0 .../c}/geoarrow_python/geoarrow_config.h | 0 .../c}/geoarrow_python/geoarrow_python.h | 0 .../src/geoarrow/c}/lib.py | 10 ++-- .../src/geoarrow/c}/pandas.py | 2 +- .../src/geoarrow/c}/pyarrow/__init__.py | 6 +- .../src/geoarrow/c}/pyarrow/_array.py | 4 +- .../src/geoarrow/c}/pyarrow/_compute.py | 46 +++++++-------- .../src/geoarrow/c}/pyarrow/_dataset.py | 16 ++--- .../src/geoarrow/c}/pyarrow/_kernel.py | 0 .../src/geoarrow/c}/pyarrow/_scalar.py | 0 .../src/geoarrow/c}/pyarrow/_type.py | 58 +++++++++---------- .../tests/test_geoarrow_dataset.py | 4 +- .../tests/test_geoarrow_lib.py | 4 +- .../tests/test_geoarrow_pandas.py | 6 +- .../tests/test_geoarrow_pandas_suite.py | 4 +- .../tests/test_geoarrow_pyarrow.py | 8 +-- .../tests/test_geoarrow_pyarrow_compute.py | 8 +-- 35 files changed, 157 insertions(+), 194 deletions(-) delete mode 100644 .env rename python/{ => geoarrow-c}/.coveragerc (100%) rename python/{ => geoarrow-c}/.gitignore (95%) rename python/{ => geoarrow-c}/MANIFEST.in (89%) rename python/{ => geoarrow-c}/README.ipynb (85%) rename python/{ => geoarrow-c}/README.md (80%) rename python/{ => geoarrow-c}/bootstrap.py (91%) rename python/{ => geoarrow-c}/pyproject.toml (98%) rename python/{ => geoarrow-c}/setup.py (90%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/__init__.py (78%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/_lib.pyx (100%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/geoarrow_python/geoarrow_config.h (100%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/geoarrow_python/geoarrow_python.h (100%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/lib.py (95%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pandas.py (99%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/__init__.py (92%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_array.py (98%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_compute.py (93%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_dataset.py (97%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_kernel.py (100%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_scalar.py (100%) rename python/{src/geoarrow => geoarrow-c/src/geoarrow/c}/pyarrow/_type.py (94%) rename python/{ => geoarrow-c}/tests/test_geoarrow_dataset.py (98%) rename python/{ => geoarrow-c}/tests/test_geoarrow_lib.py (98%) rename python/{ => geoarrow-c}/tests/test_geoarrow_pandas.py (98%) rename python/{ => geoarrow-c}/tests/test_geoarrow_pandas_suite.py (98%) rename python/{ => geoarrow-c}/tests/test_geoarrow_pyarrow.py (99%) rename python/{ => geoarrow-c}/tests/test_geoarrow_pyarrow_compute.py (99%) diff --git a/.env b/.env deleted file mode 100644 index 8e2ceb04..00000000 --- a/.env +++ /dev/null @@ -1,6 +0,0 @@ - -# Required to set default values for docker-compose.yml - -# Use nanoarrow's docker images -REPO=ghcr.io/apache/arrow-nanoarrow -GEOARROW_ARCH=amd64 diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index d0e9f2ac..6f6b33d2 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -32,22 +32,14 @@ jobs: - name: Install geoarrow run: | - pushd python + pushd python/geoarrow-c pip install .[test] popd pip list - name: Run tests run: | - pytest python/tests -v -s - - - name: Run doctests - if: success() && matrix.python-version == '3.10' - run: | - pytest --pyargs geoarrow --doctest-modules - # No Cython docs yet - # pip install pytest-cython - # pytest --pyargs geoarrow --doctest-cython + pytest python/geoarrow-c/tests -v -s - name: Coverage if: success() && matrix.python-version == '3.10' @@ -55,7 +47,7 @@ jobs: sudo apt-get install -y lcov pip uninstall --yes geoarrow pip install pytest-cov Cython - pushd python + pushd python/geoarrow-c # Build with Cython + gcc coverage options pip install -e .[test] @@ -69,9 +61,10 @@ jobs: lcov \ --capture --directory build \ --exclude "/usr/*" \ + --exclude "/opt/*" \ --exclude "/Library/*" \ --exclude "*/_lib.cpp" \ - --exclude "*/src/geoarrow/geoarrow/*" \ + --exclude "*/src/geoarrow/c/geoarrow/*" \ --output-file=coverage.info lcov --list coverage.info @@ -80,4 +73,17 @@ jobs: if: success() && matrix.python-version == '3.10' uses: codecov/codecov-action@v2 with: - files: 'python/coverage.info,python/coverage.xml' + files: 'python/geoarrow-coverage.info,python/geoarrow-c/coverage.xml' + + - name: Run doctests + if: success() && matrix.python-version == '3.10' + run: | + # Because of namespace packaging we have to add this here and + # rebuild to avoid confusig pytest + touch python/geoarrow-c/src/geoarrow/__init__.py + pip install python/geoarrow-c + + pytest --pyargs geoarrow.c --doctest-modules + # No Cython docs yet + # pip install pytest-cython + # pytest --pyargs geoarrow --doctest-cython diff --git a/README.md b/README.md index e4ddb5f8..0856020a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ release of the geoarrow specification. ## Get started in Python ```python -import geoarrow.pyarrow as ga +import geoarrow.c.pyarrow as ga ga.point() # PointType(geoarrow.point) diff --git a/ci/scripts/build-docs.sh b/ci/scripts/build-docs.sh index 59bc1048..1d39a42e 100755 --- a/ci/scripts/build-docs.sh +++ b/ci/scripts/build-docs.sh @@ -51,10 +51,10 @@ main() { # pip install . doesn't quite work with the setuptools available on the # ubuntu docker image...python -m build works I think because it sets up # a virtualenv - pushd python + pushd python/geoarrow-c rm -rf dist python3 -m build --wheel - pip3 install dist/geoarrow-*.whl + pip3 install dist/geoarrow*.whl popd pushd docs diff --git a/docker-compose.yml b/docker-compose.yml index 48368ac3..d0313301 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,14 +4,7 @@ version: '3.5' services: docs: - image: ${REPO}:ubuntu-${GEOARROW_ARCH} - build: - context: . - cache_from: - - ${REPO}:ubuntu-${GEOARROW_ARCH} - dockerfile: ci/docker/ubuntu.dockerfile - args: - GEOARROW_ARCH: ${GEOARROW_ARCH} + image: ghcr.io/apache/arrow-nanoarrow:ubuntu volumes: - .:/geoarrow-c command: "/bin/bash /geoarrow-c/ci/scripts/build-docs.sh" diff --git a/docs/source/conf.py b/docs/source/conf.py index 1c79597e..41d1b076 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ import sys import datetime -import geoarrow +import geoarrow.c sys.path.insert(0, os.path.abspath("..")) diff --git a/docs/source/python/geoarrow.rst b/docs/source/python/geoarrow.rst index 3f5e562d..2041cffe 100644 --- a/docs/source/python/geoarrow.rst +++ b/docs/source/python/geoarrow.rst @@ -2,7 +2,7 @@ Core API ======== -.. automodule:: geoarrow +.. automodule:: geoarrow.c :members: Constants diff --git a/docs/source/python/pyarrow.rst b/docs/source/python/pyarrow.rst index 64b09259..e8bd9295 100644 --- a/docs/source/python/pyarrow.rst +++ b/docs/source/python/pyarrow.rst @@ -2,7 +2,7 @@ Integration with pyarrow ======================== -.. automodule:: geoarrow.pyarrow +.. automodule:: geoarrow.c.pyarrow Array constructors ------------------ @@ -100,8 +100,8 @@ Integration with pyarrow .. autoclass:: MultiPolygonType :members: - .. autoclass:: geoarrow.pyarrow._dataset.GeoDataset + .. autoclass:: geoarrow.c.pyarrow._dataset.GeoDataset :members: - .. autoclass:: geoarrow.pyarrow._dataset.ParquetRowGroupGeoDataset + .. autoclass:: geoarrow.c.pyarrow._dataset.ParquetRowGroupGeoDataset :members: diff --git a/python/.coveragerc b/python/geoarrow-c/.coveragerc similarity index 100% rename from python/.coveragerc rename to python/geoarrow-c/.coveragerc diff --git a/python/.gitignore b/python/geoarrow-c/.gitignore similarity index 95% rename from python/.gitignore rename to python/geoarrow-c/.gitignore index 2060888f..7f728445 100644 --- a/python/.gitignore +++ b/python/geoarrow-c/.gitignore @@ -16,8 +16,8 @@ # specific language governing permissions and limitations # under the License. -src/geoarrow/geoarrow -src/geoarrow/_lib.cpp +src/geoarrow/c/geoarrow +src/geoarrow/c/_lib.cpp # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/python/MANIFEST.in b/python/geoarrow-c/MANIFEST.in similarity index 89% rename from python/MANIFEST.in rename to python/geoarrow-c/MANIFEST.in index 516f39c0..e982dd98 100644 --- a/python/MANIFEST.in +++ b/python/geoarrow-c/MANIFEST.in @@ -16,5 +16,6 @@ # under the License. exclude bootstrap.py -include src/geoarrow/geoarrow/*.h -include src/geoarrow/geoarrow/*.hpp +include src/geoarrow/c/**/**/*.h +include src/geoarrow/c/**/*.h +include src/geoarrow/c/**/*.hpp diff --git a/python/README.ipynb b/python/geoarrow-c/README.ipynb similarity index 85% rename from python/README.ipynb rename to python/geoarrow-c/README.ipynb index db1b6678..f912a36b 100644 --- a/python/README.ipynb +++ b/python/geoarrow-c/README.ipynb @@ -14,7 +14,7 @@ "Python bindings for nanoarrow are not yet available on PyPI. You can install via URL (requires a C++ compiler):\n", "\n", "```bash\n", - "python -m pip install \"https://github.com/geoarrow/geoarrow-cpp/archive/refs/heads/main.zip#egg=geoarrow&subdirectory=python\"\n", + "python -m pip install \"https://github.com/geoarrow/geoarrow-c/archive/refs/heads/main.zip#egg=geoarrow-c&subdirectory=python/geoarrow-c\"\n", "```\n", "\n", "If you can import the namespace, you're good to go! The only reasonable interface to geoarrow currently depends on `pyarrow`, which you can import with:" @@ -26,7 +26,7 @@ "metadata": {}, "outputs": [], "source": [ - "import geoarrow.pyarrow as ga" + "import geoarrow.c.pyarrow as ga" ] }, { @@ -48,7 +48,7 @@ "data": { "text/plain": [ "PointArray:PointType(geoarrow.point)[1]\n", - "\n" + "" ] }, "execution_count": 2, @@ -88,7 +88,7 @@ "PointArray:PointType(geoarrow.point)[3]\n", "\n", "\n", - "\n" + "" ] }, "execution_count": 3, @@ -117,7 +117,7 @@ "PointArray:PointType(interleaved geoarrow.point)[3]\n", "\n", "\n", - "\n" + "" ] }, "execution_count": 4, @@ -137,7 +137,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Importing `geoarrow.pyarrow` will register the geoarrow extension types with pyarrow such that you can read/write Arrow streams, Arrow files, and Parquet that contains Geoarrow extension types. A number of these files are available from the [geoarrow-data](https://github.com/geoarrow/geoarrow-data) repository." + "Importing `geoarrow.c.pyarrow` will register the geoarrow extension types with pyarrow such that you can read/write Arrow streams, Arrow files, and Parquet that contains Geoarrow extension types. A number of these files are available from the [geoarrow-data](https://github.com/geoarrow/geoarrow-data) repository." ] }, { @@ -189,22 +189,6 @@ "execution_count": 6, "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/geopandas/_compat.py:124: UserWarning: The Shapely GEOS version (3.11.1-CAPI-1.17.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.\n", - " warnings.warn(\n", - "/var/folders/gt/l87wjg8s7312zs9s7c1fgs900000gn/T/ipykernel_81348/2107898165.py:1: DeprecationWarning: Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas still uses PyGEOS by default. However, starting with version 0.14, the default will switch to Shapely. To force to use Shapely 2.0 now, you can either uninstall PyGEOS or set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas:\n", - "\n", - "import os\n", - "os.environ['USE_PYGEOS'] = '0'\n", - "import geopandas\n", - "\n", - "In the next release, GeoPandas will switch to using Shapely by default, even if PyGEOS is installed. If you only have PyGEOS installed to get speed-ups, this switch should be smooth. However, if you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html).\n", - " import geopandas\n" - ] - }, { "data": { "text/plain": [ @@ -216,9 +200,9 @@ "\n", "...245 values...\n", "\n", - "\n", - "\n", - "\n", + "\n", + "\n", + "\n", "" ] }, @@ -381,9 +365,9 @@ "\n", "...245 values...\n", "\n", - "\n", - "\n", - "\n", + "\n", + "\n", + "\n", "" ] }, @@ -444,7 +428,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.2" }, "orig_nbformat": 4 }, diff --git a/python/README.md b/python/geoarrow-c/README.md similarity index 80% rename from python/README.md rename to python/geoarrow-c/README.md index 64a1fe2f..c88a9e8b 100644 --- a/python/README.md +++ b/python/geoarrow-c/README.md @@ -1,20 +1,20 @@ # geoarrow for Python -The geoarrow Python package provides bindings to the geoarrow-c implementation of the [GeoArrow specification](https://github.com/geoarrow/geoarrow). The geoarrow Python bindings provide input/output to/from Arrow-friendly formats (e.g., Parquet, Arrow Stream, Arrow File) and general-purpose coordinate shuffling tools among GeoArrow, WKT, and WKB encodings. +The geoarrow Python package provides bindings to the geoarrow-c implementation of the [GeoArrow specification](https://github.com/geoarrow/geoarrow). The geoarrow Python bindings provide input/output to/from Arrow-friendly formats (e.g., Parquet, Arrow Stream, Arrow File) and general-purpose coordinate shuffling tools among GeoArrow, WKT, and WKB encodings. ## Installation Python bindings for nanoarrow are not yet available on PyPI. You can install via URL (requires a C++ compiler): ```bash -python -m pip install "https://github.com/geoarrow/geoarrow-cpp/archive/refs/heads/main.zip#egg=geoarrow&subdirectory=python" +python -m pip install "https://github.com/geoarrow/geoarrow-c/archive/refs/heads/main.zip#egg=geoarrow-c&subdirectory=python/geoarrow-c" ``` If you can import the namespace, you're good to go! The only reasonable interface to geoarrow currently depends on `pyarrow`, which you can import with: ```python -import geoarrow.pyarrow as ga +import geoarrow.c.pyarrow as ga ``` ## Examples @@ -34,7 +34,6 @@ ga.as_geoarrow(["POINT (0 1)"]) - This will work with: - An existing array created by geoarrow @@ -51,7 +50,7 @@ Alternatively, you can construct GeoArrow arrays directly from a series of buffe import numpy as np ga.point().from_geobuffers( - None, + None, np.array([1.0, 2.0, 3.0]), np.array([3.0, 4.0, 5.0]) ) @@ -68,7 +67,6 @@ ga.point().from_geobuffers( - ```python ga.point().with_coord_type(ga.CoordType.INTERLEAVED).from_geobuffers( None, @@ -86,8 +84,7 @@ ga.point().with_coord_type(ga.CoordType.INTERLEAVED).from_geobuffers( - -Importing `geoarrow.pyarrow` will register the geoarrow extension types with pyarrow such that you can read/write Arrow streams, Arrow files, and Parquet that contains Geoarrow extension types. A number of these files are available from the [geoarrow-data](https://github.com/geoarrow/geoarrow-data) repository. +Importing `geoarrow.c.pyarrow` will register the geoarrow extension types with pyarrow such that you can read/write Arrow streams, Arrow files, and Parquet that contains Geoarrow extension types. A number of these files are available from the [geoarrow-data](https://github.com/geoarrow/geoarrow-data) repository. ```python @@ -135,18 +132,6 @@ array = ga.as_geoarrow(df.geometry) array ``` - /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/geopandas/_compat.py:124: UserWarning: The Shapely GEOS version (3.11.1-CAPI-1.17.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow. - warnings.warn( - /var/folders/gt/l87wjg8s7312zs9s7c1fgs900000gn/T/ipykernel_81348/2107898165.py:1: DeprecationWarning: Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas still uses PyGEOS by default. However, starting with version 0.14, the default will switch to Shapely. To force to use Shapely 2.0 now, you can either uninstall PyGEOS or set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas: - - import os - os.environ['USE_PYGEOS'] = '0' - import geopandas - - In the next release, GeoPandas will switch to using Shapely by default, even if PyGEOS is installed. If you only have PyGEOS installed to get speed-ups, this switch should be smooth. However, if you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html). - import geopandas - - @@ -158,9 +143,9 @@ array ...245 values... - - - + + + @@ -180,7 +165,7 @@ geopandas.GeoSeries.from_wkb(ga.as_wkb(array)) 2 MULTILINESTRING ((631355.519 5122892.285, 6313... 3 MULTILINESTRING ((665166.020 5138641.982, 6651... 4 MULTILINESTRING ((673606.020 5162961.982, 6736... - ... + ... 250 MULTILINESTRING ((681672.620 5078601.582, 6818... 251 MULTILINESTRING ((414867.917 5093040.881, 4147... 252 MULTILINESTRING ((414867.917 5093040.881, 4148... @@ -280,9 +265,9 @@ geoarrow_array2 ...245 values... - - - + + + diff --git a/python/bootstrap.py b/python/geoarrow-c/bootstrap.py similarity index 91% rename from python/bootstrap.py rename to python/geoarrow-c/bootstrap.py index 72529c1c..5e0abb92 100644 --- a/python/bootstrap.py +++ b/python/geoarrow-c/bootstrap.py @@ -21,8 +21,8 @@ if __name__ == "__main__": this_dir = os.path.abspath(os.path.dirname(__file__)) - vendor_dir = os.path.join(this_dir, "src", "geoarrow", "geoarrow") - vendor_source_dir = os.path.join(this_dir, "..", "src", "geoarrow") + vendor_dir = os.path.join(this_dir, "src", "geoarrow", "c", "geoarrow") + vendor_source_dir = os.path.join(this_dir, "..", "..", "src", "geoarrow") if os.path.exists(vendor_dir): shutil.rmtree(vendor_dir) diff --git a/python/pyproject.toml b/python/geoarrow-c/pyproject.toml similarity index 98% rename from python/pyproject.toml rename to python/geoarrow-c/pyproject.toml index 7f57ff78..48cc90ce 100644 --- a/python/pyproject.toml +++ b/python/geoarrow-c/pyproject.toml @@ -17,7 +17,7 @@ # under the License. [project] -name = "geoarrow" +name = "geoarrow-c" version = "0.1.0-alpha0" description = "" authors = [{name = "Dewey Dunnington", email = "dewey@dunnington.ca"}] diff --git a/python/setup.py b/python/geoarrow-c/setup.py similarity index 90% rename from python/setup.py rename to python/geoarrow-c/setup.py index 05ab5b81..6f1ca53a 100644 --- a/python/setup.py +++ b/python/geoarrow-c/setup.py @@ -31,15 +31,15 @@ if os.path.exists(bootstrap_py): subprocess.run([sys.executable, bootstrap_py]) -vendor_dir = os.path.join(this_dir, "src", "geoarrow", "geoarrow") +vendor_dir = os.path.join(this_dir, "src", "geoarrow", "c", "geoarrow") sources = [ - f"src/geoarrow/geoarrow/{f}" + f"src/geoarrow/c/geoarrow/{f}" for f in os.listdir(vendor_dir) if f.endswith(".c") or f.endswith(".cc") ] sources += [ - f"src/geoarrow/geoarrow/ryu/{f}" + f"src/geoarrow/c/geoarrow/ryu/{f}" for f in os.listdir(os.path.join(vendor_dir, "ryu")) if f.endswith(".c") ] @@ -80,10 +80,10 @@ def new__compile(obj, src, ext, cc_args, extra_postargs, pp_opts): setup( ext_modules=[ Extension( - name="geoarrow._lib", - include_dirs=["src/geoarrow/geoarrow", "src/geoarrow/geoarrow_python"], + name="geoarrow.c._lib", + include_dirs=["src/geoarrow/c/geoarrow", "src/geoarrow/c/geoarrow_python"], language="c++", - sources=["src/geoarrow/_lib.pyx"] + sources, + sources=["src/geoarrow/c/_lib.pyx"] + sources, extra_compile_args=["-std=c++11"] + extra_compile_args, extra_link_args=[] + extra_link_args, define_macros=[] + extra_define_macros, diff --git a/python/src/geoarrow/__init__.py b/python/geoarrow-c/src/geoarrow/c/__init__.py similarity index 78% rename from python/src/geoarrow/__init__.py rename to python/geoarrow-c/src/geoarrow/c/__init__.py index 37d96b52..c1f21d1c 100644 --- a/python/src/geoarrow/__init__.py +++ b/python/geoarrow-c/src/geoarrow/c/__init__.py @@ -1,12 +1,12 @@ """ The root import for geoarrow. This import is intended for those working with geoarrow at a low level; most users should use the pyarrow integration -as ``import geoarrow.pyarrow as ga``. +as ``import geoarrow.c.pyarrow as ga``. Examples -------- ->>> import geoarrow as ga +>>> import geoarrow.c as ga """ diff --git a/python/src/geoarrow/_lib.pyx b/python/geoarrow-c/src/geoarrow/c/_lib.pyx similarity index 100% rename from python/src/geoarrow/_lib.pyx rename to python/geoarrow-c/src/geoarrow/c/_lib.pyx diff --git a/python/src/geoarrow/geoarrow_python/geoarrow_config.h b/python/geoarrow-c/src/geoarrow/c/geoarrow_python/geoarrow_config.h similarity index 100% rename from python/src/geoarrow/geoarrow_python/geoarrow_config.h rename to python/geoarrow-c/src/geoarrow/c/geoarrow_python/geoarrow_config.h diff --git a/python/src/geoarrow/geoarrow_python/geoarrow_python.h b/python/geoarrow-c/src/geoarrow/c/geoarrow_python/geoarrow_python.h similarity index 100% rename from python/src/geoarrow/geoarrow_python/geoarrow_python.h rename to python/geoarrow-c/src/geoarrow/c/geoarrow_python/geoarrow_python.h diff --git a/python/src/geoarrow/lib.py b/python/geoarrow-c/src/geoarrow/c/lib.py similarity index 95% rename from python/src/geoarrow/lib.py rename to python/geoarrow-c/src/geoarrow/c/lib.py index dfad2133..f8bd389e 100644 --- a/python/src/geoarrow/lib.py +++ b/python/geoarrow-c/src/geoarrow/c/lib.py @@ -17,7 +17,7 @@ class GeometryType: Examples -------- - >>> import geoarrow as ga + >>> import geoarrow.c as ga >>> ga.GeometryType.MULTIPOINT """ @@ -46,7 +46,7 @@ class Dimensions: Examples -------- - >>> import geoarrow as ga + >>> import geoarrow.c as ga >>> ga.Dimensions.XYZM """ @@ -69,7 +69,7 @@ class CoordType: Examples -------- - >>> import geoarrow as ga + >>> import geoarrow.c as ga >>> ga.CoordType.INTERLEAVED """ @@ -89,7 +89,7 @@ class EdgeType: Examples -------- - >>> import geoarrow as ga + >>> import geoarrow.c as ga >>> ga.EdgeType.SPHERICAL """ @@ -106,7 +106,7 @@ class CrsType: Examples -------- - >>> import geoarrow as ga + >>> import geoarrow.c as ga >>> ga.CrsType.PROJJSON """ diff --git a/python/src/geoarrow/pandas.py b/python/geoarrow-c/src/geoarrow/c/pandas.py similarity index 99% rename from python/src/geoarrow/pandas.py rename to python/geoarrow-c/src/geoarrow/c/pandas.py index c12b4314..eca38250 100644 --- a/python/src/geoarrow/pandas.py +++ b/python/geoarrow-c/src/geoarrow/c/pandas.py @@ -245,7 +245,7 @@ def __init__(self, parent): self._parent = parent._parent else: raise TypeError( - "`geoarrow_type` must inherit from geoarrow.pyarrow.VectorType, " + "`geoarrow_type` must inherit from geoarrow.c.pyarrow.VectorType, " "geoarrow.CVectorType, or geoarrow.pandas.GeoArrowExtensionDtype" ) diff --git a/python/src/geoarrow/pyarrow/__init__.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/__init__.py similarity index 92% rename from python/src/geoarrow/pyarrow/__init__.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/__init__.py index 08380ba9..0fafe2ad 100644 --- a/python/src/geoarrow/pyarrow/__init__.py +++ b/python/geoarrow-c/src/geoarrow/c/pyarrow/__init__.py @@ -4,7 +4,7 @@ Examples -------- ->>> import geoarrow.pyarrow as ga +>>> import geoarrow.c.pyarrow as ga """ from ..lib import GeometryType, Dimensions, CoordType, EdgeType, CrsType @@ -66,10 +66,10 @@ def dataset(*args, geometry_columns=None, use_row_groups=None, **kwargs): """Construct a GeoDataset This constructor is intended to mirror `pyarrow.dataset()`, adding - geo-specific arguments. See :class:`geoarrow.pyarrow._dataset.GeoDataset` for + geo-specific arguments. See :class:`geoarrow.c.pyarrow._dataset.GeoDataset` for details. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) diff --git a/python/src/geoarrow/pyarrow/_array.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_array.py similarity index 98% rename from python/src/geoarrow/pyarrow/_array.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_array.py index cb5a7eb0..a1311cab 100644 --- a/python/src/geoarrow/pyarrow/_array.py +++ b/python/geoarrow-c/src/geoarrow/c/pyarrow/_array.py @@ -144,12 +144,12 @@ def array(obj, type_=None, *args, validate=True, **kwargs) -> VectorArray: """Attempt to create an Array or ChunkedArray with a geoarrow extension type from ``obj``. This constructor attempts to perform the fewest transformations possible (i.e., WKB is left as WKB, WKT is left as WKT), whereas - :func:`geoarrow.pyarrow.as_geoarrow` actively attempts a conversion to + :func:`geoarrow.c.pyarrow.as_geoarrow` actively attempts a conversion to a geoarrow-encoding based on a common geometry type. GeoPandas objects are supported. This implementation relies heavily on ``pyarrow.array()`` and has similar behaviour. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.array(["POINT (0 1)"]) VectorArray:WktType(geoarrow.wkt)[1] diff --git a/python/src/geoarrow/pyarrow/_compute.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_compute.py similarity index 93% rename from python/src/geoarrow/pyarrow/_compute.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_compute.py index c70c5abc..bb2e0802 100644 --- a/python/src/geoarrow/pyarrow/_compute.py +++ b/python/geoarrow-c/src/geoarrow/c/pyarrow/_compute.py @@ -72,15 +72,15 @@ def push_all( def parse_all(obj): """Parse all features and return nothing. This is useful for - :func:`geoarrow.pyarrow.wkb` and :func:`geoarrow.pyarrow.wkt`-encoded + :func:`geoarrow.c.pyarrow.wkb` and :func:`geoarrow.c.pyarrow.wkt`-encoded arrays to validate their contents. For other types, this is a no-op. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.parse_all(["POINT (0 1)"]) >>> ga.parse_all(["POINT (0 1"]) Traceback (most recent call last): ... - geoarrow._lib.GeoArrowCException: GeoArrowKernel::push_batch() failed (22): Expected ')' at byte 10 + geoarrow.c._lib.GeoArrowCException: GeoArrowKernel::push_batch() failed (22): Expected ')' at byte 10 """ obj = obj_as_array_or_chunked(obj) @@ -97,7 +97,7 @@ def unique_geometry_types(obj): values of the :class:`geoarrow.GeometryType` and :class:`geoarrow.Dimensions` enumerators. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> print(str(ga.unique_geometry_types(["POINT Z (0 1 2)", "LINESTRING (0 0, 1 3)"]))) -- is_valid: all not null -- child 0 type: int32 @@ -152,11 +152,11 @@ def unique_geometry_types(obj): def infer_type_common(obj, coord_type=None, promote_multi=False): - """Infer a common :class:`geoarrow.pyarrow.VectorType` for the + """Infer a common :class:`geoarrow.c.pyarrow.VectorType` for the geometries in ``obj``, preferring geoarrow-encoded types and falling back to well-known binary. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.infer_type_common(["POINT Z (0 1 2)", "LINESTRING (0 0, 1 3)"]) WkbType(geoarrow.wkb) >>> ga.infer_type_common(["POINT Z (0 1 2)", "MULTIPOINT (0 0, 1 3)"]) @@ -232,9 +232,9 @@ def infer_type_common(obj, coord_type=None, promote_multi=False): def as_wkt(obj): - """Encode ``obj`` as :func:`geoarrow.pyarrow.wkt`. + """Encode ``obj`` as :func:`geoarrow.c.pyarrow.wkt`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> points = ga.as_geoarrow(["POINT (0 1)"]) >>> ga.as_wkt(points) VectorArray:WktType(geoarrow.wkt)[1] @@ -249,9 +249,9 @@ def as_wkt(obj): def as_wkb(obj): - """Encode ``obj`` as :func:`geoarrow.pyarrow.wkb`. + """Encode ``obj`` as :func:`geoarrow.c.pyarrow.wkb`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> points = ga.as_geoarrow(["POINT (0 1)"]) >>> ga.as_wkb(points) VectorArray:WkbType(geoarrow.wkb)[1] @@ -269,7 +269,7 @@ def as_geoarrow(obj, type=None, coord_type=None, promote_multi=False): """Encode ``obj`` as a geoarrow-encoded array, preferring geoarrow encodings and falling back to well-known binary if no common geoemtry type is found. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.as_geoarrow(["POINT (0 1)", "MULTIPOINT Z (0 1 2, 4 5 6)"]) MultiPointArray:MultiPointType(geoarrow.multipoint_z)[2] @@ -297,7 +297,7 @@ def format_wkt(obj, precision=None, max_element_size_bytes=None): """Format geometries in an object as well-known text with an optional cap on digits and element size to prevent excessive output for large features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> print(str(ga.format_wkt(ga.array(["POINT (0 1.3333333333333)"]), precision=5))) [ "POINT (0 1.33333)" @@ -329,7 +329,7 @@ def box(obj): """Compute a Cartesian 2D bounding box for each feature in ``obj`` as a struct(xmin, xmax, ymin, ymax) array. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.box(["LINESTRING (0 10, 34 -1)"]).type StructType(struct) >>> print(str(ga.box(["LINESTRING (0 10, 34 -1)"]))) @@ -392,7 +392,7 @@ def box_agg(obj): a scalar struct(xmin, xmax, ymin, ymax). Values that are null are currently ignored. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.box_agg(["POINT (0 10)", "POINT (34 -1)"]) """ @@ -436,7 +436,7 @@ def rechunk(obj, max_bytes): ``max_bytes``. This may be useful to more predictibly parallelize a computation for variable feature sizes. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> print(str(ga.rechunk(["POINT (0 1)", "POINT (2 3)"], max_bytes=100))) [ [ @@ -470,7 +470,7 @@ def with_coord_type(obj, coord_type): """Attempt to convert ``obj`` to a geoarrow-encoded array with a specific :class:`CoordType`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.with_coord_type(["POINT (0 1)"], ga.CoordType.INTERLEAVED) PointArray:PointType(interleaved geoarrow.point)[1] @@ -481,7 +481,7 @@ def with_coord_type(obj, coord_type): def with_edge_type(obj, edge_type): """Force a :class:`geoarrow.EdgeType` on an array. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.with_edge_type(["LINESTRING (0 1, 2 3)"], ga.EdgeType.SPHERICAL) VectorArray:WktType(spherical geoarrow.wkt)[1] @@ -494,7 +494,7 @@ def with_edge_type(obj, edge_type): def with_crs(obj, crs, crs_type=None): """Force a :class:`geoarrow.CrsType`/crs value on an array. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.with_crs(["POINT (0 1)"], "EPSG:1234") VectorArray:WktType(geoarrow.wkt )[1] @@ -509,10 +509,10 @@ def with_dimensions(obj, dimensions): specific :class:`geoarrow.Dimensions`. If dimensions need to be added, nonexistent values will be filled with ``nan``. If dimensions need to be dropped, this function will silently - drop them. You can use :func:`geoarrow.pyarrow.unique_geometry_types` + drop them. You can use :func:`geoarrow.c.pyarrow.unique_geometry_types` to efficiently detect if one or both of these will occur. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.with_dimensions(["POINT (0 1)"], ga.Dimensions.XYZM) PointArray:PointType(geoarrow.point_zm)[1] @@ -532,7 +532,7 @@ def with_geometry_type(obj, geometry_type): """Attempt to convert ``obj`` to a geoarrow-encoded array with a specific :class:`geoarrow.GeometryType`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.with_geometry_type(["POINT (0 1)"], ga.GeometryType.MULTIPOINT) MultiPointArray:MultiPointType(geoarrow.multipoint)[1] @@ -546,7 +546,7 @@ def with_geometry_type(obj, geometry_type): >>> ga.with_geometry_type(["MULTIPOINT (0 1, 2 3)"], ga.GeometryType.POINT) Traceback (most recent call last): ... - geoarrow._lib.GeoArrowCException: GeoArrowKernel::push_batch() failed (22): Can't convert feature with >1 coordinate to POINT + geoarrow.c._lib.GeoArrowCException: GeoArrowKernel::push_batch() failed (22): Can't convert feature with >1 coordinate to POINT """ obj = as_geoarrow(obj) if geometry_type == obj.type.geometry_type: @@ -559,7 +559,7 @@ def with_geometry_type(obj, geometry_type): def point_coords(obj, dimensions=None): """Extract point coordinates into separate arrays or chunked arrays. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> x, y = ga.point_coords(["POINT (0 1)", "POINT (2 3)"]) >>> list(x) [, ] diff --git a/python/src/geoarrow/pyarrow/_dataset.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_dataset.py similarity index 97% rename from python/src/geoarrow/pyarrow/_dataset.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_dataset.py index 50a6e6cc..47b076c2 100644 --- a/python/src/geoarrow/pyarrow/_dataset.py +++ b/python/geoarrow-c/src/geoarrow/c/pyarrow/_dataset.py @@ -15,7 +15,7 @@ class GeoDataset: The GeoDataset wraps a pyarrow.Dataset containing one or more geometry columns and provides indexing and IO capability. If `geometry_columns` is `None`, - it will include all columns that inherit from `geoarrow.pyarrow.VectorType`. + it will include all columns that inherit from `geoarrow.c.pyarrow.VectorType`. The `geometry_columns` are not required to be geoarrow extension type columns: text columns will be parsed as WKT; binary columns will be parsed as WKB (but are not detected automatically). @@ -37,7 +37,7 @@ def parent(self): Returns the (non geo-aware) parent pyarrow.Dataset. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) @@ -55,7 +55,7 @@ def schema(self): The schema of a GeoDataset is identical to that of its parent. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) @@ -77,7 +77,7 @@ def get_fragments(self): def geometry_columns(self): """Get a tuple of geometry column names - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) @@ -103,7 +103,7 @@ def geometry_types(self): columns actually refer a field that can be interpreted as geometry. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) @@ -137,7 +137,7 @@ def index_fragments(self, num_threads=None): name. A future implementation may handle spherical edges using a type of simplified geometry more suitable to a spherical comparison. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) @@ -163,7 +163,7 @@ def filter_fragments(self, target): """Push down a spatial query into a GeoDataset Returns a potentially simplified dataset based on the geometry of - target. Currently this uses `geoarrow.pyarrow.box_agg()` on `target` + target. Currently this uses `geoarrow.c.pyarrow.box_agg()` on `target` and performs a simple envelope comparison with each fragment. A future implementation may handle spherical edges using a type of simplified geometry more suitable to a spherical comparison. For datasets with @@ -171,7 +171,7 @@ def filter_fragments(self, target): and include fragments that intersect the simplified geometry from any of the columns. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> import pyarrow as pa >>> table = pa.table([ga.array(["POINT (0.5 1.5)"])], ["geometry"]) >>> dataset = ga.dataset(table) diff --git a/python/src/geoarrow/pyarrow/_kernel.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_kernel.py similarity index 100% rename from python/src/geoarrow/pyarrow/_kernel.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_kernel.py diff --git a/python/src/geoarrow/pyarrow/_scalar.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_scalar.py similarity index 100% rename from python/src/geoarrow/pyarrow/_scalar.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_scalar.py diff --git a/python/src/geoarrow/pyarrow/_type.py b/python/geoarrow-c/src/geoarrow/c/pyarrow/_type.py similarity index 94% rename from python/src/geoarrow/pyarrow/_type.py rename to python/geoarrow-c/src/geoarrow/c/pyarrow/_type.py index 145d1d88..6ac8130f 100644 --- a/python/src/geoarrow/pyarrow/_type.py +++ b/python/geoarrow-c/src/geoarrow/c/pyarrow/_type.py @@ -10,7 +10,7 @@ class VectorType(pa.ExtensionType): # These are injected into the class when imported by the type and scalar # modules to avoid a circular import. As a result, you can't - # use this module directly (import geoarrow.pyarrow first). + # use this module directly (import geoarrow.c.pyarrow first). _array_cls_from_name = None _scalar_cls_from_name = None _make_validate_kernel = None @@ -18,7 +18,7 @@ class VectorType(pa.ExtensionType): def __init__(self, c_vector_type): if not isinstance(c_vector_type, lib.CVectorType): raise TypeError( - "geoarrow.pyarrow.VectorType must be created from a CVectorType" + "geoarrow.c.pyarrow.VectorType must be created from a CVectorType" ) self._type = c_vector_type if self._type.extension_name != type(self)._extension_name: @@ -116,9 +116,9 @@ def _from_geobuffers_internal(self, args): def id(self): """A unique identifier for the memory layout of this type. - >>> import geoarrow.pyarrow as ga - >>> ga.wkb().id - + >>> import geoarrow.c.pyarrow as ga + >>> int(ga.wkb().id) + 100001 """ return self._type.id @@ -127,7 +127,7 @@ def geometry_type(self): """The :class:`geoarrow.GeometryType` of this type or ``GEOMETRY`` for types where this is not constant (i.e., WKT and WKB). - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.wkb().geometry_type == ga.GeometryType.GEOMETRY True >>> ga.linestring().geometry_type == ga.GeometryType.LINESTRING @@ -140,7 +140,7 @@ def dimensions(self): """The :class:`geoarrow.Dimensions` of this type or ``UNKNOWN`` for types where this is not constant (i.e., WKT and WKT). - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.wkb().dimensions == ga.Dimensions.UNKNOWN True >>> ga.linestring().dimensions == ga.Dimensions.XY @@ -152,7 +152,7 @@ def dimensions(self): def coord_type(self): """The :class:`geoarrow.CoordType` of this type. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.linestring().coord_type == ga.CoordType.SEPARATE True >>> ga.linestring().with_coord_type(ga.CoordType.INTERLEAVED).coord_type @@ -164,7 +164,7 @@ def coord_type(self): def edge_type(self): """The :class:`geoarrow.EdgeType` of this type. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.linestring().edge_type == ga.EdgeType.PLANAR True >>> ga.linestring().with_edge_type(ga.EdgeType.SPHERICAL).edge_type @@ -176,7 +176,7 @@ def edge_type(self): def crs_type(self): """The :class:`geoarrow.CrsType` of the :attr:`crs` value. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().crs_type == ga.CrsType.NONE True >>> ga.point().with_crs("EPSG:1234").crs_type @@ -188,7 +188,7 @@ def crs_type(self): def crs(self): """The coordinate reference system of this type. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().with_crs("EPSG:1234").crs 'EPSG:1234' """ @@ -197,7 +197,7 @@ def crs(self): def with_metadata(self, metadata): """This type with the extension metadata (e.g., copied from some other type) - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().with_metadata('{"crs": "EPSG:1234"}').crs 'EPSG:1234' """ @@ -208,7 +208,7 @@ def with_metadata(self, metadata): def with_geometry_type(self, geometry_type): """Returns a new type with the specified :class:`geoarrow.GeometryType`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().with_geometry_type(ga.GeometryType.LINESTRING) LinestringType(geoarrow.linestring) """ @@ -218,7 +218,7 @@ def with_geometry_type(self, geometry_type): def with_dimensions(self, dimensions): """Returns a new type with the specified :class:`geoarrow.Dimensions`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().with_dimensions(ga.Dimensions.XYZ) PointType(geoarrow.point_z) """ @@ -228,7 +228,7 @@ def with_dimensions(self, dimensions): def with_coord_type(self, coord_type): """Returns a new type with the specified :class:`geoarrow.CoordType`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point().with_coord_type(ga.CoordType.INTERLEAVED) PointType(interleaved geoarrow.point) """ @@ -238,7 +238,7 @@ def with_coord_type(self, coord_type): def with_edge_type(self, edge_type): """Returns a new type with the specified :class:`geoarrow.EdgeType`. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.linestring().with_edge_type(ga.EdgeType.SPHERICAL) LinestringType(spherical geoarrow.linestring) """ @@ -250,7 +250,7 @@ def with_crs(self, crs, crs_type=None): :class:`geoarrow.CrsType` combination. The ``crs_type`` defaults to ``NONE`` if ``crs`` is ``None``, otherwise ``UNKNOWN``. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.linestring().with_crs("EPSG:1234") LinestringType(geoarrow.linestring ) """ @@ -472,7 +472,7 @@ def _make_default(geometry_type, cls): def wkb() -> WkbType: """Well-known binary with a maximum array size of 2 GB per chunk. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.wkb() WkbType(geoarrow.wkb) >>> ga.wkb().storage_type @@ -484,7 +484,7 @@ def wkb() -> WkbType: def large_wkb() -> WkbType: """Well-known binary using 64-bit integer offsets. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.large_wkb() WkbType(geoarrow.wkb) >>> ga.large_wkb().storage_type @@ -496,7 +496,7 @@ def large_wkb() -> WkbType: def wkt() -> WktType: """Well-known text with a maximum array size of 2 GB per chunk. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.wkt() WktType(geoarrow.wkt) >>> ga.wkt().storage_type @@ -508,7 +508,7 @@ def wkt() -> WktType: def large_wkt() -> WktType: """Well-known text using 64-bit integer offsets. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.large_wkt() WktType(geoarrow.wkt) >>> ga.large_wkt().storage_type @@ -520,7 +520,7 @@ def large_wkt() -> WktType: def point() -> PointType: """Geoarrow-encoded point features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.point() PointType(geoarrow.point) >>> ga.point().storage_type @@ -532,7 +532,7 @@ def point() -> PointType: def linestring() -> PointType: """Geoarrow-encoded line features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.linestring() LinestringType(geoarrow.linestring) >>> ga.linestring().storage_type @@ -544,7 +544,7 @@ def linestring() -> PointType: def polygon() -> PolygonType: """Geoarrow-encoded polygon features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.polygon() PolygonType(geoarrow.polygon) >>> ga.polygon().storage_type @@ -556,7 +556,7 @@ def polygon() -> PolygonType: def multipoint() -> MultiPointType: """Geoarrow-encoded multipoint features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.multipoint() MultiPointType(geoarrow.multipoint) >>> ga.multipoint().storage_type @@ -568,7 +568,7 @@ def multipoint() -> MultiPointType: def multilinestring() -> MultiLinestringType: """Geoarrow-encoded multilinestring features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.multilinestring() MultiLinestringType(geoarrow.multilinestring) >>> ga.multilinestring().storage_type @@ -580,7 +580,7 @@ def multilinestring() -> MultiLinestringType: def multipolygon() -> MultiPolygonType: """Geoarrow-encoded polygon features. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.multipolygon() MultiPolygonType(geoarrow.multipolygon) >>> ga.multipolygon().storage_type @@ -599,7 +599,7 @@ def vector_type( ) -> VectorType: """Generic vector geometry type constructor. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.vector_type(ga.GeometryType.POINT, crs="EPSG:1234") PointType(geoarrow.point ) """ @@ -636,7 +636,7 @@ def vector_type_common(types): From a sequence of GeoArrow types, return a type to which all can be cast or error if this cannot occur. - >>> import geoarrow.pyarrow as ga + >>> import geoarrow.c.pyarrow as ga >>> ga.vector_type_common([ga.wkb(), ga.point()]) WkbType(geoarrow.wkb) >>> ga.vector_type_common([ga.point(), ga.point()]) diff --git a/python/tests/test_geoarrow_dataset.py b/python/geoarrow-c/tests/test_geoarrow_dataset.py similarity index 98% rename from python/tests/test_geoarrow_dataset.py rename to python/geoarrow-c/tests/test_geoarrow_dataset.py index 70ef03aa..37ab043c 100644 --- a/python/tests/test_geoarrow_dataset.py +++ b/python/geoarrow-c/tests/test_geoarrow_dataset.py @@ -5,8 +5,8 @@ import pyarrow.parquet as pq import pytest -import geoarrow.pyarrow as ga -from geoarrow.pyarrow._dataset import GeoDataset, ParquetRowGroupGeoDataset +import geoarrow.c.pyarrow as ga +from geoarrow.c.pyarrow._dataset import GeoDataset, ParquetRowGroupGeoDataset def test_geodataset_column_name_guessing(): diff --git a/python/tests/test_geoarrow_lib.py b/python/geoarrow-c/tests/test_geoarrow_lib.py similarity index 98% rename from python/tests/test_geoarrow_lib.py rename to python/geoarrow-c/tests/test_geoarrow_lib.py index 533ab195..3b64408f 100644 --- a/python/tests/test_geoarrow_lib.py +++ b/python/geoarrow-c/tests/test_geoarrow_lib.py @@ -2,8 +2,8 @@ import pyarrow as pa import pytest -import geoarrow as ga -import geoarrow.lib as lib +import geoarrow.c as ga +import geoarrow.c.lib as lib def test_schema_holder(): diff --git a/python/tests/test_geoarrow_pandas.py b/python/geoarrow-c/tests/test_geoarrow_pandas.py similarity index 98% rename from python/tests/test_geoarrow_pandas.py rename to python/geoarrow-c/tests/test_geoarrow_pandas.py index ec3579ad..e11c7118 100644 --- a/python/tests/test_geoarrow_pandas.py +++ b/python/geoarrow-c/tests/test_geoarrow_pandas.py @@ -2,9 +2,9 @@ import pandas as pd import pyarrow as pa -import geoarrow.pandas as gapd -import geoarrow.pyarrow as ga -import geoarrow.lib as lib +import geoarrow.c.pandas as gapd +import geoarrow.c.pyarrow as ga +import geoarrow.c.lib as lib import numpy as np diff --git a/python/tests/test_geoarrow_pandas_suite.py b/python/geoarrow-c/tests/test_geoarrow_pandas_suite.py similarity index 98% rename from python/tests/test_geoarrow_pandas_suite.py rename to python/geoarrow-c/tests/test_geoarrow_pandas_suite.py index 801d5128..ebb58276 100644 --- a/python/tests/test_geoarrow_pandas_suite.py +++ b/python/geoarrow-c/tests/test_geoarrow_pandas_suite.py @@ -1,7 +1,7 @@ import pytest from pandas.tests.extension import base -import geoarrow.pandas as gapd -import geoarrow.pyarrow as ga +import geoarrow.c.pandas as gapd +import geoarrow.c.pyarrow as ga import operator from pandas import ( diff --git a/python/tests/test_geoarrow_pyarrow.py b/python/geoarrow-c/tests/test_geoarrow_pyarrow.py similarity index 99% rename from python/tests/test_geoarrow_pyarrow.py rename to python/geoarrow-c/tests/test_geoarrow_pyarrow.py index 87cbb236..2a79c90f 100644 --- a/python/tests/test_geoarrow_pyarrow.py +++ b/python/geoarrow-c/tests/test_geoarrow_pyarrow.py @@ -5,10 +5,10 @@ import numpy as np import pytest -import geoarrow.lib as lib -import geoarrow.pyarrow as ga -import geoarrow.pyarrow._type as _type -import geoarrow.pyarrow._array as _array +import geoarrow.c.lib as lib +import geoarrow.c.pyarrow as ga +import geoarrow.c.pyarrow._type as _type +import geoarrow.c.pyarrow._array as _array def test_vector_type_basic(): diff --git a/python/tests/test_geoarrow_pyarrow_compute.py b/python/geoarrow-c/tests/test_geoarrow_pyarrow_compute.py similarity index 99% rename from python/tests/test_geoarrow_pyarrow_compute.py rename to python/geoarrow-c/tests/test_geoarrow_pyarrow_compute.py index 24cd43d9..4ad4df68 100644 --- a/python/tests/test_geoarrow_pyarrow_compute.py +++ b/python/geoarrow-c/tests/test_geoarrow_pyarrow_compute.py @@ -4,10 +4,10 @@ import numpy as np import pytest -import geoarrow.pyarrow as ga -import geoarrow.pyarrow._kernel as _kernel -import geoarrow.pyarrow._compute as _compute -import geoarrow.lib as lib +import geoarrow.c.pyarrow as ga +import geoarrow.c.pyarrow._kernel as _kernel +import geoarrow.c.pyarrow._compute as _compute +import geoarrow.c.lib as lib def test_set_max_workers():