Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|> class ArrayCreateNode(Scene): def run(self, **kwargs): data_generator = kwargs['data_generator'] array = kwargs['container'] array.init(data_generator.quantity()) <|code_end|> . Use current file imports: (from alvi.client.containers import Array from al...
for i, value in enumerate(data_generator.values):
Predict the next line after this snippet: <|code_start|> class ArrayCreateNode(Scene): def run(self, **kwargs): data_generator = kwargs['data_generator'] array = kwargs['container'] array.init(data_generator.quantity()) for i, value in enumerate(data_generator.values): a...
def container_class(cls):
Based on the snippet: <|code_start|> class TreeMarker(TreeCreateNode): def run(self, **kwargs): super().run(**kwargs) tree = kwargs['container'] #TODO removing marker0 variable causes test to fail #looks like pipe message (see api.Pipe) is garbage collected too soon #it is w...
tree.sync()
Continue the code snippet: <|code_start|> class MergeSort(Sort): def merge(self, array, left, mid, right): temp = [] for i in range(left, right): temp.append(array[i]) i = 0 j = right - mid k = 0 while k < len(temp): <|code_end|> . Use current file import...
if i >= mid - left:
Given the following code snippet before the placeholder: <|code_start|> class SequencedDataGenerator(DataGenerator): class Form(DataGenerator.Form): descending = forms.BooleanField(label="Descending", initial=True, required=False) def _values(self): return ((self.quantity()-i-1 if self.descend...
@property
Predict the next line for this snippet: <|code_start|> class GraphCreateNode(Scene): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.nodes = [] def run(self, **kwargs): data_generator = kwargs['data_generator'] graph = kwargs['container'] <|code_end|...
value = next(data_generator.values)
Predict the next line for this snippet: <|code_start|> class GraphCreateNode(Scene): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.nodes = [] def run(self, **kwargs): data_generator = kwargs['data_generator'] <|code_end|> with the help of current file imp...
graph = kwargs['container']
Using the snippet: <|code_start|> class TraverseTreeBreadthFirst(CreateTree): def traverse(self, tree, node, traversed_marker, frontier_marker): frontier = deque() frontier.append(node) frontier_marker.append(node) tree.sync() <|code_end|> , determine the next line of code. You have...
while frontier:
Based on the snippet: <|code_start|> class TreeCreateNode(Scene): class Form(Scene.Form): parents = forms.CharField(initial="0, 0, 1, 1, 4, 4") def __init__(self, *args, **kwargs): <|code_end|> , predict the immediate next line with the help of imports: from alvi.client.scenes.base import Scene from ...
super().__init__(*args, **kwargs)
Predict the next line for this snippet: <|code_start|> class TreeCreateNode(Scene): class Form(Scene.Form): parents = forms.CharField(initial="0, 0, 1, 1, 4, 4") def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.nodes = [] def run(self, **kwargs): ...
options = kwargs['options']
Predict the next line after this snippet: <|code_start|> class TreeAppendAndInsert(TreeCreateNode): def run(self, **kwargs): super().run(**kwargs) tree = kwargs['container'] self.nodes[2].children.append(self.nodes[4]) tree.sync() self.nodes[2].children.insert(0, self.nodes[...
if __name__ == "__main__":
Continue the code snippet: <|code_start|> class SelectionSort(Sort): def sort(self, **kwargs): array = kwargs['container'] data_generator = kwargs['data_generator'] min_marker = array.create_marker("min", 0) current_marker = array.create_marker("current", 0) for current in r...
min = j
Given the code snippet: <|code_start|> class Quicksort(Sort): def __init__(self): self.qs_left = None self.qs_right = None self.part_partby = None self.part_i = None self.part_j = None def sort(self, **kwargs): array = kwargs['container'] self.qs_left = ...
def _partition(self, A, p, r):
Continue the code snippet: <|code_start|> class TestRandom(unittest.TestCase): def test(self): generator = RandomDataGenerator(dict(n=8)) <|code_end|> . Use current file imports: import unittest from alvi.client.data_generators.random import RandomDataGenerator and context (classes, functions, or code) f...
self.assertEquals(len(list(generator.values)), 8)
Based on the snippet: <|code_start|> logger = logging.getLogger(__name__) class TestGraph(TestContainer): def test_create_node(self): graph_page = pages.Graph(self._browser.driver, "GraphCreateNode") graph_page.run(options=dict(n=4)) self.assertEqual(4, len(graph_page.svg.nodes), "create_...
self.assertEqual(10, updated, "update_node does not work properly")
Predict the next line for this snippet: <|code_start|> # add any special contexts for actions (template snippets to include defined by ref to url param in template) if action == self.PARAM_STR_ACTION_NEW_ACCOUNT: # new account return self.create_or_edit_account(request) elif action =...
return self.account_view(request, account_id=account_id)
Predict the next line after this snippet: <|code_start|> 'default_site_logo_url': '/', 'default_footer_text': _('~ Aninstance Invoicing created by Dan Bright, at ' '<a href="https://www.aninstance.com">www.aninstance.com</a> | ' '<a href="...
'default_template_frag_cache_timeout': settings.DEFAULT_CACHES_TTL,
Based on the snippet: <|code_start|> urlpatterns = [ url(r'^$', views.Invoicing.as_view(), name='invoicing'), ] if settings.DEBUG: <|code_end|> , predict the immediate next line with the help of imports: from django.conf.urls import url, include from invoicing import views from django.conf.urls.static import stat...
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Here is a snippet: <|code_start|> ''' note: pass functions like uuid.uuid4 and datatime.utcnow WITHOUT parentheses, so func called on each new instance, than being called once when model imported and the value being used for every instance created''' date_added = models.DateTimeField(default=timezone.now, b...
verbose_name='Email notifications')
Next line prediction: <|code_start|> url(r'^invoicing/', include('invoicing.urls')), # Admin section url(r'^adminardo/', admin.site.urls), # Search url(r'^search/?$', search.AninstanceSearchView.as_view(), name='search_view'), ### ROUTING # Set timezone url(r'^set_timezone/$', tz.SetTimeZ...
url(r'^/?$', include('invoicing.urls')),
Using the snippet: <|code_start|> # REST API framework router = routers.DefaultRouter() router.register(r'invoicing/client', ClientViewSet) # URL patterns urlpatterns = [ ### INCLUDES # Invoicing app url(r'^invoicing/', include('invoicing.urls')), # Admin section url(r'^adminardo/', admin.site.urls)...
{'template_name': 'registration/password_change_form.html'}, name='password_change'),
Given snippet: <|code_start|> # REST API framework router = routers.DefaultRouter() router.register(r'invoicing/client', ClientViewSet) # URL patterns urlpatterns = [ ### INCLUDES # Invoicing app url(r'^invoicing/', include('invoicing.urls')), # Admin section url(r'^adminardo/', admin.site.urls), ...
url(r'^accounts/login/$', auth_views.login,
Predict the next line for this snippet: <|code_start|> self.CACHE_TTL = self.NEVER_CACHE_TTL self.requested_page = 1 self.search_url = None self.authentication_required = self.AUTHENTICATION_REQUIRED # change in child views to activate auth self.auth_level = auth.USER_LEVEL.g...
else:
Given the code snippet: <|code_start|> PAGE_STR = 'p' STATUS_MESSAGE = None AUTHENTICATION_REQUIRED = False # authorization not required for views by default. Overwrite in CVBs for auth. RIGHT_SIDEBAR_SEARCH_PLACEHOLDER_TEXT = _('Search for') RIGHT_SIDEBAR_SEARCH_BUTTON_TEXT = _('Search') """Def...
placeholder=self.RIGHT_SIDEBAR_SEARCH_PLACEHOLDER_TEXT),
Here is a snippet: <|code_start|> - Defaults to NO authentication required, and user level of a basic user. """ NEVER_CACHE_TTL = 0 # set to 0 to prevent caching when this TTL is selected CACHE_TTL = settings.DEFAULT_CACHES_TTL TEMPLATE_NAME = None FOOTER_TEXT = None # None value means defa...
self.requested_page = 1
Given snippet: <|code_start|> '\nConverting Optical Map to SOMA Format\n' +\ '*'*50 + '\n' sys.stderr.write(msg) # Optical maps for chromosomes # Remove all white space from restriction map names for opMap in opMapList: opMap.mapId = ''.join(opMap.mapId.split()) writeMap...
return omaps
Using the snippet: <|code_start|># Convert an optical map from the Schwartz lab format # to the SOMA format # opticalMapFile: optical map file in the Schwartz lab format def convert_optical_maps(opticalMapFile, outputPfx): opMapFileOut = '%s.opt'%outputPfx msg = '\n'+'*'*50 + \ '\nReading Optical Map...
return result
Continue the code snippet: <|code_start|> # Extend the length of endy_position to make it touch the plane # tangent at center_position. endy_position /= numpy.dot(center_position, endy_position) diff1 = endy_position-center_position diff2 = local_north_position-center_position ...
yoffs_rad *= -sign_cor
Here is a snippet: <|code_start|>from __future__ import absolute_import logger = logging.getLogger(__name__) def extract_metadatas(accessors, sigma, f): logger.debug("running extract metadatas task") <|code_end|> . Write the next line using the current file imports: import logging import tkp.steps from tkp.step...
return tkp.steps.persistence.extract_metadatas(accessors, sigma, f)
Predict the next line for this snippet: <|code_start|>from __future__ import absolute_import logger = logging.getLogger(__name__) def extract_metadatas(accessors, sigma, f): logger.debug("running extract metadatas task") return tkp.steps.persistence.extract_metadatas(accessors, sigma, f) def open_as_fits(i...
return tkp.steps.persistence.paths_to_fits(images)
Here is a snippet: <|code_start|>from __future__ import with_statement # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_na...
def get_url():
Using the snippet: <|code_start|> logger = logging.getLogger(__name__) class AartfaacCasaImage(CasaImage): def __init__(self, url, plane=0, beam=None): super(AartfaacCasaImage, self).__init__(url, plane=0, beam=None) table = casacore_table(self.url.encode(), ack=False) <|code_end|> , determine th...
self.taustart_ts = self.parse_taustartts(table)
Next line prediction: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-dev...
def test_execute_store_varmetric(self):
Continue the code snippet: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nos...
def test_execute_store_varmetric(self):
Continue the code snippet: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): <|code_end|> . Use current file imports: import unittest import logging import tkp.db.model import tkp.db from tkp.testutil.alchemy...
@classmethod
Given the code snippet: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose...
self.session.flush()
Given snippet: <|code_start|> class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/issues/946 if database_disabled(): raise unittest.SkipTest("Database functionality disabl...
session = self.db.Session()
Predict the next line for this snippet: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): @classmethod <|code_end|> with the help of current file imports: import unittest import logging import tkp.db.mod...
def setUpClass(cls):
Next line prediction: <|code_start|> class TestStream(unittest.TestCase): @classmethod def setUpClass(cls): cls.hdu = create_fits_hdu() <|code_end|> . Use current file imports: (import unittest import dateutil import tkp.stream from datetime import datetime from tkp.testutil.stream_emu import create_f...
now = datetime.now()
Predict the next line after this snippet: <|code_start|> class TestStream(unittest.TestCase): @classmethod def setUpClass(cls): cls.hdu = create_fits_hdu() now = datetime.now() cls.hdu.header['date-obs'] = now.isoformat() def test_reconstruct(self): data, header = serialize...
hdulist = tkp.stream.reconstruct_fits(header, data)
Continue the code snippet: <|code_start|> class TestVersion(unittest.TestCase): def setUp(self): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/issues/946 if database_disabled(): raise unittest.SkipTest("Database functionality disabled " ...
"in configuration.")
Given the following code snippet before the placeholder: <|code_start|> class TestVersion(unittest.TestCase): def setUp(self): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/issues/946 if database_disabled(): <|code_end|> , predict the next line usin...
raise unittest.SkipTest("Database functionality disabled "
Given the code snippet: <|code_start|> class TestVersion(unittest.TestCase): def setUp(self): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/issues/946 if database_disabled(): <|code_end|> , generate the next line using the imports in this file: imp...
raise unittest.SkipTest("Database functionality disabled "
Predict the next line for this snippet: <|code_start|> cls.db = tkp.db.Database() def setUp(self): self.session = self.db.Session() self.fake_images = db_subs.generate_timespaced_dbimages_data(n_images=1) self.dataset = tkp.db.DataSet(data={'description': ...
comment="bad reason",
Here is a snippet: <|code_start|> dbqual.reject_reasons['rms'], "10 times too high", self.session) image_rejections_q = self.session.query(Rejection).filter( Rejection.image_id == self.image.id) self.assertEqual(image_rejection...
dbqual.reject(self.image.id,
Predict the next line after this snippet: <|code_start|> @requires_database() class TestReject(unittest.TestCase): @classmethod def setUpClass(cls): cls.db = tkp.db.Database() def setUp(self): self.session = self.db.Session() self.fake_images = db_subs.generate_timespaced_dbimages_...
dataset=self.dataset)
Based on the snippet: <|code_start|> self.assertEqual(image_rejections_q.count(), 0) def test_unknownreason(self): with self.assertRaises(IntegrityError): dbqual.reject(self.image.id, Rejectreason(id=666666, description="foobar"), comme...
def test_rejectreasons_sync(self):
Predict the next line for this snippet: <|code_start|> config = { 'engine': os.environ.get('TKP_DBENGINE', 'postgresql'), 'database': 'test_management', 'user': os.environ.get('TKP_DBUSER', getpass.getuser()), 'password': os.environ.get('TKP_DBPASSWORD', getpass.getuser()), 'host': os.environ.get(...
}
Here is a snippet: <|code_start|> rms = tkp.quality.rms.rms(clip) self.assertEqual(rms, tkp.quality.rms.rms_with_clipped_subregion(o)) def test_calculate_theoreticalnoise(self): # Sample data from a LOFAR image header. integration_time = 18654.3 # s bandwidth = 200 * 10**3 # ...
def test_rms_valid(self):
Next line prediction: <|code_start|> core_antennas = os.path.join(DATAPATH, 'lofar/CS001-AntennaArrays.conf') intl_antennas = os.path.join(DATAPATH, 'lofar/DE601-AntennaArrays.conf') remote_antennas = os.path.join(DATAPATH, 'lofar/RS106-AntennaArrays.conf') class TestRms(unittest.TestCase): def test_subrgion(self...
def test_rmsclippedsubregion(self):
Predict the next line for this snippet: <|code_start|> self.session.flush() self.session.commit() def test_last_assoc_timestamps(self): q = tkp.db.alchemy.varmetric._last_assoc_timestamps(self.session, self.dataset1) r = self.session.query(q).all() self.assertEqual(len(r), 2)...
r = tkp.db.alchemy.varmetric.calculate_varmetric(self.session, self.dataset1).all()
Continue the code snippet: <|code_start|> lightcurve1 = gen_lightcurve(d1_b1, self.dataset1, skyregion1) lightcurve2 = gen_lightcurve(d1_b2, self.dataset1, skyregion1) lightcurve3 = gen_lightcurve(d2_b1, self.dataset2, skyregion2) lightcurve4 = gen_lightcurve(d2_b2, self.dataset2, skyregi...
r = list(self.session.query(q).all()[0])
Predict the next line for this snippet: <|code_start|>class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/issues/946 if database_disabled(): raise unittest.SkipTest("Databa...
self.session.add_all(db_objecsts)
Given snippet: <|code_start|> logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Can't use a regular skip here, due to a Nose bug: # https://github.com/nose-devs/nose/...
self.session = self.db.Session()
Next line prediction: <|code_start|> skyregion2 = gen_skyregion(self.dataset2) lightcurve1 = gen_lightcurve(d1_b1, self.dataset1, skyregion1) lightcurve2 = gen_lightcurve(d1_b2, self.dataset1, skyregion1) lightcurve3 = gen_lightcurve(d2_b1, self.dataset2, skyregion2) lightcurve4 =...
q = tkp.db.alchemy.varmetric._combined(self.session, self.dataset1)
Based on the snippet: <|code_start|> def test_invalid_ephemeris(self): dm = measures() # No(?) ephemeris we're likely to come across is valid at MJD 0. dm.do_frame(dm.epoch("UTC", "0.0d")) self.assertFalse(tkp.quality.brightsource.check_for_valid_ephemeris(dm)) class TestBrightsourc...
image.centre_ra = 0
Given snippet: <|code_start|>class TestEphemeris(unittest.TestCase): # Tests whether we can correctly identify that an ephemeris is invalid. # I don't think it's possible to test that we can correctly identify a # valid ephemeris, because we can't be sure that the user actually has one # on disk (unless...
image.centre_ra = 90
Continue the code snippet: <|code_start|> def update_skyregion_members(session, skyregion): """ This function performs a simple distance-check against current members of the runningcatalog to find sources that should be visible in the given skyregion, and updates the assocskyrgn table accordingly. ...
,sky.id as skyrgn
Predict the next line after this snippet: <|code_start|> session.add(band) return band def update_skyregion_members(session, skyregion): """ This function performs a simple distance-check against current members of the runningcatalog to find sources that should be visible in the given skyregio...
,distance_deg
Using the snippet: <|code_start|> def update_skyregion_members(session, skyregion): """ This function performs a simple distance-check against current members of the runningcatalog to find sources that should be visible in the given skyregion, and updates the assocskyrgn table accordingly. Any pre...
,sky.id as skyrgn
Given the following code snippet before the placeholder: <|code_start|> and updates the assocskyrgn table accordingly. Any previous entries in assocskyrgn relating to this skyregion are deleted first. Note 1. We use the variable 'inter' to cache the extraction_radius as transformed onto the unit sp...
FROM skyregion sky
Given the code snippet: <|code_start|> Note 2. (To Do:) This distance check could be made more efficient by restricting to a range of RA values, as we do with the Dec. However, this optimization is complicated by the meridian wrap-around issue. """ inter = 2. * math.sin(math.radians(skyregion.xt...
+ (rc.z - sky.z) * (rc.z - sky.z)
Using the snippet: <|code_start|>""" A collection of back end subroutines (mostly SQL queries). In this module we collect together various routines that don't fit into a more specific collection. """ logger = logging.getLogger(__name__) lightcurve_query = """ SELECT im.taustart_ts ,im.tau_time ,ex.f_i...
,assocxtrsource ax
Here is a snippet: <|code_start|>""" A collection of back end subroutines (mostly SQL queries). In this module we collect together various routines that don't fit into a more specific collection. """ logger = logging.getLogger(__name__) lightcurve_query = """ SELECT im.taustart_ts ,im.tau_time ,ex.f_i...
,frequencyband bd
Continue the code snippet: <|code_start|>""" A collection of back end subroutines (mostly SQL queries). In this module we collect together various routines that don't fit into a more specific collection. """ logger = logging.getLogger(__name__) lightcurve_query = """ <|code_end|> . Use current file imports: impo...
SELECT im.taustart_ts
Predict the next line after this snippet: <|code_start|>""" A collection of back end subroutines (mostly SQL queries). In this module we collect together various routines that don't fit into a more specific collection. """ logger = logging.getLogger(__name__) lightcurve_query = """ SELECT im.taustart_ts ,im...
)
Using the snippet: <|code_start|> rms_est_sigma=rms_est_sigma, rms_est_fraction=rms_est_fraction) noise = noise_level(accessor.freq_eff, accessor.freq_bw, accessor.tau_time, accessor.antenna_set, accessor.ncore, accessor.nremote...
logger.info("image %s REJECTED: %s " % (accessor.url, bright))
Using the snippet: <|code_start|> logger = logging.getLogger(__name__) def reject_check_lofar(accessor, job_config): lofar_quality_params = job_config['quality_lofar'] quality_params = job_config['quality'] low_bound = lofar_quality_params['low_bound'] high_bound = lofar_quality_params['high_bound']...
if not rms_check:
Given the following code snippet before the placeholder: <|code_start|> logger = logging.getLogger(__name__) def reject_check_lofar(accessor, job_config): lofar_quality_params = job_config['quality_lofar'] quality_params = job_config['quality'] low_bound = lofar_quality_params['low_bound'] high_boun...
return dbquality.reject_reasons['tau_time'], "tau_time is 0"
Next line prediction: <|code_start|> compare = (alpha / C_n) * numpy.arange(lengthprob+1)[1:] / lengthprob # Find the last undercrossing, see, e.g., fig. 9 in Miller et al., AJ # 122, 3492 (2001). Searchsorted is not used because the array is not # sorted. try: index ...
def box_slice_about_pixel(x, y, box_radius):
Using the snippet: <|code_start|> """ insert_rows = 0 total_pages = 0 logging.basicConfig(filename=log_file, level=logging.DEBUG) print("Starting page data loading at %s." % ( time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime()))) logging.info("Starting page data...
try:
Continue the code snippet: <|code_start|> TERMINATED BY '\t' ESCAPED BY '"' LINES TERMINATED BY '\n'""" insert_newuser = """LOAD DATA INFILE '%s' INTO TABLE user_new FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '\t' ESCAP...
logitem = logdict['logitem']
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ Created on Thu Apr 10 18:02:16 2014 Download manager for dump files @author: jfelipe """ class DumpIntegrityError(Exception): """Exception raised for errors in the input. Attributes: msg -- explanation of the error...
.format(file_path))
Continue the code snippet: <|code_start|> class RequestError(Exception): pass def error_on_request(url, request): raise RequestError("CIM Request") <|code_end|> . Use current file imports: from httmock import HTTMock, with_httmock from xml.dom.minidom import parseString from django.test import TestCase f...
class CustomerProfileModelTests(TestCase):
Here is a snippet: <|code_start|> class RequestError(Exception): pass def error_on_request(url, request): <|code_end|> . Write the next line using the current file imports: from httmock import HTTMock, with_httmock from xml.dom.minidom import parseString from django.test import TestCase from authorizenet.model...
raise RequestError("CIM Request")
Continue the code snippet: <|code_start|> class RequestError(Exception): pass def error_on_request(url, request): <|code_end|> . Use current file imports: from httmock import HTTMock, with_httmock from xml.dom.minidom import parseString from django.test import TestCase from authorizenet.models import CustomerP...
raise RequestError("CIM Request")
Predict the next line for this snippet: <|code_start|> class RequestError(Exception): pass def error_on_request(url, request): raise RequestError("CIM Request") <|code_end|> with the help of current file imports: from httmock import HTTMock, with_httmock from xml.dom.minidom import parseString from djan...
class CustomerProfileModelTests(TestCase):
Given the code snippet: <|code_start|> def get_fingerprint(x_fp_sequence, x_fp_timestamp, x_amount): msg = '^'.join([settings.LOGIN_ID, x_fp_sequence, x_fp_timestamp, x_amount ]) + '^' return hmac.new(settings.TRANSACTION_KEY, msg).hexdigest() def extract_form_d...
'x_delim_data': "TRUE",
Given snippet: <|code_start|> def get_fingerprint(x_fp_sequence, x_fp_timestamp, x_amount): msg = '^'.join([settings.LOGIN_ID, x_fp_sequence, x_fp_timestamp, x_amount <|code_end|> , continue by predicting the next line. Consider current file imports: import hmac from django.core...
]) + '^'
Predict the next line for this snippet: <|code_start|> def get_fingerprint(x_fp_sequence, x_fp_timestamp, x_amount): msg = '^'.join([settings.LOGIN_ID, x_fp_sequence, x_fp_timestamp, x_amount ]) + '^' return hmac.new(settings.TRANSACTION_KEY, msg).hexdigest() de...
AIM_DEFAULT_DICT = {
Next line prediction: <|code_start|> urlpatterns = patterns( '', url(r"^customers/create$", CreateCustomerView.as_view()), url(r"^customers/update$", UpdateCustomerView.as_view()), url(r"^success$", success_view), <|code_end|> . Use current file imports: (from django.conf.urls import url, patterns from...
)
Predict the next line for this snippet: <|code_start|> urlpatterns = patterns( '', url(r"^customers/create$", CreateCustomerView.as_view()), url(r"^customers/update$", UpdateCustomerView.as_view()), url(r"^success$", success_view), <|code_end|> with the help of current file imports: from django.conf.u...
)
Given snippet: <|code_start|> class CreateCustomerView(PaymentProfileCreateView): def get_success_url(self): return '/success' class UpdateCustomerView(PaymentProfileUpdateView): def get_object(self): <|code_end|> , continue by predicting the next line. Consider current file imports: from django.ht...
return self.request.user.customer_profile.payment_profiles.get()
Here is a snippet: <|code_start|> class CreateCustomerView(PaymentProfileCreateView): def get_success_url(self): return '/success' class UpdateCustomerView(PaymentProfileUpdateView): def get_object(self): return self.request.user.customer_profile.payment_profiles.get() <|code_end|> . Write ...
def get_success_url(self):
Next line prediction: <|code_start|>class Item(models.Model): title = models.CharField(max_length=55) price = models.DecimalField(max_digits=8, decimal_places=2) def __unicode__(self): return self.title class Invoice(models.Model): customer = models.ForeignKey(Customer) item = models.Fore...
def flagged_payment(sender, **kwargs):
Given snippet: <|code_start|> ADDRESS_CHOICES = ( ('billing', 'Billing'), ('shipping', 'Shipping'), ) class Customer(models.Model): user = models.ForeignKey(User) shipping_same_as_billing = models.BooleanField(default=True) cim_profile_id = models.CharField(max_length=10) def __unicode__(se...
return self.customer.user.username
Based on the snippet: <|code_start|> COMMANDS_PATH = PATH + "/commands" VERSION = get_version() class CommandsManager: def __init__(self): self.commands = self.parse() # This command is used to load the modules when needed <|code_end|> , predict the immediate next line with the help of imports: impo...
def get(self, name):
Predict the next line for this snippet: <|code_start|> if not isinstance(cmd.methods, tuple) and \ not isinstance(cmd.methods, list): raise Exception("Methods need to be of type tuple or list") if not cmdmethod: raise TypeError(f"This command needs ...
cmd = self.get(name)
Predict the next line for this snippet: <|code_start|> "action" : "query", "prop" : "linkshere", "titles" : q, "lhlimit" : 500 }) data = list(data["query"]["pages"].values())[0] if "linkshere" in data: data["total"] = len(data["linkshere"]) else: data["to...
return data
Given snippet: <|code_start|> [d.remove(selector) for selector in ( ".beeldengeluid-infobox", "#personen-foto", "#personen-gegevens", ".mw-editsection" )] for a in d.find("a"): pa = pq(a) href = pa.attr("href") href = _lookuphref(href) text = ...
"titles" : q,
Predict the next line for this snippet: <|code_start|> "response_time" : response_time } return response @app.route('/') def root(): return open(config.PATH + "/static/index.html").read() @app.route('/_commands') def list_commands(): logging.debug("Listing all commands") return jso...
return cachemodule.Cache(expires = config.CACHING['expires'])
Next line prediction: <|code_start|> if snak["snaktype"] == "novalue": return { "datatype" : "novalue" } else: value = snak["datavalue"]["value"] if datatype == "wikibase-item": qid = "Q" + str(value["numeric-id"]) val[...
if datatype in ["string", "monolingualtext", "url"]:
Given snippet: <|code_start|> def __init__(self): self.entitycache = {} # If set to 'True' and only one language is given, the value # is directly given as value for a key instead of an object # # e.g. # { # "propery_labels" : "Birth name" # ...
return {
Next line prediction: <|code_start|> if download: self.download() if not self._check_integrity(): raise RuntimeError("Dataset not found or corrupted. " + "You can use download=True to download it.") self.load(num_val) def download(sel...
if not osp.isdir(exdir):
Continue the code snippet: <|code_start|>from __future__ import print_function, absolute_import class Market1501(Dataset): url = 'https://drive.google.com/file/d/0B8-rUzbwVRk0c054eEozWG9COHM/view' md5 = '65005ab7d12ec1c44de4eeafe813e68a' def __init__(self, root, split_id=0, num_val=100, download=True): ...
print("Files already downloaded and verified")
Continue the code snippet: <|code_start|> return raw_dir = osp.join(self.root, 'raw') mkdir_if_missing(raw_dir) # Download the raw zip file fpath = osp.join(raw_dir, 'DukeMTMC-reID.zip') if osp.isfile(fpath) and \ hashlib.md5(open(fpath, 'rb').read()).hexd...
fpaths = sorted(glob(osp.join(exdir, subdir, '*.jpg')))
Given the following code snippet before the placeholder: <|code_start|> md5 = '2f93496f9b516d1ee5ef51c1d5e7d601' def __init__(self, root, split_id=0, num_val=100, download=True): super(DukeMTMC, self).__init__(root, split_id=split_id) if download: self.download() if not sel...
"to {}".format(self.url, fpath))
Continue the code snippet: <|code_start|>from __future__ import print_function, absolute_import class CUHK01(Dataset): url = 'https://docs.google.com/spreadsheet/viewform?formkey=dF9pZ1BFZkNiMG1oZUdtTjZPalR0MGc6MA' md5 = 'e6d55c0da26d80cda210a2edeb448e98' def __init__(self, root, split_id=0, num_val=10...
if not self._check_integrity():
Using the snippet: <|code_start|> "You can use download=True to download it.") self.load(num_val) def download(self): if self._check_integrity(): print("Files already downloaded and verified") return raw_dir = osp.join(self.root, 'raw...
images_dir = osp.join(self.root, 'images')
Using the snippet: <|code_start|> class TestCMC(TestCase): def test_only_distmat(self): distmat = np.array([[0, 1, 2, 3, 4], [1, 0, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [1, 2, 3, 4, 0]]) ...
def test_duplicate_cams(self):