本文整理汇总了Python中pycbc.types.array.Array类的典型用法代码示例。如果您正苦于以下问题:Python Array类的具体用法?Python Array怎么用?Python Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Array类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, initial_array, delta_t=None, epoch="", dtype=None, copy=True):
if len(initial_array) < 1:
raise ValueError('initial_array must contain at least one sample.')
if delta_t is None:
try:
delta_t = initial_array.delta_t
except AttributeError:
raise TypeError('must provide either an initial_array with a delta_t attribute, or a value for delta_t')
if not delta_t > 0:
raise ValueError('delta_t must be a positive number')
# We gave a nonsensical default value to epoch so we can test if it's been set.
# If the user passes in an initial_array that has an 'epoch' attribute and doesn't
# pass in a value of epoch, then our new object's epoch comes from initial_array.
# But if the user passed in a value---even 'None'---that will take precedence over
# anything set in initial_array. Finally, if the user passes in something without
# an epoch attribute *and* doesn't pass in a value of epoch, it becomes 'None'
if not isinstance(epoch,_lal.LIGOTimeGPS):
if epoch == "":
if isinstance(initial_array, TimeSeries):
epoch = initial_array._epoch
else:
epoch = _lal.LIGOTimeGPS(0)
elif epoch is not None:
try:
epoch = _lal.LIGOTimeGPS(epoch)
except:
raise TypeError('epoch must be either None or a lal.LIGOTimeGPS')
Array.__init__(self, initial_array, dtype=dtype, copy=copy)
self._delta_t = delta_t
self._epoch = epoch
示例2: __getitem__
def __getitem__(self, index):
if isinstance(index, slice):
# Set the new epoch---note that index.start may also be None
if self._epoch is None:
new_epoch = None
elif index.start is None:
new_epoch = self._epoch
else:
if index.start < 0:
raise ValueError('Negative start index not supported')
new_epoch = self._epoch + index.start * self._delta_t
return TimeSeries(Array.__getitem__(self, index), self._delta_t, new_epoch, copy=False)
else:
return Array.__getitem__(self, index)
示例3: __getitem__
def __getitem__(self, index):
if isinstance(index, slice):
# Set the new epoch---note that index.start may also be None
if self._epoch is None:
new_epoch = None
elif index.start is None:
new_epoch = self._epoch
else:
if index.start < 0:
index.start += len(self)
new_epoch = self._epoch + index.start * self._delta_t
return TimeSeries(Array.__getitem__(self, index), self._delta_t, new_epoch, copy=False)
else:
return Array.__getitem__(self, index)
示例4: _getslice
def _getslice(self, index):
if index.step is not None:
new_delta_f = self._delta_f * index.step
else:
new_delta_f = self._delta_f
return FrequencySeries(Array._getslice(self, index),
delta_f=new_delta_f,
epoch=self._epoch,
copy=False)
示例5: _getslice
def _getslice(self, index):
# Set the new epoch---note that index.start may also be None
if self._epoch is None:
new_epoch = None
elif index.start is None:
new_epoch = self._epoch
else:
if index.start < 0:
raise ValueError('Negative start index not supported')
new_epoch = self._epoch + index.start * self._delta_t
if index.step is not None:
new_delta_t = self._delta_t * index.step
else:
new_delta_t = self._delta_t
return TimeSeries(Array._getslice(self, index), new_delta_t,
new_epoch, copy=False)