Skip to content

Commit 42e0a5e

Browse files
committed
deprecate "radius" and "radius_crs" kwargs -> use "size" and "crs" instead!
1 parent 7d18dbc commit 42e0a5e

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

eomaps/shapes.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@
1616
_log = logging.getLogger(__name__)
1717

1818

19+
def _depreciate_radius(size, crs, **kwargs):
20+
# depreciate use of radius and radius_crs in favor of size and crs
21+
# TODO remove in v8
22+
23+
if "radius" in kwargs:
24+
_log.warning(
25+
"EOmaps: The 'radius' kwarg is depreciated "
26+
"and will be removed in EOmaps v8. "
27+
"Use 'size' instead!"
28+
)
29+
size = kwargs.pop("radius")
30+
31+
if "radius_crs" in kwargs:
32+
_log.warning(
33+
"EOmaps: The 'radius_crs' kwarg is depreciated "
34+
"and will be removed in EOmaps v8. "
35+
"Use 'crs' instead!"
36+
)
37+
crs = kwargs.pop("radius_crs")
38+
39+
return size, crs
40+
41+
1942
class _CollectionAccessor:
2043
"""
2144
Accessor class to handle contours drawn by plt.contour.
@@ -643,20 +666,20 @@ class _Ellipses(_ShapeBase):
643666
def __init__(self, m):
644667
super().__init__(m=m)
645668

646-
def __call__(self, radius="estimate", radius_crs="in", n=None):
669+
def __call__(self, size="estimate", crs="in", n=None, **kwargs):
647670
"""
648671
Draw projected ellipses with dimensions defined in units of a given crs.
649672
650673
Parameters
651674
----------
652-
radius : int, float, array-like or str, optional
653-
The radius in x- and y- direction.
654-
The default is "estimate" in which case the radius is attempted
655-
to be estimated from the input-coordinates.
675+
size : int, float, array-like or str, optional
676+
The size in x- and y- direction.
677+
The default is "estimate" in which case the size is estimated
678+
from the input-coordinates.
656679
657680
If you provide an array of sizes, each datapoint will be drawn with
658681
the respective size!
659-
radius_crs : crs-specification, optional
682+
crs : crs-specification, optional
660683
The crs in which the dimensions are defined.
661684
The default is "in".
662685
n : int or None
@@ -666,6 +689,8 @@ def __call__(self, radius="estimate", radius_crs="in", n=None):
666689
"""
667690
from . import MapsGrid # do this here to avoid circular imports!
668691

692+
radius, radius_crs = _depreciate_radius(size, crs, **kwargs)
693+
669694
for m in self._m if isinstance(self._m, MapsGrid) else [self._m]:
670695
shape = self.__class__(m)
671696

@@ -876,20 +901,19 @@ class _Rectangles(_ShapeBase):
876901
def __init__(self, m):
877902
super().__init__(m=m)
878903

879-
def __call__(self, radius="estimate", radius_crs="in", mesh=False, n=None):
904+
def __call__(self, size="estimate", crs="in", mesh=False, n=None, **kwargs):
880905
"""
881906
Draw projected rectangles with fixed dimensions (and possibly curved edges).
882907
883908
Parameters
884909
----------
885-
radius : int, float, tuple or str, optional
886-
The radius in x- and y- direction.
887-
The default is "estimate" in which case the radius is attempted
888-
to be estimated from the input-coordinates.
910+
size : int, float, tuple or str, optional
911+
The size in x- and y- direction. The default is "estimate" in which
912+
case the size is estimated from the input-coordinates.
889913
890914
If you provide an array of sizes, each datapoint will be drawn with
891915
the respective size!
892-
radius_crs : crs-specification, optional
916+
crs : crs-specification, optional
893917
The crs in which the dimensions are defined.
894918
The default is "in".
895919
mesh : bool
@@ -909,6 +933,8 @@ def __call__(self, radius="estimate", radius_crs="in", mesh=False, n=None):
909933
"""
910934
from . import MapsGrid # do this here to avoid circular imports!
911935

936+
radius, radius_crs = _depreciate_radius(size, crs, **kwargs)
937+
912938
for m in self._m if isinstance(self._m, MapsGrid) else [self._m]:
913939
shape = self.__class__(m)
914940

0 commit comments

Comments
 (0)