Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|># terminal_mv.py # # Copyright (C) 2014-2016 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # A terminal for one of the challenges class TerminalMv(TerminalCd): terminal_commands = ["ls", "cat", "cd", "mv"] def do_mv(self, line): ...
return completions
Here is a snippet: <|code_start|> "challenge": 24, "step": 4 }, { "challenge": 26, "step": 1, "exists": False }, { "challenge": 27, ...
"exists": False
Continue the code snippet: <|code_start|>#!/usr/bin/env python # # Copyright (C) 2014, 2015 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # A terminal for one of the challenges class TerminalChmod(TerminalNano): terminal_commands = [ "ls", "cat", "cd", "mv", "echo",...
def complete_chmod(self, text, line, begidx, endidx):
Continue the code snippet: <|code_start|> ] }, { "name": "grapes", "contents": get_story_file("grapes") }, { "name": "milk", "contents": get_story_file("milk") }, { "name": "pie", "contents...
{
Next line prediction: <|code_start|># test_helper_functions.py # # Copyright (C) 2014-2016 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # Test helper functions @pytest.yield_fixture def test_env(): with EnvironmentVarGuard() as env: yield env def test_wrap_in_box...
" ----------------------- ",
Next line prediction: <|code_start|> @pytest.yield_fixture def test_env(): with EnvironmentVarGuard() as env: yield env def test_wrap_in_box(): output = wrap_in_box([ '{{gb:This is a long string}}', 'Short {{lb:string}}', ]) assert output == [ " ----------------------...
'en.UTF-8',
Predict the next line after this snippet: <|code_start|># clearing.py # # Copyright (C) 2014-2017 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # house = { "name": "house", "children": [ { "name": "Swordmaster", "contents": get_story_file("swo...
"exists": False
Based on the snippet: <|code_start|> chest = { "name": "chest", "children": [ { "name": "scroll", "contents": get_story_file("scroll"), }, { "name": "torn-note", "contents": get_story_file("torn-note") } ], "challenges": [ ...
"step": 5
Predict the next line after this snippet: <|code_start|> _("What would you like to ask him?"), _("\n{{yb:1: \"How did you create your tools?\"}}"), _("{{yb:2: \"What's the next big tool you want to create?\"}}"), _("{{yb:3: \"Are you going into hiding now?\"}}"), _("{{yb:4: \"...
self.send_hint(text)
Given the following code snippet before the placeholder: <|code_start|># challenge_27.py # # Copyright (C) 2014-2016 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # A chapter of the story # ---------------------------------------------------------------------------------------- ...
end_dir = "~/town/east/shed-shop"
Given the following code snippet before the placeholder: <|code_start|> self._nano.set_goal_nano_filepath("~/town/east/shed-shop/best-horn-in-the-world.sh") def check_command(self, line): if line == "cat Eleanor": self.send_hint("\n" + self.companion_speech) else: ret...
_("{{rb:Use}} {{yb:./best-horn-in-the-world.sh}} {{rb:to run the script.}}")
Predict the next line for this snippet: <|code_start|># challenge_27.py # # Copyright (C) 2014-2016 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # A chapter of the story # ---------------------------------------------------------------------------------------- class Step1(Step...
hints = [
Next line prediction: <|code_start|> return 27, 3 class Step3(StepTemplateNano): story = [ _("Now time to test your script!"), _("Use {{yb:./best-horn-in-the-world.sh}} to run it.") ] start_dir = "~/town/east/shed-shop" end_dir = "~/town/east/shed-shop" commands = [ ...
_("\nBernard: {{Bb:\"The tool is working! Wonderful! " +\
Continue the code snippet: <|code_start|> def write_wordlist(self, wordlist, *path): wordlist.output('tsv', filename=self.get_path(*path, 'words'), ignore='all', prettify=False) print(self.get_path(*path)) def pinyin(self, chars): py = [] for char in chars: ...
def gbk_and_big5(self, chars):
Predict the next line for this snippet: <|code_start|> idx = 0 header = [h.lower() for h in data[0]] if key in header: idx = header.index(key.lower()) for line in data[1:]: d[line[idx]] = OrderedDict(zip( [prefix+'_'+h if prefix else h for h in header], line)) ...
self.path = self.get_path('')
Predict the next line after this snippet: <|code_start|>#from pylexibank.util import with_sys_path _languages = load_languages(return_type='dict') def csv2dict(path, key='id', prefix=''): d = {} with UnicodeReader(path, delimiter='\t') as reader: <|code_end|> using the current file's imports: from clldutil...
data = list(reader)
Predict the next line after this snippet: <|code_start|> def md_sources(): sources = sorted(glob(cddb_path('datasets', '*', '__init__.py'))) text = '# Datasets in the CDDB\n' text += ' | ' .join(['DATASET', 'LANGUAGES', 'WORDS', 'CHARACTERS', 'STRUCTURES', 'TREES', 'INVENTORIES']) + '\n' te...
f.write(text)
Using the snippet: <|code_start|> @test.functional class TestARS(test.Case): def testNormal(self): mu = 5. sigma = 1. ars = ARS(Gauss(mu, sigma)) <|code_end|> , determine the next line of code. You have imports: import numpy import csb.test as test from csb.statistics.ars import ARS, Gau...
ars.initialize([mu - 1., mu + 1.1], z0=-10., zmax=30)
Continue the code snippet: <|code_start|> @test.functional class TestARS(test.Case): def testNormal(self): mu = 5. sigma = 1. ars = ARS(Gauss(mu, sigma)) ars.initialize([mu - 1., mu + 1.1], z0=-10., zmax=30) samples = numpy.array([ars.sample() for i in range(10000)]) ...
self.assertAlmostEqual(sigma, numpy.std(samples), delta=0.5)
Predict the next line after this snippet: <|code_start|> def testBoltzmann(self): e = numpy.linspace(-50, 1000, 1000) be = BoltzmannEnsemble(beta=1,) te = be.energy(e) for i in range(len(e)): self.assertEqual(e[i], te[i]) be = BoltzmannEnsemble(beta=0.00...
self.assertAlmostEqual(ee[i], te[i], delta=1e-5)
Given snippet: <|code_start|> tsallis = TsallisEnsemble(q=1.1, e_min= -50.) te = tsallis.energy(e) q = 1.1 ee = q / (q - 1.) * csb.numeric.log(1 + (q - 1) * (e + 50.)) - 50 for i in range(len(e)): self.assertAlmostEqual(ee[i], te[i], delta=1e-5) def tes...
test.Console()
Continue the code snippet: <|code_start|> try: __doc__ = open('README.rst', encoding="utf-8").read() except IOError: __doc__ = "" NAME = ROOT AUTHOR = "Michael Habeck et al." EMAIL = "ivan.kalev@gmail.com" URL = "http://github.com/csb-toolbox" SUMMARY = "Computational Structural Biology Toolbox" DESCRIPTION ...
def build():
Predict the next line after this snippet: <|code_start|> pass def on_epoch_end(self, epoch, epoch_log): pass def on_batch_begin(self, batch): pass def on_batch_end(self, batch, batch_log): pass def set_params(self, params): self.params = params def set_mod...
self._allow_unused_metric_testing = False
Here is a snippet: <|code_start|> """ MIT License Copyright (c) 2019 Intel ISL (Intel Intelligent Systems Lab) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including witho...
def load(self, path):
Given snippet: <|code_start|> """ MIT License Copyright (c) 2019 Intel ISL (Intel Intelligent Systems Lab) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without l...
class BaseModel(torch.nn.Module):
Based on the snippet: <|code_start|> """ MIT License Copyright (c) 2019 Intel ISL (Intel Intelligent Systems Lab) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including wi...
def load(self, path):
Given snippet: <|code_start|> if init_val is not None: self.layers[-1].linear.bias.data.fill_(init_val) def forward(self, x): x = self.embed(x) embed = x for idl, l in enumerate(self.layers): if idl % self.skip == 0 and idl > 0 and idl < len(self.layers) - 1...
def __init__(self, in_ch, out_ch, act_fn=None, norm=None):
Given the code snippet: <|code_start|> self.file_list = [] for g in gaps: file_list = sorted(glob(join(data_path, f'shuffle_False_gap_{g:02d}_*.pt'))) self.file_list += file_list frame_data_path = join(data_root, frame_prefix, track_name) ...
unit = 1.0
Here is a snippet: <|code_start|> self.add_module('up_%04d' % k, self.up_conv[-1]) ch_in = ch_in // 2 # This is for matching original unet implementation. self.up_conv += [Block(ch_in * 2, ch_in, padding=1, kernel_size=3, **conv_setup)] self....
x = self.output_conv(x)
Predict the next line after this snippet: <|code_start|># You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITI...
else:
Continue the code snippet: <|code_start|> if opt.tensorboard: if opt.tensorboard_keyword != 'none': [parent_dir, sub_dir] = logdir.split(f'/{opt.tensorboard_keyword}/') tf_logdir = os.path.join( parent_dir, opt.tensorboard_keyword, 'tensorboard', s...
Model = models.get_model(opt.net)
Given the following code snippet before the placeholder: <|code_start|> # Old saved model does not have epoch as additional values print(str(err)) epoch_loss_csv = os.path.join(logdir, 'epoch_loss.csv') if opt.resume == -1: try: ...
for p in net.parameters():
Here is a snippet: <|code_start|> os.system('rm -r ' + tf_logdir) tensorboard_logger = loggers.TensorBoardLogger( tf_logdir, opt.html_logger, allow_unused_fields='all' ) logger_list.append( tensorboard_logger ...
dataset_vali = dataset(opt, mode='vali', model=model)
Predict the next line for this snippet: <|code_start|> if opt.full_logdir is None: logdir = os.path.join(opt.logdir, exprdir, str(opt.expr_id)) else: logdir = opt.full_logdir if opt.resume == 0: if os.path.isdir(logdir): if opt.force_overwrite: print( ...
else:
Given snippet: <|code_start|> print(str_warning, 'training from scratch...') os.system('mkdir -p ' + logdir) else: opt_f_old = os.path.join(logdir, 'opt.pt') opt = options_train.overwrite(opt, opt_f_old, unique_opt_params) # Save opt if os.path.exists(os.p...
else:
Given the code snippet: <|code_start|># # 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 required by applicable law or agreed to in ...
exprdir += ('_' + opt.suffix.format(**vars(opt))) if opt.suffix != '' else ''
Here is a snippet: <|code_start|> device = torch.device('cpu') else: loadlib.set_gpu(opt.gpu) device = torch.device('cuda') global_rank = 0 # as if this is the master node else: if opt.multiprocess_distributed: opt.global_rank = opt.node_rank *...
del prev_best_data
Here is a snippet: <|code_start|>Dataset = datasets.get_dataset(opt_train.dataset) dataset = Dataset(opt_train, mode='vali', model=model) dataloader = torch.utils.data.DataLoader( dataset, batch_size=opt.batch_size, num_workers=opt.workers, pin_memory=True, drop_last=False, shuffle=False ) n_bat...
html_logger.training = False
Predict the next line after this snippet: <|code_start|> html_logger = loggers.HtmlLogger(html_summary_filepath) logger_list.append(html_logger) logger = loggers.ComposeLogger(logger_list) ################################################### print(str_stage, "Setting up models") Model = models.get_model(opt.net...
dataset,
Based on the snippet: <|code_start|> device = torch.device('cpu') else: loadlib.set_gpu(opt.gpu) device = torch.device('cuda') if opt.manual_seed is not None: loadlib.set_manual_seed(opt.manual_seed) ################################################### print(str_stage, "Setting up output directory") out...
html_summary_filepath = os.path.join(opt.output_dir, 'summary')
Using the snippet: <|code_start|># Copyright 2021 Google LLC # # 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 required by applicab...
opt.full_logdir = None
Given the following code snippet before the placeholder: <|code_start|> pin_memory=True, drop_last=False, shuffle=False ) n_batches = len(dataloader) dataiter = iter(dataloader) print(str_verbose, "Time spent in data IO initialization: %.2fs" % (time.time() - start_time)) print(str_verbose, "# test poi...
model.test_on_batch(i, batch)
Given the following code snippet before the placeholder: <|code_start|># Copyright 2021 Google LLC # # 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/LICEN...
t_embed = nn.Identity()
Based on the snippet: <|code_start|># Copyright 2021 Google LLC # # 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 required by appli...
xyz_embed = nn.Identity()
Given the code snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual('http://xp.to', shame[0]['url'])
Given snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', 'so...
provider.coverage.set([sc, go])
Based on the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') sp, *_ = State.objects.get_or_create(abbr='GO', name='São Paulo') prop...
self.assertEqual(200, self.resp.status_code)
Predict the next line for this snippet: <|code_start|> sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') sp, *_ = State.objects.get_or_create(abbr='GO', name='São Paulo') props_published = {'name': 'Xpto', ...
def test_contents(self):
Here is a snippet: <|code_start|> class TestGet(TestCase): def setUp(self): self.resp = self.client.get(resolve_url('new')) def test_get(self): self.assertEqual(200, self.resp.status_code) def test_type(self): self.assertEqual('text/html', self.resp['Content-Type'][0:9]) def...
self.assertTemplateUsed(self.resp, 'core/provider_form.html')
Predict the next line for this snippet: <|code_start|> class TestGet(TestCase): def setUp(self): self.resp = self.client.get(resolve_url('new')) def test_get(self): self.assertEqual(200, self.resp.status_code) def test_type(self): self.assertEqual('text/html', self.resp['Content-...
form = self.resp.context['form']
Given the code snippet: <|code_start|> class TestGet(TestCase): def setUp(self): self.resp = self.client.get(resolve_url('new')) def test_get(self): self.assertEqual(200, self.resp.status_code) def test_type(self): self.assertEqual('text/html', self.resp['Content-Type'][0:9]) ...
for text, count in tags:
Predict the next line for this snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') sp, *_ = State.objects.get_or_create(abbr='SP', name='São Pa...
with self.subTest():
Given snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') sp, *_ = State.objects.get_or_create(abbr='SP', name='São Paulo') props = {'n...
provider.coverage.set([sc, go])
Predict the next line for this snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp....
self.assertEqual('http://xp.to', fame[0]['url'])
Using the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual('application/json', self.resp['Content-Type'])
Based on the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
with self.subTest():
Based on the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertTemplateUsed(self.resp, 'markdown/shame.md')
Predict the next line for this snippet: <|code_start|> def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', 'sourc...
self.assertEqual('Lorem ipsum', fame[0]['other'])
Here is a snippet: <|code_start|> def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', 'source': 'http://twitter.c...
self.assertEqual('Lorem ipsum', fame[0]['other'])
Here is a snippet: <|code_start|> class TestPostInvalid(TestCase): def setUp(self): User.objects.create_superuser(username='two', password='', email='42@xp.to') sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiá...
resp = self.client.post(resolve_url('api:provider', self.provider.pk), invalid_data)
Predict the next line after this snippet: <|code_start|> class TestPostInvalid(TestCase): def setUp(self): User.objects.create_superuser(username='two', password='', email='42@xp.to') sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_crea...
invalid_data = {'name': 'Xpto', 'coverage': ['xp', 'to'], 'url': ''}
Continue the code snippet: <|code_start|> ordering = ['name'] class Provider(models.Model): FAME = 'F' SHAME = 'S' CATEGORIES = ((FAME, 'Hall of Fame (não utilizará limites/fraquia)'), (SHAME, 'Hall of Shame (utilizará limites/franquia)')) CATEGORIES_DICT = dict(CATEGORIES) ...
OTHER = 'O'
Continue the code snippet: <|code_start|> class TestProviderForm(TestCase): def test_form_has_fields(self): form = ProviderForm() fields = ['category', 'name', 'url', 'source', 'coverage', 'other'] self.assertSequenceEqual(list(form.fields), fields) def test_other_is_optional(self): ...
self.assertFalse(form.errors)
Predict the next line for this snippet: <|code_start|> class TestProviderForm(TestCase): def test_form_has_fields(self): form = ProviderForm() <|code_end|> with the help of current file imports: from django.test import TestCase from InternetSemLimites.core.forms import ProviderForm from InternetSemLimit...
fields = ['category', 'name', 'url', 'source', 'coverage', 'other']
Based on the snippet: <|code_start|> def setUp(self): User.objects.create_superuser(username='two', password='', email='42@xp.to') sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') data = {'name': 'Xpto...
def test_dont_save(self):
Predict the next line after this snippet: <|code_start|> class TestGet(TestCase): def setUp(self): self.resp = self.client.get(resolve_url('api:new')) def test_get(self): self.assertEqual(405, self.resp.status_code) <|code_end|> using the current file's imports: from django.contrib.auth.m...
class TestPostValid(TestCase):
Next line prediction: <|code_start|> props = {'name': 'Xpto', 'url': 'http://xp.to', 'source': 'http://twitter.com/xpto', 'category': Provider.FAME, 'other': 'Lorem ipsum', 'status': Provider.PUBLISHED} provider = Provid...
def test_no_content(self):
Predict the next line after this snippet: <|code_start|> 'category': Provider.FAME, 'other': 'Lorem ipsum', 'status': Provider.PUBLISHED} provider = Provider.objects.create(**props) provider.coverage.set([sc, go]) self.resp = self.client.get(reso...
fame = json_resp['hall-of-fame']
Using the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
for expected in data:
Using the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', <|code_end|> , d...
'source': 'http://twitter.com/xpto',
Continue the code snippet: <|code_start|> def fame(request): ctx = {'states': _fame_listed_by_states()} return _render_md(request, 'fame', ctx) <|code_end|> . Use current file imports: from django.shortcuts import render from InternetSemLimites.core.models import Provider, State and context (classes, funct...
def shame(request):
Predict the next line after this snippet: <|code_start|> class ProviderResource(ModelResource): class Meta: model = Provider class ProviderModelAdmin(ImportExportModelAdmin): resource_class = ProviderResource list_display = ('name', 'states', 'status', 'category', 'created_at', 'updated_at') ...
messages = (f'{count} provedor publicado.',
Predict the next line after this snippet: <|code_start|> def _providers_by_state(abbr): state = get_object_or_404(State, abbr=abbr.upper()) return state.provider_set def _to_json(providers_or_fame, shame=None): if shame: ctx = {'hall-of-fame': list(providers_or_fame), 'hall-of-shame...
return output
Given snippet: <|code_start|>def home(request): fame = _serialize_query(Provider.objects.fame()) shame = _serialize_query(Provider.objects.shame()) return _to_json(fame, shame) def fame(request): providers = _serialize_query(Provider.objects.fame()) return _to_json(providers) def shame(request):...
return _to_json(providers)
Using the snippet: <|code_start|> return HttpResponseRedirect(resolve_url('api:provider', provider.pk)) @csrf_exempt def provider_edit(request, pk): provider_original = get_object_or_404(Provider, pk=pk) provider_edited = deepcopy(provider_original) provider_edited.id = None provider_edited.edite...
return HttpResponseRedirect(resolve_url('api:provider', provider_edited.pk))
Predict the next line for this snippet: <|code_start|> class StateConverter: regex = '[\w]{2}' def to_python(self, value): return value.lower() def to_url(self, value): return value register_converter(StateConverter, 'state') app_name = 'api' <|code_end|> with the help of current ...
urlpatterns = [
Given the code snippet: <|code_start|> class StateConverter: regex = '[\w]{2}' def to_python(self, value): return value.lower() def to_url(self, value): return value register_converter(StateConverter, 'state') app_name = 'api' urlpatterns = [ path('', home, name='home'), pa...
]
Next line prediction: <|code_start|> class StateConverter: regex = '[\w]{2}' def to_python(self, value): return value.lower() def to_url(self, value): return value <|code_end|> . Use current file imports: (from django.urls import path, register_converter from InternetSemLimites.api.vi...
register_converter(StateConverter, 'state')
Here is a snippet: <|code_start|> class StateConverter: regex = '[\w]{2}' def to_python(self, value): return value.lower() def to_url(self, value): return value register_converter(StateConverter, 'state') app_name = 'api' urlpatterns = [ path('', home, name='home'), path('f...
]
Based on the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual('Xpto', fame[0]['name'])
Continue the code snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual(0, len(shame))
Continue the code snippet: <|code_start|> provider_new_args = {'model': Provider, 'form_class': ProviderForm, 'email_subject': '+1 InternetSemLimites'} provider_new = EmailAdminCreateView.as_view(**provider_new_args) provider_details = DetailView.as_view(model=Provider) def ...
return HttpResponseRedirect(resolve_url('api:home'))
Based on the snippet: <|code_start|> provider_new_args = {'model': Provider, 'form_class': ProviderForm, 'email_subject': '+1 InternetSemLimites'} provider_new = EmailAdminCreateView.as_view(**provider_new_args) provider_details = DetailView.as_view(model=Provider) def redir...
return HttpResponseRedirect(resolve_url('api:home'))
Next line prediction: <|code_start|> provider_new_args = {'model': Provider, 'form_class': ProviderForm, 'email_subject': '+1 InternetSemLimites'} provider_new = EmailAdminCreateView.as_view(**provider_new_args) provider_details = DetailView.as_view(model=Provider) def redir...
return HttpResponseRedirect(resolve_url('api:home'))
Given the following code snippet before the placeholder: <|code_start|> def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual('Lorem ipsum', shame[0]['other'])
Using the snippet: <|code_start|> class TestGet(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': 'http://xp.to', ...
self.assertEqual(1, len(shame))
Predict the next line for this snippet: <|code_start|> class TestProviderModel(TestCase): def setUp(self): sc, *_ = State.objects.get_or_create(abbr='SC', name='Santa Catarina') go, *_ = State.objects.get_or_create(abbr='GO', name='Goiás') props = {'name': 'Xpto', 'url': '...
def test_create(self):
Given snippet: <|code_start|># # Copyright (c) 2016 The Ontario Institute for Cancer Research. All rights reserved. # # This program and the accompanying materials are made available under the terms of the GNU Public License v3.0. # You should have received a copy of the GNU General Public License along with # this pro...
entry_points={
Next line prediction: <|code_start|> else: assert filename is None # Unable to download file as expected def start_server(): thread = stub_thread.stubThread(1, "TestThread") thread.start() def stop_server(): for thread in threading.enumerate(): thread.join() def download_test(file_...
if not result:
Given the code snippet: <|code_start|># # Copyright (c) 2016 The Ontario Institute for Cancer Research. All rights reserved. # # This program and the accompanying materials are made available under the terms of the GNU Public License v3.0. # You should have received a copy of the GNU General Public License along with #...
def run(self):
Continue the code snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (c) 2016 The Ontario Institute for Cancer Research. All rights reserved. # # This program and the accompanying materials are made available under the terms of the GNU Public License v3.0. # You should have received a copy o...
def check_access(self, access, name, docker=False, path='Default', password='Default', secret_key='Default', udt=True):
Given the code snippet: <|code_start|> def map(dataset, text, id=None): logging.info("OpenLSH > map() called.") start = datetime.datetime.utcnow() hashes = calculate_max_hashes(dataset.rows, dataset.bands) if len(dataset.random_seeds) < hashes: dataset.random_seeds = get_random_bits(hashes) ...
minhashes_in_band = [minhashes[band*dataset.rows + row] for row in xrange(dataset.rows)]
Next line prediction: <|code_start|> hashes = calculate_max_hashes(dataset.rows, dataset.bands) if len(dataset.random_seeds) < hashes: dataset.random_seeds = get_random_bits(hashes) dataset.put() sh_type = dataset.shingle_type modulo = dataset.minhash_modulo seeds = list(dataset.ran...
yield (key, values)
Predict the next line for this snippet: <|code_start|> buckets.append( (band * buckets_per_band) + hash(minhashes_in_band[0]) % buckets_per_band ) end = datetime.datetime.utcnow() if 0 == (start.second % 20): logging.info('id %s, length %d, time %d', id, len(text), int((end-start).total_sec...
for hno in xrange(hashes):
Given snippet: <|code_start|> def map(dataset, text, id=None): logging.info("OpenLSH > map() called.") start = datetime.datetime.utcnow() hashes = calculate_max_hashes(dataset.rows, dataset.bands) if len(dataset.random_seeds) < hashes: dataset.random_seeds = get_random_bits(hashes) dat...
modulo = dataset.minhash_modulo
Continue the code snippet: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) shingle_cache = Cache(max_size = 1) <|code_end|> . Use current file imports: impo...
max_bits = 32
Next line prediction: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) shingle_cache = Cache(max_size = 1) max_bits = 32 max_mask = 2**max_bits - 1 text_file_...
symbols = re.compile('\W+')
Continue the code snippet: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' <|code_end|> . Use current file imports: import sys, os, re, time, math, random, struct, zipfile, operator, csv, hashlib, uuid, pdb import logging fro...
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
Based on the snippet: <|code_start|> url_file_pattern = re.compile('^."id":"([^"]*)","url":"([^"]*)".*') class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler): def get(self, resource): <|code_end|> , predict the immediate next line with the help of imports: from google.appengine.ext.webapp import blobst...
blob_key = str(urllib.unquote(resource))
Using the snippet: <|code_start|> DEFAULT_SHINGLE_SIZE = 4 class ShingleType(object): W_SHINGLES = "w-shingles" K_SHINGLES = "k-shingles" @classmethod def is_valid(cls, type): if type == cls.W_SHINGLES or type == cls.K_SHINGLES: return True <|code_end|> , determine the next line of...
return False