Skip to content

Commit

Permalink
Fix pdgid (#104)
Browse files Browse the repository at this point in the history
* fix #103

* add tests for bug #103

* update corsika version

* update corsika version in tests

* update corsika compare files
  • Loading branch information
The-Ludwig authored Nov 18, 2024
1 parent b197361 commit e857b01
Showing 9 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
python-version: ["3.8"]
corsika-version: ["77500"]
corsika-version: ["77550"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ jobs:
matrix:
python-version: ["3.11"]
poetry-version: ["1.3"]
corsika-version: ["77500"]
corsika-version: ["77550"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
permissions:
6 changes: 6 additions & 0 deletions panama/read.py
Original file line number Diff line number Diff line change
@@ -386,6 +386,8 @@ def add_mother_columns(
else False
for pdgid in pdgids
}
# explicitly force an invalid PDGID to not be charm
has_charm[PDGID_ERROR_VAL] = False

# this follows the MCEq definition
lifetimes = {
@@ -395,13 +397,17 @@ def add_mother_columns(
for pdgid in lifetimes:
if lifetimes[pdgid] is None:
lifetimes[pdgid] = 0
# explicitly force invalid PDGID to have infinite lifetime
lifetimes[PDGID_ERROR_VAL] = inf

is_resonance = {
pdgid: "*" in Particle.from_pdgid(pdgid).name
if pdgid != PDGID_ERROR_VAL
else False
for pdgid in pdgids
}
# explicitly force an invalid PDGID to not be a resonance
is_resonance[PDGID_ERROR_VAL] = False

df_particles["mother_lifetimes"] = df_particles["mother_pdgid"].map(
lifetimes, na_action=None
37 changes: 35 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tests/files/compare/DAT000000
Binary file not shown.
Binary file added tests/files/noEHIST/DAT101001
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
from panama import read_DAT
import pytest

CORSIKA_VERSION = "corsika-77500"
CORSIKA_EXECUTABLE = "corsika77500Linux_SIBYLL_urqmd"
CORSIKA_VERSION = "corsika-77550"
CORSIKA_EXECUTABLE = "corsika77550Linux_SIBYLL_urqmd"

def test_cli_missing_executable(
test_file_path=Path(__file__).parent / "files" / "example_corsika.template",
8 changes: 8 additions & 0 deletions tests/test_read.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@

SINGLE_TEST_FILE = Path(__file__).parent / "files" / "DAT000000"
GLOB_TEST_FILE = Path(__file__).parent / "files" / "DAT*"
NOEHIST_TEST_FILE = Path(__file__).parent / "files" / "noEHIST" / "DAT101001"


def test_noparse(test_file_path=SINGLE_TEST_FILE):
@@ -61,6 +62,13 @@ def check_eq(file, df_run, df_event, particles, skip_mother=False):
num += 1


def test_noehist(test_file_path=NOEHIST_TEST_FILE):
# This used to fail (see issue #103)
df_run, df_event, df = panama.read_DAT(glob=test_file_path, mother_columns=True)

check_eq(test_file_path, df_run, df_event, df, skip_mother=False)


def test_noadd(test_file_path=SINGLE_TEST_FILE):
with pytest.raises(ValueError, match="requires"):
df_run, df_event, particles = panama.read_DAT(
4 changes: 2 additions & 2 deletions tests/test_run.py
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
import pytest
import numpy as np

CORSIKA_VERSION = "corsika-77500"
CORSIKA_EXECUTABLE = "corsika77500Linux_SIBYLL_urqmd"
CORSIKA_VERSION = "corsika-77550"
CORSIKA_EXECUTABLE = "corsika77550Linux_SIBYLL_urqmd"


def test_corsika_runner_cleanup(

0 comments on commit e857b01

Please sign in to comment.