simplified
This commit is contained in:
parent
ee4cfe4b24
commit
8b421ba7a7
|
@ -1473,8 +1473,7 @@ class Result:
|
||||||
def job_pointwise(group: str,
|
def job_pointwise(group: str,
|
||||||
callback: Callable,
|
callback: Callable,
|
||||||
datasets: Dict[str, str],
|
datasets: Dict[str, str],
|
||||||
args: Dict[str, str]) -> List[Union[None, Any]]:
|
args: Dict[str, str]) -> Union[None, Any]:
|
||||||
"""Execute job for _add_generic_pointwise."""
|
|
||||||
try:
|
try:
|
||||||
datasets_in = {}
|
datasets_in = {}
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
|
@ -1484,11 +1483,10 @@ class Result:
|
||||||
'label':label,
|
'label':label,
|
||||||
'meta': {k:(v.decode() if not h5py3 and type(v) is bytes else v) \
|
'meta': {k:(v.decode() if not h5py3 and type(v) is bytes else v) \
|
||||||
for k,v in loc.attrs.items()}}
|
for k,v in loc.attrs.items()}}
|
||||||
r = callback(**datasets_in,**args)
|
return callback(**datasets_in,**args)
|
||||||
return [group,r]
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f'Error during calculation: {err}.')
|
print(f'Error during calculation: {err}.')
|
||||||
return [None,None]
|
return None
|
||||||
|
|
||||||
groups = []
|
groups = []
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
|
@ -1505,9 +1503,8 @@ class Result:
|
||||||
|
|
||||||
default_arg = partial(job_pointwise,callback=func,datasets=datasets,args=args)
|
default_arg = partial(job_pointwise,callback=func,datasets=datasets,args=args)
|
||||||
|
|
||||||
for grp in util.show_progress(groups):
|
for group in util.show_progress(groups):
|
||||||
group, result = default_arg(grp) # type: ignore
|
if not (result := default_arg(group)): # type: ignore
|
||||||
if not result:
|
|
||||||
continue
|
continue
|
||||||
with h5py.File(self.fname, 'a') as f:
|
with h5py.File(self.fname, 'a') as f:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue