improved reporting + test

This commit is contained in:
Martin Diehl 2020-04-21 11:17:15 +02:00
parent bce5ed62d5
commit ac75b9e4ca
2 changed files with 16 additions and 6 deletions

View File

@ -86,13 +86,19 @@ class Result:
def __repr__(self):
"""Show selected data."""
all_selected_increments = self.selection['increments']
self.pick('increments',all_selected_increments[0:1])
first = self.list_data()
self.pick('increments',all_selected_increments[-1:])
last = self.list_data()
last = '' if len(all_selected_increments) < 2 else self.list_data()
self.pick('increments',all_selected_increments)
in_between = ''.join(['\n{}\n ...\n'.format(inc) for inc in all_selected_increments[1:-2]])
return util.srepr(first+ in_between + last)
in_between = '' if len(all_selected_increments) < 3 else \
''.join(['\n{}\n ...\n'.format(inc) for inc in all_selected_increments[1:-2]])
return util.srepr(first + in_between + last)
def _manage_selection(self,action,what,datasets):
@ -1009,7 +1015,7 @@ class Result:
continue
lock.acquire()
with h5py.File(self.fname, 'a') as f:
try:
try: # ToDo: Replace if exists?
dataset = f[result[0]].create_dataset(result[1]['label'],data=result[1]['data'])
for l,v in result[1]['meta'].items():
dataset.attrs[l]=v.encode()

View File

@ -24,6 +24,10 @@ def reference_dir(reference_dir_base):
class TestResult:
def test_self_report(self,default):
print(default)
def test_time_increments(self,default):
shape = default.read_dataset(default.get_dataset_location('F'),0).shape
default.set_by_time(0.0,20.0)