Skip to content

Commit

Permalink
Merge pull request #18 from caspervdw/docs
Browse files Browse the repository at this point in the history
Documentation + replace NaN / None by Empty geometries
  • Loading branch information
caspervdw committed Jul 22, 2019
2 parents b6291e8 + f324d0c commit c6239a3
Show file tree
Hide file tree
Showing 19 changed files with 897 additions and 272 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ coverage.xml
.venv
Pipfile
Pipfile.lock


# Documentation
docs/_build
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ language: minimal
matrix:
include:
- os: linux # 2015
env: DEPS="python=3.5 numpy=1.10 geos=3.5"
env: PYTHON_VERSION="3.5" DEPS="numpy=1.10 geos=3.5"
- os: linux # 2017
env: DEPS="python=3.6 numpy=1.13 geos=3.6"
env: PYTHON_VERSION="3.6" DEPS="numpy=1.13 geos=3.6"
- os: linux # now
env: DEPS="python=3.7 numpy geos"
env: PYTHON_VERSION="3.7" DEPS="numpy geos"
- os: osx
env: DEPS="python=3.7 numpy geos"
env: PYTHON_VERSION="3.7" DEPS="numpy geos"

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
Expand All @@ -25,10 +25,14 @@ install:
- hash -r;
- conda update --yes conda;
- conda config --set changeps1 no --set restore_free_channel true;
- conda create -n testenv --yes pytest $DEPS;
- conda create -n testenv --yes python=$PYTHON_VERSION $DEPS pytest;
- conda activate testenv;
- conda --version ; python --version ; pip --version;
- python setup.py build_ext --inplace
- pip install . --no-deps

script: pytest
script
- if [[ "$PYTHON_VERSION" == "3.5" ]];
then pytest;
else pytest --doctest-modules;
fi
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ PyGEOS
:alt: Appveyor CI status
:target: https://ci.appveyor.com/project/caspervdw/pygeos

.. PyPI
.. image:: https://badge.fury.io/py/pygeos.svg
:alt: PyPI
:target: https://badge.fury.io/py/pygeos

This is a C/Python library that wraps geometry functions in GEOS in numpy ufuncs.
This project is still in a mock-up phase: the API will most likely change.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ before_test:
- "%CMD_IN_ENV% python setup.py build_ext --inplace"

test_script:
- pytest
- pytest --doctest-modules
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
52 changes: 52 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'pygeos'
copyright = '2019, Casper van der Wel'
author = 'Casper van der Wel'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'numpydoc']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = "sphinx_rtd_theme"
# html_theme_path = ["_themes", ]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
23 changes: 23 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. pygeos documentation master file, created by
sphinx-quickstart on Mon Jul 22 11:02:13 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pygeos's documentation!
==================================

.. toctree::
:maxdepth: 2
:caption: Contents:

predicates


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`


35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
9 changes: 9 additions & 0 deletions docs/predicates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`pygeos.predicates`
========================

.. automodule:: pygeos.predicates
:members:
:undoc-members:
:special-members:
:inherited-members:
:show-inheritance:
4 changes: 2 additions & 2 deletions pygeos/constructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def convex_hull(geometries):
return ufuncs.convex_hull(geometries)


def delaunay_triangles(geometry, tolerance=0., only_edges=False):
def delaunay_triangles(geometry, tolerance=0.0, only_edges=False):
return ufuncs.delaunay_triangles(geometry, tolerance, only_edges)


Expand All @@ -139,5 +139,5 @@ def snap(geometries, reference, tolerance):
return ufuncs.snap(geometries, reference, tolerance)


def voronoi_polygons(geometry, envelope=None, tolerance=0., only_edges=False):
def voronoi_polygons(geometry, envelope=None, tolerance=0.0, only_edges=False):
return ufuncs.voronoi_polygons(geometry, envelope, tolerance, only_edges)
27 changes: 27 additions & 0 deletions pygeos/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

__all__ = [
"Geometry",
"Empty",
"GeometryType",
"get_type_id",
"get_dimensions",
"get_coordinate_dimensions",
"get_num_coordinates",
"has_z",
"normalize",
"get_srid",
"set_srid",
Expand All @@ -27,6 +29,7 @@


Geometry = ufuncs.Geometry
Empty = ufuncs.Empty


class GeometryType(IntEnum):
Expand Down Expand Up @@ -59,6 +62,30 @@ def get_num_coordinates(geometry):
return ufuncs.get_num_coordinates(geometry)


def has_z(geometry, **kwargs):
"""Returns True if a geometry has a Z coordinate.
Parameters
----------
geometry : Geometry or array_like
Notes
-----
Keyword arguments (``**kwargs``) are passed into the underlying ufunc. To
use methods such as ``.at``, import the underlying ufunc from
``pygeos.ufuncs``. See the
`NumPy docs <https://docs.scipy.org/doc/numpy/reference/ufuncs.html>`_.
Examples
--------
>>> has_z(Geometry("POINT (0 0)"))
False
>>> has_z(Geometry("POINT Z (0 0 0)"))
True
"""
return ufuncs.has_z(geometry, **kwargs)


def normalize(geometry):
return ufuncs.normalize(geometry)

Expand Down

0 comments on commit c6239a3

Please sign in to comment.