text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> json = request.get_json()
(alpha, beta) = (
pickle.loads(base64.b64decode(json['alpha'])),
pickle.loads(base64.b64decode(json['beta']))
)
return measure_controller.post_qubit(alpha, beta)
# クライアントは次のようなJSON形式で`x`と`a`を公開する。
# {'a': 0, 'x': 0}
# また、HTTPのセッション(Cookie)情報をもとに... | code_fim | hard | {
"lang": "python",
"repo": "y-yu/qrand",
"path": "/server/src/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yzgyyang/dependency_management path: /dependency_management/requirements/CondaRequirement.py
from sarge import run, Capture
from dependency_management.requirements.ExecutableRequirement import (
ExecutableRequirement)
from dependency_management.requirements.PackageRequirement import (
Pa... | code_fim | medium | {
"lang": "python",
"repo": "yzgyyang/dependency_management",
"path": "/dependency_management/requirements/CondaRequirement.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param return: True if dependency is installed, false otherwise.
"""
cmd = 'conda list {} | grep "^{}"'
if not run(cmd.format(self.package, self.package), stdout=Capture(),
stderr=Capture()).returncode:
return True
return False<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "yzgyyang/dependency_management",
"path": "/dependency_management/requirements/CondaRequirement.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.ConfigVarsDebugPanel',
'flask_debugtoolbar.panels.template.TemplateDebugPanel',
'flask_debugtoolbar.panels.logger.LoggingPanel',
'flask_debugtoolbar.panels.route_list.RouteListDebugPanel',
'flask_debugtoolbar.panels.profiler.... | code_fim | hard | {
"lang": "python",
"repo": "mcorreaiz/sqm-webapp",
"path": "/sqmwebapp/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>RouteListDebugPanel',
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
'flask_mongoengine.panels.MongoDebugPanel']
MAIL_SERVER ='smtp.gmail.com'
MAIL_PORT = 465
MAIL_USE_SSL = True<|fim_prefix|># repo: mcorreaiz/sqm-webapp path: /sqmwebapp/config.py
import ... | code_fim | hard | {
"lang": "python",
"repo": "mcorreaiz/sqm-webapp",
"path": "/sqmwebapp/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcorreaiz/sqm-webapp path: /sqmwebapp/config.py
import sys
APP_URL = 'notas-sqm.azurewebsites.net'
PREFERRED_URL_SCHEME = 'https'
MONGODB_HOST = 'mongodb://127.0.0.1:27017'
ALLOWED_EXTENSIONS = set(['doc', 'docx'])
DEBUG_TB_PANELS = ['flask_debugtoolbar.panels.versions.Versi<|fim_suffix|>RouteLi... | code_fim | hard | {
"lang": "python",
"repo": "mcorreaiz/sqm-webapp",
"path": "/sqmwebapp/config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: olavosamp/semiauto-video-annotation path: /run/old_scripts/run_dataset_inference.py
import os
import torch
import math
import random
import numpy as np
import pandas as pd
import torchvision.datasets as datasets
from PIL import Image
from pathlib ... | code_fim | hard | {
"lang": "python",
"repo": "olavosamp/semiauto-video-annotation",
"path": "/run/old_scripts/run_dataset_inference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> imagePathList = unlabelIndex.index["FramePath"].values
datasetLen = len(imagePathList)
print("\nDataset information: ")
print("\t", datasetLen, "images.")
# ImageNet statistics
mean = commons.IMAGENET_MEAN
std = commons.IMAGENET_STD
# Set transforms
da... | code_fim | hard | {
"lang": "python",
"repo": "olavosamp/semiauto-video-annotation",
"path": "/run/old_scripts/run_dataset_inference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # # Find upper threshold
# upperThreshList = np.arange(1., 0., -0.001)
# idealUpperThresh = dutils.find_ideal_upper_thresh(outputs, labels, upperThreshList)
# # Find lower threshold
# lowerThreshList = np.arange(0., 1., 0.001)
# idealLowerThresh = dutils.find_ideal_lower_thresh(ou... | code_fim | hard | {
"lang": "python",
"repo": "olavosamp/semiauto-video-annotation",
"path": "/run/old_scripts/run_dataset_inference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KumarManas04/ReUnite path: /DeeplearningAndAzure/utils.py
#LNM Hacks 4.0
#Anubhav Natani
#imports
import numpy as np
import matplotlib.pyplot as plt
import cv2
from mtcnn.mtcnn import MTCNN
from keras_facenet import FaceNet
from scipy.spatial import distance
import scipy
#variables
embedder = F... | code_fim | hard | {
"lang": "python",
"repo": "KumarManas04/ReUnite",
"path": "/DeeplearningAndAzure/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_match_score(dist):
#different thershold can be selected
if(dist>1):
return 0
else:
return 1<|fim_prefix|># repo: KumarManas04/ReUnite path: /DeeplearningAndAzure/utils.py
#LNM Hacks 4.0
#Anubhav Natani
#imports
import numpy as np
import matplotlib.pyplot as plt
import cv2
from mtcn... | code_fim | hard | {
"lang": "python",
"repo": "KumarManas04/ReUnite",
"path": "/DeeplearningAndAzure/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yoosofan/momoko path: /perf_test.py
from __future__ import print_function
from __future__ import absolute_import
import threading
from tests import *
"""
Quick and dirty performance test - async vs threads.
By default Postgresql is configured to support up 100 connections.
Change max_connectio... | code_fim | hard | {
"lang": "python",
"repo": "yoosofan/momoko",
"path": "/perf_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> db = self.build_pool_sync(dsn=good_dsn, size=thread_num)
start = time.time()
def runner(x):
futures = []
for j in range(amount):
futures.append(db.execute(self.query))
yield futures
gen_test(timeout=300)(runner)(self)
... | code_fim | hard | {
"lang": "python",
"repo": "yoosofan/momoko",
"path": "/perf_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MahmudX/Algorithms path: /Sorted Squared Array/sortedSquaredArray.py
from collections import deque
def sortedSquaredArray(array):
sortedArray = []
left = 0
right = len(array) - 1
while True:
if left == right:
sortedArray.insert(0, abs(array[right])**... | code_fim | medium | {
"lang": "python",
"repo": "MahmudX/Algorithms",
"path": "/Sorted Squared Array/sortedSquaredArray.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> arr = [-10, 1, 9, 9, 10]
print(sortedSquaredArray(arr))
if __name__ == "__main__":
main()<|fim_prefix|># repo: MahmudX/Algorithms path: /Sorted Squared Array/sortedSquaredArray.py
from collections import deque
def sortedSquaredArray(array):
sortedArray = []
left = 0
... | code_fim | medium | {
"lang": "python",
"repo": "MahmudX/Algorithms",
"path": "/Sorted Squared Array/sortedSquaredArray.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
arr = [-10, 1, 9, 9, 10]
print(sortedSquaredArray(arr))
if __name__ == "__main__":
main()<|fim_prefix|># repo: MahmudX/Algorithms path: /Sorted Squared Array/sortedSquaredArray.py
from collections import deque
def sortedSquaredArray(array):
<|fim_middle|> sortedAr... | code_fim | hard | {
"lang": "python",
"repo": "MahmudX/Algorithms",
"path": "/Sorted Squared Array/sortedSquaredArray.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return struct.unpack("<B", self.readData(1))[0]
def readU16(self):
return struct.unpack("<H", self.readData(2))[0]
def readU32(self):
return struct.unpack("<I", self.readData(4))[0]
def readString(self):
slen = self.readU8()
if slen == 0:
... | code_fim | hard | {
"lang": "python",
"repo": "CarltonSemple/seniordesign",
"path": "/parrot/packages/libARCommands/WiresharkPlugin/ardump.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CarltonSemple/seniordesign path: /parrot/packages/libARCommands/WiresharkPlugin/ardump.py
#!/usr/bin/env python
import sys, os
import struct
import dpkt
import socket
from cStringIO import StringIO
_MAGIC = 0x21 # '!'
_TAG_NETAL_FRAME_PUSHED = 0x10
_TAG_NETAL_DATA_SENT = 0x11
_TAG_NETAL_DATA_R... | code_fim | hard | {
"lang": "python",
"repo": "CarltonSemple/seniordesign",
"path": "/parrot/packages/libARCommands/WiresharkPlugin/ardump.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._size - self._src.tell()
###############################################################################
###############################################################################
class ArDumpPacket(object):
def __init__(self, tag, sizeReal, sizeDump, data, timestamp):
... | code_fim | hard | {
"lang": "python",
"repo": "CarltonSemple/seniordesign",
"path": "/parrot/packages/libARCommands/WiresharkPlugin/ardump.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def generate_svm_model(ejemplos, respuestas, function_shape, tipo_kernel):
#ejemplos = numpy.array(readCSV('./iris.csv')).astype('float')
#print(ejemplos)
#respuestas = readCSV('./iris_target.csv')
#print("----------------------------------")
#print(respuestas[0])
X = ejemplos
Y = respuest... | code_fim | hard | {
"lang": "python",
"repo": "adalvarez/tec.ia.2018.acm",
"path": "/src/tec/ic/ia/p1/svm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adalvarez/tec.ia.2018.acm path: /src/tec/ic/ia/p1/svm.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sklearn import svm
import csv
import numpy
#Valores posibles para el parametro kernel:
#linear polynomial, rbf, sigmoid
def readCSV(filename):
with open(filename, 'r', encoding="ISO... | code_fim | hard | {
"lang": "python",
"repo": "adalvarez/tec.ia.2018.acm",
"path": "/src/tec/ic/ia/p1/svm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aminekun90/MDLHELib path: /reset_makefile.py
#!/usr/bin/python
from os import listdir
from os.path import isdir, join
from subprocess import call
import sys
import uuid
def process(dirpath):
<|fim_suffix|>def main():
if len(sys.argv) == 2:
process(sys.argv[1])
if __name__ == "__main__":
main... | code_fim | hard | {
"lang": "python",
"repo": "aminekun90/MDLHELib",
"path": "/reset_makefile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
if len(sys.argv) == 2:
process(sys.argv[1])
if __name__ == "__main__":
main()<|fim_prefix|># repo: aminekun90/MDLHELib path: /reset_makefile.py
#!/usr/bin/python
from os import listdir
from os.path import isdir, join
from subprocess import call
import sys
import uuid
def process(dirpath)... | code_fim | hard | {
"lang": "python",
"repo": "aminekun90/MDLHELib",
"path": "/reset_makefile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mit-han-lab/once-for-all path: /ofa/utils/pytorch_modules.py
# Once for All: Train One Network and Specialize it for Efficient Deployment
# Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han
# International Conference on Learning Representations (ICLR), 2020.
import torch
import torch.nn ... | code_fim | hard | {
"lang": "python",
"repo": "mit-han-lab/once-for-all",
"path": "/ofa/utils/pytorch_modules.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(MyGlobalAvgPool2d, self).__init__()
self.keep_dim = keep_dim
def forward(self, x):
return x.mean(3, keepdim=self.keep_dim).mean(2, keepdim=self.keep_dim)
def __repr__(self):
return "MyGlobalAvgPool2d(keep_dim=%s)" % self.keep_dim
class Hswish(nn.Module):
... | code_fim | hard | {
"lang": "python",
"repo": "mit-han-lab/once-for-all",
"path": "/ofa/utils/pytorch_modules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>l*(n-0.5)
l=math.sin(math.pi*(n-2.0)/(2*n))*l
print s<|fim_prefix|># repo: mimijilu/abc path: /短学期part5/5e.py
import math
T=int(input())
for t in range(T):
n,k=map(int,raw_input().split())
l=input()
s=0;
for i in r<|fim_middle|>ange(0,k+1):
if(i==k): s+= l*(n-1.0)
else:
s+= | code_fim | easy | {
"lang": "python",
"repo": "mimijilu/abc",
"path": "/短学期part5/5e.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mimijilu/abc path: /短学期part5/5e.py
import math
T=int(input())
for t in range(T):
n,k=map<|fim_suffix|>ange(0,k+1):
if(i==k): s+= l*(n-1.0)
else:
s+= l*(n-0.5)
l=math.sin(math.pi*(n-2.0)/(2*n))*l
print s<|fim_middle|>(int,raw_input().split())
l=input()
s=0;
for i in r | code_fim | easy | {
"lang": "python",
"repo": "mimijilu/abc",
"path": "/短学期part5/5e.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bananajoe182/tello-yolo path: /controller.py
lambda: self.set_speed("yaw", 0),
'Key.up': lambda: self.set_speed("throttle", 0),
'Key.down': lambda: self.set_speed("throttle", 0)
}
if self.kbd_layout == "AZERTY":
self.controls_keypress = control... | code_fim | hard | {
"lang": "python",
"repo": "bananajoe182/tello-yolo",
"path": "/controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # except:
# print('not possible')
# self.prev_voice_command = voice
def process_frame(self, raw_frame, detection_all):
"""
Analyze the frame and return the frame with info... | code_fim | hard | {
"lang": "python",
"repo": "bananajoe182/tello-yolo",
"path": "/controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bananajoe182/tello-yolo path: /controller.py
_rec_array):
""" Get and process Voice Commands
"""
if self.use_voice:
voice = voice_rec_array[0]
if self.prev_voice_command != voice:
print... | code_fim | hard | {
"lang": "python",
"repo": "bananajoe182/tello-yolo",
"path": "/controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: data2health/philter-ucsf path: /improve_i2b2_notes.py
import pandas
import xml.etree.ElementTree as ET
import sys
import argparse
sys.path
sys.path.append('/usr/local/lib/python2.7/site-packages/')
import xmltodict
import os
import pandas as pd
import re
# This script removes PHI tags that are ... | code_fim | hard | {
"lang": "python",
"repo": "data2health/philter-ucsf",
"path": "/improve_i2b2_notes.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for key, value in tags_dict.items():
# Note: Value can be a list of like phi elements
# or a dictionary of the metadata about a phi element
if isinstance(value, list):
for final_value in value:
# do checks
text = final_value["@text"]
phi_type = final_value["@TYPE"]
... | code_fim | hard | {
"lang": "python",
"repo": "data2health/philter-ucsf",
"path": "/improve_i2b2_notes.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bleck9999/Kurisu path: /utils/context.py
from __future__ import annotations
import discord
from discord.ext import commands
from typing import Union, Optional, TYPE_CHECKING
if TYPE_CHECKING:
from kurisu import Kurisu
<|fim_suffix|> async def get_user(self, user_id: int) -> Optional[U... | code_fim | medium | {
"lang": "python",
"repo": "bleck9999/Kurisu",
"path": "/utils/context.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class GuildContext(KurisuContext):
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]
author: discord.Member
guild: discord.Guild<|fim_prefix|># repo: bleck9999/Kurisu path: /utils/context.py
from __future__ import annotations
import discord
from discord.ext import co... | code_fim | hard | {
"lang": "python",
"repo": "bleck9999/Kurisu",
"path": "/utils/context.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]
author: discord.Member
guild: discord.Guild<|fim_prefix|># repo: bleck9999/Kurisu path: /utils/context.py
from __future__ import annotations
import discord
from discord.ext import commands
from typing import Union, Op... | code_fim | hard | {
"lang": "python",
"repo": "bleck9999/Kurisu",
"path": "/utils/context.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: innnk/seek-awesome-job path: /main.py
import re
import time
import requests
from bs4 import BeautifulSoup
import sqlite3
import urllib
import json
from math import radians, cos, sin, asin, sqrt
import time
import os
jobName... | code_fim | hard | {
"lang": "python",
"repo": "innnk/seek-awesome-job",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''爬取BOSS直聘网,数据岗位'''
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, 'lxml')
titles = soup.select('.job-title')
companys = soup.select('.company-text > h3 > a')
reds = soup.select('.red')
webs = soup.sele... | code_fim | hard | {
"lang": "python",
"repo": "innnk/seek-awesome-job",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cougar/pywmbus path: /pywmbus/exceptions.py
"""This is a docstring."""
class WMBusTypeError(BaseException):
"""docstring for WMBusTypeError"""
class WMBusChecksumError(BaseException):
<|fim_suffix|> """docstring for WMBusDataLengthError"""<|fim_middle|> """docstring for WMBusChecksu... | code_fim | medium | {
"lang": "python",
"repo": "Cougar/pywmbus",
"path": "/pywmbus/exceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class WMBusDataLengthError(BaseException):
"""docstring for WMBusDataLengthError"""<|fim_prefix|># repo: Cougar/pywmbus path: /pywmbus/exceptions.py
"""This is a docstring."""
class WMBusTypeError(BaseException):
<|fim_middle|> """docstring for WMBusTypeError"""
class WMBusChecksumError(BaseEx... | code_fim | medium | {
"lang": "python",
"repo": "Cougar/pywmbus",
"path": "/pywmbus/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
USAGE: generator = batch_generator( batch_size = 50):
x_batch, y_batch = generator.next_batch(X_train, y_train)
INPUT: when initialize, takes an int
when generating batch, takes X and y
RETURNS: x_batch 4D-tensor [self.batch_size, channel, width... | code_fim | hard | {
"lang": "python",
"repo": "henryliuw/Gradient-Adversarial-Transformation-Network",
"path": "/tool/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henryliuw/Gradient-Adversarial-Transformation-Network path: /tool/common.py
''' this file contains functions that may be used by many people '''
import numpy as np
import torch
import torchvision
import matplotlib.pyplot as plt
tv = torchvision
tc = torch
def load_data(dataset_name ):
'''
... | code_fim | hard | {
"lang": "python",
"repo": "henryliuw/Gradient-Adversarial-Transformation-Network",
"path": "/tool/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.static_counter==None:
self.static_counter = 0
data_size = len(y)
if ( self.static_counter+1 ) * self.batch_size >= data_size:
self.static_counter = 0
return X[ data_size - self.batch_size: ], y[data_size - self.batch_size : ]
else... | code_fim | hard | {
"lang": "python",
"repo": "henryliuw/Gradient-Adversarial-Transformation-Network",
"path": "/tool/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gtfierro/point-label-sharing path: /client.py
import json
import requests
d1 = {
"name": "test1",
"contents": [
["col1","col2"],
["abcdefg.5678.re3", "val2"]
]
}
file_list = requests.get('http://localhost:5000/file').json()
print(f"file list: {file_list}")
<|fim_suf... | code_fim | hard | {
"lang": "python",
"repo": "gtfierro/point-label-sharing",
"path": "/client.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># #Remove
# # instantiate rule
# rule_stuff = {
# 'cols': [0],
# 'args': ["."]
# }
# resp = requests.post('http://localhost:5000/rule/remove', data=json.dumps(rule_stuff)).json()
# ruleid=resp['ruleid']
# print(f"ruleid: {ruleid}")
# #Regex Match (Doesn't work yet)
# # instantiate rule
# rule_stu... | code_fim | hard | {
"lang": "python",
"repo": "gtfierro/point-label-sharing",
"path": "/client.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZephyrBlu/sc2-tournament-analysis path: /handle_replay.py
from fuzzywuzzy import fuzz
from zephyrus_sc2_parser import parse_replay
from sc2_tournament_analysis.defaults import (
standard_ignore_units, standard_merge_units
)
def handle_replay(
<|fim_suffix|> # linking matched names to... | code_fim | hard | {
"lang": "python",
"repo": "ZephyrBlu/sc2-tournament-analysis",
"path": "/handle_replay.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if name_match[0] == 1:
name_id_matches[2] = player_names[1]
else:
name_id_matches[1] = player_names[1]
else:
name_id_matches = {}
match_info = data_function(
players,
timeline,
stats,
metadata,
name_id_matches... | code_fim | hard | {
"lang": "python",
"repo": "ZephyrBlu/sc2-tournament-analysis",
"path": "/handle_replay.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.register_buffer('primes', torch.tensor(
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]))
def duplicates(self, tuples):
"""
Takes a list of tuples, and for each tuple that occurs mutiple times
marks all but ... | code_fim | hard | {
"lang": "python",
"repo": "codes-kzhan/sparse-hyper",
"path": "/global_temp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codes-kzhan/sparse-hyper path: /global_temp.py
import torch
from numpy.core.multiarray import dtype
from torch.autograd import Variable
from torch.nn import Parameter
#from torch import FloatTensor, LongTensor
import abc, itertools, math, types
from numpy import prod
import torch.nn as nn
impor... | code_fim | hard | {
"lang": "python",
"repo": "codes-kzhan/sparse-hyper",
"path": "/global_temp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rngxp = rng.unsqueeze(0).unsqueeze(0).unsqueeze(0).expand_as(rr_ints) # bounds of the tensor
rrng = torch.cuda.FloatTensor(relative_range) if use_cuda \
else torch.FloatTensor(relative_range) # bounds of the range from which to sample
rrng = rrng.unsqueeze(0).unsqueeze... | code_fim | hard | {
"lang": "python",
"repo": "codes-kzhan/sparse-hyper",
"path": "/global_temp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # logging.info(f' Score = {score}')
models.append(predictor_obj)
scores.append(score)
scores_dm.append(score_dm)
logging.info(f"Holdout score = {score}")
logging.info(f" Dummy = {score_dm}")
preds_test[k, :] = predictor_obj.predict(x=proc_X_test).reshape(1, -1)
preds_holdou... | code_fim | hard | {
"lang": "python",
"repo": "vragov/Untapped_Energy_Datathon",
"path": "/src/models/train_NN_embedding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vragov/Untapped_Energy_Datathon path: /src/models/train_NN_embedding.py
import logging
import os
import pickle
import eli5
from pathlib import Path
from keras.optimizers import Adam, SGD
from scipy.stats.mstats import gmean
import numpy as np
import pandas as pd
from src.data.make_dataset impor... | code_fim | hard | {
"lang": "python",
"repo": "vragov/Untapped_Energy_Datathon",
"path": "/src/models/train_NN_embedding.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return preds_df, score_holdout
if __name__ == "__main__":
# not used in this stub but often useful for finding various files
# find .env automagically by walking up directories until it's found, then
# load up the .env entries as environment variables
input_file_path = os.path.join(... | code_fim | hard | {
"lang": "python",
"repo": "vragov/Untapped_Energy_Datathon",
"path": "/src/models/train_NN_embedding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NVIDIA/aistore path: /python/aistore/sdk/multiobj/object_collection.py
#
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
from abc import abstractmethod, ABC
from typing import Iterator, Dict
class ObjectCollection(ABC):
"""
Abstract class for collections of object name... | code_fim | medium | {
"lang": "python",
"repo": "NVIDIA/aistore",
"path": "/python/aistore/sdk/multiobj/object_collection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abstractmethod
def get_value(self) -> Dict[str, any]:
"""
Get the json representation of the names to send to the API
Returns:
Dictionary of request entry to name representation
"""
@abstractmethod
def __iter__(self) -> Iterator[str]:
... | code_fim | medium | {
"lang": "python",
"repo": "NVIDIA/aistore",
"path": "/python/aistore/sdk/multiobj/object_collection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MKoth/clients-crm-dockerized path: /backend/staff/migrations/0002_auto_20200429_2003.py
# Generated by Django 3.0.2 on 2020-04-29 20:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('company', '00... | code_fim | hard | {
"lang": "python",
"repo": "MKoth/clients-crm-dockerized",
"path": "/backend/staff/migrations/0002_auto_20200429_2003.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Field(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('company', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='company_schedule', to='company.Company')),
('staff', models.ForeignKey(null=True, on_delete=d... | code_fim | hard | {
"lang": "python",
"repo": "MKoth/clients-crm-dockerized",
"path": "/backend/staff/migrations/0002_auto_20200429_2003.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>one',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='staff',
name='position',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
... | code_fim | hard | {
"lang": "python",
"repo": "MKoth/clients-crm-dockerized",
"path": "/backend/staff/migrations/0002_auto_20200429_2003.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Devcentralized/thenewboston-node path: /thenewboston_node/accounts/views/account_balance.py
from drf_spectacular.utils import OpenApiParameter, extend_schema
from rest_framework.response import Response
from rest_framework.viewsets import ViewSet
from thenewboston_node.business_logic.blockchain.... | code_fim | hard | {
"lang": "python",
"repo": "Devcentralized/thenewboston-node",
"path": "/thenewboston_node/accounts/views/account_balance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # TODO(dmu) MEDIUM: There is a room for performance optimization use something like `?fields=` to
# retrieval of unneeded fields using get_account_balance() and get_account_balance_lock() directly.
# Also see `drf-flex-fields` and `django-restql`... | code_fim | hard | {
"lang": "python",
"repo": "Devcentralized/thenewboston-node",
"path": "/thenewboston_node/accounts/views/account_balance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @extend_schema(
responses=AccountBalanceSerializer,
parameters=[OpenApiParameter('id', str, OpenApiParameter.PATH, description='Account number')],
)
def retrieve(self, request, pk=None):
# TODO(dmu) MEDIUM: There is a room for performance optimization use something like... | code_fim | medium | {
"lang": "python",
"repo": "Devcentralized/thenewboston-node",
"path": "/thenewboston_node/accounts/views/account_balance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> delims = '(\W)|(_)|(.(?=[\W_]))|([a-z][A-Z])|(\d\D)|(\D\d)'
delimindexes = [0, len(s)]
for m in re.finditer(delims, s):
delimindexes.append(m.start()+1)
ss = set()
for i in delimindexes:
for j in delimindexes:
if i < j:
ss.add(s[i:j])
re... | code_fim | medium | {
"lang": "python",
"repo": "jpercent/phenom.io",
"path": "/factor/substrs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpercent/phenom.io path: /factor/substrs.py
# Copyright (c) 2011 Massachusetts Institute of Technology
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restric... | code_fim | medium | {
"lang": "python",
"repo": "jpercent/phenom.io",
"path": "/factor/substrs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexa/alexa-apis-for-python path: /ask-sdk-model/ask_sdk_model/interfaces/viewport/viewport_state.py
# coding: utf-8
#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
# except ... | code_fim | hard | {
"lang": "python",
"repo": "alexa/alexa-apis-for-python",
"path": "/ask-sdk-model/ask_sdk_model/interfaces/viewport/viewport_state.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.experiences = experiences
self.mode = mode
self.shape = shape
self.pixel_width = pixel_width
self.pixel_height = pixel_height
self.dpi = dpi
self.current_pixel_width = current_pixel_width
self.current_pixel_height = current_pixel_height
... | code_fim | hard | {
"lang": "python",
"repo": "alexa/alexa-apis-for-python",
"path": "/ask-sdk-model/ask_sdk_model/interfaces/viewport/viewport_state.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # type: () -> Dict[str, object]
"""Returns the model properties as a dict"""
result = {} # type: Dict
for attr, _ in six.iteritems(self.deserialized_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list... | code_fim | hard | {
"lang": "python",
"repo": "alexa/alexa-apis-for-python",
"path": "/ask-sdk-model/ask_sdk_model/interfaces/viewport/viewport_state.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: michael-gann/Petsy path: /python-project-starter/app/models/pet.py
from .db import db
class Pet(db.Model):
__tablename__ = 'pets'
id = db.Column(db.Integer, primary_key=True)
sellerId = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False)
name = db.Column(db.String)... | code_fim | medium | {
"lang": "python",
"repo": "michael-gann/Petsy",
"path": "/python-project-starter/app/models/pet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {"id": self.id, "sellerId": self.sellerId, "name": self.name,
"description": self.description, "price": self.price,
"imgurl": self.imgurl, "categoryId": self.categoryId,
"breed": self.breed, "age": self.age, "weight": self.weight,
... | code_fim | medium | {
"lang": "python",
"repo": "michael-gann/Petsy",
"path": "/python-project-starter/app/models/pet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balanagm-amzn/deep-learning-keras-tensorflow path: /solutions/sol_2313.py
plt.plot(range(len(loss_history)), loss_history, 'o', label='Linear Regression <|fim_suffix|>.xlabel('epoch')
plt.legend()
plt.show()<|fim_middle|>Training phase')
plt.ylabel('cost')
plt | code_fim | easy | {
"lang": "python",
"repo": "balanagm-amzn/deep-learning-keras-tensorflow",
"path": "/solutions/sol_2313.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.xlabel('epoch')
plt.legend()
plt.show()<|fim_prefix|># repo: balanagm-amzn/deep-learning-keras-tensorflow path: /solutions/sol_2313.py
plt.plot(range(len(loss_history)), loss<|fim_middle|>_history, 'o', label='Linear Regression Training phase')
plt.ylabel('cost')
plt | code_fim | medium | {
"lang": "python",
"repo": "balanagm-amzn/deep-learning-keras-tensorflow",
"path": "/solutions/sol_2313.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ardhanii/covid19-sir path: /covsirphy/ode/ode_solver.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from scipy.integrate import solve_ivp
from covsirphy.util.term import Term
from covsirphy.ode.mbase import ModelBase
class _ODESolver(Term):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "ardhanii/covid19-sir",
"path": "/covsirphy/ode/ode_solver.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
pandas.DataFrame: numerical solution
Index
reset index: time steps
Columns
(int): dimensional variables of the model
"""
tstart, dt, tend = 0, 1, step_n
variables = self._model.VARI... | code_fim | hard | {
"lang": "python",
"repo": "ardhanii/covid19-sir",
"path": "/covsirphy/ode/ode_solver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('queries', '0005_auto_20170728_0125'),
]
operations = [
migrations.AlterField(
model_name='queries',
name='query_text',
field=models.CharField(max_length=4096),
),
migrations.AlterField(
model_n... | code_fim | medium | {
"lang": "python",
"repo": "BigQueryManager/bigquerymgr",
"path": "/guery_manager/queries/migrations/0006_auto_20170728_0416.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BigQueryManager/bigquerymgr path: /guery_manager/queries/migrations/0006_auto_20170728_0416.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-28 04:16
from __future__ import unicode_literals
<|fim_suffix|>
dependencies = [
('queries', '0005_auto_20170728_0125'),
... | code_fim | medium | {
"lang": "python",
"repo": "BigQueryManager/bigquerymgr",
"path": "/guery_manager/queries/migrations/0006_auto_20170728_0416.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rbrewer123/docker-pyjnius path: /testpy.py
from jnius import autoclass
<|fim_suffix|>stack.push('hello')
stack.push('world')
print stack.pop()
print stack.pop()<|fim_middle|>Stack = autoclass('java.util.Stack')
stack = Stack()
| code_fim | easy | {
"lang": "python",
"repo": "rbrewer123/docker-pyjnius",
"path": "/testpy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rbrewer123/docker-pyjnius path: /testpy.py
from jnius import autoclass
<|fim_suffix|>print stack.pop()
print stack.pop()<|fim_middle|>Stack = autoclass('java.util.Stack')
stack = Stack()
stack.push('hello')
stack.push('world')
| code_fim | medium | {
"lang": "python",
"repo": "rbrewer123/docker-pyjnius",
"path": "/testpy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print stack.pop()
print stack.pop()<|fim_prefix|># repo: rbrewer123/docker-pyjnius path: /testpy.py
from jnius import autoclass
<|fim_middle|>Stack = autoclass('java.util.Stack')
stack = Stack()
stack.push('hello')
stack.push('world')
| code_fim | medium | {
"lang": "python",
"repo": "rbrewer123/docker-pyjnius",
"path": "/testpy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route('/dinosaur', methods=['GET', 'POST'])
def dinosuar():
if request.method == 'GET':
'trilobite'
elif request.method == 'POST':
'Need to do something with this...'
return "triolobite"
if __name__ == '__main__':
app.run(host='0.0.0.0')<|fim_prefix|># repo: hobb... | code_fim | hard | {
"lang": "python",
"repo": "hobbitcakes/tinydino",
"path": "/track-hostname.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hobbitcakes/tinydino path: /track-hostname.py
import urllib
#from bs4 import BeautifulSoup
import json
from flask import Flask, url_for, Response, request
#----------------------
# Load Dinosaur info
#______________________
trilobite = { "name" : "Trilobite", "Kingdom" : "Animalia", "period... | code_fim | hard | {
"lang": "python",
"repo": "hobbitcakes/tinydino",
"path": "/track-hostname.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def clean_source_time(self, alarm):
"""
告警发生的时间,格式:YYYY-MM-DD HH:mm:ss
"""
return alarm['source_time']
def clean_alarm_type(self, alarm):
"""
告警类型
"""
return list(monitors.lookup_alarm_type_list(
[alarm['alarm_type']],
... | code_fim | hard | {
"lang": "python",
"repo": "huang1125677925/fta",
"path": "/server/project/poll_alarm/custom_monitor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huang1125677925/fta path: /server/project/poll_alarm/custom_monitor.py
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights re... | code_fim | hard | {
"lang": "python",
"repo": "huang1125677925/fta",
"path": "/server/project/poll_alarm/custom_monitor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b, a + b
number += 1
fibo(1000)<|fim_prefix|># repo: Nakrez/RePy path: /tests/final/input/fibo.py
def fibo(max_value):
a, b = 0, 1
<|fim_middle|>number = 0
while b < max_value:
print(number, " = ", b)
a, b = | code_fim | medium | {
"lang": "python",
"repo": "Nakrez/RePy",
"path": "/tests/final/input/fibo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nakrez/RePy path: /tests/final/input/fibo.py
def fibo(max_value):
a, b = 0, 1
<|fim_suffix|> print(number, " = ", b)
a, b = b, a + b
number += 1
fibo(1000)<|fim_middle|>number = 0
while b < max_value:
| code_fim | easy | {
"lang": "python",
"repo": "Nakrez/RePy",
"path": "/tests/final/input/fibo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self._config['inter_request_not_pause']:
self._logger.debug("Using old request timestamp as starting point")
t_ref = self._next_request
self._logger.debug("Using time.time() as starting point")
else:
t_ref = time.time()
# Constant... | code_fim | hard | {
"lang": "python",
"repo": "tum-lkn/appaware",
"path": "/clients/servers/PrototypeServer/PrototypeServer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tum-lkn/appaware path: /clients/servers/PrototypeServer/PrototypeServer.py
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import logging
import threading
import time
import numpy as np
import random
class PrototypeServer(threading.Thread):
def __init__(self):
super(PrototypeServe... | code_fim | hard | {
"lang": "python",
"repo": "tum-lkn/appaware",
"path": "/clients/servers/PrototypeServer/PrototypeServer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> and 'description' in command:
if 'arguments' in command:
description = description + f'**{command["name"]}** ***{command["arguments"]}*** - {command["description"]}\n'
else:
description... | code_fim | hard | {
"lang": "python",
"repo": "santoshpanna/Discord-Bot",
"path": "/cogs/helpers/helpmaker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: santoshpanna/Discord-Bot path: /cogs/helpers/helpmaker.py
import discord
class Help:
def make(self, author, name, directcommands, groupedcommands, extra):
description = ""
description = description + f'Hello {author}.\n'
if directcommands:
description = ... | code_fim | hard | {
"lang": "python",
"repo": "santoshpanna/Discord-Bot",
"path": "/cogs/helpers/helpmaker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @override_settings(ENABLE_WEBPACK_BUNDLES=False)
def test_render_bundle_does_not_call_webpack_loader_when_disabled(self):
render_bundle_path = 'hypha.apply.utils.templatetags.webpack_tags.webpack_loader.render_bundle'
with mock.patch(render_bundle_path, return_value='foo.js') as m... | code_fim | hard | {
"lang": "python",
"repo": "ResetNetwork/apply-app",
"path": "/hypha/apply/utils/tests/test_templatetags.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ResetNetwork/apply-app path: /hypha/apply/utils/tests/test_templatetags.py
from unittest import mock
from django.test import SimpleTestCase, override_settings
from hypha.apply.utils.templatetags.webpack_tags import render_bundle
class WebpackTagsTestCase(SimpleTestCase):
@override_settin... | code_fim | hard | {
"lang": "python",
"repo": "ResetNetwork/apply-app",
"path": "/hypha/apply/utils/tests/test_templatetags.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> render_bundle_path = 'hypha.apply.utils.templatetags.webpack_tags.webpack_loader.render_bundle'
with mock.patch(render_bundle_path, return_value='foo.js') as mocked_render_bundle:
self.assertEqual(render_bundle('foo', 'js'), '')
self.assertFalse(mocked_render_bund... | code_fim | hard | {
"lang": "python",
"repo": "ResetNetwork/apply-app",
"path": "/hypha/apply/utils/tests/test_templatetags.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize('cause_reason', HANDLER_REASONS)
@pytest.mark.parametrize('now, delayed_iso, delay', [
['2020-01-01T00:00:00', '2020-01-01T00:04:56.789000', 4 * 60 + 56.789],
['2020-01-01T00:00:00', '2099-12-31T23:59:59.000000', WAITING_KEEPALIVE_INTERVAL],
], ids=['fast', 'slow'])
async ... | code_fim | hard | {
"lang": "python",
"repo": "nolar/kopf",
"path": "/tests/handling/test_delays.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nolar/kopf path: /tests/handling/test_delays.py
import asyncio
import datetime
import logging
import freezegun
import pytest
import kopf
from kopf._cogs.structs.ephemera import Memo
from kopf._core.actions.application import WAITING_KEEPALIVE_INTERVAL
from kopf._core.actions.execution import Te... | code_fim | hard | {
"lang": "python",
"repo": "nolar/kopf",
"path": "/tests/handling/test_delays.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> opts = parser.parse_args()
return opts
if __name__ == '__main__':
opts = parse_arguments()
logging.info(opts)
model = models.get_model(opts, datasets_shape[opts.data])
model.eval()
data = get_dataloader(opts.batch_size*opts.device_iteration*opts.replicas, opts.data == "synthe... | code_fim | hard | {
"lang": "python",
"repo": "CHDev93/examples",
"path": "/applications/pytorch/cnns/inference/run_benchmark.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CHDev93/examples path: /applications/pytorch/cnns/inference/run_benchmark.py
# Copyright 2020 Graphcore Ltd.
import time
import argparse
import torch
import poptorch
import numpy as np
from data import get_dataloader, datasets_shape
import sys
import logging
sys.path.append('..')
import models
... | code_fim | hard | {
"lang": "python",
"repo": "CHDev93/examples",
"path": "/applications/pytorch/cnns/inference/run_benchmark.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser(description='CNN training in PopTorch')
parser.add_argument('--batch-size', type=int, default=1, help='batch size for training (default: 1)')
parser.add_argument('--model', choices=models.available_models.keys(), default='resnet18', help="Choose model")
pa... | code_fim | hard | {
"lang": "python",
"repo": "CHDev93/examples",
"path": "/applications/pytorch/cnns/inference/run_benchmark.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
n = 286
while True:
tn = triangle(n)
if ispenta(tn) and ishexa(tn):
print(n, int(tn))
break
n += 1<|fim_prefix|># repo: emergent/ProjectEuler path: /Python/problem045.py
#! /usr/bin/env python3
"""
Problem 45 - Project Eu... | code_fim | medium | {
"lang": "python",
"repo": "emergent/ProjectEuler",
"path": "/Python/problem045.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emergent/ProjectEuler path: /Python/problem045.py
#! /usr/bin/env python3
"""
Problem 45 - Project Euler
http://projecteuler.net/index.php?section=problems&id=045
"""
import math
def triangle(n):
return n * (n + 1) / 2
def ispenta(pn):
n = (1 + math.sqrt(24 * pn + 1)) / 6
return n... | code_fim | medium | {
"lang": "python",
"repo": "emergent/ProjectEuler",
"path": "/Python/problem045.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def ispenta(pn):
n = (1 + math.sqrt(24 * pn + 1)) / 6
return n.is_integer()
def ishexa(hn):
n = (1 + math.sqrt(8 * hn + 1)) / 4
return n.is_integer()
if __name__ == "__main__":
n = 286
while True:
tn = triangle(n)
if ispenta(tn) and ishexa(tn):
print... | code_fim | medium | {
"lang": "python",
"repo": "emergent/ProjectEuler",
"path": "/Python/problem045.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
ndarray: Relu activation and derivative of x.
'''
y = np.maximum(0, x)
deriv = (x > 0) * 1
return y, deriv
def leaky_relu(x, leak=0.1):
'''
Args:
x(ndarray)
leak(int)
Returns:
ndarray: Leaky relu activation and derivative of x.... | code_fim | medium | {
"lang": "python",
"repo": "chidperi/deep_learning_python",
"path": "/NNActivations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chidperi/deep_learning_python path: /NNActivations.py
# File name: NNActivations
# Copyright 2017 Chidambaram Periakaruppan
# 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 ... | code_fim | hard | {
"lang": "python",
"repo": "chidperi/deep_learning_python",
"path": "/NNActivations.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
y = np.maximum(leak * x, x)
deriv = (x < 0) * leak
deriv = deriv + (x > 0) * 1
return y, deriv
activation_functions = {'relu': relu, 'leaky_relu': leaky_relu, 'sigmoid': sigmoid}<|fim_prefix|># repo: chidperi/deep_learning_python path: /NNActivations.py
# File name: NNActivatio... | code_fim | hard | {
"lang": "python",
"repo": "chidperi/deep_learning_python",
"path": "/NNActivations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.