-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Update dependent cells for functions modifying their arguments #316
Comments
Unfortunately that's not possible to do correctly. But if it were, then this notebook would error, just like a = 1
a
a += 1 Because it creates an ambiguous notebook |
One thing we can do is look for the |
Unfortunately there is (to my knowledge) no way to automatically check which input argument is mutated in Julia. In the following cases, in-place functions should be safe:
|
I didn't think of that - good that you mention it. So in that case, do you think that there is still something special that we can do for |
I suggest the following:
Although point 2. would not capture all potentially problematic cases, it would still capture a large portion of them without raising too many false positives (I have not found a case yet where this would not create a not-well-defined state). What do you think? |
Good ideas |
Some kind of "solution" / workaround for this and #417 would be to add the possibility to manually specify which variables have been updated in a cell. The execution order would be
Possible syntax:
This should give @fonsp what do you think? |
Creative solution! But if I realize this situation, and I am willing to write some extra code, wouldn't it be easier to just combine the definition and modification into one cell? |
Yes, you are right ;-) It would be best if Pluto "automagically" detects which variables have been modified in each cell, independent of the source of modification. This information could then be used for the execution order, if this is uniquely defined (e.g. 1. setting of One possibility to do this would be to fetch all variables in global scope after execution of each cell and calculate their checksum. This is compared to the variable checksums before cell execution (i.e. the result of the previously computed cell). This way, any changes could be detected. Performance should not be an issue for "small" data structures. For large arrays, etc. this may be in issue. Maybe some kind of "cutoff" could be used to track only changes in sufficiently small data structures? |
I am getting a lot of occurrences of this problem and I am not sure if some dependent cells were effectively run and if their results are correct. Meanwhile, I would suggest to add a shortcut to run the whole notebook to make sure that all cells are run with the last changes. |
You can run all cells with |
Currently, dependencies introduced by functions modifying their arguments in-place are not considered for notebook updates.
Example (each row in a separate Pluto cell):
The text was updated successfully, but these errors were encountered: