Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line after this snippet: <|code_start|> BUCKET_NAME = "thesis-video-data" STORE_HOST = env("STORE_HOST", "localhost") ACCESS_KEY = env("STORE_ACCESS_KEY") SECRET_KEY = env("STORE_SECRET_KEY") class Uploader(object): def __init__(self): if STORE_HOST is None: raise Exception("Missing minio hos...
secret_key=SECRET_KEY,
Given snippet: <|code_start|> try: if not self.minio_client.bucket_exists(BUCKET_NAME): self.minio_client.make_bucket(BUCKET_NAME, location="us-east-1") self.minio_client.set_bucket_policy(BUCKET_NAME, "", Policy.READ_ONLY) except ResponseError as err: print(err) def upload_frames(self, project): ...
self.upload_images(source_path, remote_path)
Based on the snippet: <|code_start|> BUCKET_NAME = "thesis-video-data" STORE_HOST = env("STORE_HOST", "localhost") ACCESS_KEY = env("STORE_ACCESS_KEY") SECRET_KEY = env("STORE_SECRET_KEY") class Uploader(object): def __init__(self): if STORE_HOST is None: raise Exception("Missing minio host info") if ACCES...
print(err)
Given snippet: <|code_start|> raise Exception("Missing minio credentials") self.minio_client = Minio(STORE_HOST + ':9000', access_key=ACCESS_KEY, secret_key=SECRET_KEY, secure=False) try: if not self.minio_client.bucket_exist...
self.upload_images(source_path, remote_path)
Next line prediction: <|code_start|>#!/usr/bin/python class Subtitle(Model): def __init__(self, t1, t2, text, original_text=None, character=None): self.t1 = Timestamp(t1) if (type(t1) == int) else t1 self.t2 = Timestamp(t2) if (type(t2) == int) else t2 self.text = text <|code_end|> . Use current file imports:...
self.original_text = text if text is not None else original_text
Using the snippet: <|code_start|>#!/usr/bin/python class Subtitle(Model): def __init__(self, t1, t2, text, original_text=None, character=None): self.t1 = Timestamp(t1) if (type(t1) == int) else t1 self.t2 = Timestamp(t2) if (type(t2) == int) else t2 self.text = text self.original_text = text if text is not ...
self.character = character
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python class Subtitle(Model): def __init__(self, t1, t2, text, original_text=None, character=None): self.t1 = Timestamp(t1) if (type(t1) == int) else t1 self.t2 = Timestamp(t2) if (type(t2) == int) else t2 self.text = text self.original_text...
return "t1: {}, t2: {}, text: {}, character: {}".format(self.t1, self.t2, self.text, self.character)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/python class Subtitle(Model): def __init__(self, t1, t2, text, original_text=None, character=None): self.t1 = Timestamp(t1) if (type(t1) == int) else t1 self.t2 = Timestamp(t2) if (type(t2) == int) else t2 self.text = text self.original_text =...
def __str__(self):
Given the following code snippet before the placeholder: <|code_start|> hist = centroid_histogram(clt) cluster_centers = clt.cluster_centers_ bundle = sort_frequency_with_clusters(hist, cluster_centers) clusters = rearrange_cluster(bundle) return clusters def sort_frequency_with_clusters(hist, cluster_centers)...
def rearrange_cluster(colors):
Predict the next line after this snippet: <|code_start|> def colors_from_image(image_path, count): gbr_image = cv2.imread(image_path) rgb_image = cv2.cvtColor(gbr_image, cv2.COLOR_BGR2RGB) img = rgb_image.reshape((rgb_image.shape[0] * rgb_image.shape[1], 3)) clt = KMeans(n_clusters=count) clt.fit(img) hist ...
hist = [round(val, 4) for val in hist]
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- class ScriptEntity(Model): def __init__(self, character, text, type="speech"): self.character = character self.type = type self.original_text = text self.text = text.rstrip().replace('\n', ' ') if type == 'speech' else text def __str__(self): retu...
@classmethod
Using the snippet: <|code_start|> return min(d / len(s1), 1) def pretty_print_grid(alignment): grid = alignment.grid subtitle_index = alignment.vertical_index script_index = alignment.horizontal_index alignments = alignment.alignment_list def search_indexes(i, j): for alignment in alignments: if alignment ...
for column in range(len(grid[row])):
Predict the next line after this snippet: <|code_start|> class ScoreMatrix(object): def __init__(self, grid, traceback, distance_function): self.grid = grid self.traceback = traceback self.distance_function = distance_function def score(self, c1, c2): return self.distance_function(c1, c2) def binary_dist...
def pretty_print_grid(alignment):
Predict the next line after this snippet: <|code_start|> class ScoreMatrix(object): def __init__(self, grid, traceback, distance_function): self.grid = grid <|code_end|> using the current file's imports: import editdistance import numpy as np from scipy.spatial import distance as dist from tqdm import tqdm from ...
self.traceback = traceback
Using the snippet: <|code_start|> resp = urllib.request.urlopen(req) content = resp.read() return ElementTree.fromstring(content), {'chapter': 'http://jvance.com/2008/ChapterGrabber'} def parse_chapter_info(root, ns): title = root.find('chapter:title', ns).text ref = root.find('chapter:ref', ns) id = int(ref.fi...
return parsed_chapter_info
Predict the next line for this snippet: <|code_start|> c1.t2 = c2.t1 - Timestamp(1) # minus 1ms if i == last_index: c2.t2 = duration return chapters def run(project, title): results, ns = load_titles(title) print("<ID>\t<CONFIRMATIONS>\t\t<TITLE>") titles = parse_titles(results, ns) valid = False sele...
chapter_info.chapters = add_end_to_chapters(chapter_info.chapters, chapter_info.duration)
Given snippet: <|code_start|> for i, (c1, c2) in enumerate(windows): c1.t2 = c2.t1 - Timestamp(1) # minus 1ms if i == last_index: c2.t2 = duration return chapters def run(project, title): results, ns = load_titles(title) print("<ID>\t<CONFIRMATIONS>\t\t<TITLE>") titles = parse_titles(results, ns) vali...
chapter_info = chapter_infos[0]
Predict the next line after this snippet: <|code_start|> def __str__(self): return "{:>2}: {} - {}: {}".format(self.id, self.t1, self.t2, self.name) def __repr__(self): return "{:>2}: {} - {}: {}".format(self.id, self.t1, self.t2, self.name) def as_dict(self, camel=True): d = Model.as_dict(self) d["t1"] = s...
return ElementTree.fromstring(content), {'chapter': 'http://jvance.com/2008/ChapterGrabber'}
Given the code snippet: <|code_start|> local_base_path = StoragePath.local.base_path(self.identifier) create_directory(local_base_path) class Folder(Enum): frames = 1 keyframes = 2 keyframe_thumbnails = 3 spatio = 4 plots = 5 def __str__(self): return { Project.Folder.frames: "frames", Proj...
return {
Based on the snippet: <|code_start|> def __init__(self, title): self.name = title identifier = re.sub('[^a-zA-Z0-9-_*.]', ' ', title.lower()) self.identifier = identifier.replace(" ", "_") local_base_path = StoragePath.local.base_path(self.identifier) create_directory(local_base_path) class Folder(Enum):...
merged_subtitles = 4
Continue the code snippet: <|code_start|> is_web_page_fetched = False original_encoding = None while not is_web_page_fetched: # get the script's URL from the parameters if it was passed if script_url == '' and url is not None: script_url = url else: print('Please provide the URL of a movie script you wan...
raise
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class ShotModelTests(unittest.TestCase): def setUp(self): self._sut = Shot(0, 10, 0) def test_shot_model(self): assert self._sut.length == 10 assert self._sut.duration == 400 assert self._sut.keyframe.index == 0...
def test_camel_case(self):
Using the snippet: <|code_start|> BUCKET_NAME = "thesis-video-data" ACCESS_KEY = env("AWS_ACCESS_KEY") SECRET_KEY = env("AWS_SECRET_KEY") LOCATION = env("AWS_LOCATION") def connect_bucket(): print(ACCESS_KEY, SECRET_KEY) session = Session(aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECR...
return bucket
Next line prediction: <|code_start|> ACCESS_KEY = env("AWS_ACCESS_KEY") SECRET_KEY = env("AWS_SECRET_KEY") LOCATION = env("AWS_LOCATION") def connect_bucket(): print(ACCESS_KEY, SECRET_KEY) session = Session(aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY, regio...
def upload_keyframes(project):
Predict the next line for this snippet: <|code_start|> BUCKET_NAME = "thesis-video-data" ACCESS_KEY = env("AWS_ACCESS_KEY") SECRET_KEY = env("AWS_SECRET_KEY") LOCATION = env("AWS_LOCATION") def connect_bucket(): print(ACCESS_KEY, SECRET_KEY) session = Session(aws_access_key_id=ACCESS_KEY, aws_s...
region_name=LOCATION)
Predict the next line for this snippet: <|code_start|> source_path = project.folder_path(Project.Folder.keyframes) remote_path = project.folder_path(Project.Folder.keyframes, storage_env=StoragePath.remote) upload_images(source_path, remote_path) def upload_slices(project): source_path = project.folder_path(Proje...
data = open(path, 'rb')
Given the code snippet: <|code_start|> DISCOVERY_URL = 'https://{api}.googleapis.com/$discovery/rest?version={apiVersion}' def run(project, shots): def shot_to_keyframe_path(shot): <|code_end|> , generate the next line using the imports in this file: import base64 from os import path from tqdm import tqdm from go...
index = shot.keyframe.index
Next line prediction: <|code_start|> names = filter(lambda x: re.match(name_regex, x), l.split(' ')) # require at least first and last name if len(names) >= 2: # search by last name try: user = User.objects.get(last_name=names[-1]) ...
while user is None:
Based on the snippet: <|code_start|> register = template.Library() @register.filter @stringfilter def stripjs(value): stripped = re.compile(r'<script(?:\s[^>]*)?(>(?:.(?!/script>))*</script>|/>)', re.S).sub('', force_unicode(value)) return mark_safe(stripped) @register.filter def logged_in(user): if use...
def is_slc_leader(user):
Continue the code snippet: <|code_start|> class UserBlogFeed(Feed): description_template = "blogs/blog_rss.html" def get_object(self, request, **kwargs): return get_object_or_404(Member, pk=kwargs.get('pk', None)) def title(self, obj): return "STARS Blog: " + obj.user.first_name + " " + o...
def link(self, obj):
Predict the next line after this snippet: <|code_start|> class UserBlogFeed(Feed): description_template = "blogs/blog_rss.html" def get_object(self, request, **kwargs): return get_object_or_404(Member, pk=kwargs.get('pk', None)) def title(self, obj): return "STARS Blog: " + obj.user.first...
def title(self, obj):
Given the following code snippet before the placeholder: <|code_start|> post = models.TextField(help_text='HTML is allowed') tags = models.ManyToManyField(Tag, blank=True, related_name='blogposts') objects = BlogPostManager() @models.permalink def get_absolute_url(self...
self.image = None
Here is a snippet: <|code_start|> return os.path.join(PROJECT_IMAGE_FOLDER, str(instance.pk) + os.path.splitext(filename)[1].lower()) SPONSOR_IMAGE_FOLDER = 'sponsor' def make_sponsor_image_name(instance, filename): if instance.pk is None: raise Exception('save Sponsor instance before saving ImageField'...
)
Here is a snippet: <|code_start|>from __future__ import absolute_import from __future__ import print_function class PeerchatProxyClient(ProxyClient): cipher = None ##a little HACKy def connectionMade(self): self.peer.setPeer(self) print('writing crypt') self.transport.write('CRYPT des 1 %s\n...
ProxyClient.dataReceived(self, data)
Based on the snippet: <|code_start|> class DjangoRaceConditions(unittest.TestCase): def setUp(self): pass def test_getOrCreate(self): chan = Channel.objects.get(id=1) user = User.objects.get(login='Keb') chan.users.clear() def cbAdded(result, times): chan = Channel.objects...
dfr = deferToThread(chan.users.add, user).addCallback(cbAdded, 2)
Here is a snippet: <|code_start|>from __future__ import absolute_import class DjangoRaceConditions(unittest.TestCase): def setUp(self): <|code_end|> . Write the next line using the current file imports: from twisted.trial import unittest from twisted.internet.threads import deferToThread from twisted.internet imp...
pass
Next line prediction: <|code_start|> class UtilTest(unittest.TestCase): def test_sim_mat(self): def sim_func(a, b): return a * b items = [1,2,3,4] expected = np.array([ [1., 2., 3., 4.], [2., 1., 6., 8.], [3., 6., 1., 12.], [4., 8...
np.testing.assert_array_equal(sim_mat, expected)
Here is a snippet: <|code_start|># 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 CONDITIONS OF ANY KIND, either express or implied. # See the License for t...
The ndb module is already imported.
Predict the next line for this snippet: <|code_start|> def test_predict(self): X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) clustering = KMeans(k=5, embedded=False) self.assertRaises(RuntimeError, clustering.predict(X)) clustering.fit(X) y_pred = clustering.predict(X) self.assertEqua...
self.assertEqual('gmm', clustering._method())
Predict the next line for this snippet: <|code_start|> try: except ImportError: pass class KMeansTest(TestCase): def test_simple(self): clustering = KMeans(embedded=False) clustering.stop() @requireEmbedded def test_embedded(self): clustering = KMeans(embedded=True) def test_init(self): ...
self.assertEqual('euclidean', clustering.distance)
Given snippet: <|code_start|> class GMMTest(TestCase): def test_simple(self): clustering = GMM(embedded=False) clustering.stop() @requireEmbedded def test_embedded(self): clustering = GMM(embedded=True) def test_method(self): clustering = GMM(embedded=False) self.assertEqual('gmm', cluste...
self.assertEqual('simple', clustering.compressor_method)
Given the code snippet: <|code_start|> def print_usage(): print('JubaModel - Jubatus Low-Level Model Manipulation Tool') print() parser.print_help(get_stdio()[1]) # stdout print() print('Supported Formats:') print(' IN_FORMAT: auto | binary | json') print(' OUT_FORMAT: ...
return 1
Based on the snippet: <|code_start|> m.dump_text(f) except Exception as e: raise JubaModelError('{0}: failed to write model'.format(output), e) # Output config if output_config: try: with open(output_config, 'w') as f: f.write(m.system.config) except Exception...
parser.add_option('-O', '--output', type='str', default=None,
Based on the snippet: <|code_start|> m.dump_text(get_stdio()[1]) # stdout else: with open(output, 'w') as f: m.dump_text(f) except Exception as e: raise JubaModelError('{0}: failed to write model'.format(output), e) # Output config if output_config: try: ...
help='model input format (default: %default)')
Given snippet: <|code_start|> # Output config if output_config: try: with open(output_config, 'w') as f: f.write(m.system.config) except Exception as e: raise JubaModelError('{0}: failed to write config'.format(output_config), e) @classmethod def start(cls, args): U...
parser.add_option('-T', '--transform', type='str', default=None,
Predict the next line after this snippet: <|code_start|> loader = MergeChainLoader( ArrayLoader([[0,1],[2,3],[4,5]], ['v1','v2']), ArrayLoader([[0,1],[2,3],[4,5]], ['v3','v4']), ) for row in loader: self.assertEqual(set(['v1','v2','v3','v4']), set(row.keys())) if row['v1'] == 0: ...
if row['v1'] == 0:
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class MergeChainLoaderTest(TestCase): def test_simple(self): loader = MergeChainLoader( ArrayLoader([[0,1],[2,3],[4,5]], ['v1','v2']), ArrayLoader([[0,1],[...
self.fail('unexpected row: {0}'.format(row))
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class MergeChainLoaderTest(TestCase): def test_simple(self): loader = MergeChainLoader( ArrayLoader([[0,1],[2,3],[4,5]], ['v1','v2']), ArrayLoader([[0,1],[2,3],[4...
self.assertEqual(1, row['v4'])
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class MergeChainLoaderTest(TestCase): def test_simple(self): loader = MergeChainLoader( ArrayLoader([[0,1],[2,3],[4,5]], ['v1'...
)
Continue the code snippet: <|code_start|> class MergeChainLoaderTest(TestCase): def test_simple(self): loader = MergeChainLoader( ArrayLoader([[0,1],[2,3],[4,5]], ['v1','v2']), ArrayLoader([[0,1],[2,3],[4,5]], ['v3','v4']), ) for row in loader: self.assertEqual(set(['v1','v2','v3','v4']...
{1: '_test1', 3: '_test3', 5: '_test5'}
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class NearestNeighborCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , continue by predicting the next line. Consider current file imports: from jubatus.nearest_nei...
return 'nearest_neighbor'
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class GraphCLI(GenericCLI): @classmethod <|code_end|> . Use current file imports: from jubatus.graph.types import * from .generic import GenericCLI from ..args impor...
def _name(cls):
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class GraphCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> with the help of current file imports: from jubatus.graph.types import * from ....
return 'graph'
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class GraphCLI(GenericCLI): @classmethod def _name(cls): return 'graph' @Arguments() <|code_end|> . Write the next line using the current file imports: from jubatus...
def do_create_node(self):
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class StatCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , generate the next line using the imports in this file: from jubatus.stat.types import * from .g...
return 'stat'
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class StatCLI(GenericCLI): @classmethod def _name(cls): return 'stat' @Arguments(str, float) <|code_end|> . Use current file imports: (from jubatus.stat.types im...
def do_push(self, key, value):
Predict the next line for this snippet: <|code_start|> USAGE = ''' jubash [--host HOST] [--port PORT] [--cluster CLUSTER] [--service SERVICE] [--command COMMAND] [--keepalive] [--fail-fast] [--prompt PROMPT] [--verbose] [--debug] [--help] [script ...]''' EPILOG = ' script .....
help='use customized shell prompt (default: %default)')
Given the code snippet: <|code_start|> print('Jubash - Jubatus Shell') print() parser.print_help(get_stdio()[1]) # stdout print() print('Available Services:') print(' {0}'.format(', '.join(services))) (args, scripts) = parser.parse_args(args) # Failed to parse options. ...
print_usage()
Predict the next line after this snippet: <|code_start|> def print_usage(): print('Jubash - Jubatus Shell') print() parser.print_help(get_stdio()[1]) # stdout print() print('Available Services:') print(' {0}'.format(', '.join(services))) (args, scripts) = parser.parse_args...
if args.service is not None and args.service not in services:
Next line prediction: <|code_start|> # Create shell instance. shell = JubaShell( host=args.host, port=args.port, cluster=args.cluster, service=args.service, timeout=args.timeout, keepalive=args.keepalive, verbose=args.verbose, prompt=args.prompt...
if args.debug: raise
Next line prediction: <|code_start|> def start(cls, args): USAGE = ''' jubash [--host HOST] [--port PORT] [--cluster CLUSTER] [--service SERVICE] [--command COMMAND] [--keepalive] [--fail-fast] [--prompt PROMPT] [--verbose] [--debug] [--help] [script ...]''' EPILOG = ' scr...
parser.add_option('-p', '--prompt', type='string', default=JubaShell._PS,
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class RegressionCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , predict the next line using imports from the current file...
return 'regression'
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class RegressionCLI(GenericCLI): @classmethod <|code_end|> using the current file's imports: from jubatus.regression.types import * from .generic imp...
def _name(cls):
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class RegressionCLI(GenericCLI): @classmethod def _name(cls): return 'regression' @Arguments(float, TDatum) <|code_end|> . Write the next line using the current file...
def do_train(self, score, d):
Continue the code snippet: <|code_start|> connection.commit() connection.close() def test_simple(self): loader = PostgreSQLoader(self.auth, table='test') for row in loader: self.assertEqual(set(['id','num', 'data']), set(row.keys())) if row['id'] == 1: self.assertEqual(100, row['nu...
elif row['id'] == 3:
Using the snippet: <|code_start|> from __future__ import absolute_import, division, print_function, unicode_literals class PostgreSQLoaderTest(TestCase): auth = PostgreSQLAuthHandler(user='postgres', password='postgres', host='localhost', port='5432') def setUp(self): print("setUp") connection = psycop...
cursor.execute("CREATE TABLE test2 (id serial PRIMARY KEY, num integer, data varchar);")
Using the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class WeightCLI(GenericCLI): @classmethod <|code_end|> , determine the next line of code. You have imports: from jubatus.weight.types import * from .generic import GenericCL...
def _name(cls):
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class WeightCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> . Use current file imports: (from jubatus.weight.types import * from .generic import GenericCLI f...
return 'weight'
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BanditCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> . Write the next line using the current file imports: from jubatus.bandit.types import * from .gener...
return 'bandit'
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BanditCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , continue by predicting the next line. Consider current file imports: from jubatus.bandit.types import ...
return 'bandit'
Continue the code snippet: <|code_start|># This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default...
'sphinx.ext.viewcode',
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BurstCLI(GenericCLI): @classmethod def _name(cls): return 'burst' def _clear_cache(self): <|code_end|> , generate the next line using the imports in this...
self._cached_keywords = set()
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BurstCLI(GenericCLI): @classmethod def _name(cls): return 'burst' <|code_end|> . Use current file imports: (import time from jubatus.burst.types import * fr...
def _clear_cache(self):
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BurstCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , generate the next line using the imports in this file: import time from jubatus.burst.types i...
return 'burst'
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class BurstCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> , predict the next line using imports from the current file: i...
return 'burst'
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class ClusteringCLI(GenericCLI): @classmethod <|code_end|> , generate the next line using the imports in this file: from jubatus.clustering.types import * from .generic...
def _name(cls):
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class ClusteringCLI(GenericCLI): @classmethod def _name(cls): return 'clustering' @Arguments(str, TDatum) <|code_end|> , continue by predicting the next line. Consider c...
def do_push(self, point_id, d):
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class AnomalyCLI(GenericCLI): @classmethod <|code_end|> . Use current file imports: from jubatus.anomaly.types import * from .generic import GenericCLI from ..args i...
def _name(cls):
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class AnomalyCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> . Write the next line using the current file imports: from jubatus.anomaly.types import * from .gen...
return 'anomaly'
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class ClassifierCLI(GenericCLI): @classmethod def _name(cls): <|code_end|> . Write the next line using the current file imports: from jubatus.classifier.types import * fro...
return 'classifier'
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class ClassifierCLI(GenericCLI): @classmethod <|code_end|> . Write the next line using the current file imports: from jubatus.classifier.types import * from .generic import ...
def _name(cls):
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals class ClassifierCLI(GenericCLI): @classmethod def _name(cls): return 'classifier' <|code_end|> . Use current file imports: from jubatus.classifier.types impor...
def _clear_cache(self):
Given snippet: <|code_start|> self.assertTrue(classifier.clf_ is not None) self.assertEqual(classifier.fitted_, True) classifier.stop() @requireEmbedded def test_predict(self): X = np.array([[1,1], [0,0]]) y = np.array([1,2]) classifier = NearestNeighborsClassifier() self.assertRaises(Ru...
for param in params:
Predict the next line for this snippet: <|code_start|> } classifier = LinearClassifier(**params) self.assertDictEqual(params, classifier.get_params()) classifier.stop() @requireEmbedded def test_set_params(self): params = { 'method': 'CW', 'regularization_weight': 5.0, 'softma...
classifier.save(name)
Next line prediction: <|code_start|> regression = NearestNeighborsRegression(embedded=True) @requireEmbedded def test_launch_regression(self): methods = ['euclid_lsh', 'lsh', 'minhash', 'euclidean', 'cosine'] def launch_regression(method): regression = NearestNeighborsRegression(method=method) ...
regression.fit(X, y)
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals try: except ImportError: pass class LinearRegressionTest(TestCase): def test_simple(self): regression = LinearRegression() regression.stop() @requireEmbedded ...
for method in methods:
Continue the code snippet: <|code_start|> """ if self._sh._verbose: print(msg) @property def client(self): """ Returns the client instance. """ return self._sh.get_client() ################################################################# # Built-in shell commands ##############...
def shell_command(self, param):
Predict the next line after this snippet: <|code_start|> """ Outputs logs only when in verbose mode. """ if self._sh._verbose: print(msg) @property def client(self): """ Returns the client instance. """ return self._sh.get_client() ###########################################...
)
Here is a snippet: <|code_start|> class DefaultLoader(object): def get_substitutes(self, obj, path, theme): if isinstance(obj, BaseForm): return {'path': path.strip("/"), 'theme': theme, 'form': normalize(type(obj).__name__)} elif isinstance(obj...
substitutes = self.get_substitutes(obj, path, theme)
Given snippet: <|code_start|> class DefaultLoader(object): def get_substitutes(self, obj, path, theme): if isinstance(obj, BaseForm): <|code_end|> , continue by predicting the next line. Consider current file imports: import re from django.forms.forms import BaseForm, BoundField from django.forms.formse...
return {'path': path.strip("/"),
Predict the next line for this snippet: <|code_start|> @silhouette_tag("mock") class MockTag(BaseSilhouette): def get_extra_context(self): ctx = {"obj": self.obj} # merge if any "cascaded_*" attributes in context attrs = self.merge_attrs(self.cascaded_attrs('cascaded'), self.kwargs) ...
ctx.update(attrs)
Continue the code snippet: <|code_start|> self.form = MockForm({}) self.context = Context({"form": self.form}) def tearDown(self): self.form = None self.context = None clear_app_settings_cache() def test_field(self): template_source = """{% load silhouette_tags %...
template_target = ""
Predict the next line after this snippet: <|code_start|> def test_form_fields_missing_template(self): template_source = """{% load silhouette_tags %}{% form_fields form class="form-fields" template="does/not/exist.html" %}""" with self.assertRaises(TemplateDoesNotExist): get_template_fro...
self.form = None
Predict the next line for this snippet: <|code_start|> @override_settings(SILHOUETTE_PATH="test_tags/formsets") class TestFormsetTags(SimpleTestCase): def setUp(self): self.form = MockForm({}) self.formset = MockFormSet(data={'form-TOTAL_FORMS': '2', 'form-...
template_target = """<ul><li>Please submit 1 or fewer forms.</li></ul>"""
Predict the next line for this snippet: <|code_start|> self.assertEqual("silhouette/theme/mock_form", tag.render(self.context)) def test_theme_override(self): tag = MockTag(self.context, self.form, theme="theme2") self.assertEqual("silhouette/theme2/mock_form", tag.render(self.context)) ...
def test_cascaded_attributes(self):
Continue the code snippet: <|code_start|> PATH = 'test_loaders' THEME = 'loader' PATTERNS = { "test_form": ( "{path}/{theme}/{form}.html", ), "test_formset": ( "{path}/{theme}/{formset}.html", ), "test_field": ( "{path}/{theme}/{form}-{field}-{widget}.html", ), "...
class TestLoaders(unittest.TestCase):
Given snippet: <|code_start|> ), "test_fallback": ( "{path}/{theme}/does-not-exist-1-{form}.html", "{path}/{theme}/does-not-exist-2-{form}.html", "{path}/{theme}/fallback-{form}.html", ), "test_notfound": ( "{path}/{theme}/does-not-exist-1.html", "{path}/{theme}/do...
def test_get_template_using_fallback(self):
Given the following code snippet before the placeholder: <|code_start|>try: except ImportError: # pragma: nocover try: except ImportError: PATH = 'test_loaders' THEME = 'loader' PATTERNS = { "test_form": ( "{path}/{theme}/{form}.html", <|code_end|> , predict the next line using imports from the curre...
),
Based on the snippet: <|code_start|> def test_is_number_input(self): self.assertWidgetFilterTruth(silhouette_filters.is_number_input, {'number_input'}) def test_is_email_input(self): self.assertWidgetFilterTruth(silhouette_filters.is_email_input, {'email_input'}) def test_is_url_input(self)...
def test_is_time_input(self):
Here is a snippet: <|code_start|> self.assertAllTrue(fields, test_func) self.assertAllFalse(set(self.form.fields) - set(fields), test_func) def test_is_text_input(self): self.assertWidgetFilterTruth(silhouette_filters.is_text_input, {'text_input', 'email_input', 'url_input', 'number_input', ...
def test_is_date_input(self):