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

FIX: allow generating empty phase space samples #465

Merged
merged 3 commits into from
Oct 28, 2022
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
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