Skip to content
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

add hackability to use_kwargs_dict #279

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marii-moe
Copy link
Contributor

To support the 'val_'+kwargs here: fastai/fastai#3133

Idea is to allow a little bit of hack-ability to use_kwargs_dict instead of writing special delegates function for my one off use case. Maybe not a good idea?

_wrap is reproducing the behavior in delegates, didn't want to change the default behavior of use_kwargs_dict, as I am not very familiar with its usage. _wrap allows the stacking of multiple use_kwargs_dict or delegates when keep=True, otherwise they would error when **kwargs is removed by first delegates`use_kwargs_dict`. (tests should make this more clear).

Mostly looking for guidance here on if this makes sense, or if I should try something else. Here is example usage for easy reference:

@use_kwargs_dict(y=1,z=None)
@use_kwargs_dict(x=2,wrap=True,keep=True)
def foo(a, b=1, **kwargs): pass

test_sig(foo, '(a, b=1, *, x=2, y=1, z=None)')

@use_kwargs_dict(**{ 'val_'+k:v for k,v in get_kwargs_dict(foo).items()})
@use_kwargs_dict(**get_kwargs_dict(foo),wrap=True,keep=True)
def goo(g=4, **kwargs): pass

test_sig(goo, '(g=4, *, b=1, x=2, y=1, z=None, val_b=1, val_x=2, val_y=1, val_z=None)')

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant