Skip to content

Commit

Permalink
Fix stataccum
Browse files Browse the repository at this point in the history
  • Loading branch information
stefraynaud committed Jun 29, 2018
1 parent 91164bc commit 155bc74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/python/vacumm/misc/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from vacumm.misc.grid import get_grid, set_grid
from vacumm.misc import MV2_axisConcatenate, set_atts, cp_atts
from vacumm.misc.io import netcdf4
from vacumm.misc.atime import comptime
from vacumm.misc.atime import comptime, reltime

__all__ = ['corr_proba', 'ensrank', 'qtmin', 'qtmax', 'qtminmax',
'StatAccum', 'StatAccumError']
Expand Down Expand Up @@ -757,7 +757,8 @@ def load(self, restart_file=None, iterindex=None, nowtime=None):
if nowtime is not None:
self.lasttime = comptime(nowtime)
if (hasattr(self, 'lasttime') and f.withtime>0 and self.lasttime
and comptime(f.lasttime)<=comptime(self.lasttime)):
and reltime(f.lasttime, 'hours since 2000').value <=
reltime(self.lasttime, 'hours since 2000').value):
return -1
# - what was initially asked and some more
for sname in self.all_stats + ('sum', 'sqr', 'prod', 'stats'):
Expand Down
5 changes: 2 additions & 3 deletions scripts/test/test_stats_stataccum_dumpload.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test :class:`~vacumm.misc.stats.StatAccum` with dumping and loading """

# Imports
from vcmq import MV2, N, code_file_name, StatAccum
from vcmq import MV2, N, code_file_name, StatAccum, cdms2
from numpy.testing import assert_array_almost_equal
from numpy.random import seed

Expand All @@ -26,7 +26,7 @@
var2[5:15, -1:, -1:] = MV2.masked
var2.long_name = 'Sea level'
var2.id = 'sla'
mask = var1.mask|var2.mask # common mask
mask = var1.mask | var2.mask # common mask
vmax = var2.max()
bins = N.linspace(-0.1*vmax, 0.9*vmax, 14)
nbins = len(bins)
Expand Down Expand Up @@ -77,4 +77,3 @@
# result.append(('assertTrue', N.ma.allclose(sab_stats[sname], sa1_stats[sname])))
# print sname, N.ma.allclose(sab_stats[sname], sa1_stats[sname])

print 'Done'
2 changes: 1 addition & 1 deletion test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TSF(VCTestCase):
for test_name in [
'test_stats_stataccum_single',
'test_stats_stataccum_dual',
'test_stats_dumpload',
'test_stats_stataccum_dumpload',
]:
exec(method_template.format(test_name))

Expand Down

0 comments on commit 155bc74

Please sign in to comment.