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

Interact should accept tuple of min, max, and value as input #333

Closed
jsignell opened this issue Mar 25, 2019 · 4 comments
Closed

Interact should accept tuple of min, max, and value as input #333

jsignell opened this issue Mar 25, 2019 · 4 comments

Comments

@jsignell
Copy link
Member

At the moment interact only supports passing value OR (min, max). It would be very helpful to be able to pass all three. For context - this came up in the context of making widgets from intake user parameters which have default values in addition to min, and max.

@jbednar
Copy link
Member

jbednar commented Mar 25, 2019

Definitely. PR?

@jsignell
Copy link
Member Author

The problem is that a tuple of three currently means (min, max, step) so either the value could be the 4th item, or the meaning of a 3 tuple would change.

@jbednar
Copy link
Member

jbednar commented Mar 25, 2019

It would need to be the 4th item, then.

@jsignell
Copy link
Member Author

jsignell commented Mar 25, 2019

For clarity - it would work just as well for my use case if there were a way to set function defaults from a dict.

This works as expected:

@interact(year=(2017, 2018), month=(1, 12), day=(1, 31))
def day(year=2018, month=1, day=1):
    return cat.anaconda_package_data_by_day(**locals())

But I need to set the interact kwargs with

ranges = {}
defaults = {}
for up in cat.anaconda_package_data_by_day._user_parameters:
    ranges[up.name] = (up.min, up.max)
    defaults[up.name] = up.default
print(ranges, defaults)
({'year': (2017, 2018), 'month': (1, 12), 'day': (1, 31)},
 {'year': 2018, 'month': 12, 'day': 1})

The issue is that those default values are in a dict and I don't know how to extract them into the function definition.

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

No branches or pull requests

2 participants