text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>def download(): """ allows downloading of uploaded files http://..../[app]/default/download/[filename] """ return response.download(request,db) def call(): """ exposes services. for example: http://..../[app]/default/call/jsonrpc decorate with @services.jsonrpc the fu...
code_fim
hard
{ "lang": "python", "repo": "ykanggit/web2py-appliances", "path": "/RadioScheduleLogs/controllers/default.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>@auth.requires_login() def show_program(): program_id=request.args(0) db.music.program.default=program_id db.music.program.writable=db.music.program.readable=False form=crud.create(db.music) table=plugin_jqgrid(db.music,'program',program_id,columns=['id','name','file','date_onair'], ...
code_fim
hard
{ "lang": "python", "repo": "ykanggit/web2py-appliances", "path": "/RadioScheduleLogs/controllers/default.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: david-deboer/radiobear path: /radiobear/atm_base.py # -*- mode: python; coding: utf-8 -*- """Base class for atmosphere.""" # Copyright 2018 David DeBoer # Licensed under the 2-clause BSD license. import numpy as np import os import sys # ##local imports from . import utils from . import chemistr...
code_fim
hard
{ "lang": "python", "repo": "david-deboer/radiobear", "path": "/radiobear/atm_base.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.gas = np.array(self.gas) # ## Check that P is monotonically increasing monotonic = np.all(np.diff(self.gas[self.config.C['P']]) > 0.0) if not monotonic: self.gas = np.fliplr(self.gas) monotonic = np.all(np.diff(self.gas[self.config.C['P']]) > 0....
code_fim
hard
{ "lang": "python", "repo": "david-deboer/radiobear", "path": "/radiobear/atm_base.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Compute derived atmospheric properties (makes self.property).""" self.chem = {} for key in self.config.C: if key in ['P', 'T', 'Z', 'DZ']: continue self.chem[key] = chemistry.ConstituentProperties(key) # nAtm = len(self.gas[self.c...
code_fim
hard
{ "lang": "python", "repo": "david-deboer/radiobear", "path": "/radiobear/atm_base.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, crop_window_size, label_scaler, text_terms_mapper, text_b_template): text_provider = BaseSingleTextProvider(text_terms_mapper=text_terms_mapper) \ if text_b_template is None else PairTextProvider(text_b_prompt=text_b_template, ...
code_fim
hard
{ "lang": "python", "repo": "nicolay-r/AREkit", "path": "/arekit/contrib/bert/input/providers/cropped_sample.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nicolay-r/AREkit path: /arekit/contrib/bert/input/providers/cropped_sample.py from arekit.common.data.input.providers.sample.cropped import CroppedSampleRowProvider from arekit.common.data.input.providers.text.single import BaseSingleTextProvider from arekit.contrib.bert.input.providers.text_pair...
code_fim
hard
{ "lang": "python", "repo": "nicolay-r/AREkit", "path": "/arekit/contrib/bert/input/providers/cropped_sample.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>timeA = int(input("Enter hours for Person A completes the task: ")) timeB = int(input("Enter hours for Person B completes the task: ")) print("Person A completes the task in {} hours".format(timeA)) print("Person B completes the task in {} hours".format(timeB)) total_time =round(time_work_together(timeA,...
code_fim
medium
{ "lang": "python", "repo": "syedwaleedhyder/Freelance_Projects", "path": "/QuantitativeSkillsForBusiness_FinalProject/Task4_WorkTogether.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rateA = 1/timeA rateB = 1/timeB rate_total = rateA + rateB time_total = 1/rate_total return time_total timeA = int(input("Enter hours for Person A completes the task: ")) timeB = int(input("Enter hours for Person B completes the task: ")) print("Person A completes the task in {}...
code_fim
medium
{ "lang": "python", "repo": "syedwaleedhyder/Freelance_Projects", "path": "/QuantitativeSkillsForBusiness_FinalProject/Task4_WorkTogether.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: syedwaleedhyder/Freelance_Projects path: /QuantitativeSkillsForBusiness_FinalProject/Task4_WorkTogether.py # -*- coding: utf-8 -*- """ Created on Sat Apr 20 23:39:43 2019 @author: Syed Waleed Hyder """ <|fim_suffix|> return time_total timeA = int(input("Enter hours for Person A completes th...
code_fim
medium
{ "lang": "python", "repo": "syedwaleedhyder/Freelance_Projects", "path": "/QuantitativeSkillsForBusiness_FinalProject/Task4_WorkTogether.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: TurboGears/gearbox path: /gearbox/utils/copydir.py # (c) 2005 Ian Bicking and contributors; written for Paste # (http://pythonpaste.org) Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license.php import os import pkg_resources import sys if sys.version_info[0] == 3: # ...
code_fim
hard
{ "lang": "python", "repo": "TurboGears/gearbox", "path": "/gearbox/utils/copydir.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Overridden on user's request: all_answer = None def query_interactive(src_fn, dest_fn, src_content, dest_content, simulate, out_=sys.stdout): def out(msg): out_.write(msg) out_.write('\n') out_.flush() global all_answer from difflib import unifi...
code_fim
hard
{ "lang": "python", "repo": "TurboGears/gearbox", "path": "/gearbox/utils/copydir.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def makedirs(dir, verbosity, pad): parent = os.path.dirname(os.path.abspath(dir)) if not os.path.exists(parent): makedirs(parent, verbosity, pad) os.mkdir(dir) def substitute_filename(fn, vars): for var, value in vars.items(): fn = fn.replace('+%s+' % var, str(value)) ...
code_fim
hard
{ "lang": "python", "repo": "TurboGears/gearbox", "path": "/gearbox/utils/copydir.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def get_new_path(path, name): if "\\" in path: new_path = '{}\\{}'.format(path, name) elif "/" in path: new_path = '{}/{}'.format(path, name) return new_path def get_edited_filename(path): new_path = "" new_basename = "" if os.path.exists(path): if os.path....
code_fim
hard
{ "lang": "python", "repo": "open-pulse/OpenPulse", "path": "/pulse/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: open-pulse/OpenPulse path: /pulse/utils.py 1]*A[:,2,2] + A[:,0,1]*A[:,1,2]*A[:,2,0] + A[:,0,2]*A[:,1,0]*A[:,2,1] - A[:,0,2]*A[:,1,1]*A[:,2,0] - A[:,0,1]*A[:,1,0]*A[:,2,2] - A[:,0,0]*A[:,1,2]*A[:,2,1] ) b11 = A[:,1,1]*A[:,2,2] - A[:,1,2]*A[:,2,1] b12 = -( A[:,0,...
code_fim
hard
{ "lang": "python", "repo": "open-pulse/OpenPulse", "path": "/pulse/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Parameters # ---------- # msg: str # text to be displayed. # title: str # window title. # ''' # msg_box = QMessageBox() # msg_box.setWindowFlags(Qt.WindowStaysOnTopHint) # # msg_box.setWindowModality(Qt.WindowModal) # msg_box.setIcon(QMessageBox.Info...
code_fim
hard
{ "lang": "python", "repo": "open-pulse/OpenPulse", "path": "/pulse/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert get_calling_operator(2) is None class MyOperator(BaseOperator): def execute(self, context): assert get_calling_operator(2) is self test_fn() operator = MyOperator(task_id='im-a-test') assert not test_fn.called ...
code_fim
hard
{ "lang": "python", "repo": "getsentry/airflow-metrics", "path": "/tests/utils/test_fn_utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: getsentry/airflow-metrics path: /tests/utils/test_fn_utils.py from unittest import TestCase from airflow.models import BaseOperator from airflow_metrics.utils.fn_utils import once from airflow_metrics.utils.fn_utils import get_calling_operator from airflow_metrics.utils.fn_utils import get_loca...
code_fim
hard
{ "lang": "python", "repo": "getsentry/airflow-metrics", "path": "/tests/utils/test_fn_utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Verify cluster update result cluster = utils.get_a_cluster(self, self.cluster_id) self.assertEqual('ACTIVE', cluster['status']) self.assertEqual(2, len(cluster['nodes'])) self.assertEqual(self.new_profile, cluster['profile_id'])<|fim_prefix|># repo: openstack/senl...
code_fim
hard
{ "lang": "python", "repo": "openstack/senlin-tempest-plugin", "path": "/senlin_tempest_plugin/tests/functional/test_batch_policy.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: openstack/senlin-tempest-plugin path: /senlin_tempest_plugin/tests/functional/test_batch_policy.py # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apa...
code_fim
medium
{ "lang": "python", "repo": "openstack/senlin-tempest-plugin", "path": "/senlin_tempest_plugin/tests/functional/test_batch_policy.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def test_peek_invalid(): ll = DoublyLinkedList() with pytest.raises(AssertionError): ll.peek(0) ll.insert(0, 0) for i in range(-ITERS//2, ITERS//2+1): if i == 0: continue with pytest.raises(AssertionError): ll.peek(i) def test_insert_head(): ll = Do...
code_fim
hard
{ "lang": "python", "repo": "Kiracorp/data-structures", "path": "/tests/test_doubly_linked_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_pop_head(base_ll): ll = base_ll for expected in range(len(ll)): actual = ll.pop_head() assert(expected == actual) assert(ll.is_empty()) def test_pop_tail(base_ll): ll = base_ll for expected in range(len(ll)-1, -1, -1): actual = ll.pop_tail() as...
code_fim
hard
{ "lang": "python", "repo": "Kiracorp/data-structures", "path": "/tests/test_doubly_linked_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Kiracorp/data-structures path: /tests/test_doubly_linked_list.py from data_structures import DoublyLinkedList from .parameters import * import pytest, random @pytest.fixture def base_ll(): ll = DoublyLinkedList() for i in range(ITERS): ll.insert_tail(i) return ll def test_re...
code_fim
hard
{ "lang": "python", "repo": "Kiracorp/data-structures", "path": "/tests/test_doubly_linked_list.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Downloaded models: - pos-multi: Part of speech (verb, noun, etc.), multiple languages (English, German, French, Italian, Dutch, Polish, Spanish, Swedish, Danish, Norwegian, Finnish and Czech) - ner: 4-class Named Entity Recognition, english model. - sentiment-analysis: text classification, [po...
code_fim
hard
{ "lang": "python", "repo": "Aituni/NLP-praktika", "path": "/Tagger/transformer_tagging.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Downloaded models: - pos-multi: Part of speech (verb, noun, etc.), multiple languages (English, German, French, Italian, Dutch, Polish, Spanish, Swedish, Danish, Norwegian, Finnish and Czech) - ner: 4-class Named Entity Recognition, english model. - sentiment-analysis: text classification, [p...
code_fim
medium
{ "lang": "python", "repo": "Aituni/NLP-praktika", "path": "/Tagger/transformer_tagging.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Aituni/NLP-praktika path: /Tagger/transformer_tagging.py # Source: https://github.com/huggingface/transformers/blob/master/notebooks/03-pipelines.ipynb from transformers import pipeline """ This function put tags in the input text, using transformers, with the tagger model clas_type. And wri...
code_fim
hard
{ "lang": "python", "repo": "Aituni/NLP-praktika", "path": "/Tagger/transformer_tagging.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Jem-alchemist/MicroPython path: /st7789py_mpy-master/test_st7789.py # code for micropython 1.10 on esp8266 import random import machine import st7789py as st7789 import time <|fim_suffix|> while True: display.fill( st7789.color565( random.getrandbits(8),...
code_fim
hard
{ "lang": "python", "repo": "Jem-alchemist/MicroPython", "path": "/st7789py_mpy-master/test_st7789.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> spi = machine.SPI(1, baudrate=40000000, polarity=1) display = st7789.ST7789( spi, 240, 240, reset=machine.Pin(5, machine.Pin.OUT), dc=machine.Pin(2, machine.Pin.OUT), ) display.init() while True: display.fill( st7789.color565( ...
code_fim
medium
{ "lang": "python", "repo": "Jem-alchemist/MicroPython", "path": "/st7789py_mpy-master/test_st7789.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Bernardrouhi/PuppetMaster path: /puppetMaster/main.py #!/usr/bin/python from PySide2.QtCore import Qt from PySide2.QtWidgets import (QWidget, QHBoxLayout) from widgets.CustomeWidget import PuppetMaster from core.mayaHelper import get_MayaWindow TITLE = "Puppet Master v1.0.1" <|fim_suffix|> ...
code_fim
medium
{ "lang": "python", "repo": "Bernardrouhi/PuppetMaster", "path": "/puppetMaster/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def findAndLoad(self, names=list()): ''' Find the names in work folder and load them Parameters ---------- names: (list) List of dictionaries of name and namespace. ''' if names: self.pm.findAndLoad(names) def closeE...
code_fim
hard
{ "lang": "python", "repo": "Bernardrouhi/PuppetMaster", "path": "/puppetMaster/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def force_load(self, paths=list()): ''' Load list of .PII files Parameters ---------- paths: (list) List of .PII file. ''' if paths: self.pm.force_load(paths) def findAndLoad(self, names=list()): ''' ...
code_fim
hard
{ "lang": "python", "repo": "Bernardrouhi/PuppetMaster", "path": "/puppetMaster/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, message_elements, op=None): self.message += op + "|" for string in message_elements: self.message += str(string) + "|" def get_message(self): return self.message.encode()<|fim_prefix|># repo: jdiegoh3/distributed_computing path: /Projects/pr...
code_fim
hard
{ "lang": "python", "repo": "jdiegoh3/distributed_computing", "path": "/Projects/project2/lib/MyUtils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jdiegoh3/distributed_computing path: /Projects/project2/lib/MyUtils.py import socket class Elements(object): def __init__(self, elements): self.elements = elements def add_element(self, id, process_info): self.elements[id] = process_info def remove_element(self, id)...
code_fim
hard
{ "lang": "python", "repo": "jdiegoh3/distributed_computing", "path": "/Projects/project2/lib/MyUtils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def send_message(host, port, message): temporal_socket_instance = socket.socket(socket.AF_INET, socket.SOCK_STREAM) temporal_socket_instance.connect((host, port)) temporal_socket_instance.send(message) result = temporal_socket_instance.recv(1024) return result class MessageBuilder(ob...
code_fim
hard
{ "lang": "python", "repo": "jdiegoh3/distributed_computing", "path": "/Projects/project2/lib/MyUtils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> sampleStr = ''.join((random.choice(string.ascii_letters) for i in range(lettersCount))) sampleStr += ''.join((random.choice(string.digits) for i in range(digitsCount))) sampleList = list(sampleStr) random.shuffle(sampleList) finalString = ''.join(sampleList) return finalString def...
code_fim
hard
{ "lang": "python", "repo": "go8go/Dofus-Account-Generator", "path": "/src/misc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not os.path.isfile(file): ePrint("No such file : " + file) exit(1) return True<|fim_prefix|># repo: go8go/Dofus-Account-Generator path: /src/misc.py import os import sys import json import string import random import colorama from colorama import Fore, Style def ePrint(msg): ...
code_fim
medium
{ "lang": "python", "repo": "go8go/Dofus-Account-Generator", "path": "/src/misc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: go8go/Dofus-Account-Generator path: /src/misc.py import os import sys import json import string import random import colorama from colorama import Fore, Style def ePrint(msg): <|fim_suffix|>def isFileExist(file): if not os.path.isfile(file): ePrint("No such file : " + file) ...
code_fim
hard
{ "lang": "python", "repo": "go8go/Dofus-Account-Generator", "path": "/src/misc.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #route_name = os.getenv('env_route_name') #route_name = route_name.encode("utf-8") route_name = wf.decode(os.getenv('env_route_name')) log.debug("Created the route %s" % (route_name)) url = wf.decode(os.getenv('env_url')) log.debug("Created the route %s" % (url)) start_id = find_route_id(url,...
code_fim
medium
{ "lang": "python", "repo": "kimsyversen/Ruter-workflow-for-Alfred", "path": "/src/create_route.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kimsyversen/Ruter-workflow-for-Alfred path: /src/create_route.py # encoding: utf-8 from __future__ import unicode_literals, print_function import datetime, sys, os from workflow import Workflow, ICON_WEB, web from Config import Config def find_route_id(string, start_pattern, end_pattern): sta...
code_fim
medium
{ "lang": "python", "repo": "kimsyversen/Ruter-workflow-for-Alfred", "path": "/src/create_route.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> c = Config() routes = c.get_route() #route_name = os.getenv('env_route_name') #route_name = route_name.encode("utf-8") route_name = wf.decode(os.getenv('env_route_name')) log.debug("Created the route %s" % (route_name)) url = wf.decode(os.getenv('env_url')) log.debug("Created the route %s" ...
code_fim
hard
{ "lang": "python", "repo": "kimsyversen/Ruter-workflow-for-Alfred", "path": "/src/create_route.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # by hour kpis["busyness"]["by_hour"]["num_observables"] = int( kpis["busyness"]["by_hour"]["num_observables"] ) kpis["busyness"]["by_hour"]["hour_of_day"] = int( kpis["busyness"]["by_hour"]["hour_of_day"] ) kpis["busyness"]["by_hour"...
code_fim
hard
{ "lang": "python", "repo": "aileenproject/aileen-core", "path": "/aileen/data/api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aileenproject/aileen-core path: /aileen/data/api.py from django.http import JsonResponse from django.http import HttpResponse from data.models import SeenByHour from data.queries import prepare_df_datetime_index from data.queries import compute_kpis def aggregations_by_box_id(request, box_id=N...
code_fim
hard
{ "lang": "python", "repo": "aileenproject/aileen-core", "path": "/aileen/data/api.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: UMKC-BigDataLab/DiSC path: /scripts/plot/get-ave-list-size.py #!/usr/bin/env python # -*- coding: utf-8 -*- # # Anas Katib # May 19, 2017 # # Usage: ./get-ave-list-size.py -h import argparse import sys import time def eprint(obj): sys.stderr.write(obj) sys.stderr.write('\n') def main(args)...
code_fim
hard
{ "lang": "python", "repo": "UMKC-BigDataLab/DiSC", "path": "/scripts/plot/get-ave-list-size.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Rename the arguements' title. The default (i.e. positional arguments) # is a bit confusing to users. parser._positionals.title = "required arguments" args = parser.parse_args() main(args)<|fim_prefix|># repo: UMKC-BigDataLab/DiSC path: /scripts/plot/get-ave-list-size.py #!/usr/bin/env python...
code_fim
hard
{ "lang": "python", "repo": "UMKC-BigDataLab/DiSC", "path": "/scripts/plot/get-ave-list-size.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #eprint("Done in "+str(eTime - sTime) + 's' ) if __name__ == "__main__": prog_desc = "The program reads DiSC visible families statistics file(s) and computes the avearge "\ "list size (i.e. the number of families) for all nodes."\ parser = argparse.ArgumentParser(description = prog_desc, add_...
code_fim
medium
{ "lang": "python", "repo": "UMKC-BigDataLab/DiSC", "path": "/scripts/plot/get-ave-list-size.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AddField( model_name='pontoturistico', name='review_list', field=models.ManyToManyField(to='reviews.Review'), ), ]<|fim_prefix|># repo: mhiloca/TourismApi path: /core/migrations/0005_pontoturistico_review_list.py # Gene...
code_fim
medium
{ "lang": "python", "repo": "mhiloca/TourismApi", "path": "/core/migrations/0005_pontoturistico_review_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mhiloca/TourismApi path: /core/migrations/0005_pontoturistico_review_list.py # Generated by Django 2.2.5 on 2019-09-14 22:19 from django.db import migrations, models <|fim_suffix|> operations = [ migrations.AddField( model_name='pontoturistico', name='review_l...
code_fim
medium
{ "lang": "python", "repo": "mhiloca/TourismApi", "path": "/core/migrations/0005_pontoturistico_review_list.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DeepCoin/counterpartyd path: /lib/send.py #! /usr/bin/python3 """Create and parse 'send'-type messages.""" import struct import logging from . import (util, config, exceptions, bitcoin, util) FORMAT = '>QQ' ID = 0 LENGTH = 8 + 8 def create (db, source, destination, amount, asset, test=False)...
code_fim
hard
{ "lang": "python", "repo": "DeepCoin/counterpartyd", "path": "/lib/send.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> # Debit. if validity == 'Valid': if not amount: validity = 'Invalid: zero quantity.' validity = util.debit(db, tx['source'], asset, amount) # Credit. if validity == 'Valid': util.credit(db, tx['destination'], asset, amount) # Add parsed transaction...
code_fim
hard
{ "lang": "python", "repo": "DeepCoin/counterpartyd", "path": "/lib/send.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: Open-EO/openeo-sentinelhub-python-driver path: /rest/buckets/utils.py import os import warnings from const import SentinelhubDeployments from utils import get_env_var from .results_bucket import ResultsBucket, CreodiasResultsBucket BUCKET_NAMES = { SentinelhubDeployments.MAIN: get_env_var(...
code_fim
hard
{ "lang": "python", "repo": "Open-EO/openeo-sentinelhub-python-driver", "path": "/rest/buckets/utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def get_bucket(deployment_endpoint): bucket_name = BUCKET_NAMES[deployment_endpoint] region_name = BUCKET_REGION_NAMES[deployment_endpoint] endpoint_url = BUCKET_ENDPOINT_URLS[deployment_endpoint] access_key_id = BUCKET_ACCESS_KEY_IDS[deployment_endpoint] secret_access_key = BUCKET_SE...
code_fim
hard
{ "lang": "python", "repo": "Open-EO/openeo-sentinelhub-python-driver", "path": "/rest/buckets/utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_serenaded.py from xai.brain.wordbase.verbs._serenade import _SERENADE #calss header class _SERENADED(_SERENADE, ): <|fim_suffix|> _SERENADE.__init__(self) self.name = "SERENADED" self.specie = 'verbs' self.basic = "serenade" self.jsondata ...
code_fim
easy
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/verbs/_serenaded.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _SERENADE.__init__(self) self.name = "SERENADED" self.specie = 'verbs' self.basic = "serenade" self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_serenaded.py from xai.brain.wordbase.verbs._serenade import _SERENADE #calss header class _SERENADED(_SERENADE,...
code_fim
easy
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/verbs/_serenaded.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: phrb/orio_experiments path: /orio/module/ortildriver/transformation.py sed to represent a k-ary multiplication. """ if isinstance(exp, ast.NumLitExp): if up_sign == -1: exp.val *= -1 return exp elif isinstance(exp, ast.StringLitExp...
code_fim
hard
{ "lang": "python", "repo": "phrb/orio_experiments", "path": "/orio/module/ortildriver/transformation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif isinstance(tnode, ast.ExpStmt): if tnode.exp: tnode.exp = self.__addIdentWithConstant(tnode.exp, iname, constant) return tnode elif isinstance(tnode, ast.CompStmt): tnode.stmts = [ self.__addIdentWithConstant(s, inam...
code_fim
hard
{ "lang": "python", "repo": "phrb/orio_experiments", "path": "/orio/module/ortildriver/transformation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # recursively unroll its loop body ubody = self.__unroll(lbody, unroll_factor_table) # unroll the loop body ufactor = unroll_factor_table[id.name] ustmts = [] for i in range(0, ufactor): s = ubody.replicate() ...
code_fim
hard
{ "lang": "python", "repo": "phrb/orio_experiments", "path": "/orio/module/ortildriver/transformation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: fnet123/SwarmOps path: /src/apis/core.py # -*- coding:utf-8 -*- from flask import Blueprint, request, g from flask_restful import Api, Resource from utils.public import logger class Swarm(Resource): def get(self): """ 查询存储的swarm集群信息 """ get = request.args.get("get") ...
code_fim
hard
{ "lang": "python", "repo": "fnet123/SwarmOps", "path": "/src/apis/core.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if g.auth: return g.node.GET() else: res = {"msg": "Authentication failed, permission denied.", "code": 403} logger.warn(res) return res, 403 def post(self): """create a node into swarm cluster""" Ip = request.form.get...
code_fim
hard
{ "lang": "python", "repo": "fnet123/SwarmOps", "path": "/src/apis/core.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cv2.imshow('Face', img) if cv2.waitKey(1) & 0xFF == ord('q'): break video_capture.release() cv2.destroyAllWindows()<|fim_prefix|># repo: focaaby/multiple-media-final path: /original/detector.py import numpy as np import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_d...
code_fim
hard
{ "lang": "python", "repo": "focaaby/multiple-media-final", "path": "/original/detector.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: focaaby/multiple-media-final path: /original/detector.py import numpy as np import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') video_capture = cv2.VideoCapture(0) rec = cv2.face.createLBPHFaceRecognizer() rec.load("recognizer/trainingData.xml") id = 0 name = "...
code_fim
hard
{ "lang": "python", "repo": "focaaby/multiple-media-final", "path": "/original/detector.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shubhi13/Python_Scripts path: /Automation/mail-automation/mailing/views.py import smtplib from django.http import request from django.shortcuts import render,redirect # from django.http import HttpResponse from django.core.files.storage import FileSystemStorage from email.mime.multipart import MI...
code_fim
hard
{ "lang": "python", "repo": "shubhi13/Python_Scripts", "path": "/Automation/mail-automation/mailing/views.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> uploaded_file1=request.FILES['pdf2'] uploaded_file2=request.FILES['pdf3'] fs1=FileSystemStorage() fs1.save(uploaded_file1.name,uploaded_file1) fs1.save(uploaded_file2.name,uploaded_file2) ...
code_fim
hard
{ "lang": "python", "repo": "shubhi13/Python_Scripts", "path": "/Automation/mail-automation/mailing/views.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>for ii, toll in enumerate(tol): # Run PARAFAC decomposition without line search and time start = time() fac = parafac(tensor, rank=3, n_iter_max=2000000, tol=toll) tt[ii] = time() - start # Run PARAFAC decomposition with line search and time start = time() fac_ls = parafac(tensor,...
code_fim
hard
{ "lang": "python", "repo": "szha/tensorly", "path": "/examples/decomposition/parafac_line_search.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: szha/tensorly path: /examples/decomposition/parafac_line_search.py """ Using line search with PARAFAC ========================================== Example on how to use :func:`tensorly.decomposition.parafac` with line search to accelerate convergence. """ from time import time import numpy as np ...
code_fim
hard
{ "lang": "python", "repo": "szha/tensorly", "path": "/examples/decomposition/parafac_line_search.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> logger.debug("Waiting %s seconds...", delay) time.sleep(delay) def run_import_on_slave(script): # type: (Script) -> None logger.info("Importer running in slave mode, not doing anything") while True: delay = 60 logger.debug("Waiting %d seconds...", delay) ...
code_fim
hard
{ "lang": "python", "repo": "acoustid/acoustid-server", "path": "/acoustid/scripts/import_submissions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: acoustid/acoustid-server path: /acoustid/scripts/import_submissions.py #!/usr/bin/env python # Copyright (C) 2012-2013 Lukas Lalinsky # Distributed under the MIT license, see the LICENSE file for details. import json import logging import time from typing import Any, Dict, Optional from acoust...
code_fim
hard
{ "lang": "python", "repo": "acoustid/acoustid-server", "path": "/acoustid/scripts/import_submissions.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # type: (Script) -> None logger.info("Importer running in master mode") # listen for new submissins and import them as they come min_delay = 1.0 max_delay = 10.0 delay_update_coefficient = 1.3 delay = min_delay while True: try: imported = do_import(sc...
code_fim
hard
{ "lang": "python", "repo": "acoustid/acoustid-server", "path": "/acoustid/scripts/import_submissions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>while True: n = menu(['Cadastrar Pessoas','Lista de Pessoas','Sair do Sistema']) if n == 3: final() break elif n == 1: cabecalho('Cadastrar Pessoas') nome = str(input('Nome: ')).title().strip() idade = leiaInt('Idade: ') cadastrarPessoa(Arq, nom...
code_fim
medium
{ "lang": "python", "repo": "josivantarcio/Desafios-em-Python", "path": "/Desafios/desafio115.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: josivantarcio/Desafios-em-Python path: /Desafios/desafio115.py from utilidadesCeV.menu import * from utilidadesCeV.arquivo import * <|fim_suffix|>while True: n = menu(['Cadastrar Pessoas','Lista de Pessoas','Sair do Sistema']) if n == 3: final() break elif n == 1: ...
code_fim
medium
{ "lang": "python", "repo": "josivantarcio/Desafios-em-Python", "path": "/Desafios/desafio115.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: junpenglao/Planet_Sakaar_Data_Science path: /Miscellaneous/test_script_pymc3/multinominal.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 11 13:30:53 2017 @author: laoj """ import numpy as np import pymc3 as pm import theano.tensor as tt from pymc3.distributions.distribu...
code_fim
hard
{ "lang": "python", "repo": "junpenglao/Planet_Sakaar_Data_Science", "path": "/Miscellaneous/test_script_pymc3/multinominal.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> const = (tt.gammaln(n + 1) + tt.gammaln(sum_alpha)) - tt.gammaln(n + sum_alpha) series = tt.gammaln(x + alpha) - (tt.gammaln(x + 1) + tt.gammaln(alpha)) result = const + tt.sum(series, axis=-1) return result def as_col(x): if isinstance(x, tt.TensorVariable): r...
code_fim
hard
{ "lang": "python", "repo": "junpenglao/Planet_Sakaar_Data_Science", "path": "/Miscellaneous/test_script_pymc3/multinominal.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lsh3163/ai-motorcycle path: /ai_car/rc_car_interface.py # Copyright(c) Reserved 2020. # Donghee Lee, University of Soul # __author__ = 'will' import numpy as np import cv2 import serial from picamera.array import PiRGBArray from picamera import PiCamera class RC_Car_Interface(): def __init...
code_fim
hard
{ "lang": "python", "repo": "lsh3163/ai-motorcycle", "path": "/ai_car/rc_car_interface.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> img = np.empty((320, 320, 3), dtype=np.uint8) self.camera.capture(img, 'bgr') img = img[:,:,0] # 3 dimensions have the same value because camera is set to black and white # remove two dimension data threshold = ...
code_fim
hard
{ "lang": "python", "repo": "lsh3163/ai-motorcycle", "path": "/ai_car/rc_car_interface.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LIMUNIMI/MMSP2021-Audio2ScoreAlignment path: /alignment/asmd/docs/conf.py # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configurat...
code_fim
hard
{ "lang": "python", "repo": "LIMUNIMI/MMSP2021-Audio2ScoreAlignment", "path": "/alignment/asmd/docs/conf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>project = 'ASMD' copyright = '2020, Federico Simonetta' author = 'Federico Simonetta' # The full version, including alpha/beta/rc tags release = '0.1' # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # e...
code_fim
hard
{ "lang": "python", "repo": "LIMUNIMI/MMSP2021-Audio2ScoreAlignment", "path": "/alignment/asmd/docs/conf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert say_hello("Jon") == "Hello, Jon!"<|fim_prefix|># repo: cndipowa/hellopython path: /test_hellopython.py from hellopython import say_hello <|fim_middle|>def test_hellopython_no_params(): assert say_hello() == "Hello, World!" def test_hellopython_with_params():
code_fim
medium
{ "lang": "python", "repo": "cndipowa/hellopython", "path": "/test_hellopython.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cndipowa/hellopython path: /test_hellopython.py from hellopython import say_hello <|fim_suffix|>def test_hellopython_with_params(): assert say_hello("Jon") == "Hello, Jon!"<|fim_middle|>def test_hellopython_no_params(): assert say_hello() == "Hello, World!"
code_fim
medium
{ "lang": "python", "repo": "cndipowa/hellopython", "path": "/test_hellopython.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if len(args.files) % 2 != 0: print("must have pairs of files") sys.exit(1) file_pairs = list(zip(args.files[0:-1:2], args.files[1::2])) for path_a, path_b in file_pairs: process_pointcloud(path_a, path_b, args.nogui) if __name__ == '__main__': main()<|fim_prefix...
code_fim
medium
{ "lang": "python", "repo": "Rookfighter/least-squares-cpp", "path": "/scripts/plot_pointclouds.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def main(): args = parse_args() if len(args.files) % 2 != 0: print("must have pairs of files") sys.exit(1) file_pairs = list(zip(args.files[0:-1:2], args.files[1::2])) for path_a, path_b in file_pairs: process_pointcloud(path_a, path_b, args.nogui) if __name__ ...
code_fim
hard
{ "lang": "python", "repo": "Rookfighter/least-squares-cpp", "path": "/scripts/plot_pointclouds.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Rookfighter/least-squares-cpp path: /scripts/plot_pointclouds.py import argparse import sys import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def parse_args(): parser = argparse.ArgumentParser(description='Plot point clouds') parser.add_argument(...
code_fim
hard
{ "lang": "python", "repo": "Rookfighter/least-squares-cpp", "path": "/scripts/plot_pointclouds.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abandonsea/RGBD-Seg path: /my_train.py import argparse import os import random import shutil from src.prepare_data import prepare_data from src.args import ArgumentParserRGBDSegmentation import time import warnings import torch import torch.nn as nn import torch.nn.parallel import torch.backends...
code_fim
hard
{ "lang": "python", "repo": "abandonsea/RGBD-Seg", "path": "/my_train.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Data loading code traindir = os.path.join(args.data, 'train') valdir = os.path.join(args.data, 'val') normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) train_dataset = datasets.ImageFolder( traindir, ...
code_fim
hard
{ "lang": "python", "repo": "abandonsea/RGBD-Seg", "path": "/my_train.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: vinnyotach7/Personal-Blog path: /app/main/forms.py from flask_wtf import FlaskForm from wtforms import StringField,TextAreaField,SubmitField from wtforms.validators import Required class BlogForm(FlaskForm): user = StringField('Your name',validators=[Required()]) <|fim_suffix|>class Dele...
code_fim
hard
{ "lang": "python", "repo": "vinnyotach7/Personal-Blog", "path": "/app/main/forms.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> user = StringField('Your name',validators=[Required()]) heading = StringField('Blog Heading',validators=[Required()]) blog = TextAreaField('Your blog',validators=[Required()]) submit = SubmitField('Post') class CommentForm(FlaskForm): user = StringField('Your name',validator...
code_fim
medium
{ "lang": "python", "repo": "vinnyotach7/Personal-Blog", "path": "/app/main/forms.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nihonjinrxs/flask-dotenv path: /flask_dotenv.py """ FLask-DotEnv :copyright: (c) 2015 by Yasuhiro Asaka. :license: BSD 2-Clause License """ from __future__ import absolute_import import ast import os import re import warnings class DotEnv(object): """The .env file support for Flask.""" ...
code_fim
hard
{ "lang": "python", "repo": "nihonjinrxs/flask-dotenv", "path": "/flask_dotenv.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> with open(env_file, "r") as f: for line in f: try: key, value = line.strip().split('=', 1) except ValueError: # Take care of blank or comment lines pass try: val = ast.literal_e...
code_fim
hard
{ "lang": "python", "repo": "nihonjinrxs/flask-dotenv", "path": "/flask_dotenv.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def __import_vars(self, env_file): with open(env_file, "r") as f: for line in f: try: key, value = line.strip().split('=', 1) except ValueError: # Take care of blank or comment lines pass try: ...
code_fim
hard
{ "lang": "python", "repo": "nihonjinrxs/flask-dotenv", "path": "/flask_dotenv.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """ Calculate bounding boxes components :param np.ndarray segmentation: array for which bounds boxes should be calculated :return: mapping component number to bounding box :rtype: Dict[int, BoundInfo] """ bound_info = {} count = np.max(segme...
code_fim
hard
{ "lang": "python", "repo": "monotropauniflora/PartSeg", "path": "/package/PartSegCore/segmentation_info.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> class SegmentationInfo: """ Object to storage meta information about given segmentation. Segmentation array is only referenced, not copied. :ivar numpy.ndarray ~.segmentation: reference to segmentation :ivar Dict[int,BoundInfo] bound_info: mapping from component number to bounding bo...
code_fim
medium
{ "lang": "python", "repo": "monotropauniflora/PartSeg", "path": "/package/PartSegCore/segmentation_info.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: monotropauniflora/PartSeg path: /package/PartSegCore/segmentation_info.py from typing import Dict, List, NamedTuple, Optional import numpy as np from PartSegCore.utils import numpy_repr from PartSegImage.image import minimal_dtype class BoundInfo(NamedTuple): """ Information about bou...
code_fim
medium
{ "lang": "python", "repo": "monotropauniflora/PartSeg", "path": "/package/PartSegCore/segmentation_info.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: s-c-p/date-forensics-fs path: /dateCheck.py # https://codereview.stackexchange.com/questions/37465/compare-last-modification-time-with-specfied-time import os import sqlite3 import logging import datetime op = os.path HERE = os.getcwd() logging.basicConfig(filename=r".\errors.log", level=30) ...
code_fim
hard
{ "lang": "python", "repo": "s-c-p/date-forensics-fs", "path": "/dateCheck.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def main(): with open("places-to-scan.txt", mode="rt") as fh: locations = fh.readlines() _stripper = lambda x: x.strip() _rejectEmpty = lambda x: True if x else False locations = filter(_rejectEmpty, map(_stripper, locations)) locations = [_ for _ in locations] with sqlite3.connect("analyses.db")...
code_fim
hard
{ "lang": "python", "repo": "s-c-p/date-forensics-fs", "path": "/dateCheck.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if user.is_anonymous: oip = get_ip(request) ips = oip.split(".")[:-1] ip = ".".join(ips) if ip in settings.IP_WHITELIST: return get_response(request) if ip not in cache: cache.set(ip, 0, settings.TIME_PER...
code_fim
hard
{ "lang": "python", "repo": "jelyware/biostar-central", "path": "/biostar/forum/middleware.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jelyware/biostar-central path: /biostar/forum/middleware.py import logging import time from socket import gethostbyaddr, gethostbyname from django.conf import settings from django.contrib import messages from django.contrib.auth import logout from django.core.cache import cache from django.short...
code_fim
hard
{ "lang": "python", "repo": "jelyware/biostar-central", "path": "/biostar/forum/middleware.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if settings.DEBUG: return get_response(request) if user.is_anonymous: oip = get_ip(request) ips = oip.split(".")[:-1] ip = ".".join(ips) if ip in settings.IP_WHITELIST: return get_response(request) i...
code_fim
hard
{ "lang": "python", "repo": "jelyware/biostar-central", "path": "/biostar/forum/middleware.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DemoVersion/theanolm path: /tests/theanolm/textscorer_test.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import unittest import os import numpy from theano import tensor from theanolm import Vocabulary from theanolm.scoring import TextScorer from numpy.testing import assert_almost_equal cla...
code_fim
hard
{ "lang": "python", "repo": "DemoVersion/theanolm", "path": "/tests/theanolm/textscorer_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def setUp(self): script_path = os.path.dirname(os.path.realpath(__file__)) vocabulary_path = os.path.join(script_path, 'vocabulary.txt') with open(vocabulary_path) as vocabulary_file: self.vocabulary = Vocabulary.from_file(vocabulary_file, 'words') self.dumm...
code_fim
hard
{ "lang": "python", "repo": "DemoVersion/theanolm", "path": "/tests/theanolm/textscorer_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pass def test_score_batch(self): # Network predicts <unk> probability. scorer = TextScorer(self.dummy_network) word_ids = numpy.arange(6).reshape((3, 2)) class_ids = numpy.arange(6).reshape((3, 2)) membership_probs = numpy.ones_like(word_ids).astype('fl...
code_fim
hard
{ "lang": "python", "repo": "DemoVersion/theanolm", "path": "/tests/theanolm/textscorer_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self): name = "Ensure Cosmos DB accounts have restricted access" id = "CKV_AZURE_99" supported_resources = ['azurerm_cosmosdb_account'] categories = [CheckCategories.NETWORKING] super().__init__(name=name, id=id, categories=categories, supported_res...
code_fim
hard
{ "lang": "python", "repo": "bridgecrewio/checkov", "path": "/checkov/terraform/checks/resource/azure/CosmosDBAccountsRestrictedAccess.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bridgecrewio/checkov path: /checkov/terraform/checks/resource/azure/CosmosDBAccountsRestrictedAccess.py from checkov.common.models.enums import CheckResult, CheckCategories from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck <|fim_suffix|> def scan_resource_con...
code_fim
hard
{ "lang": "python", "repo": "bridgecrewio/checkov", "path": "/checkov/terraform/checks/resource/azure/CosmosDBAccountsRestrictedAccess.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }