-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
WIP: Facilitate the creation of combined plots #777
base: main
Are you sure you want to change the base?
Conversation
When we agree, I will change the docs that show how to combine plots. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #777 +/- ##
==========================================
- Coverage 87.30% 87.29% -0.02%
==========================================
Files 394 394
Lines 50409 50417 +8
==========================================
Hits 44011 44011
- Misses 6398 6406 +8 ☔ View full report in Codecov by Sentry. |
I think most people will use grouped plots to combine different types of plots (i.e. not just a variable). For instance, geometry plots + PDOS scaling of atomic sizes, vs. a fat-bands-plot to the right. Would the I think the Is there an easy way to query whether a plot is a |
Yes, makes sense. In that case batches are not the right tool. You just build a list of plots and merge them (as it is done until now). Batches just help in getting the result of a workflow for multiple inputs while sharing the common parts of the computation. I.e. they don't help if you want to execute different workflows. There are some typical cases where one might want to batch an input. For example, plotting multiple wavefunctions: from nodify import Batch
H.plot.wavefunction(i=Batch(4, 5, 6, 9)) will create plots for the 4 wavefunctions doing one single diagonalization.
Makes sense. Something like |
Another example: from nodify import Batch, temporal_context
with temporal_context(batch_iter="product"):
H.plot.wavefunction(i=Batch(4, 5, 6, 9), represent=Batch("real", "imag")) would generate 8 plots with 1 diagonalization and 4 grid projections. |
what does Also, could one create product batches and zip batches. I.e. batch1 = Batch(1,2)
batch2 = Batch(2,3)
batch3 = Batch(*range(4))
with nodify_context(batch_iter={(batch1, batch2): "product", "*": "zip"}) probably bad names here, something that binds them together? |
Hmm interesting, so from nodify import context
with context(batch_iter="product"):
...
#or
import nodify
with nodify.context(batch_iter="product"):
...
I don't want to complicate things for now. I always keep in mind that these things should be modifiable from the GUI 😅 I thought about it but then I realised that programatically one could always create complicated combinations and then zip the batches. E.g.: batch1 = Batch(1,1,2, 2)
batch2 = Batch(2,3,2,3)
batch3 = Batch(*range(4))
# Now when batches are zipped it will result in the same situation as what you were proposing |
I don't see the final comment in your post? Maybe it got truncated, or something? |
You mean after the comment? No I didn't write anything, it's just that if you zip those three batches you end up with the same as what you were proposing. |
Since #340, there was the discussion of how to make the API for multiple plots as convenient as possible. This PR attempts to solve it.
In
nodify
, I introduced the concept of aBatch
. If you pass aBatch
as an input of a workflow, the workflow will also return aBatch
. The most important thing is that only the parts of the workflow that depend on the batch are computed for each item, the rest are shared, saving time and memory.This is automatically applicable to the plots, since they are workflows:
g_plot.get()
will now return a batch, which contains the three figures.Now the question is what is the best interface for sisl users. In this PR I have changed slightly the functions that merge plots so that they can support batches. Now one can do for example:
One can also change the way in which batches interact with each other. This is defined by the node's context. In this case they were zipped, but one could ask to take the product as well:
I have decided that the user must use the merging functions, and
g_plot.show()
does not show anything, since there is no indication of how the user wants to merge the plots. Also if we were to automatically merge them it would not work in cases like:Where the backends are different. In that case one can do:
Do you think this is fine? Is there something that you would change to make it more convenient to use?
Thanks!