本文整理汇总了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
示例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
示例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()
示例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
"""