Skip to content

Commit c7a9fc9

Browse files
committed
Clean inputs.py and use Proj to parse 'transform'
1 parent 8db6c5c commit c7a9fc9

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

proplot/internals/inputs.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import numpy.ma as ma
1010

1111
from . import ic # noqa: F401
12+
from . import _not_none, warnings
1213

1314
try:
1415
from cartopy.crs import PlateCarree
@@ -246,18 +247,15 @@ def _redirect_or_standardize(self, *args, **kwargs):
246247
return func_native(*args, **kwargs)
247248
else:
248249
# Impose default coordinate system
249-
if (
250-
self._name == 'basemap'
251-
and name in BASEMAP_FUNCS
252-
and kwargs.get('latlon', None) is None
253-
):
254-
kwargs['latlon'] = True
255-
if (
256-
self._name == 'cartopy'
257-
and name in CARTOPY_FUNCS
258-
and kwargs.get('transform', None) is None
259-
):
260-
kwargs['transform'] = PlateCarree()
250+
from ..constructor import Proj
251+
if self._name == 'basemap' and name in BASEMAP_FUNCS:
252+
if kwargs.get('latlon', None) is None:
253+
kwargs['latlon'] = True
254+
if self._name == 'cartopy' and name in CARTOPY_FUNCS:
255+
if kwargs.get('transform', None) is None:
256+
kwargs['transform'] = PlateCarree()
257+
else:
258+
kwargs['transform'] = Proj(kwargs['transform'])
261259

262260
# Process data args
263261
# NOTE: Raises error if there are more args than keys
@@ -310,7 +308,6 @@ def _dist_reduce(data, *, mean=None, means=None, median=None, medians=None, **kw
310308
distribution keyword argument for processing down the line.
311309
"""
312310
# TODO: Permit 3D array with error dimension coming first
313-
from . import _not_none, warnings
314311
means = _not_none(mean=mean, means=means)
315312
medians = _not_none(median=median, medians=medians)
316313
if means and medians:
@@ -347,7 +344,6 @@ def _dist_range(
347344
"""
348345
# Parse stds arguments
349346
# NOTE: Have to guard against "truth value of an array is ambiguous" errors
350-
from . import warnings
351347
if stds is True:
352348
stds = stds_default
353349
elif stds is False or stds is None:
@@ -624,8 +620,6 @@ def _meta_units(data):
624620
`pint.Quantity`. Format the latter with :rcraw:`unitformat`.
625621
"""
626622
_load_objects()
627-
from ..config import rc
628-
from . import warnings
629623
# Get units from the attributes
630624
if ndarray is not DataArray and isinstance(data, DataArray):
631625
units = data.attrs.get('units', None)
@@ -634,6 +628,7 @@ def _meta_units(data):
634628
return units
635629
# Get units from the quantity
636630
if ndarray is not Quantity and isinstance(data, Quantity):
631+
from ..config import rc
637632
fmt = rc.unitformat
638633
try:
639634
units = format(data.units, fmt)

0 commit comments

Comments
 (0)