diff --git a/pymule/__init__.py b/pymule/__init__.py index dee8b2f853473b043340940122e7c4f4711002b6..051ce742ff1ce815f8239c4aec2e25b873013606 100644 --- a/pymule/__init__.py +++ b/pymule/__init__.py @@ -1,2 +1,4 @@ import numpy as np import matplotlib.pyplot as plt + +from vegas import importvegas diff --git a/pymule/vegas.py b/pymule/vegas.py new file mode 100644 index 0000000000000000000000000000000000000000..e30f677b6bec26c4e4384fef11c0279700cbf1f6 --- /dev/null +++ b/pymule/vegas.py @@ -0,0 +1,19 @@ +import struct + + +def read_record(fp, typ): + l1 = struct.unpack("<I", fp.read(4))[0] + body = fp.read(l1) + l2 = struct.unpack("<I", fp.read(4))[0] + if l1 != l2: + raise KeyError("Record is not properly close %d v %d" % (l1, l2)) + + n = l1 / struct.calcsize(typ) + body = struct.unpack("<"+typ*n, body) + if typ == 'c': + return ''.join(body) + else: + if n == 1: + return body[0] + else: + return body