-
Notifications
You must be signed in to change notification settings - Fork 0
Simplify stitching by retaining prediction objects #20
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
Simplify stitching by retaining prediction objects #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deepsensor/model/model.py
Outdated
| ) - patch_overlap[0] | ||
| else: | ||
| b_x1_max = b_x1_max | ||
| first_key, first_value = next(iter(patch_pred.items())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little wary of this line, is this getting the first item in patch_pred? If so, I think that using next(iter( is a bit clunky, but also because dictionaries aren't guaranteed to be ordered consistently. Could we do this with a particular key? first_value isn't used so it seems like we only need the key here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking more into this, apparently dictionaries are ordered for python 3.7+ so we're safe. But it might be safer to use something like list(patch_pred.keys)[0] if we only need the key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to change it to this. There's always many ways to skin a cat, but I agree your way seems safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for doing this is just because I only need one variable name to work out things like coordinates and extent. So actually it shouldn't matter in this instance if the variable names are different, but good to ensure its consistent just in case.
Co-authored-by: David Wilby <[email protected]>
This PR builds upon #19 by retaining the patchwise predictions as
deepsensor.predictionobjects. This reduces the indentation and number of for loops withinstitch_clipped_predictions(). Because the code uses the.where()function to merge patchwise predictions, there is still a necessity to generate a blank prediction object with the same extent, keys and data variables at the entire extent ofX_t. There may be a shorter way to do this usingprediction.pybut I could not see this.