Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> def tearDown(self): del self.dj self.requests_mock.stop() def run_case(self, case_filename, expected_dict=None): sample_path = os.path.join(self.SAMPLES_DIR, case_filename + ".json") result_path = os.path.join(self.RESULTS_DIR, case_filename + ...
assert_dict_equal(expected_dict, response_dict)
Here is a snippet: <|code_start|> self.catalog = pydatajson.readers.read_catalog( self.get_sample("full_data.json")) self.maxDiff = None self.longMessage = True self.requests_mock = requests_mock.Mocker() self.requests_mock.start() self.requests_mock.get(reques...
if expected_dict["status"] == "OK":
Given snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals, with_statement try: except ImportError: my_vcr = vcr.VCR(path_transformer=vcr.VCR.ensure_suffix('.yaml'), cassette_library_dir=os.path.join("tests", "cassetes"), record_...
self.maxDiff = None
Next line prediction: <|code_start|> self.dj = pydatajson.DataJson(self.get_sample("full_data.json")) self.catalog = pydatajson.readers.read_catalog( self.get_sample("full_data.json")) self.maxDiff = None self.longMessage = True self.requests_mock = requests_mock.Mocke...
self.requests_mock.head(requests_mock.ANY, exc=Timeout)
Predict the next line for this snippet: <|code_start|> "instance": None, "validator": "required", "path": [ "dataset", 0 ], "message": "%s is a required property" % jsonschema_str('description'), "error_code": 1, "validator_value": [ ...
],
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class UrlValidator(SimpleValidator): def __init__(self, catalog, verify_ssl, url_check_timeout, threads_count): super(UrlValidator, self).__init__(catalog) self.verify_ssl = verify_ssl self.url_check_timeout ...
return True not in matches, response.status_code
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class UrlValidator(SimpleValidator): def __init__(self, catalog, verify_ssl, url_check_timeout, threads_count): super(UrlValidator, self).__init__(catalog) self.verify_ssl = verify_ssl self.url_check_timeout ...
except Timeout:
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class UrlValidator(SimpleValidator): def __init__(self, catalog, verify_ssl, url_check_timeout, threads_count): super(UrlValidator, self).__init__(catalog) self.verify_ssl = verify_ssl self.url_check_timeo...
timeout=self.url_check_timeout,
Given the following code snippet before the placeholder: <|code_start|> def is_list_of_matching_dicts(list_of_dicts, expected_keys=None): """Comprueba que una lista esté compuesta únicamente por diccionarios, que comparten exactamente las mismas claves. Args: list_of_dicts (list): Lista de dicciona...
elements = [set(d.keys()) == expected_keys for d in list_of_dicts]
Given snippet: <|code_start|># -*- coding: utf-8 -*- class CustomRemoteCKAN(RemoteCKAN): def __init__(self, address, apikey=None, user_agent=None, get_only=False, verify_ssl=False, requests_timeout=REQUESTS_TIMEOUT): <|code_end|> , continue by predicting the next line. Consider current file im...
self.verify_ssl = verify_ssl
Based on the snippet: <|code_start|> def test_full_datasets_meta_error_cant(self): self.assertEqual(0, self.gen_full_data.datasets_meta_error_cant()) def test_empty_datasets_meta_error_cant(self): self.assertEqual(0, self.gen_empty.datasets_meta_error_cant()) def test_just_datasets_meta_ok_...
def test_empty_datasets_sin_datos_cant(self):
Based on the snippet: <|code_start|> "error_code": 2, "message": "%s is not valid under any of the given schemas" % jsonschema_str('datosATmodernizacion.gob.ar'), "validator": "anyOf", "path": ["publisher", "mbox"], "instance": "datosATmodernizacion.gob.ar", ...
"error_code": 2,
Given the following code snippet before the placeholder: <|code_start|> {"a": 1, "b": 2}, {"a": 1, "b": 2}, {"a": 1, "b": 2} ]) self.assertTrue(result) def test_is_list_of_matching_dicts_with_mismatched_dicts(self): """is_list_of_matching_dicts devuelve F...
)
Continue the code snippet: <|code_start|> "distribuciones_formatos_cant": { "SHP": 207, "ZIP": 122, "JPEG": 26, "PDF": 235, "CSV": 499, "XLS": 25, "RDF": 1, "JSON": 5 },...
'csv': 10,
Next line prediction: <|code_start|> class ListFormatter(ValidationResponseFormatter): def format(self): rows_catalog = [] validation_result = { "catalog_title": self.response["error"]["catalog"]["title"], "catalog_status": self.response["error"]["catalog"]["status"], ...
"dataset_identifier": dataset["identifier"],
Given snippet: <|code_start|> "errors": [ { "instance": None, "validator": "required", "path": [ "dataset", 0, ...
return distribution_error()
Predict the next line after this snippet: <|code_start|> origin_tz=self.dates['tz_london'], # GMT+1, dst_tz=self.dates['tz_new_york'] ) res_london = convert_iso_string_to_dst_timezone( date, origin_tz=self.dates['tz_london'], # GMT+1, dst_tz=s...
date,
Given the code snippet: <|code_start|> for s_theme in self.dataset.get('superTheme')] try: self.assertItemsEqual(super_themes, groups) except AttributeError: self.assertCountEqual(super_themes, groups) tags = [tag['name'] for tag in package['tags']...
for s_theme in self.dataset.get('superTheme')]
Continue the code snippet: <|code_start|># coding: utf-8 from __future__ import unicode_literals, absolute_import logger = logging.getLogger(__name__) class WeiXinHook(View): @csrf_exempt def dispatch(self, request, *args, **kwargs): signature = request.GET.get('signature', '') timestamp ...
logger.warning('Invalid signature when accessing %s', request.get_full_path())
Here is a snippet: <|code_start|> self.time_fields['day'] = day # 2016年12月14日周三在上海举办的2016 Google 开发者大会 # 2016年12月14日(周三)在上海举办的2016 Google 开发者大会 self.consume_word(u'(', u'(') if self.consume_word(u'周', u'星期'): self.consume_word(u'日', u'天') or self.consume_digit() ...
self.afternoon = True
Continue the code snippet: <|code_start|> <PicUrl><![CDATA[this is a url]]></PicUrl> <MediaId><![CDATA[media_id]]></MediaId> <MsgId>12345678901234563</MsgId> </xml> """ wechat_msg = self.build_wechat_msg(req_text) resp_xml = handle_message(wechat_msg) self....
<ToUserName><![CDATA[toUser]]></ToUserName>
Next line prediction: <|code_start|> text = '半个钟头后提醒我同步' reminder = self.parse(text) self.assertEqual(reminder.desc, text) self.assertEqual(reminder.title(), '同步') self.assertAlmostEqual((reminder.time - self.now).seconds, 30 * 60, delta=2) def test_parse_day_period(self): ...
for text in ('晚上零点提醒我 我姐生日', '凌晨零点提醒我 我姐生日'):
Predict the next line after this snippet: <|code_start|> reminder = self.parse(text) self.assertEqual(reminder.desc, text) self.assertEqual(reminder.event, '') self.assertEqual(reminder.title(), '闹钟') self.assertAlmostEqual((reminder.time - self.now).seconds, 60+59, delta=2) ...
self.assertEqual(reminder.desc, text)
Next line prediction: <|code_start|> self.assertEqual(reminder.time.year, self.now.year) self.assertEqual(reminder.time.month, 12) self.assertEqual(reminder.time.day, 16) self.assertEquals(reminder.time.hour, 9) self.assertEquals(reminder.time.minute, 10) def test_parse_repea...
self.assertEqual(self.now.month, reminder.time.month)
Continue the code snippet: <|code_start|> def test_parse_hour_period_with_half(self): text = '两个半小时后提醒我' reminder = self.parse(text) self.assertEqual(reminder.desc, text) self.assertEqual(reminder.title(), '闹钟') self.assertAlmostEqual((reminder.time - self.now).seconds, 150 * ...
text = '明晚八点去看电影'
Given snippet: <|code_start|># coding: utf-8 from __future__ import unicode_literals, absolute_import DISPLAY_POST = True @urlmatch(netloc=r'(.*\.)?mp\.weixin\.qq\.com$', path='.*showqrcode') def get_qr_image_mock(url, request): content = open(TPL_IMAGE_PATH, 'rb').read() headers = { 'Content-Type'...
self.user = WechatUser(openid='miao', nickname='miaomiao', subscribe=True, last_login=timezone.now())
Given the following code snippet before the placeholder: <|code_start|> DEBUG stdout: # (use "git add <file>..." to update what will be committed) DEBUG stdout: # (use "git checkout -- <file>..." to discard changes in working directory) DEBUG stdout: # DEBUG stdout: # ...
STDERR: --column[=<style>] list untracked files in columns
Given snippet: <|code_start|>## -*- encoding: utf-8 -*- r""" Git Interface This module provides a python interface to git. Essentially, it is a raw wrapper around calls to git and retuns the output as strings. EXAMPLES:: sage: git.execute('status', porcelain=True) DEBUG cmd: git status --porcelain DEBUG ...
DEBUG stdout: ?? untracked_file
Given the code snippet: <|code_start|>r""" HTTP transport to the trac server AUTHORS: <|code_end|> , generate the next line using the imports in this file: import urllib.request import urllib.parse from xmlrpc.client import SafeTransport, Fault from .trac_error import \ TracInternalError, TracAuthenticationError...
- David Roe, Julian Rueth, Robert Bradshaw: initial version
Given the following code snippet before the placeholder: <|code_start|> exconf = { "environment" : "devel", "container" : { 'docker' : { 'image' : "python:2.7" } }, "name" : "TESTJOB", "service" : False, <|code_end|> , predict the next line using imports from the current file: from gen.apache.aurora.ap...
"max_task_failures" : 1,
Using the snippet: <|code_start|> class RandomTest(unittest.TestCase): def test_distribution(self): d = Random.Distribution() expected = { 'high': 256, 'low': 0, 'mode': None, 'name': 'triangular', 'scale': 1, } self.assert...
N = 100
Predict the next line after this snippet: <|code_start|> self.coordinates = (min_real+1j*min_imag, max_real+1j*min_imag, max_real+1j*max_imag, min_real+1j*max_imag) def __iter__(self): """ Returns ------- gen: generator A generator whic...
overlap_axes=None, avoid_origin=None):
Next line prediction: <|code_start|> self.coordinates = (min_real+1j*min_imag, max_real+1j*min_imag, max_real+1j*max_imag, min_real+1j*max_imag) def __iter__(self): """ Returns ------- gen: generator A generator which yields (s, w), whe...
overlap_axes=None, avoid_origin=None):
Given the code snippet: <|code_start|># OpenModes - An eigenmode solver for open electromagnetic resonantors # Copyright (C) 2013 David Powell # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundati...
num_faces_o = len(basis_o.mesh.polygons)
Predict the next line for this snippet: <|code_start|> transform_s = transform_o else: # calculate mutual impedance num_faces_s = len(basis_s.mesh.polygons) res = z_mfie_faces_mutual(nodes_o, basis_o.mesh.polygons, nodes_s, basis_s.mesh.polygons, ...
order='C').T).T)
Predict the next line for this snippet: <|code_start|> from __future__ import division def part_ranges_lowest(parent_part, basis_container): """Construct the slice objects for the parent part, iterating down only to the specified lowest level""" lowest = getattr(basis_container, 'lowest_parts', None) ...
ranges[part] = slice(start, stop)
Given the following code snippet before the placeholder: <|code_start|> return edges_array def triangles_sharing_nodes(self): """Return a set of all the triangles which share each node""" polygons = [OrderedSet() for _ in range(len(self.nodes))] for count, t_nodes in enumerate(...
@property
Predict the next line for this snippet: <|code_start|> np.roll(vertices, 2, axis=1))**2, axis=2)) @cached_property def closed_surface(self): """Whether the mesh represents a closed surface corresponding to a solid object""" edges, triangles_shared_by_edges = self.g...
all_polygons.append(mesh.polygons+node_offset)
Continue the code snippet: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. ...
sp = np.sin(phi)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ Created on Wed Jun 18 16:12:15 2014 @author: dap124 """ from __future__ import print_function def test_pickling_references(): """Test that references to parent objects survive the pickling and upickling process""" def ...
mesh_tol=mesh_tol)
Given snippet: <|code_start|> 2*(c*d - a*b), 0], [2*(b*d - a*c), 2*(c*d + a*b), a**2 + d**2 - b**2 - c**2, 0], [0, 0, 0, 1.0]]) self.transformation_matrix[:] = matrix.dot(self.transformation_matrix) ...
return transform[:3, :3].dot(self.mesh.nodes.T).T + transform[:3, 3]
Predict the next line after this snippet: <|code_start|> class SinglePart(Part): """A single part, which corresponds exactly to one set of basis functions""" def __init__(self, mesh, material=PecMaterial, location=None): Part.__init__(self, location) self.mesh = mesh self.material...
def iter_single(self):
Predict the next line for this snippet: <|code_start|> def __init__(self, location=None): super(Part, self).__init__() self.initial_location = location self.transformation_matrix = np.empty((4, 4)) self.reset() self.parent_ref = None def reset(self): """Reset th...
return self.parent_ref().complete_transformation.dot(
Continue the code snippet: <|code_start|> channel = self._requestable_channels[type]( props, **args) self._conn.add_channels([channel], signal=signal) if handle.get_type() != HANDLE_TYPE_NONE and type in self._channels: self._channels[type].setdefault(handle, []).append(c...
self._channels.setdefault(type, {})
Continue the code snippet: <|code_start|># modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY ...
def close(self):
Given the code snippet: <|code_start|># # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is dis...
self._requestables = list()
Predict the next line after this snippet: <|code_start|># # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # T...
self._requestables = list()
Continue the code snippet: <|code_start|># modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY ...
def close(self):
Given the following code snippet before the placeholder: <|code_start|> telepathy.CONNECTION_INTERFACE_CAPABILITIES : lambda x: self.GetCapabilities(x).items(), telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : lambda x: self.GetContactCapabilities(x).items() ...
handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
Given the code snippet: <|code_start|># Copyright (C) 2005,2006,2009,2010 Collabora Limited # Copyright (C) 2005,2006 Nokia Corporation # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; e...
def __int__(self):
Here is a snippet: <|code_start|># modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY...
self.enabled = False
Based on the snippet: <|code_start|> LEVELS = { logging.ERROR: DEBUG_LEVEL_ERROR, logging.FATAL: DEBUG_LEVEL_CRITICAL, logging.WARNING: DEBUG_LEVEL_WARNING, logging.INFO: DEBUG_LEVEL_INFO, logging.DEBUG: DEBUG_LEVEL_DEBUG, logging.NOTSET: DEBUG_LEVEL_DEBUG } D...
def _set_enabled(self, value):
Predict the next line for this snippet: <|code_start|> logging.INFO: DEBUG_LEVEL_INFO, logging.DEBUG: DEBUG_LEVEL_DEBUG, logging.NOTSET: DEBUG_LEVEL_DEBUG } DEBUG_MESSAGE_LIMIT = 800 class Debug(_Debug, DBusProperties, logging.Handler): def __init__(self, conn_manager, root=''): ...
def add_message(self, timestamp, name, level, msg):
Predict the next line for this snippet: <|code_start|> def get_record_level(self, record): return LEVELS[record.levelno] def get_record_name(self, record): name = record.name if name.contains("."): domain, category = record.name.split('.', 1) name = domain + "/" ...
lines[0] = self._buffer + lines[0]
Based on the snippet: <|code_start|> def get_record_level(self, record): return LEVELS[record.levelno] def get_record_name(self, record): name = record.name if name.contains("."): domain, category = record.name.split('.', 1) name = domain + "/" + category ...
self._buffer = lines[-1]
Given the code snippet: <|code_start|> if len(self._messages) >= DEBUG_MESSAGE_LIMIT: self._messages.pop() self._messages.append((timestamp, name, level, msg)) if self.enabled: self.NewDebugMessage(timestamp, name, level, msg) # Handle logging module messages def...
self._stderr = stderr
Predict the next line after this snippet: <|code_start|> logging.Handler.__init__(self) self._implement_property_get(DEBUG, {'Enabled': lambda: self.enabled}) self._implement_property_set(DEBUG, {'Enabled': self._set_enabled}) logging.getLogger(root).addHandler(self) #sys.stderr ...
def get_record_name(self, record):
Continue the code snippet: <|code_start|> logging.Handler.__init__(self) self._implement_property_get(DEBUG, {'Enabled': lambda: self.enabled}) self._implement_property_set(DEBUG, {'Enabled': self._set_enabled}) logging.getLogger(root).addHandler(self) #sys.stderr = StdErrWrapper...
def get_record_name(self, record):