FastTrackiverse / fasttrackpy

A fasttrack implementation in python
https://fasttrackiverse.github.io/fasttrackpy/
MIT License
9 stars 0 forks source link

`CandidateTracks` should be indexable, iterable #67

Closed JoFrhwld closed 3 months ago

JoFrhwld commented 6 months ago

The goal

My own user expectation is that if we have a CandidateTracks object called tracks, then tracks[0] would return the first value in tracks.candidates. Similarly, I'd expect

[x.maximum_formant for x in tracks]

To return an equivalent list to

[x.maximum_formant for x in tracks.candidates]

How to do it

This will involve implementing the following dunder methods for CandidateTracks

JoFrhwld commented 5 months ago

Actually, subclassing it with collections.abc.Sequence could get us most of the way there. Just need to define:

def __getitem__(self, i):
  return self.candidates[i]

def __len__(self):
  return len(self.candidates)