-
Notifications
You must be signed in to change notification settings - Fork 79
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
Padding inside ufunc #447
base: grid_ufunc_refactor_project
Are you sure you want to change the base?
Padding inside ufunc #447
Conversation
class Padder: | ||
""" | ||
Internal class which can pad numpy arrays, or compose a numpy ufunc with a particular padding operation. | ||
|
||
One instance of the Padder class should be used for one padding operation, as its internals store the options chosen | ||
for that particular use. | ||
""" | ||
grid: "Grid" | ||
boundary_width: ... # TODO work out what all these types need to be | ||
boundary: ... | ||
fill_value: ... |
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.
@jbusecke I'm posting this as a WIP so you can see what I'm imagining here
# Compose the ufunc with the padding needed to replace trimmed elements | ||
padder = Padder(grid, boundary_width_real_axes, boundary, fill_value) | ||
pad_then_func = padder.compose_with(func) |
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.
Means that this is all the reference to padding I need to have in apply_as_grid_ufunc
Sketch of how we might refactor the code to pad inside the ufunc, as discussed in #443.
The idea is that all the complexity of composing the the padding operation with the desired ufunc operation is abstracted away into this
Padder
class, makingapply_as_grid_ufunc
as simple as possible to understand.Also adds tests for the bug described in #436.
pre-commit run --all-files
whats-new.rst
api.rst