Commit b9ac5aaf authored by Kipp Cannon's avatar Kipp Cannon
Browse files

add element iteration order test for array I/O code

parent 929c44fb
Pipeline #236205 passed with stages
in 1 minute and 38 seconds
......@@ -77,4 +77,5 @@ ligo_lw_test_01 test_array test_ilwd test_ligolw test_lsctables test_param test_
@echo "<=== end $@ ==="
clean :
rm -f big_array.xml.gz
rm -f ligo_lw_test_01*png
......@@ -2,8 +2,42 @@
import doctest
import sys
from ligo.lw import array
from ligo.lw import ligolw
from ligo.lw import array as ligolw_array
from ligo.lw import utils as ligolw_utils
import numpy
import time
class LIGOXMLContentHandler(ligolw.LIGOLWContentHandler):
def test_io_iteration_order():
orig = numpy.arange(200**3, dtype = "double")
orig.shape = (200,200,200)
xmldoc = ligolw.Document()
xmldoc.appendChild(ligolw.LIGO_LW()).appendChild("test", orig))
start_write = time.perf_counter()
ligolw_utils.write_filename(xmldoc, "big_array.xml.gz", compress = "gz", with_mv = False)
end_write = time.perf_counter()
print("writing took %g s" % (end_write - start_write))
start_read = time.perf_counter()
recov = ligolw_array.get_array(ligolw_utils.load_filename("big_array.xml.gz", contenthandler = LIGOXMLContentHandler), "test").array
end_read = time.perf_counter()
print("reading took %g s" % (end_read - start_read))
if not (recov == orig).all():
raise ValueError("arrays are not the same")
if __name__ == '__main__':
failures = doctest.testmod(array)[0]
failures = doctest.testmod(ligolw_array)[0]
except ValueError:
failures |= 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