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

Autoexecute ipython notebook cells just like in Mathcad #3164

Open
MySchizoBuddy opened this issue Apr 12, 2013 · 6 comments
Open

Autoexecute ipython notebook cells just like in Mathcad #3164

MySchizoBuddy opened this issue Apr 12, 2013 · 6 comments
Milestone

Comments

@MySchizoBuddy
Copy link

Similar to Mathcad add autorun capability to ipython notebooks.
for eg

In [1]:  x = 1
In [2]:  a = 3
ln [3]:  y = x + 3
         y
Out [3]: 4

If you now alter In [1] and make x = 2, ipython should then autoexecute the In [3] cell because one of it's dependencies has changed, x is no longer 1 and the value of y is now dirty. After re-evaluate In [3] the Out [3] should now show 5. Since In [2] doesn't depend on x it shouldn't be re-evaluated. This will speed up computations in complex and long notebooks.

@takluyver
Copy link
Member

I think we'd only want to provide this if we could be confident it would work really well, because if people think it's automatically updating everything, they may not notice if something isn't up to date.

@ellisonbg
Copy link
Member

I don't think we would implement this in IPython proper, but it shouldn't be difficult to implement this in a javascript notebook extension (custom.js).

@jasongrout
Copy link
Member

This is the main idea behind my new sage "interact" implementation: snippets of code that track dependencies and automatically update when a dependency is changed.

@MySchizoBuddy
Copy link
Author

@takluyver The implementation will always keep the notebook uptodate. if not then it is a buggy implementation.
In the current way where you have to manually execute the entire notebook is more error prone. You might make a change and forget to re-execute the notebook. That is a much worse situation.

@jasongrout can the sage interact feature be backported to ipython?

@takluyver
Copy link
Member

Yes, I mean that a buggy implementation would be worse than not having this, because people would try to rely on it. And I think that a bug-free implementation would be quite hard to do, because Python is so flexible. For instance:

a = []
options = {'a': a.append, 'b': lambda x: None}


f = open('some_file')
opt = f.read()
options[opt](f.read())

print a

Now you have to track a dictionary holding a method which holds a bound reference to a. You don't know without examining the file whether the middle section will modify a. You could assume it always modifies everything the dictionary holds a reference to, but if there are long calculations downstream, that could get very wasteful. And this is a simple example - there's much more complexity I could bring in, especially if I got onto dynamic code (exec and eval).

@benelot
Copy link

benelot commented Jan 13, 2018

How about making the dependencies explicit? I mean if I can mark cell A being dependent on B then I can automatically trigger A if B is changed. I am currently thinking about a similar thing meaning that the extension I am looking for could check before the execution of A if B was already executed/triggers B before A. That might make the case much easier.

P.S. Oh I did not see that this was 5 years ago.

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

5 participants