Skip to content

Commit

Permalink
Simplify code to check if hdf5 group exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sfield17 committed Jan 12, 2025
1 parent d52e77b commit 38388a9
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions gwsurrogate/new/precessing_surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,19 +792,13 @@ def _eval_comp(self, data, q, chiA, chiB):
nodes.append(_eval_scalar_fit(fit_data, fit_params, self._get_fit_settings))

return np.array(nodes).dot(data['EI_basis'])

def _check_h5group_exists(self, h5file, group_name):
""" Check if h5 group GROUP_NAME has valid data to load. """

try:
group_keys = h5file[group_name].keys()
if len(group_keys) == 0: # no data in group
return False
else:
return True
except KeyError: # cannot open group -- doesn't exist
return False

def _check_h5group_exists(self, h5file, group_name):
""" Check if h5 group GROUP_NAME has valid data to load.
Returns true or False """

return group_name in h5file


##############################################################################
Expand Down

0 comments on commit 38388a9

Please sign in to comment.