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

Replace recipes with jupyter notebook #309

Merged
merged 9 commits into from
Sep 26, 2024
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
184 changes: 0 additions & 184 deletions examples/python/dyaa.py

This file was deleted.

21 changes: 12 additions & 9 deletions examples/python/positivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ def main(filename, Q2):
pid = 4

# init pineappl objects
lumi_entries = [pineappl.lumi.LumiEntry([(pid, lepton_pid, 1.0)])]
lumi_entries = [pineappl.boc.Channel([(pid, lepton_pid, 1.0)])]
orders = [pineappl.grid.Order(0, 0, 0, 0)]
bins = len(xgrid)
bin_limits = list(map(float, range(0, bins + 1)))
# NOTE: `bin_limits` have to be `np.ndarray`
bin_limits = np.array([float(i) for i in range(0, bins + 1)])
# subgrid params - default is just sufficient
params = pineappl.subgrid.SubgridParams()
# inti grid
grid = pineappl.grid.Grid.create(lumi_entries, orders, bin_limits, params)
grid = pineappl.grid.Grid(lumi_entries, orders, bin_limits, params)
limits = []
# add each point as a bin
for bin_, x in enumerate(xgrid):
Expand All @@ -31,13 +32,15 @@ def main(filename, Q2):
# create and set
subgrid = pineappl.import_only_subgrid.ImportOnlySubgridV1(
array[np.newaxis, :, np.newaxis],
[Q2],
xgrid,
[1.0],
np.array([Q2]), # `q2_grid` has to be `np.ndarrary`
np.array(xgrid), # `x_grid` has to be `np.ndarrary`
np.array([1.0]), # `x_grid` has to be `np.ndarrary`
)
grid.set_subgrid(0, bin_, 0, subgrid)
grid.set_subgrid(0, bin_, 0, subgrid.into())
# set the correct observables
normalizations = [1.0] * bins
normalizations = np.array(
[1.0] * bins
) # `normalizations` has to be `np.ndarray`
remapper = pineappl.bin.BinRemapper(normalizations, limits)
grid.set_remapper(remapper)

Expand All @@ -55,4 +58,4 @@ def main(filename, Q2):


if __name__ == "__main__":
main("charm-positivity.pineappl", 1.5 ** 2)
main("charm-positivity.pineappl", 1.5**2)
3 changes: 2 additions & 1 deletion pineappl_py/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

.ipynb_checkpoints
docs/source/*.pineappl.lz4
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
Loading