Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI random failures #275

Merged
Merged
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
22 changes: 10 additions & 12 deletions wecopttool/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2401,18 +2401,16 @@ def subset_close(
raise ValueError("Elements in set_b not unique")

ind = []
tmp_result = [False for _ in range(len(set_a))]
for subset_element in set_a:
for set_element in set_b:
if np.isclose(subset_element, set_element, rtol, atol, equal_nan):
tmp_set_ind = np.where(
np.isclose(set_element, set_b , rtol, atol, equal_nan))
tmp_subset_ind = np.where(
np.isclose(subset_element, set_a , rtol, atol,
equal_nan))
ind.append( int(tmp_set_ind[0]) )
tmp_result[ int(tmp_subset_ind[0]) ] = True
subset = all(tmp_result)
for el in set_a:
a_in_b = np.isclose(set_b, el,
rtol=rtol, atol=atol, equal_nan=equal_nan)
if np.sum(a_in_b) == 1:
ind.append(np.flatnonzero(a_in_b)[0])
if np.sum(a_in_b) > 1:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subset_close is only ever used to confirm the wave elevation directions are all included in the list of excitation coefficient directions, so I figured taking the nearest value is the best solution. I highly doubt this ever becomes an issue if using the normal WecOptTool workflow, but I think it's good to have.

_log.warning('Multiple matching elements in subset, ' +
'selecting closest match.')
ind.append(np.argmin(np.abs(a_in_b - el)))
subset = len(set_a) == len(ind)
ind = ind if subset else []
return subset, ind

Expand Down
Loading