Skip to content

Commit

Permalink
FIX: allow generating empty phase space samples (#465)
Browse files Browse the repository at this point in the history
* FIX: update PR labels
* MAINT: add test for generating empty phase space sample
  • Loading branch information
redeboer authored Oct 28, 2022
1 parent d79c8ac commit 6d9d5bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ jobs:
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest
with:
any_of: Bug,💡 Feature,⚠️ Interface,📝 Docs,🔨 Maintenance,🖱️ DX
none_of: Epic,❌ Won't fix,💫 Good first issue
any_of:
🐛 Bug,💡 Feature,⚙️ Enhancement,⚠️ Interface,❗ Behavior,📝 Docs,🔨
Maintenance,🖱️ DX
none_of: Epic,💫 Good first issue
repo_token: ${{ secrets.GITHUB_TOKEN }}

check-title:
name: Check title
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Install Dependencies
run: npm install @commitlint/config-conventional
- run: npm install @commitlint/config-conventional
- uses: JulienKode/pull-request-name-linter-action@v0.5.0
3 changes: 2 additions & 1 deletion src/tensorwaves/data/phasespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def generate(self, size: int, rng: RealNumberGenerator) -> DataSample:
progress_bar.update(n=get_number_of_events(bunch))
finalize_progress_bar(progress_bar)
phsp = select_events(momentum_pool, selector=slice(None, size))
del phsp["weights"]
if len(phsp) != 0:
del phsp["weights"]
return phsp


Expand Down
11 changes: 11 additions & 0 deletions tests/data/test_phasespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ def test_generate(
assert len(momenta) == n_events
assert pytest.approx(momenta, abs=1e-6) == expected_sample[i]

def test_generate_no_events(self, pdg: "ParticleCollection"):
rng = TFUniformRealNumberGenerator()
phsp_generator = TFPhaseSpaceGenerator(
initial_state_mass=pdg["J/psi(1S)"].mass,
final_state_masses={
i: pdg[name].mass for i, name in enumerate(["gamma", "pi0", "pi0"])
},
)
phsp_momenta = phsp_generator.generate(0, rng)
assert len(phsp_momenta) == 0


class TestTFWeightedPhaseSpaceGenerator:
def test_generate_deterministic(self, pdg: "ParticleCollection"):
Expand Down

0 comments on commit 6d9d5bf

Please sign in to comment.