diff --git a/ecoscope/base/__init__.py b/ecoscope/base/__init__.py index 4a10c84..bc98e5e 100644 --- a/ecoscope/base/__init__.py +++ b/ecoscope/base/__init__.py @@ -7,7 +7,6 @@ ) from ecoscope.base.base import EcoDataFrame, Relocations, Trajectory from ecoscope.base.utils import ( - cachedproperty, create_meshgrid, groupby_intervals, hex_to_rgba, @@ -23,7 +22,6 @@ "RelocsSpeedFilter", "TrajSegFilter", "Trajectory", - "cachedproperty", "create_meshgrid", "groupby_intervals", "hex_to_rgba", diff --git a/ecoscope/base/base.py b/ecoscope/base/base.py index 776109b..c14890a 100644 --- a/ecoscope/base/base.py +++ b/ecoscope/base/base.py @@ -13,7 +13,7 @@ RelocsSpeedFilter, TrajSegFilter, ) -from ecoscope.base.utils import cachedproperty +from functools import cached_property class EcoDataFrame(gpd.GeoDataFrame): @@ -285,13 +285,13 @@ def apply_reloc_filter(self, fix_filter=None, inplace=False): if not inplace: return frame - @cachedproperty + @cached_property def distance_from_centroid(self): # calculate the distance between the centroid and the fix gs = self.geometry.to_crs(crs=self.estimate_utm_crs()) return gs.distance(gs.unary_union.centroid) - @cachedproperty + @cached_property def cluster_radius(self): """ The cluster radius is the largest distance between a point in the relocationss and the @@ -300,7 +300,7 @@ def cluster_radius(self): distance = self.distance_from_centroid return distance.max() - @cachedproperty + @cached_property def cluster_std_dev(self): """ The cluster standard deviation is the standard deviation of the radii from the centroid diff --git a/ecoscope/base/utils.py b/ecoscope/base/utils.py index ae2b036..d257f3b 100644 --- a/ecoscope/base/utils.py +++ b/ecoscope/base/utils.py @@ -74,33 +74,6 @@ def create_meshgrid( return gs.to_crs(out_crs) -class cachedproperty: # noqa - """ - The ``cachedproperty`` is used similar to :class:`property`, except - that the wrapped method is only called once. This is commonly used - to implement lazy attributes. - """ - - def __init__(self, func): - self.func = func - - def __doc__(self): - return getattr(self.func, "__doc__") - - def __isabstractmethod__(self): - return getattr(self.func, "__isabstractmethod__", False) - - def __get__(self, obj, objtype=None): - if obj is None: - return self - value = obj.__dict__[self.func.__name__] = self.func(obj) - return value - - def __repr__(self): - cls = self.__class__.__name__ - return f"<{cls} func={self.func}>" - - def groupby_intervals(df, col, intervals): """ Parameters