Skip to content
Open
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
33 changes: 30 additions & 3 deletions esda/shape.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import warnings

import numpy
import pandas
Expand Down Expand Up @@ -198,7 +199,23 @@ def radii_ratio(collection):
"""
The Flaherty & Crumplin (1992) index, OS_3 in :cite:`altman1998Districting`.

Also known as Schumm's shape index (Schumm (1956) in MacEachren 1985).

The ratio of the radius of the equi-areal circle to the radius of the MBC
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period at the end of the description sentence. The line should end with a period for consistency with other docstrings in the module.

Suggested change
The ratio of the radius of the equi-areal circle to the radius of the MBC
The ratio of the radius of the equi-areal circle to the radius of the MBC.

Copilot uses AI. Check for mistakes.

.. math::
{\\sqrt{{A} \\over {\\pi}}} \\over {R}

where :math:`A` is the area and :math:`R` is the radius of the minimum bounding
circle.

Notes
-----
Implementation follows :cite:`maceachren1985compactness`.

See Also
--------
shape_index : Deprecated alias for this function.
"""
ga = _cast(collection)
r_eac = numpy.sqrt(shapely.area(ga) / numpy.pi)
Expand Down Expand Up @@ -350,7 +367,12 @@ def rectangularity(collection):

def shape_index(collection):
"""
Schumm’s shape index (Schumm (1956) in MacEachren 1985)
.. deprecated:: 2.5.0
``shape_index`` is deprecated and will be removed in future.
Use :func:`radii_ratio` instead, which computes the same Schumm's shape index
(Schumm (1956) in MacEachren 1985).

Schumm's shape index (Schumm (1956) in MacEachren 1985)

.. math::
{\\sqrt{{A} \\over {\\pi}}} \\over {R}
Expand All @@ -363,8 +385,13 @@ def shape_index(collection):
Implementation follows :cite:`maceachren1985compactness`.

"""
ga = _cast(collection)
return numpy.sqrt(shapely.area(ga) / numpy.pi) / shapely.minimum_bounding_radius(ga)
warnings.warn(
"shape_index is deprecated and will be removed in future. "
"Use radii_ratio instead, which computes the same index.",
DeprecationWarning,
stacklevel=2,
)
return radii_ratio(collection)


def equivalent_rectangular_index(collection):
Expand Down
11 changes: 9 additions & 2 deletions esda/tests/test_shape.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import geopandas
import numpy
import pytest
Expand Down Expand Up @@ -176,8 +178,13 @@ def test_rectangularity():


def test_shape_index():
observed = esda.shape.shape_index(shape)
testing.assert_allclose(observed, 0.659366, atol=ATOL)
"""Test that shape_index is deprecated and returns same value as radii_ratio."""
with pytest.warns(DeprecationWarning, match="deprecated"):
observed = esda.shape.shape_index(shape)

# Check that result matches radii_ratio
expected = esda.shape.radii_ratio(shape)
testing.assert_allclose(observed, expected, atol=ATOL)
Comment on lines +185 to +187
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the original test here. You are deprecating stuff, you should ensure that original tests pass.

testing.assert_allclose(observed, 0.659366, atol=ATOL)



def test_equivalent_rectangular_index():
Expand Down
Loading