text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>if __name__ == "__main__":
from sync import Config
conf = Config("./sync.ini")
conn = conf.parse_db_conn()
schemas = conf.parse_schemas()
#dump_mysql(conn, schemas)
get_tables(conn, schemas)<|fim_prefix|># repo: webclinic017/mysql_sync path: /dump.py
#!/usr/bin/env python
# codin... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/mysql_sync",
"path": "/dump.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/mysql_sync path: /dump.py
#!/usr/bin/env python
# coding: utf-8
import os
import re
import time
import json
defaults = "--single-transaction --skip-lock-tables --compact --skip-opt --quick --no-create-info" \
"--master-data --skip-extended-insert"
# ignore_tables = ["soccerda... | code_fim | medium | {
"lang": "python",
"repo": "webclinic017/mysql_sync",
"path": "/dump.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ErudyTang/alphaML path: /wsabie/src/wsabie_model_train.py
#-*- coding:utf-8 -*-
import sys
import os
import random
import time
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import datasets
from tensorflow.keras import layers
os.environ["TF_CPP_MIN_... | code_fim | hard | {
"lang": "python",
"repo": "ErudyTang/alphaML",
"path": "/wsabie/src/wsabie_model_train.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 加载训练数据
train_dl = DataLoader(train_filename)
train_dl.load_data()
train_dl.preprocess_data()
batch_size *= train_dl.one_batch
if verbose:
print >> sys.stderr, "train_data: left_bow_size[%d], right_bow_size[%d], left_vec_size[%d], right_vec_size[%d]" % \
(train_dl.left_bow_size, train_dl.r... | code_fim | hard | {
"lang": "python",
"repo": "ErudyTang/alphaML",
"path": "/wsabie/src/wsabie_model_train.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 创建模型
model = WSABIE(train_dl.left_bow_size, train_dl.right_bow_size, train_dl.left_vec_size, embedding_size)
model.build(input_shape=(None, train_dl.left_vec_size + train_dl.right_vec_size))
if verbose:
model.summary()
optimizer = tf.keras.optimizers.Adam(alpha)
train_loss_results = []
train_au... | code_fim | hard | {
"lang": "python",
"repo": "ErudyTang/alphaML",
"path": "/wsabie/src/wsabie_model_train.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> alt_texts.append(attributes['alt'])
except Exception as e:
pass
return images, alt_texts<|fim_prefix|># repo: OliverEdholm/icon-alt-text-image-retrieval path: /src/datasets.py
import json
from pathlib import Path
import cv2
import pandas as pd
from tqdm i... | code_fim | hard | {
"lang": "python",
"repo": "OliverEdholm/icon-alt-text-image-retrieval",
"path": "/src/datasets.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if image is not None:
images.append(image)
alt_texts.append(attributes['alt'])
except Exception as e:
pass
return images, alt_texts<|fim_prefix|># repo: OliverEdholm/icon-alt-text-image-retrieval path: /src/datasets.py
... | code_fim | hard | {
"lang": "python",
"repo": "OliverEdholm/icon-alt-text-image-retrieval",
"path": "/src/datasets.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OliverEdholm/icon-alt-text-image-retrieval path: /src/datasets.py
import json
from pathlib import Path
import cv2
import pandas as pd
from tqdm import tqdm
<|fim_suffix|> images = []
alt_texts = []
for json_path in tqdm(list(dataset_path.glob('*.json'))):
try:
wi... | code_fim | medium | {
"lang": "python",
"repo": "OliverEdholm/icon-alt-text-image-retrieval",
"path": "/src/datasets.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PlainJi/autoencoder-cifar-10 path: /Scripts/computation_graph/Graph1.py
'''
First graph model to be trained for this task.
This file defines the method required to spawn and return a tensorflow graph for the autoencoder model.
coded by: Animesh
'''
import tensorflow as tf
graph = ... | code_fim | hard | {
"lang": "python",
"repo": "PlainJi/autoencoder-cifar-10",
"path": "/Scripts/computation_graph/Graph1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # decoder layers:
# The input to this layer is 2 x 2 x 32
decoder_layer1 = tf.layers.conv2d_transpose(encoder_layer3, 32, [5, 5], strides=(4, 4), padding="SAME")
# Output from this layer: 8 x 8 x 32
# The input to this layer: 8 x 8 x 32
decoder_layer2 = tf.layers.conv2d_transpose(... | code_fim | hard | {
"lang": "python",
"repo": "PlainJi/autoencoder-cifar-10",
"path": "/Scripts/computation_graph/Graph1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeonjunmin/python_basic path: /ch6.py
#1.함수
print('#################### 1.함수 ###################')
def add(num1,num2):
return num1 + num2
print(add(1,2))
def add_mul(num1,num2): #다중 리턴값을 튜플형태로 반환
return num1 + num2 , num1*num2
print(add_mul(1,2))
<|fim_suffix|>#2.모둘
print('########... | code_fim | medium | {
"lang": "python",
"repo": "jeonjunmin/python_basic",
"path": "/ch6.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>my_add , my_mul = add_mul(1,2) #튜플 언패킹
print(my_add)
print(my_mul)
#2.모둘
print('#################### 2.모둘 ###################')
# from 패키지명 import 모듈명 -> 이와 같은 형시으로 선언하고 함수를 활용한다.
import ch6_
ch6_.animal1()
ch6_.animal2()<|fim_prefix|># repo: jeonjunmin/python_basic path: /ch6.py
#1.함수
print('######... | code_fim | medium | {
"lang": "python",
"repo": "jeonjunmin/python_basic",
"path": "/ch6.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def w09_playblast_cmd(self, *args):
#Clamp resolution to view port
import maya.OpenMayaUI as omui
curView = omui.M3dView.active3dView()
portWidth = curView.portWidth()
portHeight = curView.portHeight()
resWidth = cmds.getAttr( 'defaultResolution.wid... | code_fim | hard | {
"lang": "python",
"repo": "kryfo/HQ",
"path": "/last_at_HQ/hq_toolbox/hq_maya/hq_maya/window/w09_playBlastWin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kryfo/HQ path: /last_at_HQ/hq_toolbox/hq_maya/hq_maya/window/w09_playBlastWin.py
# -*- coding: utf-8 -*-
import os
if os.path.exists( r'\\10.99.1.6\Digital\Library\hq_toolbox' )==False and os.path.exists(r'\\XMFTDYPROJECT\digital\film_project\Tool\hq_toolbox')==False :
raise IOError()
#######... | code_fim | hard | {
"lang": "python",
"repo": "kryfo/HQ",
"path": "/last_at_HQ/hq_toolbox/hq_maya/hq_maya/window/w09_playBlastWin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> filenameV = 'playblast/%s/%s/%s'%(sceneName,camShortName, camShortName);
cmds.playblast( format='iff', filename=filenameV, sequenceTime=False, viewer=False, clearCache=True, showOrnaments=True, fp=4, percent=100, compression="jpg", quality=100, wh=[resWidth, resHeight] )
... | code_fim | hard | {
"lang": "python",
"repo": "kryfo/HQ",
"path": "/last_at_HQ/hq_toolbox/hq_maya/hq_maya/window/w09_playBlastWin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cooado/CombineMaliExportedObjFiles path: /swapPngChannels.py
'''
Swap the channel of green and alpha for images exported from mali graphics debugger with texture format as rgba4444
Usage:
python swapPngChannels.py
'''
import os
from PIL import Image
if __name__ == "__main__":
curDir = o... | code_fim | hard | {
"lang": "python",
"repo": "cooado/CombineMaliExportedObjFiles",
"path": "/swapPngChannels.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> im_rgb = im.convert('RGBA')
for x in range(0, width):
for y in range(0,height):
r, g, b, a = im_rgb.getpixel((x, y))
im_rgb.putpixel((x, y), (b, a, r, g))
#outfile, ext = os.path.splitext(infile)
prefixName = pngFile[:-7]
... | code_fim | medium | {
"lang": "python",
"repo": "cooado/CombineMaliExportedObjFiles",
"path": "/swapPngChannels.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in range(0, width):
for y in range(0,height):
r, g, b, a = im_rgb.getpixel((x, y))
im_rgb.putpixel((x, y), (b, a, r, g))
#outfile, ext = os.path.splitext(infile)
prefixName = pngFile[:-7]
outfile = os.path.join(curDir, pref... | code_fim | medium | {
"lang": "python",
"repo": "cooado/CombineMaliExportedObjFiles",
"path": "/swapPngChannels.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KaneX/projectEulerSolutions path: /src/q026.py
import sys
import math
maxSize = 10001
# generate a list of prime numbers
aIsPrime = [True] * maxSize
for i in range(2, maxSize):
if not aIsPrime[i]:
continue
for j in range(2*i, maxSize, i):
aIsPrime[j] = False
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "KaneX/projectEulerSolutions",
"path": "/src/q026.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lengthList = [0] * maxSize
T = int(input().strip())
for a0 in range(T):
N = int(input().strip())
maxLength = 0
maxPrime = 2
for prime in primeList:
if prime >= N:
break
if lengthList[prime] == 0:
length = 1
divisor = 10
while ... | code_fim | medium | {
"lang": "python",
"repo": "KaneX/projectEulerSolutions",
"path": "/src/q026.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>dados = np.loadtxt('outB0TMC2.avr.dat')
nmove = dados[:, 0]
U_N = dados[:, 1]
E_N = dados[:, 6]
dens = dados[:, 4]
ax1.plot(nmove, U_N, 'blue', alpha=0.55, linewidth=2.5)
ax1.set_xlabel('NMOVE')
ax1.set_ylabel('U/N')
ax2.plot(nmove, E_N, 'blue', alpha=0.55, linewidth=2.5)
ax2.set_xlabel('NMOVE')
ax2.set... | code_fim | hard | {
"lang": "python",
"repo": "brittosandro/curvas",
"path": "/plot_estatisticas_DICE/graf1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brittosandro/curvas path: /plot_estatisticas_DICE/graf1.py
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style="ticks")
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(7.5, 8.8))
fig.subplots_adjust(
left=0.13,
ri... | code_fim | hard | {
"lang": "python",
"repo": "brittosandro/curvas",
"path": "/plot_estatisticas_DICE/graf1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a-yoshio/remainder path: /app/form/__init__.py
from datetime import datetime as dt
def None_check(key, value):
if value is None or value == '':
print(f'{key} is empty.')
value = None
return value
def str_check(key, value):
if type(value) != str:
raise TypeErr... | code_fim | medium | {
"lang": "python",
"repo": "a-yoshio/remainder",
"path": "/app/form/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
value = dt.strptime(value, '%Y%m%d%H%M')
return value
except ValueError as e:
raise ValueError(f'{key} must be datetime format like %Y%m%d%H%M')<|fim_prefix|># repo: a-yoshio/remainder path: /app/form/__init__.py
from datetime import datetime as dt
def None_check(key... | code_fim | medium | {
"lang": "python",
"repo": "a-yoshio/remainder",
"path": "/app/form/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kohout/djangocms-getaweb-address path: /djangocms_address/templatetags/cmsaddress.py
# -*- coding: utf-8 -*-
from django import template
from django.utils.safestring import mark_safe
from easy_thumbnails.files import get_thumbnailer
from djangocms_address import settings
<|fim_suffix|> thumb_... | code_fim | medium | {
"lang": "python",
"repo": "kohout/djangocms-getaweb-address",
"path": "/djangocms_address/templatetags/cmsaddress.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if settings.GEOCODING_KEY:
return settings.GEOCODING_KEY_URL
return ''
@register.simple_tag()
def filter_via_ajax():
return 'ajax_filter' if settings.FILTER_USING_AJAX else ''<|fim_prefix|># repo: kohout/djangocms-getaweb-address path: /djangocms_address/templatetags/cmsaddress.py
# ... | code_fim | hard | {
"lang": "python",
"repo": "kohout/djangocms-getaweb-address",
"path": "/djangocms_address/templatetags/cmsaddress.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> thumb_url = get_thumbnailer(image).get_thumbnail(settings.IMG_OPTIONS_LOGO).url
return mark_safe('<img src="%s" alt="%s" />' % (thumb_url, item.name))
@register.simple_tag()
def gmaps_api_key():
if settings.GEOCODING_KEY:
return settings.GEOCODING_KEY_URL
return ''
@register.simp... | code_fim | medium | {
"lang": "python",
"repo": "kohout/djangocms-getaweb-address",
"path": "/djangocms_address/templatetags/cmsaddress.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n % k == 0 and k != 1:
print("yes")
self.rotate(nums, 1)
self.rotate(nums, k-1)
else:
for _ in range(len(nums)):
temp = nums[store_index]
nums[store_index] = store_value
store_value = temp
... | code_fim | medium | {
"lang": "python",
"repo": "nixonpj/leetcode",
"path": "/Rotate_Array.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nixonpj/leetcode path: /Rotate_Array.py
"""
Given an array, rotate the array to the right by k steps, where k is non-negative.
Follow up:
Try to come up as many solutions as you can, there are at least 3 different
ways to solve this problem.
Could you do it in-place with O(1) extra ... | code_fim | medium | {
"lang": "python",
"repo": "nixonpj/leetcode",
"path": "/Rotate_Array.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def rotate(self, nums: List[int], k: int) -> None:
n = len(nums)
store_value, store_index = nums[0], (k % n)
if k == 0:
return
if n % k == 0 and k != 1:
print("yes")
self.rotate(nums, 1)
self.rotate(nums, k-1)
els... | code_fim | medium | {
"lang": "python",
"repo": "nixonpj/leetcode",
"path": "/Rotate_Array.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ClearTasksForm(FlaskForm):
submit = SubmitField('Clear To-Do List')<|fim_prefix|># repo: wilsonvetdev/IS211_Assignment11 path: /forms.py
from flask_wtf import FlaskForm
from wtforms import StringField, SelectField, SubmitField
from wtforms.fields.html5 import EmailField
from wtforms.validators ... | code_fim | hard | {
"lang": "python",
"repo": "wilsonvetdev/IS211_Assignment11",
"path": "/forms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wilsonvetdev/IS211_Assignment11 path: /forms.py
from flask_wtf import FlaskForm
from wtforms import StringField, SelectField, SubmitField
from wtforms.fields.html5 import EmailField
from wtforms.validators import DataRequired, Email
<|fim_suffix|>class ClearTasksForm(FlaskForm):
submit = Sub... | code_fim | hard | {
"lang": "python",
"repo": "wilsonvetdev/IS211_Assignment11",
"path": "/forms.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MojitoBar/Python_Study path: /python_study/lab6_11.py
"""
챕터: day6
주제: 정규식
문제: 정규식 기호 연습
작성자: 주동석
작성일: 2018. 11. 22
"""
import re
"""
1. apple에 a가 들어있는지 확인
2. apple에 b가 들어있는지 확인
3. 정규식을 이용하여, 사용자가 입력한 영어 문장에서 a, e, i, o, u가 포함되어 있는지 찾아서 출력하시오. 만족하는 첫번째만 출력한다.
<입력> This is a te... | code_fim | hard | {
"lang": "python",
"repo": "MojitoBar/Python_Study",
"path": "/python_study/lab6_11.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s4 = input("문장을 입력해 주세요: ")
l = re.findall("\d+", s4)
for i in l:
print(i)
"""
10. 입력된 문장에서 <이후에 나오는 단어들을 출력하라.>
A. 입력 예: <2015> <김일수> <성공회대학교>
"""
s5 = input("문장을 입력해 주세요:")
l = re.findall("^<$\"", s5)
for i in l:
print(i)<|fim_prefix|># repo: MojitoBar/Python_Study path: /python_study/lab6_11.p... | code_fim | hard | {
"lang": "python",
"repo": "MojitoBar/Python_Study",
"path": "/python_study/lab6_11.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def validate_query(query):
return get_link_from_query(query) or re.search("aliexpress", query) or is_digits(query)
def is_digits(query):
return re.search("^\d+$", query)<|fim_prefix|># repo: blackbass1988/aliprice_bot path: /lib/common.py
import re
def get_link_from_query(query):
<|fim_middl... | code_fim | medium | {
"lang": "python",
"repo": "blackbass1988/aliprice_bot",
"path": "/lib/common.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blackbass1988/aliprice_bot path: /lib/common.py
import re
def get_link_from_query(query):
<|fim_suffix|>def is_digits(query):
return re.search("^\d+$", query)<|fim_middle|> m = re.findall("(https?://\S+)", query)
if len(m) > 0:
return m[0]
return None
def validate_query... | code_fim | hard | {
"lang": "python",
"repo": "blackbass1988/aliprice_bot",
"path": "/lib/common.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blackbass1988/aliprice_bot path: /lib/common.py
import re
def get_link_from_query(query):
m = re.findall("(https?://\S+)", query)
if len(m) > 0:
return m[0]
return None
<|fim_suffix|> return get_link_from_query(query) or re.search("aliexpress", query) or is_digits(query)... | code_fim | easy | {
"lang": "python",
"repo": "blackbass1988/aliprice_bot",
"path": "/lib/common.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HongChutang/python-simple-spider path: /html_parser.py
# -*- coding: utf-8 -*-
'''
页面解析器
'''
__author__ = 'Evan Hung'
import urlparse
import re
from bs4 import BeautifulSoup
class HtmlParser(object):
def parse(self, page_url, html_cont):
if page_url is None or html_cont is None... | code_fim | hard | {
"lang": "python",
"repo": "HongChutang/python-simple-spider",
"path": "/html_parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 搜索摘要标签 规则为<div class ="lemma-summary"> summary content </div>
summary_node = soup.find('div', class_='lemma-summary')
if summary_node:
res_data['summary'] = summary_node.get_text()
else:
res_data['summary'] = ''
return res_data<|fim_prefix... | code_fim | hard | {
"lang": "python",
"repo": "HongChutang/python-simple-spider",
"path": "/html_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _get_new_data(self, page_url, soup):
res_data = {}
# url
res_data['url'] = page_url
# 搜索标题标签 规则为<dd class ="lemmaWgt-lemmaTitle-title"><h1> title text </h1>
title_node = soup.find('dd', class_='lemmaWgt-lemmaTitle-title').find('h1')
if title_node:
... | code_fim | hard | {
"lang": "python",
"repo": "HongChutang/python-simple-spider",
"path": "/html_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pradhyo/search_engine path: /web_crawler.py
# Build a web crawler
import string
index = {}
graph = {}
def get_next_target(page):
"""Return starting and ending positions of next url in 'page'"""
start_link = page.find('<a href=')
if start_link == -1:
return None,0
url_start = page.find('"'... | code_fim | hard | {
"lang": "python",
"repo": "Pradhyo/search_engine",
"path": "/web_crawler.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def rank_pages(graph):
damping_factor = 0.8
loops = 10
ranks = {}
npages = len(graph)
for page in graph:
ranks[page] = 1.0 / npages
for i in range(0):
newranks = {}
for page in graph:
newrank = (1 - d) / npages
newranks[page] = newrank
ranks = newranks
return ranks
def web_crawle... | code_fim | hard | {
"lang": "python",
"repo": "Pradhyo/search_engine",
"path": "/web_crawler.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenzh12/PPO-BiHyb path: /ged_ppo_single_model.py
import torch
from torch import nn
from pyg_graph_models import GCN, GraphAttentionPooling, ResNetBlock, TensorNetworkModule
from utils import construct_graph_batch, pad_tensor
import numpy as np
from torch_geometric.utils import to_dense_batc... | code_fim | hard | {
"lang": "python",
"repo": "chenzh12/PPO-BiHyb",
"path": "/ged_ppo_single_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ActorNet(torch.nn.Module):
def __init__(
self,
state_feature_size,
batch_norm,
):
super(ActorNet, self).__init__()
self.state_feature_size = state_feature_size
self.batch_norm = batch_norm
self.act1_resnet = ResNe... | code_fim | hard | {
"lang": "python",
"repo": "chenzh12/PPO-BiHyb",
"path": "/ged_ppo_single_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # select action
act_probs = nn.functional.softmax(act_scores + mask, dim=1)
if greedy_sel_num > 0:
argsort_prob = torch.argsort(act_probs, dim=-1, descending=True)
acts = argsort_prob[:, :greedy_sel_num]
return acts, act_probs[torch.arange(a... | code_fim | hard | {
"lang": "python",
"repo": "chenzh12/PPO-BiHyb",
"path": "/ged_ppo_single_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jlian2/Masked-Proxy-Loss-for-Text-Indepedent-Speaker-Verification path: /models/x_vector.py
#! /usr/bin/python
# -*- encoding: utf-8 -*-
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Parameter
from models.ResNetBlocks import *
class x_vector_model(nn.M... | code_fim | hard | {
"lang": "python",
"repo": "jlian2/Masked-Proxy-Loss-for-Text-Indepedent-Speaker-Verification",
"path": "/models/x_vector.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = self.dropout_tdnn1(self.bn_tdnn1(F.relu(self.tdnn1(x))))
#print(x.shape)
x = self.dropout_tdnn2(self.bn_tdnn2(F.relu(self.tdnn2(x))))
#print(x.shape)
x = self.dropout_tdnn3(self.bn_tdnn3(F.relu(self.tdnn3(x))))
#print(x.shape)
x = self.dropout_td... | code_fim | hard | {
"lang": "python",
"repo": "jlian2/Masked-Proxy-Loss-for-Text-Indepedent-Speaker-Verification",
"path": "/models/x_vector.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> counter = 1
while True:
user_input = (yield)
result = counter * user_input
print(result)
counter += 1<|fim_prefix|># repo: dreamminister/python_mfti path: /multiplier_coroutine.py
def coroutine(f):
def wrap(*args,**kwargs):
gen = f(*args,**kwargs)
... | code_fim | easy | {
"lang": "python",
"repo": "dreamminister/python_mfti",
"path": "/multiplier_coroutine.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dreamminister/python_mfti path: /multiplier_coroutine.py
def coroutine(f):
def wrap(*args,**kwargs):
gen = f(*args,**kwargs)
gen.send(None)
return gen
return wrap
<|fim_suffix|> counter = 1
while True:
user_input = (yield)
result = counter *... | code_fim | easy | {
"lang": "python",
"repo": "dreamminister/python_mfti",
"path": "/multiplier_coroutine.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> formatted_attr = {}
for x in attribute:
code = x['code']
value = x['value']
formatted_attr[code] = value
return json.dumps(formatted_attr)
def format_attribute_for_input(input_json):
attr_pairs = []
for x,y in input_json.items():
pair = {
... | code_fim | medium | {
"lang": "python",
"repo": "JANA-rsangani/FormatInputOutputJSON",
"path": "/HttpExample/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JANA-rsangani/FormatInputOutputJSON path: /HttpExample/__init__.py
import logging
import json
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
req_body = req.get_json()
# Read In... | code_fim | medium | {
"lang": "python",
"repo": "JANA-rsangani/FormatInputOutputJSON",
"path": "/HttpExample/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> matplotlib.pyplot.figure()
ax1 = matplotlib.pyplot.subplot(1,1,1)
ignore_fields=set(['date_hour', 'timestamp', 'cycle', 'unuseddata', 'unuseddata_1', 'unuseddata_2', 'unuseddata_3', 'unuseddata_4', 'unuseddata_5', 'unuseddata_6'])
for field in datas.dtype.names:
if field not in ignore_fields:
a... | code_fim | medium | {
"lang": "python",
"repo": "borntocodeRaj/python_AGV",
"path": "/v15/LogArcelor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: borntocodeRaj/python_AGV path: /v15/LogArcelor.py
#!/usr/bin/python
import matplotlib.pyplot
import matplotlib.mlab
import collections
def Import(filename):
datas=matplotlib.mlab.csv2rec(filename,delimiter='\t')
print "LogCan20:", filename, "OK n=", len(datas)
return datas
def PlotT(datas )... | code_fim | medium | {
"lang": "python",
"repo": "borntocodeRaj/python_AGV",
"path": "/v15/LogArcelor.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>matplotlib.pyplot.ion()
try:
infosVCU=Import("AgentCanArcelorInfoFromVcu.txt")
inputVCU=Import("AgentCanArcelorInputFromVcu.txt")
outputVCU=Import("AgentCanArcelorOutputToVcu.txt")
print 'OK'
except IOError:
print 'End.'<|fim_prefix|># repo: borntocodeRaj/python_AGV path: /v15/LogArcelor.py
#!/usr... | code_fim | hard | {
"lang": "python",
"repo": "borntocodeRaj/python_AGV",
"path": "/v15/LogArcelor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: surajmgr/kamasystems_web path: /job/models.py
from django.db import models
from datetime import datetime
# Create your models here.
class topProjects(models.Model):
icon = models.CharField(max_length=500, blank=True)
title = models.CharField(max_length=50)
description = models.CharF... | code_fim | hard | {
"lang": "python",
"repo": "surajmgr/kamasystems_web",
"path": "/job/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = models.CharField(max_length=50)
email = models.EmailField()
date = models.DateTimeField(default=datetime.now)
message = models.CharField(
max_length=2000,
help_text='Write your message here...'
)
def __str__(self):
return f'{self.name}'
class Me... | code_fim | medium | {
"lang": "python",
"repo": "surajmgr/kamasystems_web",
"path": "/job/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomorrowsletters/it-academy-python-spring path: /src/task_3.py
# 3 lines: For loop, built-in enumerate function, new st<|fim_suffix|>']
for i, name in enumerate(friends):
print("iteration {iteration} is {name}".format(iteration=i, name=name))<|fim_middle|>yle formatting
friends = ['john', 'pa... | code_fim | easy | {
"lang": "python",
"repo": "tomorrowsletters/it-academy-python-spring",
"path": "/src/task_3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>']
for i, name in enumerate(friends):
print("iteration {iteration} is {name}".format(iteration=i, name=name))<|fim_prefix|># repo: tomorrowsletters/it-academy-python-spring path: /src/task_3.py
# 3 lines: For loop, built-in enumerate function, new st<|fim_middle|>yle formatting
friends = ['john', 'pa... | code_fim | easy | {
"lang": "python",
"repo": "tomorrowsletters/it-academy-python-spring",
"path": "/src/task_3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WayneHajas/GeoduckUnsurveyedBeds path: /test.py
from scipy.stats import norm
from scipy.stats.mstats import mquantiles
from numpy.random import choice,seed
from numpy import array
seed(756)
Den=[ 0.08015092, 0.10789958, 0.12167541, 0.21219431, 0.07920235, 0.19467892, 0.5431346, 0.1377906... | code_fim | medium | {
"lang": "python",
"repo": "WayneHajas/GeoduckUnsurveyedBeds",
"path": "/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result=choice(array(Den),size=n,replace=True)
return(result)
p=[.005,.025,.05,.125,.5,.875,.95,975,.995]
p=[.125,.5,.875]
n=10000
B=BA.rvs(size=n)*MnWgt.rvs(size=n)* RandDen(n)
#print(B)
print(mquantiles(B,p))<|fim_prefix|># repo: WayneHajas/GeoduckUnsurveyedBeds path: /test.py
from scipy.stats... | code_fim | hard | {
"lang": "python",
"repo": "WayneHajas/GeoduckUnsurveyedBeds",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># передаем в функцию заполненный словарь и преобразуем его в именованные аргументы
output_user_info(**user_info)<|fim_prefix|># repo: alferovyuriy/geekbrains path: /Python(Basic)/home_work_3/task2.py
# словарь с информацией о пользователе
user_info = {
'name': str,
'surname': str,
'year': str,
'city'... | code_fim | hard | {
"lang": "python",
"repo": "alferovyuriy/geekbrains",
"path": "/Python(Basic)/home_work_3/task2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alferovyuriy/geekbrains path: /Python(Basic)/home_work_3/task2.py
# словарь с информацией о пользователе
user_info = {
'name': str,
'surname': str,
'year': str,
'city': str,
'email': str,
'phone_num': str,
}
def output_user_info(name, surname, year, city, email, phone_num):
""" функция п... | code_fim | medium | {
"lang": "python",
"repo": "alferovyuriy/geekbrains",
"path": "/Python(Basic)/home_work_3/task2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChloeJaneC/Sandbox path: /oddName.py
"""
Chloe Jane Coleman
"""
name = input("Please enter your name")
while name == "":
name =<|fim_suffix|>ter \nPlease enter your name")
print(name[::2])<|fim_middle|> input("Your name must have at least one charac | code_fim | easy | {
"lang": "python",
"repo": "ChloeJaneC/Sandbox",
"path": "/oddName.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ter \nPlease enter your name")
print(name[::2])<|fim_prefix|># repo: ChloeJaneC/Sandbox path: /oddName.py
"""
Chloe Jane Coleman
"""
name = input("Please enter your name")
while name == "":
name =<|fim_middle|> input("Your name must have at least one charac | code_fim | easy | {
"lang": "python",
"repo": "ChloeJaneC/Sandbox",
"path": "/oddName.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>end1 = datetime.datetime.now()
time_delta1 = end1 - start1
print('처리시간 : ', time_delta1)
# grid
# 최적의 매개변수 SVC(C=1, kernel='linear')
# 최종정답률 0.9666666666666667
# 0.9666666666666667
# 처리시간 : 0:00:00.088735
# random
# 최적의 매개변수 SVC(C=1, kernel='linear')
# 최종정답률 0.9666666666666667
# 0.9666666666666667
# 처리시간... | code_fim | hard | {
"lang": "python",
"repo": "Jeong-Kyu/A_study",
"path": "/ml/m13_randomSearch1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jeong-Kyu/A_study path: /ml/m13_randomSearch1.py
import numpy as np
from sklearn.datasets import load_iris
from sklearn.preprocessing import MinMaxScaler, StandardScaler
from sklearn.model_selection import train_test_split, KFold, cross_val_score,GridSearchCV, RandomizedSearchCV
from sklearn.metr... | code_fim | hard | {
"lang": "python",
"repo": "Jeong-Kyu/A_study",
"path": "/ml/m13_randomSearch1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>y_pred=model.predict(x_test)
print('최종정답률', accuracy_score(y_test,y_pred))
aaa = model.score(x_test, y_test)
print(aaa)
end1 = datetime.datetime.now()
time_delta1 = end1 - start1
print('처리시간 : ', time_delta1)
# grid
# 최적의 매개변수 SVC(C=1, kernel='linear')
# 최종정답률 0.9666666666666667
# 0.9666666666666667
# 처... | code_fim | hard | {
"lang": "python",
"repo": "Jeong-Kyu/A_study",
"path": "/ml/m13_randomSearch1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_future = self.__class__()
def _done_handler(base_future):
"""
Converts results of underlying future into results of new future
:param ThenableFuture base_future: Original Future instance, but now guaranteed to be resolved
due to can... | code_fim | hard | {
"lang": "python",
"repo": "mshtemler/splunk-git",
"path": "/apps/python_upgrade_readiness_app/bin/libs_py3/pura_libs_utils/futures_then/futures_then.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mshtemler/splunk-git path: /apps/python_upgrade_readiness_app/bin/libs_py3/pura_libs_utils/futures_then/futures_then.py
import sys
import weakref
from concurrent.futures import Future
class CircularFuturesChainException(Exception):
pass
class ThenableFuture(Future):
@property
de... | code_fim | hard | {
"lang": "python",
"repo": "mshtemler/splunk-git",
"path": "/apps/python_upgrade_readiness_app/bin/libs_py3/pura_libs_utils/futures_then/futures_then.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if base_future.cancelled():
new_future.cancel()
return
try:
result = base_future.result()
if on_fulfilled:
result = on_fulfilled(result)
# Per Promise/A+ spec, if return value is a... | code_fim | hard | {
"lang": "python",
"repo": "mshtemler/splunk-git",
"path": "/apps/python_upgrade_readiness_app/bin/libs_py3/pura_libs_utils/futures_then/futures_then.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vorjat/PythonBootCamp path: /zjazd_2/zadanie_11.py
zbior = set()
while True:
komenda = input("Podaj liczbę, ewentualnie [w]yjdz")
if komenda == "w":
break
zbior.add(int(komenda))
<|fim_suffix|>zbior3 = zbior & zbior2
print(zbior3)
print(len(zbior3))<|fim_middle|>zbior2 = set(... | code_fim | medium | {
"lang": "python",
"repo": "vorjat/PythonBootCamp",
"path": "/zjazd_2/zadanie_11.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for liczba in zbior:
if liczba % 2 == 0 and liczba < 101:
zbior2.add(liczba)
zbior3 = zbior & zbior2
print(zbior3)
print(len(zbior3))<|fim_prefix|># repo: vorjat/PythonBootCamp path: /zjazd_2/zadanie_11.py
zbior = set()
while True:
komenda = input("Podaj liczbę, ewentualnie [w]yjdz")
... | code_fim | easy | {
"lang": "python",
"repo": "vorjat/PythonBootCamp",
"path": "/zjazd_2/zadanie_11.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i_palavra in range(len(palavra) - 1):
if palavra[i_palavra].lower() in "aeiou" \
and palavra[i_palavra + 1].lower() in "aeiou":
return "sim"
return "nao"
palavra = raw_input()
print tem_vogais_adjacentes(palavra)
if __name__ == "__main__":
assert tem_vogais_adjacentes("orfeu") == "sim"
a... | code_fim | medium | {
"lang": "python",
"repo": "alessandroliafook/P1",
"path": "/unidade7/tem_vogais_adjacentes/tem_vogais_adjacentes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alessandroliafook/P1 path: /unidade7/tem_vogais_adjacentes/tem_vogais_adjacentes.py
# coding: utf-8
# Tem Vogais Adjacentes | UFCG - PROGRAMAÇÃO 1
# (C) | Alessandro Santos, 2015
<|fim_suffix|>palavra = raw_input()
print tem_vogais_adjacentes(palavra)
if __name__ == "__main__":
assert tem_voga... | code_fim | hard | {
"lang": "python",
"repo": "alessandroliafook/P1",
"path": "/unidade7/tem_vogais_adjacentes/tem_vogais_adjacentes.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pdlinh307/topccs path: /klass/appconfig.py
# -*- coding: utf-8 -*-
import configparser
from klass.singleton import Singleton
<|fim_suffix|> return self.__config[name]<|fim_middle|>class AppConfig(metaclass=Singleton):
__config = None
def __init__(self, file):
self.__conf... | code_fim | hard | {
"lang": "python",
"repo": "pdlinh307/topccs",
"path": "/klass/appconfig.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.__config = configparser.ConfigParser()
self.__config.read(file)
def section(self, name):
return self.__config[name]<|fim_prefix|># repo: pdlinh307/topccs path: /klass/appconfig.py
# -*- coding: utf-8 -*-
import configparser
from klass.singleton import Singleton
<|fim_mi... | code_fim | medium | {
"lang": "python",
"repo": "pdlinh307/topccs",
"path": "/klass/appconfig.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fikarchamiiiim/Video-captioning path: /models/ChildSum.py
import torch
import torch.nn as nn
import torch.nn.functional as F
class ChildSum(nn.Module):
<|fim_suffix|> def forward(self, h1, h2, c1, c2):
i = F.sigmoid(self.i1(h1)+self.i2(h2))
g = F.tanh(self.g1(h1)+self.g2(h2))... | code_fim | hard | {
"lang": "python",
"repo": "fikarchamiiiim/Video-captioning",
"path": "/models/ChildSum.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(self, h1, h2, c1, c2):
i = F.sigmoid(self.i1(h1)+self.i2(h2))
g = F.tanh(self.g1(h1)+self.g2(h2))
f_1 = F.sigmoid(self.f1(h1))
f_2 = F.sigmoid(self.f2(h2))
o = F.sigmoid(self.o1(h1)+self.o2(h2))
c = i * g + f_1 * c1 + f_2 * c2
h = o *... | code_fim | hard | {
"lang": "python",
"repo": "fikarchamiiiim/Video-captioning",
"path": "/models/ChildSum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smart-sensor-devices-ab/bleuio_examples path: /Python/scan_and_store_example/scan_and_store.py
from datetime import datetime
from bleuio_lib.bleuio_funcs import BleuIo
# from serial import SerialException
from time import sleep
my_dongle = BleuIo()
my_dongle.start_daemon()
print(
"Connect... | code_fim | hard | {
"lang": "python",
"repo": "smart-sensor-devices-ab/bleuio_examples",
"path": "/Python/scan_and_store_example/scan_and_store.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Stop the scan
my_dongle.stop_scan()
# Fetch the result
log = my_dongle.rx_scanning_results
# Saves the log to scan_log.txt
with open("scan_log.txt", "w") as scan_log:
for line in log:
scan_log.write(line)<|fim_prefix|># repo: smart-sensor-devices-ab/bleuio_e... | code_fim | hard | {
"lang": "python",
"repo": "smart-sensor-devices-ab/bleuio_examples",
"path": "/Python/scan_and_store_example/scan_and_store.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.triggered.door_closed()
self.assertEqual(self.triggered.get_door_state(), AlarmState.DOOR_CLOSED)
self.assertIsInstance(self.alarm.get_alarm_state(), Triggered)
self.assertFalse(self.alarm.get_alarm_state().is_door_open())
def test_alarm_deactivated_door_opened(s... | code_fim | hard | {
"lang": "python",
"repo": "BerrevoetsRobbe/RaspberryPiClass",
"path": "/Code/Alarm/AlarmState/Test/test_triggered.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BerrevoetsRobbe/RaspberryPiClass path: /Code/Alarm/AlarmState/Test/test_triggered.py
import mock
import time
from unittest import TestCase
from Alarm.Alarm import Alarm
from Alarm.AlarmState.AlarmState import AlarmState
from Alarm.AlarmState.Triggered import Triggered
from Alarm.AlarmState.Idle ... | code_fim | hard | {
"lang": "python",
"repo": "BerrevoetsRobbe/RaspberryPiClass",
"path": "/Code/Alarm/AlarmState/Test/test_triggered.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TatheerHussain/easySearch path: /data_seacher.py
from pymagnitude import *
import fetch
from fetch import db, Article
from tfidf import DFTable
import os
from annoy import AnnoyIndex
import logging
import nltk
from nltk import sent_tokenize
from nltk.tokenize import word_tokenize
import re
from n... | code_fim | hard | {
"lang": "python",
"repo": "TatheerHussain/easySearch",
"path": "/data_seacher.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> question_vec = self._get_sentence_vec(text)
ids, ds = self.annoy.get_nns_by_vector(question_vec, 50, include_distances=True)
ids = numpy.array(ids)
ds = numpy.array(ds)
for i in range(int(limit/step)+1):
choices = ids[ds < (i * step)]
if len(... | code_fim | hard | {
"lang": "python",
"repo": "TatheerHussain/easySearch",
"path": "/data_seacher.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def find_all_ORFs_both_strands(dna):
""" Finds all non-nested open reading frames in the given DNA sequence on both
strands.
dna: a DNA sequence
returns: a list of non-nested ORFs
>>> find_all_ORFs_both_strands("ATGCGAATGTAGCATCAAA")
['ATGCGAATG', 'ATGCTACATTCGCAT']
... | code_fim | hard | {
"lang": "python",
"repo": "srbarden/GeneFinder",
"path": "/gene_finder.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: srbarden/GeneFinder path: /gene_finder.py
# -*- coding: utf-8 -*-
"""
YOUR HEADER COMMENT HERE
@author: Sarah Barden
"""
import random
import math
from load import load_seq
random.seed(5845)
from amino_acids import aa, codons, aa_table # you may find these useful
def shuffle_string(s):
... | code_fim | hard | {
"lang": "python",
"repo": "srbarden/GeneFinder",
"path": "/gene_finder.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 1kovalevskiy/chat path: /venv/Lib/site-packages/internet/search/Bing.py
from .SearchEngine import SearchEngine, Navigator
from bs4 import BeautifulSoup
class Bing(SearchEngine):
def __init__(self, navigator=None):
"""
:type navigator: Navigator
"""
super().__init__(base_url='https://bi... | code_fim | medium | {
"lang": "python",
"repo": "1kovalevskiy/chat",
"path": "/venv/Lib/site-packages/internet/search/Bing.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().reset()
def get_search_url(self, query):
return f'{self.url}/search?q={query}'
def parse_search_results(self, html):
"""
:type html: BeautifulSoup
:rtype: list[dict[str,str]]
"""
b_content = html.findAll(attrs={'id': 'b_content'})[0]
b_algo = b_content.findAll(attrs={'class': ... | code_fim | medium | {
"lang": "python",
"repo": "1kovalevskiy/chat",
"path": "/venv/Lib/site-packages/internet/search/Bing.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#convert month_year column from period type to datetime to use in line chart
df_fig0['Period'] =df_fig0.Period.values.astype('datetime64[M]')
# In[ ]:
#add title and information to the streamlit dashboard page
st.set_page_config(layout="wide")
st.markdown( "<div style='background-color:#EBF5FB; font-... | code_fim | hard | {
"lang": "python",
"repo": "abeergh/HealthAnalytics_project",
"path": "/Health_analytics_project.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abeergh/HealthAnalytics_project path: /Health_analytics_project.py
#!/usr/bin/env python
# coding: utf-8
# # Setup and import libraries
# In[2]:
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
from plotly.subplots import make_subplots
import plotly.g... | code_fim | hard | {
"lang": "python",
"repo": "abeergh/HealthAnalytics_project",
"path": "/Health_analytics_project.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vikas-t/practice-problems path: /functional-problems/rightViewOfBinaryTree.py
#!/usr/bin/python3
# https://practice.geeksforgeeks.org/problems/right-view-of-binary-tree/1
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
<|fim... | code_fim | hard | {
"lang": "python",
"repo": "vikas-t/practice-problems",
"path": "/functional-problems/rightViewOfBinaryTree.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> getSum(root.left, level+1, h)
getSum(root.right, level+1, h)
def getSum2(root, level=0, maxLevel=None, sum=None):
"""
This approach is better than the previous one as it does not use extra
space. We keep track of two variables as references, maxlevel and sum.
maxLevel refers to t... | code_fim | hard | {
"lang": "python",
"repo": "vikas-t/practice-problems",
"path": "/functional-problems/rightViewOfBinaryTree.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e")
else:
print("No, the String is not a palindrome")<|fim_prefix|># repo: AnshumanSharma05/Python path: /Palidnrome.py
#Palidnrome
word=input("Enter the word")
word=word.replace(" ","")
word=word.casefold()
new_word=word[::-1]
if(wo<|fim_middle|>rd==new_word):
print("Yes, the String is a palindr... | code_fim | easy | {
"lang": "python",
"repo": "AnshumanSharma05/Python",
"path": "/Palidnrome.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnshumanSharma05/Python path: /Palidnrome.py
#Palidnrome
word=input("Enter the word")
word=word.replace(" ","")
word=word.casefold()
new_word=word[::-1]
if(wo<|fim_suffix|>e")
else:
print("No, the String is not a palindrome")<|fim_middle|>rd==new_word):
print("Yes, the String is a palindr... | code_fim | easy | {
"lang": "python",
"repo": "AnshumanSharma05/Python",
"path": "/Palidnrome.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bierschokolade/spotify_lyric path: /crawlers/GeniusCrawler.py
from bs4 import BeautifulSoup
import requests
from crawlers.Crawler import Crawler
class GeniusCrawler(Crawler):
def __init__(self):
super().__init__('Genius Lyric')
def search_for_lyrics(self, artist, song):
<|fim_s... | code_fim | hard | {
"lang": "python",
"repo": "Bierschokolade/spotify_lyric",
"path": "/crawlers/GeniusCrawler.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> html_code = BeautifulSoup(request.text, features="html.parser")
lyric = html_code.find("div", {"class": "lyrics"}).get_text()
return self.format_lyrics(lyric)
except Exception as e:
self.raise_not_found()
def format_lyrics(self, lyric):
... | code_fim | hard | {
"lang": "python",
"repo": "Bierschokolade/spotify_lyric",
"path": "/crawlers/GeniusCrawler.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: decolector/textilera path: /misc/sms_read.py
#/usr/bin/python
import time
from sms_reader import SmsReader
<|fim_suffix|>if __name__ == "__main__":
while True:
reader.update()
if len(reader.new_sms) > 0:
messages = reader.new_sms
print messages
... | code_fim | easy | {
"lang": "python",
"repo": "decolector/textilera",
"path": "/misc/sms_read.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
while True:
reader.update()
if len(reader.new_sms) > 0:
messages = reader.new_sms
print messages
reader.new_sms = []
time.sleep(1)<|fim_prefix|># repo: decolector/textilera path: /misc/sms_read.py
#/usr/bin/python... | code_fim | easy | {
"lang": "python",
"repo": "decolector/textilera",
"path": "/misc/sms_read.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># print the phrase the right number of times
for i in range( 0 , nbr_of_times):
print(phrase)<|fim_prefix|># repo: jaden-stanford/OldPythonProjects path: /again_and_again.py
''' Purpose: print a requested phrase a requested number of times
'''
# get phrase to be repeated
reply = input( "Enter phras... | code_fim | easy | {
"lang": "python",
"repo": "jaden-stanford/OldPythonProjects",
"path": "/again_and_again.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaden-stanford/OldPythonProjects path: /again_and_again.py
''' Purpose: print a requested phrase a requested number of times
'''
# get phrase to be repeated
reply = input( "Enter phrase to be printed: " )
<|fim_suffix|>
nbr_of_times = int( reply )
# print the phrase the right number of times
... | code_fim | medium | {
"lang": "python",
"repo": "jaden-stanford/OldPythonProjects",
"path": "/again_and_again.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.