Skip to content

Commit b6f57e5

Browse files
committed
now in backward-compatible version
1 parent a2c394d commit b6f57e5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5087,23 +5087,25 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
50875087
dataout[...,i0_shift:] = datain[...,start_idx:i0+start_idx]
50885088
return dataout,lonsout
50895089

5090-
def addcyclic(arr,axis=-1):
5090+
def addcyclic(*arr,**axiskwarg):
50915091
"""
5092-
``arrout, lonsout = addcyclic((arrin, lonsin),axis=-1)``
5092+
``arrout, lonsout = addcyclic(arrin,lonsin,axis=-1)``
50935093
adds cyclic (wraparound) points in longitude to one or several arrays,
50945094
(e.g. ``arrin`` and ``lonsin``),
5095-
where ``axis`` sets the dimension longitude is in (default: right-most).
5095+
where ``axis`` sets the dimension longitude is in (optional, default: right-most).
50965096
"""
5097+
# get axis keyword argument (default: -1)
5098+
axis = axiskwarg.get('axis',-1)
50975099
# define function for a single grid array
50985100
def _addcyclic(a):
50995101
aT = np.swapaxes(a,0,axis)
51005102
idx = np.append(np.arange(aT.shape[0]),0)
51015103
return np.swapaxes(aT[idx],axis,0)
5102-
# process eventual list/tuple of arrays
5103-
if isinstance(arr,list) or isinstance(arr,tuple):
5104-
return map(_addcyclic,arr)
5104+
# process array(s)
5105+
if len(arr) == 1:
5106+
return _addcyclic(arr[0])
51055107
else:
5106-
return _addcyclic(arr)
5108+
return map(_addcyclic,arr)
51075109

51085110
def _choosecorners(width,height,**kwargs):
51095111
"""

0 commit comments

Comments
 (0)