You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's annoying that we need to specify a return_type when we call examples, and that if we don't, we get the path by default; usually I just want a Sound instead
this also makes extra work when I want a larger example dataset (which is still not a full dataset, so I think we should resist a scikit-learn-like datasets API, at least for now. Make pollyglot an extra at some point, maybe) -- I have to specify the type and then make additional call to examples to get multiple "types", e.g. the Sounds and the Annotations
I think we should do the following:
for built-in examples that are a sound file, just return a Sound
if we add other types of examples later, just return the type by default too; e.g., Spectrogram or Annotation
change the return_type to a Boolean return_path argument that if True returns the path (the way we do now by default) -- but have it default to False
for larger example datasets, have a scikit-learn-style Bunch that we return with keys for "sounds", "annotations", etc. The idea here is that we get everything for the example dataset in one fell swoop, and we also don't prescribe via strict attribute names or something what exactly is in the dataset; I can imagine scenarios, say datasets from behavioral experiments, where we might want to return stuff that's not strictly a built-in VocalPy-specific type. The reason to have a Bunch is so that we can have dotted attribute acces like the sklearn Bunch does (via the __getattr__ dunder)
I think I should further refactor to do what I did when I rewrote crowsetta.data as crowsetta.examples:
have an Example dataclass that is basically what we call ExampleMetadata now; this will be internal to the _example module but it makes it clear that what we are representing with the class is a specific example
We should also put all the metadata in a static json file, and (again as in crowsetta) add a classmethod from_metadata that makes an Example instance from the metadata in the json; i.e. there will be a json file that is a list ("array") of dicts ("objects"), and we will get an Example for each "object"
and have a separate text file with a description, which is what we now call metadata as a field on the ExampleMeta class (confusingly)
and then load all the Examples inside the module and have the REGISTRY just be a mapping from Example.name to Example (for each instance)
Activity
Refactor examples API, fix #185
NickleDave commentedon Oct 13, 2024
I think I should further refactor to do what I did when I rewrote
crowsetta.dataascrowsetta.examples:Exampledataclass that is basically what we callExampleMetadatanow; this will be internal to the_examplemodule but it makes it clear that what we are representing with the class is a specific examplefrom_metadatathat makes anExampleinstance from the metadata in the json; i.e. there will be a json file that is a list ("array") of dicts ("objects"), and we will get anExamplefor each "object"metadataas a field on theExampleMetaclass (confusingly)Examples inside the module and have theREGISTRYjust be a mapping fromExample.nametoExample(for each instance)Refactor examples API, fix #185
Refactor code for example data to be like crowsetta.examples, fix #185
ENH/CLN: Post-NMAC 2024 GRS fixes (#189)