Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/actions/install_conda_pip/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ runs:
- name: Install host requirements
shell: bash -l {0}
run: |
conda install lhapdf pandoc
conda install lhapdf pandoc pip
- name: Install package with test extras
shell: bash -l {0}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/prepare_environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: conda-incubator/setup-miniconda@v3
- uses: conda-incubator/setup-miniconda@v4
with:
python-version: ${{ inputs.python-version }}
use-mamba: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/all_tests_nnpdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Build recipe
shell: bash -l {0}
run: |
conda install conda-build --yes
conda install -n base conda-build --yes
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 I was both clever and handsome I would be too powerful for this world.
Anyway, this can be merged I guess.

(I've done this change because reading https://github.com/conda-incubator/setup-miniconda#important I thought macos, which has its own flavour of bash due to licence issues, might be messing with the environment activation, but I don't fully know why this fixes it other than "apple bad")

conda build -q conda-recipe --package-format=1
- name: Keep conda package as artifact
if: ${{ !cancelled() }}
Expand Down
5 changes: 4 additions & 1 deletion nnpdf_data/nnpdf_data/filter_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def check_xq2_degenearcy(Q2, x):
unique kinematics are: {unique_pairs.shape[1]}, original size: {size}"""
) from exc


def uncert_skip_variant(source_file, skip_file, uncert_file, uncert_name, remove_source=True):
r"""
Create two new uncertainty files, one where the specified uncertainty
Expand Down Expand Up @@ -469,7 +470,9 @@ def uncert_skip_variant(source_file, skip_file, uncert_file, uncert_name, remove
content_uncert = {}

if 'definitions' in content and uncert_name in content['definitions']:
content_uncert['definitions'] = {uncert_name: copy.deepcopy(content['definitions'][uncert_name])}
content_uncert['definitions'] = {
uncert_name: copy.deepcopy(content['definitions'][uncert_name])
}
content_uncert['bins'] = {}
bins = []
for i in range(len(content['bins'])):
Expand Down
16 changes: 4 additions & 12 deletions validphys2/src/validphys/covmats.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ def dataset_inputs_t0_total_covmat_separate(
In this case the t0 prescription is used for the experimental covmat and the multiplicative
errors are separated. Moreover, the theory covmat is added to experimental covmat.
"""
covmat = dataset_inputs_t0_exp_covmat_separate
covmat += loaded_theory_covmat
return covmat
return dataset_inputs_t0_exp_covmat_separate + loaded_theory_covmat


def dataset_inputs_t0_exp_covmat_separate(
Expand Down Expand Up @@ -448,9 +446,7 @@ def dataset_inputs_total_covmat_separate(dataset_inputs_exp_covmat_separate, loa
In this case the t0 prescription is not used for the experimental covmat and the multiplicative
errors are separated. Moreover, the theory covmat is added to experimental covmat.
"""
covmat = dataset_inputs_exp_covmat_separate
covmat += loaded_theory_covmat
return covmat
return dataset_inputs_exp_covmat_separate + loaded_theory_covmat


def dataset_inputs_exp_covmat_separate(
Expand Down Expand Up @@ -482,9 +478,7 @@ def dataset_inputs_t0_total_covmat(dataset_inputs_t0_exp_covmat, loaded_theory_c
by fitting_data_dict. In this case the t0 prescription is used for the experimental covmat
and the multiplicative errors are included in it. Moreover, the theory covmat is added to experimental covmat.
"""
covmat = dataset_inputs_t0_exp_covmat
covmat += loaded_theory_covmat
return covmat
return dataset_inputs_t0_exp_covmat + loaded_theory_covmat


def dataset_inputs_t0_exp_covmat(
Expand Down Expand Up @@ -517,9 +511,7 @@ def dataset_inputs_total_covmat(dataset_inputs_exp_covmat, loaded_theory_covmat)
by fitting_data_dict. In this case the t0 prescription is not used for the experimental covmat
and the multiplicative errors are included in it. Moreover, the theory covmat is added to experimental covmat.
"""
covmat = dataset_inputs_exp_covmat
covmat += loaded_theory_covmat
return covmat
return dataset_inputs_exp_covmat + loaded_theory_covmat


def dataset_inputs_exp_covmat(
Expand Down
31 changes: 30 additions & 1 deletion validphys2/src/validphys/tests/test_covmats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@

from nnpdf_data.commondataparser import load_commondata
from validphys.api import API
from validphys.covmats import dataset_t0_predictions, reorder_thcovmat_as_expcovmat, sqrt_covmat
from validphys.covmats import (
dataset_inputs_t0_total_covmat,
dataset_inputs_t0_total_covmat_separate,
dataset_inputs_total_covmat,
dataset_inputs_total_covmat_separate,
dataset_t0_predictions,
reorder_thcovmat_as_expcovmat,
sqrt_covmat,
)
from validphys.tests.conftest import DATA, HESSIAN_PDF, PDF, THEORYID

# Experiments which have non trivial correlations between their datasets
Expand Down Expand Up @@ -153,3 +161,24 @@ def test_single_datapoint(single_data_single_point_internal_cuts_config):
# Ensure the dataset is only a single datapoint
assert ld.ndata == 1
ld.systematic_errors(t0_predictions)


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.

The test is fine per se, but I'd like to hear @scarlehoff's opinion. In my view, the test prevents us from repeating the same mistake, although now that we are aware of the issue it might seem a bit superfluous. Still, I think we should keep it as a reminder for the future and as a signal for new members.

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.

Many of our tests are built on the blood of our previous mistakes. I'm happy with superflous tests.

@pytest.mark.parametrize(
"combine_fn",
[
dataset_inputs_t0_total_covmat_separate,
dataset_inputs_total_covmat_separate,
dataset_inputs_t0_total_covmat,
dataset_inputs_total_covmat,
],
)
def test_covmat_summing_helpers_do_not_mutate_inputs(combine_fn):
exp = np.array([[1.0, 0.2], [0.2, 2.0]])
th = np.array([[0.5, 0.1], [0.1, 0.3]])
exp_before = exp.copy()

result = combine_fn(exp, th)

np.testing.assert_allclose(exp, exp_before)
np.testing.assert_allclose(result, exp_before + th)
assert result is not exp
Loading