Skip to content

Commit 341c832

Browse files
committed
Minor compatibility changes
1 parent 244b7ab commit 341c832

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

psyplot/data.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,6 +2815,7 @@ def fldmean(self, keepdims=False):
28152815
means.coords[xcoord.name].attrs['bounds'] = xcoord.name + '_bnds'
28162816
means.coords[ycoord.name].attrs['bounds'] = ycoord.name + '_bnds'
28172817
self._insert_fldmean_bounds(means, keepdims)
2818+
means.name = arr.name
28182819
return means
28192820

28202821
def fldstd(self, keepdims=False):
@@ -2851,13 +2852,17 @@ def fldstd(self, keepdims=False):
28512852
variance = variance.expand_dims(sdims, axis=axis)
28522853
for key, coord in six.iteritems(means.coords):
28532854
if key not in variance.coords:
2855+
dims = set(sdims).intersection(coord.dims)
28542856
variance[key] = coord if keepdims else coord.isel(
2855-
**dict(zip(sdims, repeat(0))))
2857+
**dict(zip(dims, repeat(0))))
28562858
for key, coord in six.iteritems(means.psy.base.coords):
28572859
if key not in variance.psy.base.coords:
2860+
dims = set(sdims).intersection(coord.dims)
28582861
variance.psy.base[key] = coord if keepdims else coord.isel(
2859-
**dict(zip(sdims, repeat(0))))
2860-
return variance**0.5
2862+
**dict(zip(dims, repeat(0))))
2863+
std = variance**0.5
2864+
std.name = arr.name
2865+
return std
28612866

28622867
def fldpctl(self, q, keepdims=False):
28632868
"""Calculate the percentiles along the x- and y-dimensions
@@ -2927,7 +2932,11 @@ def fldpctl(self, q, keepdims=False):
29272932
sorter.__getitem__(indices)])
29282933

29292934
# compute the percentiles
2930-
weights = np.nancumsum(weights, axis=0) - 0.5 * weights
2935+
try:
2936+
weights = np.nancumsum(weights, axis=0) - 0.5 * weights
2937+
except AttributeError:
2938+
notnull = ~np.isnan(weights)
2939+
weights[notnull] = np.cumsum(weights[notnull])
29312940
all_indices = map(tuple, product(*map(range, data.shape[1:])))
29322941
pctl = np.zeros((len(q), ) + data.shape[1:])
29332942

0 commit comments

Comments
 (0)