def lal(self): """ Returns a LAL Object that contains this data """ lal_data = None if self._data.dtype == float32: lal_data = _lal.CreateREAL4Vector(len(self)) elif self._data.dtype == float64: lal_data = _lal.CreateREAL8Vector(len(self)) elif self._data.dtype == complex64: lal_data = _lal.CreateCOMPLEX8Vector(len(self)) elif self._data.dtype == complex128: lal_data = _lal.CreateCOMPLEX16Vector(len(self)) lal_data.data[:] = self.numpy() return lal_data
def lal(self): """ Returns a LAL Object that contains this data """ lal_data = None if type(self._data) is not _numpy.ndarray: raise TypeError("Cannot return lal type from the GPU") elif self._data.dtype == float32: lal_data = _lal.CreateREAL4Vector(len(self)) elif self._data.dtype == float64: lal_data = _lal.CreateREAL8Vector(len(self)) elif self._data.dtype == complex64: lal_data = _lal.CreateCOMPLEX8Vector(len(self)) elif self._data.dtype == complex128: lal_data = _lal.CreateCOMPLEX16Vector(len(self)) lal_data.data[:] = self._data return lal_data
warnings.simplefilter("error", numpy.ComplexWarning) # check module load print("checking module load ...") import lal from lal import globalvar as lalglobalvar lal_c_si = lal.C_SI lal_180_pi = lal.LAL_180_PI print("PASSED module load") # check memory allocation print("checking memory allocation ...") if not lal.NoDebug: lal.CheckMemoryLeaks() mem1 = lal.Detector() mem2 = lal.CreateCOMPLEX8Vector(5) mem3 = lal.CreateREAL8Vector(3) mem4 = lal.CreateREAL4TimeSeries("test", lal.LIGOTimeGPS(0), 100, 0.1, lal.DimensionlessUnit, 10) print("*** below should be an error message from CheckMemoryLeaks() ***") try: lal.CheckMemoryLeaks() expected_exception = True except: pass assert (not expected_exception) print("*** above should be an error message from CheckMemoryLeaks() ***") del mem1 del mem2 del mem3 del mem4