You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the work on #154 I am making command-line script functionality available as Python modules. One interesting and troublesome aspect in that respect is that while a command-line script can simply modify global matplotlib settings, that will not work as well in a longer running Python process where the code formerly in scripts might now be invoked again and again.
For instance, we want to use the new cliutils.run functionality to invoke command line scripts in a jupyter notebook in the current process (which incidently allows custom-in-memory files to be used as input for the command line scripts!).
So how do we clean this up? We have to make sure that we never modify global matplotlib rcparams, and we also have to be careful about modifying the matplotlib backends.
So we must have consistent global matplotlib infrastructure for all of NCrystal, and we must use a context manager to switch to the agg backend when we need pdf plots. We should also only every change rcParams with the matplotlib.pyplot.rc_context context manager. See also the discussion at: matplotlib/matplotlib#26362
We should also take the opportunity to make this easier to use during non-graphical unit tests. Some of the functionality from _testimpl.py could be adopted, but also improved.
During the work on #154 I am making command-line script functionality available as Python modules. One interesting and troublesome aspect in that respect is that while a command-line script can simply modify global matplotlib settings, that will not work as well in a longer running Python process where the code formerly in scripts might now be invoked again and again.
For instance, we want to use the new cliutils.run functionality to invoke command line scripts in a jupyter notebook in the current process (which incidently allows custom-in-memory files to be used as input for the command line scripts!).
So how do we clean this up? We have to make sure that we never modify global matplotlib rcparams, and we also have to be careful about modifying the matplotlib backends.
So we must have consistent global matplotlib infrastructure for all of NCrystal, and we must use a context manager to switch to the agg backend when we need pdf plots. We should also only every change rcParams with the matplotlib.pyplot.rc_context context manager. See also the discussion at: matplotlib/matplotlib#26362
Maybe we should also ensure that all of our matplotlib plotting functions simply return standalone Figure() objects?
See also https://matplotlib.org/devdocs/gallery/user_interfaces/web_application_server_sgskip.html
The text was updated successfully, but these errors were encountered: