-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
I'm beginning more serious work on Pyresample 2.0 in #379 and I'm running into some issues with the interface as I saw it after looking at the legacy nearest neighbor resampler and how it was used. Here's the general structure of a Resampler subclass:
class MyResampler(Resampler):
def __init__(self, src_geom, dst_geom, cache=None):
...
def precompute(self, **kwargs):
...
def compute(self, data, **kwargs):
return new_data
def resample(self, data, **kwargs):
self.precompute(**kwargs)
return self.compute(data, **kwargs)The idea is that users will use create_resampler like this:
resampler = create_resampler(src_geom, dst_geom, resampler="nearest", cache=some_cache)
resampler.precompute(...) # optional to pre-seed any cache
new_data = resampler.resample(data, **kwargs)The issues and questions I'm running into:
- Should custom keyword arguments go in
__init__or in theprecompute? For example, the nearest neighbor resampler currently allows you to customize number of neighbors, radius of influence, and epsilon. Originally I liked the idea of all resamplers having the same__init__interface. It was nice and clean and leaves the work up to 2 methods (precompute/compute). If settings like these are passed to precompute/compute and not__init__then it lets a single resampler instance be used for all combinations of these parameters BUT it also means that the user has to specify these parameters to the methods every time they call them. - What, if anything, should
precomputereturn? Currently these classes are returning acache_idthat has to be passed tocomputeso it can get the proper item from the cache and use it. I think this ID can just be generated multiple times (assuming it is quick) and doesn't have to be returned. And if the cache id isn't returned, then shouldprecomputereturn anything at all? No probably?
Thoughts? We might need a video call for this.