Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark slow tests, update __eq__ methods, pin reqs #60

Merged
merged 32 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
35c834e
Typing for read parquet
brl0 Jan 11, 2021
2e0e00f
Ignore monkeytype
brl0 Jan 31, 2021
94347e9
Fix for pandas update, mark slow tests
brl0 Jan 31, 2021
9227303
Merge branch 'master' into fix_fillna
brl0 Jan 31, 2021
abc9d6e
Fix duplicate import
brl0 Jan 31, 2021
50ec3b8
Pin numpy
brl0 Feb 2, 2021
f8b5970
Pin pyarrow
brl0 Feb 2, 2021
d37f138
Pin pyarrow < 2
brl0 Feb 3, 2021
79bf0ba
Remove pins for numpy and pyarrow
brl0 Feb 6, 2021
c400e36
Suppress hypothesis health check causing failures
brl0 Feb 6, 2021
1334731
Temporarily skip slow tests, try 3.8 on MacOS
brl0 Feb 6, 2021
82bd02f
Try pinning numpy on MacOS
brl0 Feb 6, 2021
7627f5d
Check platform for numpy requirement
brl0 Feb 6, 2021
afbc75c
Fix warnings about np.object
brl0 Feb 6, 2021
ca1ece6
Run slow tests by default again
brl0 Feb 6, 2021
e6b8cf3
Merge branch 'remove_pins' into initial_typing
brl0 Feb 6, 2021
065ebff
Sort imports, add more type info
brl0 Feb 6, 2021
d6e26cb
Unmark dask test, update pins, skip slow
brl0 Feb 6, 2021
da5cc87
Pin pyarrow < 2 on Mac, try conda-forge for others
brl0 Feb 6, 2021
498e7fc
Add snappy, swap channels, pin 3.6
brl0 Feb 6, 2021
72f4995
Correct channels, try pyarrow 3
brl0 Feb 6, 2021
351c5c9
Unpin pyarrow except Mac
brl0 Feb 6, 2021
292c46d
Fix pyarrow req, enable slow tests
brl0 Feb 6, 2021
b93a406
Relative imports, isort, cleanup
brl0 Feb 7, 2021
a5ca5eb
Fix pin
brl0 Feb 7, 2021
9b33a12
Try pyarrow from conda-forge on Mac
brl0 Feb 7, 2021
7140e33
Try pinning Dask on Mac
brl0 Feb 8, 2021
70553e3
Try lower Dask version on Mac
brl0 Feb 8, 2021
3abb8d5
Try lower Dask version on Mac, skip slow tests
brl0 Feb 8, 2021
60715f0
Undo skip slow tests
brl0 Feb 8, 2021
fc14db0
Revert pyarrow pin
brl0 Feb 8, 2021
2f16777
Update change log
brl0 Feb 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
timeout-minutes: 40
defaults:
run:
shell: bash -l {0}
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
CHANS_DEV: "-c pyviz/label/dev"
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
conda activate test-environment
conda list
doit develop_install ${{ env.CHANS_DEV }} -o tests
pip install hilbertcurve
pip install hilbertcurve
- name: doit env_capture
run: |
eval "$(conda shell.bash hook)"
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ venv.bak/
*.parq
.idea/
spatialpandas/.version

.vscode/

monkeytype.sqlite3

.doit.db
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
known_local_folder=spatialpandas
known_first_party=spatialpandas
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
Version 0.4.0
=============

### Added
- Add HoloViz build infrastructure. ([#50](https://github.com/holoviz/spatialpandas/pull/50))
- Add `--skip-slow` and `--run-slow` options, slow tests are still run by default. ([#60](https://github.com/holoviz/spatialpandas/pull/60))
- Add some type hints to parquet functions. ([#60](https://github.com/holoviz/spatialpandas/pull/60))

### Fixed
- Fix compatibility with latest pandas. ([#55](https://github.com/holoviz/spatialpandas/pull/55))
- Fix certain tests fail due to hypothesis health check. ([#60](https://github.com/holoviz/spatialpandas/pull/60))
- Pin numpy and dask on MacOS to pass tests. ([#60](https://github.com/holoviz/spatialpandas/pull/60))


### Updated
- Allow using cx indexer without spatial index. ([#54](https://github.com/holoviz/spatialpandas/pull/54))
- Switch to GitHub Actions. ([#55](https://github.com/holoviz/spatialpandas/pull/55))
- Updated Geometry class __eq__ method so that if other object is a container, the equality method on the container is called, so now performing an equality check between a geometry object and a geometry array should return correct results, which should be a bool array, whereas previously it would simply return False because the objects were not the same immediate type. ([#60](https://github.com/holoviz/spatialpandas/pull/60))
- Update GeometryArray class __eq__ method to allow comparison of an individual element to all objects in the array, returning an array of bool. ([#60](https://github.com/holoviz/spatialpandas/pull/60))
- Add NotImplementedError for __contains__ method. ([#60](https://github.com/holoviz/spatialpandas/pull/60))


Version 0.3.6
=============

Expand Down
33 changes: 33 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Configuration for pytest."""
import pytest


_DEFAULT_SKIPSLOW = False


def pytest_addoption(parser):
"""Add command-line flags for pytest."""
parser.addoption(
"--skip-slow",
action="store_true",
help="skips slow tests",
default=_DEFAULT_SKIPSLOW,
)
parser.addoption(
"--run-slow",
action="store_true",
default=False, # Only used for cli override
help="run slow tests",
)


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")


def pytest_collection_modifyitems(config, items):
if not config.getoption("--run-slow") and config.getoption("--skip-slow"):
skip_slow = pytest.mark.skip(reason="Skipping slow tests")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
46 changes: 31 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
from setuptools import setup, find_packages
import sys

import param
from setuptools import find_packages, setup

extras_require = {
'tests': [
'pytest',
'codecov',
'pytest-cov',
'flake8',
'geopandas',
'hypothesis',
'pytest-cov',
'pytest',
'scipy',
'shapely',
'geopandas',
],
'examples': [
'geopandas',
'matplotlib',
'descartes',
'datashader',
'descartes',
'geopandas',
'holoviews',
'matplotlib',
]
}

install_requires = [
'pandas>=0.25',
'dask[complete] >=2.0',
'fsspec',
'numba',
'numpy',
'pyarrow>=0.15',
'pandas>=0.25',
'param',
'fsspec',
'pyarrow>=0.15',
'retrying',
'snappy',
]

# Checking for platform explicitly because
# pyctdev does not handle dependency conditions
# such as 'numpy<1.20;platform_system=="Darwin"'
if sys.platform == 'darwin':
install_requires.extend([
'dask[complete]>=2.0,<2020.12',
'numpy<1.20',
])
else:
install_requires.extend([
'dask[complete]>=2.0',
'numpy',
])

setup_args = dict(
name='spatialpandas',
version=param.version.get_setup_version(
__file__, "spatialpandas", archive_commit="$Format:%h$"
__file__,
"spatialpandas",
archive_commit="$Format:%h$",
),
description='Pandas extension arrays for spatial/geometric operations',
long_description=open("README.md").read(),
Expand All @@ -49,9 +66,8 @@
tests_require=extras_require['tests'],
license='BSD-2-Clause',
packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True
include_package_data=True,
)

if __name__ == '__main__':
setup(**setup_args)

22 changes: 13 additions & 9 deletions spatialpandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
from . import geometry, spatialindex, tools # noqa
from .geoseries import GeoSeries # noqa
from .geodataframe import GeoDataFrame # noqa
from .tools.sjoin import sjoin # noqa
import param as _param

from . import geometry, spatialindex, tools # noqa
from .geodataframe import GeoDataFrame # noqa
from .geoseries import GeoSeries # noqa
from .tools.sjoin import sjoin # noqa

try:
import dask.dataframe # noqa
import dask.dataframe # noqa
# Import to trigger registration of types with Dask
import spatialpandas.dask # noqa
import spatialpandas.dask # noqa
except ImportError:
# Dask dataframe not available
pass

__version__ = str(_param.version.Version(
fpath=__file__, archive_commit="$Format:%h$", reponame="spatialpandas")
)
__version__ = str(
_param.version.Version(
fpath=__file__,
archive_commit="$Format:%h$",
reponame="spatialpandas",
))
34 changes: 18 additions & 16 deletions spatialpandas/dask.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import copy
import json
import os
import uuid
from inspect import signature

import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
from retrying import retry

import dask
import dask.dataframe as dd
from dask import delayed
from dask.dataframe.core import get_parallel_type
from dask.dataframe.partitionquantiles import partition_quantiles
from dask.dataframe.utils import make_array_nonempty, make_meta, meta_nonempty

from spatialpandas.geometry.base import _BaseCoordinateIndexer, GeometryDtype
from spatialpandas.spatialindex import HilbertRtree
from .geoseries import GeoSeries
from .geodataframe import GeoDataFrame
import dask
from dask.dataframe.core import get_parallel_type
from dask.dataframe.utils import make_meta, meta_nonempty, make_array_nonempty
import pandas as pd
import numpy as np
import pyarrow.parquet as pq
import pyarrow as pa
import os
import uuid
import json
import copy
from inspect import signature
from retrying import retry
from .geometry.base import GeometryDtype, _BaseCoordinateIndexer
from .geoseries import GeoSeries
from .spatialindex import HilbertRtree


class DaskGeoSeries(dd.Series):
Expand Down
3 changes: 2 additions & 1 deletion spatialpandas/geodataframe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pandas as pd

from ._optional_imports import gp
from .geometry import GeometryDtype
from .geoseries import GeoSeries, _MaybeGeoSeries
from ._optional_imports import gp


class _MaybeGeoDataFrame(pd.DataFrame):
Expand Down
2 changes: 1 addition & 1 deletion spatialpandas/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .polygon import Polygon, PolygonArray, PolygonDtype # noqa
from .polygon import Polygon, PolygonArray, PolygonDtype # noqa
from .multipolygon import ( # noqa
MultiPolygon, MultiPolygonArray, MultiPolygonDtype
)
Expand Down
2 changes: 1 addition & 1 deletion spatialpandas/geometry/_algorithms/bounds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from spatialpandas.utils import ngjit
from ...utils import ngjit


@ngjit
Expand Down
8 changes: 4 additions & 4 deletions spatialpandas/geometry/_algorithms/intersection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np

from spatialpandas.geometry._algorithms.bounds import total_bounds_interleaved
from spatialpandas.geometry._algorithms.orientation import triangle_orientation
from spatialpandas.utils import ngjit, ngpjit
from numba import prange

from ...geometry._algorithms.bounds import total_bounds_interleaved
from ...geometry._algorithms.orientation import triangle_orientation
from ...utils import ngjit, ngpjit


@ngjit
def segment_intersects_point(ax0, ay0, ax1, ay1, bx, by):
Expand Down
2 changes: 1 addition & 1 deletion spatialpandas/geometry/_algorithms/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from spatialpandas.utils import ngjit
from ...utils import ngjit


@ngjit
Expand Down
5 changes: 3 additions & 2 deletions spatialpandas/geometry/_algorithms/orientation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from spatialpandas.geometry._algorithms.measures import compute_area
from spatialpandas.utils import ngjit
import numpy as np

from ...geometry._algorithms.measures import compute_area
from ...utils import ngjit


@ngjit
def triangle_orientation(ax, ay, bx, by, cx, cy):
Expand Down
34 changes: 20 additions & 14 deletions spatialpandas/geometry/base.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import re
from collections.abc import Container, Iterable
from numbers import Integral
from collections.abc import Iterable

import numpy as np
import pandas as pd
import pyarrow as pa
from pandas.api.extensions import ExtensionArray, ExtensionDtype
from pandas.api.types import is_array_like

from spatialpandas.spatialindex import HilbertRtree
from spatialpandas.spatialindex.rtree import _distances_from_bounds
import re

from spatialpandas.utils import ngjit
from .._optional_imports import sg, gp
from .._optional_imports import gp, sg
from ..spatialindex import HilbertRtree
from ..spatialindex.rtree import _distances_from_bounds
from ..utils import ngjit


def _unwrap_geometry(a, element_dtype):
Expand Down Expand Up @@ -144,6 +143,8 @@ def __hash__(self):
return hash((self.__class__, np.array(self.data.as_py()).tobytes()))

def __eq__(self, other):
if isinstance(other, Container):
return other == self
if type(other) is not type(self):
return False
return self.data == other.data
Expand Down Expand Up @@ -336,11 +337,18 @@ def __eq__(self, other):
for i in range(len(self)):
result[i] = self[i] == other[i]
return result
else:
raise ValueError("""
if isinstance(other, (self.dtype.type, type(None))):
result = np.zeros(len(self), dtype=np.bool_)
for i in range(len(self)):
result[i] = self[i] == other
return result
raise ValueError("""
Cannot check equality of {typ} of length {a_len} with:
{other}""".format(typ=type(self).__name__, a_len=len(self), other=repr(other)))

def __contains__(self, item) -> bool:
raise NotImplementedError

def __len__(self):
return len(self.data)

Expand Down Expand Up @@ -499,8 +507,8 @@ def _concat_same_type(cls, to_concat):

def fillna(self, value=None, method=None, limit=None):
from pandas.api.types import is_array_like
from pandas.util._validators import validate_fillna_kwargs
from pandas.core.missing import get_fill_func
from pandas.util._validators import validate_fillna_kwargs

value, method = validate_fillna_kwargs(value, method)

Expand Down Expand Up @@ -766,10 +774,8 @@ def is_geometry_array(data):


def to_geometry_array(data, dtype=None):
from . import (
PointArray, MultiPointArray, LineArray, RingArray,
MultiLineArray, PolygonArray, MultiPolygonArray
)
from . import (LineArray, MultiLineArray, MultiPointArray,
MultiPolygonArray, PointArray, PolygonArray, RingArray)
if sg is not None:
shapely_to_spatialpandas = {
sg.Point: PointArray,
Expand Down
Loading