text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>if __name__ == "__main__":
print(word_count(""))
print(word_count("Hello"))
print(word_count('Hello, my cat. And my cat doesn\'t say "hello" back.'))
print(word_count(
'This is a test of the emergency broadcast network. This is only a test.'))<|fim_prefix|># repo: aaronspurgeon/has... | code_fim | hard | {
"lang": "python",
"repo": "aaronspurgeon/hashtables-flex",
"path": "/applications/word_count/word_count.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
print(word_count(""))
print(word_count("Hello"))
print(word_count('Hello, my cat. And my cat doesn\'t say "hello" back.'))
print(word_count(
'This is a test of the emergency broadcast network. This is only a test.'))<|fim_prefix|># repo: aaronspurgeon/ha... | code_fim | hard | {
"lang": "python",
"repo": "aaronspurgeon/hashtables-flex",
"path": "/applications/word_count/word_count.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ibell/ACHP-1 path: /Documentation/Web/MPLPlots/CondenserFace.py
import pylab,numpy as np
from numpy import sin
from matplotlib.patches import FancyArrowPatch
fig=pylab.figure()
w=1
h=1
th=3.14159/25.
x=np.r_[0,0,w,w,0]
y=np.r_[0,h,h-w*sin(th),0-w*sin(th),0]
pylab.plot(x,y)
<|fim_suf... | code_fim | hard | {
"lang": "python",
"repo": "ibell/ACHP-1",
"path": "/Documentation/Web/MPLPlots/CondenserFace.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pylab.gca().add_patch(FancyArrowPatch((w+w/10.,h-h/12.0-(w+w/10.)*sin(th)),(w,h-h/12.0-w*sin(th)),arrowstyle='-|>',fc='k',ec='k',mutation_scale=20,lw=0.8))
pylab.gca().add_patch(FancyArrowPatch((0,h/12.0),(-w/10.,h/12.0-(-w/10.)*sin(th)),arrowstyle='-|>',fc='k',ec='k',mutation_scale=20,lw=0.8))
py... | code_fim | hard | {
"lang": "python",
"repo": "ibell/ACHP-1",
"path": "/Documentation/Web/MPLPlots/CondenserFace.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># symmetric_difference() return the values in the first set and not in the second set
# and the values in the second set and not in the first set
set9 ={1, 2, 3, 4, 5, 6, 7, 8 , 9}
set10 = {1, 2, 3, 4, 5, 6, "A", "B"}
print(set9)
print(set9.symmetric_difference(set10))
print(set9^set10)
print(set9)
print(... | code_fim | hard | {
"lang": "python",
"repo": "amiraHag/python-basic-course2",
"path": "/set/set3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amiraHag/python-basic-course2 path: /set/set3.py
# -------------------------------
# --------- Set Methods ---------
# -------------------------------
# difference() return the values in the first set that not in the second set
set1 ={1, 2, 3, 4, 5, 6, 7, 8 , 9}
set2 = {1, 2, 3, 4, 5, 6, "A", "... | code_fim | hard | {
"lang": "python",
"repo": "amiraHag/python-basic-course2",
"path": "/set/set3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: markdyousef/my-nns path: /cnn/layer.py
import numpy as np
def layer_forward(x, w):
"""
input:
- inputs (x): (N, d_1, ..., d_k),
- weights (w): (D, M)
"""
# intermediate value (z)
z = None
output = []
cache = (x, w, z, output)
return o... | code_fim | hard | {
"lang": "python",
"repo": "markdyousef/my-nns",
"path": "/cnn/layer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> N = d_output.shape[0]
d_x = d_output.dot(w.T).reshape(x.shape)
d_w = x.reshape([N, -1]).T.dot(d_output)
d_b = np.sum(d_output, axis=0)
return d_x, d_w, d_b
def relu_forward(x):
"""
input:
- inputs (x): (N, d_1, ..., d_k)
return:
- output: ... | code_fim | hard | {
"lang": "python",
"repo": "markdyousef/my-nns",
"path": "/cnn/layer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
input:
- upstream derivative (d_output): (N, M)
- cache (cache): (x, w)
return:
- gradients (dx, d_w, d_b): ((N, d1, ..., d_k)(D, M), (M,))
"""
# Unpack cache values
x, w, b = cache
N = d_output.shape[0]
d_x = d_output.dot(w... | code_fim | hard | {
"lang": "python",
"repo": "markdyousef/my-nns",
"path": "/cnn/layer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nicholasturner1/NeuronEncodings path: /neuronencodings/data/utils.py
__doc__ = """
Dataset Module Utilities - mostly for handling files and datasets
"""
import glob
import os
import random
from meshparty import mesh_io
# Datasets -----------------------
SVEN_BASE = "seungmount/research/svenmd"... | code_fim | hard | {
"lang": "python",
"repo": "nicholasturner1/NeuronEncodings",
"path": "/neuronencodings/data/utils.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def files_from_dir(dirname, exts=["obj", "h5"]):
"""
Searches a directory for a set of extensions and returns the files
matching those extensions, sorted by basename
"""
filenames = list()
for ext in exts:
ext_expr = os.path.join(dirname, f"*.{ext}")
filenames.exten... | code_fim | hard | {
"lang": "python",
"repo": "nicholasturner1/NeuronEncodings",
"path": "/neuronencodings/data/utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> train_files = permutation[:n_train]
val_files = permutation[n_train:(n_train+n_val)]
test_files = permutation[(n_train+n_val):]
return train_files, val_files, test_files
# Helper functions for testing (e.g. sample.py)
def pull_n_samples(dset, n):
"""Pulls n random samples from a dat... | code_fim | hard | {
"lang": "python",
"repo": "nicholasturner1/NeuronEncodings",
"path": "/neuronencodings/data/utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> managed = False
db_table = 'NavigantAnalyzer_results_flat'
def get_fields(self):
result = dict()
datetime_fields = ['race_begin', 'result_start_time']
for field in Results_flat._meta.fields:
value = field.value_to_string(self)
if value.i... | code_fim | medium | {
"lang": "python",
"repo": "rikoster/DataPuisto",
"path": "/NavigantAnalyzer/models/results_flat.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rikoster/DataPuisto path: /NavigantAnalyzer/models/results_flat.py
from django.db import models
from NavigantAnalyzer.common import convert_datetime_string
import json
# A custom view-based model for flat outputs - RÖ - 2018-10-24
# Don't add, change or delete fields without editing the view in ... | code_fim | medium | {
"lang": "python",
"repo": "rikoster/DataPuisto",
"path": "/NavigantAnalyzer/models/results_flat.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = dict()
datetime_fields = ['race_begin', 'result_start_time']
for field in Results_flat._meta.fields:
value = field.value_to_string(self)
if value.isdigit():
value = int(value)
if field.name in datetime_fields:
... | code_fim | medium | {
"lang": "python",
"repo": "rikoster/DataPuisto",
"path": "/NavigantAnalyzer/models/results_flat.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RamilKh/otus path: /task5/app/decorators/parser_stop.py
"""
Декоратор parser_stop - парсер результата вывода комманды docker stop.
"""
<|fim_suffix|> result = func(*args, **kwargs)
stdout = result['stdout']
"""
stdout: строки разделены \n
"""
data... | code_fim | medium | {
"lang": "python",
"repo": "RamilKh/otus",
"path": "/task5/app/decorators/parser_stop.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = stdout.split('\n')
result['data'] = data[0]
return result
return wrapper<|fim_prefix|># repo: RamilKh/otus path: /task5/app/decorators/parser_stop.py
"""
Декоратор parser_stop - парсер результата вывода комманды docker stop.
"""
from functools import wraps
<|fim_mi... | code_fim | hard | {
"lang": "python",
"repo": "RamilKh/otus",
"path": "/task5/app/decorators/parser_stop.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def clone(self):
return self.__class__(filename=self.filename, formatter=self.format)<|fim_prefix|># repo: ceumicrodata/tarr path: /tarr/debug.py
# drop data to file filter
import tarr.compiler_base
def format_data(data):
return '{0.id}: {0.payload}'.format(data)
class WRITE_TO_FILE(t... | code_fim | hard | {
"lang": "python",
"repo": "ceumicrodata/tarr",
"path": "/tarr/debug.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, filename, formatter=format_data):
self.format = formatter
self.filename = filename
def run(self, runner, data):
# NOTE: we need to do writing in UNBUFFERED mode (buffering=0)
# as potentially there are other processes writing to the same file
... | code_fim | medium | {
"lang": "python",
"repo": "ceumicrodata/tarr",
"path": "/tarr/debug.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ceumicrodata/tarr path: /tarr/debug.py
# drop data to file filter
import tarr.compiler_base
def format_data(data):
return '{0.id}: {0.payload}'.format(data)
<|fim_suffix|> @property
def __name__(self):
return 'POINT OF INTEREST - WRITE("{}")'.format(self.filename)
def ... | code_fim | medium | {
"lang": "python",
"repo": "ceumicrodata/tarr",
"path": "/tarr/debug.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get(self, request, pk, *args, **kwargs):
response = {'code': 100, 'data': None, 'error': None}
try:
degree_course = models.DegreeCourse.objects.filter(id=pk).first()
ser = DegreeCourseSerializer(degree_course)
response['data'] = ser.data
... | code_fim | hard | {
"lang": "python",
"repo": "lxw920110/s11_luffycity",
"path": "/api/views/degreecourse.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lxw920110/s11_luffycity path: /api/views/degreecourse.py
from app01 import models
from rest_framework.views import APIView
# from api.utils.response import BaseResponse
from rest_framework.response import Response
from rest_framework.pagination import PageNumberPagination
from api.serializers.cou... | code_fim | hard | {
"lang": "python",
"repo": "lxw920110/s11_luffycity",
"path": "/api/views/degreecourse.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cpatrick/geoweb path: /nodes/streamworker.py
# -*- coding: utf-8 -*-
import os
import sys
import base64
import cdutil
import json
import os
from array import array
from uuid import uuid4
import cdms2
import numpy as np
import matplotlib as mpl
mpl.rcParams['mathtext.default'] = 'regular'
mp... | code_fim | hard | {
"lang": "python",
"repo": "cpatrick/geoweb",
"path": "/nodes/streamworker.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> m.drawcoastlines()
#self.debug("save to temp file")
temp_image_file = os.path.join(TEMP_DIR, '%s.png' % str(uuid4()))
fig.savefig(temp_image_file, dpi=100)
#self.debug("convert image data to base64")
with open(temp_image_file, "rb") as temp_image:
... | code_fim | hard | {
"lang": "python",
"repo": "cpatrick/geoweb",
"path": "/nodes/streamworker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
is_even(2)
is_even(3)
is_even("cat")<|fim_prefix|># repo: renglard/python_L01 path: /ex3.py
def check_integer(a):
if type(a) != int:
print("please input an integer")
exit()
<|fim_middle|>
def is_even(a):
check_integer(a)
if a % 2 == 0:
print("true")
return ... | code_fim | medium | {
"lang": "python",
"repo": "renglard/python_L01",
"path": "/ex3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: renglard/python_L01 path: /ex3.py
def check_integer(a):
if type(a) != int:
print("please input an integer")
exit()
def is_even(a):
<|fim_suffix|>
is_even(2)
is_even(3)
is_even("cat")<|fim_middle|> check_integer(a)
if a % 2 == 0:
print("true")
return ... | code_fim | medium | {
"lang": "python",
"repo": "renglard/python_L01",
"path": "/ex3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pypa/pip path: /src/pip/_vendor/urllib3/util/ssltransport.py
import io
import socket
import ssl
from ..exceptions import ProxySchemeUnsupported
from ..packages import six
SSL_BLOCKSIZE = 16384
class SSLTransport:
"""
The SSLTransport wraps an existing socket and establishes an SSL con... | code_fim | hard | {
"lang": "python",
"repo": "pypa/pip",
"path": "/src/pip/_vendor/urllib3/util/ssltransport.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.socket.gettimeout()
def _decref_socketios(self):
self.socket._decref_socketios()
def _wrap_ssl_read(self, len, buffer=None):
try:
return self._ssl_io_loop(self.sslobj.read, len, buffer)
except ssl.SSLError as e:
if e.errno == ss... | code_fim | hard | {
"lang": "python",
"repo": "pypa/pip",
"path": "/src/pip/_vendor/urllib3/util/ssltransport.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while should_loop:
errno = None
try:
ret = func(*args)
except ssl.SSLError as e:
if e.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
# WANT_READ, and WANT_WRITE are expected, others are not.
... | code_fim | hard | {
"lang": "python",
"repo": "pypa/pip",
"path": "/src/pip/_vendor/urllib3/util/ssltransport.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Vesihiisi/COH-tools path: /importer/RoRo.py
from Monument import Monument, Dataset
import importer_utils as utils
import importer as importer
class RoRo(Monument):
def set_adm_location(self):
counties = self.data_files["counties"]
self.set_from_dict_match(counties, "iso_cod... | code_fim | hard | {
"lang": "python",
"repo": "Vesihiisi/COH-tools",
"path": "/importer/RoRo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, db_row_dict, mapping, data_files, existing, repository):
Monument.__init__(self, db_row_dict, mapping,
data_files, existing, repository)
self.set_monuments_all_id("cod")
self.set_changed()
self.set_wlm_source()
self.s... | code_fim | hard | {
"lang": "python",
"repo": "Vesihiisi/COH-tools",
"path": "/importer/RoRo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name = name
def get_name(self):
return self.name
def greet(self): # あいさつをする
print(f"こんにちは。私は{self.name}です。")
#@@range_end(list1) # ←この行は無視してください。本文に引用するためのものです。
#実行
#@@range_begin(list2) # ←この行は無視してください。本文に引用するためのものです。
foo = Person()
bar = Person()
foo.set_name('... | code_fim | medium | {
"lang": "python",
"repo": "mushahiroyuki/beginning-python",
"path": "/Chapter07/0703person.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mushahiroyuki/beginning-python path: /Chapter07/0703person.py
#@@range_begin(list1) # ←この行は無視してください。本文に引用するためのものです。
#ファイル名 Chapter07/0703person.py
# __metaclass__ = type #← python 2を使っている場合は行頭の「#」を取る
class Person:
def set_name(self, name):
self.name = name
def get_name(self):
... | code_fim | hard | {
"lang": "python",
"repo": "mushahiroyuki/beginning-python",
"path": "/Chapter07/0703person.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[num] = True
return -1
print(firstDuplicate([2,1,3,5,3]))<|fim_prefix|># repo: yash921/AlgoExpert path: /firstduplicate.py
def firstDuplicate(array):
"""
Time O(n) | Space O(n<|fim_middle|>)
"""
dic = {}
for num in array:
if num in dic:
return num
else:... | code_fim | medium | {
"lang": "python",
"repo": "yash921/AlgoExpert",
"path": "/firstduplicate.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yash921/AlgoExpert path: /firstduplicate.py
def firstDuplicate(array):
"""
Time O(n) | Space O(n)
"""
dic = {}
for num in array:
if num <|fim_suffix|>[num] = True
return -1
print(firstDuplicate([2,1,3,5,3]))<|fim_middle|>in dic:
return num
else:... | code_fim | medium | {
"lang": "python",
"repo": "yash921/AlgoExpert",
"path": "/firstduplicate.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
reader = imageio.get_reader('test1080.mov')
print reader
fps = reader.get_meta_data()['fps']
print fps
# for i, im in enumerate(reader):
# print i
nums = [10, 200]
for num in nums:
a = time.time()
image = reader.get_data(num)
b = time.time()
print b - a
# print image<|fim_prefi... | code_fim | medium | {
"lang": "python",
"repo": "ZackBinHill/Sins",
"path": "/sins/ui/widgets/version_player/old/imageio_test01.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZackBinHill/Sins path: /sins/ui/widgets/version_player/old/imageio_test01.py
# -*- coding: utf-8 -*-
# __author__ = 'XingHuan'
# 3/27/2018
import os
import imageio
import time
os.environ['IMAGEIO_FFMPEG_EXE'] = 'D:/Program Files/ffmpeg-3.4/bin/ffmpeg.exe'
<|fim_suffix|># for i, im in enumerate... | code_fim | medium | {
"lang": "python",
"repo": "ZackBinHill/Sins",
"path": "/sins/ui/widgets/version_player/old/imageio_test01.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# for i, im in enumerate(reader):
# print i
nums = [10, 200]
for num in nums:
a = time.time()
image = reader.get_data(num)
b = time.time()
print b - a
# print image<|fim_prefix|># repo: ZackBinHill/Sins path: /sins/ui/widgets/version_player/old/imageio_test01.py
# -*- coding: ut... | code_fim | medium | {
"lang": "python",
"repo": "ZackBinHill/Sins",
"path": "/sins/ui/widgets/version_player/old/imageio_test01.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: romain-li/leetcode path: /problems/0113_Path_Sum_II/__init__.py
ID = '113'
TITLE = 'Path Sum II'
DIFFICULTY = 'Medium'
URL = 'https://oj.leetcode.com/problems/path-sum-ii/'
BOOK = False
PROBLEM = r"""Given a binary tree and a sum, find all root-to-leaf paths where each path's
sum equals the given... | code_fim | hard | {
"lang": "python",
"repo": "romain-li/leetcode",
"path": "/problems/0113_Path_Sum_II/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>return
[
[5,4,11,2],
[5,8,4,5]
]
"""<|fim_prefix|># repo: romain-li/leetcode path: /problems/0113_Path_Sum_II/__init__.py
ID = '113'
TITLE = 'Path Sum II'
DIFFICULTY = 'Medium'
URL = 'https://oj.leetcode.com/problems/path-sum-ii/'
BOOK = False
PROBLEM = r"""... | code_fim | hard | {
"lang": "python",
"repo": "romain-li/leetcode",
"path": "/problems/0113_Path_Sum_II/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
return
[
[5,4,11,2],
[5,8,4,5]
]
"""<|fim_prefix|># repo: romain-li/leetcode path: /problems/0113_Path_Sum_II/__init__.py
ID = '113'
TITLE = 'Path Sum II'
DIFFICULTY = 'Medium'
URL = 'https://oj.leetcode.com/problems/path-sum-ii/'
BOOK = False
PROBLEM = r""... | code_fim | medium | {
"lang": "python",
"repo": "romain-li/leetcode",
"path": "/problems/0113_Path_Sum_II/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>while (choice != rand):
attempt += 1
choice =get_choice(attempt)
if choice > rand:
print('Too high. Guess again:',end='')
elif choice < rand:
print('Too low. Guess again:',end='')
else:
print('Correct. It took you {0} guesses.'.format(attempt))
#if __name... | code_fim | hard | {
"lang": "python",
"repo": "varunk01/Utilsfnc",
"path": "/numberguess.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>choice =0
rand = get_random()
attempt =0
while (choice != rand):
attempt += 1
choice =get_choice(attempt)
if choice > rand:
print('Too high. Guess again:',end='')
elif choice < rand:
print('Too low. Guess again:',end='')
else:
print('Correct. It took you {... | code_fim | medium | {
"lang": "python",
"repo": "varunk01/Utilsfnc",
"path": "/numberguess.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: varunk01/Utilsfnc path: /numberguess.py
"""
*********************************************************************
* Project : POP1 (Practical Exam)
* Program name : q2.py
* Author : varunk01
* Purpose : Attempts to solve the question 2 from the exam paper
* Date created : 28/05/2018
*
* Date ... | code_fim | hard | {
"lang": "python",
"repo": "varunk01/Utilsfnc",
"path": "/numberguess.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def getSarcasmScore(sentence):
sentence = sentence.encode('ascii', 'ignore')
features = feature_extraction.getallfeatureset(sentence)
features_vec = vec.transform(features)
score = classifier.decision_function(features_vec)[0]
percentage = int(round(2.0*(1.0/(1.0+np.exp(-score))-0... | code_fim | hard | {
"lang": "python",
"repo": "shashwatnayak/detecting-sarcasm",
"path": "/sarcasm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shashwatnayak/detecting-sarcasm path: /sarcasm.py
# -*- coding: utf-8 -*-
import numpy as np
import pickle
import os
import feature_extraction
#import topic
file1 = open('vecdict_all.p', 'r')
file2 = open('classif_all.p','r')
vec = pickle.load(file1)
classifier = pickle.load(file2)
file1.clo... | code_fim | medium | {
"lang": "python",
"repo": "shashwatnayak/detecting-sarcasm",
"path": "/sarcasm.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sentence = sentence.encode('ascii', 'ignore')
features = feature_extraction.getallfeatureset(sentence)
features_vec = vec.transform(features)
score = classifier.decision_function(features_vec)[0]
percentage = int(round(2.0*(1.0/(1.0+np.exp(-score))-0.5)*100.0))
return per... | code_fim | medium | {
"lang": "python",
"repo": "shashwatnayak/detecting-sarcasm",
"path": "/sarcasm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LiuFang816/SALSTM_py_data path: /python/panpanpandas_ultrafinance/ultrafinance-master/tests/unit/test_py_talib.py
'''
Created on Dec 18, 2011
@author: ppa
'''
import unittest
from ultrafinance.pyTaLib.indicator import Sma
<|fim_suffix|> pass
def tearDown(self):
pass
def... | code_fim | easy | {
"lang": "python",
"repo": "LiuFang816/SALSTM_py_data",
"path": "/python/panpanpandas_ultrafinance/ultrafinance-master/tests/unit/test_py_talib.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testSma(self):
sma = Sma(period = 3)
expectedAvgs = [1, 1.5, 2, 3, 4]
for index, number in enumerate(range(1, 6) ):
self.assertEqual(expectedAvgs[index], sma(number))<|fim_prefix|># repo: LiuFang816/SALSTM_py_data path: /python/panpanpandas_ultrafinance/ultrafi... | code_fim | medium | {
"lang": "python",
"repo": "LiuFang816/SALSTM_py_data",
"path": "/python/panpanpandas_ultrafinance/ultrafinance-master/tests/unit/test_py_talib.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def testSma(self):
sma = Sma(period = 3)
expectedAvgs = [1, 1.5, 2, 3, 4]
for index, number in enumerate(range(1, 6) ):
self.assertEqual(expectedAvgs[index], sma(number))<|fim_prefix|># repo: LiuFang816/SALSTM_py_data path: /python/panpanpandas_ultraf... | code_fim | easy | {
"lang": "python",
"repo": "LiuFang816/SALSTM_py_data",
"path": "/python/panpanpandas_ultrafinance/ultrafinance-master/tests/unit/test_py_talib.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class UnflattenTestCase(unittest.TestCase):
def test_simple(self):
self.assertDictEqual(
unflatten(
{'a': 1,
'b[0]': 'c',
'b[1][0]': 'd',
'b[1][1][e][f]': -1,
'b[1][1][e][g]': 'h'}),
{'a... | code_fim | hard | {
"lang": "python",
"repo": "sovetov/unflatten",
"path": "/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sovetov/unflatten path: /test.py
import unittest
from unflatten import _path_tuples_with_values_to_dict_tree, dot_colon_join, dot_colon_split
from unflatten import _recognize_lists
from unflatten import _tree_to_path_tuples_with_values
from unflatten import brackets_join
from unflatten import fl... | code_fim | hard | {
"lang": "python",
"repo": "sovetov/unflatten",
"path": "/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
handle (UcsHandle)
org_name (string): Name of the organization
name (string): Name of the firmware pack.
org_parent (string): Parent of Org.
Returns:
None
Example:
firmware_pack_remove(handle, org_name="sample_org",
... | code_fim | hard | {
"lang": "python",
"repo": "vvb/ucsmsdk_samples",
"path": "/ucsmsdk_samples/server/firmware_pack.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def helper(s, k):
if len(s) < k:
return 0
ch = min(set(s), key=s.count)
if s.count(ch) >= k:
return len(s)
else:
return max(helper(t, k) for t in s.split(ch))
return helper(s, k)<|fim_prefix|># ... | code_fim | hard | {
"lang": "python",
"repo": "honchen22/LeetCode",
"path": "/算法/Python/395. Longest Substring with At Least K Repeating Characters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: champagnemandem/crypto-python path: /Crypto/cryptobot_3.py
import numpy as np
import csv
class PriceTracker:
def __init__(self):
pass
def getValue(self, i):
pass
class CsvTracker:
def __init__(self, csv_file):
self.current_row = 61
self.csv_file_co... | code_fim | hard | {
"lang": "python",
"repo": "champagnemandem/crypto-python",
"path": "/Crypto/cryptobot_3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> current_price = self.price_tracker.getValue(0)
result = 0
i = 0
for heuristic in self.heuristics:
print "For Heuristic %s at time %s ouptut = %s" % (i, self.price_tracker.current_row, heuristic.getCurrentValue())
result += heuristic.getCurrentValue()... | code_fim | hard | {
"lang": "python",
"repo": "champagnemandem/crypto-python",
"path": "/Crypto/cryptobot_3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> busstop_list=[]
req = request.Request('{}?{}'.format(BusInfo.url_busstop, parse.urlencode(BusInfo.params)))
with request.urlopen(req) as res:
json_load = json.load(res)
for v in json_load:
try:
busstop = { 'busstop_id'... | code_fim | hard | {
"lang": "python",
"repo": "mxl00474/Yokohama_bus_navi_gmap",
"path": "/bus_monitor/BusInfo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mxl00474/Yokohama_bus_navi_gmap path: /bus_monitor/BusInfo.py
from urllib import request, parse
import pandas as pd
import json
import os
class BusInfo:
url = 'https://api-tokyochallenge.odpt.org/api/v4/odpt:Bus'
url_busstop = 'https://api-tokyochallenge.odpt.org/api/v4/odpt:BusstopPole... | code_fim | hard | {
"lang": "python",
"repo": "mxl00474/Yokohama_bus_navi_gmap",
"path": "/bus_monitor/BusInfo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
path('detalhes/', user_views.painel, name="painel"),
path('produto/ajax/delete_prod/', prod_views.deleteProd, name="deleteProd"),
path('produto/', user_views.painelProdutos, name="painel_produtos"),
path('<int:id_produto>', prod_views.detalheProduto, name="detalhe_prod"),
... | code_fim | medium | {
"lang": "python",
"repo": "JVitorLeone/monitora",
"path": "/users/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JVitorLeone/monitora path: /users/urls.py
from django.urls import path
from . import views as user_views
from produtos import views as prod_views
from django.contrib.auth import views as auth_views
<|fim_suffix|>urlpatterns = [
path('detalhes/', user_views.painel, name="painel"),
path('p... | code_fim | medium | {
"lang": "python",
"repo": "JVitorLeone/monitora",
"path": "/users/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: artheadsweden/python_nov_18 path: /day2/My_Map.py
def func(n):
return n*2
def my_map(f, seq):
return [f(item) for item in seq]
def main():
<|fim_suffix|>if __name__ == '__main__':
main()<|fim_middle|> numbers = [1, 2, 3, 4]
result = list(map(func, numbers))
print(result)
... | code_fim | medium | {
"lang": "python",
"repo": "artheadsweden/python_nov_18",
"path": "/day2/My_Map.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = [func(item) for item in numbers]
print(result)
if __name__ == '__main__':
main()<|fim_prefix|># repo: artheadsweden/python_nov_18 path: /day2/My_Map.py
def func(n):
return n*2
def my_map(f, seq):
return [f(item) for item in seq]
def main():
<|fim_middle|> numbers = [1,... | code_fim | medium | {
"lang": "python",
"repo": "artheadsweden/python_nov_18",
"path": "/day2/My_Map.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def subset2_helper(num, mid_result, result, position):
result.append(mid_result[:])
for i in range(position, len(num)):
mid_result.append(num[i])
subset2_helper(num, mid_result, result, i + 1)
mid_result.pop()
if __name__ == '__main__':
subset2([1, 2, 3])<|fim_prefix|>... | code_fim | medium | {
"lang": "python",
"repo": "yuzhecd/al_py",
"path": "/Recursion/Subset2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.append(mid_result[:])
for i in range(position, len(num)):
mid_result.append(num[i])
subset2_helper(num, mid_result, result, i + 1)
mid_result.pop()
if __name__ == '__main__':
subset2([1, 2, 3])<|fim_prefix|># repo: yuzhecd/al_py path: /Recursion/Subset2.py
# Th... | code_fim | easy | {
"lang": "python",
"repo": "yuzhecd/al_py",
"path": "/Recursion/Subset2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yuzhecd/al_py path: /Recursion/Subset2.py
# This program just for testing push from Mac.
def subset2(num):
mid_result = []
result = []
subset2_helper(num, mid_result, result, 0)
print(result)
<|fim_suffix|>if __name__ == '__main__':
subset2([1, 2, 3])<|fim_middle|>def subset2... | code_fim | hard | {
"lang": "python",
"repo": "yuzhecd/al_py",
"path": "/Recursion/Subset2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> urlprefix = "http://www.ocw.titech.ac.jp"
response = requests.get(url)
soup = BeautifulSoup(response.content,'lxml')
table = soup.find('table',class_='ranking-list').tbody
for item in table.find_all('tr'):
code = item.find('td',class_='code').string
name = item.find('td',class_='course_title').a... | code_fim | hard | {
"lang": "python",
"repo": "IQ1-ITSP/OcwScraping",
"path": "/mainpage.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IQ1-ITSP/OcwScraping path: /mainpage.py
import requests
from bs4 import BeautifulSoup
'''
OCWから学院一覧を取得するスクリプト(6個くらいだから必要ない気もする)
gakuinListの各要素は次のような辞書に鳴っている
{
'name' : 学院名,
'url' : その学院の授業の一覧のurl,
}
'''
def getGakuinList():
url = "http://www.ocw.titech.ac.jp/"
response = requests.get(url)
s... | code_fim | hard | {
"lang": "python",
"repo": "IQ1-ITSP/OcwScraping",
"path": "/mainpage.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if fn:
fname = fn
else:
fname = 'TMP_scat.png'
fig.savefig( fname, format='png' )
print 'WROTE --> %s' % fname
######################################
use = '''
Usage: %s
-h help
'''
if __name__ == '__main__':
def usage():
sys.stderr.write(use % s... | code_fim | hard | {
"lang": "python",
"repo": "cpearson1/et-demands",
"path": "/et-demands/refET/bin/scat_plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cpearson1/et-demands path: /et-demands/refET/bin/scat_plot.py
#!/usr/bin/env python
##!/work/local/bin/python
##!/work/local/CDAT/bin/python
import sys,getopt
import matplotlib.pyplot as plt
def read():
x = []
y = []
for line in sys.stdin:
v1,v2 = line.split()[:2]
... | code_fim | hard | {
"lang": "python",
"repo": "cpearson1/et-demands",
"path": "/et-demands/refET/bin/scat_plot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devysi0827/irioneora path: /backend/pages/views.py
from .models import RecommendedArtifact
from .serializers import RecommendedArtifactSerialize
from rest_framework.decorators import api_view
from rest_framework.response import Response
from datetime import datetime
import requests, bs4
# const... | code_fim | hard | {
"lang": "python",
"repo": "devysi0827/irioneora",
"path": "/backend/pages/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if nowYear%4==0 and nowYear%100!=0 or nowYear%400==0:
month = [31,29,31,30,31,30,31,31,30,31,30,31]
else:
month = [31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(nowMonth-1):
daySum += month[i]
daySum += nowDay
Recommended_list = RecommendedArtifact.... | code_fim | hard | {
"lang": "python",
"repo": "devysi0827/irioneora",
"path": "/backend/pages/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for var, val in self.variables.items():
yield var + ': ' + val
if __name__ == '__main__':
if len(sys.argv) > 1:
for path in sys.argv[1:]:
name = '.'.join(path.split('.')[:-1])
extractor = Extractor(name)
read = open(path)
... | code_fim | hard | {
"lang": "python",
"repo": "josh-austin/color-extractor",
"path": "/extract.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ecotrust/TEKDB path: /TEKDB/explore/urls.py
from django.conf.urls import url, include
from . import views
explore_patterns = [
url(r'^$', views.explore),
url(r'^(?P<model_type>\w+)/$', views.get_by_model_type),
url(r'^(?P<model_type>\w+)/(?P<id>\w+)/$', views.get_by_model_id),
u... | code_fim | medium | {
"lang": "python",
"repo": "Ecotrust/TEKDB",
"path": "/TEKDB/explore/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
url(r'^about/', views.about),
url(r'^help/', views.help),
url(r'^search/', views.search, name='search'),
url(r'^explore$', views.explore),
url(r'^explore/', include(explore_patterns)),
url(r'^export$', views.download),
url(r'^export/', include(export_patterns)),
... | code_fim | medium | {
"lang": "python",
"repo": "Ecotrust/TEKDB",
"path": "/TEKDB/explore/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JordyHB/Jord-bot path: /bot_functions.py
import random
import profile_handler
import re
class RollBot():
"""A class that handles the bulk of functionality"""
def __init__(self):
"""initializes the attributes of the class"""
# this is where the procesed user input gets s... | code_fim | hard | {
"lang": "python",
"repo": "JordyHB/Jord-bot",
"path": "/bot_functions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Function that handles the optional advantage options"""
# This part handles advantage so it takes the highest of the 2 numbers
# and then drops the lowest number
if self.adv == 'adv':
# Checks wether the number that was input is not 1 or 2.
if st... | code_fim | hard | {
"lang": "python",
"repo": "JordyHB/Jord-bot",
"path": "/bot_functions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pyautogui.pixel(xPosition, yPosition)[0] == 0:
click(xPosition, yPosition)<|fim_prefix|># repo: AnwarFahad/tooWeaktooSlow path: /tooWeaktooSlow.py
# The purpose of this bot is to cick the first black pixel.
# Testing a change here done by Git.
# changes through branches
import pyaut... | code_fim | medium | {
"lang": "python",
"repo": "AnwarFahad/tooWeaktooSlow",
"path": "/tooWeaktooSlow.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>while keyboard.is_pressed('s') == False:
# If the pixel is black (0), click on that pixel
if pyautogui.pixel(xPosition, yPosition)[0] == 0:
click(xPosition, yPosition)<|fim_prefix|># repo: AnwarFahad/tooWeaktooSlow path: /tooWeaktooSlow.py
# The purpose of this bot is to cick the f... | code_fim | hard | {
"lang": "python",
"repo": "AnwarFahad/tooWeaktooSlow",
"path": "/tooWeaktooSlow.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnwarFahad/tooWeaktooSlow path: /tooWeaktooSlow.py
# The purpose of this bot is to cick the first black pixel.
# Testing a change here done by Git.
# changes through branches
import pyautogui
import keyboard
import win32api
import win32con
import time
# click function, with a 0.01 pa... | code_fim | hard | {
"lang": "python",
"repo": "AnwarFahad/tooWeaktooSlow",
"path": "/tooWeaktooSlow.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: figkim/TC2 path: /leetcode/2020/hard/00076_minimum_window_substring/min_substring_dy.py
class Solution:
def minWindow(self, s: str, t: str) -> str:
char_cnt = {}
for character in t:
if character not in char_cnt:
char_cnt[character] = 1
e... | code_fim | hard | {
"lang": "python",
"repo": "figkim/TC2",
"path": "/leetcode/2020/hard/00076_minimum_window_substring/min_substring_dy.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if containAll:
substring = s[dq[0][0]:dq[-1][0]+1]
if min_substring is None or len(substring) < len(min_substring):
min_substring = substring
return min_substring if min_substring else ""<|fim_prefix|># repo: figkim/TC2 path: /l... | code_fim | hard | {
"lang": "python",
"repo": "figkim/TC2",
"path": "/leetcode/2020/hard/00076_minimum_window_substring/min_substring_dy.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Rearranges columns of S to best fit the components they likely represent (maximizes sum of correlations)"""
cov = np.cov(trueS, S)
k = S.shape[0]
corr = np.zeros([k,k])
for i in range(k):
for j in range(k):
corr[i][j] = cov[i + k][j]/np.sqrt(cov[i + k][i + ... | code_fim | hard | {
"lang": "python",
"repo": "KKDeng/proxmin",
"path": "/examples/unmixing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KKDeng/proxmin path: /examples/unmixing.py
from proxmin import nmf
from proxmin.utils import Traceback
from proxmin import operators as po
from scipy.optimize import linear_sum_assignment
import numpy as np
import matplotlib.pyplot as plt
import time
from functools import partial
# init... | code_fim | hard | {
"lang": "python",
"repo": "KKDeng/proxmin",
"path": "/examples/unmixing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username')))
response_content = r.content.decode('utf-8')
json_data = response_content.lstrip('])}while(1);</x>')
return json.loads(json_data)<|fim_prefix|># repo: myles/me-api path: /middleware/module_medium.py
from __future__ impo... | code_fim | medium | {
"lang": "python",
"repo": "myles/me-api",
"path": "/middleware/module_medium.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> response_content = r.content.decode('utf-8')
json_data = response_content.lstrip('])}while(1);</x>')
return json.loads(json_data)<|fim_prefix|># repo: myles/me-api path: /middleware/module_medium.py
from __future__ import unicode_literals
import requests
<|fim_middle|>try:
import json... | code_fim | hard | {
"lang": "python",
"repo": "myles/me-api",
"path": "/middleware/module_medium.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: myles/me-api path: /middleware/module_medium.py
from __future__ import unicode_literals
import requests
<|fim_suffix|> MEDIUM_API_ENDPOINT = 'https://medium.com/{0}/latest?format=json'
r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username')))
response_content = r.content.d... | code_fim | medium | {
"lang": "python",
"repo": "myles/me-api",
"path": "/middleware/module_medium.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def input_batch_generator(self, split_name, is_training=False, batch_size=32, get_filenames = False, get_sparselabel = True, get_denselabel = True):
samples = self.get_samples(split_name)
self.prepare_get_filenames = get_filenames
self.prepare_get_sparselabel = get_sparselabel... | code_fim | hard | {
"lang": "python",
"repo": "Lesley96-11/cluttered_mnist_sequence",
"path": "/preparedata.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomkooij/AdventOfCode path: /aoc2015/day19.py
# adventofcode.com
# day19
from collections import defaultdict
INPUTFILE = 'input/input19'
TEST = False
TESTCASE = ('HOH', ['H => HO\n', 'H => OH\n', 'O => HH\n'], ['OHOH', 'HOOH', 'HHHH', 'HOHO'])
def find_idx(string, substring):
<|fim_suffix|>if... | code_fim | hard | {
"lang": "python",
"repo": "tomkooij/AdventOfCode",
"path": "/aoc2015/day19.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # part B
# Cheated! #Atoms - 2*(#Rn) - 2*(#Y) - 1
# https://www.reddit.com/r/adventofcode/comments/3xflz8/day_19_solutions/cy4etju
print 'part B'
print sum(map(str.isupper,inputstring)) - 2*inputstring.count('Rn') - 2*inputstring.count('Y') - 1<|fim_prefix|># repo: tomkooij/AdventOfCod... | code_fim | hard | {
"lang": "python",
"repo": "tomkooij/AdventOfCode",
"path": "/aoc2015/day19.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def create_agents() -> List[InsuranceAgent]:
"""
Create the InsuranceAgents. Consumers are created with randomized attributes.
:return: A new list of InsuranceAgent.
"""
agents = []
for consumer in range(AGENTS_COUNT):
insur... | code_fim | hard | {
"lang": "python",
"repo": "octavian-negru/call-center-coding-exercise",
"path": "/call_center/src/actors/actors_creator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __del__(self):
self.stop_all_agents()
@staticmethod
def create_consumers() -> List[Consumer]:
"""
Create the consumers. Consumers are created with randomized attributes.
:return: A new list of Consumer.
"""
consumers = []
for consume... | code_fim | hard | {
"lang": "python",
"repo": "octavian-negru/call-center-coding-exercise",
"path": "/call_center/src/actors/actors_creator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: octavian-negru/call-center-coding-exercise path: /call_center/src/actors/actors_creator.py
import random
from typing import List
from faker import Faker
from call_center.src.actors.agent import InsuranceAgent
from call_center.src.actors.consumer import Consumer
from call_center.src.common.pers... | code_fim | hard | {
"lang": "python",
"repo": "octavian-negru/call-center-coding-exercise",
"path": "/call_center/src/actors/actors_creator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('FAQ', '0004_auto_20210616_1253'),
]
operations = [
migrations.RemoveField(
model_name='question',
name='link',
),
migrations.RemoveField(
model_name='question',
name='photo',
),
... | code_fim | medium | {
"lang": "python",
"repo": "KikoIsHere/Django-first-project",
"path": "/FAQ/migrations/0005_auto_20210616_1341.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='question',
name='link',
),
migrations.RemoveField(
model_name='question',
name='photo',
),
migrations.AlterField(
model_name='question',
na... | code_fim | medium | {
"lang": "python",
"repo": "KikoIsHere/Django-first-project",
"path": "/FAQ/migrations/0005_auto_20210616_1341.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KikoIsHere/Django-first-project path: /FAQ/migrations/0005_auto_20210616_1341.py
# Generated by Django 3.2.4 on 2021-06-16 13:41
import ckeditor.fields
from django.db import migrations
<|fim_suffix|> dependencies = [
('FAQ', '0004_auto_20210616_1253'),
]
operations = [
... | code_fim | medium | {
"lang": "python",
"repo": "KikoIsHere/Django-first-project",
"path": "/FAQ/migrations/0005_auto_20210616_1341.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_python/Problem_95/531.py
s = 'ejp mysljylc kd kxveddknmc re jsicpdrysirbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcdde kr kd eoya kw aej tysr re ujdr lkgc jv'
sa = 'our language is impossible to understandthere are twenty six factorial possibilitiesso ... | code_fim | medium | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_95/531.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>f = open('A-small-attempt0.in', 'r')
L = f.readlines()
tc = 0
for i in range(1, len(L)):
s = L[i]
S = ''
for j in range(len(s)):
if s[j] == '\n':
continue
S += ans[s[j]]
tc += 1
print('Case #',tc,': ',S,sep='')<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_py... | code_fim | medium | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_95/531.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carinasauter/partyplanner path: /test/test_unit.py
import unittest
from app.party import Party
from app.guest import Guest
from app.shoppingList import ShoppingList
def test_aPartywithNoGuestsShouldHaveNoPartyGuests():
party = Party()
assert 0 == party.numberOfGuests()
def test_aPartywithOne... | code_fim | hard | {
"lang": "python",
"repo": "carinasauter/partyplanner",
"path": "/test/test_unit.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> party = Party()
party.setLocation("my House")
assert "my House" == party.getLocation()
def test_aGuestShouldRevealHerName():
guest1 = Guest("Lisa", "female")
assert "Lisa" == guest1.hasName()
def test_weShouldKnowWhoIsAtTheParty():
party = Party()
lisa = Guest("Lisa", 'female')
rob = Guest("Rob... | code_fim | hard | {
"lang": "python",
"repo": "carinasauter/partyplanner",
"path": "/test/test_unit.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_createShoppingListBasedOnParty():
shoppingList = ShoppingList()
party = Party()
lisa = Guest("Lisa", 'female')
rob = Guest("Rob", 'male')
susan = Guest("susan", 'female')
party.attendedBy(lisa)
party.attendedBy(rob)
party.attendedBy(susan)
shoppingList.baseOn(party)
assert shoppingList.... | code_fim | hard | {
"lang": "python",
"repo": "carinasauter/partyplanner",
"path": "/test/test_unit.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.