-
Notifications
You must be signed in to change notification settings - Fork 0
Provide some tests #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
168 commits
Select commit
Hold shift + click to select a range
241345d
Added first test of configs
andreab1997 04bc966
Added other tests of configs
andreab1997 101f63f
Completed config tests
andreab1997 d778955
Fixing
andreab1997 2fd0bd9
Added pineko.toml file for testing
andreab1997 44f8bf5
Added tests for theory_card
andreab1997 e4b3a1b
Added tests for check
andreab1997 f0e22e4
Init evolve test
andreab1997 e86e5ed
Completed evolve tests
andreab1997 0eca8f5
Init test theory
andreab1997 204c6b2
Other theory tests
andreab1997 50af20e
Completed test for theory
andreab1997 968673d
Added necessary files
andreab1997 b0f2703
Added file
andreab1997 2752533
Added dir
andreab1997 01e5019
Remove stuff
andreab1997 f8dbaae
Added some cli tests
andreab1997 e4ef2f7
First attempt to SV
felixhekhorn 4cc5c88
Update pre-commit
felixhekhorn 319a79a
Run pre-commit
felixhekhorn b41a20e
Pass alpha_s around
felixhekhorn ea6fe0d
Propagate scales around
felixhekhorn a08884c
Fix compare call. Save before compare
felixhekhorn aa29f5c
Fix bug in as computation
felixhekhorn da496a5
Pass more xiev around
felixhekhorn ec5e243
Remove xiev
felixhekhorn 3129554
Init pydocstyle and update pre-commit
felixhekhorn 710f976
Appease pydocstyle
felixhekhorn 4869ca0
Fix assumptions hash computation
felixhekhorn 2a10743
Revert assuptions fix
felixhekhorn 271eea2
Play with SV
felixhekhorn d088c6c
Improve sv script
felixhekhorn c6c4472
Save debug script
felixhekhorn 2aceb26
Backup more debug stuff
felixhekhorn a33dd4c
Upgrade PineAPPL to v0.5.4
alecandido 6119584
Splitted funcs, put if in theory and change cli
andreab1997 6f32da0
Fixing
andreab1997 da639bf
Fixing
andreab1997 bd16255
Put scalevar parameters as arguments
andreab1997 90aeace
Fixed init of cli
andreab1997 4ec986a
Added SV check as default when computing fks
andreab1997 42dd75b
Splitted funcs, put if in theory and change cli
andreab1997 9a08100
Change argument of the function and put tocheck as argument
andreab1997 ca1dcff
put the grid as argument of evolve
andreab1997 3ae9f29
Run pre-commit
andreab1997 01710dc
Removed redundant def of xir and xif
andreab1997 3aedd43
Fixed import of pineappl
andreab1997 78a1d67
Fixed import of pineappl
andreab1997 9b9b9ed
Splitted funcs, put if in theory and change cli
andreab1997 0a24150
Fixing
andreab1997 b3517e1
First implementation
andreab1997 cfcdf11
Fixing
andreab1997 a1f3cab
Put scalevar parameters as arguments
andreab1997 c076e79
Fixed init of cli
andreab1997 237269f
Added SV check as default when computing fks
andreab1997 c88a95c
Fixing
andreab1997 bd22d00
Splitted funcs, put if in theory and change cli
andreab1997 ab248fd
Fixing
andreab1997 059fad8
Change argument of the function and put tocheck as argument
andreab1997 0b0549d
put the grid as argument of evolve
andreab1997 7bcff1e
Run pre-commit
andreab1997 73b1d87
Fixed import of pineappl
andreab1997 228a89f
Minor changes
andreab1997 5b0f976
Change names of funcs
andreab1997 53efcc5
Fixed theory
andreab1997 e8aa039
Remove debug scripts
felixhekhorn aff171b
Changed eko args in evolve_grid
andreab1997 dc1e73d
fixed names of import and runned pre-commit
andreab1997 22ad61e
Changed eko args in evolve_grid
andreab1997 e10d1fd
fixed names of import and runned pre-commit
andreab1997 53e520e
Fixing
andreab1997 65ae229
First draft of implementation
andreab1997 4551808
Added check on lumi
andreab1997 6ef0034
Removed pdb
andreab1997 b066450
Fixing
andreab1997 2d3c344
Changed name
andreab1997 697d987
Added relevant test
andreab1997 e8df738
Fixed conflict
andreab1997 991c4f3
Update src/pineko/evolve.py
felixhekhorn 6e495db
Update src/pineko/theory.py
felixhekhorn c5e90d2
Rename xi to xif
felixhekhorn 1492378
Narrow opcard args in theory
felixhekhorn 99c6b55
Added relevant tests
andreab1997 e0ac356
Refactor check subcommand
alecandido 7752c32
Improve functions' names consistency
alecandido 6e5e85d
Removed isDIS
andreab1997 076d22a
Changed grid name
andreab1997 28c4e90
Update src/pineko/check.py
andreab1997 d5a66a0
Fix missing not
alecandido f945ac0
Fixed bug
andreab1997 730c344
Added first element in check and updated test
andreab1997 09ca0b1
slitted func islepton and updated tests
andreab1997 61ed41e
Updated test
andreab1997 bd7fc92
Updating tests
andreab1997 3443598
Fixed checks and tests
andreab1997 9882041
Fixed func and updated test
andreab1997 1410ac3
Refactor check to include order_mask and sv for QED
andreab1997 e749f9c
Added some docs
andreab1997 f661681
Fixing docs
andreab1997 5a8c6cf
Fixing url of logo
andreab1997 f1020c8
Update README.md
andreab1997 e97b5c4
Update pre-commit
felixhekhorn 6844ec3
Anger black
felixhekhorn 42c8e70
Reconcile black
felixhekhorn 7ae14e2
Restore docstrings for module level variables
alecandido c6416af
Drop check-docstring-first due to https://github.com/pre-commit/pre-c…
felixhekhorn 20eadd8
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] d3a8b66
Fixed integrability opcards
andreab1997 cbaef67
Fixing
andreab1997 18f6c1f
Fixing again
andreab1997 dfa1265
Copying x_grid rather than assigning
andreab1997 370c59a
explicitly casting the list
andreab1997 a612ba4
Recognize integrability from grid
andreab1997 b090b83
Removed int argument from func
andreab1997 5b38cff
Removed wrong docs
andreab1997 81f05cb
Removed function is_integrability
andreab1997 007a46a
Run poetry update
felixhekhorn 58c122d
Update eko and pineappl
felixhekhorn 584c7ab
Fix eko syntax
felixhekhorn b7f4deb
Add eko compatibility layer
felixhekhorn 866fc5b
Add version information
felixhekhorn f496232
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] f22c86f
Removed wrong test on factorization scale for schemeB
andreab1997 fa6dc70
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] 12a5053
Added tests for check
andreab1997 579dc54
Merge branch 'main' into testing
andreab1997 e6bfb37
Fix test_check
andreab1997 ed4c3a4
Fix test_cli
andreab1997 52d5195
Fix test_evolve
andreab1997 ff73e6b
Fix test_theory_card
andreab1997 4b8d284
Fix test_theory
andreab1997 688e4cc
Run black
andreab1997 278e0fe
Remove useless import
andreab1997 ba323a8
Separe benchmarks from tests
andreab1997 6674dba
Fix .toml
andreab1997 7aa598b
Fix theory_bench and change workflow for bench
andreab1997 ff630b6
Change names of benchmarks
andreab1997 c02328e
TEST: remove theory_bench
andreab1997 c089af1
Restore theory_bench and pineko.toml
andreab1997 e3ca4e9
Change name of benchmarks
andreab1997 3f468fd
Fix bench
andreab1997 6d56fdd
Add test for islepton
andreab1997 7784436
Add test on exception of check
andreab1997 5137572
Add test for check cli
andreab1997 035e504
Add test for comparator
andreab1997 c1e95d2
Change Fk to check in benchmark
andreab1997 949018f
Add fakepdf and test for compare cli
andreab1997 f064fa5
Remove banana
andreab1997 333e3d6
Fix path of fakepdf
andreab1997 e877f65
Fix test_pdf path
andreab1997 c6004b5
Remove useless members of pdf
andreab1997 0c3edc2
Change name of evolve benchmark
andreab1997 28158aa
Make folders explicit
andreab1997 70ef0ce
Make folders explicit again
andreab1997 aa49853
Make folders explicit in theory_bench
andreab1997 5e0fd12
Update pyproject.toml
andreab1997 9572d93
Update workflow to cache poetry virtualenv
andreab1997 435d020
Try to fix workflow
andreab1997 ec5f792
Try to install project only, when cache is used
alecandido fa63bd1
Revert "Try to install project only, when cache is used
"
alecandido 0ab1126
Ignore local config
felixhekhorn 3654d7b
Fix unused imports
felixhekhorn 375ddbb
Make lhapdf_path a fixture
andreab1997 0b91ba8
Make test_files and test_pdf fixtures
andreab1997 1774ae5
Change names of benchmarks
andreab1997 f52eeff
Update benchmarks/bench_theory.py
andreab1997 554f3a4
Change name of theory_obj_hera
andreab1997 584e653
Use pytest fixtures
andreab1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: benchmarks | ||
|
|
||
| on: push | ||
|
|
||
| jobs: | ||
| bench: | ||
| name: Benchmarks | ||
| runs-on: ubuntu-latest | ||
|
|
||
| container: | ||
| image: ghcr.io/n3pdf/bench-evol:latest | ||
| credentials: | ||
| username: ${{ github.repository_owner }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| # tags needed for dynamic versioning | ||
| fetch-depth: 0 | ||
| - name: Install and configure Poetry | ||
| run: | | ||
| curl -sSL https://install.python-poetry.org | python3 - | ||
| # update path for this and the other steps | ||
| export PATH=$HOME/.local/bin:$PATH | ||
| echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
| # prevent poetry environments | ||
| # in order to access container pre-installed packages | ||
| poetry config virtualenvs.create false | ||
| # log all configurations | ||
| poetry config --list | ||
| - name: Cache Poetry virtualenv | ||
| uses: actions/cache@v2 | ||
| id: cache | ||
| with: | ||
| path: ~/.virtualenvs | ||
| key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }} | ||
| - name: Install version management tool | ||
| run: | | ||
| # same poetry env | ||
| PIP="$(head -n1 $(which poetry) | cut -c 3-) -m pip" | ||
| ${PIP} install poetry-dynamic-versioning | ||
| - name: Install dependencies | ||
| run: poetry install --no-interaction --no-root | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| - name: Install project | ||
| run: | | ||
| poetry install --no-interaction ${{ inputs.poetry-extras }} | ||
|
alecandido marked this conversation as resolved.
|
||
| - name: Install task runner | ||
| run: pip install poethepoet | ||
| - name: Lint with pylint | ||
| run: | | ||
| # Search for actual errors | ||
| poe lint | ||
| # For warnings instead return always zero | ||
| poe lint-warnings | ||
| - name: Test with pytest | ||
| run: | | ||
| poe bench | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v2 | ||
| with: | ||
| files: ./coverage.xml | ||
| flags: bench | ||
| name: codecov-umbrella | ||
| fail_ci_if_error: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import pathlib | ||
|
|
||
| import eko | ||
| import numpy as np | ||
| import pineappl | ||
| import pytest | ||
|
|
||
| import pineko.check | ||
|
|
||
|
|
||
| def benchmark_check_grid_and_eko_compatible(test_files): | ||
| grid = pineappl.grid.Grid.read( | ||
| test_files / "data/grids/208/HERA_CC_318GEV_EM_SIGMARED.pineappl.lz4" | ||
| ) | ||
| wrong_grid = pineappl.grid.Grid.read( | ||
| test_files / "data/grids/208/NUTEV_CC_NU_FE_SIGMARED.pineappl.lz4" | ||
| ) | ||
| ekoop = eko.output.Output.load_tar( | ||
| test_files / "data/ekos/208/HERA_CC_318GEV_EM_SIGMARED.tar" | ||
| ) | ||
| with pytest.raises(ValueError): | ||
| pineko.check.check_grid_and_eko_compatible(wrong_grid, ekoop, 1.0) | ||
| pineko.check.check_grid_and_eko_compatible(grid, ekoop, 1.0) | ||
| ekoop.xgrid_reshape(targetgrid=[0.0001, 0.001, 0.1, 0.5, 1.0]) | ||
| with pytest.raises(ValueError): | ||
| pineko.check.check_grid_and_eko_compatible(grid, ekoop, 1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import pathlib | ||
|
|
||
| import pytest | ||
| from click.testing import CliRunner | ||
|
|
||
| from pineko.cli._base import command | ||
|
|
||
|
|
||
| def benchmark_check_cli(test_files): | ||
| grid_path = pathlib.Path( | ||
| test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| ) | ||
| wrong_grid_path = pathlib.Path( | ||
| test_files / "data/grids/208/HERA_CC_318GEV_EM_SIGMARED.pineappl.lz4" | ||
| ) | ||
| eko_path = pathlib.Path(test_files / "data/ekos/208/LHCB_DY_13TEV_DIMUON.tar") | ||
| runner = CliRunner() | ||
| result = runner.invoke( | ||
| command, ["check", "compatibility", str(grid_path), str(eko_path)] | ||
| ) | ||
| assert "Success: grids are compatible" in result.output | ||
| wrong_result = runner.invoke( | ||
| command, ["check", "compatibility", str(wrong_grid_path), str(eko_path)] | ||
| ) | ||
| assert ( | ||
| "Error: Q2 grid in pineappl grid and eko operator are NOT compatible!" | ||
| in wrong_result.output | ||
| ) | ||
| wrong_scvar_res = runner.invoke( | ||
| command, ["check", "scvar", str(grid_path), "wrong_string", "2", "0"] | ||
| ) | ||
| assert "Invalid value for 'SCALE'" in wrong_scvar_res.output | ||
| ren_res = runner.invoke( | ||
| command, ["check", "scvar", str(grid_path), "ren", "2", "0"] | ||
| ) | ||
| assert ( | ||
| "Success: grids contain renormalization scale variations for as" | ||
| in ren_res.output | ||
| ) | ||
| assert ( | ||
| "Success: grids contain renormalization scale variations for al" | ||
| in ren_res.output | ||
| ) | ||
| fact_res = runner.invoke( | ||
| command, ["check", "scvar", str(grid_path), "fact", "2", "0"] | ||
| ) | ||
| assert ( | ||
| "Success: grids contain factorization scale variations for as" | ||
| in fact_res.output | ||
| ) | ||
| assert ( | ||
| "Success: grids contain factorization scale variations for al" | ||
| in fact_res.output | ||
| ) | ||
|
|
||
|
|
||
| def benchmark_opcard_cli(tmp_path, test_files): | ||
| grid_path = pathlib.Path( | ||
| test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| ) | ||
| default_card_path = pathlib.Path(test_files / "data/operator_cards/_template.yaml") | ||
| target_path = pathlib.Path(tmp_path / "test_ope_card.yaml") | ||
| runner = CliRunner() | ||
| result = runner.invoke( | ||
| command, ["opcard", str(grid_path), str(default_card_path), str(target_path)] | ||
| ) | ||
| assert "Success" in result.output | ||
|
|
||
|
|
||
| def benchmark_compare_cli(lhapdf_path, test_files, test_pdf): | ||
| grid_path = pathlib.Path( | ||
| test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| ) | ||
| fk_path = pathlib.Path( | ||
| test_files / "data/fktables/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| ) | ||
| runner = CliRunner() | ||
| with lhapdf_path(test_pdf): | ||
| result = runner.invoke( | ||
| command, | ||
| ["compare", str(grid_path), str(fk_path), "2", "0", "NNPDF40_nlo_as_01180"], | ||
| ) | ||
| assert "yll left" in result.output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import pathlib | ||
|
|
||
| import pineappl | ||
|
|
||
| import pineko | ||
|
|
||
|
|
||
| def benchmark_compare(lhapdf_path, test_files, test_pdf): | ||
| pine_path = test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| grid = pineappl.grid.Grid.read(pine_path) | ||
| fk_path = test_files / "data/fktables/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4" | ||
| fk = pineappl.fk_table.FkTable.read(fk_path) | ||
| pdf = "NNPDF40_nlo_as_01180" | ||
| with lhapdf_path(test_pdf): | ||
| comp_table = pineko.comparator.compare(grid, fk, 2, 0, pdf, 1.0, 1.0) | ||
| errors = comp_table["permille_error"].values | ||
| assertions = [er < 5.0 for er in errors] | ||
| assert False not in assertions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import pathlib | ||
|
|
||
| import pytest | ||
|
|
||
| import pineko | ||
|
|
||
|
|
||
| def benchmark_detect(test_files): | ||
| with pytest.raises(FileNotFoundError): | ||
| pineko.configs.detect() | ||
| conf_file = pineko.configs.detect(test_files) | ||
|
|
||
|
|
||
| def benchmark_load(test_files): | ||
| conf_file = pineko.configs.load(test_files) | ||
| assert conf_file["paths"]["root"] == test_files | ||
| assert conf_file["paths"]["grids"] == "data/grids/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import pathlib | ||
|
|
||
| import eko | ||
| import pineappl | ||
| import pytest | ||
|
|
||
| import pineko | ||
|
|
||
|
|
||
| def benchmark_write_operator_card_from_file(tmp_path, test_files): | ||
| pine_path = test_files / "data/grids/208/HERA_CC_318GEV_EM_SIGMARED.pineappl.lz4" | ||
| default_path = test_files / "data/operator_cards/_template.yaml" | ||
| target_path = pathlib.Path(tmp_path / "test_operator.yaml") | ||
| x_grid, q2_grid = pineko.evolve.write_operator_card_from_file( | ||
| pine_path, default_path, target_path, 1.0 | ||
| ) | ||
| wrong_pine_path = test_files / "data/grids/208/HERA_CC_318GEV_EM_wrong.pineappl.lz4" | ||
| with pytest.raises(FileNotFoundError): | ||
| x_grid, q2_grid = pineko.evolve.write_operator_card_from_file( | ||
| wrong_pine_path, default_path, target_path, 1.0 | ||
| ) | ||
|
|
||
|
|
||
| def benchmark_evolve_grid(tmp_path, lhapdf_path, test_files, test_pdf): | ||
| pine_path = test_files / "data/grids/208/HERA_CC_318GEV_EM_SIGMARED.pineappl.lz4" | ||
| pinegrid = pineappl.grid.Grid.read(pine_path) | ||
| eko_path = test_files / "data/ekos/208/HERA_CC_318GEV_EM_SIGMARED.tar" | ||
| eko_op = eko.output.Output.load_tar(eko_path) | ||
| target_path = pathlib.Path(tmp_path / "test_fktable.pineappl.lz4") | ||
| max_as = 1 | ||
| max_al = 0 | ||
| base_configs = pineko.configs.load(test_files) | ||
| pineko.configs.configs = pineko.configs.defaults(base_configs) | ||
| tcard = pineko.theory_card.load(208) | ||
| assumptions = pineko.theory_card.construct_assumptions(tcard) | ||
| with lhapdf_path(test_pdf): | ||
| pineko.evolve.evolve_grid( | ||
| pinegrid, | ||
| eko_op, | ||
| target_path, | ||
| max_as, | ||
| max_al, | ||
| 1.0, | ||
| 1.0, | ||
| assumptions=assumptions, | ||
| comparison_pdf="NNPDF40_nlo_as_01180", | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.