Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Continue the code snippet: <|code_start|> # account = Account.objects.get(id=1) self.assertEqual(account.id, 1) self.assertEqual(account.email, 'john@example.com') account = Account.objects.get(email='paul@example.com') self.assertEqual(account.id, 2) self.assert...
reporter = Reporter.objects.get(id=1)
Next line prediction: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') <|code_end|> . Use current file imports: (from rest_framework import routers from .api.views import Account...
router.register(r'articles', ArticleViewSet, base_name='article')
Next line prediction: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') router.register(r'articles', ArticleViewSet, base_name='article') <|code_end|> . Use current file imports: ...
router.register(r'tags', TagViewSet, base_name='tag')
Predict the next line for this snippet: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') router.register(r'articles', ArticleViewSet, base_name='article') router.register(r'tags',...
router.register(r'reversed/articles', ReversedArticleViewSet, base_name='reversedarticle')
Based on the snippet: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') router.register(r'articles', ArticleViewSet, base_name='article') router.register(r'tags', TagViewSet, base_...
router.register(r'reversed/reporters', ReversedReporterViewSet, base_name='reversedreporter')
Predict the next line after this snippet: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') router.register(r'articles', ArticleViewSet, base_name='article') router.register(r'tags...
router.register(r'reversed/tags', ReversedTagViewSet, base_name='reversedtag')
Predict the next line after this snippet: <|code_start|> # API router = routers.DefaultRouter() router.register(r'accounts', AccountViewSet, base_name='account') router.register(r'reporters', ReporterViewSet, base_name='reporter') router.register(r'articles', ArticleViewSet, base_name='article') router.register(r'tags...
router.register(r'reversed/accounts', ReversedAccountViewSet, base_name='reversedaccount')
Here is a snippet: <|code_start|> # Filters and permissions are declared in settings class AccountViewSet(ModelViewSet): queryset = Account.objects.all() serializer_class = AccountSerializer class ReporterViewSet(ModelViewSet): <|code_end|> . Write the next line using the current file imports: from .mixin...
queryset = Reporter.objects.all()
Using the snippet: <|code_start|> # Filters and permissions are declared in settings class AccountViewSet(ModelViewSet): queryset = Account.objects.all() serializer_class = AccountSerializer class ReporterViewSet(ModelViewSet): queryset = Reporter.objects.all() serializer_class = ReporterSerializer...
queryset = Article.objects.all()
Predict the next line after this snippet: <|code_start|> # Filters and permissions are declared in settings class AccountViewSet(ModelViewSet): queryset = Account.objects.all() serializer_class = AccountSerializer class ReporterViewSet(ModelViewSet): queryset = Reporter.objects.all() serializer_cla...
queryset = Tag.objects.all()
Given the code snippet: <|code_start|> return reverse(self.MARK_DONE_URL_NAME, args=(self.referral.patient.id, self.referral.id, self.id)) def admin_url(self): return reverse( 'admin:referral_followuprequest...
ContactResult,
Given snippet: <|code_start|> class PatientContact(Note): followup_request = models.ForeignKey(FollowupRequest) referral = models.ForeignKey(Referral) contact_method = models.ForeignKey( ContactMethod, null=False, blank=False, help_text="What was the method of contact?") ...
NoAptReason,
Given the code snippet: <|code_start|> PTSHOW_OPTS = [(PTSHOW_YES, "Yes"), (PTSHOW_NO, "No")] has_appointment = models.CharField( choices=PTSHOW_OPTS, blank=True, max_length=1, verbose_name="Appointment scheduled?", help_text="Did the patient make an appointmen...
NoShowReason,
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals, print_function def dashboard_dispatch(request): """Redirect an incoming user to the appropriate dashboard. Falls back to the 'home' url. """ provider_type = request.session['clint...
clinic_list = ClinicDate.objects.filter(workup__attending=provider)
Given the code snippet: <|code_start|>from __future__ import unicode_literals class TestPatientContactForm(TestCase): """ Tests the beahvior of the PatientContactForm which has a lot of complicated logic around valid form submission """ fixtures = ['pttrack'] def setUp(self): """...
self.contact_method = ContactMethod.objects.create(
Given snippet: <|code_start|> name='COH', address='Euclid Ave.') refloc.care_availiable.add(reftype) self.referral = models.Referral.objects.create( comments="Needs his back checked", status=models.Referral.STATUS_PENDING, kind=reftype, author=...
self.noapt_reason = NoAptReason.objects.create(
Given the following code snippet before the placeholder: <|code_start|> self.referral = models.Referral.objects.create( comments="Needs his back checked", status=models.Referral.STATUS_PENDING, kind=reftype, author=Provider.objects.first(), author_type...
self.noshow_reason = NoShowReason.objects.create(
Predict the next line after this snippet: <|code_start|> date_of_birth=datetime.date(1990, 0o1, 0o1), patient_comfortable_with_english=False, preferred_contact_method=self.contact_method, ) reftype = ReferralType.objects.create( name="Specialty", is_fqhc=F...
self.successful_res = ContactResult.objects.create(
Predict the next line for this snippet: <|code_start|> url(r'^(?P<pt_id>[0-9]+)/document/$', views.DocumentCreate.as_view(), name="new-document"), url(r'^document/(?P<pk>[0-9]+)$', DetailView.as_view(model=models.Document), name="document-detail"), url(r'^document/update/(?P<p...
url.callback = provider_required(url.callback)
Given the code snippet: <|code_start|> # MISC url(r'^about/', TemplateView.as_view(template_name='pttrack/about.html'), name='about'), ] def wrap_url(url, no_wrap=[], login_only=[], provider_only=[], updated_provider_only=[]): ''' Wrap URL in decorators as appropriate. ...
url.callback = clintype_required(url.callback)
Given the following code snippet before the placeholder: <|code_start|> DetailView.as_view(model=models.Document), name="document-detail"), url(r'^document/update/(?P<pk>[0-9]+)$', views.DocumentUpdate.as_view(), name="document-update"), # MISC url(r'^about/', Templat...
url.callback = provider_update_required(url.callback)
Using the snippet: <|code_start|> unwrapped_urlconf = [ # pylint: disable=invalid-name url(r'^(?P<pt_id>[0-9]+)/referral/$', views.ReferralFollowupCreate.as_view(), name='new-referral-followup'), url(r'^(?P<pt_id>[0-9]+)/(?P<ftype>[\w]+)/$', views.FollowupCreate.as_view(), name=...
urlpatterns = [wrap_url(url, **wrap_config) for url in unwrapped_urlconf]
Using the snippet: <|code_start|>from __future__ import unicode_literals unwrapped_urlconf = [ url(r'^dispatch/$', views.dashboard_dispatch, name='dashboard-dispatch'), url(r'^attending/$', views.dashboard_attending, name='dashboard-attending'), ] <|code_end|> , determine the ...
urlpatterns = [wrap_url(u, **{}) for u in unwrapped_urlconf]
Predict the next line after this snippet: <|code_start|>from __future__ import unicode_literals def get_clindates(): '''Get the clinic dates associated with today.''' clindates = models.ClinicDate.objects.filter( clinic_date=now().date()) return clindates def new_note_dispatch(request, pt_...
class WorkupCreate(NoteFormView):
Given the code snippet: <|code_start|> wu_previous = pt.latest_workup() if wu_previous is not None: date_string = wu_previous.written_datetime.strftime("%B %d, %Y") for field in settings.OSLER_WORKUP_COPY_FORWARD_FIELDS: initial[field] = settings.OSLER_WORKUP_COPY_...
class WorkupUpdate(NoteUpdate):
Using the snippet: <|code_start|> 'done in the admin panel by a user with sufficient ', 'privileges (e.g. coordinator).') def get_initial(self): initial = super(WorkupCreate, self).get_initial() pt = get_object_or_404(Patient, pk=self.kwargs['pt_id']) # self....
wu.author_type = get_current_provider_type(self.request)
Here is a snippet: <|code_start|>from __future__ import unicode_literals class Command(BaseCommand): help = '''Email attendings when they have unattested workups.''' def handle(self, *args, **options): <|code_end|> . Write the next line using the current file imports: from builtins import str from django....
unsigned_wus = Workup.objects.filter(signer=None)
Next line prediction: <|code_start|>from __future__ import unicode_literals class AppointmentForm(ModelForm): class Meta(object): <|code_end|> . Use current file imports: (from builtins import object from django.forms import ModelForm, TimeInput from crispy_forms.helper import FormHelper from crispy_forms.lay...
model = Appointment
Continue the code snippet: <|code_start|> url(r'^(?P<pk>[0-9]+)/error/$', views.error_workup, name="workup-error"), url(r'^(?P<pk>[0-9]+)/pdf/$', views.pdf_workup, name="workup-pdf"), # PROGRESS NOTES url(r'^(?P<pt_id>[0-9]+)/psychnote/$', views.ProgressNoteCreate...
urlpatterns = [wrap_url(url, **wrap_config) for url in unwrapped_urlconf]
Using the snippet: <|code_start|>from __future__ import unicode_literals def apt_dict(): apt = {'clindate': now().date(), 'clintime': time(9, 0), 'appointment_type': 'PSYCH_NIGHT', 'comment': 'stuff', 'author': Provider.objects.first(), 'author_type': Provide...
form = AppointmentForm(data=apt)
Based on the snippet: <|code_start|>from __future__ import unicode_literals class TestAppointmentViews(TestCase): fixtures = ['pttrack', 'workup'] def setUp(self): self.all_roles_provider = build_provider() log_in_provider(self.client, self.all_roles_provider) self.apt = models....
response = self.client.post(reverse("appointment-new"), data=apt_dict())
Using the snippet: <|code_start|>from __future__ import unicode_literals def followup_choice(request, pt_id): '''Prompt the user to choose a follow up type.''' pt = get_object_or_404(Patient, pk=pt_id) return render(request, 'pttrack/followup-choice.html', {'patient': pt}) <|code_end|> , determine the...
class FollowupUpdate(NoteUpdate):
Given the code snippet: <|code_start|> def get_success_url(self): pt = self.object.patient return reverse("patient-detail", args=(pt.id, )) class ReferralFollowupUpdate(FollowupUpdate): model = models.ReferralFollowup form_class = forms.ReferralFollowup note_type = "Referral Followup" ...
class FollowupCreate(NoteFormView):
Given the code snippet: <|code_start|> class FollowupCreate(NoteFormView): '''A view for creating a new Followup''' template_name = 'pttrack/form_submission.html' note_type = "Followup" def get_form_class(self, **kwargs): ftype = self.kwargs['ftype'] futypes = {'labs': forms.LabFollo...
fu.author_type = get_current_provider_type(self.request)
Here is a snippet: <|code_start|> raise ValueError( "Provider {p} doesn't have role {r}!".format( p=user.provider, r=active_role)) if active_role.signs_charts: assert active_role in user.provider.clinical_roles.all() self.signed_date = now...
validators=[validate_attending])
Predict the next line after this snippet: <|code_start|> """Mark a patient as having not shown to an appointment """ apt = get_object_or_404(Appointment, pk=pk) apt.pt_showed = False apt.save() return HttpResponseRedirect(reverse("appointment-list")) def mark_arrived(request, pk): """Mark...
class AppointmentCreate(NoteFormView):
Given the following code snippet before the placeholder: <|code_start|> else: d[a.clindate] = [a] return render(request, 'appointment/appointment_list.html', {'appointments_by_date': d}) def mark_no_show(request, pk): """Mark a patient as having not shown to an appointmen...
class AppointmentUpdate(NoteUpdate):
Predict the next line after this snippet: <|code_start|> def mark_arrived(request, pk): """Mark a patient as having arrived to an appointment """ apt = get_object_or_404(Appointment, pk=pk) apt.pt_showed = True apt.save() return HttpResponseRedirect(reverse("patient-update", args=(apt.patient....
appointment.author_type = get_current_provider_type(self.request)
Continue the code snippet: <|code_start|> return render(request, 'appointment/appointment_list.html', {'appointments_by_date': d}) def mark_no_show(request, pk): """Mark a patient as having not shown to an appointment """ apt = get_object_or_404(Appointment, pk=pk) apt.pt_showed ...
form_class = AppointmentForm
Using the snippet: <|code_start|>from __future__ import unicode_literals # pylint: disable=I0011 unwrapped_urlpatterns = [ # pylint: disable=invalid-name url(r'^pt_list/$', views.PtList.as_view(), name='pt_list_api'), ] wrap_config = {} <|code_end|> , determine the next line of code. You have i...
urlpatterns = [wrap_url(url, **wrap_config) for url in unwrapped_urlpatterns]
Using the snippet: <|code_start|> template_name = 'demographics/demographics-create.html' form_class = DemographicsForm def get_context_data(self, **kwargs): context = super(DemographicsCreate, self).get_context_data(**kwargs) if 'pt_id' in self.kwargs: context['patient'] = Pa...
dg_old = Demographics.objects.get(patient=pt.id)
Using the snippet: <|code_start|>from __future__ import unicode_literals # Create your views here. class DemographicsCreate(FormView): template_name = 'demographics/demographics-create.html' <|code_end|> , determine the next line of code. You have imports: import datetime from django.shortcuts import get_ob...
form_class = DemographicsForm
Given the following code snippet before the placeholder: <|code_start|> 'timestamp', ) search_fields = ( 'user__username', 'user__first_name', 'user__last_name', 'user__email', 'url', 'role__short_name' ) # change_list_template = 'admin/pageview-log-summary.html' # date_hier...
admin.site.register(PageviewRecord, PageviewRecordAdmin)
Given snippet: <|code_start|>from __future__ import unicode_literals class TestAudit(TestCase): fixtures = ['pttrack.json'] def setUp(self): self.client = Client() def test_audit_unicode(self): """Check that unicode works for TestAudit """ <|code_end|> , continue by predicting ...
p = PageviewRecord.objects.create(
Given the following code snippet before the placeholder: <|code_start|> self.assertIn('opt=OPT', stdout.getvalue()) def test_args_missing(self): with captured(out(), err()) as (stdout, stderr): with mock_args([]): with self.assertRaises(SystemExit): Re...
with InTempDir():
Predict the next line for this snippet: <|code_start|> LOGGING_CONFIG_FILE_DATA = """ [loggers] keys = root [logger_root] level = DEBUG handlers = console [handlers] keys = console [handler_console] class = StreamHandler args = (sys.stderr,) level = DEBUG formatter = console [formatters] keys = console [formatter_...
with mock_args([]):
Using the snippet: <|code_start|> class TestRegisterWorkflow(unittest.TestCase): def setUp(self): self.mock_swf = mock_swf() self.mock_swf.start() self.connection = get_connection() self.connection.register_domain( name='TEST', workflowExecutionRetentionPer...
result = register_workflow(self.connection, 'TEST', Demo)
Predict the next line after this snippet: <|code_start|> @mock.patch('caravan.commands.decider.Worker') class Test(unittest.TestCase): def test_nominal(self, m_worker_cls): m_worker = m_worker_cls.return_value m_worker.run.side_effect = [None, None, KeyboardInterrupt('KILLTEST')] args =...
[fixtures.TestWorkflow1, fixtures.TestWorkflow2])
Continue the code snippet: <|code_start|> @mock.patch('caravan.commands.decider.Worker') class Test(unittest.TestCase): def test_nominal(self, m_worker_cls): m_worker = m_worker_cls.return_value m_worker.run.side_effect = [None, None, KeyboardInterrupt('KILLTEST')] args = [ ...
with mock_args(args):
Continue the code snippet: <|code_start|> @mock.patch('caravan.commands.decider.Worker') class Test(unittest.TestCase): def test_nominal(self, m_worker_cls): m_worker = m_worker_cls.return_value m_worker.run.side_effect = [None, None, KeyboardInterrupt('KILLTEST')] args = [ ...
Command.main()
Predict the next line after this snippet: <|code_start|> @mock.patch('caravan.commands.decider.get_connection', autospec=True) def test_register_workflows(self, m_get_conn, m_register, m_worker_cls): m_worker = m_worker_cls.return_value m_worker.run.side_effect = KeyboardInterrupt('KILLTEST') ...
loader = ClassesLoaderFromModule(caravan.Workflow)
Given the code snippet: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}' httpretty.register_uri(httpretty.POST, "https://swf.us-east-1.am...
with mock_args(args):
Based on the snippet: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}' httpretty.register_uri(httpretty.POST, "https://swf.us-east-1.amaz...
Command.main()
Next line prediction: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}' httpretty.register_uri(httpretty.POST, "https://swf.us-east-1.amaz...
with mock_args(args):
Given snippet: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}' httpretty.register_uri(httpretty.POST, "https://swf.us-east-1.amazonaws.c...
Command.main()
Here is a snippet: <|code_start|> class Test(unittest.TestCase): @httpretty.activate def test_nominal(self): args = ['-d', 'DOMAIN', '-i', 'ID', '-s', 'SIG'] headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } httpretty.register_uri(http...
with mock_args(args):
Next line prediction: <|code_start|> class Test(unittest.TestCase): @httpretty.activate def test_nominal(self): args = ['-d', 'DOMAIN', '-i', 'ID', '-s', 'SIG'] headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } httpretty.register_uri(h...
Command.main()
Using the snippet: <|code_start|> class Test(unittest.TestCase): @httpretty.activate def test_nominal(self): args = ['--name', 'DOMAIN', '--retention-days', '10'] headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } httpretty.register_uri...
with mock_args(args):
Continue the code snippet: <|code_start|> class Test(unittest.TestCase): @httpretty.activate def test_nominal(self): args = ['--name', 'DOMAIN', '--retention-days', '10'] headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } httpretty.regi...
Command.main()
Predict the next line after this snippet: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = """ {"domainInfos": [ {"description": "music", "name": "867530901", "status": "REGISTER...
with mock_args(args):
Here is a snippet: <|code_start|> def httpretty_register(): headers = { 'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57', } body = """ {"domainInfos": [ {"description": "music", "name": "867530901", "status": "REGISTERED"}, {"desc...
Command.main()
Given the following code snippet before the placeholder: <|code_start|> { "executionInfos": [ { "cancelRequested": false, "execution": { "runId": "f5ebbac6-941c-4342-ad69-dfd2f8be6689", "workflowId": "20110927-T-1" }, ...
with mock_args(args):
Predict the next line for this snippet: <|code_start|> { "cancelRequested": false, "execution": { "runId": "f5ebbac6-941c-4342-ad69-dfd2f8be6689", "workflowId": "20110927-T-1" }, "executionStatus": "OPEN", ...
Command.main()
Given the following code snippet before the placeholder: <|code_start|> views = Blueprint('views', __name__) @views.route('/') def index(): <|code_end|> , predict the next line using imports from the current file: from flask import Blueprint, render_template from gepify.influxdb import influxdb and context includin...
influxdb.count('index_page_visits')
Given the following code snippet before the placeholder: <|code_start|> def login_required(f): @wraps(f) def decorated_function(*args, **kwargs): access_token = session.get('spotify_access_token', None) refresh_token = session.get('spotify_refresh_token', None) expires_at = session.get(...
token_data = get_access_token_from_refresh_token(
Using the snippet: <|code_start|> def login_required(f): @wraps(f) def decorated_function(*args, **kwargs): access_token = session.get('spotify_access_token', None) refresh_token = session.get('spotify_refresh_token', None) expires_at = session.get('spotify_expires_at', None) i...
save_token_data_in_session(token_data)
Continue the code snippet: <|code_start|> # 'Song is aleady downloading. Will retry in 5 seconds.') # self.assertTrue(retry.called) def test_download_song_with_unsupported_provider(self): with self.assertRaisesRegex(ValueError, 'Provider not found: zamunda'): songs.download_s...
playlists.cache = SimpleCache()
Next line prediction: <|code_start|> playlist = playlists.cache.get('spotify_1234_mp3') self.assertEqual(playlist['path'], './playlists/spotify_1234_mp3.zip') self.assertEqual(playlist['checksum'], checksum) class mocked_Resource(): def __init__(self, *args, **kwargs): self.result ...
song_id = youtube.get_song_id('existing song')
Given the code snippet: <|code_start|> youtube.download_song('song id', 'mp3') self.assertEqual(download.call_count, 1) download.assert_called_with(['http://www.youtube.com/watch?v=song id']) class mocked_Response(): def __init__(self, obj): self.obj = obj class mocked_Client(): ...
song_id, download_id = soundcloud.get_song_id('existing song')
Given the following code snippet before the placeholder: <|code_start|>""" Minimum Description Length Principle (MDLP) binning - Original paper: http://sci2s.ugr.es/keel/pdf/algorithm/congreso/fayyad1993.pdf - Implementation inspiration: https://www.ibm.com/support/knowledgecenter/it/SSLVMB_21.0.0/com.ibm.spss.statist...
class MDLPBinner(BaseSupervisedBinner):
Continue the code snippet: <|code_start|>""" Bayesian blocks binning. Good for visualization. References: - http://adsabs.harvard.edu/abs/2012arXiv1207.5578S - https://jakevdp.github.io/blog/2012/09/12/dynamic-programming-in-python/ """ <|code_end|> . Use current file imports: import numpy as np from skle...
class BayesianBlocksBinner(BaseUnsupervisedBinner):
Given the code snippet: <|code_start|> class DistributionResampler(): def __init__(self, column=0, sample_frac=0.5, n_bins=100, seed=None): super().__init__() self.column = column self.sample_frac = sample_frac <|code_end|> , generate the next line using the imports in this file: import ...
self.binner = EqualFrequencyBinner(n_bins=n_bins)
Given snippet: <|code_start|>class TutorialDoc(Document): doc_type = 'tutorial' author = DictField(Mapping.build( name = TextField(), email = TextField(), jabber = TextField(), website = TextField() )) clientversion = TextField() links = ListField( DictField(...
db.add_document(TutorialDoc)
Predict the next line for this snippet: <|code_start|> :param data: data for mail-forming, depends on mailtype ''' if data: if mailtype is 'mailreminder': msg = Message('[einfachJabber.de] Jabber-Konto Registrierung') msg.body = u''' einfachJabber.de Du hast eben über...
mail.send(msg)
Based on the snippet: <|code_start|> chunk_offset = struct.unpack(fmt, self.fh.read(fmt_size)) chunk_address = struct.unpack('<Q', self.fh.read(8))[0] keys.append(OrderedDict(( ('chunk_size', chunk_size), ('filter_mask', filter_mask), (...
shape = [_padded_size(i, j) for i, j in zip(data_shape, chunk_shape)]
Based on the snippet: <|code_start|>class BTree(object): """ HDF5 version 1 B-Tree. """ def __init__(self, fh, offset): """ initalize. """ self.fh = fh # read in the root node root_node = self._read_node(offset) self.root_node = root_node # read in all ...
node = _unpack_struct_from_file(B_LINK_NODE_V1, self.fh)
Continue the code snippet: <|code_start|> raise NotImplementedError('datatype not implemented') else: true_dtype = None # create array to store data shape = [_padded_size(i, j) for i, j in zip(data_shape, chunk_shape)] data = np.zeros(shape, dtype=dtype) ...
to_reference = np.vectorize(Reference)
Here is a snippet: <|code_start|> DIRNAME = os.path.dirname(__file__) DATASET_FLETCHER_HDF5_FILE = os.path.join(DIRNAME, 'fletcher32.hdf5') def test_fletcher32_datasets(): with pyfive.File(DATASET_FLETCHER_HDF5_FILE) as hfile: # check data dset1 = hfile['dataset1'] assert_array_equal(d...
_verify_fletcher32(bad_chunk)
Predict the next line for this snippet: <|code_start|> def __init__(self, fh, offset): fh.seek(offset) header = _unpack_struct_from_file(GLOBAL_HEAP_HEADER, fh) assert header['signature'] == b'GCOL' assert header['version'] == 1 heap_data_size = header['collection_size'] - G...
offset += _padded_size(info['object_size'])
Using the snippet: <|code_start|> return self._objects FORMAT_SIGNATURE = b'\211HDF\r\n\032\n' # Version 0 SUPERBLOCK SUPERBLOCK_V0 = OrderedDict(( ('format_signature', '8s'), ('superblock_version', 'B'), ('free_storage_version', 'B'), ('root_group_version', 'B'), ('reserved_0', 'B'), ...
SUPERBLOCK_V0_SIZE = _structure_size(SUPERBLOCK_V0)
Given the code snippet: <|code_start|> links[e['link_name']] = heap.get_object_name(offset).decode('utf-8') return links class GlobalHeap(object): """ HDF5 Global Heap collection. """ def __init__(self, fh, offset): fh.seek(offset) header = _unpack_struct_from_...
info = _unpack_struct_from(
Predict the next line after this snippet: <|code_start|>""" Misc low-level representation of HDF5 objects. """ class SuperBlock(object): """ HDF5 Superblock. """ def __init__(self, fh, offset): """ initalize. """ fh.seek(offset) version_hint = struct.unpack_from('<B', fh.re...
contents = _unpack_struct_from_file(SUPERBLOCK_V0, fh)
Next line prediction: <|code_start|>""" Misc low-level representation of HDF5 objects. """ class SuperBlock(object): """ HDF5 Superblock. """ def __init__(self, fh, offset): """ initalize. """ fh.seek(offset) version_hint = struct.unpack_from('<B', fh.read(9), 8)[0] ...
raise InvalidHDF5File('Incorrect file signature')
Using the snippet: <|code_start|> dtype_char = 'f' byte_order = datatype_msg['class_bit_field_0'] & 0x01 if byte_order == 0: byte_order_char = '<' # little-endian else: byte_order_char = '>' # big-endian # 12-bytes floating-point property description ...
name_size = _padded_size(null_location - self.offset, 8)
Given the following code snippet before the placeholder: <|code_start|> prop2['dim_size_1'] == 0 and prop2['dim_size_2'] == 0 and prop2['dim_size_3'] == 0 and prop2['dim_size_4'] == 0 ) if names_valid and dtypes_valid and offsets_val...
DATATYPE_MSG_SIZE = _structure_size(DATATYPE_MSG)
Continue the code snippet: <|code_start|>""" Representation and reading of HDF5 datatype messages. """ class DatatypeMessage(object): """ Representation of a HDF5 Datatype Message. """ # Contents and layout defined in IV.A.2.d. def __init__(self, buf, offset): self.buf = buf self.offset...
datatype_msg = _unpack_struct_from(DATATYPE_MSG, self.buf, self.offset)
Predict the next line after this snippet: <|code_start|> # last 4 bits datatype_class = datatype_msg['class_and_version'] & 0x0F if datatype_class == DATATYPE_FIXED_POINT: return self._determine_dtype_fixed_point(datatype_msg) elif datatype_class == DATATYPE_FLOATING_POINT: ...
raise InvalidHDF5File('Invalid datatype class %i' % (datatype_class))
Predict the next line after this snippet: <|code_start|># assign the RHS definitions for the ODE, the vardict dictionary, # to the varspecs attribute of DSargs DSargs.varspecs = vardict # Create an object representing the implementation of the model. # In PyDSTool, this is known as a Generator object, because # it can...
ts, vs = euler_integrate(DS, 0, 20, step, DS.initialconditions['v'])
Next line prediction: <|code_start|> except OSError: # directory was created and populated with images in a # previous run => keep it pass # cannot set albums => empty subdirs so that no albums are # generated album.subdirs = [] album.medias = ...
signals.album_initialized.connect(filter_nomedia)
Given snippet: <|code_start|> CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) def test_read_settings(settings): """Test that the settings are correctly read.""" assert settings['img_size'] == (640, 480) assert settings['thumb_size'] == (200, 150) assert settings['thumb_suffix'] == '.tn' ...
assert get_thumb(settings, src) == ref
Using the snippet: <|code_start|> assert settings['thumb_size'] == (200, 150) assert settings['thumb_suffix'] == '.tn' assert settings['source'] == os.path.join(CURRENT_DIR, 'sample', 'pictures') def test_get_thumb(settings): """Test the get_thumb function.""" tests = [ ('example.jpg', 'thu...
settings = read_settings(str(conf))
Using the snippet: <|code_start|> filename, ext = os.path.splitext(f) options = gallery.settings["upload_s3_options"] proposed_cache_control = None if "media_max_age" in options and ext in [".jpg", ".png", ".webm", ".mp4"]: proposed_cache_control = "max-age=%s" % options["media_max_age"] eli...
signals.gallery_build.connect(upload_s3)
Predict the next line after this snippet: <|code_start|> Based on pilkit's Adjust_ processor. .. _Adjust: \ https://github.com/matthewwithanm/pilkit/blob/master/pilkit/processors/base.py#L19 Settings:: adjust_options = { 'color': 1.0, 'brightness': 1.0, 'contrast': 1.0, 'sharpn...
signals.img_resized.connect(adjust)
Predict the next line for this snippet: <|code_start|> def copy_assets(settings): theme_path = os.path.join(settings["destination"], 'static') copy( os.path.join(ASSETS_PATH, "decrypt.js"), theme_path, symlink=False, rellink=False, ) copy( os.path.join(ASSETS_PAT...
signals.gallery_build.connect(encrypt_gallery)
Given the code snippet: <|code_start|> # in case any of the credentials are newly generated, write them back # to cache cache["credentials"] = { "gcm_tag": options["gcm_tag"], "kdf_salt": options["kdf_salt"], "kdf_iters": options["kdf_iters"], "galleryId": options["galleryId"]...
to_encrypt.append(get_thumb(settings, media.dst_filename)) # thumbnail
Given the code snippet: <|code_start|> # save the progress and abort the build if any image # fails to be encrypted save_cache(settings, cache) raise Abort key_check_path = os.path.join(settings["destination"], 'static', 'keycheck.txt')...
copy(
Given the following code snippet before the placeholder: <|code_start|> nb_items = min(nb_items, nb_medias) if nb_items > 0 else nb_medias base_url = feed_url.rsplit('/', maxsplit=1)[0] for item in medias[:nb_items]: if theme == 'galleria': link = f'{base_url}/{item.path}/#{item.url}' ...
signals.gallery_build.connect(generate_feeds)
Here is a snippet: <|code_start|> compress_settings = gallery.settings.get( 'compress_assets_options', DEFAULT_SETTINGS ) compressor = get_compressor(compress_settings) if compressor is None: return # Collecting theme assets theme_assets = [] for current_directory, _, filena...
signals.gallery_build.connect(compress_gallery)
Based on the snippet: <|code_start|> CURRENT_DIR = os.path.dirname(__file__) SAMPLE_DIR = os.path.join(CURRENT_DIR, 'sample') def test_copy(tmpdir): filename = 'KeckObservatory20071020.jpg' src = os.path.join(SAMPLE_DIR, 'pictures', 'dir2', filename) dst = str(tmpdir.join(filename)) <|code_end|> , predic...
utils.copy(src, dst)
Predict the next line for this snippet: <|code_start|> CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) BUILD_DIR = os.path.join(CURRENT_DIR, 'sample', '_build') @pytest.fixture(scope='session', autouse=True) def remove_build(): """Ensure that build directory does not exists before each test.""" if ...
for name in dir(signals):