Skip to content

Commit f7561e3

Browse files
authored
API: deprecation decorators for transition to functional API (#406)
* POC: function-based API * deprecation * include removed decorator * use the deprecation, update * update * testing
1 parent 2399659 commit f7561e3

File tree

3 files changed

+282
-74
lines changed

3 files changed

+282
-74
lines changed

momepy/dimension.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from tqdm.auto import tqdm
1515

1616
from .shape import _circle_radius
17+
from .utils import deprecated, removed
1718

1819
GPD_GE_10 = Version(gpd.__version__) >= Version("1.0dev")
1920

@@ -34,6 +35,7 @@
3435
]
3536

3637

38+
@removed("`.area` attribute of a GeoDataFrame")
3739
class Area:
3840
"""
3941
Calculates the area of each object in a given GeoDataFrame. It can be used for any
@@ -63,11 +65,11 @@ class Area:
6365
"""
6466

6567
def __init__(self, gdf):
66-
# TODO: deprecate and point people to .area
6768
self.gdf = gdf
6869
self.series = self.gdf.geometry.area
6970

7071

72+
@removed("`.length` attribute of a GeoDataFrame")
7173
class Perimeter:
7274
"""
7375
Calculates perimeter of each object in a given GeoDataFrame. It can be used for any
@@ -96,11 +98,11 @@ class Perimeter:
9698
"""
9799

98100
def __init__(self, gdf):
99-
# TODO: deprecate and point people to .length
100101
self.gdf = gdf
101102
self.series = self.gdf.geometry.length
102103

103104

105+
@deprecated("volume")
104106
class Volume:
105107
"""
106108
Calculates the volume of each object in a
@@ -145,7 +147,6 @@ class Volume:
145147
"""
146148

147149
def __init__(self, gdf, heights, areas=None):
148-
# TODO: deprecate in favor of volume
149150
self.gdf = gdf
150151

151152
gdf = gdf.copy()
@@ -170,6 +171,7 @@ def __init__(self, gdf, heights, areas=None):
170171
) from err
171172

172173

174+
@deprecated("floor_area")
173175
class FloorArea:
174176
"""
175177
Calculates floor area of each object based on height and area. The number of
@@ -218,7 +220,6 @@ class FloorArea:
218220
"""
219221

220222
def __init__(self, gdf, heights, areas=None):
221-
# TODO: deprecate in favor of floor_area
222223
self.gdf = gdf
223224

224225
gdf = gdf.copy()
@@ -243,6 +244,7 @@ def __init__(self, gdf, heights, areas=None):
243244
) from err
244245

245246

247+
@deprecated("courtyard_area")
246248
class CourtyardArea:
247249
"""
248250
Calculates area of holes within geometry - area of courtyards.
@@ -292,6 +294,7 @@ def __init__(self, gdf, areas=None):
292294
self.series = pd.Series(exts - gdf[areas], index=gdf.index)
293295

294296

297+
@deprecated("longest_axis_length")
295298
class LongestAxisLength:
296299
"""
297300
Calculates the length of the longest axis of object. Axis is defined as a
@@ -321,12 +324,12 @@ class LongestAxisLength:
321324
"""
322325

323326
def __init__(self, gdf):
324-
# TODO: deprecate in favor of longest_axis_length
325327
self.gdf = gdf
326328
hulls = gdf.geometry.convex_hull.exterior
327329
self.series = hulls.apply(lambda g: _circle_radius(list(g.coords))) * 2
328330

329331

332+
@deprecated("describe")
330333
class AverageCharacter:
331334
"""
332335
Calculates the average of a character within a set
@@ -407,7 +410,6 @@ def __init__(
407410
mode="all",
408411
verbose=True,
409412
):
410-
# TODO: deprecate in favor of momepy.describe
411413
self.gdf = gdf
412414
self.sw = spatial_weights
413415
self.id = gdf[unique_id]
@@ -862,6 +864,7 @@ def __init__(self, gdf, spatial_weights, unique_id, verbose=True):
862864
self.series = pd.Series(results_list, index=gdf.index)
863865

864866

867+
@deprecated("perimeter_wall")
865868
class PerimeterWall:
866869
"""
867870
Calculate the perimeter wall length of the joined structure.
@@ -901,7 +904,6 @@ class PerimeterWall:
901904
"""
902905

903906
def __init__(self, gdf, spatial_weights=None, verbose=True):
904-
# TODO: deprecate in favor of perimeter_wall
905907
self.gdf = gdf
906908

907909
if spatial_weights is None:

0 commit comments

Comments
 (0)