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

interactive: Add argument for suppressing result output. #712

Closed
wants to merge 1 commit into from

Conversation

josteinbf
Copy link

The flag can typically be used when the output is large, e.g. a numpy
array.

The flag can typically be used when the output is large, e.g. a numpy
array.
@josteinbf
Copy link
Author

How should parameters like these to interactive be documented? I see that clear_output is not documented.

@jdfreder
Copy link
Contributor

Clear output should be documented in the interactive example notebook. What's your use case for this flag?

@josteinbf
Copy link
Author

I did not add the clear output flag, and I do not know what the use case for that flag is. If you are asking about the use case for the output_result flag, see the first comment above.

@jdfreder
Copy link
Contributor

I think the use of interact without output rendering is a little strange because it's not what interact was intended for. Interact was intended to be used to explore the input/output relationship of functions. General UIs are usually constructed "manually" by instantiating the widgets directly. That said, I don't see why this would hurt (other than API bloat / scope creep). I'll differ to @ellisonbg or @SylvainCorlay 's judgement for a 👍 or 👎 .

As an aside, you should be able to accomplish a similar effect by wrapping your function in a lambda that returns nothing.

@SylvainCorlay
Copy link
Member

I am not a good judge at all since not a big fan of the interact way of doing things altogether. Using widgets directly is already very simple.

For a python beginner, interact is too magic: decorator syntax, introspection, widget abbreviation, nontrivial behavior wrt output.

My only objective with interact at the moment is to make it compatible with the API of sage so that sage's migration to ipywidgets is as easy as possible.

@raphaeltimbo
Copy link

I was looking for something like this... I hope it will be merged.
For example, Lorenz Differential Equations.ipynb has a huge array as output and sometimes I only want to see the plot. Delete the line return 'array' in this case is a possibility (all the code in inside the notebook), but sometimes the function that I am using is in a .py file and things become more complicated.

@jdemeyer
Copy link
Contributor

I'm not commenting on whether this is a good idea or not, but if you do implement, it should be an option (see #771).

@jasongrout
Copy link
Member

jasongrout commented Nov 24, 2016

Here's a situation where output isn't wanted:

from ipywidgets import interact

def f(x,y):
    print(x)
    print(y)
    return 'Huge printed output: %s'%(x+y)

interact(f, x=10, y=(1,20))

and here's a solution that uses the functools.wraps method:

from functools import wraps
@interact(x=10, y=(1,20))
@wraps(f)
def myfun(**kwargs):
    f(**kwargs)

I'm on the fence whether we should encourage users to use something like the above workaround, or provide an option. Thoughts from @josteinbf?

Edit: I think we only need **kwargs, not *args, in the wrapping function

@jasongrout
Copy link
Member

I'm going to close this since the wrapping solution above has a smaller API surface and hews more closely to the ideas of the interact decorator.

@jasongrout jasongrout closed this Jun 19, 2017
@jasongrout jasongrout added this to the Reference milestone Nov 17, 2017
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 9, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants