本文整理汇总了Python中output.Output.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Output.reset方法的具体用法?Python Output.reset怎么用?Python Output.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类output.Output
的用法示例。
在下文中一共展示了Output.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ContextAggregator
# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import reset [as 别名]
class ContextAggregator(object):
"""database class"""
AGGREGATION_MODE = 0
SINGLE_ONLY_MODE = 1
MAX_TAU = "max_tau"
PM = "propagation_mode"
defaults = {MAX_TAU:0, PM:AGGREGATION_MODE}
def is_single_only_mode(self):
return self.configuration(ContextAggregator.PM) == ContextAggregator.SINGLE_ONLY_MODE
def is_aggregation_mode(self):
return self.configuration(ContextAggregator.PM) == ContextAggregator.AGGREGATION_MODE
#
# Initialization and Reset
#
def __init__(self, id = -1, config = None):
self.id = id
self.set_config(config)
# inner data structure
self.input = Input()
self.context_database = ContextDatabase()
self.assorted_context_database = AssortedContextDatabase()
self.output = Output()
self.context_history = ContextHistory()
# instance variables for debugging purposes
self.new_aggregate = None
self.filtered_singles = None
self.data = None
self.average = None
def get_data(self):
return self.data
def __reset(self):
self.input.reset()
self.context_database.reset()
self.assorted_context_database.reset()
self.output.reset()
self.context_history.reset()
def reset(self):
"""reset is for garbage collection in multiple data simulation.
This is done for releasing memory for another simulation.
"""
self.__reset()
gc.collect()
#
# Sample
#
def get_sample(self):
return self.configuration("sample")
def get_sample_data(self):
sample = self.get_sample()
if sample is None:
return None # sampled_value = -2 # default value is -1
# [] works as an API
return sample[self.id]
#
# Input
#
def get_input_dictionary(self):
return self.input.dictionary
def initalize_before_iteration(self):
"""initialization is needed for starting execution of dataflow
"""
self.input.reset()
#
# Configuration methods
#
def get_config(self):
return self.config
def set_config(self, config):
self.config = process_default_values(config, ContextAggregator.defaults)
return self.config
def get_current_sample(self):
return self.current_sample
def configuration(self, key):
if key in self.config:
return self.config[key]
else:
return None
#
# Database
#
#.........这里部分代码省略.........
开发者ID:prosseek,项目名称:Efficient-Decentralized-Context-Sharing-via-Aggregation-Simulation,代码行数:103,代码来源:context_aggregator.py