New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter_kwargs parameter name collision #165
Comments
.. sorry, just realized that report wasn't terribly precise. The issue is that you can't use |
I'm curious what the context is.
I see. That's no problem, of course. Though maybe we should be extra sure that a collision with the arg name doesn't happen, and call it something like |
The real solution here is to not use **, and keep the target kwargs as a dict. But that breaks backward-compatibility. Otherwise, I'd recommend something that connotes a private name, eg, |
Of course, what I meant was I am curious why you are using
I like your one-underscore solution. |
Oh! The upcoming jams.sonify module does dynamic dispatch to map annotation objects to mir_eval.sonify functions. Since we don't (can't) know the sonification type up front, all sonify parameters live in a kwargs, which needs to be filtered because the sonify functions don't have a common signature. For instance, I have this fragment for making a full-track sonification of all isophonics annotations in one go: y_annotated = y.copy()
for ann in jam.annotations:
try:
print('Trying to sonify {:s}'.format(ann.namespace))
y_ann = jams.sonify.sonify(ann)
y_ann = librosa.util.fix_length(y_ann, len(y_annotated))
y_annotated += y_ann
except jams.NamespaceError:
pass And I'd like to be able to say |
Oh, nice. |
I'm trying to use
util.filter_kwargs
on sonify functions, and hitting a collision with the argumentfunction
.This would be fixed by renaming
filter_kwargs
'sfunction
argument (not a keyword argument) to something unique, likewrapped_function
.This should be a trivial change, and I can PR if it sounds reasonable.
The text was updated successfully, but these errors were encountered: