Commit f51a873d authored by Kipp Cannon's avatar Kipp Cannon

remove dagfile, offsetvector, segmentsUtils modules

- dagfile goes to gstlal
- offsetvector goes to lalburst
- segmentsUtils goes to ligo.segments
- deprecation warning stubs are left in their place
parent 8aacd61b
Pipeline #34367 failed with stages
in 4 minutes and 21 seconds
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,9 +5,6 @@ check : \
iterutils_verify \
lal_verify \
ligolw_test01 \
offsetvector_verify \
segments_verify \
segmentsUtils_verify \
test_ligolw_array \
test_ligolw_ligolw \
test_ligolw_lsctables \
......@@ -42,21 +39,6 @@ ligolw_test01 :
$(PYTHON) ligo_lw_test_01.py && $(printpassfail)
@echo "<=== end ligolw_test01 ==="
offsetvector_verify :
@echo "=== start offsetvector_verify ===>"
$(PYTHON) offsetvector_verify.py && $(printpassfail)
@echo "<=== end offsetvector_verify ==="
segmentsUtils_verify :
@echo "=== start segmentsUtils_verify ===>"
$(PYTHON) segmentsUtils_verify.py && $(printpassfail)
@echo "<=== end segmentsUtils_verify ==="
segments_verify :
@echo "=== start segments_verify ===>"
$(PYTHON) segments_verify.py && $(printpassfail)
@echo "<=== end segments_verify ==="
test_ligolw_array :
@echo "=== start test_ligolw_array ===>"
$(PYTHON) test_ligolw_array.py && $(printpassfail)
......
import doctest
import sys
from glue import offsetvector
failures = doctest.testmod(offsetvector)[0]
sys.exit(bool(failures))
import random
import sys
import unittest
from glue import iterutils
from glue import segments
from glue import segmentsUtils
import verifyutils
from six.moves import range
from functools import reduce
from six.moves import StringIO
verifyutils.segments = segments
#
# How many times to repeat the algebraic tests
#
algebra_repeats = 8000
algebra_listlength = 200
#
# Define the components of the test suite.
#
class test_segwizard(unittest.TestCase):
def test_fromsegwizard(self):
"""
Test segwizard parsing.
"""
data = StringIO("""# This is a comment
# This is another comment
# Again a comment
1 10 100 90
2 110 120 10# Here's a comment
3 125 130 5 # Another one
4 0 200 200""")
correct = segments.segmentlist([segments.segment(10, 100), segments.segment(110, 120), segments.segment(125, 130), segments.segment(0, 200)])
self.assertEqual(correct, segmentsUtils.fromsegwizard(data, strict=True))
def test_tofromseqwizard(self):
"""
Check that the segwizard writing routine's output is parsed
correctly.
"""
data = StringIO()
correct = segments.segmentlist([segments.segment(10, 100), segments.segment(110, 120), segments.segment(125, 130), segments.segment(0, 200)])
segmentsUtils.tosegwizard(data, correct)
data.seek(0)
self.assertEqual(correct, segmentsUtils.fromsegwizard(data, strict=True))
class test_vote(unittest.TestCase):
def test_vote(self):
"""
Test vote().
"""
for i in range(algebra_repeats):
seglists = []
for j in range(random.randint(0, 10)):
seglists.append(verifyutils.random_coalesced_list(algebra_listlength))
n = random.randint(0, len(seglists))
correct = reduce(lambda x, y: x | y, (votes and reduce(lambda a, b: a & b, votes) or segments.segmentlist() for votes in iterutils.choices(seglists, n)), segments.segmentlist())
self.assertEqual(correct, segmentsUtils.vote(seglists, n))
#
# Construct and run the test suite.
#
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(test_segwizard))
suite.addTest(unittest.makeSuite(test_vote))
sys.exit(not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful())
#!/usr/bin/env python
import sys
import unittest
import warnings
class TestSegmentsWarning(unittest.TestCase):
def test_warning(self):
with warnings.catch_warnings(record=True) as ctx:
warnings.simplefilter('always')
from glue import segments
self.assertIn('ligo.segments', str(ctx[0].message))
class TestSegments(unittest.TestCase):
def test_sanity(self):
with warnings.catch_warnings() as ctx:
warnings.filterwarnings('ignore', category=DeprecationWarning)
from glue import segments
a = segments.segment(1, 2)
b = segments.segment(3, 4)
l = segments.segmentlist([a, b])
d = segments.segmentlistdict()
d['a'] = segments.segmentlist([a])
d['b'] = segments.segmentlist([b])
self.assertEqual(d['a'], l[:1])
self.assertEqual(d['b'], l[1:])
# run the tests
if __name__ == "__main__":
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestSegmentsWarning))
suite.addTest(unittest.makeSuite(TestSegments))
if not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful():
sys.exit(1)
import random
from six.moves import range
from six.moves import zip
#
# segmentlist generation utilities
#
def random_coalesced_list(n):
"""
Return a coalesced segmentlist of n elements with random boundaries.
"""
def r():
return random.randint(1, 127) / 128.0
if n < 1:
raise ValueError(n)
l = segments.segmentlist([None] * n)
x = r()
l[0] = segments.segment(x, x + r())
x = l[0][1] + r()
for i in range(1, n):
l[i] = segments.segment(x, x + r())
x = l[i][1] + r()
return l
def random_uncoalesced_list(n):
"""
Return an uncoalesced segmentlist of n elements with random
boundaries.
"""
def r():
return float(random.randint(1, 999)) / 1000
if n < 1:
raise ValueError(n)
x = r()
l = segments.segmentlist([segments.segment(x, x + r() / 100.0)])
for i in range(n - 1):
x = r()
l.append(segments.segment(x, x + r() / 100.0))
return l
def iscoalesced(l):
"""
Return True if the segmentlist l is coalesced.
"""
for a, b in zip(l, l[1:]):
if a[1] >= b[0]:
return False
return True
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