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


Python OrderedCollection.remake方法代碼示例

本文整理匯總了Python中gnome.utilities.orderedcollection.OrderedCollection.remake方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedCollection.remake方法的具體用法?Python OrderedCollection.remake怎麽用?Python OrderedCollection.remake使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnome.utilities.orderedcollection.OrderedCollection的用法示例。


在下文中一共展示了OrderedCollection.remake方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_remake

# 需要導入模塊: from gnome.utilities.orderedcollection import OrderedCollection [as 別名]
# 或者: from gnome.utilities.orderedcollection.OrderedCollection import remake [as 別名]
def test_remake():
    'delete automatically remakes internal lists without None'
    oc = OrderedCollection(['p', 'q', 'ab', 'adsf', 'ss'])
    del oc[0]
    del oc[2]
    oc.remake()
    for ix, elem in enumerate(oc._elems):
        assert elem is not None
        assert oc._d_index[s_id(elem)] == ix
開發者ID:NOAA-ORR-ERD,項目名稱:PyGnome,代碼行數:11,代碼來源:test_ordered_collection.py

示例2: test_remake

# 需要導入模塊: from gnome.utilities.orderedcollection import OrderedCollection [as 別名]
# 或者: from gnome.utilities.orderedcollection.OrderedCollection import remake [as 別名]
def test_remake():
    "remakes internal lists without None enteries"
    oc = OrderedCollection(["p", "q", "ab", "adsf", "ss"])
    del oc[0]
    del oc[3]
    assert oc._elems[0] is None
    assert oc._elems[3] is None
    oc.remake()
    for ix, elem in enumerate(oc._elems):
        assert elem is not None
        assert oc._index[s_id(elem)] == ix
開發者ID:JamesMakela-NOAA,項目名稱:PyGnome,代碼行數:13,代碼來源:test_ordered_collection.py

示例3: test_remake_emptyoc

# 需要導入模塊: from gnome.utilities.orderedcollection import OrderedCollection [as 別名]
# 或者: from gnome.utilities.orderedcollection.OrderedCollection import remake [as 別名]
def test_remake_emptyoc():
    "empty OC"
    oc = OrderedCollection(dtype=int)
    oc.remake()
開發者ID:JamesMakela-NOAA,項目名稱:PyGnome,代碼行數:6,代碼來源:test_ordered_collection.py

示例4: SpillContainer

# 需要導入模塊: from gnome.utilities.orderedcollection import OrderedCollection [as 別名]
# 或者: from gnome.utilities.orderedcollection.OrderedCollection import remake [as 別名]

#.........這裏部分代碼省略.........
        Make current_time optional since SpillContainer doesn't require it
        especially for 0th step; however, the model needs to set it because
        it will write_output() after each step. The data_arrays along with
        the current_time_stamp must be set in order to write_output()

        :param model_start_time: model_start_time to initialize
            current_time_stamp. This is the time_stamp associated with 0-th
            step so initial conditions for data arrays
        :param array_types: a dict of additional array_types to append to
            standard array_types attribute. The data_arrays are initialized and
            appended based on the values of array_types attribute

        .. note:: The SpillContainer cycles through each of the keys in
        array_types and checks to see if there is an associated initializer
        in each Spill. If a corresponding initializer is found, it gets the
        array_types from initializer and appends them to its own list. For
        most initializers like 
        """
        # Question - should we purge any new arrays that were added in previous
        # call to prepare_for_model_run()?
        # No! If user made modifications to _array_types before running model,
        # let's keep those. A rewind will reset data_arrays.
        self._array_types.update(array_types)

        # for each array_types, use the key to get the associated initializer
        for key in array_types:
            for spill in self.spills:
                if spill.is_initializer(key):
                    self._array_types.update(
                        spill.get_initializer(key).array_types)
        self.initialize_data_arrays()

        # remake() spills ordered collection
        self.spills.remake()

    def initialize_data_arrays(self):
        """
        initialize_data_arrays() is called without input data during rewind
        and prepare_for_model_run to define all data arrays.
        At this time the arrays are empty.
        """
        for name, atype in self._array_types.iteritems():
            # Initialize data_arrays with 0 elements
            self._data_arrays[name] = atype.initialize_null()

    def _append_data_arrays(self, num_released):
        """
        initialize data arrays once spill has spawned particles
        Data arrays are set to their initial_values

        :param num_released: number of particles released
        :type num_released: int

        """
        for name, atype in self._array_types.iteritems():
            # initialize all arrays even if 0 length
            self._data_arrays[name] = np.r_[self._data_arrays[name],
                                            atype.initialize(num_released)]

    def release_elements(self, time_step, model_time):
        """
        Called at the end of a time step

        This calls release_elements on all of the contained spills, and adds
        the elements to the data arrays
        """
開發者ID:JamesMakela-NOAA,項目名稱:PyGnome,代碼行數:70,代碼來源:spill_container.py


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