text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Atoosa-Telus/ccoe-infra-dev-np path: /main.py
# [START imports]
import json
import sys
import os
import argparse
import datetime
import configparser
import yaml
from datetime import datetime
import sys
import argparse
sys.path.insert(0, './python-modules')
# sys.path.insert(0, './resources')
sys... | code_fim | hard | {
"lang": "python",
"repo": "Atoosa-Telus/ccoe-infra-dev-np",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> project = ProjectClass(config['Project'], alias)
valid_aliases = project.list_valid_aliases(config['Project'])
print(valid_aliases)
print(project.name)
print(project.env)
print(project)
# bq.dataset_metadata_read()<|fim_prefix|># repo: Atoosa-Telus/ccoe-infra-dev-np path: /m... | code_fim | hard | {
"lang": "python",
"repo": "Atoosa-Telus/ccoe-infra-dev-np",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python path: /source/oddtuples.py
def oddTuples(aTup):
'''
aTup: a tuple
<|fim_suffix|> g = g + (aTup[i],)
print "g " , g
return g
print oddTuples((4, 15, 4, 5, 2, 15, 7, 20))<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python",
"path": "/source/oddtuples.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print oddTuples((4, 15, 4, 5, 2, 15, 7, 20))<|fim_prefix|># repo: mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python path: /source/oddtuples.py
def oddTuples(aTup):
'''
aTup: a tuple
<|fim_middle|> returns: tuple, every other element of aTup.
'''
# Y... | code_fim | hard | {
"lang": "python",
"repo": "mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python",
"path": "/source/oddtuples.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> g = g + (aTup[i],)
print "g " , g
return g
print oddTuples((4, 15, 4, 5, 2, 15, 7, 20))<|fim_prefix|># repo: mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python path: /source/oddtuples.py
def oddTuples(aTup):
'''
aTup: a tuple
<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "mahmedraza/6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python",
"path": "/source/oddtuples.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Train
count = 0
print 'Train total ' + str(train_num * crop_number)
index = sorted(range(0, train_num * crop_number), key=lambda x: random.random())
in_db = lmdb.open(savepath + 'flickr-train-lmdb', map_size=int(1e12))
with in_db.begin(write=True) as in_txn:
for style in train_pic:
for pic in train_p... | code_fim | hard | {
"lang": "python",
"repo": "kevinkingo/ImageStyle-TwoPath",
"path": "/flickr/data_provider/generate_flickr_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kevinkingo/ImageStyle-TwoPath path: /flickr/data_provider/generate_flickr_data.py
import caffe
import lmdb
import numpy as np
import cv2, random
savepath = '../data/'
if not os.path.exists(savepath):
os.makedirs(savepath)
def crop_image(img):
crop_size = 224
range_h = img.shape[0] - crop... | code_fim | hard | {
"lang": "python",
"repo": "kevinkingo/ImageStyle-TwoPath",
"path": "/flickr/data_provider/generate_flickr_data.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VivienAdnot/python-cheatsheet path: /libs/numpy/test_numpy.py
import numpy as np
from numpy.testing import assert_array_equal
# takes a list
def get_3_max_values(arr):
np_array = np.array(arr)
sorted_index_array = np.argsort(np_array)
sorted_array = np_array[sorted_index_array]
<|fim_suff... | code_fim | hard | {
"lang": "python",
"repo": "VivienAdnot/python-cheatsheet",
"path": "/libs/numpy/test_numpy.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> values = [4, 6, 12]
expected_result = [4, 4+6, 4+6+12] # [4, 10, 22]
assert_array_equal(np.cumsum(values), expected_result)<|fim_prefix|># repo: VivienAdnot/python-cheatsheet path: /libs/numpy/test_numpy.py
import numpy as np
from numpy.testing import assert_array_equal
# takes a list
def ge... | code_fim | hard | {
"lang": "python",
"repo": "VivienAdnot/python-cheatsheet",
"path": "/libs/numpy/test_numpy.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> trailingJetPt_hist = ROOT.TH1F('trailingJetPt_hist', 'Trailing Jet p_{T} (RECO)', 50, 0, 500)
trailingJetPt_hist.GetXaxis().SetTitle('p_{T} (GeV)')
trailingJetPt_hist.GetYaxis().SetTitle('Number of Events')
histos['trailingJetPt_hist'] = trailingJetPt_hist
print('Histograms declared')
return histo... | code_fim | hard | {
"lang": "python",
"repo": "alpakpinar/VBFStudies",
"path": "/lib/histos.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alpakpinar/VBFStudies path: /lib/histos.py
import ROOT
def declareHistos():
print('Declaring histograms')
histos = {}
nJets_hist = ROOT.TH1D('nJets_hist', 'Number of Jets (RECO)', 20, 0, 20)
nJets_hist.GetXaxis().SetTitle('Number of Jets')
nJets_hist.GetYaxis().SetTitle('Number of Events... | code_fim | hard | {
"lang": "python",
"repo": "alpakpinar/VBFStudies",
"path": "/lib/histos.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: horia141/jupiter path: /src/core/jupiter/core/framework/secure.py
"""Annotations for codepaths that deal with security in some way."""
from typing import Callable, TypeVar
<|fim_suffix|>def secure_class(cls): # type: ignore
"""Mark this class as dealing with security, auth, etc but it's noo... | code_fim | medium | {
"lang": "python",
"repo": "horia141/jupiter",
"path": "/src/core/jupiter/core/framework/secure.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def secure_class(cls): # type: ignore
"""Mark this class as dealing with security, auth, etc but it's noop otherwise."""
return cls<|fim_prefix|># repo: horia141/jupiter path: /src/core/jupiter/core/framework/secure.py
"""Annotations for codepaths that deal with security in some way."""
from ty... | code_fim | medium | {
"lang": "python",
"repo": "horia141/jupiter",
"path": "/src/core/jupiter/core/framework/secure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def secure_fn(f: Callable[..., X]) -> Callable[..., X]: # type: ignore
"""Mark this function as dealing with security, auth, etc but it's noop otherwise."""
return f
def secure_class(cls): # type: ignore
"""Mark this class as dealing with security, auth, etc but it's noop otherwise."""
... | code_fim | easy | {
"lang": "python",
"repo": "horia141/jupiter",
"path": "/src/core/jupiter/core/framework/secure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: siriuswhiter/SharkAndFish path: /effcient_test.py
from RunLenCode import *
from SEA import *
from twice_encode import *
scale=1
stastic=[]
stastic_2=[]
for i in range(6):
l = [10, 33, 100, 319, 1000, 3190]
scale = l[i]
s=Sea(scale,scale,3)
s.init_random<|fim_suffix|>ode_2=t.Sea2Tc... | code_fim | medium | {
"lang": "python",
"repo": "siriuswhiter/SharkAndFish",
"path": "/effcient_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ode_2=t.Sea2Tcode(s)
stastic_2.append(len(code_2)/(2*scale*scale))
print(stastic)
print(stastic_2)<|fim_prefix|># repo: siriuswhiter/SharkAndFish path: /effcient_test.py
from RunLenCode import *
from SEA import *
from twice_encode import *
scale=1
stastic=[]
stastic_2=[]
for i in range(6):
... | code_fim | medium | {
"lang": "python",
"repo": "siriuswhiter/SharkAndFish",
"path": "/effcient_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def replace_with_values(self, template_key, values):
self.replace(template_key, values[template_key])
def contents(self):
return self.template_string<|fim_prefix|># repo: hugemane/prerequisite-dependency-presider path: /pdp/utility/filetemplate.py
from string import Template
cl... | code_fim | hard | {
"lang": "python",
"repo": "hugemane/prerequisite-dependency-presider",
"path": "/pdp/utility/filetemplate.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hugemane/prerequisite-dependency-presider path: /pdp/utility/filetemplate.py
from string import Template
class FileTemplate:
def __init__(self, template_string):
self.template_string = template_string
<|fim_suffix|> template = Template(self.template_string)
replacem... | code_fim | medium | {
"lang": "python",
"repo": "hugemane/prerequisite-dependency-presider",
"path": "/pdp/utility/filetemplate.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> def replace(self, template_key, value):
template = Template(self.template_string)
replacement = {template_key: value}
self.template_string = template.safe_substitute(replacement)
def replace_with_values(self, template_key, values):
self.replace(template_key, values... | code_fim | medium | {
"lang": "python",
"repo": "hugemane/prerequisite-dependency-presider",
"path": "/pdp/utility/filetemplate.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sulembutproton/pythonbible path: /pythonbible/formatter.py
import json
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import Any, Callable, Dict, List, Optional, Type
from pythonbible.bible.bible_parser import BibleParser
from pythonbible.bible.osis.parse... | code_fim | hard | {
"lang": "python",
"repo": "sulembutproton/pythonbible",
"path": "/pythonbible/formatter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> text += _format_paragraph(verse_text, format_type)
return text
def format_scripture_text_with_parser(
verse_ids: List[int],
parser: BibleParser,
full_title: bool,
format_type: str,
include_verse_numbers: bool,
) -> str:
title_function: Callable[[Any], Any] = (
... | code_fim | hard | {
"lang": "python",
"repo": "sulembutproton/pythonbible",
"path": "/pythonbible/formatter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polaroidz/euler path: /euler09.py
def is_triplet(t):
a, b, c = t
if not a < b < c:
return False
<|fim_suffix|>from itertools import combinations
a = combinations(range(200, 500), 3)
a = filter(is_triplet, a)
a = next(a)
print(a, sum(a))<|fim_middle|> return a**2 + b**2 == c**2 and a ... | code_fim | easy | {
"lang": "python",
"repo": "polaroidz/euler",
"path": "/euler09.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a = combinations(range(200, 500), 3)
a = filter(is_triplet, a)
a = next(a)
print(a, sum(a))<|fim_prefix|># repo: polaroidz/euler path: /euler09.py
def is_triplet(t):
a, b, c = t
if not a < b < c:
return False
return a**2 + b**2 == c**2 and a + b + c == 1000
<|fim_middle|>from itertools impo... | code_fim | easy | {
"lang": "python",
"repo": "polaroidz/euler",
"path": "/euler09.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_constructor(self):
"""
"""
assert self.santa.floor == 0
@pytest.mark.parametrize("instructions,floor", [
("(())", 0),
("()()", 0),
("(((", 3),
("(()(()(", 3),
("))(((((", 3),
("())", -1),
("))(", -1),
(")))",... | code_fim | medium | {
"lang": "python",
"repo": "pylbrecht/adventofcode",
"path": "/2015/day01/test_day1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @pytest.mark.parametrize("instructions,floor", [
("(())", 0),
("()()", 0),
("(((", 3),
("(()(()(", 3),
("))(((((", 3),
("())", -1),
("))(", -1),
(")))", -3),
(")())())", -3),
])
def test_move(self, instructions, floor):
... | code_fim | hard | {
"lang": "python",
"repo": "pylbrecht/adventofcode",
"path": "/2015/day01/test_day1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pylbrecht/adventofcode path: /2015/day01/test_day1.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
from day1 import *
import pytest
class TestSanta:
"""
"""
def setup_method(self, method):
"""
"""
self.santa = Santa()
<|fim_suffix|> @pytest.m... | code_fim | medium | {
"lang": "python",
"repo": "pylbrecht/adventofcode",
"path": "/2015/day01/test_day1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #access tesseract module
tess.pytesseract.tesseract_cmd ='C:\Program Files\Tesseract-OCR/tesseract.exe'
result = tess.image_to_string(img)
#remove an auto added character at the beginning of the string if the image had no text
print("analuyzying")
print(result)
return result[:-1]<|fim_pref... | code_fim | medium | {
"lang": "python",
"repo": "IvanYu327/Study-Goose",
"path": "/imageToText.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IvanYu327/Study-Goose path: /imageToText.py
import pytesseract as tess
from PIL import Image
import urllib.request
from PIL import Image
<|fim_suffix|> #access tesseract module
tess.pytesseract.tesseract_cmd ='C:\Program Files\Tesseract-OCR/tesseract.exe'
result = tess.image_to_strin... | code_fim | hard | {
"lang": "python",
"repo": "IvanYu327/Study-Goose",
"path": "/imageToText.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hello-kukoo/flaskbokeh path: /app.py
# -*- coding: utf-8 -*-
from flask import Flask, Response, make_response, render_template, request
import numpy as np
import pandas as pd
from bokeh.plotting import figure, output_file
from bokeh.embed import components
from bokeh.charts import Histogram
ap... | code_fim | hard | {
"lang": "python",
"repo": "hello-kukoo/flaskbokeh",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> p.line(years, second_country_data_attribute, legend=second_country,
line_color="green", line_width=3)
return p
@app.route('/gapminder', methods=['GET', 'POST'])
def gapminder_plot():
first_country = "China"
second_country = "Singapore"
selected_attribute = "income"
if... | code_fim | hard | {
"lang": "python",
"repo": "hello-kukoo/flaskbokeh",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('fly')
person_car_robot = PersonCarRobot()
person_car_robot.talk()
person_car_robot.run()
person_car_robot.fly()<|fim_prefix|># repo: jsmack/learn path: /old/language/python/udemy/ds/087/87.py
class Person(object):
def talk(self):
print('talk')
def run(self):
prin... | code_fim | easy | {
"lang": "python",
"repo": "jsmack/learn",
"path": "/old/language/python/udemy/ds/087/87.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jsmack/learn path: /old/language/python/udemy/ds/087/87.py
class Person(object):
def talk(self):
print('talk')
<|fim_suffix|>person_car_robot = PersonCarRobot()
person_car_robot.talk()
person_car_robot.run()
person_car_robot.fly()<|fim_middle|> def run(self):
print('run pe... | code_fim | hard | {
"lang": "python",
"repo": "jsmack/learn",
"path": "/old/language/python/udemy/ds/087/87.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lways ruining everything
that's my future daughter in law
berk is pretty much perfect
all of my hard work has paid off
the world just got a whole lot bigger
you want to give this another shot
this is amazing
no longer amazing
that really came out of nowhere
we got to work on your solo gliding th... | code_fim | hard | {
"lang": "python",
"repo": "Xayrulloh/English-Ozbek-dictionary",
"path": "/lugatga ogirish.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xayrulloh/English-Ozbek-dictionary path: /lugatga ogirish.py
gizni yuming, bolalar
Bu shamol bilan biz Dragonga tong otguncha etib boramiz
Yaxshisi, biz bu kemani ajdarlarga to'ldiramiz va tezda
halol bo'lish vaqti emas
port choragidan tashqarida
ularga to'r, yigitlar
ularni pastga tushirin... | code_fim | hard | {
"lang": "python",
"repo": "Xayrulloh/English-Ozbek-dictionary",
"path": "/lugatga ogirish.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impersonation
you're the pride of Berk, son
i'm pretty impressed with myself, too
and since no chief could ask for a better successor
i've decided
sensitive
it's a lot of responsibility
all those speeches and planning and running the village that's his thing
i think you're missing the point
what... | code_fim | hard | {
"lang": "python",
"repo": "Xayrulloh/English-Ozbek-dictionary",
"path": "/lugatga ogirish.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imanousar/Automatic-Subtitles-Synchronization path: /SubSync Auth/BGRU/subsync/model/eval_ann.py
import matplotlib.pyplot as plt
import pickle
import sys
import os
DIRNAME = os.path.dirname(os.path.realpath(__file__))
OUT_DIR = os.path.join(DIRNAME, 'out')
MODEL = os.path.join(OUT_DIR, 'ann.hdf5... | code_fim | medium | {
"lang": "python",
"repo": "imanousar/Automatic-Subtitles-Synchronization",
"path": "/SubSync Auth/BGRU/subsync/model/eval_ann.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('val_loss:', min(history['val_loss']))
print('val_acc:', max(history['val_acc']))
try:
plot(history)
except KeyboardInterrupt as e:
sys.exit(0)<|fim_prefix|># repo: imanousar/Automatic-Subtitles-Synchronization path: /SubSync Auth/BGRU/subsync/model/eval_ann.py
impo... | code_fim | hard | {
"lang": "python",
"repo": "imanousar/Automatic-Subtitles-Synchronization",
"path": "/SubSync Auth/BGRU/subsync/model/eval_ann.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
history = pickle.load(open(HIST, "rb"))
print('val_loss:', min(history['val_loss']))
print('val_acc:', max(history['val_acc']))
try:
plot(history)
except KeyboardInterrupt as e:
sys.exit(0)<|fim_prefix|># repo: imanousar/Automatic-Subtitles... | code_fim | hard | {
"lang": "python",
"repo": "imanousar/Automatic-Subtitles-Synchronization",
"path": "/SubSync Auth/BGRU/subsync/model/eval_ann.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
'inter_image_path': os.path.join(data_root,'inter_img'),# 内参图像路径
'exter_image_path':os.path.join(data_root,'exter_param.jpg'),# 外参图像路径
'K':None,'D':None,'Xi':None#或者手动输入内参,List
}
calibrate_config={
'select_laser':'auto'
'',# auto or manual
... | code_fim | hard | {
"lang": "python",
"repo": "K7epifanio/CameraLaserCalibrate",
"path": "/Configs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: K7epifanio/CameraLaserCalibrate path: /Configs.py
import os
data_root = './data/camera1'# 绝对路径
data_collection_config = {'cam_id':0,
'img_wight':1280,'img_hight':720,
'scan_topic_name': 'scan', # 激光消息名字,一般为scan
'local_r... | code_fim | hard | {
"lang": "python",
"repo": "K7epifanio/CameraLaserCalibrate",
"path": "/Configs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BaduMa/python-self-study path: /dict-set.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/11/9 11:53
# @Author : maxu
# dict
# Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度
d ={'A':90,'B':55,'C':27}
print(d['B'])
# 把数据放入dict的方法,除了初始化时指定外... | code_fim | hard | {
"lang": "python",
"repo": "BaduMa/python-self-study",
"path": "/dict-set.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># dict可以用在需要高速查找的很多地方,在Python代码中几乎无处不在,正确使用dict非常重要,需要牢记的第一条就是dict的key必须是不可变对象。
# 这是因为dict根据key来计算value的存储位置,如果每次计算相同的key得出的结果不同,那dict内部就完全混乱了。这个通过key计算位置的算法称为哈希算法(Hash)。
# 要保证hash的正确性,作为key的对象就不能变。在Python中,字符串、整数等都是不可变的,因此,可以放心地作为key。而list是可变的,就不能作为key
# set: set和dict类似,也是一组key的集合,但不存储value。由于key不... | code_fim | medium | {
"lang": "python",
"repo": "BaduMa/python-self-study",
"path": "/dict-set.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GabrielMartinMoran/TFI_UNTREF path: /api/tests/utils/validators/numeric_validator_test.py
import pytest
from src.utils.validators.numeric_validator import NumericValidator
class ExampleModel:
prop_to_validate = None
@pytest.fixture
def model():
return ExampleModel()
def test_is_valid_r... | code_fim | hard | {
"lang": "python",
"repo": "GabrielMartinMoran/TFI_UNTREF",
"path": "/api/tests/utils/validators/numeric_validator_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_is_valid_returns_true_when_property_value_is_valid_and_value_is_equal_to_min(model):
model.prop_to_validate = 10
validator = NumericValidator('prop_to_validate', int, min=10)
actual = validator.is_valid(model)
assert actual
def test_is_valid_returns_false_when_property_value_is_g... | code_fim | hard | {
"lang": "python",
"repo": "GabrielMartinMoran/TFI_UNTREF",
"path": "/api/tests/utils/validators/numeric_validator_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return HttpResponse('<h>%s comforline</h>' %i.marka)
if(i.marka =="Audi"):
return HttpResponse('<h>%s comfort</h>' % i.marka)
#return HttpResponse('<h>hosgeldin</h>')<|fim_prefix|># repo: IstanbulSehirUniversity2017Fall/assignment1-django-models-mehmetaky... | code_fim | medium | {
"lang": "python",
"repo": "IstanbulSehirUniversity2017Fall/assignment1-django-models-mehmetakyol",
"path": "/cars/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IstanbulSehirUniversity2017Fall/assignment1-django-models-mehmetakyol path: /cars/views.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render,HttpResponse
from .models import Cars
# Create your views here.
def home_view(request,marka):
... | code_fim | medium | {
"lang": "python",
"repo": "IstanbulSehirUniversity2017Fall/assignment1-django-models-mehmetakyol",
"path": "/cars/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dash-carrera/Coding-Projects-from-Youth path: /highfrequencystealing/main.py
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# 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 L... | code_fim | hard | {
"lang": "python",
"repo": "dash-carrera/Coding-Projects-from-Youth",
"path": "/highfrequencystealing/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Updates the score given a post request from Processing
def get(self):
global p1score, p2score
p1score = self.request.get("p1score")
p2score = self.request.get("p2score")
application = webapp2.WSGIApplication([
('/', MainPage),
('/venmo_oauth',Authentication),
('/payment',MakePayment),... | code_fim | hard | {
"lang": "python",
"repo": "dash-carrera/Coding-Projects-from-Youth",
"path": "/highfrequencystealing/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carlos-gemmell/Glasgow-NLP path: /notebooks/src/Experiments.py
from abc import ABC, abstractmethod
import torch
from .metrics import nltk_bleu
import numpy as np
import os
import sys
from .useful_utils import string_split_v3, string_split_v1, chunks
import pytrec_eval
import json
import subproces... | code_fim | hard | {
"lang": "python",
"repo": "carlos-gemmell/Glasgow-NLP",
"path": "/notebooks/src/Experiments.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def dict_mean(self, dict_list):
mean_dict = {}
for key in dict_list[0].keys():
mean_dict[key] = sum(d[key] for d in dict_list) / len(dict_list)
return mean_dict
class TREC_Eval_Command_Experiment():
def __init__(self, trec_eval_command='trec_eval -q -c -M10... | code_fim | hard | {
"lang": "python",
"repo": "carlos-gemmell/Glasgow-NLP",
"path": "/notebooks/src/Experiments.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dtekluva/Collection_of_python_apps path: /uncharted/io test.py
import random
import string
f = open("twist.txt","r") #opens file with name of "test.txt"
<|fim_suffix|>f.close()
##print ("Loading word list from file...")
### inFile: file
##inFile = open("twist.txt", 'r')
### line: string
##line =... | code_fim | medium | {
"lang": "python",
"repo": "dtekluva/Collection_of_python_apps",
"path": "/uncharted/io test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>f.close()
##print ("Loading word list from file...")
### inFile: file
##inFile = open("twist.txt", 'r')
### line: string
##line = inFile.readline()
### wordlist: list of strings
##wordlist = str.split(line)
###print(line)
##
##
##print (" ", len(wordlist), "words loaded.")<|fim_prefix|># repo: dtekluva/C... | code_fim | medium | {
"lang": "python",
"repo": "dtekluva/Collection_of_python_apps",
"path": "/uncharted/io test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hmcts/rdo-serviceops-dash path: /app/routes/idam_services/idam.py
from flask import Flask, Blueprint, render_template
import os
import adal
import requests
import json
<|fim_suffix|>
return render_template('idam_services/index.html')<|fim_middle|>from azure.common.credentials import Service... | code_fim | medium | {
"lang": "python",
"repo": "hmcts/rdo-serviceops-dash",
"path": "/app/routes/idam_services/idam.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
return render_template('idam_services/index.html')<|fim_prefix|># repo: hmcts/rdo-serviceops-dash path: /app/routes/idam_services/idam.py
from flask import Flask, Blueprint, render_template
import os
import adal
import requests
import json
from azure.common.credentials import ServicePrincipalCrede... | code_fim | easy | {
"lang": "python",
"repo": "hmcts/rdo-serviceops-dash",
"path": "/app/routes/idam_services/idam.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rishti-gupta/CSE575_SML_Project1 path: /proj_part_1.py
import scipy.io
import math
import numpy
from sklearn.metrics import confusion_matrix
# Initial dataset
Numpyfile = scipy.io.loadmat('mnist_data.mat')
train_x = Numpyfile['trX'] # 784x12116
train_y = Numpyfile['trY'] # 12116x1
test_x = Nu... | code_fim | hard | {
"lang": "python",
"repo": "rishti-gupta/CSE575_SML_Project1",
"path": "/proj_part_1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def log_likelihood(train_x8, train_y8, weights):
scores = numpy.dot(train_x8, weights)
ll = numpy.sum(train_y8 * scores - numpy.log(1 + numpy.exp(scores)))
return ll
def logistic_regression(train_x8, train_y8, weights, num_steps, learning_rate):
init = log_likelihood(train_x8, train_y8, ... | code_fim | hard | {
"lang": "python",
"repo": "rishti-gupta/CSE575_SML_Project1",
"path": "/proj_part_1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> scores = numpy.dot(train_x8, weights)
ll = numpy.sum(train_y8 * scores - numpy.log(1 + numpy.exp(scores)))
return ll
def logistic_regression(train_x8, train_y8, weights, num_steps, learning_rate):
init = log_likelihood(train_x8, train_y8, weights)
print("initial ", init)
for ste... | code_fim | hard | {
"lang": "python",
"repo": "rishti-gupta/CSE575_SML_Project1",
"path": "/proj_part_1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jcrodriguezu/legalstat path: /web_scraper.py
# -*- coding: utf-8 -*-
"""Legal start web scraper test."""
import json
import argparse
import requests
import lxml.html
from scraper import ItemParser, Scraper
INITIAL_URL = "https://yolaw-tokeep-hiring-env.herokuapp.com/"
class WebScraper(object... | code_fim | hard | {
"lang": "python",
"repo": "jcrodriguezu/legalstat",
"path": "/web_scraper.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __get_remote_json_data(self, json_path):
pass
def get_parameters():
"""Check the script parameters and return a dict with the values.
:return: Dict with the parsed parameters. Ex:
{
json_path: /home/user/test/test.json,
location: web
}... | code_fim | hard | {
"lang": "python",
"repo": "jcrodriguezu/legalstat",
"path": "/web_scraper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_parameters():
"""Check the script parameters and return a dict with the values.
:return: Dict with the parsed parameters. Ex:
{
json_path: /home/user/test/test.json,
location: web
}
"""
parser = argparse.ArgumentParser(
prog='pyt... | code_fim | hard | {
"lang": "python",
"repo": "jcrodriguezu/legalstat",
"path": "/web_scraper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # It can be printed.
print(c)
# This is nice, but it also makes sense to have things that are not just single numbers or strings.
# We can define data structures like Lists. This is done by using brackets.
empty_list = []
full_list = ["apple", "pear", "COVID"]
print(empty_list)
print(full_l... | code_fim | hard | {
"lang": "python",
"repo": "alexluuuu/covid_analysis",
"path": "/starter.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# we can print out variables:
print(a)
print(b)
# we can do mathematical operations:
d = a + b
# note that we are putting d on the left hand.
# you can think of the equals sign as saying "d receives the value of a + b"
print(d)
# We can also define a variable to be some text. This is calle... | code_fim | hard | {
"lang": "python",
"repo": "alexluuuu/covid_analysis",
"path": "/starter.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexluuuu/covid_analysis path: /starter.py
"""
starter.py
All text enclosed in triple quotes (regardless of line breaks inside) will turn into a comment.
Comments will be ignored when the code, which means we can use this to document what our code does.
"""
# using a hashtag is another way to... | code_fim | hard | {
"lang": "python",
"repo": "alexluuuu/covid_analysis",
"path": "/starter.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joycekanfp/geophoto path: /geophotoapp/models.py
from django.db import models
import datetime
class GeoPhoto(models.Model):
title = models.CharField(max_length=250)
latitude=models.FloatField()
longitude=models.FloatField()
photo_url = models.CharField(max_length=500, unique=True... | code_fim | medium | {
"lang": "python",
"repo": "joycekanfp/geophoto",
"path": "/geophotoapp/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.name
class FavList(models.Model):
geophoto = models.ForeignKey(GeoPhoto, on_delete=models.CASCADE)
date_added = models.DateField(default=datetime.datetime.now)
def __str__(self):
return self.geophoto.title<|fim_prefix|># repo: joycekanfp/geophoto path: /geophotoa... | code_fim | medium | {
"lang": "python",
"repo": "joycekanfp/geophoto",
"path": "/geophotoapp/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> geophoto = models.ForeignKey(GeoPhoto, on_delete=models.CASCADE)
date_added = models.DateField(default=datetime.datetime.now)
def __str__(self):
return self.geophoto.title<|fim_prefix|># repo: joycekanfp/geophoto path: /geophotoapp/models.py
from django.db import models
import dateti... | code_fim | hard | {
"lang": "python",
"repo": "joycekanfp/geophoto",
"path": "/geophotoapp/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iitwebdev/lectures path: /WSGI/ianb/SodaFired/trunk/sodafired/db.py
from sqlobject import *
hub = sqlhub
class Piece(SQLObject):
title = StringCol(notNull=True)
link = StringCol(alternateID=True)
description = StringCol()
price = CurrencyCol()
inventory = IntCol(notNull=Tru... | code_fim | medium | {
"lang": "python",
"repo": "iitwebdev/lectures",
"path": "/WSGI/ianb/SodaFired/trunk/sodafired/db.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for table in Piece, PieceTags, Section:
table.createTable(ifNotExists=True)
if reset:
table.clearTable()<|fim_prefix|># repo: iitwebdev/lectures path: /WSGI/ianb/SodaFired/trunk/sodafired/db.py
from sqlobject import *
hub = sqlhub
class Piece(SQLObject):
title = Str... | code_fim | medium | {
"lang": "python",
"repo": "iitwebdev/lectures",
"path": "/WSGI/ianb/SodaFired/trunk/sodafired/db.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def init_db(reset=False):
for table in Piece, PieceTags, Section:
table.createTable(ifNotExists=True)
if reset:
table.clearTable()<|fim_prefix|># repo: iitwebdev/lectures path: /WSGI/ianb/SodaFired/trunk/sodafired/db.py
from sqlobject import *
hub = sqlhub
class Piece(SQ... | code_fim | medium | {
"lang": "python",
"repo": "iitwebdev/lectures",
"path": "/WSGI/ianb/SodaFired/trunk/sodafired/db.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>time = "13:58"
time = "25:51"
time = "02:76"
print(validTime(time))<|fim_prefix|># repo: Bharadwaja92/CompetitiveCoding path: /CodeSignal/Arcade/ValidTime.py
"""
Check if the given string is a correct time representation of the 24-hour clock.
Example
For time = "13:58", the output should be
validTime(t... | code_fim | medium | {
"lang": "python",
"repo": "Bharadwaja92/CompetitiveCoding",
"path": "/CodeSignal/Arcade/ValidTime.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bharadwaja92/CompetitiveCoding path: /CodeSignal/Arcade/ValidTime.py
"""
Check if the given string is a correct time representation of the 24-hour clock.
Example
For time = "13:58", the output should be
validTime(time) = true;
For time = "25:51", the output should be
validTime(time) = false;
Fo... | code_fim | easy | {
"lang": "python",
"repo": "Bharadwaja92/CompetitiveCoding",
"path": "/CodeSignal/Arcade/ValidTime.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum() % K
counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
answer += counter[x]
counter[x] += 1
if i >= K-1:
counter[Acum[i-(K-1)]] -= 1
print(answer)<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Py... | code_fim | medium | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p02851/s786658234.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02851/s786658234.py
import sys
import numpy as np
from collections import defaultdict
<|fim_suffix|>N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum() % K
counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
answer +=... | code_fim | medium | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p02851/s786658234.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: storrellas/idrink path: /combiner/apps.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
<|fim_suffix|> name = 'combiner'<|fim_middle|>class CombinerConfig(AppConfig):
| code_fim | easy | {
"lang": "python",
"repo": "storrellas/idrink",
"path": "/combiner/apps.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class CombinerConfig(AppConfig):
name = 'combiner'<|fim_prefix|># repo: storrellas/idrink path: /combiner/apps.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
<|fim_middle|>from django.apps import AppConfig
| code_fim | easy | {
"lang": "python",
"repo": "storrellas/idrink",
"path": "/combiner/apps.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = Service_center
fields = ['name', 'phone', 'content']
class Report_problem_Form(forms.ModelForm):
class Meta:
model = Report_problem
fields = ['reason', 'other_reason']<|fim_prefix|># repo: Animal-recipe/AnimalRecipe path: /footer/forms.py
from django import fo... | code_fim | medium | {
"lang": "python",
"repo": "Animal-recipe/AnimalRecipe",
"path": "/footer/forms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Animal-recipe/AnimalRecipe path: /footer/forms.py
from django import forms
from .models import AD, Service_center, Report_problem
class ADForm(forms.ModelForm):
class Meta:
model = AD
fields = ['name', 'phone', 'content']
class Service_center_Form(forms.ModelForm):
class... | code_fim | easy | {
"lang": "python",
"repo": "Animal-recipe/AnimalRecipe",
"path": "/footer/forms.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = Report_problem
fields = ['reason', 'other_reason']<|fim_prefix|># repo: Animal-recipe/AnimalRecipe path: /footer/forms.py
from django import forms
from .models import AD, Service_center, Report_problem
class ADForm(forms.ModelForm):
class Meta:
model =... | code_fim | medium | {
"lang": "python",
"repo": "Animal-recipe/AnimalRecipe",
"path": "/footer/forms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
file = readFile('docs/read.txt')
writeFile('docs/write.txt', file);<|fim_prefix|># repo: sutin1234/python3-basic path: /read_file.py
def readFile(file_path):
f = open(file_path, 'r')
contents = f.read()
f.close()
return contents
<|fim_middle|>def writeFile(file_path, con... | code_fim | medium | {
"lang": "python",
"repo": "sutin1234/python3-basic",
"path": "/read_file.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f = open(file_path, 'w+')
f.write(contents)
f.close()
return f
if __name__ == '__main__':
file = readFile('docs/read.txt')
writeFile('docs/write.txt', file);<|fim_prefix|># repo: sutin1234/python3-basic path: /read_file.py
def readFile(file_path):
f = open(file_path, 'r')
contents = f.read()
f.... | code_fim | easy | {
"lang": "python",
"repo": "sutin1234/python3-basic",
"path": "/read_file.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sutin1234/python3-basic path: /read_file.py
def readFile(file_path):
f = open(file_path, 'r')
contents = f.read()
f.close()
return contents
<|fim_suffix|> f = open(file_path, 'w+')
f.write(contents)
f.close()
return f
if __name__ == '__main__':
file = readFile('docs/read.txt')
writeFil... | code_fim | easy | {
"lang": "python",
"repo": "sutin1234/python3-basic",
"path": "/read_file.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josh-asi/typeracer-bot path: /typeracer-bot.py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from s... | code_fim | hard | {
"lang": "python",
"repo": "josh-asi/typeracer-bot",
"path": "/typeracer-bot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>textInput = wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[1]/div/div[1]/div[2]/table/tbody/tr[2]/td[2]/div/div[1]/table/tbody/tr[3]/td/div/div/table/tbody/tr[2]/td[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/input')))
for word in excerpt.text:
textInput.send_keys(word)
if wor... | code_fim | hard | {
"lang": "python",
"repo": "josh-asi/typeracer-bot",
"path": "/typeracer-bot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
plaintext (str): English string to encrypt
Returns:
Encrypted text
"""
return simplesubstitution.encrypt(KEY, plaintext)<|fim_prefix|># repo: micheloosterhof/lantern path: /lantern/modules/atbash.py
"""Automated breaking of the Atbash Cipher."""
from lantern.module... | code_fim | hard | {
"lang": "python",
"repo": "micheloosterhof/lantern",
"path": "/lantern/modules/atbash.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: micheloosterhof/lantern path: /lantern/modules/atbash.py
"""Automated breaking of the Atbash Cipher."""
from lantern.modules import simplesubstitution
from typing import Iterable
# TODO: Consider using an affine cipher for transformation in future
KEY = 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
def decr... | code_fim | medium | {
"lang": "python",
"repo": "micheloosterhof/lantern",
"path": "/lantern/modules/atbash.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Duck-duck-duan/Algorithmic path: /CSES/dice combinations/dice_combinations_2.py
n = int(input())
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
<|fim_suffix|>print(dp[n]% (10**9 + 7))<|fim_middle|> for x in range(1,7):
if i - x >= 0:
dp[i] += dp[i-x] % (10**9 + 7)... | code_fim | medium | {
"lang": "python",
"repo": "Duck-duck-duan/Algorithmic",
"path": "/CSES/dice combinations/dice_combinations_2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(dp[n]% (10**9 + 7))<|fim_prefix|># repo: Duck-duck-duan/Algorithmic path: /CSES/dice combinations/dice_combinations_2.py
n = int(input())
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
<|fim_middle|> for x in range(1,7):
if i - x >= 0:
dp[i] += dp[i-x] % (10**9 + 7)... | code_fim | medium | {
"lang": "python",
"repo": "Duck-duck-duan/Algorithmic",
"path": "/CSES/dice combinations/dice_combinations_2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># print('\n \n test set \n')
# y_pred_test = classf.predict(X_test)
# y_true_test = y_test
#
#
# print("Accuracy on test set: " + str(accuracy_score(y_true_test, y_pred_test)))
#
# cm_test = confusion_matrix(y_true_test, y_pred_test)
# print("Confusion matrix Test set")
# print(cm_test)
#
# TPrate = cm_te... | code_fim | hard | {
"lang": "python",
"repo": "RVACardoso/APSFailureLearning",
"path": "/NBayes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RVACardoso/APSFailureLearning path: /NBayes.py
#bernouli multinomial ou gaussiana
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from... | code_fim | hard | {
"lang": "python",
"repo": "RVACardoso/APSFailureLearning",
"path": "/NBayes.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># df_train = df_train.drop(columns=['cd_000'])
# df_test = df_test.drop(columns=['cd_000'])
# col = [17, 63, 68, 83, 95]
# col = [elem+15 for elem in col]
# print(col)
# X_train_imb = df_train.iloc[:, col].values
X_train_imb = df_train.iloc[:, 1:].values
y_train_imb = df_train.iloc[:, 0].values
X_test =... | code_fim | hard | {
"lang": "python",
"repo": "RVACardoso/APSFailureLearning",
"path": "/NBayes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomczak724/COVID_tracking_analysis path: /code/covid_plotting.py
import os
import sys
import glob
import json
import numpy
import pandas
import datetime
import subprocess
import matplotlib
from matplotlib import pyplot
import covid_utils as utils
def main():
### plot summary of data for... | code_fim | hard | {
"lang": "python",
"repo": "tomczak724/COVID_tracking_analysis",
"path": "/code/covid_plotting.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
df_input : pandas.DataFrame
Dataframe containing the data (duh)
column : str
Name of column to analyze
'''
if column not in df_input.columns:
raise IOError('Column "%s" not found in input dataframe' % column)
### ... | code_fim | hard | {
"lang": "python",
"repo": "tomczak724/COVID_tracking_analysis",
"path": "/code/covid_plotting.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WangliLin/SAH-RNN path: /utils.py
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import pandas as pd
import tensorflow as tf
import random as rn
import numpy as np
import os
from sklearn.metrics import precision_recall_curve, roc_auc_score
from keras.callbacks import EarlyStopping, ReduceLROnPla... | code_fim | hard | {
"lang": "python",
"repo": "WangliLin/SAH-RNN",
"path": "/utils.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> precision, recall, _ = precision_recall_curve(y_true, y_pred)
try:
idx = precision.tolist().index(0.1 + np.min(abs(precision - 0.1)))
except:
idx = precision.tolist().index(0.1 - np.min(abs(precision - 0.1)))
return recall[idx]<|fim_prefix|># repo: WangliLin/SAH-RNN path: ... | code_fim | hard | {
"lang": "python",
"repo": "WangliLin/SAH-RNN",
"path": "/utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>f bufA[0] == " ": #첫 글자가 공백이라면
count_word -= 1
print(count_word)<|fim_prefix|># repo: pereahave/my_source_for_baekjoon path: /1152 단어의 개수.py
bufA = input()
count_word = 1
if bufA == "": #입력이 없으면 0를 출력
print(0)
else:
for i in bufA:
if i == " ": #공백문자를 계산
count_wor<... | code_fim | medium | {
"lang": "python",
"repo": "pereahave/my_source_for_baekjoon",
"path": "/1152 단어의 개수.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pereahave/my_source_for_baekjoon path: /1152 단어의 개수.py
bufA = input()
count_word = 1
if bufA == "": #입력이 없으면 0를 출력
print(0)
else:
for i in bufA:
if i == " ": #공백문자를 계산
count_wor<|fim_suffix|>f bufA[0] == " ": #첫 글자가 공백이라면
count_word -= 1
print(count_word)<... | code_fim | medium | {
"lang": "python",
"repo": "pereahave/my_source_for_baekjoon",
"path": "/1152 단어의 개수.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rf = RandomForestRegressor(n_estimators=20, max_depth=4)
#20个分类器,深度为4
scores = []
print(X.shape)
for i in range(X.shape[1]):#分别让每个特征与响应变量做模型分析并得到误差率
score = cross_val_score(rf, X[:, i:i+1], Y, scoring="r2",
cv=ShuffleSplit(len(X), 3, .3))
scores.append((round(np.mea... | code_fim | medium | {
"lang": "python",
"repo": "Simon-lsy/Citytree",
"path": "/classification/weight_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Simon-lsy/Citytree path: /classification/weight_test.py
from sklearn.cross_validation import cross_val_score, ShuffleSplit
from sklearn.datasets import load_boston#波士顿房屋价格预测
from sklearn.ensemble import RandomForestRegressor
import numpy as np
#集成学习ensemble库中的随机森林回归RandomForestRegressor
<|fim_su... | code_fim | medium | {
"lang": "python",
"repo": "Simon-lsy/Citytree",
"path": "/classification/weight_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
dim = 300
vs = 5000
bpemb_en = BPEmb(lang="en", dim=dim, vs=vs)
vocab = dict((i, i + 1) for i in range(vs))
embeds = bpemb_en.vectors
embeds = np.concatenate((np.zeros((1, dim)), embeds))
embeds = torch.FloatTensor(embeds)
embeds = nn.Embedding.... | code_fim | hard | {
"lang": "python",
"repo": "GrigoryBartosh/hse08_unimodel",
"path": "/experiments/build_vocab.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GrigoryBartosh/hse08_unimodel path: /experiments/build_vocab.py
import pickle
import torch
import torch.nn as nn
import numpy as np
from bpemb import BPEmb
from common.config import PATH
VOCAB_PATH = PATH['DATASETS']['COCO']['VOCAB']
EMBEDS_PATH = PATH['MODELS']['WORD_EMBEDS']
def save_voc... | code_fim | hard | {
"lang": "python",
"repo": "GrigoryBartosh/hse08_unimodel",
"path": "/experiments/build_vocab.py",
"mode": "psm",
"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.