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

avoid infinite loop in gapfill strategy #12

Draft
wants to merge 1 commit into
base: patchwise_train
Choose a base branch
from

Conversation

davidwilby
Copy link
Owner

I think that this should be equivalent behaviour, but with raising an error rather than going into an infinite loop.

I'm finding it quite confusing trying to replicate the previous behaviour.

Basically instead of continuing to sample dates, here I generate a randomly ordered list of the dates and iterate through until a suitable sample is found, raising an error if we don't find one by the end of the list.

Copy link
Collaborator

@MartinSJRogers MartinSJRogers left a comment

Choose a reason for hiding this comment

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

Think this is all good. One minor comment for clarificiation

if np.all(target_mask_data == False):
if i == len(added_mask_dates):
# if the last date in the list has been reached and no suitable mask is found
raise ValueError("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be content within the "" here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

There should indeed, I don't think I understand enough to write an informative error message here, can you suggest one?

while keep_searching:
added_mask_date = rng.choice(self.context[context_idx].time)
# Iterate through a randomly ordered list of dates
added_mask_dates = rng.choice(self.context[context_idx].time,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a sensible approach to me- happy with this amendment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants