Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

New Resampler interface design and discussion

Aperta
#381 1 commento 0 reazioni 4 assegnatari Vedi su GitHub

@pnuu ci sta già lavorando.

Dal 28/9/2021.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

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:

  1. Should custom keyword arguments go in __init__ or in the precompute? 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.
  2. What, if anything, should precompute return? Currently these classes are returning a cache_id that has to be passed to compute so 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 should precompute return anything at all? No probably?

Thoughts? We might need a video call for this.

Lingua principale
Python
Stelle
388
Fork
103
Merge medio
7g 4h
PR unite (30g)
4

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytroll/pyresample

Tutte le issue di pytroll/pyresample

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.