diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f3187e26..8fa77196 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -15,6 +15,10 @@ on: default: test required: false +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: Test: name: ${{ matrix.os }}, ${{ matrix.environment-file }} diff --git a/ci/envs/312-dev.yaml b/ci/envs/312-dev.yaml index a8e29321..119adf74 100644 --- a/ci/envs/312-dev.yaml +++ b/ci/envs/312-dev.yaml @@ -3,28 +3,24 @@ channels: - conda-forge dependencies: - python=3.12 - - dask - - geopandas - - inequality - - libpysal>=4.11.0 - - networkx - - osmnx - packaging - - pandas!=1.5.0 - - shapely>=2 - tqdm - - numba + # - numba # testing - codecov - pytest - pytest-cov - # for mapclassify - - scikit-learn - pip - pip: + - --pre --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --extra-index-url https://pypi.org/simple + - numpy + - pandas + - shapely - git+https://github.com/geopandas/geopandas.git - git+https://github.com/pysal/libpysal.git - git+https://github.com/networkx/networkx.git - - git+https://github.com/shapely/shapely.git - git+https://github.com/pysal/mapclassify.git - git+https://github.com/pysal/esda.git + - git+https://github.com/pysal/inequality.git + - osmnx + - scikit-learn diff --git a/momepy/functional/_dimension.py b/momepy/functional/_dimension.py index ff05cc39..987ea405 100644 --- a/momepy/functional/_dimension.py +++ b/momepy/functional/_dimension.py @@ -28,9 +28,9 @@ def volume( - area: NDArray[np.float_] | Series, - height: NDArray[np.float_] | Series, -) -> NDArray[np.float_] | Series: + area: NDArray[np.float64] | Series, + height: NDArray[np.float64] | Series, +) -> NDArray[np.float64] | Series: """ Calculates volume of each object in given GeoDataFrame based on its height and area. @@ -39,24 +39,24 @@ def volume( Parameters ---------- - area : NDArray[np.float_] | Series + area : NDArray[np.float64] | Series array of areas - height : NDArray[np.float_] | Series + height : NDArray[np.float64] | Series array of heights Returns ------- - NDArray[np.float_] | Series + NDArray[np.float64] | Series array of a type depending on the input """ return area * height def floor_area( - area: NDArray[np.float_] | Series, - height: NDArray[np.float_] | Series, - floor_height: float | NDArray[np.float_] | Series = 3, -) -> NDArray[np.float_] | Series: + area: NDArray[np.float64] | Series, + height: NDArray[np.float64] | Series, + floor_height: float | NDArray[np.float64] | Series = 3, +) -> NDArray[np.float64] | Series: """Calculates floor area of each object based on height and area. The number of @@ -69,17 +69,17 @@ def floor_area( Parameters ---------- - area : NDArray[np.float_] | Series + area : NDArray[np.float64] | Series array of areas - height : NDArray[np.float_] | Series + height : NDArray[np.float64] | Series array of heights - floor_height : float | NDArray[np.float_] | Series, optional + floor_height : float | NDArray[np.float64] | Series, optional float denoting the uniform floor height or an aarray reflecting the building height by geometry, by default 3 Returns ------- - NDArray[np.float_] | Series + NDArray[np.float64] | Series array of a type depending on the input """ return area * (height // floor_height) @@ -172,7 +172,7 @@ def perimeter_wall( def weighted_character( - y: NDArray[np.float_] | Series, area: NDArray[np.float_] | Series, graph: Graph + y: NDArray[np.float64] | Series, area: NDArray[np.float64] | Series, graph: Graph ) -> Series: """Calculates the weighted character. @@ -191,9 +191,9 @@ def weighted_character( Parameters ---------- - y : NDArray[np.float_] | Series + y : NDArray[np.float64] | Series The character values to be weighted. - area : NDArray[np.float_] | Series + area : NDArray[np.float64] | Series The area values to be used as weightss graph : libpysal.graph.Graph A spatial weights matrix for values and areas. @@ -392,7 +392,7 @@ def _get_point_njit(x1, y1, bearing, dist): @njit def generate_ticks(list_points, end_markers, tick_length): - ticks = np.empty((len(list_points) * 2, 4), dtype=np.float64) + ticks = np.empty((len(list_points) * 2, 4), dtype=float) for i in range(len(list_points)): tick_pos = i * 2 diff --git a/momepy/functional/_diversity.py b/momepy/functional/_diversity.py index 3ff5ea37..ad2c1880 100644 --- a/momepy/functional/_diversity.py +++ b/momepy/functional/_diversity.py @@ -79,8 +79,8 @@ def _percentile_limited_group_grouper(y, group_index, q=(25, 75)): def describe_agg( - y: NDArray[np.float_] | Series, - aggregation_key: NDArray[np.float_] | Series, + y: NDArray[np.float64] | Series, + aggregation_key: NDArray[np.float64] | Series, result_index: pd.Index = None, q: tuple[float, float] | list[float] | None = None, statistics: list[str] | None = None, @@ -171,8 +171,8 @@ def describe_agg( def describe_reached_agg( - y: NDArray[np.float_] | Series, - graph_index: NDArray[np.float_] | Series, + y: NDArray[np.float64] | Series, + graph_index: NDArray[np.float64] | Series, graph: Graph, q: tuple[float, float] | list[float] | None = None, statistics: list[str] | None = None, diff --git a/momepy/functional/_shape.py b/momepy/functional/_shape.py index 15eb5481..0d0a970e 100644 --- a/momepy/functional/_shape.py +++ b/momepy/functional/_shape.py @@ -32,7 +32,7 @@ def form_factor( geometry: GeoDataFrame | GeoSeries, - height: NDArray[np.float_] | Series, + height: NDArray[np.float64] | Series, ) -> Series: """Calculates the form factor of each object given its geometry and height. @@ -50,7 +50,7 @@ def form_factor( ---------- geometry : GeoDataFrame | GeoSeries A GeoDataFrame or GeoSeries containing polygons to analyse. - height : NDArray[np.float_] | Series + height : NDArray[np.float64] | Series array of heights Returns @@ -178,7 +178,7 @@ def convexity(geometry: GeoDataFrame | GeoSeries) -> Series: def courtyard_index( geometry: GeoDataFrame | GeoSeries, - courtyard_area: NDArray[np.float_] | Series | None = None, + courtyard_area: NDArray[np.float64] | Series | None = None, ) -> Series: """Calculates the courtyard index of each object given its geometry. @@ -191,7 +191,7 @@ def courtyard_index( ---------- geometry : GeoDataFrame | GeoSeries A GeoDataFrame or GeoSeries containing polygons to analyse. - courtyard_area : NDArray[np.float_] | Series | None, optional + courtyard_area : NDArray[np.float64] | Series | None, optional array of courtyard areas. If None, it will be calculated, by default None Returns @@ -227,7 +227,7 @@ def rectangularity(geometry: GeoDataFrame | GeoSeries) -> Series: def shape_index( geometry: GeoDataFrame | GeoSeries, - longest_axis_length: NDArray[np.float_] | Series | None = None, + longest_axis_length: NDArray[np.float64] | Series | None = None, ) -> Series: """Calculates the shape index of each object given its geometry. @@ -238,7 +238,7 @@ def shape_index( ---------- geometry : GeoDataFrame | GeoSeries A GeoDataFrame or GeoSeries containing polygons to analyse. - longest_axis_length : NDArray[np.float_] | Series | None, optional + longest_axis_length : NDArray[np.float64] | Series | None, optional array of longest axis lengths. If None, it will be calculated, by default None Returns @@ -475,7 +475,7 @@ def linearity(geometry: GeoDataFrame | GeoSeries) -> Series: def compactness_weighted_axis( geometry: GeoDataFrame | GeoSeries, - longest_axis_length: NDArray[np.float_] | Series | None = None, + longest_axis_length: NDArray[np.float64] | Series | None = None, ) -> Series: """Calculates the compactness-weighted axis of each object in a given GeoDataFrame. @@ -487,7 +487,7 @@ def compactness_weighted_axis( ---------- geometry : GeoDataFrame | GeoSeries A GeoDataFrame or GeoSeries containing polygons to analyse. - longest_axis_length : NDArray[np.float_] | Series | None, optional + longest_axis_length : NDArray[np.float64] | Series | None, optional array of longest axis lengths. If None, it will be calculated, by default None Returns @@ -506,13 +506,13 @@ def compactness_weighted_axis( def _true_angles_mask( - points: NDArray[np.float_], eps: float, return_degrees: bool = False -) -> NDArray[np.bool_] | tuple[NDArray[np.bool_], NDArray[np.float_]]: + points: NDArray[np.float64], eps: float, return_degrees: bool = False +) -> NDArray[np.bool_] | tuple[NDArray[np.bool_], NDArray[np.float64]]: """Calculates the mask of true angles. Parameters ---------- - points : NDArray[np.float_] + points : NDArray[np.float64] array of points eps : float Deviation from 180 degrees to consider a corner @@ -521,7 +521,7 @@ def _true_angles_mask( Returns ------- - NDArray[np.bool_] | tuple[NDArray[np.bool_], NDArray[np.float_]] + NDArray[np.bool_] | tuple[NDArray[np.bool_], NDArray[np.float64]] boolean array or a tuple of boolean array and float array of degrees """ a = np.roll(points, 1, axis=0) diff --git a/momepy/functional/tests/test_distribution.py b/momepy/functional/tests/test_distribution.py index f0a990a7..4c141a13 100644 --- a/momepy/functional/tests/test_distribution.py +++ b/momepy/functional/tests/test_distribution.py @@ -56,7 +56,7 @@ def test_alignment(self): "max": 21.32311946014944, } r = mm.alignment(orientation, self.graph) - assert_result(r, expected, self.df_buildings) + assert_result(r, expected, self.df_buildings, check_names=False) def test_neighbor_distance(self): expected = { @@ -66,7 +66,7 @@ def test_neighbor_distance(self): "max": 42.164831456311475, } r = mm.neighbor_distance(self.df_buildings, self.graph) - assert_result(r, expected, self.df_buildings) + assert_result(r, expected, self.df_buildings, check_names=False) def test_mean_interbuilding_distance(self): expected = { diff --git a/momepy/preprocessing.py b/momepy/preprocessing.py index 9c5e4924..b5faa612 100644 --- a/momepy/preprocessing.py +++ b/momepy/preprocessing.py @@ -1518,7 +1518,7 @@ class FaceArtifacts: ['circlular_compactness', 'isoperimetric_quotient', 'diameter_ratio'], by default "circular_compactness" height_mins : float, optional - Required depth of valleys, by default np.NINF + Required depth of valleys, by default -np.inf height_maxs : float, optional Required height of peaks, by default 0.008 prominence : float, optional @@ -1560,7 +1560,7 @@ def __init__( self, gdf, index="circular_compactness", - height_mins=np.NINF, + height_mins=-np.inf, height_maxs=0.008, prominence=0.00075, ):