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
assert (all(map(lambda x, y: x == y.upper(), sv, svdat))) del sv del svout del svdat lal.CheckMemoryLeaks() print("PASSED input views of string array structs") ## check input views of numeric array structs print("checking input views of numeric array structs ...") r4dat = numpy.array([1.2, 2.3, 3.4, 4.5, 5.6], dtype=numpy.float32) r8dat = numpy.array([3.4, 4.5, 5.6, 6.7, 7.8, 8.9], dtype=numpy.float64) c8dat = numpy.array(numpy.vectorize(complex)(r4dat, 8 + r4dat), dtype=numpy.complex64) c16dat = numpy.array(numpy.vectorize(complex)(r8dat, 16 + r8dat), dtype=numpy.complex128) r4 = lal.CreateREAL4Vector(len(r4dat)) r4.data = r4dat r4out = lal.CreateREAL4Vector(len(r4dat)) r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype) assert (lal.swig_lal_test_viewin_REAL4Vector(r4out, r4)) assert ((r4out.data == r4.data).all()) r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype) assert (lal.swig_lal_test_viewin_REAL4Vector(r4out, r4dat)) assert ((r4out.data == r4dat).all()) r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype) assert (lal.swig_lal_test_viewinout_REAL4Vector(r4out, r4)) assert ((2 * r4out.data == r4.data).all()) r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype) assert (lal.swig_lal_test_viewinout_REAL4Vector(r4out, r4dat)) assert ((2 * r4out.data == r4dat).all()) r4.data = r4dat