text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self.last_clmn = data.shape[1]
if print_log: print('self.last_clmn= ', self.last_clmn)
if print_log: print('last 5 columns: ', data_lbl.columns[self.last_clmn - 5: self.last_clmn])
# ---
del data
del lbl
if use_data_for_ml_dump:
# ---
... | code_fim | hard | {
"lang": "python",
"repo": "SergejGorev/FML_lib",
"path": "/ensemble.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SergejGorev/FML_lib path: /ensemble.py
_arr_v1.0.pickle" # r"d:\20-ML_projects\01-Algorithmic_trading\02_1-EURUSD\ens_clf_arr_v1.0.pickle"
self.ens_pred_df_pickle_path = self.folder_name + os.sep + self.ens_pred_df_pickle_prefix+ self.pickle_postfix # r"d:\20-ML_projects\01-Algorithmic_... | code_fim | hard | {
"lang": "python",
"repo": "SergejGorev/FML_lib",
"path": "/ensemble.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.path.remove(self.location)
@staticmethod
def from_hash(info):
instance = Can()
brand = getattr(__import__(info["brand"], globals(), locals(), [info["brand"]]), info["brand"])
instance.brand = info["brand"]
instance.product = brand(**info["product"])
return instance
@staticmethod
de... | code_fim | hard | {
"lang": "python",
"repo": "steffansluis/spam",
"path": "/build/lib.linux-x86_64-2.7/spam/can.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: steffansluis/spam path: /build/lib.linux-x86_64-2.7/spam/can.py
import os.path
import json
from pprint import pprint
import subprocess
class Can(object):
def __init__(self, location=None):
self.location = location
if location:
self.name = os.path.basename(location)
def install(self):
... | code_fim | medium | {
"lang": "python",
"repo": "steffansluis/spam",
"path": "/build/lib.linux-x86_64-2.7/spam/can.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@execution_time
def luhn(number):
digits = [int(x) for x in ''.join(number.split())]
even = [x * 2 if x * 2 <= 9 else x * 2 - 9 for x in digits[-2::-2]]
odd = [x for x in digits[-1::-2]]
print(sum(even+odd)) #Сумма должна быть кратна 10
luhn(input("Введите номер карты:\n"))<|fim_pr... | code_fim | hard | {
"lang": "python",
"repo": "klepik1990/some-practice",
"path": "/Luhn_algorithm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: klepik1990/some-practice path: /Luhn_algorithm.py
import time
def execution_time(func):
def wrapped_f(*args):
<|fim_suffix|> digits = [int(x) for x in ''.join(number.split())]
even = [x * 2 if x * 2 <= 9 else x * 2 - 9 for x in digits[-2::-2]]
odd = [x for x in digits[-1::-2]]
... | code_fim | hard | {
"lang": "python",
"repo": "klepik1990/some-practice",
"path": "/Luhn_algorithm.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> digits = [int(x) for x in ''.join(number.split())]
even = [x * 2 if x * 2 <= 9 else x * 2 - 9 for x in digits[-2::-2]]
odd = [x for x in digits[-1::-2]]
print(sum(even+odd)) #Сумма должна быть кратна 10
luhn(input("Введите номер карты:\n"))<|fim_prefix|># repo: klepik1990/some-prac... | code_fim | hard | {
"lang": "python",
"repo": "klepik1990/some-practice",
"path": "/Luhn_algorithm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timapage/korzinka.uz path: /products/migrations/0012_auto_20210315_1604.py
# Generated by Django 3.1.7 on 2021-03-15 11:04
from django.db import migrations
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='orders',
... | code_fim | hard | {
"lang": "python",
"repo": "timapage/korzinka.uz",
"path": "/products/migrations/0012_auto_20210315_1604.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='orders',
name='customer',
),
migrations.RemoveField(
model_name='orders',
name='products',
),
migrations.RemoveField(
model_name='orders',
... | code_fim | hard | {
"lang": "python",
"repo": "timapage/korzinka.uz",
"path": "/products/migrations/0012_auto_20210315_1604.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# noinspection PyPep8Naming
def Cache(
cacheStorage=TimeCacheStorage(time_seconds=1, maxCount=1000),
checkPutToCache=lambda key, res, args, kwargs: True,
calcKey = __defaultKeyCalculator,
log = False
):
"""
:param cacheStorage: this parameter need to be impleme... | code_fim | hard | {
"lang": "python",
"repo": "shaddyx/simpleDecorators",
"path": "/simpledecorators/Cache.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shaddyx/simpleDecorators path: /simpledecorators/Cache.py
#import time
from functools import wraps
from threading import RLock
import expiringdict
import logging
import os
import json
import time
from abc import ABCMeta, abstractmethod, abstractproperty
logger = logging.getLogger('Cache')
def _... | code_fim | hard | {
"lang": "python",
"repo": "shaddyx/simpleDecorators",
"path": "/simpledecorators/Cache.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add(self, key, value):
lock.acquire()
try:
f=open(self.___filePath(key), "w")
f.write(self.__serialize(value))
f.close()
finally:
lock.release()
def get(self, key):
lock.acq... | code_fim | hard | {
"lang": "python",
"repo": "shaddyx/simpleDecorators",
"path": "/simpledecorators/Cache.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def equals(self, v1, v2, message):
if not v1 == v2:
self._fail("%s (%s != %s)" % (message, str(v1), str(v2)))
def null(self, value, message):
if not value is None:
self._fail("%s (%s was not None)" % (message, str(value)))
def not_null(self, value, message):
if ... | code_fim | hard | {
"lang": "python",
"repo": "shadowmint/python-nark",
"path": "/src/nark/_assert.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def not_null(self, value, message):
if value is None:
self._fail("%s (value was None)" % (message, str(value)))
def contains(self, items, item, message):
if item not in items:
self._fail("%s (%s was not in the list %r)" % (message, str(item), items))
def trace(self, messa... | code_fim | hard | {
"lang": "python",
"repo": "shadowmint/python-nark",
"path": "/src/nark/_assert.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shadowmint/python-nark path: /src/nark/_assert.py
# Copyright 2012 Douglas Linder
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/L... | code_fim | hard | {
"lang": "python",
"repo": "shadowmint/python-nark",
"path": "/src/nark/_assert.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pietrek14/python-powtorzenie path: /pdf10/1.py
import turtle
import keyboard
def new_turtle(x,y):
newTurtle = turtle.Turtle()
newTurtle.speed("fastest")
newTurtle.penup()
newTurtle.goto(x,y)
newTurtle.pendown()
return newTurtle
<|fim_suffix|> t.left(45)
t.forward... | code_fim | medium | {
"lang": "python",
"repo": "Pietrek14/python-powtorzenie",
"path": "/pdf10/1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def frac(a, r=7, depth_limit=3,depth=0):
if depth == depth_limit:
t.right(90)
t.circle(r)
t.left(90)
return
t.left(45)
t.forward(a)
frac(a/2,r,depth_limit,depth+1)
t.backward(a)
t.right(45)
t.forward(a)
frac(a/2,r,depth_limit,depth+1)
... | code_fim | medium | {
"lang": "python",
"repo": "Pietrek14/python-powtorzenie",
"path": "/pdf10/1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if depth == depth_limit:
t.right(90)
t.circle(r)
t.left(90)
return
t.left(45)
t.forward(a)
frac(a/2,r,depth_limit,depth+1)
t.backward(a)
t.right(45)
t.forward(a)
frac(a/2,r,depth_limit,depth+1)
t.backward(a)
t.right(45)
t.for... | code_fim | medium | {
"lang": "python",
"repo": "Pietrek14/python-powtorzenie",
"path": "/pdf10/1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jane-Zhai/LeetCode path: /easy_tree_563_findTilt.py
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Tree:
def __init__(self):
<|fim_suffix|> def sumTree(self,node):
if not node:
return 0,... | code_fim | hard | {
"lang": "python",
"repo": "Jane-Zhai/LeetCode",
"path": "/easy_tree_563_findTilt.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.tilt = 0
self.leftsum = 0
self.rightsum = 0
def findTilt(self, root):
"""
:type root: TreeNode
:rtype: int
"""
_,ans = self.sumTree(root)
return ans
def sumTree(self,node):
if not node:
... | code_fim | hard | {
"lang": "python",
"repo": "Jane-Zhai/LeetCode",
"path": "/easy_tree_563_findTilt.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Response(
result,
headers=headers
)
@app.route('/sea/<user_input>')
def sea(user_input):
def preprocess_word(word):
# Remove punctuation
word = word.strip('\'"?!,.():;')
# Convert more than 2 letter repetitions to 2 letter
# funnnnny ... | code_fim | hard | {
"lang": "python",
"repo": "nourozkhan/final_project",
"path": "/strem_n_clean.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nourozkhan/final_project path: /strem_n_clean.py
from flask import Flask, Response
import os
import nltk
import random
import pickle
from twython import TwythonStreamer
import re
import json
from nltk.tokenize import word_tokenize
app = Flask(__name__)
headers = {
'Cache-Control': '... | code_fim | hard | {
"lang": "python",
"repo": "nourozkhan/final_project",
"path": "/strem_n_clean.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open('computing_gc_content.txt') as fp:
highest_gc, highest_name = float('-inf'), ''
for name, gc in read_fasta(fp):
if gc > highest_gc:
highest_gc, highest_name = gc, name
print(highest_name + '\n' + str(highest_gc))<|fim_prefix|># repo: kaisteussy/rosalind path: /co... | code_fim | hard | {
"lang": "python",
"repo": "kaisteussy/rosalind",
"path": "/computing_gc_content.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kaisteussy/rosalind path: /computing_gc_content.py
# modified read_fasta() function from BioPython
# First application of yield to get multiple value pairs out of a function!
def calculate_gc_percentage(dna_string):
gc_count = 0
for letter in dna_string:
if letter == 'C' or lett... | code_fim | hard | {
"lang": "python",
"repo": "kaisteussy/rosalind",
"path": "/computing_gc_content.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ErikValle/RECALL path: /train_manager.py
for hc in classes:
current_paths = []
for c in hc:
path = base_path + str(c).zfill(2) + ".tfrecord"
current_paths.append(path)
paths.append(current_paths)
return paths
... | code_fim | hard | {
"lang": "python",
"repo": "ErikValle/RECALL",
"path": "/train_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ErikValle/RECALL path: /train_manager.py
"_" + class_id + ".tfrecord"
paths.append(current_path)
return paths
def get_mixed_train_paths(self):
assert self.dataset_type_first_step == "sequential" or self.dataset_type_first_step == "overlapped", \
"Er... | code_fim | hard | {
"lang": "python",
"repo": "ErikValle/RECALL",
"path": "/train_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_replay_source_no_helper_paths(self):
"""
Returns all tfrecord file paths of images that do not need an helper to compute their labels.
:return: A list of strings. Each string is a path to a tfrecord file containing images. This file do not need an
helper for th... | code_fim | hard | {
"lang": "python",
"repo": "ErikValle/RECALL",
"path": "/train_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firework-eternity/Personal-Python-Repository path: /basics_test/spider_exercise.py
#!usr/bin/python
# -*- coding:UTF-8 -*-
import requests
from lxml import etree
from bs4 import BeautifulSoup
# class SpiderExercise:
#
# def __init__(self):
# 获取网址
url = "https://www.biqooge.com/8_8539/"
he... | code_fim | hard | {
"lang": "python",
"repo": "firework-eternity/Personal-Python-Repository",
"path": "/basics_test/spider_exercise.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 获取并进入第一章的链接
first_href = dom.xpath("//*[@id=\"list\"]/dl/dd[10]/a/@href")
new_url = "https://www.biqooge.com/" + str(first_href[0])
response = requests.get(new_url, headers=headers)
code = response.apparent_encoding
print(code)
response.encoding = "gbk"
content_text = response.text
# print(content_text)... | code_fim | medium | {
"lang": "python",
"repo": "firework-eternity/Personal-Python-Repository",
"path": "/basics_test/spider_exercise.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 获取网站编码格式
code = response.apparent_encoding
print(code)
# 设置网页格式
response.encoding = "gbk"
# 将页面信息转化为dom格式
content_text = response.text
dom = etree.HTML(content_text)
# 根据xpath信息定位
list_dom = dom.xpath("//*[@id=\"list\"]/dl/dd[10]/a/text()")
# 打印定位的元素信息
print(list_dom)
# 获取并进入第一章的链接
first_href = dom... | code_fim | hard | {
"lang": "python",
"repo": "firework-eternity/Personal-Python-Repository",
"path": "/basics_test/spider_exercise.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
for obj in self.enemies:
obj.draw(self.win)
if obj.X < -30:
self.enemies.remove(obj)
for obj in self.items:
obj.draw(self.win)
if obj.X < -30:
self.items.remove(obj)
if self.player.get_rec... | code_fim | hard | {
"lang": "python",
"repo": "Timonevontimonsson/Rymdspel",
"path": "/scripts/level.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Timonevontimonsson/Rymdspel path: /scripts/level.py
#! python3
import sys
import os
import pygame
from pygame.locals import *
from scripts.player import Player
from scripts.obstacle import Obstacle
from scripts.projectile import Projectile
from scripts.text import Text
from scripts.Explorer impo... | code_fim | hard | {
"lang": "python",
"repo": "Timonevontimonsson/Rymdspel",
"path": "/scripts/level.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Skill controls
if event.key == pygame.K_SPACE:
if self.player.timeSinceLastSkill > 2500:
self.player.skillShot()
if event.key == pygame.K_LSHIFT:
if self.player.dash == False:
... | code_fim | hard | {
"lang": "python",
"repo": "Timonevontimonsson/Rymdspel",
"path": "/scripts/level.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ventadehumo/AplicativoCRY path: /tfgCrypMoney/AppCryptoMoney/Spider/enginemodule.py
from scrapy import FormRequest
from scrapy import Request
from scrapy.spiders import CrawlSpider
import xml.etree.cElementTree as ET
from time import gmtime, strftime
import os
import sys
class RequestNode:
... | code_fim | hard | {
"lang": "python",
"repo": "ventadehumo/AplicativoCRY",
"path": "/tfgCrypMoney/AppCryptoMoney/Spider/enginemodule.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.actualNode is not None:
tmpIdx = self.actualNode.idx
while tmpIdx is not None:
self.numNodes -= 1
nodeToExecute = self.actualNode
self.lastExecutionNode = nodeToExecute
self.actualNode = self.actualNode... | code_fim | hard | {
"lang": "python",
"repo": "ventadehumo/AplicativoCRY",
"path": "/tfgCrypMoney/AppCryptoMoney/Spider/enginemodule.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def insertNextLastListNodesSER(self, listNodes):
for node in listNodes:
self.insertLastSER(requestNode=node)
def insertNextLastSameIdxSER(self, requestNode, idx):
if idx is None:
self.insertLastSER(requestNode=requestNode)
else:
req = se... | code_fim | hard | {
"lang": "python",
"repo": "ventadehumo/AplicativoCRY",
"path": "/tfgCrypMoney/AppCryptoMoney/Spider/enginemodule.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jigsaw2212/IIM-IBM-Modelling-Hackathon path: /scripts/clean_text_and_split_into_sentences.py
from multiprocessing import Pool
from pymongo import MongoClient
import gensim
from nltk.tokenize import sent_tokenize, word_tokenize
import re
from nltk.corpus import stopwords
import enchant
db = Mongo... | code_fim | hard | {
"lang": "python",
"repo": "jigsaw2212/IIM-IBM-Modelling-Hackathon",
"path": "/scripts/clean_text_and_split_into_sentences.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def only_in_dict(words):
ret = []
for w in words:
try:
if dict.check(w):
ret.append(w)
except Exception as e:
print e, w
return ret
def remove_stop_words(sent):
return (w for w in sent if w not in stopwords)
if __name__ == '__main... | code_fim | hard | {
"lang": "python",
"repo": "jigsaw2212/IIM-IBM-Modelling-Hackathon",
"path": "/scripts/clean_text_and_split_into_sentences.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Plot centers with indicators
for i, c in enumerate(centers):
ax.scatter(x=c[0], y=c[1], color='white', edgecolors='black',
alpha=1, linewidth=2, marker='o', s=200)
ax.scatter(x=c[0], y=c[1], marker='$%d$' % (i), alpha=1, s=100)
# Se... | code_fim | hard | {
"lang": "python",
"repo": "Leaniz/img_similarity",
"path": "/core/visualize_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Leaniz/img_similarity path: /core/visualize_data.py
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import itertools
import core.const as const
def plot_cluster_results(df, preds, centers):
cols = [col for col in df.columns if col not in const.EXCLUDED_COLS]... | code_fim | medium | {
"lang": "python",
"repo": "Leaniz/img_similarity",
"path": "/core/visualize_data.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cols = [col for col in df.columns if col not in const.EXCLUDED_COLS]
col_pairs = itertools.combinations(cols, 3)
predictions = pd.DataFrame(preds, columns=['Cluster'])
plot_data = pd.concat([predictions, df], axis=1)
# Color map
cmap = cm.get_cmap('Set1')
for x, y, z in col_p... | code_fim | hard | {
"lang": "python",
"repo": "Leaniz/img_similarity",
"path": "/core/visualize_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if arg.endswith("?"):
return "Sure."
return "Whatever."<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py
class Bob:
def hey(self, arg):
arg = arg.strip()
<|fim_middle|> if not arg:
return... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if arg.isupper():
return "Whoa, chill out!"
if arg.endswith("?"):
return "Sure."
return "Whatever."<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py
class Bob:
def hey(self, arg):
<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py
class Bob:
def hey(self, arg):
<|fim_suffix|> if arg.isupper():
return "Whoa, chill out!"
if arg.endswith("?"):
return "Sure."
return "Whatever."<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/bob/43c7f233f5864d478400398c76e11477.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print "Merging %s into %s" % (doc2['name'], doc1['name'])
print journal_article_count(id1)
print journal_article_count(id2)
aliases = set(doc1['aliases'] + doc2['aliases'])
print aliases
print doc1['name']
if not dryrun:
doc1['aliases'] = list(aliases)
db.save(doc1)
db.delete(doc2)
print doc1... | code_fim | medium | {
"lang": "python",
"repo": "oakling/Oakling",
"path": "/akorn_search/lib/merge_journals.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oakling/Oakling path: /akorn_search/lib/merge_journals.py
import couchdb
import sys
server = couchdb.Server()
db = server['journals']
db_store = server['store']
def journal_article_count(journal_id):
<|fim_suffix|>doc1 = db[id1]
doc2 = db[id2]
print "Merging %s into %s" % (doc2['name'], doc1['... | code_fim | hard | {
"lang": "python",
"repo": "oakling/Oakling",
"path": "/akorn_search/lib/merge_journals.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print doc1
for row in db_store.view('index/journal_id', key=id2, include_docs=True).rows:
row.doc['journal_id_from'] = id2
row.doc['journal_id'] = id1
db_store.save(row.doc)<|fim_prefix|># repo: oakling/Oakling path: /akorn_search/lib/merge_journals.py
import couchdb
import sys
server =... | code_fim | medium | {
"lang": "python",
"repo": "oakling/Oakling",
"path": "/akorn_search/lib/merge_journals.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheGreatRambler/blender-universal-exporter path: /main.py
bl_info = {
"name": "Universal Exporter",
"category": "Import & Export",
}
import bpy
class Export(bpy.types.Operator):
"""Export blender project"""
bl_idname = "object.export_scene"
bl_label = "Export Blender Scene"... | code_fim | hard | {
"lang": "python",
"repo": "TheGreatRambler/blender-universal-exporter",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # This script converts all objects to .obj files
for obj in bpy.data.objects:
bpy.ops.object.select_name(name=obj.name)
bpy.ops.export_scene.obj(filepath=file_path, # the filepath
check_existing=True,
fil... | code_fim | hard | {
"lang": "python",
"repo": "TheGreatRambler/blender-universal-exporter",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YoungjaeKang/awesome-repo path: /rooms/serializers.py
from rest_framework import serializers
from .models import Room
from users.serializers import UserSerializer
# class RoomSerializer(serializers.Serializer):
# name = serializers.CharField(max_length=140)
# price = serializers.Integer... | code_fim | hard | {
"lang": "python",
"repo": "YoungjaeKang/awesome-repo",
"path": "/rooms/serializers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # RoomSerializer의 user가 id(int)로 나오는데 그거 말고 username이랑 superhost를 보고 싶다면
# user에도 serializers.py와 class를 만들고 그걸 여기서 import해준다.
user = UserSerializer()
class Meta:
model = Room
# fields = ("pk", "name", "price", "user",)
exclude = ("modified",)
# Manual
class Writ... | code_fim | medium | {
"lang": "python",
"repo": "YoungjaeKang/awesome-repo",
"path": "/rooms/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Manual
class WriteRoomSerializer(serializers.Serializer):
name = serializers.CharField(max_length=140)
address = serializers.CharField(max_length=140)
price = serializers.IntegerField(help_text="USD per night")
beds = serializers.IntegerField(default=1)
lat = serializers.DecimalField... | code_fim | medium | {
"lang": "python",
"repo": "YoungjaeKang/awesome-repo",
"path": "/rooms/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Register intent handlers
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(GetGuessAlexaNumberorGetGuessMyNumberIntentHandler())
# sb.add_request_handler(GetAttemptsIntentHandler())
# sb.add_request_handler(GetRangeIntentHandler())
sb.add_request_handler(GetLowerorHigherIntentHandler... | code_fim | medium | {
"lang": "python",
"repo": "JACTheCreator/guess-the-number",
"path": "/lambda/custom/number.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JACTheCreator/guess-the-number path: /lambda/custom/number.py
from ask_sdk_core.skill_builder import SkillBuilder
from intents.launch_request_handler import LaunchRequestHandler
from intents.get_guess_alexa_number_or_my_number_intent_handler import GetGuessAlexaNumberorGetGuessMyNumberIntentHand... | code_fim | hard | {
"lang": "python",
"repo": "JACTheCreator/guess-the-number",
"path": "/lambda/custom/number.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog... | code_fim | hard | {
"lang": "python",
"repo": "zhq2281/Modeling",
"path": "/ui_dialog_plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhq2281/Modeling path: /ui_dialog_plot.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui_dialog_plot.ui'
#
# Created by: PyQt5 UI code generator 5.13.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "zhq2281/Modeling",
"path": "/ui_dialog_plot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Dialog.setObjectName("Dialog")
Dialog.resize(640, 480)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.... | code_fim | medium | {
"lang": "python",
"repo": "zhq2281/Modeling",
"path": "/ui_dialog_plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='sample',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='... | code_fim | hard | {
"lang": "python",
"repo": "yc-hu/dm_apps",
"path": "/grais/migrations/0015_auto_20210401_0824.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yc-hu/dm_apps path: /grais/migrations/0015_auto_20210401_0824.py
# Generated by Django 3.1.6 on 2021-04-01 11:24
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "yc-hu/dm_apps",
"path": "/grais/migrations/0015_auto_20210401_0824.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def update_users(old_first, old_last, new_first, new_last):
total = 0
with open('users2.csv', 'r') as file:
csv_reader = reader(file)
names = list(csv_reader)
with open('users2.csv', 'w') as file2:
csv_writer = writer(file2)
#csv_writer.writerow(["First Name", ... | code_fim | medium | {
"lang": "python",
"repo": "jsneed/TheModernPython3Bootcamp",
"path": "/Section-031/exercise-322.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jsneed/TheModernPython3Bootcamp path: /Section-031/exercise-322.py
'''
update_users("Grace", "Hopper", "Hello", "World") # Users updated: 1.
update_users("Colt", "Steele", "Boba", "Fett") # Users updated: 2.
update_users("Not", "Here", "Still not", "Here") # Users updated: 0.
'''
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "jsneed/TheModernPython3Bootcamp",
"path": "/Section-031/exercise-322.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yarmash/projecteuler path: /python/p070.py
#!/usr/bin/env python3
"""Problem 70: Totient permutation"""
from bisect import bisect_left
from heapq import heappop, heappush
from utils import is_permutation, prime_sieve
def main():
<|fim_suffix|> class Number:
"""Number which is the ... | code_fim | hard | {
"lang": "python",
"repo": "yarmash/projecteuler",
"path": "/python/p070.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __lt__(self, other):
return self.number*other.phi < other.number*self.phi
queue = []
for low_idx in range(middle_idx, -1, -1):
heappush(queue, Number(low_idx, candidate_primes(low_idx)))
while queue:
number = heappop(queue)
if is_permutation(... | code_fim | hard | {
"lang": "python",
"repo": "yarmash/projecteuler",
"path": "/python/p070.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while queue:
number = heappop(queue)
if is_permutation(number.number, number.phi):
return number.number
try:
heappush(queue, Number(number.low_idx, number.gen))
except StopIteration:
pass
if __name__ == "__main__":
print(main(... | code_fim | hard | {
"lang": "python",
"repo": "yarmash/projecteuler",
"path": "/python/p070.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
e: threshold, for example 90%
"""
d = np.array(dataset)
cov = np.cov(d.transpose())
vals,vecs = np.linalg.eig(cov)
desc_idx = np.argsort(-vals)
desc_idx_sel = []
sum_vals = sum(vals)
temp = 0
for x in desc_idx:
desc_idx_sel.append(x)
temp = t... | code_fim | medium | {
"lang": "python",
"repo": "sarahzhouUestc/machine-learning-algorithms",
"path": "/falldetection/kNN.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def classifyKNN(x,dataset,labels,k):
dataSetNum = dataset.shape[0]
diffMat = np.tile(x, (dataSetNum, 1)) - dataset
sqDistances = list(np.tile(0,diffMat.shape[0]))
for i in range(diffMat.shape[0]):
for j in range(diffMat.shape[1]):
sqDistances[i]+=diffMat[i,j]**2 ... | code_fim | hard | {
"lang": "python",
"repo": "sarahzhouUestc/machine-learning-algorithms",
"path": "/falldetection/kNN.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sarahzhouUestc/machine-learning-algorithms path: /falldetection/kNN.py
# encoding=utf-8
import numpy as np
import operator
def normalize(dataset):
"""
Normalize dataset, and make mean value be 0 and variance be 1.
"""
minVals = dataset.min(axis=0)
maxVals = dataset.max(axis=0... | code_fim | hard | {
"lang": "python",
"repo": "sarahzhouUestc/machine-learning-algorithms",
"path": "/falldetection/kNN.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hauzerlin/ML_2021 path: /1. Regression/hauzer/Regression.py
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load
import n... | code_fim | hard | {
"lang": "python",
"repo": "hauzerlin/ML_2021",
"path": "/1. Regression/hauzer/Regression.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return np.sum((_y-_x.dot(_theta))**2)
theta = np.random.random((np.size(x,1), 1))
learning_rate = 41e-9
regular_param = 1
train_X = x[:4239]
train_Y = y[:4239]
vari_X = x[4239:]
vari_Y = y[4239:]
x_mix = train_X.T.dot(train_X)
x_sub = train_X.T.dot(train_Y)
def get_gradient(_x, _y, _theta):
re... | code_fim | hard | {
"lang": "python",
"repo": "hauzerlin/ML_2021",
"path": "/1. Regression/hauzer/Regression.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dr = os.path.dirname(__file__)
file_path = os.path.join(dr, '../data/test.srt')
texts = psrt.parse(file_path)
print texts
sents, vb = vocab.make(texts)
print sents
print vb<|fim_prefix|># repo: francis-shuoch/PHD path: /tests/test_vocab.py
import u... | code_fim | medium | {
"lang": "python",
"repo": "francis-shuoch/PHD",
"path": "/tests/test_vocab.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: francis-shuoch/PHD path: /tests/test_vocab.py
import unittest
import os
import parser.srt as psrt
import nlp.vocab as vocab
<|fim_suffix|> def test_parse(self):
dr = os.path.dirname(__file__)
file_path = os.path.join(dr, '../data/test.srt')
texts = psrt.parse(file_pa... | code_fim | medium | {
"lang": "python",
"repo": "francis-shuoch/PHD",
"path": "/tests/test_vocab.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_parse(self):
dr = os.path.dirname(__file__)
file_path = os.path.join(dr, '../data/test.srt')
texts = psrt.parse(file_path)
print texts
sents, vb = vocab.make(texts)
print sents
print vb<|fim_prefix|># repo: francis-shuoch/PHD path: /te... | code_fim | medium | {
"lang": "python",
"repo": "francis-shuoch/PHD",
"path": "/tests/test_vocab.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: StuartLittlefair/ginga path: /ginga/util/stages/rgbmap.py
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
import numpy as np
from ginga import cmap, imap, ColorDist
from ginga.RGBMap import RGBMapper
from ginga.gw import Widgets, Colo... | code_fim | hard | {
"lang": "python",
"repo": "StuartLittlefair/ginga",
"path": "/ginga/util/stages/rgbmap.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> combobox = b.intensity
options = []
for name in self.imap_names:
options.append(name)
combobox.append_text(name)
try:
index = self.imap_names.index(self._imap_name)
except Exception:
index = self.imap_names.index('ramp... | code_fim | hard | {
"lang": "python",
"repo": "StuartLittlefair/ginga",
"path": "/ginga/util/stages/rgbmap.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def copy_from_viewer_cb(self, w):
rgbmap = self.viewer.get_rgbmap()
rgbmap.copy_attributes(self.rgbmap, keylist=self.settings_keys)
self.pipeline.run_from(self)
def stretch_cmap_cb(self, w, val):
self.rgbmap.reset_sarr(callback=False)
stretch_val = 100.0 -... | code_fim | hard | {
"lang": "python",
"repo": "StuartLittlefair/ginga",
"path": "/ginga/util/stages/rgbmap.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> nums[j]=currentvalue
nums = [22, 16, 43, 27, 33, 41, 17, 21, 56]
insertionSort(nums)
print(nums)<|fim_prefix|># repo: nisheshpaudel/python_assignment_3 path: /A/b.py
def insertionSort(nums):
for i in range(1, len(nums)):
<|fim_middle|> currentvalue = nums[i]
j = i
while j>0 and n... | code_fim | medium | {
"lang": "python",
"repo": "nisheshpaudel/python_assignment_3",
"path": "/A/b.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nisheshpaudel/python_assignment_3 path: /A/b.py
def insertionSort(nums):
for i in range(1, len(nums)):
<|fim_suffix|>nums = [22, 16, 43, 27, 33, 41, 17, 21, 56]
insertionSort(nums)
print(nums)<|fim_middle|> currentvalue = nums[i]
j = i
while j>0 and nums[j - 1]>currentvalue:
... | code_fim | medium | {
"lang": "python",
"repo": "nisheshpaudel/python_assignment_3",
"path": "/A/b.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nums = [22, 16, 43, 27, 33, 41, 17, 21, 56]
insertionSort(nums)
print(nums)<|fim_prefix|># repo: nisheshpaudel/python_assignment_3 path: /A/b.py
def insertionSort(nums):
for i in range(1, len(nums)):
<|fim_middle|> currentvalue = nums[i]
j = i
while j>0 and nums[j - 1]>currentvalue:
... | code_fim | medium | {
"lang": "python",
"repo": "nisheshpaudel/python_assignment_3",
"path": "/A/b.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertTrue(success)
logging.debug('Bug review status changed successfully')
report = self._cc_client.getReport(bug.reportId)
self.assertEqual(report.reviewData.comment, review_comment)
self.assertEqual(report.reviewData.status, status)
# Change review... | code_fim | hard | {
"lang": "python",
"repo": "imbur/codechecker",
"path": "/web/tests/functional/review_status/test_review_status.py",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imbur/codechecker path: /web/tests/functional/review_status/test_review_status.py
#
# -------------------------------------------------------------------------
#
# Part of the CodeChecker project, under the Apache License v2.0 with
# LLVM Exceptions. See LICENSE for license information.
# SPDX... | code_fim | hard | {
"lang": "python",
"repo": "imbur/codechecker",
"path": "/web/tests/functional/review_status/test_review_status.py",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Modify review comments from intentional to confirmed for the
# second store.
with open(source_file, 'r+', encoding='utf-8', errors='ignore') as sf:
content = sf.read()
new_content = content.replace("codechecker_intentional",
... | code_fim | hard | {
"lang": "python",
"repo": "imbur/codechecker",
"path": "/web/tests/functional/review_status/test_review_status.py",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Set titles
ax[0,0].set_title('Intensity')
ax[0,1].set_title('DOPL')
ax[1,0].set_title('DOP45')
ax[1,1].set_title('DOPC')
fig.suptitle('DOPs vs Depth')
pass
def map_DOP_reflectance(self):
filt_top_detector = self.df['hitObj'] == self... | code_fim | hard | {
"lang": "python",
"repo": "JeanPhilippe123/Sintering",
"path": "/Monte_Carlo/Analyse_data_Monte_Carlo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeanPhilippe123/Sintering path: /Monte_Carlo/Analyse_data_Monte_Carlo.py
.dirname(os.path.realpath(__file__)), '')
max_segments = 4000
pice = 917
def __init__(self,name,numrays,radius,Delta,g,wlum,pol,Random_pol=False,diffuse_light=False):
self.name = name
self.nu... | code_fim | hard | {
"lang": "python",
"repo": "JeanPhilippe123/Sintering",
"path": "/Monte_Carlo/Analyse_data_Monte_Carlo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def calculate_Stokes_xy(self,df):
[I,Q,U,V] = self.calculate_Stokes_of_rays(df)
#Calculate Stokes vs Radius
XY_detector = 100/self.mus_theo
bins = (np.linspace(-XY_detector,XY_detector,50),np.linspace(-XY_detector,XY_detector,50))
#Histogram of... | code_fim | hard | {
"lang": "python",
"repo": "JeanPhilippe123/Sintering",
"path": "/Monte_Carlo/Analyse_data_Monte_Carlo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Raises:
PermissionDenied:
If the account of the user corresponding to the provided
credentials is not active.
"""
email = email or username
try:
email_instance = models.Email.objects.get(
address=email... | code_fim | hard | {
"lang": "python",
"repo": "UltiManager/ultimanager-api-old",
"path": "/api/account/authentication.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
The user with the provided ID. ``None`` is returned if no
user with the provided ID exists.
"""
try:
return UserModel.objects.get(id=user_id)
except UserModel.DoesNotExist:
return None<|fim_prefix|># repo: UltiManager... | code_fim | hard | {
"lang": "python",
"repo": "UltiManager/ultimanager-api-old",
"path": "/api/account/authentication.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stevalang/Coding-Lessons path: /SoftUni/Python Developmen/Python-Advanced/Tuples-Sets/2_Average_Student_Grades.py
from collections import defaultdict
students = defaultdict(list)
<|fim_suffix|>for name, grades in students.items():
grades_str = ' '.join(map(lambda f: format(f, '.2f'), grades... | code_fim | medium | {
"lang": "python",
"repo": "stevalang/Coding-Lessons",
"path": "/SoftUni/Python Developmen/Python-Advanced/Tuples-Sets/2_Average_Student_Grades.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for name, grades in students.items():
grades_str = ' '.join(map(lambda f: format(f, '.2f'), grades))
print(f'{name} -> {grades_str} (avg: {sum(grades)/ len(grades):.2f})')<|fim_prefix|># repo: stevalang/Coding-Lessons path: /SoftUni/Python Developmen/Python-Advanced/Tuples-Sets/2_Average_Student_... | code_fim | medium | {
"lang": "python",
"repo": "stevalang/Coding-Lessons",
"path": "/SoftUni/Python Developmen/Python-Advanced/Tuples-Sets/2_Average_Student_Grades.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diviswen/Cycle4Completion path: /main_code.py
learning_rate', type=float, default=0.001, help='Initial learning rate [default: 0.001]')
parser.add_argument('--decay_step', type=int, default=400000, help='Decay step for lr decay [default: 200000]')
parser.add_argument('--decay_rate', type=float, d... | code_fim | hard | {
"lang": "python",
"repo": "diviswen/Cycle4Completion",
"path": "/main_code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diviswen/Cycle4Completion path: /main_code.py
parser = argparse.ArgumentParser()
parser.add_argument('--model', default='model_code', help='Model name [default: model_l2h]')
parser.add_argument('--log_dir', default='logs', help='Log dir [default: logs]')
parser.add_argument('--num_point', type=i... | code_fim | hard | {
"lang": "python",
"repo": "diviswen/Cycle4Completion",
"path": "/main_code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Init variables
ckpt_state = tf.train.get_checkpoint_state(RESTORE_PATH)
if ckpt_state is not None:
LOAD_MODEL_FILE = os.path.join(RESTORE_PATH, os.path.basename(ckpt_state.model_checkpoint_path))
saver.restore(sess, LOAD_MODEL_FILE)
log_string(... | code_fim | hard | {
"lang": "python",
"repo": "diviswen/Cycle4Completion",
"path": "/main_code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return email_contents, labels
@classmethod
def _generate_ngrams_using_ES(cls, corpus, all_labels):
def _mtermvector_query_helper(text_chunks):
return {
"docs": [
{"doc": {"text": text}} for text in text_chunks
]
... | code_fim | hard | {
"lang": "python",
"repo": "sumeetgajjar/CS6200-S20",
"path": "/HW_7/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sumeetgajjar/CS6200-S20 path: /HW_7/main.py
import email
import json
import logging
import os
import random
import re
import string
from collections import defaultdict
from typing import Dict
import numpy as np
from bs4 import BeautifulSoup
from nltk import SnowballStemmer
from nltk.corpus impor... | code_fim | hard | {
"lang": "python",
"repo": "sumeetgajjar/CS6200-S20",
"path": "/HW_7/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _helper(email_body):
content_type = str(email_body.get_content_type())
content_disposition = str(email_body.get_content_disposition())
if content_type == 'text/plain' and 'attachment' not in content_disposition:
parsed_email.body += str(email... | code_fim | hard | {
"lang": "python",
"repo": "sumeetgajjar/CS6200-S20",
"path": "/HW_7/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>printf('*** WRITING CSV DATA')
f = open('bookdata.csv', 'w')
writer = csv.writer(f)
for record in DATA:
writer.writenow(record)
f.close()
printf('*** REVIEW OF SAVED DATA')
f = open('bookdata.csv', 'r')
reader = csv.reader(f)
for chap, title, modpkgs in reader:
printf('Chapter %s: %r (featuring %... | code_fim | medium | {
"lang": "python",
"repo": "NetworkRanger/python-core",
"path": "/chapter14/csvex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NetworkRanger/python-core path: /chapter14/csvex.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: NetworkRanger
# Date: 2019/8/11 4:21 PM
<|fim_suffix|>DATA = (
(9, 'Web Clients and Servers', 'base64, urllib'),
(10, 'Web Programming: CGI & WSGI', 'cgi, time, wsgiref'),
(13,... | code_fim | medium | {
"lang": "python",
"repo": "NetworkRanger/python-core",
"path": "/chapter14/csvex.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DATA = (
(9, 'Web Clients and Servers', 'base64, urllib'),
(10, 'Web Programming: CGI & WSGI', 'cgi, time, wsgiref'),
(13, 'Web Services', 'urllib, twython')
)
printf('*** WRITING CSV DATA')
f = open('bookdata.csv', 'w')
writer = csv.writer(f)
for record in DATA:
writer.writenow(record)
f... | code_fim | medium | {
"lang": "python",
"repo": "NetworkRanger/python-core",
"path": "/chapter14/csvex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: podhmo/monokaki path: /examples/customize-renderer/renderer.py
import json
from collections import OrderedDict
def ordered_json_render(data, record, formatter):
kwargs = OrderedDict()
# see: https://docs.python.org/3/library/logging.html#formatter-objects
kwargs["time"] = formatter.... | code_fim | hard | {
"lang": "python",
"repo": "podhmo/monokaki",
"path": "/examples/customize-renderer/renderer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # extra data
kwargs.update(record.kwargs)
return json.dumps(kwargs, indent=2)<|fim_prefix|># repo: podhmo/monokaki path: /examples/customize-renderer/renderer.py
import json
from collections import OrderedDict
def ordered_json_render(data, record, formatter):
<|fim_middle|> kwargs = Orde... | code_fim | hard | {
"lang": "python",
"repo": "podhmo/monokaki",
"path": "/examples/customize-renderer/renderer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: apalevich/PyMentor path: /06_dogs.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise with classes and objects.
We create class Dog so we can use create objects-dogs:
>>> bob = Dog('Bob')
>>> print(bob.name)
Bob
Using arguments we can give it not only name but date of birth (as an ... | code_fim | medium | {
"lang": "python",
"repo": "apalevich/PyMentor",
"path": "/06_dogs.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.