prompt large_stringlengths 72 9.34k | completion large_stringlengths 0 7.61k |
|---|---|
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | start |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | stop |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | summary |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | local_rank |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | start |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | stop |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | summary |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | template = {'HeatTemplateFormatVersion': '2012-12-12'}
config.cfg.CONF.set_override('max_template_size', 1024)
template['Resources'] = ['a'] * (config.cfg.CONF.max_template_size / 3)
limit = config.cfg.CONF.max_template_size |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | def setUp(self):
super(JsonToYamlTest, self).setUp()
self.expected_test_count = 2
self.longMessage = True
self.maxDiff = None
def test_convert_all_templates(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'templates')
... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | super(JsonToYamlTest, self).setUp()
self.expected_test_count = 2
self.longMessage = True
self.maxDiff = None |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'templates')
template_test_count = 0
for (json_str,
yml_str,
file_name) in self.convert_all_json_to_yaml(path):
self.compare_json_vs_yaml(json_str, yml_str, file_n... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | yml = template_format.parse(yml_str)
self.assertEqual(u'2012-12-12', yml[u'HeatTemplateFormatVersion'],
file_name)
self.assertFalse(u'AWSTemplateFormatVersion' in yml, file_name)
del(yml[u'HeatTemplateFormatVersion'])
jsn = template_format.parse(json_st... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | for path in os.listdir(dirpath):
if not path.endswith('.template') and not path.endswith('.json'):
continue
f = open(os.path.join(dirpath, path), 'r')
json_str = f.read()
yml_str = template_format.convert_json_to_yaml(json_str)
yield (... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | def _parse_template(self, tmpl_str, msg_str):
parse_ex = self.assertRaises(ValueError,
template_format.parse,
tmpl_str)
self.assertIn(msg_str, six.text_type(parse_ex))
def test_long_yaml(self):
template = {'HeatTe... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | parse_ex = self.assertRaises(ValueError,
template_format.parse,
tmpl_str)
self.assertIn(msg_str, six.text_type(parse_ex)) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | template = {'HeatTemplateFormatVersion': '2012-12-12'}
config.cfg.CONF.set_override('max_template_size', 1024)
template['Resources'] = ['a'] * (config.cfg.CONF.max_template_size / 3)
limit = config.cfg.CONF.max_template_size
long_yaml = yaml.safe_dump(template)
self.asser... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | yaml = ''
self._parse_template(yaml, 'Template format version not found')
yaml2 = '''Parameters: {}
Mappings: {}
Resources: {}
Outputs: {}
'''
self._parse_template(yaml2, 'Template format version not found') |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | tmpl_str = 'just string'
msg = 'The template is not a JSON object or YAML mapping.'
self._parse_template(tmpl_str, msg) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | tmpl_str = '{test'
msg = 'line 1, column 1'
self._parse_template(tmpl_str, msg) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | tmpl_str = '["foo" , "bar"]'
msg = 'The template is not a JSON object or YAML mapping.'
self._parse_template(tmpl_str, msg) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | tmpl_str = '{}'
msg = 'Template format version not found'
self._parse_template(tmpl_str, msg) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | tmpl_str = 'heat_template_version: 2013-05-23'
expected = {'heat_template_version': '2013-05-23'}
self.assertEqual(expected, template_format.parse(tmpl_str)) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | scenarios = [
('scanner', dict(raised_exception=yaml.scanner.ScannerError())),
('parser', dict(raised_exception=yaml.parser.ParserError())),
('reader',
dict(raised_exception=yaml.reader.ReaderError('', '', '', '', ''))),
]
def test_parse_to_value_exception(self):
te... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | text = 'not important'
with mock.patch.object(yaml, 'load') as yaml_loader:
yaml_loader.side_effect = self.raised_exception
self.assertRaises(ValueError,
template_format.parse, text) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | def setUp(self):
super(JsonYamlResolvedCompareTest, self).setUp()
self.longMessage = True
self.maxDiff = None
def load_template(self, file_name):
filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'templates', file_name)
... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | super(JsonYamlResolvedCompareTest, self).setUp()
self.longMessage = True
self.maxDiff = None |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'templates', file_name)
f = open(filepath)
t = template_format.parse(f.read())
f.close()
return t |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | t1 = self.load_template(json_file)
t2 = self.load_template(yaml_file)
del(t1[u'AWSTemplateFormatVersion'])
t1[u'HeatTemplateFormatVersion'] = t2[u'HeatTemplateFormatVersion']
stack1 = utils.parse_stack(t1, parameters)
stack2 = utils.parse_stack(t2, parameters)
# ... |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | self.compare_stacks('Neutron.template', 'Neutron.yaml', {}) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | self.compare_stacks('WordPress_Single_Instance.template',
'WordPress_Single_Instance.yaml',
{'KeyName': 'test'}) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | break |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | del(jsn[u'AWSTemplateFormatVersion']) |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | continue |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | setUp |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_convert_all_templates |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | compare_json_vs_yaml |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | convert_all_json_to_yaml |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | _parse_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_long_yaml |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_no_version_format |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_string_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_invalid_yaml_and_json_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_json_document |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_empty_json_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_yaml_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_parse_to_value_exception |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | setUp |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | load_template |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | compare_stacks |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_neutron_resolved |
<|file_name|>test_template_format.py<|end_file_name|><|fim▁begin|>#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | test_wordpress_resolved |
<|file_name|>product.py<|end_file_name|><|fim▁begin|><|fim▁hole|>#
# Copyright (C) 2014 Comunitea Servicios Tecnológicos All Rights Reserved
# $Kiko Sánchez <kiko@comunitea.com>$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public Li... | ############################################################################## |
<|file_name|>product.py<|end_file_name|><|fim▁begin|>##############################################################################
#
# Copyright (C) 2014 Comunitea Servicios Tecnológicos All Rights Reserved
# $Kiko Sánchez <kiko@comunitea.com>$
#
# This program is free software: you can redistribute it and/or... | ame = 'outlet.loss'
@api.multi
@api.depends('qty', 'price_outlet', 'price_unit')
def _get_outlet_loss(self):
for loss in self:
loss.total_lost = loss.qty*(loss.price_outlet-loss.price_unit)
product_id = fields.Many2one('product.product', 'Product')
price_unit = fields.Float... |
<|file_name|>product.py<|end_file_name|><|fim▁begin|>##############################################################################
#
# Copyright (C) 2014 Comunitea Servicios Tecnológicos All Rights Reserved
# $Kiko Sánchez <kiko@comunitea.com>$
#
# This program is free software: you can redistribute it and/or... | r loss in self:
loss.total_lost = loss.qty*(loss.price_outlet-loss.price_unit)
|
<|file_name|>product.py<|end_file_name|><|fim▁begin|>##############################################################################
#
# Copyright (C) 2014 Comunitea Servicios Tecnológicos All Rights Reserved
# $Kiko Sánchez <kiko@comunitea.com>$
#
# This program is free software: you can redistribute it and/or... | et_outlet_loss(s |
<|file_name|>svg_example.py<|end_file_name|><|fim▁begin|># Example made by OssiLehtinen
#
from svgpathtools import svg2paths, wsvg
import numpy as np
import uArmRobot<|fim▁hole|>import time
#Configure Serial Port
#serialport = "com3" # for windows
serialport = "/dev/ttyACM0" # for linux like system
# Co... | |
<|file_name|>svg_example.py<|end_file_name|><|fim▁begin|># Example made by OssiLehtinen
#
from svgpathtools import svg2paths, wsvg
import numpy as np
import uArmRobot
import time
#Configure Serial Port
#serialport = "com3" # for windows
serialport = "/dev/ttyACM0" # for linux like system
# Connect to uA... | for seg in path:
segcoords = []
for p in range(steps_per_seg+1):
cp = seg.point(float(p)/float(steps_per_seg))
segcoords.append([-np.real(cp)*scale+x_offset, np.imag(cp)*scale])
coords.append(segcoords) |
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>import collections
puzzle_input = (0,13,1,8,6,15)
test_inputs = [
([(0,3,6), 10], 0),
([(1,3,2)], 1),
([(2,1,3)], 10),
([(1,2,3)], 27),
([(2,3,1)], 78),
([(3,2,1)], 438),
([(3,1,2)], 1836),
# Expensive Tests
# ([(0,3,6), 300000... | turn = 0
turn_last_spoken = collections.defaultdict(int) |
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>import collections
puzzle_input = (0,13,1,8,6,15)
test_inputs = [
([(0,3,6), 10], 0),
([(1,3,2)], 1),
([(2,1,3)], 10),
([(1,2,3)], 27),
([(2,3,1)], 78),
([(3,2,1)], 438),
([(3,1,2)], 1836),
# Expensive Tests
# ([(0,3,6), 300000... | turn = 0
turn_last_spoken = collections.defaultdict(int)
prev_number = None
for value in input_:
turn_last_spoken[prev_number] = turn
prev_number = value
turn += 1
while turn < iterations:
current_number = turn_last_spoken[prev_number]
turn_last_spoken[prev_... |
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>import collections
puzzle_input = (0,13,1,8,6,15)
test_inputs = [
([(0,3,6), 10], 0),
([(1,3,2)], 1),
([(2,1,3)], 10),
([(1,2,3)], 27),
([(2,3,1)], 78),
([(3,2,1)], 438),
([(3,1,2)], 1836),
# Expensive Tests
# ([(0,3,6), 300000... | current_number = turn - current_number |
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>import collections
puzzle_input = (0,13,1,8,6,15)
test_inputs = [
([(0,3,6), 10], 0),
([(1,3,2)], 1),
([(2,1,3)], 10),
([(1,2,3)], 27),
([(2,3,1)], 78),
([(3,2,1)], 438),
([(3,1,2)], 1836),
# Expensive Tests
# ([(0,3,6), 300000... | iterate |
<|file_name|>bytenet_test.py<|end_file_name|><|fim▁begin|># coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#<|fim▁hole|># http://... | |
<|file_name|>bytenet_test.py<|end_file_name|><|fim▁begin|># coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | def testByteNet(self):
vocab_size = 9
x = np.random.random_integers(1, high=vocab_size - 1, size=(3, 5, 1, 1))
y = np.random.random_integers(1, high=vocab_size - 1, size=(3, 6, 1, 1))
hparams = bytenet.bytenet_base()
p_hparams = problem_hparams.test_problem_hparams(vocab_size, vocab_size)
with... |
<|file_name|>bytenet_test.py<|end_file_name|><|fim▁begin|># coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | vocab_size = 9
x = np.random.random_integers(1, high=vocab_size - 1, size=(3, 5, 1, 1))
y = np.random.random_integers(1, high=vocab_size - 1, size=(3, 6, 1, 1))
hparams = bytenet.bytenet_base()
p_hparams = problem_hparams.test_problem_hparams(vocab_size, vocab_size)
with self.test_session() as s... |
<|file_name|>bytenet_test.py<|end_file_name|><|fim▁begin|># coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | tf.test.main() |
<|file_name|>bytenet_test.py<|end_file_name|><|fim▁begin|># coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | testByteNet |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):<|fim▁hole|> elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(index):
_checkInput(index)
serie = "0 1 1 2 3 5 8".replace(" ", "")
return in... | if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index)) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
<|fim_middle|>
def fib_from_string(index):
_checkInput(index)
serie = "0 1 1 2 3 5 8".replace(" ", "")
return int(serie[index])
def fib_from_list(index):
_checkInput(index)
serie = [0,1,1,2,3,5,8]
return serie[... | if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__)) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | _checkInput(index)
serie = "0 1 1 2 3 5 8".replace(" ", "")
return int(serie[index]) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | _checkInput(index)
serie = [0,1,1,2,3,5,8]
return serie[index] |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | _checkInput(index)
current_number = current_index = 0
base = 1
while current_index < index:
old_base = current_number
current_number = current_number + base
base = old_base
current_index += 1
pass
return current_number |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | if index <= 1:
return index
return recursion(index - 1) + recursion(index - 2) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | _checkInput(index)
return recursion(index) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
<|fim_middle|>
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(index):
_checkInput(index)
serie = "0 1 1 ... | raise ValueError("Indice negativo non supportato [{}]".format(index)) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
<|fim_middle|>
def fib_from_string(index):
_checkInput(index)
serie = "0 1 1 2 3 5 8".repl... | raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__)) |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | return index |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def <|fim_middle|>(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(i... | _checkInput |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def <|fim_middle|>(index... | fib_from_string |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | fib_from_list |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | fib_from_algo |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | recursion |
<|file_name|>fibonacci.py<|end_file_name|><|fim▁begin|>def _checkInput(index):
if index < 0:
raise ValueError("Indice negativo non supportato [{}]".format(index))
elif type(index) != int:
raise TypeError("Inserire un intero [tipo input {}]".format(type(index).__name__))
def fib_from_string(inde... | fib_from_recursion_func |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():<|fim▁hole|> if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
return p
... | p = kivy_platform() |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
<|fim_middle|>
class Service(object):
def __init__(self):
osc.init()
self.last_update =... | p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
return p |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | def __init__(self):
osc.init()
self.last_update = 0
self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT)
osc.bind(self.oscid, self.pocket_connect, '/pocket/connect')
osc.bind(self.oscid, self.pocket_list, '/pocket/list')
osc.bind(self.oscid, self.pocket_mark... |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | osc.init()
self.last_update = 0
self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT)
osc.bind(self.oscid, self.pocket_connect, '/pocket/connect')
osc.bind(self.oscid, self.pocket_list, '/pocket/list')
osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_rea... |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | osc.sendMsg() |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | while self._run:
osc.readQueue(self.oscid)
sleep(.1) |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | if 'token' in kwargs:
self.token = kwargs['token']
else:
pocketclient.authorize(platform(), self.save_pocket_token) |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | self.token = {
'key': api_key,
'token': token,
'username': username
} |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | if not self.token:
if self.pocket_last_update:
pocketclient.get_items(self.
else:
pass
pass |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | pass |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
<|fim_middle|>
else... | return 'desktop' |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | return p |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | self.token = kwargs['token'] |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | pocketclient.authorize(platform(), self.save_pocket_token) |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | if self.pocket_last_update:
pocketclient.get_items(self.
else:
pass |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | pass |
<|file_name|>main.py<|end_file_name|><|fim▁begin|>from kivy.lib import osc
from time import sleep
import pocketclient
from kivy.utils import platform as kivy_platform
SERVICE_PORT = 4000
def platform():
p = kivy_platform()
if p.lower() in ('linux', 'waindows', 'osx'):
return 'desktop'
else:
... | Service().run() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.