Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions ci/envs/311-oldest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ channels:
- conda-forge
dependencies:
- python=3.11
- geopandas=0.14
- geopandas=1.0
- inequality
- libpysal=4.12.0
- mapclassify
- networkx=3.2
- numpy=1.25
- networkx=3.3
- numpy=2.0
- packaging
- pandas=2.0
- pandas=2.2
- shapely=2.0
- tqdm=4.65
- numba=0.58
- tqdm=4.67
- numba=0.60
- fiona=1.10
# testing
- codecov
Expand Down
6 changes: 3 additions & 3 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ Dependencies

Required dependencies:

- `geopandas`_ (>= 0.12.0)
- `geopandas`_ (>= 1.0)
- `libpysal`_ (>= 4.12.0)
- `networkx`_
- `tqdm`_

Some functions also depend on additional packages, which are optional:

- `mapclassify`_ (>= 2.4.2)
- `mapclassify`_
- `inequality`_
- `numba`_
- `esda`_
Expand All @@ -111,7 +111,7 @@ Some functions also depend on additional packages, which are optional:

.. _numba: https://numba.pydata.org

.. _tqdm: http://networkx.github.io
.. _tqdm: https://tqdm.github.io

.. _pysal: http://pysal.org

Expand Down
7 changes: 0 additions & 7 deletions momepy/diversity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from libpysal.graph import Graph
from libpysal.graph._utils import _percentile_filtration_grouper
from numpy.typing import NDArray
from packaging.version import Version
from pandas import DataFrame, Series

try:
Expand Down Expand Up @@ -162,9 +161,6 @@ def describe_agg(
6.0 652.432194 32.829824
""" # noqa: E501

if Version(pd.__version__) <= Version("2.1.0"):
raise ImportError("pandas 2.1.0 or newer is required to use this function.")

# series indice needs renaming, since multiindices
# without explicit names cannot be joined
if isinstance(y, np.ndarray):
Expand Down Expand Up @@ -289,9 +285,6 @@ def describe_reached_agg(
4 683.514930 NaN
""" # noqa: E501

if Version(pd.__version__) <= Version("2.1.0"):
raise ImportError("pandas 2.1.0 or newer is required to use this function.")

# series indice needs renaming, since multiindices
# without explicit names cannot be joined
if isinstance(y, np.ndarray):
Expand Down
11 changes: 3 additions & 8 deletions momepy/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from shapely.geometry.base import BaseGeometry
from shapely.ops import polygonize

GPD_GE_10 = Version(gpd.__version__) >= Version("1.0dev")
SHPLY_GE_210 = Version(shapely.__version__) >= Version("2.1.0")

__all__ = [
Expand Down Expand Up @@ -127,7 +126,7 @@ def morphological_tessellation(
)

if isinstance(clip, GeoSeries | GeoDataFrame):
clip = clip.union_all() if GPD_GE_10 else clip.unary_union
clip = clip.union_all()

mt = voronoi_frames(
geometry,
Expand Down Expand Up @@ -772,11 +771,7 @@ def buffered_limit(
elif not isinstance(buffer, int | float):
raise ValueError("`buffer` must be either 'adaptive' or a number.")

return (
gdf.buffer(buffer, **kwargs).union_all()
if GPD_GE_10
else gdf.buffer(buffer, **kwargs).unary_union
)
return gdf.buffer(buffer, **kwargs).union_all()


def get_network_ratio(df, edges, initial_buffer=500):
Expand Down Expand Up @@ -921,7 +916,7 @@ def enclosures(
barriers = pd.concat([primary_barriers.geometry, limit_b.geometry])
else:
barriers = primary_barriers
unioned = barriers.union_all() if GPD_GE_10 else barriers.unary_union
unioned = barriers.union_all()
polygons = polygonize(unioned)
enclosures = gpd.GeoSeries(list(polygons), crs=primary_barriers.crs)

Expand Down
27 changes: 0 additions & 27 deletions momepy/tests/test_diversity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import pandas as pd
import pytest
from libpysal.graph import Graph
from packaging.version import Version
from pandas.testing import assert_frame_equal, assert_series_equal

import momepy as mm

from .conftest import assert_frame_result, assert_result

PD_210 = Version(pd.__version__) >= Version("2.1.0")


class TestDescribe:
def setup_method(self):
Expand Down Expand Up @@ -394,9 +391,6 @@ def test_unique(self):
un_nan_drop, un_nan_drop_expected, self.df_tessellation, check_names=False
)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_describe_agg(self):
df = mm.describe_agg(
self.df_buildings["area"],
Expand Down Expand Up @@ -469,9 +463,6 @@ def test_describe_agg(self):
assert_result(df["sum"], expected_fl_area_sum, result_index)
assert_result(df["mean"], expected_fl_area_mean, result_index)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_describe_cols(self):
df = mm.describe_agg(
self.df_buildings["area"],
Expand All @@ -480,9 +471,6 @@ def test_describe_cols(self):
)
assert list(df.columns) == ["min", "max"]

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_describe_reached_agg(self):
df_sw = mm.describe_reached_agg(
self.df_buildings["fl_area"], self.df_buildings["nID"], graph=self.graph_sw
Expand Down Expand Up @@ -512,9 +500,6 @@ def test_describe_reached_agg(self):
filtered_df["count"], filtered_expected, self.df_streets, check_names=False
)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_describe_reached_input_equality(self):
island_result_df = mm.describe_agg(
self.df_buildings["area"], self.df_buildings["nID"]
Expand All @@ -529,9 +514,6 @@ def test_describe_reached_input_equality(self):
island_result_df.values, island_result_ndarray.values, equal_nan=True
)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_describe_reached_cols(self):
df = mm.describe_reached_agg(
self.df_buildings["fl_area"],
Expand All @@ -542,9 +524,6 @@ def test_describe_reached_cols(self):
)
assert list(df.columns) == ["min", "max"]

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_na_results(self):
nan_areas = self.df_buildings["area"]
nan_areas.iloc[range(0, len(self.df_buildings), 3),] = np.nan
Expand Down Expand Up @@ -614,9 +593,6 @@ def test_density(self):
check_names=False,
)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_unweighted_percentile(self):
perc = mm.percentile(self.df_tessellation["area"], self.diversity_graph)
perc_expected = {
Expand Down Expand Up @@ -662,9 +638,6 @@ def test_unweighted_percentile(self):
perc = mm.percentile(self.df_tessellation["area"].iloc[:100], graph)
assert perc.loc[0].isna().all()

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_distance_decay_linearly_weighted_percentiles(self):
# setup weight decay graph

Expand Down
7 changes: 0 additions & 7 deletions momepy/tests/test_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
import networkx as nx
import numpy as np
import pandas as pd
import pytest
from libpysal.graph import Graph
from packaging.version import Version
from pandas.testing import assert_series_equal

import momepy as mm

from .conftest import assert_result

PD_210 = Version(pd.__version__) >= Version("2.1.0")


class TestIntensity:
def setup_method(self):
Expand Down Expand Up @@ -95,9 +91,6 @@ def test_node_density(self):
assert_series_equal(alternative_density, density)
assert_series_equal(alternative_weighted, weighted)

@pytest.mark.skipif(
not PD_210, reason="aggregation is different in previous pandas versions"
)
def test_area_ratio(self):
def area_ratio(overlay, covering, agg_key):
res = mm.describe_agg(covering, agg_key)
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ classifiers = [
]
requires-python = ">=3.11"
dependencies = [
"geopandas>=0.14.0",
"geopandas>=1.0",
"libpysal>=4.12.0",
"networkx>=3.2",
"networkx>=3.3",
"numpy>=2.0",
"packaging",
"pandas>=2.0",
"shapely>=2",
"tqdm>=4.65",
"pandas>=2.2",
"shapely>=2.0",
"tqdm>=4.67",
]

[project.urls]
Expand All @@ -49,7 +50,7 @@ Repository = "https://github.com/pysal/momepy"

[project.optional-dependencies]
plus = [
"numba",
"numba>=0.60",
"inequality",
"mapclassify",
"esda",
Expand Down