text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> try:
instruction: str = common.bytecode_mapping[opcode]
except KeyError:
instruction: str = 'nop'
return '@{}\t{}'.format(addr, instruction)
# def push(stack, value):
# if len(stack) < 0x400:
# stack.append(value)
# else:
# print('\t[-] Stack overflow'... | code_fim | hard | {
"lang": "python",
"repo": "Dethada/LSCVM-Tool",
"path": "/execute.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> return str(stack.pop())
def cmp(stack: List[int]):
val1: int = stack.pop()
val2: int = stack.pop()
if val1 == val2:
stack.append(0)
elif val1 < val2:
stack.append(1)
else:
stack.append(-1)
def write(stack: List[int], memory: List[int]):
addr: int = s... | code_fim | hard | {
"lang": "python",
"repo": "Dethada/LSCVM-Tool",
"path": "/execute.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>assert 'Stumbl' in browser.title<|fim_prefix|># repo: maxehio/Stumbl path: /functional_tests.py
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
... | code_fim | medium | {
"lang": "python",
"repo": "maxehio/Stumbl",
"path": "/functional_tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxehio/Stumbl path: /functional_tests.py
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
<|fim_suffix|>assert 'Stumbl' in browser.title... | code_fim | medium | {
"lang": "python",
"repo": "maxehio/Stumbl",
"path": "/functional_tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CyberLab1/boringssl path: /QUIC-project/client.py
import os
import socket
import time
import datetime
print('Client has started.')
def getIP():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 1))
return s.getsockname()[0]
def pause_until_next_minute():
minute = d... | code_fim | hard | {
"lang": "python",
"repo": "CyberLab1/boringssl",
"path": "/QUIC-project/client.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>#pause_until_next_minute()
#time.sleep(1)
print(f'Client IP: {getIP()}')
numSamples = 1
serverIP = input('Enter the server IP address: ') #getIP() #'10.0.0.235'
lsquic_dir = os.path.expanduser('~/oqs/lsquic')
myCmd = f'{lsquic_dir}/build/./research_client -H www.example.com -s {serverIP}:4433 -g -j'
st... | code_fim | hard | {
"lang": "python",
"repo": "CyberLab1/boringssl",
"path": "/QUIC-project/client.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>lsquic_dir = os.path.expanduser('~/oqs/lsquic')
myCmd = f'{lsquic_dir}/build/./research_client -H www.example.com -s {serverIP}:4433 -g -j'
startTime = time.time()
for i in range(numSamples):
os.system(myCmd)
endTime = time.time()
print ("Time Taken: ")
print (endTime - startTime)<|fim_prefix|># repo... | code_fim | medium | {
"lang": "python",
"repo": "CyberLab1/boringssl",
"path": "/QUIC-project/client.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wx-b/DIRL path: /src/train_synthetic_2d.py
i in range(k, len(x_list) - k)])
def sample_class_dann_logits(class_features, class_labels, class_id, batch_size, num_target_labels_tf,
mean_source_filtered, mean_target_filtered, class_batch_size):
n_samples = class_... | code_fim | hard | {
"lang": "python",
"repo": "wx-b/DIRL",
"path": "/src/train_synthetic_2d.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> class_domain_A_loss = tf.cond(class_A_labels_size_bool, lambda: tf.constant(0.0), lambda: class_domain_A_loss)
class_domain_B_loss = tf.cond(class_B_labels_size_bool, lambda: tf.constant(0.0), lambda: class_domain_B_loss)
class_domain_A_loss = tf.scalar_mul(class_domain_weight, class_domain_A... | code_fim | hard | {
"lang": "python",
"repo": "wx-b/DIRL",
"path": "/src/train_synthetic_2d.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for trial_num in range(num_trials):
print('trial:', trial_num)
print('dirl_loss', 'domain_loss', 'class_dann_loss', 'classify_loss', 'triplet_loss', 'reg_entropy')
iter_list = []
all_metrics = []
gif_images_list = []
sess = tf.InteractiveSession()
... | code_fim | hard | {
"lang": "python",
"repo": "wx-b/DIRL",
"path": "/src/train_synthetic_2d.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AIoT-Lab-BKAI/ORO-CCGRID2023-CADIS path: /algorithm/cfmtx/cfmtx.py
import json
import numpy as np
import torch
from torch.utils.data import DataLoader
from torchmetrics import ConfusionMatrix
def cfmtx_test(model, testing_data, device="cuda"):
test_loader = DataLoader(testing_data, batch_si... | code_fim | hard | {
"lang": "python",
"repo": "AIoT-Lab-BKAI/ORO-CCGRID2023-CADIS",
"path": "/algorithm/cfmtx/cfmtx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loss_fn = torch.nn.CrossEntropyLoss()
size = len(test_loader.dataset)
num_batches = len(test_loader)
model.eval()
test_loss, correct = 0, 0
confmat = ConfusionMatrix(num_classes=10).to(device)
cmtx = 0
with torch.no_grad():
for X, y in test_loader:
X, ... | code_fim | medium | {
"lang": "python",
"repo": "AIoT-Lab-BKAI/ORO-CCGRID2023-CADIS",
"path": "/algorithm/cfmtx/cfmtx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cnt = 1
result = max(result, cnt)
print(result)<|fim_prefix|># repo: viing937/codeforces path: /src/702A.py
n = int(input())
a = list(map(int, input().split(" ")))
result, cnt = 1, 1
for i in range(1, n):
i<|fim_middle|>f a[i] > a[i-1]:
cnt += 1
else:
| code_fim | easy | {
"lang": "python",
"repo": "viing937/codeforces",
"path": "/src/702A.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: viing937/codeforces path: /src/702A.py
n = int(input())
a = list(map(int, input().split(" <|fim_suffix|> cnt = 1
result = max(result, cnt)
print(result)<|fim_middle|>")))
result, cnt = 1, 1
for i in range(1, n):
if a[i] > a[i-1]:
cnt += 1
else:
| code_fim | medium | {
"lang": "python",
"repo": "viing937/codeforces",
"path": "/src/702A.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: viing937/codeforces path: /src/702A.py
n = int(input())
a = list(map(int, input().split(" ")))
result, cnt = 1, 1
for i in range(1, n):
i<|fim_suffix|> cnt = 1
result = max(result, cnt)
print(result)<|fim_middle|>f a[i] > a[i-1]:
cnt += 1
else:
| code_fim | easy | {
"lang": "python",
"repo": "viing937/codeforces",
"path": "/src/702A.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shahbagdadi/py-algo-n-ds path: /llstq/firstUniqueNumber/Solution.py
from typing import List
class Node:
def __init__(self,val):
self.val = val
self.next = self.prev = None
class DLList:
def __init__(self):
self.head , self.tail = Node(-1) , Node(-1)
self.... | code_fim | hard | {
"lang": "python",
"repo": "shahbagdadi/py-algo-n-ds",
"path": "/llstq/firstUniqueNumber/Solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add(self, n: int) -> None:
if n in self.dups: return
if n in self.uniq:
node = self.uniq[n]
self.ulist.deleteNode(node)
del self.uniq[n]
self.dups.add(n)
else:
node = Node(n)
self.uniq[n] = node
... | code_fim | hard | {
"lang": "python",
"repo": "shahbagdadi/py-algo-n-ds",
"path": "/llstq/firstUniqueNumber/Solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>parola = 'aa'
parolaCercata = parola + '\n'
print(cerca(parola))<|fim_prefix|># repo: acboss/python path: /dizionario.py
fin = open('words.txt')
def cerca(parolaCercata):
<|fim_middle|> if parolaCercata in fin:
return True
else:
return False
| code_fim | medium | {
"lang": "python",
"repo": "acboss/python",
"path": "/dizionario.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acboss/python path: /dizionario.py
fin = open('words.txt')
def cerca(parolaCercata):
<|fim_suffix|>
parola = 'aa'
parolaCercata = parola + '\n'
print(cerca(parola))<|fim_middle|> if parolaCercata in fin:
return True
else:
return False
| code_fim | medium | {
"lang": "python",
"repo": "acboss/python",
"path": "/dizionario.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
parola = 'aa'
parolaCercata = parola + '\n'
print(cerca(parola))<|fim_prefix|># repo: acboss/python path: /dizionario.py
fin = open('words.txt')
def cerca(parolaCercata):
<|fim_middle|> if parolaCercata in fin:
return True
else:
return False
| code_fim | medium | {
"lang": "python",
"repo": "acboss/python",
"path": "/dizionario.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def dense_sift(image, fraction=1.0):
""" dense SIFT
use VLFEAT vl_phow through octave; expects a grayscale image
"""
octave.push("im", image)
octave.eval("im = single(im);")
octave.eval("[kp,siftd] = vl_phow(im); ")
descriptors = octave.pull("siftd")
# flip from column... | code_fim | hard | {
"lang": "python",
"repo": "bdecost/uhcs",
"path": "/mfeat/local.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bdecost/uhcs path: /mfeat/local.py
# -*- coding: utf-8 -*-
"""
mfeat.local
~~~~~~~
This module provides a wrapper for vlfeat local image feature extraction
:license: MIT, see LICENSE for more details.
"""
import numpy as np
from oct2py import octave
<|fim_suffix|> """ random... | code_fim | medium | {
"lang": "python",
"repo": "bdecost/uhcs",
"path": "/mfeat/local.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ dense SIFT
use VLFEAT vl_phow through octave; expects a grayscale image
"""
octave.push("im", image)
octave.eval("im = single(im);")
octave.eval("[kp,siftd] = vl_phow(im); ")
descriptors = octave.pull("siftd")
# flip from column-major to row-major
descriptors =... | code_fim | medium | {
"lang": "python",
"repo": "bdecost/uhcs",
"path": "/mfeat/local.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Charleo85/medium-crawler path: /db/action2TopicTable.py
# -*- coding: utf-8 -*-
import psycopg2,sys
from db.config import config
def createTopicTable():
command = ("""
CREATE TABLE topic (
topicID SERIAL PRIMARY KEY,
name text,
mediumID varchar(20),
description text
)
""")
... | code_fim | hard | {
"lang": "python",
"repo": "Charleo85/medium-crawler",
"path": "/db/action2TopicTable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return topicID[0]
except(Exception, psycopg2.DatabaseError) as error:
print(error, file=sys.stderr)
finally:
if conn is not None:
conn.close()
def queryAllTopicMediumID():
command = ("SELECT mediumID FROM topic")
conn = None
try:
params = config()
conn = psycopg2.connect(**params)
... | code_fim | hard | {
"lang": "python",
"repo": "Charleo85/medium-crawler",
"path": "/db/action2TopicTable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>- 1]) + dp[i - 1],
abs(heights[i] - heights[i - 2]) + dp[i - 2]
)
return dp[n - 1]
if __name__ == '__main__':
print(frogJump(4, [10, 20, 30, 10]))<|fim_prefix|># repo: suyash248/ds_algo path: /DynamicProgramming/stiver/frogJumps.py
from typing impo... | code_fim | hard | {
"lang": "python",
"repo": "suyash248/ds_algo",
"path": "/DynamicProgramming/stiver/frogJumps.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: suyash248/ds_algo path: /DynamicProgramming/stiver/frogJumps.py
from typing import List
def frogJump(n: int, heights: List[int]) -> int:
# def f(i):
# if i == 0:
# return 0
# if i == 1:
# return abs(heights[0] - heights[1])
# return min(abs(hei... | code_fim | hard | {
"lang": "python",
"repo": "suyash248/ds_algo",
"path": "/DynamicProgramming/stiver/frogJumps.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> early_stopping = keras.callbacks.EarlyStopping(monitor='val_accuracy', patience=300, verbose=0, mode='auto')
checkpoint1 = ModelCheckpoint(filepath=save_dir + '/weights.{epoch:02d}-{val_loss:.2f}.hdf5', monitor='val_loss',verbose=1, save_best_only=False, save_weights_only=False, mode='auto', peri... | code_fim | hard | {
"lang": "python",
"repo": "jjfeng/CNNC",
"path": "/train_with_labels_wholedatax.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jjfeng/CNNC path: /train_with_labels_wholedatax.py
from __future__ import print_function
# Usage python train_with_labels_wholedata.py number_of_data_parts_divided
# command line in developer's linux machine :
# module load cuda-8.0 using GPU
#srun -p gpu --gres=gpu:1 -c 2 --mem=20Gb python ... | code_fim | hard | {
"lang": "python",
"repo": "jjfeng/CNNC",
"path": "/train_with_labels_wholedatax.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> history = model.fit(x_train, y_train,batch_size=args.batch_size,epochs=args.epochs,validation_split=0.2,shuffle=True, callbacks=callbacks_list)
# Save model and weights
model.save(args.out_model_file)
############################################################################## plo... | code_fim | hard | {
"lang": "python",
"repo": "jjfeng/CNNC",
"path": "/train_with_labels_wholedatax.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sealemar/macropy path: /macropy/experimental/test/debug_pyxl_tests.py
import unittest
import macropy.activate
<|fim_suffix|>def test_suite(suites=[], cases=[]):
new_suites = [x.Tests for x in suites]
new_cases = [unittest.makeSuite(x.Tests) for x in cases]
return unittest.TestSuite(n... | code_fim | easy | {
"lang": "python",
"repo": "sealemar/macropy",
"path": "/macropy/experimental/test/debug_pyxl_tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>unittest.TextTestRunner().run (
test_suite (cases= [
pyxl_snippets] ) )<|fim_prefix|># repo: sealemar/macropy path: /macropy/experimental/test/debug_pyxl_tests.py
import unittest
import macropy.activate
import pyxl_snippets
<|fim_middle|>def test_suite(suites=[], cases=[]):
new_suites =... | code_fim | medium | {
"lang": "python",
"repo": "sealemar/macropy",
"path": "/macropy/experimental/test/debug_pyxl_tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/tacker path: /tacker/tests/unit/objects/test_grant.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.apache.org/licenses/LICENSE-2.0
#
# Unle... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/unit/objects/test_grant.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _check_vim_connection_info(_obj, _data):
self.assertEqual(len(_obj), len(_data))
for obj, data in zip(_obj, _data):
self.assertIsInstance(obj, objects.VimConnectionInfo)
def _check_update_resources(_obj, _data):
self.assertEqual(len(... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/unit/objects/test_grant.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(len(_obj), len(_data))
for obj, data in zip(_obj, _data):
self.assertIsInstance(obj, objects.CpProtocolData)
self.assertEqual(obj.layer_protocol,
data.get('layer_protocol'))
if obj.ip_over_ethernet... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/unit/objects/test_grant.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> >>> multiply(5, 10)
50
>>> multiply(-1, 1)
-1
>>> multiply(0.5, 1.5)
0.75
"""
return a*b<|fim_prefix|># repo: ikonst/teamcity-messages path: /tests/guinea-pigs/nose/doctests/namespace1/d.py
def multiply(a, b):
<|fim_middle|> """
'multiply' multiplies two numbers and returns the result.... | code_fim | medium | {
"lang": "python",
"repo": "ikonst/teamcity-messages",
"path": "/tests/guinea-pigs/nose/doctests/namespace1/d.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ikonst/teamcity-messages path: /tests/guinea-pigs/nose/doctests/namespace1/d.py
def multiply(a, b):
<|fim_suffix|> >>> multiply(5, 10)
50
>>> multiply(-1, 1)
-1
>>> multiply(0.5, 1.5)
0.75
"""
return a*b<|fim_middle|> """
'multiply' multiplies two numbers and returns the result.... | code_fim | medium | {
"lang": "python",
"repo": "ikonst/teamcity-messages",
"path": "/tests/guinea-pigs/nose/doctests/namespace1/d.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucklyzhu/CvPytorch path: /src/models/fcos.py
# !/usr/bin/env python
# -- coding: utf-8 --
# @Time : 2020/11/2 18:47
# @Author : liumin
# @File : fcos.py
import torch
import torch.nn as nn
from .tools.fcos_detect import FcosBody, GenTargets, ClipBoxes, DetectHead
from ..losses.fcos_loss... | code_fim | hard | {
"lang": "python",
"repo": "lucklyzhu/CvPytorch",
"path": "/src/models/fcos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mode == 'infer':
'''
for inference mode, img should preprocessed before feeding in net
'''
out = self.fcos_body(imgs)
scores, classes, boxes = self.detection_head(out)
boxes = self.clip_boxes(imgs, boxes)
... | code_fim | hard | {
"lang": "python",
"repo": "lucklyzhu/CvPytorch",
"path": "/src/models/fcos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def main(self):
if (self.samplename is not None) and (self.distkey is not None):
item = SampleDistanceEntry(self.samplename, self.distkey, self.h5io)
if isinstance(self.filetype, CorMatFileType):
item.writeCorMat(self.path, self.filetype)
eli... | code_fim | hard | {
"lang": "python",
"repo": "awacha/cct",
"path": "/cct/core2/processing/calculations/reportingjob.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> stopEvent: multiprocessing.synchronize.Event, messagequeue: multiprocessing.queues.Queue,
filetype: Union[CorMatFileType, CurveFileType, PatternFileType, ReportFileType],
samplename: Optional[str], distkey: Optional[str], path: str):
super().__ini... | code_fim | hard | {
"lang": "python",
"repo": "awacha/cct",
"path": "/cct/core2/processing/calculations/reportingjob.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awacha/cct path: /cct/core2/processing/calculations/reportingjob.py
from .backgroundprocess import BackgroundProcess, BackgroundProcessError
import multiprocessing
from multiprocessing import Lock
from typing import Any, Union, Optional
import enum
from .resultsentry import CorMatFileType, CurveF... | code_fim | hard | {
"lang": "python",
"repo": "awacha/cct",
"path": "/cct/core2/processing/calculations/reportingjob.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a1kaid/hunter path: /HunterCelery/notice/email_observer.py
#!/ usr/bin/env
# coding=utf-8
#
# Copyright 2019 ztosec & https://www.zto.com/
#
# 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... | code_fim | hard | {
"lang": "python",
"repo": "a1kaid/hunter",
"path": "/HunterCelery/notice/email_observer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class EmailObserver(BaseObserver):
def notify(self, task_id):
"""
发送邮件通知
:return:
"""
email_content, receivers_email = self.generate_report(task_id=task_id)
logger.info("task task_id:{} has been checked out, hunter will send result to email:{}".format(... | code_fim | hard | {
"lang": "python",
"repo": "a1kaid/hunter",
"path": "/HunterCelery/notice/email_observer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def right(self):
return self.end
@property
def is_empty(self):
if self.left_open or self.right_open:
cond = self.start >= self.end # One/both bounds open
else:
cond = self.start > self.end # Both bounds closed
return fuzz... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/sympy/sets/sets.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sympy/sympy path: /sympy/sets/sets.py
rn self._sup
@property
def _sup(self):
raise NotImplementedError("(%s)._sup" % self)
def contains(self, other):
"""
Returns a SymPy value indicating whether ``other`` is contained
in ``self``: ``true`` if it is, `... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/sympy/sets/sets.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
from .fancysets import ImageSet
from .setexpr import set_function
if len(args) < 2:
raise ValueError('imageset expects at least 2 args, got: %s' % len(args))
if isinstance(args[0], (Symbol, tuple)) and len(args) > 2:
f = Lambda(args[0], args[1])
set_list =... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/sympy/sets/sets.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> while not shutdown:
for p in processes:
if p.poll() is not None:
# return code for unknown is 2
# anything higher than that is an error
# keep solving unless there are no more running processes
if p.returncode >= 2:
... | code_fim | hard | {
"lang": "python",
"repo": "mfkiwl/pono",
"path": "/scripts/parallel_pono.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mfkiwl/pono path: /scripts/parallel_pono.py
#!/usr/bin/env python3
import argparse
import signal
import subprocess
import sys
import time
import os
## Non-blocking reads for subprocess
## https://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python
import sys
fro... | code_fim | hard | {
"lang": "python",
"repo": "mfkiwl/pono",
"path": "/scripts/parallel_pono.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if proc.poll() is None:
proc.terminate()
proc.kill()
out, _ = proc.communicate()
print(out.decode('utf-8'))
print()
sys.stdout.flush()
shutdown = False
def handle_signal(signum, frame):
# send signal recieved to subprocesses... | code_fim | hard | {
"lang": "python",
"repo": "mfkiwl/pono",
"path": "/scripts/parallel_pono.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: madcpt/MojiRambling path: /preprocess/make_vocab.py
import pickle
import numpy
import random
from tqdm import tqdm
import json
import os
import torch
from torch.utils.data.dataset import Dataset
from torch.utils.data.dataloader import DataLoader
from embeddings import GloveEmbedding, KazumaCharE... | code_fim | hard | {
"lang": "python",
"repo": "madcpt/MojiRambling",
"path": "/preprocess/make_vocab.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(self.dataset_path + 'preprocessed.pickle', 'rb') as f:
preprocessed = pickle.load(f)
self.word2index = preprocessed['word2index']
train = self.make_dataloader(preprocessed['train'], batch_size)
dev = self.make_dataloader(preprocessed['dev'], batch_siz... | code_fim | hard | {
"lang": "python",
"repo": "madcpt/MojiRambling",
"path": "/preprocess/make_vocab.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_bounds(self):
c, a = 3, 2
t = tadasets.torus(n=3045, c=3, a=2)
bound = c + a
rs = np.fromiter((norm(p) for p in t), np.float64)
assert np.all(rs <= bound)
def test_plt(self):
t = tadasets.torus(n=345)
tadasets.plot3d(t)
def te... | code_fim | hard | {
"lang": "python",
"repo": "scikit-tda/tadasets",
"path": "/test/test_shapes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scikit-tda/tadasets path: /test/test_shapes.py
import numpy as np
import pytest
import tadasets
from scipy.spatial.distance import pdist
def norm(p):
return np.sum(p ** 2) ** 0.5
class TestEmbedding:
def test_shape(self):
d = np.random.random((100, 3))
d_emb = tadasets... | code_fim | hard | {
"lang": "python",
"repo": "scikit-tda/tadasets",
"path": "/test/test_shapes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juholeinonen/iwclul2016-scripts path: /04_recognize/configs/complete_wikipedia/gen_configs.py
#!/usr/bin/env python3
import os
import glob
for lang in ("sme", "est", "fin"):
for gender in ("M", "F"):
for tool in ("s", "v"):
r = range(5,10)
if lang == "sme":
... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/iwclul2016-scripts",
"path": "/04_recognize/configs/complete_wikipedia/gen_configs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("export TEST_TRN=$GROUP_DIR/p/sami/audio_data/{}_{}/devel200.trn".format(lang, gender), file=f)
print("export TEST_WAVLIST=$GROUP_DIR/p/sami/audio_data/{}_{}/devel200.scp".format(lang, gender), file=f)
print("export ONE_BYTE_EN... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/iwclul2016-scripts",
"path": "/04_recognize/configs/complete_wikipedia/gen_configs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("export TEST_AM={}".format(am), file=f)
print("export TEST_LM=$GROUP_DIR/p/sami/lmmodels/complete_wikipedia/{}{}_cow_{}_{}g_{}".format(lang,gender,tool,order,type), file=f)
print("export TEST_TRN=$GROUP_DIR/p/sami/audio_data/{}... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/iwclul2016-scripts",
"path": "/04_recognize/configs/complete_wikipedia/gen_configs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: unlock21/Marvel-API-Playground path: /marvel/views.py
from django.http import HttpResponse, JsonResponse
from django.template import loader
from marvel.models import Character, Comic
app_name = 'marvel'
def index(request):
query = request.GET.get('q', '')
searchCharacters = []
if qu... | code_fim | medium | {
"lang": "python",
"repo": "unlock21/Marvel-API-Playground",
"path": "/marvel/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def comics(request):
return JsonResponse(list(Comic.objects.values()), safe=False)
# def comicsSearch(request):
# query = request.GET.get('q', '')
# if (query == ''): return JsonResponse([])
# comics = Comic.objects.filter(name__contains=query).select_related()
# # characters = comics... | code_fim | hard | {
"lang": "python",
"repo": "unlock21/Marvel-API-Playground",
"path": "/marvel/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('auctions', '0002_auto_20210924_1008'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='date',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AlterField(
... | code_fim | medium | {
"lang": "python",
"repo": "KonstantineDM/django-ecommerce-auctions",
"path": "/auctions/migrations/0003_auto_20210924_1143.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KonstantineDM/django-ecommerce-auctions path: /auctions/migrations/0003_auto_20210924_1143.py
# Generated by Django 3.2.7 on 2021-09-24 08:43
from django.db import migrations, models
import django.utils.timezone
<|fim_suffix|> dependencies = [
('auctions', '0002_auto_20210924_1008')... | code_fim | medium | {
"lang": "python",
"repo": "KonstantineDM/django-ecommerce-auctions",
"path": "/auctions/migrations/0003_auto_20210924_1143.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bigartm/visartm path: /datasets/urls.py
from django.conf.urls import url
import datasets.views as datasets_views
urlpatterns = [
url(r'^$', datasets_views.datasets_list<|fim_suffix|>l(r'^document_all_topics$', datasets_views.document_all_topics),
url(r'^document_segments$', datasets_views... | code_fim | hard | {
"lang": "python",
"repo": "bigartm/visartm",
"path": "/datasets/urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>l(r'^document_all_topics$', datasets_views.document_all_topics),
url(r'^document_segments$', datasets_views.document_segments),
]<|fim_prefix|># repo: bigartm/visartm path: /datasets/urls.py
from django.conf.urls import url
import datasets.views as datasets_views
urlpatterns = [
url(r'^$', datase... | code_fim | hard | {
"lang": "python",
"repo": "bigartm/visartm",
"path": "/datasets/urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#?#?#?#?#
?.|.|.|.?
#?#?#?#-#
?X|.?
#?#?#
After this point, there is (NEEE|SSE(EE|N)). This gives you exactly two
options: NEEE and SSE(EE|N). By following NEEE, the map now looks like this:
#?#?#?#?#
?.|.|.|.?
#-#?#?#?#
?.|.|.|.?
#?#?#?#-#
?X|.?
#?#?#
Now, only SSE(EE|N) remains. Becau... | code_fim | hard | {
"lang": "python",
"repo": "naiveai/adventofcode",
"path": "/python/2018/20/1.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: naiveai/adventofcode path: /python/2018/20/1.py
"""
The area you are in is made up entirely of rooms and doors. The rooms are
arranged in a grid, and rooms only connect to adjacent rooms when a door is
present between them.
For example, drawing rooms as ., walls as #, doors as | or -, your curre... | code_fim | hard | {
"lang": "python",
"repo": "naiveai/adventofcode",
"path": "/python/2018/20/1.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#?#?#?#?#
?.|.|.|.?
#-#?#?#?#
?.|.|.|.?
#?#?#?#-#
?X|.?
#?#?#
Now, only SSE(EE|N) remains. Because it is in the same parenthesized group as
NEEE, it starts from the same room NEEE started in. It states that starting
from that point, there exist doors which will allow you to move south twice,
then... | code_fim | hard | {
"lang": "python",
"repo": "naiveai/adventofcode",
"path": "/python/2018/20/1.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> UNSUPPORTED_ARGS = frozenset([
'data_files',
'package_dir',
'package_data',
'packages',
])
def __init__(self, **kwargs):
"""
:param kwargs: Passed to `setuptools.setup
<https://pythonhosted.org/setuptools/setuptools.html>`_."""
self._kw = kwargs
self._binaries... | code_fim | hard | {
"lang": "python",
"repo": "foursquare/pants",
"path": "/src/python/pants/backend/python/python_artifact.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.name
def _compute_fingerprint(self):
return sha1(json.dumps((self._kw, self._binaries),
ensure_ascii=True,
allow_nan=False,
sort_keys=True)).hexdigest()
def with_binaries(self, *... | code_fim | hard | {
"lang": "python",
"repo": "foursquare/pants",
"path": "/src/python/pants/backend/python/python_artifact.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: foursquare/pants path: /src/python/pants/backend/python/python_artifact.py
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scope... | code_fim | hard | {
"lang": "python",
"repo": "foursquare/pants",
"path": "/src/python/pants/backend/python/python_artifact.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PacktPublishing/Modern-Python-Standard-Library-Cookbook path: /Chapter04/filesdirs_08.py
import shutil
def copydir(source, dest, ignore=None):
<|fim_suffix|>import glob
print(glob.glob('_build/pdf/*'))
print(glob.glob('/tmp/buildcopy/*'))
copydir('_build/pdf', '/tmp/buildcopy', ignore=('*.rtc'... | code_fim | hard | {
"lang": "python",
"repo": "PacktPublishing/Modern-Python-Standard-Library-Cookbook",
"path": "/Chapter04/filesdirs_08.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>import glob
print(glob.glob('_build/pdf/*'))
print(glob.glob('/tmp/buildcopy/*'))
copydir('_build/pdf', '/tmp/buildcopy', ignore=('*.rtc', '*.stylelog'))
print(glob.glob('/tmp/buildcopy/*'))<|fim_prefix|># repo: PacktPublishing/Modern-Python-Standard-Library-Cookbook path: /Chapter04/filesdirs_08.py
i... | code_fim | hard | {
"lang": "python",
"repo": "PacktPublishing/Modern-Python-Standard-Library-Cookbook",
"path": "/Chapter04/filesdirs_08.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jo-lang/traversing_designspaces path: /2axes_code/area_circular.py
# --------------------------
# imports
import sys
sys.path.append("..")
from helper_functions import *
# --------------------------
# settings
p_w, p_h = 500, 500
margin = 30
dia = 4
steps = 40
txt = 'vfonts'
f_name = 'Skia-... | code_fim | hard | {
"lang": "python",
"repo": "jo-lang/traversing_designspaces",
"path": "/2axes_code/area_circular.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># --------------------------
# functions
def a_page():
newPage(p_w,p_h)
font(f_name)
fontSize(32)
fill(1)
rect(0, 0, p_w, p_h)
translate(margin, margin)
fill(.75)
rect(0, 0, axis_w, axis_h)
fill(0)
oval(-dia/2, -dia/2, dia, dia)
oval(-dia/2 + axis_w, -dia... | code_fim | hard | {
"lang": "python",
"repo": "jo-lang/traversing_designspaces",
"path": "/2axes_code/area_circular.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def_x = map_val(axis1_def, axis1_min, axis1_max, 0, axis_w)
def_y = map_val(axis2_def, axis2_min, axis2_max, 0, axis_h)
# --------------------------
# functions
def a_page():
newPage(p_w,p_h)
font(f_name)
fontSize(32)
fill(1)
rect(0, 0, p_w, p_h)
translate(margin, margin)
... | code_fim | hard | {
"lang": "python",
"repo": "jo-lang/traversing_designspaces",
"path": "/2axes_code/area_circular.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for item in in_dict:
if 'children' in item:
out_dict = out_dict + flatten_dictionary(item['children'])
else:
out_dict.append(item)
return(out_dict)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Save Safari Bookmarks.')
parser.add_argument("-v", "--verbose", help=... | code_fim | hard | {
"lang": "python",
"repo": "AG-Labs/SafariBookmarkSaver",
"path": "/SafariBookmarkSaver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out_dict = []
for item in in_dict:
if 'children' in item:
out_dict = out_dict + flatten_dictionary(item['children'])
else:
out_dict.append(item)
return(out_dict)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Save Safari Bookmarks.')
parser.add_argument("-v", "-... | code_fim | hard | {
"lang": "python",
"repo": "AG-Labs/SafariBookmarkSaver",
"path": "/SafariBookmarkSaver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AG-Labs/SafariBookmarkSaver path: /SafariBookmarkSaver.py
from urllib.request import Request, urlopen
from urllib.error import URLError
from functools import cmp_to_key
import plistlib
import subprocess
import os
import re
from shutil import copy as copy, Error as SHerror
import argparse
import t... | code_fim | hard | {
"lang": "python",
"repo": "AG-Labs/SafariBookmarkSaver",
"path": "/SafariBookmarkSaver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def initiate(self):
self.process.daemon = True
self.process.start()
def terminate(self):
self.process.terminate()
class QuietServer(Server):
def __init__(self, port):
TCPServer.__init__(self, ("", port), QuietHandler)
self.process = multiprocessing.Pr... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyjsdl",
"path": "/pyjsdl/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pandinosaurus/pyjsdl path: /pyjsdl/app.py
#!/usr/bin/env python
#Pyjsdl - Copyright (C) 2013
#Released under the MIT License
"""
Pyjsdl App
Script launches HTML app on desktop using Gtk/Webkit.
Copy app script to the application root and optionally rename.
Run the script once to create an ini ... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyjsdl",
"path": "/pyjsdl/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def webview_setup(self):
self.web = WebKit2.WebView()
uri = 'http://%s:%d/%s' % (self.config.server_ip,
self.config.server_port,
self.config.app_uri)
self.web.load_uri(uri)
self.window.add(self.web)
... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyjsdl",
"path": "/pyjsdl/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @commands.command(aliases=["Invite"])
async def invite(self, ctx):
"""Sends embed with buttons to invite the bot"""
lang = getLang(ctx.message.guild.id)
with open(f"embeds/{lang}/inviting.json", "r") as f:
inviting = json.load(f)
await ctx.reply(embed=... | code_fim | hard | {
"lang": "python",
"repo": "SilverSnowFox/Chat-Tools-Fox",
"path": "/commands/utilities/invite.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SilverSnowFox/Chat-Tools-Fox path: /commands/utilities/invite.py
import simplejson as json
import discord
from functions.getLang import getLang
from discord.ext import commands
from discord import Button, ButtonStyle, ActionRow
<|fim_suffix|> self.client = client
@commands.command(al... | code_fim | hard | {
"lang": "python",
"repo": "SilverSnowFox/Chat-Tools-Fox",
"path": "/commands/utilities/invite.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jonsim/search path: /search_modules/symbols.py
global - i.e. it
has greater scope than even global symbols. This state is only
represented by a few formats.
is_weak: Boolean, True if the symbol has weak binding - i.e. it can
be overridden by a stron... | code_fim | hard | {
"lang": "python",
"repo": "jonsim/search",
"path": "/search_modules/symbols.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not line:
return None
# Return first successful parsing.
sym = _parse_elfsymbol(line)
if sym is not None:
return sym
return _parse_othersymbol(line)
def parse_object_file(path, objdump):
"""Parses an ObjectFile from an objdump output.
Args:
path: ... | code_fim | hard | {
"lang": "python",
"repo": "jonsim/search",
"path": "/search_modules/symbols.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jonsim/search path: /search_modules/symbols.py
section: String name of the section this symbol resides in.
size: int size of the symbol, typically in bytes.
name: String name of the symbol.
"""
self.value = value
self.section = sectio... | code_fim | hard | {
"lang": "python",
"repo": "jonsim/search",
"path": "/search_modules/symbols.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tianhm/fastFM path: /fastFM/tests/test_ranking.py
# Author: Immanuel Bayer
# License: BSD 3 clause
import numpy as np
import scipy.sparse as sp
from fastFM import bpr
from fastFM import utils
def get_test_problem(task='regression'):
X = sp.csc_matrix(np.array([[6, 1],
... | code_fim | hard | {
"lang": "python",
"repo": "tianhm/fastFM",
"path": "/fastFM/tests/test_ranking.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, p in enumerate(pairs):
if y[p[0]] > y[p[1]]:
compares[i, 0] = p[0]
compares[i, 1] = p[1]
else:
compares[i, 0] = p[1]
compares[i, 1] = p[0]
print(compares)
fm = bpr.FMRecommender(n_iter=2000,
init... | code_fim | hard | {
"lang": "python",
"repo": "tianhm/fastFM",
"path": "/fastFM/tests/test_ranking.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>model = cv2.dnn_DetectionModel(frozen_model, config_file)
model.setInputSize(320,320)
model.setInputScale(1.0/127.5)
model.setInputMean((127.5, 127.5, 127.5))
model.setInputSwapRB(True)
while True:
success, img = cap.read()
classIds, confs, bbox= model.detect(img, confThreshold = thres)
... | code_fim | hard | {
"lang": "python",
"repo": "tarannum-perween/The-Sparks-Foundation-Tasks",
"path": "/object_detection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>classlabel = []
classfile = 'coco.names.txt'
with open(classfile, "rt") as f:
classlabel = f.read().rstrip('\n').split('\n')
config_file = 'ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
frozen_model = 'frozen_inference_graph.pb'
model = cv2.dnn_DetectionModel(frozen_model, config_file)
... | code_fim | medium | {
"lang": "python",
"repo": "tarannum-perween/The-Sparks-Foundation-Tasks",
"path": "/object_detection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tarannum-perween/The-Sparks-Foundation-Tasks path: /object_detection.py
#Object Detection using SSD-MobileNetv3
#Implementation using Python and OpenCV.
import cv2
thres = 0.5 #threshold to detect object
cap = cv2.VideoCapture(0) #Capture video by the default camera
<|fim_suffix|>... | code_fim | hard | {
"lang": "python",
"repo": "tarannum-perween/The-Sparks-Foundation-Tasks",
"path": "/object_detection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>to_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('firstname', models.CharField(max_length=40)),
('lastname', models.CharField(max_length=40)),
('mobile_number', models.CharField(blank=True, max_length=10)),
('descript... | code_fim | hard | {
"lang": "python",
"repo": "osundiranay/django-crud-ajax-login-register-fileupload",
"path": "/crud/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: osundiranay/django-crud-ajax-login-register-fileupload path: /crud/migrations/0001_initial.py
# Generated by Django 3.0.1 on 2020-01-01 06:55
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
... | code_fim | hard | {
"lang": "python",
"repo": "osundiranay/django-crud-ajax-login-register-fileupload",
"path": "/crud/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saltstack/salt path: /tests/pytests/integration/netapi/rest_tornado/test_events_api_handler.py
from functools import partial
import pytest
import tornado.gen
from salt.netapi.rest_tornado import saltnado
# TODO: run all the same tests from the root handler, but for now since they are
# the sam... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/pytests/integration/netapi/rest_tornado/test_events_api_handler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.slow_test
async def test_get(http_client, io_loop, app):
events_fired = []
def on_event(events_fired, event):
if len(events_fired) < 6:
event = event.decode("utf-8")
app.event_listener.event.fire_event(
{"foo": "bar", "baz": "qux"}, "sa... | code_fim | medium | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/pytests/integration/netapi/rest_tornado/test_events_api_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> lock = _locks.get(name)
if lock is None:
lock = Lock()
_locks[name] = lock
if lock.acquire(timeout=timeout):
try:
yield
finally:
lock.release()
else:
raise TimeoutError()<|fim_prefix|># repo: sleuth-io/sleuth-pr path: /sleuth... | code_fim | medium | {
"lang": "python",
"repo": "sleuth-io/sleuth-pr",
"path": "/sleuthpr/lock.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sleuth-io/sleuth-pr path: /sleuthpr/lock.py
from contextlib import contextmanager
from threading import Lock
from typing import Dict
<|fim_suffix|>
# todo: This should be swapped with redlock in prod
@contextmanager
def with_lock(name: str, timeout=1000):
lock = _locks.get(name)
if lock ... | code_fim | easy | {
"lang": "python",
"repo": "sleuth-io/sleuth-pr",
"path": "/sleuthpr/lock.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: khandavally/devstack path: /EPAQA/pci_device_patch.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Intel Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.... | code_fim | hard | {
"lang": "python",
"repo": "khandavally/devstack",
"path": "/EPAQA/pci_device_patch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if instance and self.instance_uuid != instance['uuid']:
raise exception.PciDeviceInvalidOwner(
compute_node_id=self.compute_node_id,
address=self.address, owner=self.instance_uuid,
hopeowner=instance['uuid'])
old_status = self.sta... | code_fim | hard | {
"lang": "python",
"repo": "khandavally/devstack",
"path": "/EPAQA/pci_device_patch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def is_character_level(self):
return True
@property
def target_space_id(self):
return problem.SpaceID.EN_CHR
@property
def train_shards(self):
return 1
@property
def dev_shards(self):
return 1
def preprocess_example(self, example, mode, _):
# Resize from... | code_fim | hard | {
"lang": "python",
"repo": "yyht/BERT",
"path": "/t2t_bert/utils/tensor2tensor/data_generators/ocr.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yyht/BERT path: /t2t_bert/utils/tensor2tensor/data_generators/ocr.py
# coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# 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 Lic... | code_fim | hard | {
"lang": "python",
"repo": "yyht/BERT",
"path": "/t2t_bert/utils/tensor2tensor/data_generators/ocr.py",
"mode": "psm",
"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.