alecandido / partons

1 stars 0 forks source link

Add minimal API #13

Open cschwan opened 1 year ago

cschwan commented 1 year ago

Commit c5f4b29a3da816cb7d534352f66d6e84afb98d81 adds a minimal API, as outlined in #12, which I copied from the lhapdf crate. There are a few things to do:

cschwan commented 1 year ago

@AleCandido @scarlehoff you can add more backends now. To do that copy the file partons/src/noop.rs, give it a different name and fill the methods with meaningful implementations. Finally you'll need to add the corresponding lines in partons/src/frontend.rs here:

https://github.com/AleCandido/partons/blob/de8f95d2cb3066588008f2faf054b7d05de1b55a/partons/src/frontend.rs#L36-L39

and here

https://github.com/AleCandido/partons/blob/de8f95d2cb3066588008f2faf054b7d05de1b55a/partons/src/frontend.rs#L68-L71

The functions PdfSet::new and PdfSetEnum::new should then select between the different backends depending on the selected set or PDF (still TBD).

alecandido commented 1 year ago

Given the interest, I will soon restart working on automatic fetching and caching.

I was about to propose you the noop.rs as well, and to move there the former fake_lhapdf.hpp. But I see you don't need any suggestion :D Thanks for this part, it looks perfect to me :)

cschwan commented 1 year ago

I'm a little bit unhappy about partons/src/fake_lhapdf.rs, which is a copy of noop.rs and nothing else, but it's necessary because every struct implementing Pdf or PdfSet must be a different type; I can live with it.

We should decide how the backend selection works, which right now is very dumb for Pdf

https://github.com/AleCandido/partons/blob/dc585d3a5d58ffdbfd0ace911b6b514d59adcd3a/partons/src/frontend.rs#L57-L60

and PdfSet:

https://github.com/AleCandido/partons/blob/dc585d3a5d58ffdbfd0ace911b6b514d59adcd3a/partons/src/frontend.rs#L87-L90

One easy way would be to

Another option is to have different backends name PDF sets differently, but I don't like it that much.

alecandido commented 1 year ago

use the 'default' backend if the prefix is missing. This could be our internal backend.

Apply a default is perfectly fine. To select the others, I would pass an optional argument, i.e. Option<BackendsEnum> in Rust (in Python it can really be optional).

Since I already added a configuration file, we can add an option also there to select a different backend. But I would do at a later stage.