Skip to content

Dictionary interface for quick access to annotations #112

@bmcfee

Description

@bmcfee

I was chatting with Peter today about some of the more annoying aspects of using jams for simple tasks. For example, to get a single onsets annotation out of the jams object, one has to do something like the following:

>>> anns = jam.search(namespace='onsets')
>>> onset = anns[0]
...

which is rather cumbersome.

I think we can shortcut this a little by providing a read-only dictionary interface to the jams object:

>>> onset = jam['onset'][0]

where the JAMS object under the hood just short-circuits the search for us:

def __getitem__(self, query):
    return self.search(namespace=query)

Would this level of syntactic sugar be helpful?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions