Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate radius kwarg for shapes #215

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
50 changes: 38 additions & 12 deletions eomaps/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@
_log = logging.getLogger(__name__)


def _depreciate_radius(size, crs, **kwargs):
# depreciate use of radius and radius_crs in favor of size and crs
# TODO remove in v8

if "radius" in kwargs:
_log.warning(
"EOmaps: The 'radius' kwarg is depreciated "
"and will be removed in EOmaps v8. "
"Use 'size' instead!"
)
size = kwargs.pop("radius")

if "radius_crs" in kwargs:
_log.warning(
"EOmaps: The 'radius_crs' kwarg is depreciated "
"and will be removed in EOmaps v8. "
"Use 'crs' instead!"
)
crs = kwargs.pop("radius_crs")

return size, crs


class _CollectionAccessor:
"""
Accessor class to handle contours drawn by plt.contour.
Expand Down Expand Up @@ -648,20 +671,20 @@ class _Ellipses(_ShapeBase):
def __init__(self, m):
super().__init__(m=m)

def __call__(self, radius="estimate", radius_crs="in", n=None):
def __call__(self, size="estimate", crs="in", n=None, **kwargs):
"""
Draw projected ellipses with dimensions defined in units of a given crs.

Parameters
----------
radius : int, float, array-like or str, optional
The radius in x- and y- direction.
The default is "estimate" in which case the radius is attempted
to be estimated from the input-coordinates.
size : int, float, array-like or str, optional
The size in x- and y- direction.
The default is "estimate" in which case the size is estimated
from the input-coordinates.

If you provide an array of sizes, each datapoint will be drawn with
the respective size!
radius_crs : crs-specification, optional
crs : crs-specification, optional
The crs in which the dimensions are defined.
The default is "in".
n : int or None
Expand All @@ -671,6 +694,8 @@ def __call__(self, radius="estimate", radius_crs="in", n=None):
"""
from . import MapsGrid # do this here to avoid circular imports!

radius, radius_crs = _depreciate_radius(size, crs, **kwargs)

for m in self._m if isinstance(self._m, MapsGrid) else [self._m]:
shape = self.__class__(m)

Expand Down Expand Up @@ -881,20 +906,19 @@ class _Rectangles(_ShapeBase):
def __init__(self, m):
super().__init__(m=m)

def __call__(self, radius="estimate", radius_crs="in", mesh=False, n=None):
def __call__(self, size="estimate", crs="in", mesh=False, n=None, **kwargs):
"""
Draw projected rectangles with fixed dimensions (and possibly curved edges).

Parameters
----------
radius : int, float, tuple or str, optional
The radius in x- and y- direction.
The default is "estimate" in which case the radius is attempted
to be estimated from the input-coordinates.
size : int, float, tuple or str, optional
The size in x- and y- direction. The default is "estimate" in which
case the size is estimated from the input-coordinates.

If you provide an array of sizes, each datapoint will be drawn with
the respective size!
radius_crs : crs-specification, optional
crs : crs-specification, optional
The crs in which the dimensions are defined.
The default is "in".
mesh : bool
Expand All @@ -914,6 +938,8 @@ def __call__(self, radius="estimate", radius_crs="in", mesh=False, n=None):
"""
from . import MapsGrid # do this here to avoid circular imports!

radius, radius_crs = _depreciate_radius(size, crs, **kwargs)

for m in self._m if isinstance(self._m, MapsGrid) else [self._m]:
shape = self.__class__(m)

Expand Down
Loading