Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit 80f04749 authored by Adam Mercer's avatar Adam Mercer

Merge branch 'lalburst-test-python3-allclose' into 'master'

Use assert_allclose to compare floats in lalburst/test

See merge request lscsoft/lalsuite!311
parents c302e263 ec1015af
Pipeline #21979 passed with stages
in 25 minutes and 56 seconds
import unittest
import sys
from numpy.testing import assert_allclose
from lalburst import snglcoinc
......@@ -29,51 +31,67 @@ class TestCoincRates(unittest.TestCase):
def test_coinc_rates(self):
rates = snglcoinc.CoincRates(("H1", "L1", "V1"), 0.005, 2)
self.assertDictEqual(
rates.coinc_rates(H1=0.001, L1=0.002, V1=0.003),
{frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 1.9372787960306537e-07,
frozenset(['L1', 'V1']): 3.77380092200718e-07,
frozenset(['H1', 'L1', 'V1']): 1.0125819710267318e-11},
)
self.assertDictEqual(
rates.coinc_rates(H1=0.001, L1=0.002, V1=0.002),
{frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 1.291519197353769e-07,
frozenset(['L1', 'V1']): 2.5158672813381197e-07,
frozenset(['H1', 'L1', 'V1']): 6.750546473511545e-12},
)
self.assertDictEqual(
rates.coinc_rates(H1=0.001, L1=0.002, V1=0.001),
{frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 6.457595986768845e-08,
frozenset(['L1', 'V1']): 1.2579336406690598e-07,
frozenset(['H1', 'L1', 'V1']): 3.3752732367557724e-12},
)
crates = rates.coinc_rates(H1=0.001, L1=0.002, V1=0.003)
expected = {
frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 1.9372787960306537e-07,
frozenset(['L1', 'V1']): 3.77380092200718e-07,
frozenset(['H1', 'L1', 'V1']): 1.0125819710267318e-11,
}
for key in crates:
assert_allclose(crates[key], expected[key])
crates = rates.coinc_rates(H1=0.001, L1=0.002, V1=0.002)
expected = {
frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 1.291519197353769e-07,
frozenset(['L1', 'V1']): 2.5158672813381197e-07,
frozenset(['H1', 'L1', 'V1']): 6.750546473511545e-12,
}
for key in crates:
assert_allclose(crates[key], expected[key])
crates = rates.coinc_rates(H1=0.001, L1=0.002, V1=0.001)
expected = {
frozenset(['H1', 'L1']): 6.00513846088957e-08,
frozenset(['H1', 'V1']): 6.457595986768845e-08,
frozenset(['L1', 'V1']): 1.2579336406690598e-07,
frozenset(['H1', 'L1', 'V1']): 3.3752732367557724e-12,
}
for key in crates:
assert_allclose(crates[key], expected[key])
def test_strict_coinc_rates(self):
rates = snglcoinc.CoincRates(("H1", "L1", "V1"), 0.005, 2)
self.assertDictEqual(
rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.003),
{frozenset(['H1', 'L1']): 6.004125878918543e-08,
frozenset(['H1', 'V1']): 1.937177537833551e-07,
frozenset(['L1', 'V1']): 3.7736996638100773e-07,
frozenset(['H1', 'L1', 'V1']): 1.0125819710267318e-11},
)
self.assertDictEqual(
rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.002),
{frozenset(['H1', 'L1']): 6.004463406242219e-08,
frozenset(['H1', 'V1']): 1.2914516918890337e-07,
frozenset(['L1', 'V1']): 2.5157997758733847e-07,
frozenset(['H1', 'L1', 'V1']): 6.750546473511545e-12},
)
self.assertDictEqual(
rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.001),
{frozenset(['H1', 'L1']): 6.004800933565894e-08,
frozenset(['H1', 'V1']): 6.457258459445168e-08,
frozenset(['L1', 'V1']): 1.2578998879366924e-07,
frozenset(['H1', 'L1', 'V1']): 3.3752732367557724e-12},
)
scrates = rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.003)
expected = {
frozenset(['H1', 'L1']): 6.004125878918543e-08,
frozenset(['H1', 'V1']): 1.937177537833551e-07,
frozenset(['L1', 'V1']): 3.7736996638100773e-07,
frozenset(['H1', 'L1', 'V1']): 1.0125819710267318e-11,
}
for key in scrates:
assert_allclose(scrates[key], expected[key])
scrates = rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.002)
expected = {
frozenset(['H1', 'L1']): 6.004463406242219e-08,
frozenset(['H1', 'V1']): 1.2914516918890337e-07,
frozenset(['L1', 'V1']): 2.5157997758733847e-07,
frozenset(['H1', 'L1', 'V1']): 6.750546473511545e-12,
}
for key in scrates:
assert_allclose(scrates[key], expected[key])
scrates = rates.strict_coinc_rates(H1=0.001, L1=0.002, V1=0.001)
expected = {
frozenset(['H1', 'L1']): 6.004800933565894e-08,
frozenset(['H1', 'V1']): 6.457258459445168e-08,
frozenset(['L1', 'V1']): 1.2578998879366924e-07,
frozenset(['H1', 'L1', 'V1']): 3.3752732367557724e-12,
}
for key in scrates:
assert_allclose(scrates[key], expected[key])
def test_lnP_instruments(self):
rates = snglcoinc.CoincRates(("H1", "L1", "V1"), 0.005, 2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment