當前位置: 首頁>>代碼示例>>Python>>正文


Python array.Array類代碼示例

本文整理匯總了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
開發者ID:bhooshan-gadre,項目名稱:pycbc,代碼行數:30,代碼來源:timeseries.py

示例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)
開發者ID:gayathrigcc,項目名稱:pycbc,代碼行數:14,代碼來源:timeseries.py

示例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)
開發者ID:AbhayMK,項目名稱:pycbc,代碼行數:14,代碼來源:timeseries.py

示例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)
開發者ID:aburony1970,項目名稱:pycbc,代碼行數:9,代碼來源:frequencyseries.py

示例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)
開發者ID:cmbiwer,項目名稱:pycbc,代碼行數:18,代碼來源:timeseries.py


注:本文中的pycbc.types.array.Array類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。