text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>def runcommands(cs, ts, ps, serials, verbose = False, profiling = False):
""" Runs a series of commands at certain specified times """
if len(ts) == len(cs):
i = 0
t0 = time.time()
dt = time.time() - t0 # elapsed time
while i < len(cs):
ser = seri... | code_fim | hard | {
"lang": "python",
"repo": "carllacan/serialseries",
"path": "/serialseries.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>1
if o == 'S':
print("%.1f"%s)
if o == 'M':
print("%.1f"%(s/66))<|fim_prefix|># repo: arfoysal/URI-Online-Judge-Problem-Solve-Python-and-C path: /uri 1184 - Below the Main Diagonal.py
o = input()
v = []
s = 0
for i in range(12):
col = []
for j in range(12):
col.append(float(input(... | code_fim | medium | {
"lang": "python",
"repo": "arfoysal/URI-Online-Judge-Problem-Solve-Python-and-C",
"path": "/uri 1184 - Below the Main Diagonal.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arfoysal/URI-Online-Judge-Problem-Solve-Python-and-C path: /uri 1184 - Below the Main Diagonal.py
o = input()
v = []
s = 0
for i in range(12):
col = []
for j in <|fim_suffix|>r i in range(1, 12):
for j in range(a):
s += v[i][j]
a+=1
if o == 'S':
print("%.1f"%s)
if o ==... | code_fim | medium | {
"lang": "python",
"repo": "arfoysal/URI-Online-Judge-Problem-Solve-Python-and-C",
"path": "/uri 1184 - Below the Main Diagonal.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jfreder10/Playground path: /MLmodels/HeartData/HeartDiseasePredAppScratch.py
import sklearn
import pandas as pd
import numpy as np
from sklearn import datasets, ensemble
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
import statistics ... | code_fim | hard | {
"lang": "python",
"repo": "jfreder10/Playground",
"path": "/MLmodels/HeartData/HeartDiseasePredAppScratch.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#plot two densities centered on the mean of the var and the selected value of the var for all vars
#start with treating each var as a normal distro then plot a density curve where the
#mean is the mean of the var and another curve on same plot where the mean is the selected value from the input of a n... | code_fim | hard | {
"lang": "python",
"repo": "jfreder10/Playground",
"path": "/MLmodels/HeartData/HeartDiseasePredAppScratch.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#plot two densities centered on the mean of the var and the selected value of the var for all vars
#start with treating each var as a normal distro then plot a density curve where the
#mean is the mean of the var and another curve on same plot where the mean is the selected value from the input of a... | code_fim | hard | {
"lang": "python",
"repo": "jfreder10/Playground",
"path": "/MLmodels/HeartData/HeartDiseasePredAppScratch.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AndreiCostinescu/Modulo path: /App/JungeAkademie/modulo/apps.py
from django.apps import AppConfig
<|fim_suffix|> name = 'modulo'
verbose_name = 'TUM:JungeAkademie - Modulo'
def ready(self):
#start-up / initialization code here!!!
from .recommender import Recommen... | code_fim | easy | {
"lang": "python",
"repo": "AndreiCostinescu/Modulo",
"path": "/App/JungeAkademie/modulo/apps.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #start-up / initialization code here!!!
from .recommender import Recommender
Recommender.initialize()<|fim_prefix|># repo: AndreiCostinescu/Modulo path: /App/JungeAkademie/modulo/apps.py
from django.apps import AppConfig
class ModuloConfig(AppConfig):
<|fim_middle|> name = 'm... | code_fim | medium | {
"lang": "python",
"repo": "AndreiCostinescu/Modulo",
"path": "/App/JungeAkademie/modulo/apps.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: APSDetectors/qtGSD path: /qtGSD_DESIGN.py
izePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth())
self.groupBox_2.setSizePolicy(sizePolicy)
self.groupBox_2.setMinimumSize(QtCore.QSize(100, 225))
font = QtGui.QF... | code_fim | hard | {
"lang": "python",
"repo": "APSDetectors/qtGSD",
"path": "/qtGSD_DESIGN.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: APSDetectors/qtGSD path: /qtGSD_DESIGN.py
i.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
... | code_fim | hard | {
"lang": "python",
"repo": "APSDetectors/qtGSD",
"path": "/qtGSD_DESIGN.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tGui.QComboBox(self.horizontalLayoutWidget_2)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth())
... | code_fim | hard | {
"lang": "python",
"repo": "APSDetectors/qtGSD",
"path": "/qtGSD_DESIGN.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#class Item(db.Model):
# id = db.Column(db.Integer, primary_key = True)
# product = db.Column(db.String(200))
# price = db.Column(db.Integer)<|fim_prefix|># repo: sirfmt/webstore path: /edits_scaps/edits.py
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
#app.config['SQLALCHEMY_TRAC... | code_fim | hard | {
"lang": "python",
"repo": "sirfmt/webstore",
"path": "/edits_scaps/edits.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sirfmt/webstore path: /edits_scaps/edits.py
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
#app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True;
#db = SQLAlchemy(app)
<|fim_suffix|>#Getting the database instance
db = client['mydb']
print("Database created........")
#Verification
... | code_fim | medium | {
"lang": "python",
"repo": "sirfmt/webstore",
"path": "/edits_scaps/edits.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ewinata/RaspberryPi_internship path: /RPi/module/serial/gps_decoder.py
def ddm_dd_convert(coord, direction):
"""Converts GPS reading from DDM to DD
str coord - the ddm coordinate from $GPGGA
str direction - the direction of the coord (N,S,W,E)
returns - string rep... | code_fim | hard | {
"lang": "python",
"repo": "ewinata/RaspberryPi_internship",
"path": "/RPi/module/serial/gps_decoder.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Translates $GPGSA line into documented array
str line - the GPGSA line
returns - the data documented into array
"""
gps = line.strip().split(',')
#check data
if gps[2] == '1':
return
if gps[2] == '2':
fix = '2D fix'
else:
fix ... | code_fim | hard | {
"lang": "python",
"repo": "ewinata/RaspberryPi_internship",
"path": "/RPi/module/serial/gps_decoder.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VibhuJawa/cudf path: /python/cudf/setup.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION.
import os
import shutil
import subprocess
import sys
import sysconfig
from distutils.spawn import find_executable
from distutils.sysconfig import get_python_lib
import numpy as np
import pyarrow as pa
from ... | code_fim | hard | {
"lang": "python",
"repo": "VibhuJawa/cudf",
"path": "/python/cudf/setup.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
cmdclass["build_ext"] = build_ext_and_proto
extensions = [
Extension(
"*",
sources=cython_files,
include_dirs=[
"../../cpp/include/cudf",
"../../cpp/include",
os.path.join(CUDF_ROOT, "include"),
os.path.join(CUDF_ROOT, "_deps/li... | code_fim | hard | {
"lang": "python",
"repo": "VibhuJawa/cudf",
"path": "/python/cudf/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for type_ in TYPES:
pre = 'from __main__ import {}, a, b, c'.format(type_.__name__)
body = '{}(a, b, c)'.format(type_.__name__)
print('\t', type_.__name__, timeit.repeat(stmt=body, setup=pre, repeat=5))
def test_immut():
'''Verifies that the type called SimpleObjectImmuta... | code_fim | medium | {
"lang": "python",
"repo": "androm3da/struct_bench",
"path": "/comparison.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> q = SimpleObjectImmutable(a, b, c)
SimpleObjectImmutable.__setattr__ = read_only
try:
q.a = 1
assert(False)
except ValueError:
assert(True)
if __name__ == '__main__':
measure_creation()
test_immut()<|fim_prefix|># repo: androm3da/struct_bench path: /compa... | code_fim | hard | {
"lang": "python",
"repo": "androm3da/struct_bench",
"path": "/comparison.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pingf/schemathesis path: /src/schemathesis/extra/pytest_plugin.py
from typing import Any, Callable, Generator, List, Optional
import pytest
from _pytest import nodes
from _pytest.config import hookimpl
from _pytest.python import Function, PyCollector # type: ignore
from hypothesis.errors import... | code_fim | hard | {
"lang": "python",
"repo": "pingf/schemathesis",
"path": "/src/schemathesis/extra/pytest_plugin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class SchemathesisCase(PyCollector):
def __init__(self, test_function: Callable, *args: Any, **kwargs: Any) -> None:
self.test_function = test_function
self.schemathesis_case = test_function._schemathesis_test # type: ignore
super().__init__(*args, **kwargs)
def _get_tes... | code_fim | hard | {
"lang": "python",
"repo": "pingf/schemathesis",
"path": "/src/schemathesis/extra/pytest_plugin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Generate all items for the given endpoint.
Could produce more than one test item if
parametrization is applied via ``pytest.mark.parametrize`` or ``pytest_generate_tests``.
"""
try:
hypothesis_item = create_test(endpoint, self.test_function)
... | code_fim | hard | {
"lang": "python",
"repo": "pingf/schemathesis",
"path": "/src/schemathesis/extra/pytest_plugin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NRCANTerry/snow-depth path: /Include/calculate_depth.py
# import necessary modules
import cv2
import xlsxwriter
import statistics
from matplotlib import pyplot as plt
import math
import tqdm
import numpy as np
import datetime
def getDepths(imgs, img_names, intersectionCoords, stakeValidity, temp... | code_fim | hard | {
"lang": "python",
"repo": "NRCANTerry/snow-depth",
"path": "/Include/calculate_depth.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # remove negative values
filterSet = zip(median_depths, median_depths_est, image_dates)
filterSet = [(x, y, z) for x, y, z in filterSet if x != False]
median_depths, median_depths_est, image_dates = zip(*filterSet)
median_depths = np.asarray(median_depths).clip(0)
median_depths_est... | code_fim | hard | {
"lang": "python",
"repo": "NRCANTerry/snow-depth",
"path": "/Include/calculate_depth.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual("I have some docs", docs.__doc__)
hooked = self._callFUT(docs)
self.assertEqual(hooked.__doc__, docs.__doc__)
def test_preserves_doc_function(self):
def docs():
"""I have some docs"""
self._check_preserves_doc(docs)
def test_p... | code_fim | hard | {
"lang": "python",
"repo": "zopefoundation/zope.hookable",
"path": "/src/zope/hookable/tests/test_hookable.py",
"mode": "spm",
"license": "ZPL-2.1",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zopefoundation/zope.hookable path: /src/zope/hookable/tests/test_hookable.py
##############################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Pu... | code_fim | hard | {
"lang": "python",
"repo": "zopefoundation/zope.hookable",
"path": "/src/zope/hookable/tests/test_hookable.py",
"mode": "psm",
"license": "ZPL-2.1",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Turtlefromocean/Codeit path: /CodeitPython/practice/quiz_word_test.py
with open('vocabulary.txt', 'r') as f:
for line in f:
information = line.strip().split(': ')
# print(information[0], information[1])
question = information[1]
<|fim_suffix|> answer:
pr... | code_fim | medium | {
"lang": "python",
"repo": "Turtlefromocean/Codeit",
"path": "/CodeitPython/practice/quiz_word_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> answer:
print('맞았습니다!')
else:
print(f'아쉽습니다. 정답은 {answer}입니다.')<|fim_prefix|># repo: Turtlefromocean/Codeit path: /CodeitPython/practice/quiz_word_test.py
with open('vocabulary.txt', 'r') as f:
for line in f:
information = line.strip().sp<|fim_middle|>lit(': '... | code_fim | medium | {
"lang": "python",
"repo": "Turtlefromocean/Codeit",
"path": "/CodeitPython/practice/quiz_word_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Es contorno de tomate?")
c=cv2.waitKey(0) & 0xFF
if (c==ord("t") ):
print("Histograma guardado como valido")
if (c==ord("n") ):
print("Histograma guardado como no valido")
cv2.destroyAllWindows()<|fim_prefix|># repo: nicodblay/contorno pa... | code_fim | hard | {
"lang": "python",
"repo": "nicodblay/contorno",
"path": "/contorne4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nicodblay/contorno path: /contorne4.py
import cv2
import numpy as np
from matplotlib import pyplot as plt
#cargar la imagen a analizar
imagen= cv2.imread("tomate22.jpg")
#cv2.imshow("Original", imagen)
#cv2.waitKey(0)
# Convertimos en escala de grise
gris = cv2.cvtColor(imagen, cv2.COLOR_BGR2G... | code_fim | hard | {
"lang": "python",
"repo": "nicodblay/contorno",
"path": "/contorne4.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>cv2.drawContours(imagen,contornos,-1,(255,0,0), 2)
cv2.imshow("contornos", imagen)
cv2.waitKey(0)
for x in range (len(contornos)):
#mascara
mask=np.zeros_like(imagen)
out=np.zeros_like(imagen)
cv2.drawContours(mask, [contornos[x]], 0, (255,0,0), -1) #con ese -1 al final hace que pint... | code_fim | hard | {
"lang": "python",
"repo": "nicodblay/contorno",
"path": "/contorne4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mjs0031/Course-Comp-6000-Term path: /Data_Base/Data/Imports/child_import.py
""" Python Package Support """
# Not applicable
""" Django Package Support """
# Not applicable
""" Internal Package Support """
from Data_Base.models import School, Person, Child
"""
Data_Base/Data/Imports/child_impo... | code_fim | hard | {
"lang": "python",
"repo": "mjs0031/Course-Comp-6000-Term",
"path": "/Data_Base/Data/Imports/child_import.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 6
x = Child.objects.create(
first_name = 'Jasmine',
last_name = 'Goulette',
school = School.objects.get(pk=6),
)
x.family.add(Person.objects.get(pk=6))
x.family.add... | code_fim | hard | {
"lang": "python",
"repo": "mjs0031/Course-Comp-6000-Term",
"path": "/Data_Base/Data/Imports/child_import.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 3
x = Child.objects.create(
first_name = 'Bart',
last_name = 'Simpson',
school = School.objects.get(pk=3),
)
x.family.add(Person.objects.get(pk=3))
x.family.add(Per... | code_fim | hard | {
"lang": "python",
"repo": "mjs0031/Course-Comp-6000-Term",
"path": "/Data_Base/Data/Imports/child_import.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2.)**2 + cos(lat1) * cos(lat2) * sin(dlon/2.)**2
c = 2 * asin(sqrt(a))
r = 6371 # Radius of earth in kilometers. Use 3956 for miles
return c * r
def get_closest_shape_pt(lat, lon, shape):
dist = shape.a... | code_fim | hard | {
"lang": "python",
"repo": "sidetrackedmind/seattle-bustime",
"path": "/nearest_station.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c = haversine(seg_pt_1, seg_pt_2)
b = haversine(seg_pt_1, pt)
a = haversine(seg_pt_2, pt)
num1 = (b**2 + c**2 - a**2)
num2 = (a**2 + c**2 - b**2)
if (num1 < 0) or (num2 < 0):
return min(a, b)
theta = acos( num1 / (2.*b*c))
h = b * sin(theta)
return h<|fim_pr... | code_fim | medium | {
"lang": "python",
"repo": "sidetrackedmind/seattle-bustime",
"path": "/nearest_station.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sidetrackedmind/seattle-bustime path: /nearest_station.py
#grabbed the following from moses marsh -- https://github.com/sidetrackedmind/gimme-bus/blob/master/gimmebus/utilities.py
from datetime import datetime as dt
from math import radians, cos, sin, acos, asin, sqrt
import networkx as nx
## T... | code_fim | hard | {
"lang": "python",
"repo": "sidetrackedmind/seattle-bustime",
"path": "/nearest_station.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: varenius/oso path: /MISC/checkdata.py
#!/usr/bin/python
import socket, os, datetime, time, re, sys
import numpy as np
import matplotlib.pyplot as plt
from baseband import vdif
import astropy.units as u
from scipy.signal import resample_poly
import matplotlib.patches as patches
def fbcmd(message)... | code_fim | hard | {
"lang": "python",
"repo": "varenius/oso",
"path": "/MISC/checkdata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DEBUG=False# Print jive5ab return messages, which are parsed for results
ifs2plot = [0,1,2,3,4,5,6,7] # List IFs to plot, starting from 0.
#Plot design
nrows = 8
ncols = bbcsperIF
extractiontime = "0.01s" # At least 0.01s
iflabels = ["A", "B", "C", "D", "E", "F", "G", "H"]
plt.rcParams.update({'font.si... | code_fim | hard | {
"lang": "python",
"repo": "varenius/oso",
"path": "/MISC/checkdata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: klim1286/PythonBasics path: /unit1-1.py
y = 10
x = 'Тишь да гладь'
print(f'Текст:{x}')
print(f'Число:{y}')
a1 = input('Введите первое число: ')
a2 = input('Введите второе число: ')
b1 =<|fim_suffix|>rint(f'Вы ввели числа: {a1}/{a2}')
print(f'Вы ввели строки: {b1} / {b2}')<|fim_middle|> input('Вве... | code_fim | medium | {
"lang": "python",
"repo": "klim1286/PythonBasics",
"path": "/unit1-1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rint(f'Вы ввели числа: {a1}/{a2}')
print(f'Вы ввели строки: {b1} / {b2}')<|fim_prefix|># repo: klim1286/PythonBasics path: /unit1-1.py
y = 10
x = 'Тишь да гладь'
print(f'Текст:{x}')
print(f'Число:{y}')
a1 = input('Введите первое число: ')
a2 = input('Введите второе число: ')
b1 =<|fim_middle|> input('Вве... | code_fim | medium | {
"lang": "python",
"repo": "klim1286/PythonBasics",
"path": "/unit1-1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input('Введите первую строку: ')
b2 = input('Введите вторую строку: ')
print(f'Вы ввели числа: {a1}/{a2}')
print(f'Вы ввели строки: {b1} / {b2}')<|fim_prefix|># repo: klim1286/PythonBasics path: /unit1-1.py
y = 10
x = 'Тишь да гладь'
print(f'Текст:{x}')
print(f'Число:{y}')
a1 = <|fim_middle|>input('Введ... | code_fim | medium | {
"lang": "python",
"repo": "klim1286/PythonBasics",
"path": "/unit1-1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
read=c.readlines()
print read
c.close()<|fim_prefix|># repo: KingShineK/crawler path: /study/delete_data.py
# _*_ coding:utf-8 _*_
import csv
c=op<|fim_middle|>en(r"e:/test.csv","r+")
#read=csv.reader(c)
#for line in read:
# print line | code_fim | medium | {
"lang": "python",
"repo": "KingShineK/crawler",
"path": "/study/delete_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KingShineK/crawler path: /study/delete_data.py
# _*_ coding:utf-8 _*_
import csv
c=open(r"e:/test.csv","r+")
#read=csv.reade<|fim_suffix|>
read=c.readlines()
print read
c.close()<|fim_middle|>r(c)
#for line in read:
# print line | code_fim | easy | {
"lang": "python",
"repo": "KingShineK/crawler",
"path": "/study/delete_data.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if direction == 'RIGHT':
x_change = 10
y_change = 0
elif direction == 'LEFT':
x_change = -10
y_change = 0
elif direction == 'UP':
x_change = 0
y_change = -10
elif direction == 'DOWN':
x_chan... | code_fim | hard | {
"lang": "python",
"repo": "bambaw/pygame-tron",
"path": "/PYGAME TRON/SNAKE CODE/bit Snake/game.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> countdown = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
r... | code_fim | hard | {
"lang": "python",
"repo": "bambaw/pygame-tron",
"path": "/PYGAME TRON/SNAKE CODE/bit Snake/game.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bambaw/pygame-tron path: /PYGAME TRON/SNAKE CODE/bit Snake/game.py
#! /usr/bin/env python
from game_calc import *
def game(screen, clock):
running = True
time = 0
WHITE = (255,255,255)
BLUE = (0,0,205)
upper_border = pygame.Rect(12,44,1000,20)
right_border = pygame.Rect(9... | code_fim | hard | {
"lang": "python",
"repo": "bambaw/pygame-tron",
"path": "/PYGAME TRON/SNAKE CODE/bit Snake/game.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a, b = map(int,input().split())
myswap(a,b)<|fim_prefix|># repo: JinleeJeong/Algorithm path: /20년 3월/1581.py
def myswap(a, b):
<|fim_middle|> temp = a
a = b
b = temp
if a < b:
print(a, b)
else:
print(b, a)
| code_fim | medium | {
"lang": "python",
"repo": "JinleeJeong/Algorithm",
"path": "/20년 3월/1581.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JinleeJeong/Algorithm path: /20년 3월/1581.py
def myswap(a, b):
<|fim_suffix|>a, b = map(int,input().split())
myswap(a,b)<|fim_middle|> temp = a
a = b
b = temp
if a < b:
print(a, b)
else:
print(b, a)
| code_fim | medium | {
"lang": "python",
"repo": "JinleeJeong/Algorithm",
"path": "/20년 3월/1581.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lorena-ReyF/CursoPythonOctubre2019 path: /Clase021119/RecibirDatosDeArduino.py
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 2 08:04:11 2019
<|fim_suffix|>for i in range(100):
lectura.append(arduino.readline())
arduino.close()
print(lectura)<|fim_middle|>@author: yocoy
"""
import serial,... | code_fim | medium | {
"lang": "python",
"repo": "Lorena-ReyF/CursoPythonOctubre2019",
"path": "/Clase021119/RecibirDatosDeArduino.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(100):
lectura.append(arduino.readline())
arduino.close()
print(lectura)<|fim_prefix|># repo: Lorena-ReyF/CursoPythonOctubre2019 path: /Clase021119/RecibirDatosDeArduino.py
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 2 08:04:11 2019
<|fim_middle|>@author: yocoy
"""
import serial,... | code_fim | medium | {
"lang": "python",
"repo": "Lorena-ReyF/CursoPythonOctubre2019",
"path": "/Clase021119/RecibirDatosDeArduino.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joez/letspy path: /lang/data/superset.py
#!/usr/bin/env python3
# given a set A and n other sets.
# find whether <|fim_suffix|>input())):
b.append(A > set(map(int, input().split())))
print(all(b))<|fim_middle|>set A is a strict superset of each of the n sets
# print True if yes, otherwise F... | code_fim | medium | {
"lang": "python",
"repo": "joez/letspy",
"path": "/lang/data/superset.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rwise False
A = set(map(int, input().split()))
b = []
for _ in range(int(input())):
b.append(A > set(map(int, input().split())))
print(all(b))<|fim_prefix|># repo: joez/letspy path: /lang/data/superset.py
#!/usr/bin/env python3
# given a set A and n other sets.
# find whether <|fim_middle|>set A i... | code_fim | medium | {
"lang": "python",
"repo": "joez/letspy",
"path": "/lang/data/superset.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cloudify-PS/cloudify-agent path: /cloudify_agent/tests/installer/test_operations.py
#########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License... | code_fim | hard | {
"lang": "python",
"repo": "Cloudify-PS/cloudify-agent",
"path": "/cloudify_agent/tests/installer/test_operations.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @only_ci
@patch('cloudify.workflows.local._validate_node')
@patch.dict('agent_packager.logger.LOGGER',
disable_existing_loggers=False)
def test_local_agent_from_source(self, _):
agent_name = utils.internal.generate_agent_name()
agent_queue = '{0}-queue'.for... | code_fim | hard | {
"lang": "python",
"repo": "Cloudify-PS/cloudify-agent",
"path": "/cloudify_agent/tests/installer/test_operations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dcragusa/LeetCode path: /100-199/100-109/101.py
"""
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Example 1:
<|fim_suffix|> def helper(left, right):
if left is None and right is None:
return True
elif ... | code_fim | hard | {
"lang": "python",
"repo": "dcragusa/LeetCode",
"path": "/100-199/100-109/101.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
assert is_symmetric(list_to_tree([1, 2, 2, 3, 4, 4, 3])) is True
assert is_symmetric(list_to_tree([1, 2, 2, None, 3, None, 3])) is False
assert is_symmetric(list_to_tree([1, 2, 2, None, 2, None])) is False
assert is_symmetric(list_to_tree([1, 2, 3])) is False<|fim_prefix|># repo: dcragusa/LeetCode path:... | code_fim | hard | {
"lang": "python",
"repo": "dcragusa/LeetCode",
"path": "/100-199/100-109/101.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #published_data를 지금날짜로 바꾸고 save
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title<|fim_prefix|># repo: ssh6189/2020.02.21 path: /mysite/blog/models.py
# Create your models here.
from django.db import models
from django.utils import ... | code_fim | hard | {
"lang": "python",
"repo": "ssh6189/2020.02.21",
"path": "/mysite/blog/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ssh6189/2020.02.21 path: /mysite/blog/models.py
# Create your models here.
from django.db import models
from django.utils import timezone
from django.db import models
# Create your models here.
#필드 개수가 다르다.
<|fim_suffix|> def publish(self):
#published_data를 지금날짜로 바꾸고 save
sel... | code_fim | hard | {
"lang": "python",
"repo": "ssh6189/2020.02.21",
"path": "/mysite/blog/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robertbjornson/utils path: /scanFilesBySuf.py
import os, sys
top=sys.argv[1]
max=int(sys.argv[2])
cnts={}
for d, dirs, files in os.walk(top):
for f in files:
i=f.find(".")
if i ==-1: i=0
suf=f[i:]
rec=cnts.setdefault(suf, [0,0])
fn=d+'/'+f
i... | code_fim | medium | {
"lang": "python",
"repo": "robertbjornson/utils",
"path": "/scanFilesBySuf.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for sz, cnt, suf in sorted([(cnts[k][1], cnts[k][0], k) for k in cnts], reverse=True)[:max]:
print ("%s\t%d\t%.3f" % (suf, cnt, sz))<|fim_prefix|># repo: robertbjornson/utils path: /scanFilesBySuf.py
import os, sys
top=sys.argv[1]
max=int(sys.argv[2])
cnts={}
for d, dirs, files in os.walk(top):
... | code_fim | medium | {
"lang": "python",
"repo": "robertbjornson/utils",
"path": "/scanFilesBySuf.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def refresh(self):
self.color(random.choice(colors))
self.goto(random.randint(-280, 280), random.randint(-280, 280))<|fim_prefix|># repo: alvarogutierrezvalle/Snake-Game path: /Food.py
import random
from turtle import Turtle
colors = ["red", "blue", 'green', 'peru', 'purple', 'pink',... | code_fim | medium | {
"lang": "python",
"repo": "alvarogutierrezvalle/Snake-Game",
"path": "/Food.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alvarogutierrezvalle/Snake-Game path: /Food.py
import random
from turtle import Turtle
colors = ["red", "blue", 'green', 'peru', 'purple', 'pink', 'chocolate', 'grey', 'cyan', 'brown']
<|fim_suffix|> def refresh(self):
self.color(random.choice(colors))
self.goto(random.randi... | code_fim | hard | {
"lang": "python",
"repo": "alvarogutierrezvalle/Snake-Game",
"path": "/Food.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> guild_channels = [dow_bot.get_guild(guild_id) for guild_id in guild_ids]
for guild_channel in guild_channels:
try:
red = get(guild_channel.roles, name='RED')
green = get(guild_channel.roles, name='GREEN')
if "-" in watching_dow:
... | code_fim | hard | {
"lang": "python",
"repo": "epeenphrine/live-ticker-bots",
"path": "/bot/live_ticker_bots.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: epeenphrine/live-ticker-bots path: /bot/live_ticker_bots.py
from discord.ext import commands, tasks
from discord.utils import get
import discord
import re
import json
import time
import random
import asyncio
import os
import datetime
from live_ticker_scrape import wrangle_data
from tokens impo... | code_fim | hard | {
"lang": "python",
"repo": "epeenphrine/live-ticker-bots",
"path": "/bot/live_ticker_bots.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>common.assertEquals(digits(125874), digits(251748))
def same_digits_as_multiples(x, multiples):
d = digits(x)
# duplicate digits are implicitly forbidden
if len(d) != len(str(x)): return False
for i in multiples:
if d != digits(i*x):
return False
return True
common.assertEquals(Tru... | code_fim | medium | {
"lang": "python",
"repo": "durandal42/project-euler",
"path": "/p052.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: durandal42/project-euler path: /p052.py
'''It can be seen that the number, 125874, and its double, 251748, contain
exactly the same digits, but in a different order.
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain
the same digits.
'''
import common
import iterto... | code_fim | hard | {
"lang": "python",
"repo": "durandal42/project-euler",
"path": "/p052.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OneGov/onegov-cloud path: /src/onegov/core/utils.py
ile(r'[\.\(\)\\/\s<>\[\]{},:;?!@&=+$#@%|\*"\'`]+')
_double_dash = re.compile(r'[-]+')
_number_suffix = re.compile(r'-([0-9]+)$')
_repeated_spaces = re.compile(r'\s\s+')
_uuid = re.compile(
r'^[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{4... | code_fim | hard | {
"lang": "python",
"repo": "OneGov/onegov-cloud",
"path": "/src/onegov/core/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> This only works for external URLs! If posting to server itself is
needed, use a process instead of the thread!
"""
def __init__(
self,
url: str,
data: bytes,
headers: 'Collection[tuple[str, str]]',
timeout: float = 30
):
Thread.__init__... | code_fim | hard | {
"lang": "python",
"repo": "OneGov/onegov-cloud",
"path": "/src/onegov/core/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def is_subpath(directory: str, path: str) -> bool:
""" Returns true if the given path is inside the given directory. """
directory = os.path.join(os.path.realpath(directory), '')
path = os.path.realpath(path)
# return true, if the common prefix of both is equal to directory
# e.g. /a... | code_fim | hard | {
"lang": "python",
"repo": "OneGov/onegov-cloud",
"path": "/src/onegov/core/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret = []
pos = 0
for l in contents:
ls = l.strip()
if ls.startswith('(') and ls.endswith(')'):
label = ls[1:-1]
if label in self.symbols:
raise ParseError('Label redefinition')
else:
... | code_fim | hard | {
"lang": "python",
"repo": "alexryndin/nand2tetris",
"path": "/06/assembler.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexryndin/nand2tetris path: /06/assembler.py
#!/usr/bin/python
import sys
import os
class ParseError(Exception):
pass
def remove_inline_comments(text):
ret = []
in_comment_block = False
p = 0
while True:
if (op := text.find('/*', p)) > 0:
in_comment_b... | code_fim | hard | {
"lang": "python",
"repo": "alexryndin/nand2tetris",
"path": "/06/assembler.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GaiYu0/f1 path: /multi.py
import argparse
import tensorboardX as tb
import torch as th
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data as D
import data
import mlp
import resnet
import utils
parser = argparse.ArgumentParser()
parser.add_argument('--bst', nargs=... | code_fim | hard | {
"lang": "python",
"repo": "GaiYu0/f1",
"path": "/multi.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if args.tb:
path = 'tb/%s' % args.id
writer = tb.SummaryWriter(path)
train_writer = tb.SummaryWriter(path + '/a')
val_writer = tb.SummaryWriter(path + '/b')
test_writer = tb.SummaryWriter(path + '/c')
def infer(loader, model):
yy = []
y_barr = []
for x, y in loader:
... | code_fim | hard | {
"lang": "python",
"repo": "GaiYu0/f1",
"path": "/multi.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(args.ni):
xx = [next(loader)[0].to(dev) for loader in train_loaders]
x = th.cat(xx)
utils.train(model)
z = F.softmax(model(x), 1)
zz = th.split(z, [len(x) for x in xx])
pneg_list = [1 - th.mean(z[:, i]) for i, z in enumerate(zz)]
fnfn = [p_class * p_neg for p_cla... | code_fim | hard | {
"lang": "python",
"repo": "GaiYu0/f1",
"path": "/multi.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return table, dates
def _create_table_for_chart_from_dframe(dframe, desired_ccaas):
ccaas = sorted(dframe.index)
ccaas = [ccaa for ccaa in ccaas if is_desired_ccaa(ccaa, desired_ccaas)]
dates = list(dframe.columns)
table = []
for date in dates:
row = [date.date()]
... | code_fim | hard | {
"lang": "python",
"repo": "JoseBlanca/seguimiento_covid",
"path": "/src/generate_report.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoseBlanca/seguimiento_covid path: /src/generate_report.py
rechart', 'controls']});
'''
DESCRIPTIONS_CCAA = {
'incidencia_acumulada': 'Número de casos informados en los 15 días anteriores por cien mil habitantes. Datos obtenidos de los informes del Carlos III.',
'hospitalized': 'Número medio d... | code_fim | hard | {
"lang": "python",
"repo": "JoseBlanca/seguimiento_covid",
"path": "/src/generate_report.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if spa_report and desired_ccaas:
raise ValueError('choose one, either spa or ccaa report')
if desired_ccaas and len(desired_ccaas) == 1:
only_one_ccaa = True
ccaa_iso = convert_to_ccaa_iso(desired_ccaas[0])
else:
only_one_ccaa = False
ccaa_info = data_sou... | code_fim | hard | {
"lang": "python",
"repo": "JoseBlanca/seguimiento_covid",
"path": "/src/generate_report.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JamesBatho/flaskFeedback path: /seed.py
"""Seed file to make sample data for pets db."""
from models import db, User, Feedback
from app import app
# Create all tables
db.drop_all()
db.create_all()
# If table isn't empty, empty it
User.query.delete()
Feedback.query.delete()
# Add users and po... | code_fim | medium | {
"lang": "python",
"repo": "JamesBatho/flaskFeedback",
"path": "/seed.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>db.session.add(feed)
# Commit--otherwise, this never gets saved!
db.session.commit()<|fim_prefix|># repo: JamesBatho/flaskFeedback path: /seed.py
"""Seed file to make sample data for pets db."""
from models import db, User, Feedback
from app import app
# Create all tables
db.drop_all()
db.create_all(... | code_fim | medium | {
"lang": "python",
"repo": "JamesBatho/flaskFeedback",
"path": "/seed.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#have to add users first to not violate foreign key constraints
db.session.commit()
feed = Feedback(title="test",content="alsdkjf",username="John")
db.session.add(feed)
# Commit--otherwise, this never gets saved!
db.session.commit()<|fim_prefix|># repo: JamesBatho/flaskFeedback path: /seed.py
"""See... | code_fim | medium | {
"lang": "python",
"repo": "JamesBatho/flaskFeedback",
"path": "/seed.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blacklc/Practice-for-Django path: /src/djproject/books/context_processors.py
#!/usr/bin/env python
#coding:utf-8
'''
Created on 2016年8月29日
@author: lichen
'''
<|fim_suffix|> """
自定义context_processors
"""
return {
"context_test":"test"
}<|fim_middle|>def c... | code_fim | easy | {
"lang": "python",
"repo": "blacklc/Practice-for-Django",
"path": "/src/djproject/books/context_processors.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
自定义context_processors
"""
return {
"context_test":"test"
}<|fim_prefix|># repo: blacklc/Practice-for-Django path: /src/djproject/books/context_processors.py
#!/usr/bin/env python
#coding:utf-8
'''
Created on 2016年8月29日
@author: lichen
'''
<|fim_middle|>def c... | code_fim | easy | {
"lang": "python",
"repo": "blacklc/Practice-for-Django",
"path": "/src/djproject/books/context_processors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def custom_proc(request):
"""
自定义context_processors
"""
return {
"context_test":"test"
}<|fim_prefix|># repo: blacklc/Practice-for-Django path: /src/djproject/books/context_processors.py
#!/usr/bin/env python
#coding:utf-8
<|fim_middle|>'''
Created on 2016年8月29日
... | code_fim | easy | {
"lang": "python",
"repo": "blacklc/Practice-for-Django",
"path": "/src/djproject/books/context_processors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def refreshCam04():
try:
tmp_photo = URL2PhotoImage(cameraURL04)
image04_label.configure(image=tmp_photo)
image04_label.image = tmp_photo # keep a reference to prevent tkinter garbage collection
except:
pass
if rootWindow.state() == 'normal': Timer(0.05, refreshCam04).start()
def refreshCam05... | code_fim | hard | {
"lang": "python",
"repo": "grintor/gtc_cam16",
"path": "/gtc_cam9.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grintor/gtc_cam16 path: /gtc_cam9.py
#!/usr/bin/python3
import tkinter
from PIL import Image, ImageTk
import requests
from io import BytesIO
from threading import Timer
rootWindow = tkinter.Tk()
# the following makes the program full-screen
RWidth = rootWindow.winfo_screenwidth()
RHeight = ro... | code_fim | hard | {
"lang": "python",
"repo": "grintor/gtc_cam16",
"path": "/gtc_cam9.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
tmp_photo = URL2PhotoImage(cameraURL02)
image02_label.configure(image=tmp_photo)
image02_label.image = tmp_photo # keep a reference to prevent tkinter garbage collection
except:
pass
if rootWindow.state() == 'normal': Timer(0.05, refreshCam02).start()
def refreshCam03():
try:
tmp_phot... | code_fim | hard | {
"lang": "python",
"repo": "grintor/gtc_cam16",
"path": "/gtc_cam9.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_test_batches(data_dir='/home/yunhan/batchified'):
"""
return a list or generator of (large) ndarrays,
in order to efficiently utilize GPU
"""
# train 3 valid 1
# Use batch 1 - 53 as train (60%), 54 - 71 as validation (20%), 72 - 89 as test (20%)
n = 18
idx =... | code_fim | hard | {
"lang": "python",
"repo": "liangz1/KaggleDiatetic",
"path": "/src/data_utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liangz1/KaggleDiatetic path: /src/data_utils.py
import numpy as np
def get_train_batches(data_dir='/home/yunhan/batchified'):
"""
return a list or generator of (large) ndarrays,
in order to efficiently utilize GPU
"""
# todo: read in data that is preoprocessed
# ... | code_fim | medium | {
"lang": "python",
"repo": "liangz1/KaggleDiatetic",
"path": "/src/data_utils.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AarnavKashyap/C109 path: /c109/heightweight.py
import pandas as pd
import statistics
import csv
df = pd.read_csv("height-weight.csv")
heightlist = df["Height(Inches)"].to_list()
weightlist = df["Weight(Pounds)"].to_list()
heightmean = statistics.mean(heightlist)
heightmedian = statisti... | code_fim | medium | {
"lang": "python",
"repo": "AarnavKashyap/C109",
"path": "/c109/heightweight.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>firststart = heightmean - heightstdev
firstend = heightmean + heightstdev
secondstart = heightmean - 2*heightstdev
secondend = heightmean + 2*heightstdev
thirdstart = heightmean - 3*heightstdev
thirdend = heightmean + 3*heightstdev
first = [result for result in heightlist if result > firststar... | code_fim | hard | {
"lang": "python",
"repo": "AarnavKashyap/C109",
"path": "/c109/heightweight.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
# Landing page area
url(r'^$', TemplateView.as_view(template_name='visitor/landing-index.html'), name='landing_index'),
url(r'^about$', TemplateView.as_view(template_name='visitor/landing-about.html'), name='landing_about'),
url(r'^terms/$', TemplateView.as_view(templat... | code_fim | medium | {
"lang": "python",
"repo": "my-django-projects/oscarproject",
"path": "/allauthdemo/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: my-django-projects/oscarproject path: /allauthdemo/urls.py
"""URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
... | code_fim | hard | {
"lang": "python",
"repo": "my-django-projects/oscarproject",
"path": "/allauthdemo/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Account management is done by allauth
url(r'^accounts/', include('allauth.urls')),
# Account profile and member info done locally
url(r'^accounts/profile/$', account_profile, name='account_profile'),
url(r'^member/$', member_index, name='user_home'),
url(r'^member/action$'... | code_fim | hard | {
"lang": "python",
"repo": "my-django-projects/oscarproject",
"path": "/allauthdemo/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #TODO:
#change the action here based on the obv
#make action = 0 (left) or action = 1 (right) based on if-statements
print("Episode", episode, "finished after", steps, "time steps with total reward", total_reward)
if __name__ == "__main__":
simulate()<|fim... | code_fim | hard | {
"lang": "python",
"repo": "wtcutler/AI-Final-Project",
"path": "/gym/envs/classic_control/files/CartPoleStarter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wtcutler/AI-Final-Project path: /gym/envs/classic_control/files/CartPoleStarter.py
#CartPoleStarter
import gym
## Defining the simulation related constants
NUM_EPISODES = 1000
def simulate():
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
for episode in ra... | code_fim | hard | {
"lang": "python",
"repo": "wtcutler/AI-Final-Project",
"path": "/gym/envs/classic_control/files/CartPoleStarter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: twsearle/2decsfinder path: /test_code/PSIgenerator.py
# MODULES
import sys
sys.path.append('~/Documents/Project_3/REPO')
from scipy import *
from scipy import linalg
import cPickle as pickle
import ConfigParser
import TobySpectralMethods as tsm
config = ConfigParser.RawConfigParser()
fp = open(... | code_fim | hard | {
"lang": "python",
"repo": "twsearle/2decsfinder",
"path": "/test_code/PSIgenerator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# MAIN
vecLen = (2*N+1)*M
# Useful operators
MDY = tsm.mk_diff_y()
MDYY = dot(MDY,MDY)
MDYYY = dot(MDY,MDYY)
MDX = tsm.mk_diff_x()
MDXX = dot(MDX, MDX)
MDXY = dot(MDX, MDY)
LAPLAC = dot(MDX,MDX) + dot(MDY,MDY)
BIHARM = dot(LAPLAC, LAPLAC)
MDXLAPLAC = dot(MDX, LAPLAC)
MDYLAPLAC = dot(MDY, LAPLAC)
# sin... | code_fim | hard | {
"lang": "python",
"repo": "twsearle/2decsfinder",
"path": "/test_code/PSIgenerator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> PSI = zeros(vecLen, dtype='complex')
PSI[N*M] += 2.0/3.0
PSI[N*M+1] += 3.0/4.0
PSI[N*M+2] += 0.0
PSI[N*M+3] += -1.0/12.0
# Perturb 3 of 4 of first Chebyshevs of the 1st Fourier mode
PSI[(N-1)*M] = -random.normal(loc=amp, scale=0.001)
PSI[(N-1)*M+2] = random.normal(loc=... | code_fim | hard | {
"lang": "python",
"repo": "twsearle/2decsfinder",
"path": "/test_code/PSIgenerator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TestuUser123/smart-english path: /settings/migrations/0004_auto_20211110_0936.py
# Generated by Django 3.2.9 on 2021-11-10 13:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('settings', '0003_auto_20210814_2246'),
]
ope... | code_fim | hard | {
"lang": "python",
"repo": "TestuUser123/smart-english",
"path": "/settings/migrations/0004_auto_20211110_0936.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.