nbval icon indicating copy to clipboard operation
nbval copied to clipboard

Is sharing state between cells and expected and testable use case?

Open jonathanstathakis opened this issue 1 year ago • 1 comments

As title. I very often work with notebooks which first generate a dataset then proceed to analyse it across a number of interdependent cells. I would assume that most users would have a similar pattern. I have however found that testing a notebook fails unless I import all cell dependencies into each cell, which to me is an anti-pattern.

Am I missing a configuration which allows me to use the notebook global scope within each cell/test? I admit I am not an expert at the inner workings of ipython notebooks.

jonathanstathakis avatar Dec 04 '24 04:12 jonathanstathakis

Do you have a small example you can share to illustrate this? The global variables are meant to persist from one cell to the next by default, it shouldn't need any configuration.

On Wed, 4 Dec 2024, 04:46 jstathakis, @.***> wrote:

As title. I very often work with notebooks which first generate a dataset then proceed to analyse it across a number of interdependent cells. I would assume that most users would have a similar pattern. I have however found that testing a notebook fails unless I import all cell dependencies into each cell, which to me is an anti-pattern.

Am I missing a configuration which allows me to use the notebook global scope within each cell/test? I admit I am not an expert at the inner workings of ipython notebooks.

— Reply to this email directly, view it on GitHub https://github.com/computationalmodelling/nbval/issues/214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQB5NIQT3QTJFSRK6ZQ232D2CJXAVCNFSM6AAAAABS7HJAROVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4YTMNJVGA3TKMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

takluyver avatar Dec 04 '24 08:12 takluyver