本文整理匯總了Python中result.Result類的典型用法代碼示例。如果您正苦於以下問題:Python Result類的具體用法?Python Result怎麽用?Python Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Result類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_result_set
def create_result_set(self, reading_system, testsuite, user):
from result import Result
from score import Score, AccessibilityScore
from testsuite_app import helper_functions
last_updated = helper_functions.generate_timestamp()
result_set = ResultSet(reading_system = reading_system, testsuite=testsuite, last_updated = last_updated, user = user)
result_set.save()
print "Creating result set"
# create empty results for each test
tests = testsuite.get_tests()
for test in tests:
result = Result(result_set = result_set, test = test)
result.save()
# create empty scores for each category
categories = testsuite.get_categories()
for cat in categories:
if testsuite.testsuite_type == common.TESTSUITE_TYPE_DEFAULT:
score = Score(category = cat, result_set = result_set)
score.save()
else:
score = AccessibilityScore(category = cat, result_set = result_set)
score.save()
if testsuite.testsuite_type == common.TESTSUITE_TYPE_DEFAULT:
overall_score = Score(category = None, result_set = result_set)
overall_score.save()
else:
overall_score = AccessibilityScore(category = None, result_set = result_set)
overall_score.save()
result_set.visibility = reading_system.visibility
return result_set
示例2: test_sources_are_stored
def test_sources_are_stored(self):
r = Result()
r.add("foo", Source("handle", "what they twote about foo", "twitter.com/linktotweet"))
s = r.get_source_list("foo")
self.assertEqual(s[0].handle, "handle")
self.assertEqual(s[0].text, "what they twote about foo")
self.assertEqual(s[0].link, "twitter.com/linktotweet")
示例3: __init__
def __init__(self, data, model, learning_rate=0.01, l1_rate=0.0, l2_rate=0.0):
assert isinstance(data, Data)
assert isinstance(model, Model)
self.data = data
self.model = model
self.result = Result()
self.params_result = Result(os.path.join(self.result.dir, "params"))
weights = [p for p in self.model.params if "weight" in p.name or "filter" in p.name]
l1 = np.sum([abs(w).sum() for w in weights])
l2 = np.sum([(w ** 2).sum() for w in weights])
self._cost = function(
inputs=(self.model.input_symbol, self.model.answer_symbol),
outputs=self.model.cost(True) + l1_rate * l1 + l2_rate * l2,
updates=self._update(learning_rate),
)
self._train_error = function(
inputs=(self.model.input_symbol, self.model.answer_symbol), outputs=self.model.error(True), updates=[]
)
self._test_error = function(
inputs=(self.model.input_symbol, self.model.answer_symbol), outputs=self.model.error(False), updates=[]
)
示例4: parseScript
def parseScript(self, scriptURL):
result = Result(TBTAFParsingScriptStatus.SUCCESS, "Success")
file = None
try:
file = self._openFile(scriptURL)
self._parseFile(file, result)
if (result.status==TBTAFParsingScriptStatus.ERROR):
file.close()
##return result
else:
if (TBTAFInterpreter.OrchestratorReference is None):
result.status=TBTAFParsingScriptStatus.ERROR
result.message="Orchestrator Reference has not been set."
##return result
if(result.status==TBTAFParsingScriptStatus.SUCCESS):
self.startExecution(TBTAFInterpreter.OrchestratorReference)
#print result.status
#print result.message
except Exception as e:
#traceback.print_exc(e)
raise e
finally:
if(file is not None):
file.close()
return result
示例5: get_results
def get_results(self):
"""
This function reads the file saved by the simulator at the end of the simulation to retrieve results
:return: Dictionary containing simulation results
"""
# Retrieve filename
res = Result()
results = res.get_results(self.filename)
return results
示例6: collate_words
def collate_words(self, meme, sources):
"""Given a list of Sources and a Meme, populate a Result
object with matching words"""
regex = self._format_regex(meme)
result = Result()
for source in sources:
match = re.search(regex, source.text, re.IGNORECASE)
if match:
result.add(match.groups()[0].lower(), source)
#assumption: there was exactly one match
return result
示例7: run
def run(self):
while True:
rid = libimport.GetNextListenResult(self.iid)
if rid is not None:
function = libimport.GetNextListenResultFunction(self.iid).decode('ascii')
inparams = libimport.GetNextListenResultInParameter(self.iid)
params = libimport.GetNextListenResultParameter(self.iid)
request = Request(rid, function, inparams, None)
result = Result(self.iid, request)
result.set_params(params)
self.listen_q.put(result)
time.sleep(0.001)
示例8: main
def main(argv):
result = Result()
w1 = Worker(0.1, 100, result)
w1.start()
w1.join()
w2 = Worker(0.2, 200, result)
w2.start()
w2.join()
print result.get()
print "Done."
示例9: submit_result
def submit_result(self):
for result in self.get_results():
if result['score'] > settings.MIN_HOF_SCORE:
login = result['login']
if ' ' in login:
login = login.split(' ')[0]
lowest = yield Result.get_last(login, self.board_size)
if lowest is None or lowest.score < result['score']:
result = Result(
login=login,
score=result['score'],
board_size=self.board_size,
)
yield result.put()
示例10: __init__
def __init__(self, xml_state, target_dir, root_dir):
self.custom_args = None
self.label = None
self.root_dir = root_dir
self.requested_image_type = xml_state.get_build_type_name()
if self.requested_image_type == 'pxe':
self.requested_filesystem = xml_state.build_type.get_filesystem()
else:
self.requested_filesystem = self.requested_image_type
if not self.requested_filesystem:
raise KiwiFileSystemSetupError(
'No filesystem configured in %s type' %
self.requested_image_type
)
self.filename = ''.join(
[
target_dir, '/',
xml_state.xml_data.get_name(),
'.' + platform.machine(),
'-' + xml_state.get_image_version(),
'.', self.requested_filesystem
]
)
self.blocksize = xml_state.build_type.get_target_blocksize()
self.filesystem_setup = FileSystemSetup(xml_state, root_dir)
self.filesystems_no_device_node = [
'squashfs'
]
self.result = Result()
示例11: exit
def exit(self):
"""Exit the simulation and create a result file"""
self.logger.debug("Interruption: exit = " + str(eval(self.config.exit_condition)) +
" sim time = " + str(time.time() - self.config.t_init) + " timeout = " + str(
self.config.timeout))
self.config.t_end = time.time()
# Create a result instance and save
try:
results = Result(self.body)
self.logger.info(results)
results.save_results()
except Exception as e:
self.logger.error("Unable to create a result report. Caused by: " + str(e))
pass
示例12: ArchiveBuilder
class ArchiveBuilder(object):
"""
root archive image builder
"""
def __init__(self, xml_state, target_dir, root_dir):
self.root_dir = root_dir
self.target_dir = target_dir
self.xml_state = xml_state
self.requested_archive_type = xml_state.get_build_type_name()
self.result = Result()
self.filename = self.__target_file_for('tar.xz')
self.checksum = self.__target_file_for('md5')
def create(self):
supported_archives = Defaults.get_archive_image_types()
if self.requested_archive_type not in supported_archives:
raise KiwiArchiveSetupError(
'Unknown archive type: %s' % self.requested_archive_type
)
if self.requested_archive_type == 'tbz':
log.info('Creating XZ compressed tar archive')
archive = ArchiveTar(
self.__target_file_for('tar')
)
archive.create_xz_compressed(self.root_dir)
checksum = Checksum(self.filename)
log.info('--> Creating archive checksum')
checksum.md5(self.checksum)
self.result.add(
'root_archive', self.filename
)
self.result.add(
'root_archive_checksum', self.checksum
)
return self.result
def __target_file_for(self, suffix):
return ''.join(
[
self.target_dir, '/',
self.xml_state.xml_data.get_name(),
'.' + platform.machine(),
'-' + self.xml_state.get_image_version(),
'.', suffix
]
)
示例13: test_list_is_sorted
def test_list_is_sorted(self):
r = Result()
r.add("baz", None)
r.add("bar", None)
r.add("foo", None)
r.add("foo", None)
r.add("baz", None)
r.add("baz", None)
self.assertEqual(r.get_list(), [("baz", 3), ("foo", 2), ("bar", 1)])
示例14: __init__
def __init__(self, xml_state, target_dir, root_dir):
self.root_dir = root_dir
self.target_dir = target_dir
self.xml_state = xml_state
self.requested_archive_type = xml_state.get_build_type_name()
self.result = Result()
self.filename = self.__target_file_for('tar.xz')
self.checksum = self.__target_file_for('md5')
示例15: ContainerBuilder
class ContainerBuilder(object):
"""
container image builder
"""
def __init__(self, xml_state, target_dir, root_dir):
self.root_dir = root_dir
self.requested_container_name = xml_state.build_type.get_container()
self.requested_container_type = xml_state.get_build_type_name()
self.filename = ''.join(
[
target_dir, '/',
xml_state.xml_data.get_name(),
'.' + platform.machine(),
'-' + xml_state.get_image_version(),
'.', self.requested_container_type, '.tar.xz'
]
)
self.result = Result()
def create(self):
setup_options = {}
if self.requested_container_name:
setup_options['container_name'] = self.requested_container_name
container_setup = ContainerSetup(
self.requested_container_type, self.root_dir, setup_options
)
log.info('Setting up %s container', self.requested_container_type)
log.info(
'--> Container name: %s', container_setup.get_container_name()
)
container_setup.setup()
log.info(
'--> Creating container archive'
)
container_image = ContainerImage(
self.requested_container_type, self.root_dir
)
container_image.create(
self.filename
)
self.result.add(
'container', self.filename
)
return self.result