Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
7eed199
Starting substitution of apfel with eko in evolven3fit
andreab1997 Mar 9, 2022
f16c3c7
Fixing
andreab1997 Mar 9, 2022
a393c47
Separated function to evolve exportgrid
andreab1997 Mar 10, 2022
1662220
removed old evolven3fit
andreab1997 Mar 10, 2022
b3b16fd
Fixed names according to name changed in ekobox
andreab1997 Mar 25, 2022
6a246ed
Revert "removed old evolven3fit"
andreab1997 Mar 25, 2022
28924cc
Removing old evolven3fit
andreab1997 Mar 25, 2022
70e3f83
Added eko and banana to conda-recipe/meta
andreab1997 May 16, 2022
6524bfe
Restored old evolven3fit and changed name
andreab1997 Jul 11, 2022
2a6c40a
Fixed cli, removed files, changed name of command
andreab1997 Jul 12, 2022
f446636
Fixed folder issues
andreab1997 Jul 13, 2022
9abfbfc
allow global and pathlib paths
andreab1997 Jul 13, 2022
b94fd49
Minor changes
andreab1997 Jul 13, 2022
a10da27
Updated eko version
andreab1997 Jul 13, 2022
74062bc
Fixed load_fit
andreab1997 Jul 13, 2022
0d9056a
Fixed info path
andreab1997 Jul 13, 2022
74aeb57
Reworked evolven3fit_API
andreab1997 Jul 14, 2022
214813d
Added some doc
andreab1997 Jul 14, 2022
ee662cd
Added funcs to fix paths
andreab1997 Jul 14, 2022
ca53512
Changed x-grid of eko
andreab1997 Jul 15, 2022
9787fcb
Fixing stuff
andreab1997 Aug 16, 2022
17cec62
Minor fixes
andreab1997 Aug 16, 2022
912f767
Starting substitution of apfel with eko in evolven3fit
andreab1997 Mar 9, 2022
e5775ec
Fixing
andreab1997 Mar 9, 2022
14c9175
Separated function to evolve exportgrid
andreab1997 Mar 10, 2022
713df25
removed old evolven3fit
andreab1997 Mar 10, 2022
50b1165
Fixed names according to name changed in ekobox
andreab1997 Mar 25, 2022
950a967
Revert "removed old evolven3fit"
andreab1997 Mar 25, 2022
8fc0aff
Removing old evolven3fit
andreab1997 Mar 25, 2022
735064e
Added eko and banana to conda-recipe/meta
andreab1997 May 16, 2022
c1fd370
Restored old evolven3fit and changed name
andreab1997 Jul 11, 2022
b2f8c64
Fixed cli, removed files, changed name of command
andreab1997 Jul 12, 2022
8853ebc
Fixed folder issues
andreab1997 Jul 13, 2022
5aa0716
allow global and pathlib paths
andreab1997 Jul 13, 2022
213ffcc
Minor changes
andreab1997 Jul 13, 2022
b4b254f
Updated eko version
andreab1997 Jul 13, 2022
04095cf
Fixed load_fit
andreab1997 Jul 13, 2022
1c652dd
Fixed info path
andreab1997 Jul 13, 2022
18c2d6b
Reworked evolven3fit_API
andreab1997 Jul 14, 2022
94bb090
Added some doc
andreab1997 Jul 14, 2022
4358bf4
Added funcs to fix paths
andreab1997 Jul 14, 2022
f5c7cab
Changed x-grid of eko
andreab1997 Jul 15, 2022
b5ec0b4
Fixing stuff
andreab1997 Aug 16, 2022
d078c8f
Minor fixes
andreab1997 Aug 16, 2022
cf6838d
fixing conflict
andreab1997 Aug 23, 2022
998e2fd
move evolven3fit to n3fit setup
giacomomagni Aug 23, 2022
821c9dc
Converted grids to lists
andreab1997 Aug 23, 2022
0f3de49
update variable number of replicas in info file
giacomomagni Aug 23, 2022
18c65a2
Merge branch 'evolfit_w_eko' of https://github.com/NNPDF/nnpdf into e…
giacomomagni Aug 23, 2022
aad9d75
Added log, dump options and more options
andreab1997 Aug 23, 2022
3354610
Merge branch 'evolfit_w_eko' of github.com:NNPDF/nnpdf into evolfit_w…
andreab1997 Aug 23, 2022
3e8b63a
removed comment
andreab1997 Aug 23, 2022
ddd75a5
Changed default
andreab1997 Aug 23, 2022
7d83c5d
Fixing default cli
andreab1997 Aug 23, 2022
f55265c
Adding ErrorType to info file
giacomomagni Aug 23, 2022
5c5487c
use cubic interpolation and fix xfxQ2
giacomomagni Aug 24, 2022
0ff8287
Merge branch 'master' into evolfit_w_eko
giacomomagni Aug 24, 2022
d919fba
remove evolven3fit log file if exists
giacomomagni Aug 24, 2022
ce1eb03
Fixed test
andreab1997 Aug 24, 2022
5a1a1e8
Removed import in init
andreab1997 Aug 25, 2022
caba20a
Fixed import order
andreab1997 Aug 25, 2022
ea45980
Added docstring
andreab1997 Aug 25, 2022
3f960df
Run black
andreab1997 Aug 25, 2022
2866b46
Added error if log exists
andreab1997 Aug 25, 2022
b56cb35
Use rmdir in place of os
andreab1997 Aug 25, 2022
f4375cd
Using glob to get replica
andreab1997 Aug 25, 2022
7597401
Simplified hasFlavor
andreab1997 Aug 25, 2022
5433721
Raise error if eko path does not exists
andreab1997 Aug 25, 2022
10d096c
Using exist_ok=True
andreab1997 Aug 25, 2022
8bdca5a
Added docstrings and run black
andreab1997 Aug 25, 2022
fdd3a51
Moved docstring to init
andreab1997 Aug 25, 2022
a02cd35
Add more log when saving ad loading ekos
giacomomagni Aug 25, 2022
e5a68be
Removed evolven3fit_API
andreab1997 Aug 25, 2022
d4a57a6
Changed best_epoch in quickcard
andreab1997 Aug 25, 2022
975f373
Update n3fit/src/evolven3fit/utils.py
andreab1997 Aug 25, 2022
d9d84ca
Update n3fit/src/evolven3fit/utils.py
andreab1997 Aug 25, 2022
cdd973f
Remove function mv_file and add docs
andreab1997 Sep 6, 2022
3d47814
Add comment in evolve_fit
andreab1997 Sep 6, 2022
b4ec3dd
Add the possibility to choose q_grid
andreab1997 Sep 6, 2022
69490c2
Added default q grid
andreab1997 Sep 6, 2022
9715d61
Added default x-grid
andreab1997 Sep 6, 2022
98d5192
Fixing yaml safe_load
andreab1997 Sep 6, 2022
aa421a0
Change target x-grid
andreab1997 Sep 6, 2022
5665b1e
Change fitbot
andreab1997 Sep 6, 2022
3484ef3
Use exportgrid as interpolation grid for eko
andreab1997 Sep 6, 2022
d1912f6
Add simple test
andreab1997 Sep 8, 2022
58e6f5a
test on workflow
andreab1997 Sep 8, 2022
59663c6
Test workflow
andreab1997 Sep 8, 2022
58ce979
Fix problem with xmin and xmax
andreab1997 Sep 9, 2022
02c85a8
Test on workflow
andreab1997 Sep 9, 2022
9a4004b
Test workflow
andreab1997 Sep 9, 2022
48dea08
Fix workflow and add more points to q2 grid in matching region
andreab1997 Sep 9, 2022
f9f6c53
Fix test
andreab1997 Sep 9, 2022
5df949d
Add some test
andreab1997 Sep 12, 2022
da1619a
Remove code from init
andreab1997 Sep 14, 2022
dac3851
Move to argparse
andreab1997 Sep 14, 2022
ebb04f3
Improve argparse and give possibility to only construct eko
andreab1997 Sep 14, 2022
eda1f18
Use default x_grid for produce_eko
andreab1997 Sep 14, 2022
8e5dfa6
Change names and fix imports
andreab1997 Sep 14, 2022
7aa5814
Add log to stdout
andreab1997 Sep 14, 2022
bffcc88
Fix imports
andreab1997 Sep 14, 2022
63ee62a
Add pids_dict to pdfbases and use it
andreab1997 Sep 14, 2022
52eadc1
Move fix path functions
andreab1997 Sep 14, 2022
fa1ec3c
Move cli in n3fit.scripts
andreab1997 Sep 14, 2022
afd5d6c
Change name of logger
andreab1997 Sep 14, 2022
efbcb72
Add some doc
andreab1997 Sep 14, 2022
104e7be
Add check of the provided path
andreab1997 Sep 14, 2022
ca625e0
Remove comment
andreab1997 Sep 14, 2022
a3d689e
Remove comment
andreab1997 Sep 14, 2022
bb50d5c
Fix ValueError raised when dumping eko
andreab1997 Sep 14, 2022
679404d
Add error if eko not saved
andreab1997 Sep 14, 2022
197feb8
Add Error if one of q_fin and q_points is not specified
andreab1997 Sep 14, 2022
238cea1
Add comments on test
andreab1997 Sep 14, 2022
63632bb
Substitute lambda function
andreab1997 Sep 14, 2022
0d4d68f
Simplify load_fit func
andreab1997 Sep 14, 2022
d555a4d
removed conda-bld
andreab1997 Sep 15, 2022
ec61e48
Update n3fit/src/evolven3fit/eko_utils.py
andreab1997 Sep 15, 2022
488dc17
Update n3fit/src/evolven3fit/evolve.py
andreab1997 Sep 15, 2022
03520c9
Update n3fit/src/evolven3fit/evolve.py
andreab1997 Sep 15, 2022
3355eaa
Add force option
andreab1997 Sep 15, 2022
b265f1c
Update n3fit/src/evolven3fit/evolve.py
andreab1997 Sep 15, 2022
f2a7313
Remove replica list
andreab1997 Sep 15, 2022
5158a52
Removed info file check
andreab1997 Sep 15, 2022
53c3713
Removed info file check
andreab1997 Sep 15, 2022
32e21d4
Run black
andreab1997 Sep 15, 2022
5a27956
Fix doc
andreab1997 Sep 15, 2022
67b550d
First implementation
andreab1997 Sep 16, 2022
4a4fc40
Remove pdb
andreab1997 Sep 16, 2022
bff4be7
Update n3fit/src/evolven3fit/evolve.py
andreab1997 Sep 16, 2022
fd0e203
Remove function get_eko in core
andreab1997 Sep 16, 2022
6f185ab
Add some tests
andreab1997 Sep 16, 2022
9d355d7
Add test for eko_utils
andreab1997 Sep 19, 2022
aafd779
Add test for eko_utils
andreab1997 Sep 19, 2022
5686f12
Fix tests
andreab1997 Sep 19, 2022
68cbe3f
Merge pull request #1601 from NNPDF/eko_from_theory
andreab1997 Sep 21, 2022
dc39e4c
Change names
andreab1997 Oct 24, 2022
b1f2dff
Add download of theory
andreab1997 Oct 24, 2022
d6233b4
Remove loader
andreab1997 Oct 24, 2022
6099f9f
Make fitbot use old evolven3fit
andreab1997 Oct 24, 2022
4044dd4
Fix fitbot to run with old evolven3fit
andreab1997 Oct 25, 2022
92bd651
Update n3fit/src/evolven3fit_new/utils.py
andreab1997 Oct 25, 2022
146c4a3
Use numpy for isclose
andreab1997 Oct 25, 2022
06909c5
Update n3fit/src/n3fit/scripts/evolven3fit_new.py
andreab1997 Oct 25, 2022
2929e59
Fix again fitbot
andreab1997 Oct 25, 2022
778ba10
Update n3fit/src/n3fit/tests/test_evolven3fit.py
andreab1997 Oct 25, 2022
fa8e5e0
Use API
andreab1997 Oct 25, 2022
37218f6
Remove import of Loader
andreab1997 Oct 25, 2022
eb70131
Fix test
andreab1997 Oct 25, 2022
4281753
Add comment
andreab1997 Oct 26, 2022
c157d2d
Split functions in test
andreab1997 Oct 26, 2022
631077e
Split long line in tests
andreab1997 Oct 26, 2022
895888f
Add comment on test
andreab1997 Oct 26, 2022
836b9a8
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
0d8bdc0
Use variables in test
andreab1997 Oct 26, 2022
c701774
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
573b87f
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
92d11e8
Put default q2grid top level
andreab1997 Oct 26, 2022
2c5267c
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
21c460c
Add comment on matching scales
andreab1997 Oct 26, 2022
c9459c2
Make generate_q2grid more clear
andreab1997 Oct 26, 2022
05cd541
Use Q_ini instead of Q0
andreab1997 Oct 26, 2022
5618a0a
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
b34b008
Remove .keys in iteration over dict
andreab1997 Oct 26, 2022
51758f0
Remove test for LhapdfLike xfxq2
andreab1997 Oct 26, 2022
6a772a4
Add docs for LhapdfLike class
andreab1997 Oct 26, 2022
0e06c29
Specify encoding
andreab1997 Oct 26, 2022
4685982
Join conditions in generate_q2grid
andreab1997 Oct 26, 2022
ca814f0
Add example for fix_info_path
andreab1997 Oct 26, 2022
0cd8ab6
Add example for fix_replica_path
andreab1997 Oct 26, 2022
7cc4d21
Add docs of check_is_fit
andreab1997 Oct 26, 2022
1b4e7c3
Put logfile name top level
andreab1997 Oct 26, 2022
ffb591e
Give None as default for t_card_dict and op_card_dict
andreab1997 Oct 26, 2022
e1a9f5e
Add doc
andreab1997 Oct 26, 2022
b31d6b4
Remove underscore to logger
andreab1997 Oct 26, 2022
4ccc7b8
Move comment to doc of generate_q2grid
andreab1997 Oct 26, 2022
f3e2289
Remove underscores from arguments
andreab1997 Oct 26, 2022
ec7e6e5
Remove optional from help of argument
andreab1997 Oct 26, 2022
fb487fe
Put Xgrid top level
andreab1997 Oct 26, 2022
8a71819
Add comment in construct_eko_for_fit
andreab1997 Oct 27, 2022
9d0a9e4
Fix comment in regressions/filter.yml
andreab1997 Oct 27, 2022
dee3a06
Put logging setting top level
andreab1997 Oct 27, 2022
75563cf
Fix q2_grid generation and add relevant test
andreab1997 Oct 27, 2022
4dff1c6
Use the logging setting inside evolven3fit_new
andreab1997 Oct 27, 2022
c947dfd
Move the definitions of the subcommands to external functions
andreab1997 Oct 27, 2022
c45413d
Add actual cli function inside the package
andreab1997 Oct 27, 2022
2b8dd5a
Change name of log to _logger
andreab1997 Oct 28, 2022
92bc1c8
Catch only FileNotFoundError when loading eko
andreab1997 Oct 28, 2022
7fdbbf8
Revert quickcard2 to master version
alecandido Oct 28, 2022
e2733b9
Fix logs
andreab1997 Nov 7, 2022
86d1440
Remove comment
andreab1997 Nov 7, 2022
2cf6188
Add new line
andreab1997 Nov 7, 2022
7f4d475
Import XGRID from evolven3fit_new.cli for writer
andreab1997 Nov 7, 2022
841c123
Write filter absolute path in error message
andreab1997 Nov 7, 2022
2388e43
Avoid long line in evolven3fit_new
andreab1997 Nov 8, 2022
2eb9fc0
Reformat eko_utils
andreab1997 Nov 8, 2022
f951600
fix help in construct_eko_parser
giacomomagni Nov 9, 2022
d58790a
Remove unused import
andreab1997 Nov 28, 2022
5ca9f26
Fix docstring
andreab1997 Nov 28, 2022
b03b580
Substitute theory_ to t_
andreab1997 Nov 28, 2022
2f46626
Change conf_folder to fit_folder
andreab1997 Nov 28, 2022
7c77b45
Run black on cli.py
andreab1997 Nov 28, 2022
a5b4602
Remove wrong pass
andreab1997 Nov 28, 2022
8429851
Remove unused log
andreab1997 Nov 28, 2022
c317723
Change name of eko_op to _
andreab1997 Dec 1, 2022
649af06
Fix fitbot to use new evolven3fit
andreab1997 Jan 13, 2023
a7fd736
Restore old fitbot
andreab1997 Jan 16, 2023
c0ddad3
fix to the fitbot
scarlehoff Jan 18, 2023
ff57667
Update conda-recipe/meta.yaml
scarlehoff Jan 18, 2023
91a549c
Update plots
andreab1997 Jan 24, 2023
c6c05bc
Update plots again
andreab1997 Jan 24, 2023
0dd4081
Fix conflict for baseline test plots
andreab1997 Feb 1, 2023
3e6c0c8
Take again the plots from master
andreab1997 Feb 1, 2023
6c8de7f
Remove usage of API
andreab1997 Feb 15, 2023
396456a
Restore conda-build in gitgnore
andreab1997 Feb 15, 2023
5d10970
Fix tests
andreab1997 Feb 16, 2023
821987c
Remove one x point from test
andreab1997 Feb 16, 2023
cde7bc7
Merge branch 'master' into evolfit_w_eko
scarlehoff Feb 21, 2023
9b1669e
Update conda_build_config.yaml
scarlehoff Feb 21, 2023
94f63d7
pin the versions of eko and banana in conda
scarlehoff Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ ENV/
env.bak/
venv.bak/

conda-build
conda_bld/

# Spyder project settings
.spyderproject
.spyproject
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#For some reason the resolver decides to use an old version of numpy
#without this
numpy:
- 1.22
- 1.21

pin_run_as_build:
lhapdf: x.x.x
Expand Down
6 changes: 5 additions & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ requirements:
- sphinx_rtd_theme >0.5
- sphinxcontrib-bibtex
- curio >=1.0
- pineappl >=0.5.2
- pineappl >=0.5.8
- eko ==0.10.2
- banana-hep ==0.6.6
- lz4 >=3.1.10 # see https://github.com/conda-forge/eko-feedstock/issues/10


test:
requires:
Expand Down
1 change: 1 addition & 0 deletions n3fit/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

entry_points = {'console_scripts':
['n3fit = n3fit.scripts.n3fit_exec:main',
'evolven3fit_new = n3fit.scripts.evolven3fit_new:main',
Comment thread
scarlehoff marked this conversation as resolved.
'vp-setupfit = n3fit.scripts.vp_setupfit:main',
'varflavors = n3fit.scripts.varflavors:main',
]
Expand Down
Empty file.
244 changes: 244 additions & 0 deletions n3fit/src/evolven3fit_new/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
from . import evolve, utils
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make a universal xgrid (shared with the writer) and defintion of a fit (shared with vp-upload) I would say everything in this file should just be done in the actual script file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember who asked, but I was asked esplicitly to do exactly the opposite (which is why now everything is inside cli.py). For me it is fine to move the second time but please avoid me the third :).

Copy link
Copy Markdown
Contributor

@alecandido alecandido Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is what you refer to, but some time ago, I asked you to write the CLI as a very small wrapper around an API (for Pineko).
The idea is that everything you do in bash, you'd like to be able to control programmatically also from Python (it is useful if you want to automate some tasks). Moreover, it is easier also for testing: if you have a large bunch of code in the CLI only, you have to test it with bash calls, rather than Python ones.

Maybe it is not what you refer to, but in case, this does not apply to this file: there are only two elements, a global value and a single function. The function is only making two calls, and it is not directly defining the CLI itslef, so it is mainly about its documentation. If you are able to put the documentation in another suitable place, it is just redundant, since it is used in a single place. And if you move also the value somewhere else (utils.py? or whatever) you can also get rid of one file :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually referring to your comment of 12 days ago on this PR:

Consider also to move the CLI script definition inside the package (it is more integrated) and just call a package function in the script.

However, again, it is not a problem: I can move again :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also to move the CLI script definition inside the package (it is more integrated) and just call a package function in the script.

Of this I'm still convinced, for the same reasons of Pineko. What I meant here was to reduce all subcommands to a single function call, and keep the script parser only. Being me, I would also define the parsers in the package, since scripts are much more annoying to test and maintain in general - but this is definitely personal preference, in the end is just a ~100 lines script, with only parsers.
But the cli.py only contains a single function, with two calls: if it makes sense as an operation, you can keep and move in another existing module. Otherwise, if it is only a wrapper for two function calls, called that way only once, you can inline in the script, also because the other branch is already not a single function call:

stdout_log = logging.StreamHandler(sys.stdout)
stdout_log.setLevel(evolve.LOGGING_SETTINGS["level"])
stdout_log.setFormatter(
evolve.LOGGING_SETTINGS["formatter"])
for logger_ in (_logger, *[logging.getLogger("eko")]):
logger_.handlers = []
logger_.setLevel(evolve.LOGGING_SETTINGS["level"])
logger_.addHandler(stdout_log)
if args.x_grid_ini is None:
if args.x_grid_points is None:
x_grid = cli.XGRID
else:
raise ValueError(
"x_grid_ini and x_grid_points must be specified either both or none of them"
)
elif args.x_grid_points is None:
raise ValueError(
"x_grid_ini and x_grid_points must be specified either both or none of them"
)

Copy link
Copy Markdown
Contributor

@alecandido alecandido Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Baseline: modularize as much as possible, to organize things, but not too much. If you have a module for a function, and a function with just two calls (called only once), you can probably simplify a bit, grouping with something else.

(However, at some level it becomes personal preference: you'll maintain it, you decide ^^)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure, it was a conscious decision to keep this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end this solution seemed to me good enough: I would not like to put both the xgrid and the function inside the script. If you really have a strong opinion about that for me it is also fine to change, otherwise I would rather keep as it is.


import numpy as np

XGRID = np.array(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xgrid is already defined in writer.py so make sure to define it only once and make both import it from the same point (also, what's up with the indentation)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is done by black. Do you prefer to have it on one single line (as writer.py used to be)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. No if this is what black does by default then that's fine with me. (in fact, I would like to black-ify more of the nnpdf code, just to get a consistent formatting, but lets not start open that discussion again)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely think it is good to be able to see what the default xgrid is from other parts of the code. For that it seems funny to have to import a cli module.

[
1.00000000000000e-09,
1.29708482343957e-09,
1.68242903474257e-09,
2.18225315420583e-09,
2.83056741739819e-09,
3.67148597892941e-09,
4.76222862935315e-09,
6.17701427376180e-09,
8.01211109898438e-09,
1.03923870607245e-08,
1.34798064073805e-08,
1.74844503691778e-08,
2.26788118881103e-08,
2.94163370300835e-08,
3.81554746595878e-08,
4.94908707232129e-08,
6.41938295708371e-08,
8.32647951986859e-08,
1.08001422993829e-07,
1.40086873081130e-07,
1.81704331793772e-07,
2.35685551545377e-07,
3.05703512595323e-07,
3.96522309841747e-07,
5.14321257236570e-07,
6.67115245136676e-07,
8.65299922973143e-07,
1.12235875241487e-06,
1.45577995547683e-06,
1.88824560514613e-06,
2.44917352454946e-06,
3.17671650028717e-06,
4.12035415232797e-06,
5.34425265752090e-06,
6.93161897806315e-06,
8.99034258238145e-06,
1.16603030112258e-05,
1.51228312288769e-05,
1.96129529349212e-05,
2.54352207134502e-05,
3.29841683435992e-05,
4.27707053972016e-05,
5.54561248105849e-05,
7.18958313632514e-05,
9.31954227979614e-05,
1.20782367731330e-04,
1.56497209466554e-04,
2.02708936328495e-04,
2.62459799331951e-04,
3.39645244168985e-04,
4.39234443000422e-04,
5.67535660104533e-04,
7.32507615725537e-04,
9.44112105452451e-04,
1.21469317686978e-03,
1.55935306118224e-03,
1.99627451141338e-03,
2.54691493736552e-03,
3.23597510213126e-03,
4.09103436509565e-03,
5.14175977083962e-03,
6.41865096062317e-03,
7.95137940306351e-03,
9.76689999624100e-03,
1.18876139251364e-02,
1.43298947643919e-02,
1.71032279460271e-02,
2.02100733925079e-02,
2.36463971369542e-02,
2.74026915728357e-02,
3.14652506132444e-02,
3.58174829282429e-02,
4.04411060163317e-02,
4.53171343973807e-02,
5.04266347950069e-02,
5.57512610084339e-02,
6.12736019390519e-02,
6.69773829498255e-02,
7.28475589986517e-02,
7.88703322292727e-02,
8.50331197801452e-02,
9.13244910278679e-02,
9.77340879783772e-02,
1.04252538208639e-01,
1.10871366547237e-01,
1.17582909372878e-01,
1.24380233801599e-01,
1.31257062945031e-01,
1.38207707707289e-01,
1.45227005135651e-01,
1.52310263065985e-01,
1.59453210652156e-01,
1.66651954293987e-01,
1.73902938455578e-01,
1.81202910873333e-01,
1.88548891679097e-01,
1.95938145999193e-01,
2.03368159629765e-01,
2.10836617429103e-01,
2.18341384106561e-01,
2.25880487124065e-01,
2.33452101459503e-01,
2.41054536011681e-01,
2.48686221452762e-01,
2.56345699358723e-01,
2.64031612468684e-01,
2.71742695942783e-01,
2.79477769504149e-01,
2.87235730364833e-01,
2.95015546847664e-01,
3.02816252626866e-01,
3.10636941519503e-01,
3.18476762768082e-01,
3.26334916761672e-01,
3.34210651149156e-01,
3.42103257303627e-01,
3.50012067101685e-01,
3.57936449985571e-01,
3.65875810279643e-01,
3.73829584735962e-01,
3.81797240286494e-01,
3.89778271981947e-01,
3.97772201099286e-01,
4.05778573402340e-01,
4.13796957540671e-01,
4.21826943574548e-01,
4.29868141614175e-01,
4.37920180563205e-01,
4.45982706956990e-01,
4.54055383887562e-01,
4.62137890007651e-01,
4.70229918607142e-01,
4.78331176755675e-01,
4.86441384506059e-01,
4.94560274153348e-01,
5.02687589545177e-01,
5.10823085439086e-01,
5.18966526903235e-01,
5.27117688756998e-01,
5.35276355048428e-01,
5.43442318565661e-01,
5.51615380379768e-01,
5.59795349416641e-01,
5.67982042055800e-01,
5.76175281754088e-01,
5.84374898692498e-01,
5.92580729444440e-01,
6.00792616663950e-01,
6.09010408792398e-01,
6.17233959782450e-01,
6.25463128838069e-01,
6.33697780169485e-01,
6.41937782762089e-01,
6.50183010158361e-01,
6.58433340251944e-01,
6.66688655093089e-01,
6.74948840704708e-01,
6.83213786908386e-01,
6.91483387159697e-01,
6.99757538392251e-01,
7.08036140869916e-01,
7.16319098046733e-01,
7.24606316434025e-01,
7.32897705474271e-01,
7.41193177421404e-01,
7.49492647227008e-01,
7.57796032432224e-01,
7.66103253064927e-01,
7.74414231541921e-01,
7.82728892575836e-01,
7.91047163086478e-01,
7.99368972116378e-01,
8.07694250750291e-01,
8.16022932038457e-01,
8.24354950923382e-01,
8.32690244169987e-01,
8.41028750298844e-01,
8.49370409522600e-01,
8.57715163684985e-01,
8.66062956202683e-01,
8.74413732009721e-01,
8.82767437504206e-01,
8.91124020497459e-01,
8.99483430165226e-01,
9.07845617001021e-01,
9.16210532771399e-01,
9.24578130473112e-01,
9.32948364292029e-01,
9.41321189563734e-01,
9.49696562735755e-01,
9.58074441331298e-01,
9.66454783914439e-01,
9.74837550056705e-01,
9.83222700304978e-01,
9.91610196150662e-01,
1.00000000000000e00,
]
)


def cli_evolven3fit_new(
configuration_folder,
q_fin,
q_points,
op_card_info,
theory_card_info,
dump,
load,
force,
):
"""Evolves the fitted PDFs.

The q_grid starts at the Q0 given by the theory but
the last point is q_fin and its number of
points can be specified by q_points. If just one of the
two is not specified by the user, the default grid
will be used.

If a path is given for the dump option, the eko
will be dumped in that path after the computation.

If a path is given for the load option, the eko
to be used for the evolution will be loaded from that
path.

The two options are mutually exclusive.
"""
utils.check_is_a_fit(configuration_folder)
return evolve.evolve_fit(
configuration_folder,
q_fin,
q_points,
op_card_info,
theory_card_info,
force,
load,
dump,
)
83 changes: 83 additions & 0 deletions n3fit/src/evolven3fit_new/eko_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from ekobox import gen_theory, gen_op
from eko import run_dglap

from validphys.loader import Loader
Comment thread
andreab1997 marked this conversation as resolved.
from . import utils

from typing import Any, Dict, Optional
import logging

_logger = logging.getLogger(__name__)


def construct_eko_cards(
theoryID,
q_fin,
q_points,
x_grid,
op_card_dict: Optional[Dict[str, Any]] = None,
theory_card_dict: Optional[Dict[str, Any]] = None,
):
"""
Return the theory and operator cards used to construct the eko.
theoryID is the ID of the theory for which we are computing the theory and operator card.
q_fin is the final point of the q grid while q_points is the number of points of the grid.
x_grid is the x grid to be used.
op_card_dict and theory_card_dict are optional updates that can be provided respectively to the
operator card and to the theory card.
"""
if theory_card_dict is None:
theory_card_dict = {}
if op_card_dict is None:
op_card_dict = {}
# theory_card construction
theory = Loader().check_theoryID(theoryID).get_description()
theory.pop("FNS")
theory.update(theory_card_dict)
theory_card = gen_theory.gen_theory_card(theory["PTO"], theory["Q0"], update=theory)
# construct operator card
q2_grid = utils.generate_q2grid(
theory["Q0"],
q_fin,
q_points,
{theory["mb"]: theory["kbThr"], theory["mt"]: theory["ktThr"]},
)
op_card = gen_op.gen_op_card(q2_grid, update={"interpolation_xgrid": x_grid})
op_card.update(op_card_dict)
Comment thread
andreab1997 marked this conversation as resolved.
return theory_card, op_card


def construct_eko_for_fit(theory_card, op_card, save_path=None):
"""
Construct the eko operator needed for evolution of fitted pdfs

Parameters
----------
theory_card: dict
theory card to use for the eko
op_card: dict
operator card to use for the eko
save_path: pathlib.Path
path where the eko will be saved (the eko
won't be saved if save_path is None)
Returns
-------
: eko.output.Output
eko operator
"""
# generate eko operator
if save_path is not None:
if not save_path.parent.exists():
raise FileNotFoundError(
f"Path where eko should be dumped does not exist: {save_path}"
)
eko_op = run_dglap(theory_card, op_card)
if save_path is not None:
# Here we want to catch all possible exceptions in order to avoid losing the computed eko
try:
_logger.info(f"Saving computed eko to : {save_path}")
eko_op.dump_tar(save_path)
except:
Comment thread
andreab1997 marked this conversation as resolved.
_logger.error(f"Error saving the eko to : {save_path}")
pass
return eko_op
Loading