Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openquake/calculators/export/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,9 @@ def export_job_zip(ekey, dstore):
inputs['taxonomy_mapping'] = dest
inputs['sites'] = dstore.export_path('sites.csv')
sitecol = dstore['sitecol']
sitecol.make_complete() # needed for test_impact[1]
writer.save(sitecol.array, inputs['sites'])
if 'complete' in dstore:
sitecol.complete = dstore['complete'] # needed for test_impact[1]
writer.save(sitecol.complete.array, inputs['sites'])
with open(job_ini, 'w') as out:
out.write(oq.to_ini(**inputs))
fnames = list(inputs.values()) + [assetcol_csv]
Expand Down
1 change: 0 additions & 1 deletion openquake/calculators/post_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ def post_execute(self, ok):
return
oq = self.oqparam
if 'risk' in oq.calculation_mode:
self.datastore['oqparam'] = oq
for ln in self.oqparam.loss_types:
li = scientific.LOSSID[ln]
dloss = views.view('delta_loss:%d' % li, self.datastore)
Expand Down
7 changes: 5 additions & 2 deletions openquake/commonlib/oqvalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,8 @@ def check_risk(self):
self.raise_invalid('missing investigation_time')

def check_ebrisk(self):
# check specific to ebrisk
# checks specific to ebrisk
self.ground_motion_fields = self.ground_motion_fields
if self.calculation_mode == 'ebrisk':
if self.ground_motion_fields:
print('ground_motion_fields overridden to false',
Expand Down Expand Up @@ -2345,7 +2346,9 @@ def to_ini(self, **inputs):
return ini

def __toh5__(self):
return hdf5.dumps(vars(self)), {}
oqp = hdf5.dumps(vars(self))
# assert '"ground_motion_fields": 1' in oqp
return oqp, {}

def __fromh5__(self, array, attrs):
if isinstance(array, numpy.ndarray):
Expand Down
2 changes: 1 addition & 1 deletion openquake/engine/tests/impact_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_impact(n):
with log, log2:
expose_outputs(calc.datastore)
expose_outputs(calc2.datastore)
# compare(calc.datastore, calc2.datastore)
compare(calc.datastore, calc2.datastore)


def test_impact5():
Expand Down
13 changes: 5 additions & 8 deletions openquake/hazardlib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,14 +674,11 @@ def __toh5__(self):
return {n: self.array[n] for n in names}, {'__pdcolumns__': cols}

def __fromh5__(self, dic, attrs):
if isinstance(dic, dict): # engine >= 3.11
params = attrs['__pdcolumns__'].split()
dtype = numpy.dtype([(p, site_param_dt[p]) for p in params])
self.array = numpy.zeros(len(dic['sids']), dtype)
for p in dic:
self.array[p] = dic[p][()]
else: # old engine, dic is actually a structured array
self.array = dic
params = attrs['__pdcolumns__'].split()
dtype = numpy.dtype([(p, site_param_dt[p]) for p in params])
self.array = numpy.zeros(len(dic['sids']), dtype)
for p in dic:
self.array[p] = dic[p][()]
self.complete = self

@property
Expand Down
Loading