Skip to content

Commit

Permalink
Add benchmark of integrated probability
Browse files Browse the repository at this point in the history
Add benchmark of integrated probability within the union of a set
of fields.
  • Loading branch information
lpsinger committed Aug 22, 2022
1 parent 0b800b9 commit 30181c0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions healpix_alchemy/tests/benchmarks/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,22 @@ def test_fields_in_90pct_credible_region(bench, random_fields, random_sky_map):

# Run benchmark
bench(query)


def test_integrated_probability(bench, random_fields, random_sky_map):
"""Find integrated probability within union of fields."""
union = sa.select(
func.union(FieldTile.hpx).label('hpx')
).subquery()

area = (union.columns.hpx * SkymapTile.hpx).area
prob = sa.func.sum(SkymapTile.probdensity * area)

query = sa.select(
prob
).filter(
SkymapTile.id == 1,
union.columns.hpx.overlaps(SkymapTile.hpx)
)

bench(query)

0 comments on commit 30181c0

Please sign in to comment.