Skip to content
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

Change data format to only use structured arrays #42

Merged
merged 6 commits into from
Jul 25, 2023

Conversation

kdund
Copy link
Member

@kdund kdund commented Jul 14, 2023

The inference_interface only stores np.arrays, and it is tidier, IMO to just stick with this, and let individual likelihoods use structured_array_to_dict at setting if it wants dicts.

At the moment setting w/o datasets names does not work, since the nt_likelihood branch misses the get_datasets_names(): raise NotImplementedError function, but otherwise, this worked well for both the gaussian and complex likelihood:


from alea.blueice_extended_model import BlueiceExtendedModel
import os
import alea
import numpy as np

alea_dir = os.path.dirname(alea.__file__)
config_path = os.path.join(alea_dir, "examples/unbinned_wimp_statistical_model.yaml")

# Initialize the statistical model
statistical_model = BlueiceExtendedModel.from_config(config_path)

complex_data = statistical_model.generate_data()
datanames = ["{:d}".format(i) for i in range(len(complex_data))]

statistical_model.store_data("complexdata.h5",[complex_data], data_name_list=datanames)

data, _ = ii.toydata_from_file("complexdata.h5")
[np.all(data[0][i] == complex_data[i]) for i in range(4)] #returns True, True, True, True

@hammannr hammannr linked an issue Jul 17, 2023 that may be closed by this pull request
Base automatically changed from nt_likelihood to master July 17, 2023 07:15
@kdund kdund requested a review from dachengx July 21, 2023 14:19
@github-actions
Copy link

github-actions bot commented Jul 24, 2023

Pull Request Test Coverage Report for Build 5655411007

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
alea/models/blueice_extended_model.py 0 4 0.0%
Totals Coverage Status
Change from base Build 5652428657: 0.0%
Covered Lines: 0
Relevant Lines: 2871

💛 - Coveralls

@dachengx dachengx merged commit 82f8d2d into main Jul 25, 2023
5 checks passed
@dachengx dachengx deleted the nt_likelihood_dataformat branch July 25, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check data reading/writing
2 participants