2from functools
import wraps
3from astropy
import units
as u
12 Wrapper to map LAL erros to Python errors
15 def wrapper(*args, **kwargs):
18 return func(*args, **kwargs)
19 except RuntimeError
as e:
20 lalerr = lal.GetBaseErrno()
21 exception = exceptionmap[lalerr]
if lalerr
in exceptionmap
else e
22 raise exception
from None
27 lal.ENOENT: FileNotFoundError(
"No such file or directory"),
28 lal.EIO: OSError(
"I/O Error"),
29 lal.ENOMEM: MemoryError(
"Memory Allocation Error"),
30 lal.EFAULT: ValueError(
"Invalid pointer"),
31 lal.EINVAL: ValueError(
"Invalid Argument"),
32 lal.EDOM: ValueError(
"Input domain error"),
33 lal.ERANGE: ArithmeticError(
"Output range error"),
34 lal.ENOSYS: NotImplementedError(
"Function not implemented"),
35 lal.EFAILED: RuntimeError(
"Generic Failure"),
36 lal.EBADLEN: ValueError(
"Inconsistent or invalid length"),
37 lal.ESIZE: ValueError(
"Wrong Size"),
38 lal.EDIMS: ValueError(
"Wrong dimensions"),
39 lal.ETYPE: TypeError(
"Wrong or unknown type"),
40 lal.ETIME: ValueError(
"Invalid time"),
41 lal.EFREQ: ValueError(
"Invalid frequency"),
42 lal.EUNIT: u.UnitsError(
"Invalid units"),
43 lal.ENAME: ValueError(
"Wrong name"),
44 lal.EDATA: ValueError(
"Invalid data"),
45 lal.ESYS: SystemError(
"System Error"),
46 lal.EERR: RuntimeError(
"Internal Error"),
47 lal.EFPINVAL: FloatingPointError(
"IEEE Invalid floating point operation, eg sqrt(-1), 0/0"),
48 lal.EFPDIV0: ZeroDivisionError(
"IEEE Division by zero floating point error"),
49 lal.EFPOVRFLW: OverflowError(
"IEEE Floating point overflow error"),
50 lal.EFPUNDFLW: FloatingPointError(
"IEEE Floating point underflow error"),
51 lal.EFPINEXCT: FloatingPointError(
"IEEE Floating point inexact error"),
52 lal.EMAXITER: ArithmeticError(
"Exceeded maximum number of iterations"),
53 lal.EDIVERGE: ArithmeticError(
"Series is diverging"),
54 lal.ESING: ArithmeticError(
"Apparent singularity detected"),
55 lal.ETOL: ArithmeticError(
"Failed to reach specified tolerance"),
56 lal.ELOSS: ArithmeticError(
"Loss of accuracy"),
57 lal.EUSR0: RuntimeError(
"User defined Error"),
58 lal.EUSR1: RuntimeError(
"User defined Error"),
59 lal.EUSR2: RuntimeError(
"User defined Error"),
60 lal.EUSR3: RuntimeError(
"User defined Error"),
61 lal.EUSR4: RuntimeError(
"User defined Error"),
62 lal.EUSR5: RuntimeError(
"User defined Error"),
63 lal.EUSR6: RuntimeError(
"User defined Error"),
64 lal.EUSR7: RuntimeError(
"User defined Error"),
65 lal.EUSR8: RuntimeError(
"User defined Error"),
66 lal.EUSR9: RuntimeError(
"User defined Error")
76 Raise Error when there is an issue
with waveform generation.
80 message : Output message
for the error.
83 Raises waveform generation error exception
86 def __init__(self, message="Error during waveform generation"):
91 return f
'{self.message}'
96 Raise Error when parameter passes is out of waveform domain
100 parameter : Parameter
in question
101 message : Output message
for the error.
105 Raises domain error exception
107 def __init__(self, parameter, message="Input parameter out of waveform domain"):
113 return f
'{self.parameter} -> {self.message}'
118 Raise Exception when the needed file is not at the given path
122 file_name : Path to the file
in question.
123 message : Output message
for the error.
127 Raises File
not found at given path error excetion.
130 def __init__(self, file_path, message="File not found at "):
136 return f
'{self.message} -> {self.file_path}'
Raise Error when parameter passes is out of waveform domain.
def __init__(self, parameter, message="Input parameter out of waveform domain")
Raise Exception when the needed file is not at the given path.
def __init__(self, file_path, message="File not found at ")
def mapexception(func)
Mapping between LAL Errors and Python.