text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|># SQL can be run over DataFrames that have been registered as a table
teenagers = sqlCtx.sql("SELECT * FROM people WHERE age >= 13 AND age <= 19")
print(teenagers.dtypes)
for teen in teenagers.collect():
print(teen)
schemaPeople.groupBy("age").count().orderBy(col("age").desc()).show()<|fim_prefix|># re... | code_fim | hard | {
"lang": "python",
"repo": "blarking94/Python",
"path": "/PySpark/spark-sql.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for teen in teenagers.collect():
print(teen)
schemaPeople.groupBy("age").count().orderBy(col("age").desc()).show()<|fim_prefix|># repo: blarking94/Python path: /PySpark/spark-sql.py
from pyspark.sql import SQLContext, Row
from pyspark import SparkContext, SparkConf
from pyspark.sql.functions import col... | code_fim | hard | {
"lang": "python",
"repo": "blarking94/Python",
"path": "/PySpark/spark-sql.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jtwhite79/my_python_junk path: /gather/gathered/MD_CWM_tsproc_setup_02.py
import copy
import sys
import os
from datetime import datetime,timedelta
from dateutil.relativedelta import relativedelta
import numpy as np
import pandas
import tsprocClass as tc
import pestUtil as pu
#update paramete... | code_fim | hard | {
"lang": "python",
"repo": "jtwhite79/my_python_junk",
"path": "/gather/gathered/MD_CWM_tsproc_setup_02.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #--copy the final processed block to have the same name as the original
#renamed_block = tsp.copy_2_series(reduced_block,[site_name+'_ro'],role='final',wght=100.0,context=tc.PEST_CONTEXT)
#pest_oblocks.extend(renamed_block)
renamed_block = tsp.copy_2_series(... | code_fim | hard | {
"lang": "python",
"repo": "jtwhite79/my_python_junk",
"path": "/gather/gathered/MD_CWM_tsproc_setup_02.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#--process each head record individually because of the variable record length
for i,[site,oblock,mblock] in enumerate(zip(smp_site_names,oblocks,mblocks)):
oblock = [oblock]
mblock = [mblock]
#--get the start and end of the observed record
ostart = stage_smp.records[site].dropna().inde... | code_fim | hard | {
"lang": "python",
"repo": "jtwhite79/my_python_junk",
"path": "/gather/gathered/MD_CWM_tsproc_setup_02.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cxrodgers/MCwatch path: /behavior/misc.py
""""Module for miscellaneous behavior stuff
For example, stuff like extracting lick times or choice times.
TrialSpeak shouldn't depend on stuff like that.
# Also get the pldf and use that to get lick times
ldf = ArduFSM.TrialSpeak.read_logfile_... | code_fim | hard | {
"lang": "python",
"repo": "cxrodgers/MCwatch",
"path": "/behavior/misc.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return choice_times
def get_included_trials(trial_times, data_range, t_start=0, t_stop=0):
"""Identify the trials included in a temporal range.
trial_times : Series of trial times (e.g., rwin times) indexed by
trial labels
data_range : 2-tuple (start, stop) specifyin... | code_fim | hard | {
"lang": "python",
"repo": "cxrodgers/MCwatch",
"path": "/behavior/misc.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> a = 0
for product in self.lista_productos:
a += 1
if product.cat_producto == categoria:
print(f"=================Producto 0{a}:=================")
product.producto_info()
print("Se REMATA, y su nuevo precio de remate e... | code_fim | hard | {
"lang": "python",
"repo": "jemm2008/tienda-productos",
"path": "/modulos/tienda.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jemm2008/tienda-productos path: /modulos/tienda.py
class Tienda:
def __init__(self, nombre_tienda, lista_productos = []):
self.nombre_tienda = nombre_tienda
self.lista_productos = lista_productos
def __str__(self):
return f"Nombre de la Tienda: {self.nombre_tienda... | code_fim | medium | {
"lang": "python",
"repo": "jemm2008/tienda-productos",
"path": "/modulos/tienda.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterModelOptions(
name='comprobantemodel',
options={'verbose_name': 'Comprobante'},
),
migrations.AlterModelTable(
name='comprobantemodel',
table='t_comprobante',
),
]<|fim_prefix|># repo: Ke... | code_fim | medium | {
"lang": "python",
"repo": "KevLeop/backend-tecsup",
"path": "/semana 9/facturacion/restaurante/migrations/0004_auto_20210324_1933.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KevLeop/backend-tecsup path: /semana 9/facturacion/restaurante/migrations/0004_auto_20210324_1933.py
# Generated by Django 3.1.7 on 2021-03-25 00:33
<|fim_suffix|> dependencies = [
('restaurante', '0003_auto_20210324_1932'),
]
operations = [
migrations.AlterModelOptio... | code_fim | medium | {
"lang": "python",
"repo": "KevLeop/backend-tecsup",
"path": "/semana 9/facturacion/restaurante/migrations/0004_auto_20210324_1933.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>entrada = int(input())
resultado = contador_notas(100, entrada)
if (resultado != -1):
print("{} nota(s) de R$ {}".format(resultado, 100))<|fim_prefix|># repo: lucinama/PythonPratice path: /Uri-1018-Cedulas/Uri_1018_Cedulas.py
def contador_notas(multiplo, numero):
<|fim_middle|> if(numero % multipl... | code_fim | medium | {
"lang": "python",
"repo": "lucinama/PythonPratice",
"path": "/Uri-1018-Cedulas/Uri_1018_Cedulas.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
entrada = int(input())
resultado = contador_notas(100, entrada)
if (resultado != -1):
print("{} nota(s) de R$ {}".format(resultado, 100))<|fim_prefix|># repo: lucinama/PythonPratice path: /Uri-1018-Cedulas/Uri_1018_Cedulas.py
def contador_notas(multiplo, numero):
<|fim_middle|> if(numero % multip... | code_fim | medium | {
"lang": "python",
"repo": "lucinama/PythonPratice",
"path": "/Uri-1018-Cedulas/Uri_1018_Cedulas.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucinama/PythonPratice path: /Uri-1018-Cedulas/Uri_1018_Cedulas.py
def contador_notas(multiplo, numero):
<|fim_suffix|>
entrada = int(input())
resultado = contador_notas(100, entrada)
if (resultado != -1):
print("{} nota(s) de R$ {}".format(resultado, 100))<|fim_middle|> if(numero % multip... | code_fim | medium | {
"lang": "python",
"repo": "lucinama/PythonPratice",
"path": "/Uri-1018-Cedulas/Uri_1018_Cedulas.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yudingchu/open-falcon4j path: /open-falcon4j-agent/src/main/resources/py/Base.py
# -*- coding:utf-8 -*-
import time
class Base:
<|fim_suffix|> '''
获取时间戳
:return:
'''
return str(time.time()).split('.')[0]<|fim_middle|> def getTime(self):
| code_fim | easy | {
"lang": "python",
"repo": "yudingchu/open-falcon4j",
"path": "/open-falcon4j-agent/src/main/resources/py/Base.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
获取时间戳
:return:
'''
return str(time.time()).split('.')[0]<|fim_prefix|># repo: yudingchu/open-falcon4j path: /open-falcon4j-agent/src/main/resources/py/Base.py
# -*- coding:utf-8 -*-
import time
class Base:
<|fim_middle|> def getTime(self):
| code_fim | easy | {
"lang": "python",
"repo": "yudingchu/open-falcon4j",
"path": "/open-falcon4j-agent/src/main/resources/py/Base.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Raised when the object can not be created from the provided dict."""
pass<|fim_prefix|># repo: AndreaCossio/PoliTo-Projects path: /NTMY-code/server/database/exceptions.py
"""This module provides the definition of the exceptions that can be raised from the database module."""
class DatabaseErr... | code_fim | medium | {
"lang": "python",
"repo": "AndreaCossio/PoliTo-Projects",
"path": "/NTMY-code/server/database/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
razao=float("inf")
else:
razao=tabela[linha][menor_posicao]/tabela[menor_solucao_posicao][menor_posicao]
for coluna in range (0,n_colunas):
tabela[linha][coluna]=tabela[linha][coluna]-(razao*tabela[menor_solucao_posicao][coluna])
#Buscar o menor numero negativo na linha 0
menor... | code_fim | hard | {
"lang": "python",
"repo": "Carlos-Alfredo/M-todos-Num-ricos",
"path": "/metodos numericos python/questao1_d.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carlos-Alfredo/M-todos-Num-ricos path: /metodos numericos python/questao1_d.py
tabela = [[1,-45,-20,0,0,0,0],[0,20,5,1,0,0,9500],[0,0.04,0.12,0,1,0,40],[0,1,1,0,0,1,551]]
colunas = ["Z","A","B","S1","S2","S3","Solução"]
linhas = ["Z","S1","S2","S3"]
n_colunas=7
n_linhas=4
#Inicio do algori... | code_fim | hard | {
"lang": "python",
"repo": "Carlos-Alfredo/M-todos-Num-ricos",
"path": "/metodos numericos python/questao1_d.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>osicao][menor_posicao] e dividir a linha menor_solucao_posicao por ele
pivo=tabela[menor_solucao_posicao][menor_posicao]
for coluna in range(0,n_colunas):
if(pivo==0):
tabela[menor_solucao_posicao][coluna]=float("inf")
else:
tabela[menor_solucao_posicao][coluna]=tabela[menor_solucao_posi... | code_fim | hard | {
"lang": "python",
"repo": "Carlos-Alfredo/M-todos-Num-ricos",
"path": "/metodos numericos python/questao1_d.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: L200184098/Prak_Algostruk path: /L200184098_Modul2_H/No7.py
# nomer7
import no2_modul2 # Atau apapun file-nya yang kamu buat tadi
class MhsTIF(no2_modul2.Mahasiswa): # perhatikan class induknya : Mahasiswa
"""Class MhsTIF yang dibangun dari class Mahasiswa"""
def kataKa... | code_fim | medium | {
"lang": "python",
"repo": "L200184098/Prak_Algostruk",
"path": "/L200184098_Modul2_H/No7.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Class MhsTIF yang dibangun dari class Mahasiswa"""
def kataKanPy(self):
print('Python is cool.')
"Apakah metode / state itu berasal dari class Manusia, Mahasiswa, atau MhsTIF?
"Jawab :
"Metoode atau state yang muncul berasal dari semua class baik Manusia, Mahasiswa, atau MhsTIF... | code_fim | medium | {
"lang": "python",
"repo": "L200184098/Prak_Algostruk",
"path": "/L200184098_Modul2_H/No7.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
optional_argument_func("Hello", "World")
arbitrary_argument_func()
arbitrary_argument_func("hello")
arbitrary_argument_func("hello", "world", "again")<|fim_prefix|># repo: KqSMea8/PythonTools path: /features_test/arbitrary_number_args.py
#! /usr/bin/env python
#... | code_fim | hard | {
"lang": "python",
"repo": "KqSMea8/PythonTools",
"path": "/features_test/arbitrary_number_args.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KqSMea8/PythonTools path: /features_test/arbitrary_number_args.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
# Copyright © YXC
# CreateTime: 2016-03-09 10:06:02
"""
Example of functions with arbitrary number arguments
"""
def optional_argument_func(arg1='', arg2=''):
... | code_fim | hard | {
"lang": "python",
"repo": "KqSMea8/PythonTools",
"path": "/features_test/arbitrary_number_args.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_case05(self):
"""Datetime versions compare"""
version = versions.get_version_power("2020.1.1")
version2 = versions.get_version_power("2021.1.1")
self.assertGreater(version2, version)<|fim_prefix|># repo: anatolio-deb/vpnmupd path: /tests/test_module01.py
from ... | code_fim | hard | {
"lang": "python",
"repo": "anatolio-deb/vpnmupd",
"path": "/tests/test_module01.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anatolio-deb/vpnmupd path: /tests/test_module01.py
from datetime import datetime
from unittest import TestCase
from vpnmupd import versions
class TestClass01(TestCase):
"""Software dependency versions compared"""
def setUp(self) -> None:
super().setUp()
self.any_string... | code_fim | medium | {
"lang": "python",
"repo": "anatolio-deb/vpnmupd",
"path": "/tests/test_module01.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Version power calculation"""
version = versions.get_version_power("1.1.1")
self.assertEqual(version, 111)
def test_case03(self):
"""Version power calculation compared"""
version1 = versions.get_version_power("1.1.1")
version2 = versions.get_version_p... | code_fim | hard | {
"lang": "python",
"repo": "anatolio-deb/vpnmupd",
"path": "/tests/test_module01.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getConfig(self):
r = self._get("config")
result = r.json()
if("Config_Version" in result):
self.config = result
def putConfig(self):
r = self._post("config", json=self.config)
try:
r = self._post("apply")
except Timeout:
... | code_fim | hard | {
"lang": "python",
"repo": "shrank/python_netonix_api",
"path": "/netonix_api.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.orig_config = deepcopy(self.config)
if("Config_Version" in config):
del config["Config_Version"]
self.config.update(config)
def getDiff(self):
if(self.orig_config is None):
return {}
if(DIFF is False):
raise ImportError... | code_fim | hard | {
"lang": "python",
"repo": "shrank/python_netonix_api",
"path": "/netonix_api.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shrank/python_netonix_api path: /netonix_api.py
#!/usr/bin/env python3
"""
Python class to access Netonix® WISP Switch WebAPI
** NEITHER THIS CODE NOR THE AUTHOR IS ASSOCIATED WITH NETONIX® IN ANY WAY.**
This is free and unencumbered software released into the public domain.
Anyone is free to ... | code_fim | hard | {
"lang": "python",
"repo": "shrank/python_netonix_api",
"path": "/netonix_api.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> users_and_ids.append((u,int(id)))
users_and_ids.sort(key = lambda pair:pair[1])
for id,usr in users_and_ids:
print id,usr<|fim_prefix|># repo: iahmad-khan/python-handson-CERN-4day path: /usernames5.py
#!/usr/bin/python
import sys
f = open('/etc/passwd','r')
user<|fim_middle|>s_and_ids = []
for line in... | code_fim | medium | {
"lang": "python",
"repo": "iahmad-khan/python-handson-CERN-4day",
"path": "/usernames5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iahmad-khan/python-handson-CERN-4day path: /usernames5.py
#!/usr/bin/python
import sys
f = open('/etc/passwd','r')
user<|fim_suffix|>mbda pair:pair[1])
for id,usr in users_and_ids:
print id,usr<|fim_middle|>s_and_ids = []
for line in f:
u,_,id,_ = line.split(':',3)
users_and_ids.append((u,i... | code_fim | medium | {
"lang": "python",
"repo": "iahmad-khan/python-handson-CERN-4day",
"path": "/usernames5.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mbda pair:pair[1])
for id,usr in users_and_ids:
print id,usr<|fim_prefix|># repo: iahmad-khan/python-handson-CERN-4day path: /usernames5.py
#!/usr/bin/python
import sys
f = open('/etc/passwd','r')
users_and_ids = []
for line in f:
u,_,id,_ = line.split(':',3)
<|fim_middle|> users_and_ids.append((u,i... | code_fim | medium | {
"lang": "python",
"repo": "iahmad-khan/python-handson-CERN-4day",
"path": "/usernames5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
if len(sys.argv) < 2:
print "examples: "
print " %s '1+1)'" % sys.argv[0]
sys.exit()
s = sys.argv[1]
vv = back(s, 'E')
if vv:
print s + ' is valid, it can be reduced to E'
for i in vv:
print '\t' + '\t'.join(... | code_fim | hard | {
"lang": "python",
"repo": "bianyuan1986/algorithm",
"path": "/validate",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bianyuan1986/algorithm path: /validate
#!/usr/bin/python
#encoding=utf-8
import os, sys
rules = {
'E': ['A'],
'A': ['A+M', 'M'],
'M': ['M*P', 'P'],
'P': ['(E)', 'N'],
'N': [str(i) for i in range(10)],
}
#st为要扫描的字符串
#target为终止状态,即最后的可接受状态
def back(st, target):
reduced_se... | code_fim | hard | {
"lang": "python",
"repo": "bianyuan1986/algorithm",
"path": "/validate",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ysw0421/OpenCV_Tutorial path: /Project 5 Week/KMeans.py
import math
import numpy as np
import cv2
from matplotlib import pyplot as plt
from sklearn.cluster import KMeans
from sklearn import metrics
from scipy.spatial.distance import cdist
if (__name__ == "__main__"):
cap = cv2.V... | code_fim | hard | {
"lang": "python",
"repo": "ysw0421/OpenCV_Tutorial",
"path": "/Project 5 Week/KMeans.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #같은 좌표 값 제거
if count == 0:
print("List has one List")
elif list[count][1] == list[count-1][1] and list[count][2] == list[count-1][2] :
a = list.pop()
count = count - 1
count = count + 1
count = 0... | code_fim | hard | {
"lang": "python",
"repo": "ysw0421/OpenCV_Tutorial",
"path": "/Project 5 Week/KMeans.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #(0,0)에서 부터의 거리 오름차순 정리
if not list:
print("empty")
else:
list.sort()
print(list)
'''
for i in range(len(list)):
if count == 0:
print("list 내용 한개")
else:
... | code_fim | hard | {
"lang": "python",
"repo": "ysw0421/OpenCV_Tutorial",
"path": "/Project 5 Week/KMeans.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p03835/s659308652.py
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
<|fim_suffix|> K, S = read_ints()
# X+Y+Z = S
# 0 <= X,Y,Z <= K
total = 0
for X in range(K... | code_fim | easy | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p03835/s659308652.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def solve():
K, S = read_ints()
# X+Y+Z = S
# 0 <= X,Y,Z <= K
total = 0
for X in range(K+1):
if S-X < 0:
break
# Y+Z=S-X
Y_min = max(S-X-K, 0)
Y_max = min(S-X, K)
if Y_min <= Y_max:
total += Y_max-Y_min+1
return total
... | code_fim | medium | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p03835/s659308652.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def check_odoo_relative_import(self, node):
if self.odoo_module_name in self._get_odoo_module_imported(node):
self.add_message('odoo-addons-relative-import', node=node,
args=(self.odoo_module_name))
@staticmethod
def _is_absolute_import(node, n... | code_fim | hard | {
"lang": "python",
"repo": "it-projects-llc/pylint-odoo",
"path": "/pylint_odoo/checkers/modules_odoo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: it-projects-llc/pylint-odoo path: /pylint_odoo/checkers/modules_odoo.py
rts
return
if self._is_module_name_in_whitelist(module_name):
# ignore whitelisted modules
return
isort_obj = isort.SortImports(file_contents='')
import_category = i... | code_fim | hard | {
"lang": "python",
"repo": "it-projects-llc/pylint-odoo",
"path": "/pylint_odoo/checkers/modules_odoo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """The xml attribute is missing the translation="off" tag
Example <attribute name="groups">sale.group</attribute>
"""
if (self.linter._all_options['valid_odoo_versions'].config
.valid_odoo_versions != ['8.0']):
return True
self.msg_a... | code_fim | hard | {
"lang": "python",
"repo": "it-projects-llc/pylint-odoo",
"path": "/pylint_odoo/checkers/modules_odoo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sadegh-dev/dj-shop path: /shop/accounts/managers.py
from django.contrib.auth.models import BaseUserManager
class MyUserManager(BaseUserManager):
def create_user(self, email, password, full_name, national_code, mobile, address):
<|fim_suffix|> user = self.create_user(email, password, ... | code_fim | hard | {
"lang": "python",
"repo": "sadegh-dev/dj-shop",
"path": "/shop/accounts/managers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = self.model(
email = self.normalize_email(email) ,
full_name = full_name ,
national_code = national_code ,
mobile = mobile ,
address = address,
)
user.set_password(password)
user.save(using=self._db)
... | code_fim | hard | {
"lang": "python",
"repo": "sadegh-dev/dj-shop",
"path": "/shop/accounts/managers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: j1h7e7/OWL-stats path: /elopreds/elocalculations.py
import json, requests, math, random
#import datagatherer
# Constants:
start_elo = 0 # Starting elo
decay_factor = 0.9 # Decay % between stages
k = 30 # k for elo change
d = 200 # Difference in elo... | code_fim | hard | {
"lang": "python",
"repo": "j1h7e7/OWL-stats",
"path": "/elopreds/elocalculations.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> random_roll = random.random()
team1winchance = 1/(1+10**((elo2-elo1)/d))
drawchance = self.map_draws[mapname][0]/self.map_draws[mapname][1] * min(team1winchance,1-team1winchance)*2
if random_roll < team1winchance - drawchance/2: act_t1, act_t2 = 1,0
... | code_fim | hard | {
"lang": "python",
"repo": "j1h7e7/OWL-stats",
"path": "/elopreds/elocalculations.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Услуга"""
PERIOD = (
(0, ''),
(1, '6'),
(2, '12'),
(3, '24'),
)
title = models.CharField("Название", max_length=100)
description = models.TextField("Описание")
image = models.ImageField("Фото", upload_to="services/", null=True, blank=True)
e... | code_fim | hard | {
"lang": "python",
"repo": "aquaracer/DRF_car_service",
"path": "/api/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aquaracer/DRF_car_service path: /api/models.py
from django.contrib.auth.models import User
from django.core import validators
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import Group
from django.... | code_fim | hard | {
"lang": "python",
"repo": "aquaracer/DRF_car_service",
"path": "/api/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_gold(bot, update):
chat_type = get_chat_type(update)
response = get_course_gold()
if chat_type == "group":
bot.sendMessage(chat_id=group_chat_id(update), text=response,
reply_to_message_id=update.message.message_id)
else:
bot.sendMessage(chat... | code_fim | hard | {
"lang": "python",
"repo": "niklsspb/heroku_bot",
"path": "/jobs.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_everyday(bot, update):
global results
check_date()
chat_type = get_chat_type(update)
if results is None:
results = get_every_day()
if results is not None:
if chat_type == "group":
bot.sendPhoto(chat_id=group_chat_id(update), photo=result... | code_fim | hard | {
"lang": "python",
"repo": "niklsspb/heroku_bot",
"path": "/jobs.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: niklsspb/heroku_bot path: /jobs.py
import datetime
import json
import logging
from grab import Grab
from actions import get_course_gold, get_chat_type, get_indexes, group_chat_id
# logging.basicConfig(
# format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
# level=logging.DEB... | code_fim | hard | {
"lang": "python",
"repo": "niklsspb/heroku_bot",
"path": "/jobs.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikaelbeat/Robot_Framework_Recap path: /Robot_Framework_Recap/Python_Basics/Constructors.py
# Constructor without arguments
class Demo:
def __init__(self):
print("\nThis is constructor")
obj = Demo()
<|fim_suffix|> def __init__(self, number1, number2):
su... | code_fim | easy | {
"lang": "python",
"repo": "mikaelbeat/Robot_Framework_Recap",
"path": "/Robot_Framework_Recap/Python_Basics/Constructors.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sumOfNumbers = number1 + number2
print(sumOfNumbers)
obj2 = Demo2(50,75)<|fim_prefix|># repo: mikaelbeat/Robot_Framework_Recap path: /Robot_Framework_Recap/Python_Basics/Constructors.py
# Constructor without arguments
class Demo:
def __init__(self):
print("\nThis is... | code_fim | medium | {
"lang": "python",
"repo": "mikaelbeat/Robot_Framework_Recap",
"path": "/Robot_Framework_Recap/Python_Basics/Constructors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, number1, number2):
sumOfNumbers = number1 + number2
print(sumOfNumbers)
obj2 = Demo2(50,75)<|fim_prefix|># repo: mikaelbeat/Robot_Framework_Recap path: /Robot_Framework_Recap/Python_Basics/Constructors.py
# Constructor without arguments
class Demo:
de... | code_fim | medium | {
"lang": "python",
"repo": "mikaelbeat/Robot_Framework_Recap",
"path": "/Robot_Framework_Recap/Python_Basics/Constructors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: changhengliou/ECE-GY-9123-DL-final path: /Paper2PPT/baselines/mead/run_mead.py
import os
import shutil
from tqdm import tqdm
from pathlib import Path
from eval_mead import PERCENT
DATAPATH = '../../../data/test'
# MEAD_DIR = 'mead'
MEAD_DIR = os.path.abspath('mead')
MEAD_DATA_PATH = f'{MEAD_DIR}... | code_fim | hard | {
"lang": "python",
"repo": "changhengliou/ECE-GY-9123-DL-final",
"path": "/Paper2PPT/baselines/mead/run_mead.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Create cluster and docsent files...')
os.system(
f'perl {MEAD_FORMATTING_ADDONS}/text2cluster.pl {DATA_DIR}')
if os.system(f'mv {DATA_DIR}/../{TARGET}.cluster {DATA_DIR}') != 0:
print(
'MAKE SURE you have change $dir/$dir.cluster to $dir.cluster in {MEAD_FOR... | code_fim | hard | {
"lang": "python",
"repo": "changhengliou/ECE-GY-9123-DL-final",
"path": "/Paper2PPT/baselines/mead/run_mead.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>""""
RSS源分类器及高频词去除函数
函数calcMostFreq() ❶。 该函数遍历词汇表中的每个词并统计它在文本中出现的次数, 然后根据出现次数从高到低对词典进行排序,
最后返回排序最高的30个单词。 你很快就会明白这个函数的重要性
以下四行) 计算出现频率
"""
def calcMostFreq(vocabList,fullText):
import operator
freqDict = {}
for token in vocabList:
freqDict[token]=fullText.count(token)
sortedFreq = ... | code_fim | hard | {
"lang": "python",
"repo": "HeiBoWang/machine_learning_in_action",
"path": "/Ch04/bayes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HeiBoWang/machine_learning_in_action path: /Ch04/bayes.py
# coding=utf-8
from numpy import *
""" 1
函数loadDataSet()创建了一些实验样本。 该函数返回的第一个变量是进行词条切分后的文档集合, 这些文档来自斑点犬爱好者留言
板。 这些留言文本被切分成一系列的词条集合, 标点符号从文本中去掉,
loadDataSet( )函数返回的第二个
变量是一个类别标签的集合。 这里有两类, 侮辱性和非侮辱性。 这些文本的类别由人工标注, 这些标注信息用于训练程序以便自动检测侮辱性留言
... | code_fim | hard | {
"lang": "python",
"repo": "HeiBoWang/machine_learning_in_action",
"path": "/Ch04/bayes.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oscar-mx/notes path: /Python/Python语言基础1:语法入门/3.运算符/06运算符优先级.py
# 运算符的优先级
# 和数学中一样,在Python运算也有优先级,比如先乘除 后加减
# 运算符的优先级可以根据优先级的表格来查询,
# 在表格中位置越靠下的运算符优先级越高,优先级越高的越优先计算
# 如果优先级一样则自左向右计算
# 关于优先级的表格,你知道有这么一个东西就够了,千万不要去记
# 在开发中如果遇到优先级不清楚的,则可以通过小括号来改变运算顺序
a = 1 + 2 * 3
<|fim_suffix|># print(a)
# ... | code_fim | medium | {
"lang": "python",
"repo": "oscar-mx/notes",
"path": "/Python/Python语言基础1:语法入门/3.运算符/06运算符优先级.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 逻辑运算符(补充)
# 逻辑运算符可以连着使用
result = 1 < 2 < 3 # 相当于 1 < 2 and 2 < 3
result = 10 < 20 > 15
print(result)<|fim_prefix|># repo: oscar-mx/notes path: /Python/Python语言基础1:语法入门/3.运算符/06运算符优先级.py
# 运算符的优先级
# 和数学中一样,在Python运算也有优先级,比如先乘除 后加减
# 运算符的优先级可以根据优先级的表格来查询,
# 在表格中位置越靠下的运算符优先级越高,优先级越高的越优先计算
# 如果优先级一样则自... | code_fim | easy | {
"lang": "python",
"repo": "oscar-mx/notes",
"path": "/Python/Python语言基础1:语法入门/3.运算符/06运算符优先级.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pgw928/TIL path: /algorithms/boj/dp/9657.py
import sys
n= int(sys.stdin.readline())
<|fim_suffix|> if k in dp:
return dp[k]
else:
for i in range(7, k+1):
if dp[i-3]=='SK' and dp[i-1]=='SK' and dp[i-4]=='SK':
dp[i] = 'CY'
else:
... | code_fim | medium | {
"lang": "python",
"repo": "pgw928/TIL",
"path": "/algorithms/boj/dp/9657.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if k in dp:
return dp[k]
else:
for i in range(7, k+1):
if dp[i-3]=='SK' and dp[i-1]=='SK' and dp[i-4]=='SK':
dp[i] = 'CY'
else:
dp[i] = 'SK'
return dp[k]
print(sol(n))<|fim_prefix|># repo: pgw928/TIL path: /algorithm... | code_fim | medium | {
"lang": "python",
"repo": "pgw928/TIL",
"path": "/algorithms/boj/dp/9657.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def sol(k):
if k in dp:
return dp[k]
else:
for i in range(7, k+1):
if dp[i-3]=='SK' and dp[i-1]=='SK' and dp[i-4]=='SK':
dp[i] = 'CY'
else:
dp[i] = 'SK'
return dp[k]
print(sol(n))<|fim_prefix|># repo: pgw928/TIL path... | code_fim | easy | {
"lang": "python",
"repo": "pgw928/TIL",
"path": "/algorithms/boj/dp/9657.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_topfiles(self):
topf = mrbump_util.ResultsSummary(results_pkl=os.path.join(self.testfiles_dir, AMPLE_PKL)).topFiles()
self.assertEqual(len(topf), 3)
self.assertEqual(topf[2]['info'], 'SHELXE trace of MR result')
if __name__ == "__main__":
unittest.main()<|fim_pre... | code_fim | hard | {
"lang": "python",
"repo": "rigdenlab/ample",
"path": "/ample/util/tests/test_mrbump_util.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> topf = mrbump_util.ResultsSummary(results_pkl=os.path.join(self.testfiles_dir, AMPLE_PKL)).topFiles()
self.assertEqual(len(topf), 3)
self.assertEqual(topf[2]['info'], 'SHELXE trace of MR result')
if __name__ == "__main__":
unittest.main()<|fim_prefix|># repo: rigdenlab/ample ... | code_fim | hard | {
"lang": "python",
"repo": "rigdenlab/ample",
"path": "/ample/util/tests/test_mrbump_util.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rigdenlab/ample path: /ample/util/tests/test_mrbump_util.py
"""Test functions for util.mrbump_util"""
import pickle
import os
import sys
import unittest
from ample.constants import AMPLE_PKL, SHARE_DIR
from ample.util import mrbump_util
<|fim_suffix|> topf = mrbump_util.ResultsSummary(r... | code_fim | hard | {
"lang": "python",
"repo": "rigdenlab/ample",
"path": "/ample/util/tests/test_mrbump_util.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # gpu share
#gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
# Launch the graph
newConfig = tf.ConfigProto()
newConfig.intra_op_parallelism_threads = num_intra_threads
with tf.Session(config=newConfig) as sess:
# with tf.Session() as sess:
sess.run(init)
# Fit all training da... | code_fim | hard | {
"lang": "python",
"repo": "lenhattan86/IRFimpl",
"path": "/tf_bench/scripts/tf_cnn_benchmarks/linear_regression.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nsgj/corePython path: /chapter6/6-10UpperToLower.py
def Return():
s = raw_input('Enter a s: ')
i = 0
s1 = ''
leng = len(s)
while i < leng:
if s[i] == s[i].lower():
s1 += s[i].upper()
else:
s1 += s[i].lower()
i += 1
<|fim... | code_fim | easy | {
"lang": "python",
"repo": "Nsgj/corePython",
"path": "/chapter6/6-10UpperToLower.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
print Return()<|fim_prefix|># repo: Nsgj/corePython path: /chapter6/6-10UpperToLower.py
def Return():
s = raw_input('Enter a s: ')
i = 0
s1 = ''
leng = len(s)
while i < leng:
if s[i] == s[i].lower():
s1 += s[i].upper()
e... | code_fim | easy | {
"lang": "python",
"repo": "Nsgj/corePython",
"path": "/chapter6/6-10UpperToLower.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/Gvoice-Glodon path: /Gvoice-api/tts.py
#-*-coding:utf-8 -*-
import subprocess
<|fim_suffix|>if __name__ == '__main__':
text = "我是聊天机器人"
get_audio(text)<|fim_middle|>def get_audio(text):
stat = subprocess.call(['./tts', text])
if stat == 0:
return "Success"
... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/Gvoice-Glodon",
"path": "/Gvoice-api/tts.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
text = "我是聊天机器人"
get_audio(text)<|fim_prefix|># repo: cash2one/Gvoice-Glodon path: /Gvoice-api/tts.py
#-*-coding:utf-8 -*-
import subprocess
def get_audio(text):
stat = subprocess.call(['./tts', text])
<|fim_middle|> if stat == 0:
return "Success"
... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/Gvoice-Glodon",
"path": "/Gvoice-api/tts.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ondevg/Algos_HAs path: /Ali_Baba_2.py
import random
def less(i1, i2):
return i1[0] * i2[1] < i2[0] * i1[1]
def equal(i1, i2):
return i1[0] * i2[1] == i2[0] * i1[1]
<|fim_suffix|> if r is None:
r = len(x)
if (r - l) > 1:
pivot = x[random.randint(l, r - 1)]
... | code_fim | hard | {
"lang": "python",
"repo": "ondevg/Algos_HAs",
"path": "/Ali_Baba_2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if r is None:
r = len(x)
if (r - l) > 1:
pivot = x[random.randint(l, r - 1)]
il, ir = partition(x, l, r, pivot)
qsort(x, l, il)
qsort(x, ir, r)
N, w = list(map(int, input().split()))
x = []
for i in range(N):
x.append(tuple(map(int, input().split())))
... | code_fim | hard | {
"lang": "python",
"repo": "ondevg/Algos_HAs",
"path": "/Ali_Baba_2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>N, w = list(map(int, input().split()))
x = []
for i in range(N):
x.append(tuple(map(int, input().split())))
qsort(x)
x = x[::-1]
s = 0
i = 0
while (i < N) and (w >= x[i][1]):
s += x[i][0]
w -= x[i][1]
i += 1
if i < N:
s += (x[i][0] * w // x[i][1])
print(s)<|fim_prefix|># repo: ondevg... | code_fim | medium | {
"lang": "python",
"repo": "ondevg/Algos_HAs",
"path": "/Ali_Baba_2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> post_id = request.POST.get('postId')
page = request.POST.get('page')
comments = Comment.objects.filter(post__id=post_id).order_by('-created_at')
comments = paginate_list(comments, page)
comments_html = loader.render_to_string(
'social/partials/comments.html',
{'co... | code_fim | hard | {
"lang": "python",
"repo": "nicholaskajoh/krak.lol",
"path": "/social/views/ajax.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nicholaskajoh/krak.lol path: /social/views/ajax.py
# views which respond to ajax requests
from django.contrib import messages
from django.conf import settings
from django.contrib.auth.models import User
from social.models import Like, Post, Comment, Notification
from social.notifications i... | code_fim | hard | {
"lang": "python",
"repo": "nicholaskajoh/krak.lol",
"path": "/social/views/ajax.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def context_answers(convos):
context,answers = [],[]
for convo in convos:
for index,line in enumerate(convo[:-1]):
context.append(line)
answers.append(convo[index+1])
assert len(context) == len(answers)
return context,answers
def _basic_t... | code_fim | hard | {
"lang": "python",
"repo": "johnsonice/Chatbot_seq2seq",
"path": "/seq2seq/data_util/weibo_single.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: johnsonice/Chatbot_seq2seq path: /seq2seq/data_util/weibo_single.py
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 09:54:08 2017
@author: chuang
"""
import os
import pickle
#from collections import Counter
#import user_replace
import jieba
import re
from multiprocessing import... | code_fim | hard | {
"lang": "python",
"repo": "johnsonice/Chatbot_seq2seq",
"path": "/seq2seq/data_util/weibo_single.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _tokenized_data(context,answers):
train_enc_tokens = [_basic_tokenizer(t) for t in context]
print('Train_enc_token done.')
train_dec_tokens = [_basic_tokenizer(t) for t in answers]
print('Train_dec_token done.')
return train_enc_tokens, train_dec_tokens
de... | code_fim | hard | {
"lang": "python",
"repo": "johnsonice/Chatbot_seq2seq",
"path": "/seq2seq/data_util/weibo_single.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def pourA(state):
(a, b) = state["state"]
global curId
curId += 1
ans = {
"state": (lambda x, y: (x + y - capB, capB)
if x + y > capB else (0, x + y))
(a, b),
"cost": state["cost"],
"id": cur... | code_fim | hard | {
"lang": "python",
"repo": "stechu/Courses",
"path": "/CSE573/measureWater.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stechu/Courses path: /CSE573/measureWater.py
#!/usr/bin/env python
'''
Generate tree search dot file
'''
import copy
# Colors supported by graphviz, in some pleasing order
colors = {
"fa": "brown",
"fb": "brown1",
"ea": "cadetblue",
"eb": "cadetblue1",
"pa": "orange",
... | code_fim | hard | {
"lang": "python",
"repo": "stechu/Courses",
"path": "/CSE573/measureWater.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def emptyB(state):
(a, b) = state["state"]
global curId
curId += 1
ans = {
"state": (a, 0),
"cost": state["cost"],
"id": curId,
"parent": state["id"],
"action": "eb",
"visited": copy.deepcopy(state[... | code_fim | hard | {
"lang": "python",
"repo": "stechu/Courses",
"path": "/CSE573/measureWater.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GreatHorizon/library path: /Controllers/StudentDebtsController.py
from Models.AdminPageModel import AdminPageModel
class StudentDebtsController:
def __init__(self, master, model, view):
self._master = master
self._model = model
self._view = view
def BackToAdmin... | code_fim | hard | {
"lang": "python",
"repo": "GreatHorizon/library",
"path": "/Controllers/StudentDebtsController.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def ReturnBooks(self, idCopies):
if (len(idCopies) > 0):
try:
id = self._model.GetStudentId(idCopies[0])
self._model.ReturnBooks(idCopies)
self._view.ClearTable()
studentDebts = self._model.GetStudentDebts(id)
... | code_fim | hard | {
"lang": "python",
"repo": "GreatHorizon/library",
"path": "/Controllers/StudentDebtsController.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c=a/b+0.5
c=int(c)
print(c)<|fim_prefix|># repo: Dearyyyyy/TCG path: /data/3922/AC_py/508717.py
# coding=utf-8
while True:
a,b=input().split()
a=float(a)
b=float(b)
if b<|fim_middle|>==0:
print("error")
else:
| code_fim | easy | {
"lang": "python",
"repo": "Dearyyyyy/TCG",
"path": "/data/3922/AC_py/508717.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>==0:
print("error")
else:
c=a/b+0.5
c=int(c)
print(c)<|fim_prefix|># repo: Dearyyyyy/TCG path: /data/3922/AC_py/508717.py
# coding=utf-8
while True:
a,b=input().s<|fim_middle|>plit()
a=float(a)
b=float(b)
if b | code_fim | easy | {
"lang": "python",
"repo": "Dearyyyyy/TCG",
"path": "/data/3922/AC_py/508717.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dearyyyyy/TCG path: /data/3922/AC_py/508717.py
# coding=utf-8
while True:
a,b=input().s<|fim_suffix|>==0:
print("error")
else:
c=a/b+0.5
c=int(c)
print(c)<|fim_middle|>plit()
a=float(a)
b=float(b)
if b | code_fim | easy | {
"lang": "python",
"repo": "Dearyyyyy/TCG",
"path": "/data/3922/AC_py/508717.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> GPIO.output(POWER_PIN, False)
def adc_to_temp(readout):
millivolts = readout * (3300.0 / 1024.0)
temp_c = ((millivolts - 100.0) / 10.0) - 40.0
return temp_c
if __name__ == "__main__":
HYGROMETER = 0
TEMP = 1
LIGHT = 2
spi_setup()
power_on()
time.sleep(PAUSE)
... | code_fim | hard | {
"lang": "python",
"repo": "avolkov/rpi-gardening",
"path": "/source/0004_light_temp_moisture.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avolkov/rpi-gardening path: /source/0004_light_temp_moisture.py
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
POWER_PIN = 21
SPICLK = 18
SPIMISO = 23
SPIMOSI = 24
SPICS = 25
PAUSE = 0.1
# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
def readadc(adcnum, clockpin, m... | code_fim | hard | {
"lang": "python",
"repo": "avolkov/rpi-gardening",
"path": "/source/0004_light_temp_moisture.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> shidu + "\nPM25: " + pm25 + "\nPM10: " + pm10 + "\n空气质量: " + quality + \
"\n风力风向: " + fx + fl + "\n感冒指数: " + ganmao + "\n温馨提示: " + tips + "\n更新时间: " + update_time
print(tdwt)
requests.post(cpurl, tdwt.encode('utf-8')) # 把天气数据转换成UTF-8格式,不然要报错。
except:... | code_fim | hard | {
"lang": "python",
"repo": "cumthxy/cron_iob",
"path": "/tianqi.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cumthxy/cron_iob path: /tianqi.py
import requests
# qq推送 申请参考https://cp.xuthus.cc/
key = ''
def main():
try:
api = 'http://t.weather.itboy.net/api/weather/city/' # API地址,必须配合城市代码使用
city_code = '101070201' # 进入https://where.heweather.com/index.html查询你的城市代码
tqurl = ap... | code_fim | hard | {
"lang": "python",
"repo": "cumthxy/cron_iob",
"path": "/tianqi.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lemartin19/spotify-visualization path: /flaskr/auth.py
from base64 import b64encode
from configparser import ConfigParser
import functools
from flask import (
Blueprint, flash, redirect, render_template, request, session, url_for, app
)
from requests.exceptions import SSLError
import spotipy
... | code_fim | hard | {
"lang": "python",
"repo": "lemartin19/spotify-visualization",
"path": "/flaskr/auth.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
: Clear session and log user out
: PARAMS None
: RETURN <view>
'''
session.clear()
return redirect(url_for('home'))
def login_required(view):
@functools.wraps(view)
def wrapped_view(**kwargs):
if 'refresh' in session:
refresh = SP_OAUTH.refresh... | code_fim | hard | {
"lang": "python",
"repo": "lemartin19/spotify-visualization",
"path": "/flaskr/auth.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># options for countdown timer
fontFace = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 1
thickness = 4
countdownSeconds = 5
displayPhotoSeconds = 5
# Set up WebCam
width = 640
height = 480
cam = cv2.VideoCapture(0)
cam.set(3,width)
cam.set(4,height)
bgNumber = 0
new_img_nums = random.sample(range(1,9), 4)
bg =... | code_fim | hard | {
"lang": "python",
"repo": "RosemanJ/pibooth",
"path": "/pibooth_test2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while(True):
img = GetImage(bg) #get masked image from webcam
key = cv2.waitKey(1) #check for keypress
if clicked == True : # if countdown timer started
elapsed = datetime.datetime.now() - clickedTime
secs = int(elapsed.total_seconds())
if secs > countdownSeconds : # i... | code_fim | hard | {
"lang": "python",
"repo": "RosemanJ/pibooth",
"path": "/pibooth_test2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RosemanJ/pibooth path: /pibooth_test2.py
import numpy as np
import cv2
import datetime
import random
# from random import randint
import time
import logging
def GetDateTimeString():
dt = str(datetime.datetime.now()).split(".")[0]
clean = dt.replace(" ","_").replace(":","_")
return cl... | code_fim | hard | {
"lang": "python",
"repo": "RosemanJ/pibooth",
"path": "/pibooth_test2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kobeomseok95/codingTest path: /boj/gold/14725.py
from sys import stdin
read = lambda: stdin.readline().strip()
class Trie:
def __init__(self, me, parent=None):
self.me = me
self.parent = parent
self.children = {}
def get_answer(trie, count):
print(("--" * count... | code_fim | hard | {
"lang": "python",
"repo": "kobeomseok95/codingTest",
"path": "/boj/gold/14725.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> trie_dict = dict(sorted(trie_dict.items(), key=lambda x: x[0]))
for k in trie_dict.keys():
get_answer(trie_dict[k], 0)
if __name__ == "__main__":
main()<|fim_prefix|># repo: kobeomseok95/codingTest path: /boj/gold/14725.py
from sys import stdin
read = lambda: stdin.readline().strip(... | code_fim | hard | {
"lang": "python",
"repo": "kobeomseok95/codingTest",
"path": "/boj/gold/14725.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rmit-s3740446-Ryan-Cassidy/PIoT-Assignment-1 path: /electronicDie.py
from sense_hat import SenseHat
import time
import random
#Set game_mode to True for single roll returning value
#False for demonstration purposes
class ElectronicDie:
def __init__(self, mode):
self.game_mode = mode
... | code_fim | hard | {
"lang": "python",
"repo": "rmit-s3740446-Ryan-Cassidy/PIoT-Assignment-1",
"path": "/electronicDie.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.