pya icon indicating copy to clipboard operation
pya copied to clipboard

Asig metadata

Open thomas-hermann opened this issue 5 years ago • 4 comments

For Arecorder.record(), it would be useful to store the time stamps when recordings were made. One way would be to change recordings.append((timestamp, asig)), but that would make access and interpretation less intuitive. So that lead me to the idea of Asig.metadata:

I propose to add an attribute Asig.metadata, which could be a dict with fields such as

  • timestamp,
  • author,
  • recording_device,
  • history (which could be a list itself and store those things currently appended to label)
  • etc. (ideas?)

By the way, Asig.label would be a perfect item in the meta data dict!

Before such a far-reaching change, I'd like to hear your feedback and ideas on this issue.

Note that we already have a context variable named '_' (yes, funny name, but short and nice, e.g. to access results of a1.find_events().plot() via a1._['events'] and self._['plot']. This is convenient for returning auxilliary data without breaking the logic of returning self always.

Hand in hand with that, I feel that the currently often used strategy to return a new Asig with new data

return Asig(newsig, self.sr, self.label, self.cn,...)

is suboptimal as it often fails to copy '_' and would, if metadata should be implemented, become even more complex. So probably a static method Asig._copy() for devs, which generally duplicates self w/o copying sig would help, so instead we could simply write

return Asig._copy(self, newsig, attr_to_overwrite=new_value,...)

Looking forward to hear your thoughts on both issues.

thomas-hermann avatar Oct 05 '19 18:10 thomas-hermann