-
Notifications
You must be signed in to change notification settings - Fork 3
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
Extend fill grid python interface #107
Conversation
I'm doing something ugly in Instead I'd like to:
if possible in a single statement. @cschwan any idea? |
Codecov Report
@@ Coverage Diff @@
## master #107 +/- ##
==========================================
+ Coverage 88.43% 88.58% +0.15%
==========================================
Files 31 31
Lines 3070 3111 +41
==========================================
+ Hits 2715 2756 +41
Misses 355 355
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Note that
fill_with_array
must be able to replace multiplefill
calls, therefore also differentobservable
values must be passed - I'd pass multiple one-dimensional arrays, just like in the old interface https://github.com/N3PDF/pineappl/blob/eb3b58a4b0ccf6339c6ad66c39b3be7c866d7435/wrappers/python/src/pineappl/interface.py#L168-L188 In the old Python interface also
order
andlumi
are arrays, but I believe in those cases multiplefill_array
calls shouldn't be hurtful, so let's not promote them to arrays - I'd also rename
fill_with_array
intofill_array
, that's simpler - @Zaharid might have more specific requests (?), as we're planning to interface it with his N-tuple machinery, where this function will be used.
The interface looks ok to me. I think these would be the requisite primitives. ISTM it would be slightly simpler to pass separate arrays and typically faster since it would typically avoid having to construct a big array somewhere in Python. |
Okay, so I'd say:
In summary, I agree with all your points and I can take care of implementing them, it should take little. |
Hi @cschwan, are you aware of any rust pattern to avoid repeated instances of calls like this:
|
@alecandido I believe that's the correct way to do it. I'm not aware of any 'better' way. |
😞 |
I suppose one could look into the izip macro and extend it, but doesn't seem worth it. |
This for sure... |
I added very basic tests, but unfortunately I can't do more without implementing a wider interface. At the moment, we have a very small API for subgrids (I already pointed out this somewhere else, while I was investigating a grid in the interpreter), and, in particular, we can only set values, but never read. Sooner or later (but not too late, since it's useful for debugging), I'd add methods like |
|
You could copy the example in https://github.com/N3PDF/pineappl/blob/master/examples/python/dyaa.py and make it a test! |
* master: Add numpyfication in python layer, support generic sequences Update docs to numpy arrays usage Fix numpy arrays related tests Port bin to numpy arrays Port fktable to numpy arrays Port import subgrid to numpy arrays Correct `remap` help a bit Support native pathlike objects Convert lists to numpy arrays in grid interface
@alecandido do you think this is ready for merging? If yes, please go ahead! |
Not yet, it's actually missing the test: I dismissed the change request because it was related to P.S.: scheduled today |
Great 👍! This is the last Issue for v0.5.0, after having it fixed we'll release a new Rust version, a new Python pip version, and now I'm having a look at the conda package: https://github.com/conda-forge/pineappl-feedstock. That'd mean we can announce it tomorrow and let people test it. @Zaharid might be interested in it. Will NNPDF/runcards, N3PDF/pineko, NNPDF/fktables be affected by the Python changes? |
This PR is extending the API, and #106 is backward compatible at the end. So maybe #107 is the only one that might break something. However, |
I raise a white flag:
Here I need a bit more of domain knowledge to put some meaningful number, and test something different from 0. So, if you want to play a bit with numbers @cschwan do it, otherwise we can even merge (a test with 0 is not that meaningful, but at least we're testing the grid is not corrupted and can be convoluted...). |
@alecandido thanks again, I think that's sufficient for the time being, everything else we can do in Issue #108. |
This should close #81
I'm not sure that getting as input a 2 dimensional
numpy
array is the best idea ever:https://github.com/N3PDF/pineappl/blob/cf7a8828e73d77a8e4b0c9a05a369617932e95d2/pineappl_py/src/grid.rs#L150-L156
but at the end of the day
NTuple
is a meaningful concept inpineappl
, and it is more or less a named array off64
elements, so it's not that bad.The only other option would be to have 4 matching arrays
x1s
,x2s
,q2s
,weights
: