- proper overwrite
- no out of bounds error for empty time selection (just pick nothin)
This commit is contained in:
Martin Diehl 2020-05-25 23:54:06 +02:00
parent 9855c61747
commit 6f7c7005b0
1 changed files with 2 additions and 1 deletions

View File

@ -146,6 +146,7 @@ class Result:
choice = [] choice = []
for c in iterator: for c in iterator:
idx = np.searchsorted(self.times,c) idx = np.searchsorted(self.times,c)
if idx >= len(self.times): continue
if np.isclose(c,self.times[idx]): if np.isclose(c,self.times[idx]):
choice.append(self.increments[idx]) choice.append(self.increments[idx])
elif np.isclose(c,self.times[idx+1]): elif np.isclose(c,self.times[idx+1]):
@ -1031,7 +1032,7 @@ class Result:
try: try:
if self._allow_overwrite and result[0]+'/'+result[1]['label'] in f: if self._allow_overwrite and result[0]+'/'+result[1]['label'] in f:
dataset = f[result[0]+'/'+result[1]['label']] dataset = f[result[0]+'/'+result[1]['label']]
datset = result[1]['data'] dataset[...] = result[1]['data']
dataset.attrs['Overwritten'] = 'Yes'.encode() dataset.attrs['Overwritten'] = 'Yes'.encode()
else: else:
dataset = f[result[0]].create_dataset(result[1]['label'],data=result[1]['data']) dataset = f[result[0]].create_dataset(result[1]['label'],data=result[1]['data'])