text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> q.lower()=='yes':
csv_writer=csv.DictWriter(wf,fieldnames=csv_headers,delimiter=',')
csv_writer.writeheader()
for l in csv_reader:
csv_writer.writerow(l)
else:
print("Please try with a different file name")<|f... | code_fim | medium | {
"lang": "python",
"repo": "awsanand2018/MyCodeFiles",
"path": "/parse-csv-file.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>or l in csv_reader:
csv_writer.writerow(l)
else:
print("Please try with a different file name")<|fim_prefix|># repo: awsanand2018/MyCodeFiles path: /parse-csv-file.py
import csv
import os
with open("sample.csv") as rf:
csv_reader=csv.DictRea... | code_fim | hard | {
"lang": "python",
"repo": "awsanand2018/MyCodeFiles",
"path": "/parse-csv-file.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adore96/Video-Splitter path: /crop.py
# Improting Image class from PIL module
from PIL import Image
<|fim_suffix|># Setting the points for cropped image
left = 155
top = 65
right = 360
bottom = 270
# Cropped image of above dimension
# (It will not change orginal image)
im1 = im.crop((left, top,... | code_fim | medium | {
"lang": "python",
"repo": "Adore96/Video-Splitter",
"path": "/crop.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Shows the image in image viewer
im1.show()
im.show()<|fim_prefix|># repo: Adore96/Video-Splitter path: /crop.py
# Improting Image class from PIL module
from PIL import Image
# Opens a image in RGB mode
im = Image.open("data/frame1.jpg")
# Setting the points for cropped image
left = 155
top = 65
right... | code_fim | medium | {
"lang": "python",
"repo": "Adore96/Video-Splitter",
"path": "/crop.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
与 54 思路类似,注意边界...
:type n: int
:rtype: List[List[int]]
"""
array = [[0 for _ in range(n)] for _ in range(n)]
top = left = 0
bottom = right = n - 1
cur_num = 1
while left <= right and top <= bottom:
for inde... | code_fim | hard | {
"lang": "python",
"repo": "Flynnon/leetcode",
"path": "/src/leetcode_100/59_spiral_matrix_2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Flynnon/leetcode path: /src/leetcode_100/59_spiral_matrix_2.py
# 给定一个正整数 n,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。
#
# DEMO:
# 输入: 3
# 输出:
# [
# [ 1, 2, 3 ],
# [ 8, 9, 4 ],
# [ 7, 6, 5 ]
# ]
<|fim_suffix|> """
与 54 思路类似,注意边界...
:type n: int
:rtype: List[List... | code_fim | hard | {
"lang": "python",
"repo": "Flynnon/leetcode",
"path": "/src/leetcode_100/59_spiral_matrix_2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generateMatrix(self, n):
"""
与 54 思路类似,注意边界...
:type n: int
:rtype: List[List[int]]
"""
array = [[0 for _ in range(n)] for _ in range(n)]
top = left = 0
bottom = right = n - 1
cur_num = 1
while left <= right and to... | code_fim | hard | {
"lang": "python",
"repo": "Flynnon/leetcode",
"path": "/src/leetcode_100/59_spiral_matrix_2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Start playing"""
self.player.set_state(Gst.State.PLAYING)
def pause(self):
"""Pause playing"""
self.player.set_state(Gst.State.PAUSED)
def stop(self):
self.player.set_state(Gst.State.NULL)<|fim_prefix|># repo: galou/radio_archive path: /gstreamer_playe... | code_fim | hard | {
"lang": "python",
"repo": "galou/radio_archive",
"path": "/gstreamer_player.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._uri
@uri.setter
def uri(self, value):
self._uri = value
self.player.set_state(Gst.State.NULL)
if value:
self.player.set_property('uri', value)
def play(self):
"""Start playing"""
self.player.set_state(Gst.State.PLAYING)... | code_fim | medium | {
"lang": "python",
"repo": "galou/radio_archive",
"path": "/gstreamer_player.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: galou/radio_archive path: /gstreamer_player.py
# -* coding: utf-8 -*-
# A headless media player based on gstreamer.
from gi.repository import Gst
Gst.init(None)
class Player:
def __init__(self, uri=None):
# Creates a playbin (plays media from an uri).
self.player = Gst.Elem... | code_fim | medium | {
"lang": "python",
"repo": "galou/radio_archive",
"path": "/gstreamer_player.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: denis-plotnikov/code path: /compare_configs.sh
#!/usr/bin/python
import sys
def get_params(fname):
d = dict()
with open(fname) as f:
for line in f:
l = line.strip()
if (line[0] == '#'):
continue
param = line.split('=')
v = ' '.join(param[1:])
d[param[0]] = v.strip('\n')
... | code_fim | medium | {
"lang": "python",
"repo": "denis-plotnikov/code",
"path": "/compare_configs.sh",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>param_names = set([key for key in params1]) | set([key for key in params2])
the_first = True
f_output = "{0:80}{1:40}{2:40}"
for param in param_names:
try:
val1 = params1[param]
except KeyError:
val1 = '-'
try:
val2 = params2[param]
except KeyError:
val2 = '-'
if (val1 != val2):
if t... | code_fim | hard | {
"lang": "python",
"repo": "denis-plotnikov/code",
"path": "/compare_configs.sh",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
val2 = params2[param]
except KeyError:
val2 = '-'
if (val1 != val2):
if the_first:
print(f_output.format("Param name", f1, f2))
print "-"*140
the_first = False
print (f_output.format(param, val1, val2))<|fim_prefix|># repo: denis-plotnikov/code path: /compare_configs.sh
#!/usr/... | code_fim | medium | {
"lang": "python",
"repo": "denis-plotnikov/code",
"path": "/compare_configs.sh",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DOXOPOKC/accountant_app path: /backend/bluebird/models.py
[self.klass][1])):
os.mkdir(os.path.join(settings.MEDIA_ROOT,
KLASS_TYPES[self.klass][1]), mode=0o777)
def get_str_as_path(self):
return os.path.join(os.path.join(settings.MEDIA_ROOT,
... | code_fim | hard | {
"lang": "python",
"repo": "DOXOPOKC/accountant_app",
"path": "/backend/bluebird/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DOXOPOKC/accountant_app path: /backend/bluebird/models.py
Field('Дата заключения договора',
blank=True, null=True)
signed_user = models.ForeignKey('SignUser', blank=True, null=True,
on_delete=models.CASCADE,
... | code_fim | hard | {
"lang": "python",
"repo": "DOXOPOKC/accountant_app",
"path": "/backend/bluebird/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># class SingleFilesTemplate(models.Model):
# contagent_type = models.IntegerField(choices=KLASS_TYPES, default=0)
# def __str__(self):
# return KLASS_TYPES[self.contagent_type][1]
# class Meta:
# verbose_name_plural = "Шаблоны единичных файлов"
# class PackFilesTemplate(mod... | code_fim | hard | {
"lang": "python",
"repo": "DOXOPOKC/accountant_app",
"path": "/backend/bluebird/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='divida',
name='id_cliente',
field=models.CharField(max_length=10),
),
migrations.AlterField(
model_name='divida',
name='motivo',
field=models.CharField(max_... | code_fim | medium | {
"lang": "python",
"repo": "ferpavanello/dividas",
"path": "/dividas/core/migrations/0002_auto_20190505_1541.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ferpavanello/dividas path: /dividas/core/migrations/0002_auto_20190505_1541.py
# Generated by Django 2.2.1 on 2019-05-05 18:41
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AlterField(... | code_fim | medium | {
"lang": "python",
"repo": "ferpavanello/dividas",
"path": "/dividas/core/migrations/0002_auto_20190505_1541.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Derecho/django-ipban path: /ipban/middleware.py
from models import Ban
from django.shortcuts import render_to_response
class IPBanMiddleware(object):
<|fim_suffix|> # see if user is banned
try:
# if this doesnt throw an exception, user is banned
ban = Ban.objects.get(ip=ip... | code_fim | hard | {
"lang": "python",
"repo": "Derecho/django-ipban",
"path": "/ipban/middleware.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ip = request.META['REMOTE_ADDR'] # user's IP
# see if user is banned
try:
# if this doesnt throw an exception, user is banned
ban = Ban.objects.get(ip=ip)
if ban.banned():
# return the "ban page"
return render_to_response("ban/banned.ht... | code_fim | medium | {
"lang": "python",
"repo": "Derecho/django-ipban",
"path": "/ipban/middleware.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaohai12/leetcode path: /Arrary/45. Jump Game II.py
class Solution:
def jump(self, nums: List[int]) -> int:
l = len(nums)
jump = 0
curEnd = 0
curFarthest = 0
for i in range<|fim_suffix|>d:
jump+=1
curEnd = curFarthest
... | code_fim | hard | {
"lang": "python",
"repo": "xiaohai12/leetcode",
"path": "/Arrary/45. Jump Game II.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(l-1):
curFarthest= max(curFarthest,i+nums[i])
if i==curEnd:
jump+=1
curEnd = curFarthest
return jump<|fim_prefix|># repo: xiaohai12/leetcode path: /Arrary/45. Jump Game II.py
class Solution:
def jump(self, nums: List[int]) -> int:
... | code_fim | hard | {
"lang": "python",
"repo": "xiaohai12/leetcode",
"path": "/Arrary/45. Jump Game II.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fridoling/tub_nmd_VIII path: /src/tub_nmd_VIII_fast.py
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import copy
import sys
def mutate(genotype_in, mut_matrix):
genotype_out = np.zeros(8)
for i in range(8):
rand_vec = np.random.choice(8, size=int(genotype_in[i]), p=m... | code_fim | hard | {
"lang": "python",
"repo": "fridoling/tub_nmd_VIII",
"path": "/src/tub_nmd_VIII_fast.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_gene_freqs3(gt):
gene_freq = np.zeros((gt.shape[0], gt.shape[1], 3))
for i in range(8):
bin_i = np.binary_repr(i, width=3)
for j in range(3):
if bin_i[j] =='1':
gene_freq[:,:,j] += gt[:,:,i]
return(gene_freq)
def convert_mut(mp):
# c... | code_fim | hard | {
"lang": "python",
"repo": "fridoling/tub_nmd_VIII",
"path": "/src/tub_nmd_VIII_fast.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AriaAsuna/Online_mobile_shopmain path: /Online_mobile_shopmain/products/migrations/0001_initial.py
# Generated by Django 3.1.7 on 2021-03-24 14:51
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> dependencies = [
]
operations = [
... | code_fim | hard | {
"lang": "python",
"repo": "AriaAsuna/Online_mobile_shopmain",
"path": "/Online_mobile_shopmain/products/migrations/0001_initial.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Products_Table',
fields=[
('product_id', models.IntegerField(auto_created=True, primary_key=True, serialize=False)),
('product_name', models.CharField(max_length=50)),
('product... | code_fim | hard | {
"lang": "python",
"repo": "AriaAsuna/Online_mobile_shopmain",
"path": "/Online_mobile_shopmain/products/migrations/0001_initial.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidlyness/Advent-of-Code-2018 path: /07/main.py
# coding=utf-8
"""Advent of Code 2018, Day 7"""
import networkx
import re
G = networkx.DiGraph()
with open("puzzle_input") as f:
for line in f.read().split("\n"):
match = re.search("Step (?P<pre>[A-Z]).*step (?P<post>[A-Z])", line)
... | code_fim | medium | {
"lang": "python",
"repo": "davidlyness/Advent-of-Code-2018",
"path": "/07/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def part_two():
"""Solution to Part 2"""
tasks = {}
current_time = 0
while G.nodes():
# noinspection PyCallingNonCallable
candidate_next_tasks = [task for task in G.nodes()
if task not in tasks.keys() and G.in_degree(task) == 0]
if ca... | code_fim | medium | {
"lang": "python",
"repo": "davidlyness/Advent-of-Code-2018",
"path": "/07/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: woonji913/til path: /Algorithm/python 파일/20190318/농작물2.py
# import sys
# sys.stdin = open("농작물input.txt")
T = int(input())
for n in range(1, T+1):
N = int(input())
arr = [list(map(int, list(input()))) for _ in range(N)]
# print(arr)
a = N//2
b = N//2
result = 0
for i... | code_fim | medium | {
"lang": "python",
"repo": "woonji913/til",
"path": "/Algorithm/python 파일/20190318/농작물2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> a += -1
b += 1
else:
a += 1
b += -1
print("#{0} {1}".format(n, result))<|fim_prefix|># repo: woonji913/til path: /Algorithm/python 파일/20190318/농작물2.py
# import sys
# sys.stdin = open("농작물input.txt")
T = int(input())
for n in range(1, T+1):
N = in... | code_fim | medium | {
"lang": "python",
"repo": "woonji913/til",
"path": "/Algorithm/python 파일/20190318/농작물2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Abubakarshaikh/booking-web-app path: /server/__init__.py
from flask import Flask
from flask_bcrypt import Bcrypt
from flask_jwt_extended import JWTManager
from flask_migrate import Migrate
from flask_restful import Api
from flask_apispec.extension import FlaskApiSpec
from server.admin import add... | code_fim | hard | {
"lang": "python",
"repo": "Abubakarshaikh/booking-web-app",
"path": "/server/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_app():
add_routes(api)
add_commands(app)
login_manager.init_app(app)
docs = FlaskApiSpec(app)
register_docs(docs)
return app<|fim_prefix|># repo: Abubakarshaikh/booking-web-app path: /server/__init__.py
from flask import Flask
from flask_bcrypt import Bcrypt
from flask_... | code_fim | hard | {
"lang": "python",
"repo": "Abubakarshaikh/booking-web-app",
"path": "/server/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if num == 0:
return rom
digits = len(str(num))
multiple = 10 ** (digits -1)
cur = int(num / multiple)
cur = cur * multiple
num = num % multiple
halfway = 5 * multiple
fullway = 10 * multiple
if cur + multiple == halfway:
rom += d[multiple] + d[ha... | code_fim | medium | {
"lang": "python",
"repo": "ravikumarsureshbabu/Algorithms",
"path": "/numtoroman.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ravikumarsureshbabu/Algorithms path: /numtoroman.py
d = {
1 : 'I',
5 : 'V',
10: 'X',
50: 'L',
100: 'C',
500: 'D',
1000: 'M'
}
e = {
'I': 1,
'V': 5,
'X':... | code_fim | hard | {
"lang": "python",
"repo": "ravikumarsureshbabu/Algorithms",
"path": "/numtoroman.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> halfway = 5 * multiple
fullway = 10 * multiple
if cur + multiple == halfway:
rom += d[multiple] + d[halfway]
elif cur + multiple == fullway:
rom += d[multiple] + d[fullway]
else:
if cur >= halfway:
cur -= halfway
rom += d[halfway]
... | code_fim | hard | {
"lang": "python",
"repo": "ravikumarsureshbabu/Algorithms",
"path": "/numtoroman.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mind-the-Pineapple/tpot-age path: /BayOptPy/helperfunctions.py
tqdm import tqdm
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix
from sklearn.utils.multiclass import unique_labels
import seaborn as sns
sns.set()
def get_paths(de... | code_fim | hard | {
"lang": "python",
"repo": "Mind-the-Pineapple/tpot-age",
"path": "/BayOptPy/helperfunctions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Resample the dataset by a factor of %d' %resamplefactor)
print('Original image size: %s' %(imgs[0].shape,))
# resample dataset to a lower quality. Increase the voxel size by two
resampleby2affine = np.array([[resamplefactor, 1, 1, 1],
[1, resamplefa... | code_fim | hard | {
"lang": "python",
"repo": "Mind-the-Pineapple/tpot-age",
"path": "/BayOptPy/helperfunctions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GangaMegha/Generative-Models path: /Video_Dynamics_Prediction/PythonScripts/Dynamics/GenerateHidden_FromTrainedRBM.py
import pickle
import numpy as np
in_dir = "C:\\Users\\ganga\\Github\\Generative-Models\\Project\\Data\\Dynamics\\"
out_dir = f"C:\\Users\\ganga\\Github\\Generative-Models\\Projec... | code_fim | hard | {
"lang": "python",
"repo": "GangaMegha/Generative-Models",
"path": "/Video_Dynamics_Prediction/PythonScripts/Dynamics/GenerateHidden_FromTrainedRBM.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> v = test_frames[i].T
# Getting hidden states of RBM using frames
# (h x v) @ (v x b) + (h x 1) = (h x b)
p_h_v = sigmoid(W @ v + b_h)
hidden.append(p_h_v.T)
hidden = np.array(hidden)
print("Test Hidden p_h_v : ", hidden.shape)
pickle.dump(hidden, open(f"{out_dir}\\test_p_h_v.pkl" , 'wb' ) )<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "GangaMegha/Generative-Models",
"path": "/Video_Dynamics_Prediction/PythonScripts/Dynamics/GenerateHidden_FromTrainedRBM.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return sample
# ------------------------ Train Data ----------------------------------------
for count in range(5):
hidden = []
for i in range(train_frames.shape[0]):
v = train_frames[i].T
# Getting hidden states of RBM using frames
# (h x v) @ (v x b) + (h x 1) = (h x b)
p_h_v = sigmoid(W ... | code_fim | hard | {
"lang": "python",
"repo": "GangaMegha/Generative-Models",
"path": "/Video_Dynamics_Prediction/PythonScripts/Dynamics/GenerateHidden_FromTrainedRBM.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RohithYogi/Predict-Future-Sales path: /predict.py
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import numpy.random as nr
import math
import os
from datetime import datetime
from sklearn.linear_model import LinearRegression, SGDRegressor
import sys
i... | code_fim | hard | {
"lang": "python",
"repo": "RohithYogi/Predict-Future-Sales",
"path": "/predict.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def trainXGBoost(self):
self.__xgb.fit(self.train_data,self.train_labels,eval_metric="rmse",eval_set=[(self.train_data, self.train_labels), (self.x_train_val, self.y_train_val)],verbose=True,early_stopping_rounds=10)
def testXGBoost(self):
self.predicted_labels = self.__xgb.predict(self.val_data)
... | code_fim | hard | {
"lang": "python",
"repo": "RohithYogi/Predict-Future-Sales",
"path": "/predict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>st[i] = tmp[0] + list[int(tmp[1])-1]
for i in range(0, k):
start = input()
print(len([word for word in list if word.startswith(start)]))<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2211/60799/235003.py
list = input().split()
n = int(list[0])
k = int(list[1])
list.clear(... | code_fim | medium | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2211/60799/235003.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2211/60799/235003.py
list = input().split()
n = int(list[0])
k = int(list[1])
list.clear()
fo<|fim_suffix|>st[i] = tmp[0] + list[int(tmp[1])-1]
for i in range(0, k):
start = input()
print(len([word for word in list if word.startswith(start... | code_fim | medium | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2211/60799/235003.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nput()
print(len([word for word in list if word.startswith(start)]))<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2211/60799/235003.py
list = input().split()
n = int(list[0])
k = int(list[1])
list.clear()
fo<|fim_middle|>r i in range(0, n):
list.append("")
tmp = inpu... | code_fim | medium | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2211/60799/235003.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Функция собирает из двух предварительно отсортированных массивов,
поданных на вход, один и ео же возвращает
:param merge_1: - первый отсортированный список
:param merge_2: - второй отсортированный список
:return: - "слитый" из двух, отсортированный список
"""
# ... | code_fim | hard | {
"lang": "python",
"repo": "Dmitry1973/algorythms",
"path": "/Less_7/L7_t2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dmitry1973/algorythms path: /Less_7/L7_t2.py
# 2. Отсортируйте по возрастанию методом слияния одномерный вещественный массив,
# заданный случайными числами на промежутке [0; 50).
# Выведите на экран исходный и отсортированный массивы.
from random import randint
# создаем массив [0, 50) сл... | code_fim | medium | {
"lang": "python",
"repo": "Dmitry1973/algorythms",
"path": "/Less_7/L7_t2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cr3m/cryptowall_v3 path: /ida_pro/ida_python/string_obfuscation_0.py
#!/usr/bin/python
# This IDAPython code can be used to de-obfuscate strings generated by
# CryptoWall version 3, as well as any other malware samples that make use of
# this technique.
'''
Example disassembly:
<|fim_suffix|>p... | code_fim | hard | {
"lang": "python",
"repo": "cr3m/cryptowall_v3",
"path": "/ida_pro/ida_python/string_obfuscation_0.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pos = here()
original_pos = pos
out = ""
while True:
if GetMnem(pos) == "mov" and GetOpnd(pos, 0)[0] == "e" and GetOpnd(pos, 0)[2] == "x":
out += chr(GetOperandValue(pos,1))
elif GetMnem(pos) == "mov" and "[ebp" in GetOpnd(pos, 0):
None
elif GetMnem(pos) == "xor":
MakeComm(original_pos, out)
pr... | code_fim | hard | {
"lang": "python",
"repo": "cr3m/cryptowall_v3",
"path": "/ida_pro/ida_python/string_obfuscation_0.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> i = 0
while(i < 3):
tri.forward(135)
tri.right(145)
i += 1
def main():
window = turtle.Screen()
window.bgcolor("blue")
draw_square()
draw_circle()
draw_triangle()
window.exitonclick()
main()<|fim_prefix|># repo: gbengaoti/Fullstackdevelopment path: /Object oriented Python/Lesson 3/movet... | code_fim | medium | {
"lang": "python",
"repo": "gbengaoti/Fullstackdevelopment",
"path": "/Object oriented Python/Lesson 3/moveturtle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gbengaoti/Fullstackdevelopment path: /Object oriented Python/Lesson 3/moveturtle.py
import turtle
def draw_square():
conrad = turtle.Turtle()
conrad.shape("turtle")
conrad.color("red")
conrad.speed(3)
<|fim_suffix|>def draw_triangle():
tri = turtle.Turtle()
tri.shape("turtle")
i = 0... | code_fim | medium | {
"lang": "python",
"repo": "gbengaoti/Fullstackdevelopment",
"path": "/Object oriented Python/Lesson 3/moveturtle.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
tri = turtle.Turtle()
tri.shape("turtle")
i = 0
while(i < 3):
tri.forward(135)
tri.right(145)
i += 1
def main():
window = turtle.Screen()
window.bgcolor("blue")
draw_square()
draw_circle()
draw_triangle()
window.exitonclick()
main()<|fim_prefix|># repo: gbengaoti/Fullstackdevelopmen... | code_fim | medium | {
"lang": "python",
"repo": "gbengaoti/Fullstackdevelopment",
"path": "/Object oriented Python/Lesson 3/moveturtle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mer-git/ICB path: /Taller2.py
# -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
def largo (l, n):
<|fim_suffix|>def hayBorde(l,n,h):
if largo(l,n)==h:
return True
else:
return False
print(hayBorde([2,4,4,4,6,6,6,10,10],2,4))<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "Mer-git/ICB",
"path": "/Taller2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def hayBorde(l,n,h):
if largo(l,n)==h:
return True
else:
return False
print(hayBorde([2,4,4,4,6,6,6,10,10],2,4))<|fim_prefix|># repo: Mer-git/ICB path: /Taller2.py
# -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
<|fim_middle|>def largo (l, n):
... | code_fim | hard | {
"lang": "python",
"repo": "Mer-git/ICB",
"path": "/Taller2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nikoletazl/Basics-Python path: /tema_2/excersice_2/bonus_points.py
number = int(input())
bonus = 0
if number <= 100:
bonus = 5
total_point = number + bonus
elif number > 1000:
bonus = 0.1 * number
total_point = number + bonus
else:
bonus = 0.2 * number
total_poin... | code_fim | medium | {
"lang": "python",
"repo": "Nikoletazl/Basics-Python",
"path": "/tema_2/excersice_2/bonus_points.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
elif number % 10 == 5:
bonus = bonus + 2
total_point = number + bonus
print(bonus)
print(total_point)<|fim_prefix|># repo: Nikoletazl/Basics-Python path: /tema_2/excersice_2/bonus_points.py
number = int(input())
bonus = 0
if number <= 100:
bonus = 5
total_point = number ... | code_fim | hard | {
"lang": "python",
"repo": "Nikoletazl/Basics-Python",
"path": "/tema_2/excersice_2/bonus_points.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Siddhant24/ELL409 path: /Assignment_1/PCA.py
import numpy as np
import pandas as pd
import matplotlib as plt
import scipy.linalg
from distance_metrics import *
import time
import random
RANDOM_SEED = 42
np.random.seed(RANDOM_SEED)
random.seed(RANDOM_SEED)
#####################################... | code_fim | medium | {
"lang": "python",
"repo": "Siddhant24/ELL409",
"path": "/Assignment_1/PCA.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>################################################################
# Whitening #
################################################################
def whiteningTransform(X, W, U):
L = np.diag(W)
Z = np.transpose(np.matmul(np.matmul(scipy.linalg.fractional_matrix_power(L, -0.5), U.transpose()), (X - np.m... | code_fim | hard | {
"lang": "python",
"repo": "Siddhant24/ELL409",
"path": "/Assignment_1/PCA.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> [Z, X3] = project(X, U, p)
#Projection, P, Reconstruction, EigenVectors, EigenValues
return [Z, p, X3, U, W]
################################################################
# Whitening #
################################################################
def whiteningTransform(X, W, U):... | code_fim | hard | {
"lang": "python",
"repo": "Siddhant24/ELL409",
"path": "/Assignment_1/PCA.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yeonkyungJoo/algorithm_study path: /KwangHo/조이스틱.py
def solution(name):
Len = len(name)
nameList = [name[i] for i in range(Len)]
nameField = ['A' for i in range(Len)]
answer = 0
# 정방향
for i in range(Len):
a = ord(nameField[i])
b = ord(nameList[i])
... | code_fim | hard | {
"lang": "python",
"repo": "yeonkyungJoo/algorithm_study",
"path": "/KwangHo/조이스틱.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dap = min(dap,answer)
return dap
'''
중복코드로 많아 함수로 빼고싶었지만..패쓰!
정방향의 가중치와
정방향으로 0~길이/2 만큼까지 가고 + 역방향 가면서
원하는 name만들어졌는지 계속 체크!
최소가중치를 구해서 출력!!
'''<|fim_prefix|># repo: yeonkyungJoo/algorithm_study path: /KwangHo/조이스틱.py
def solution(name):
Len = len(name)
nameList = [name[i... | code_fim | hard | {
"lang": "python",
"repo": "yeonkyungJoo/algorithm_study",
"path": "/KwangHo/조이스틱.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
path('admin/', admin.site.urls),
path('account/', include('account.urls'), name='account'),
path('images/', include('images.urls', namespace='images')),
path('password_reset/', password_reset, {'template_name': 'registration/password_reset.html'}, name='password_reset'),
... | code_fim | medium | {
"lang": "python",
"repo": "urosjevremovic/social-website",
"path": "/social_website/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: urosjevremovic/social-website path: /social_website/urls.py
"""social_website URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app im... | code_fim | medium | {
"lang": "python",
"repo": "urosjevremovic/social-website",
"path": "/social_website/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _id = db.Column(db.Integer, primary_key=True)
language = db.Column(db.String(64), index=True)
word = db.Column(db.String(64), index=True, unique=True)
date = db.Column(db.DateTime, index=True, default=datetime.utcnow)<|fim_prefix|># repo: gabastil/conlang-app path: /app/models.py
from dat... | code_fim | easy | {
"lang": "python",
"repo": "gabastil/conlang-app",
"path": "/app/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabastil/conlang-app path: /app/models.py
from datetime import datetime
from app import db
<|fim_suffix|> _id = db.Column(db.Integer, primary_key=True)
language = db.Column(db.String(64), index=True)
word = db.Column(db.String(64), index=True, unique=True)
date = db.Column(db.Dat... | code_fim | easy | {
"lang": "python",
"repo": "gabastil/conlang-app",
"path": "/app/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabastil/conlang-app path: /app/models.py
from datetime import datetime
from app import db
<|fim_suffix|> _id = db.Column(db.Integer, primary_key=True)
language = db.Column(db.String(64), index=True)
word = db.Column(db.String(64), index=True, unique=True)
date = db.Column(db.Date... | code_fim | easy | {
"lang": "python",
"repo": "gabastil/conlang-app",
"path": "/app/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: snowdj/MachineLearning_V path: /4.LogRegres/logRegres.py
#coding=utf-8
from numpy import *
#代码5-1,Logistic回归梯度上升优化算法。
def loadDataSet():
"""解析文件
Return: dataMat 文档列表 [[1,x1,x2]...]; labelMat 类别标签列表[1,0,1...]
@author:VPrincekin
"""
dataMat = []; labelMat= []
fr = open('te... | code_fim | hard | {
"lang": "python",
"repo": "snowdj/MachineLearning_V",
"path": "/4.LogRegres/logRegres.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def colicTest():
"""测试Logistic回归算法
Args: None
Return: Logistic回归算法错误率
"""
#每个样本有21个特征,一个类别。
frTrain = open('horseColicTraining.txt')
frTest = open('horseColicTest.txt')
trainingSet = []; trainingLabels = []
#开始解析训练文本,通过stocGradAscent1()计算并返回,回归系数向量。
for line in... | code_fim | hard | {
"lang": "python",
"repo": "snowdj/MachineLearning_V",
"path": "/4.LogRegres/logRegres.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Zinko17/MovieProject path: /movie_project/movie/serializers.py
from rest_framework import serializers
from .models import *
<|fim_suffix|>class FilmSerializer(serializers.ModelSerializer):
class Meta:
model = Movie
fields = '__all__'<|fim_middle|>class MovieSerializer(serial... | code_fim | medium | {
"lang": "python",
"repo": "Zinko17/MovieProject",
"path": "/movie_project/movie/serializers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class FilmSerializer(serializers.ModelSerializer):
class Meta:
model = Movie
fields = '__all__'<|fim_prefix|># repo: Zinko17/MovieProject path: /movie_project/movie/serializers.py
from rest_framework import serializers
from .models import *
class MovieSerializer(serializers.Serializ... | code_fim | medium | {
"lang": "python",
"repo": "Zinko17/MovieProject",
"path": "/movie_project/movie/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = Movie
fields = '__all__'<|fim_prefix|># repo: Zinko17/MovieProject path: /movie_project/movie/serializers.py
from rest_framework import serializers
from .models import *
class MovieSerializer(serializers.Serializer):
movie_name = serializers.ListField(child=serializers.CharFi... | code_fim | easy | {
"lang": "python",
"repo": "Zinko17/MovieProject",
"path": "/movie_project/movie/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def send(self, value, convergence=False):
"""Send one value (distortion gain) to the server"""
# dump to json format
data = json.dumps(dict({"gain" : value, "convergence" : convergence})).encode()
print("Sending value {} as data {}".format(value, data))
self.soc... | code_fim | medium | {
"lang": "python",
"repo": "Sytta/Semester_Project",
"path": "/Python Scripts/Communication/Client.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sytta/Semester_Project path: /Python Scripts/Communication/Client.py
import socket
import json
import numpy as np
"""TCP client used to communicate with the Unity Application"""
class TCP:
def __init__(self, sock = None):
# Create a TCP socket
if sock is None:
se... | code_fim | hard | {
"lang": "python",
"repo": "Sytta/Semester_Project",
"path": "/Python Scripts/Communication/Client.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if char appears for all members, add one to
# count_all_members_have_response var which keeps track of the total count
# for all groups
if char_in_all_members == True:
#print('char', char, 'exists for all members of this group')
count_all_members_have_response += 1
# finished proc... | code_fim | hard | {
"lang": "python",
"repo": "RobertVallance/adventofcode",
"path": "/day6.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RobertVallance/adventofcode path: /day6.py
# read in file of customs declaration responses
declarations_file = open('day6_declarations.txt', 'r')
lines = declarations_file.readlines()
# initialise variables
group_responses = [] # temporary container for all responses of each g... | code_fim | hard | {
"lang": "python",
"repo": "RobertVallance/adventofcode",
"path": "/day6.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> char_in_all_members = False
# if char appears for all members, add one to
# count_all_members_have_response var which keeps track of the total count
# for all groups
if char_in_all_members == True:
#print('char', char, 'exists for all members of this group')
count_all_members_hav... | code_fim | hard | {
"lang": "python",
"repo": "RobertVallance/adventofcode",
"path": "/day6.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: espnet/espnet path: /espnet2/schedulers/warmup_step_lr.py
"""Step (with Warm up) learning rate scheduler module."""
from typing import Union
import torch
from torch.optim.lr_scheduler import _LRScheduler
from typeguard import check_argument_types
from espnet2.schedulers.abs_scheduler import Abs... | code_fim | hard | {
"lang": "python",
"repo": "espnet/espnet",
"path": "/espnet2/schedulers/warmup_step_lr.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (
f"{self.__class__.__name__}(warmup_steps={self.warmup_steps}, "
f"steps_per_epoch={self.steps_per_epoch},"
f" step_size={self.step_size}, gamma={self.gamma})"
)
def get_lr(self):
self.step_num += 1
if self.step_num % self.st... | code_fim | hard | {
"lang": "python",
"repo": "espnet/espnet",
"path": "/espnet2/schedulers/warmup_step_lr.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gioak93/Python-for-everybody path: /JSONbasics.py
import json
import urllib.request, urllib.parse, urllib.error
import xml.etree.ElementTree as ET
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
total=list()
<|fim_suffix|>for items in x:... | code_fim | hard | {
"lang": "python",
"repo": "Gioak93/Python-for-everybody",
"path": "/JSONbasics.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>info = json.loads(data)
print('User count:', len(info['comments']))
x = info['comments']
for items in x:
y= (items['count'])
total.append(int(y))
print ('Sum :', sum(total))<|fim_prefix|># repo: Gioak93/Python-for-everybody path: /JSONbasics.py
import json
import urllib.request, urllib.parse, ... | code_fim | hard | {
"lang": "python",
"repo": "Gioak93/Python-for-everybody",
"path": "/JSONbasics.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for items in x:
y= (items['count'])
total.append(int(y))
print ('Sum :', sum(total))<|fim_prefix|># repo: Gioak93/Python-for-everybody path: /JSONbasics.py
import json
import urllib.request, urllib.parse, urllib.error
import xml.etree.ElementTree as ET
import ssl
ctx = ssl.create_default_conte... | code_fim | medium | {
"lang": "python",
"repo": "Gioak93/Python-for-everybody",
"path": "/JSONbasics.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get(self):
user = self.get_user()
if user:
post_id = self.request.get('post_id')
post = PostData.get_by_id(int(post_id))
voter_list = post.voter_list
if post.author == user:
error = "cant vote for self"
... | code_fim | hard | {
"lang": "python",
"repo": "vondirath/ud-blog",
"path": "/handlers/votehandler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vondirath/ud-blog path: /handlers/votehandler.py
# [BEGIN IMPORTS]
from mainhandler import MainHandler
from sec.data import *
# [END IMPORTS]
class UpVoteHandler (MainHandler):
def get(self):
user = self.get_user()
if user:
post_id = self.request.get('post_id')
... | code_fim | hard | {
"lang": "python",
"repo": "vondirath/ud-blog",
"path": "/handlers/votehandler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = self.get_user()
if user:
post_id = self.request.get('post_id')
post = PostData.get_by_id(int(post_id))
voter_list = post.voter_list
if post.author == user:
error = "cant vote for self"
self.render('mai... | code_fim | hard | {
"lang": "python",
"repo": "vondirath/ud-blog",
"path": "/handlers/votehandler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '2018/6/1 hello python'
@app.route('/news')
def news():
return '内蒙古新闻资讯,请选择浏览'
if __name__ == '__main__':
manager.run()<|fim_prefix|># repo: gwlsuccess/python1 path: /index.py
from flask import Flask
from flask_script import Manager
<|fim_middle|>app = Flask(__name__)
manager = Man... | code_fim | medium | {
"lang": "python",
"repo": "gwlsuccess/python1",
"path": "/index.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gwlsuccess/python1 path: /index.py
from flask import Flask
from flask_script import Manager
<|fim_suffix|>@app.route('/')
def index():
return '2018/6/1 hello python'
@app.route('/news')
def news():
return '内蒙古新闻资讯,请选择浏览'
if __name__ == '__main__':
manager.run()<|fim_middle|>app = F... | code_fim | easy | {
"lang": "python",
"repo": "gwlsuccess/python1",
"path": "/index.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luis-wang/Robotics_408I path: /movement/turning.py
import sys, getopt
sys.path.append('.')
import RTIMU
import os.path
import time
import math
import encoders
import motors
#right is master, left is slave
master_power = .6
slave_power = -.6
right_num_revs = 0
left_num_revs = 0
kp = .5
encoders... | code_fim | hard | {
"lang": "python",
"repo": "luis-wang/Robotics_408I",
"path": "/movement/turning.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>imu.setSlerpPower(0.02)
imu.setGyroEnable(True)
imu.setAccelEnable(True)
imu.setCompassEnable(True)
poll_interval = imu.IMUGetPollInterval()
print("Recommended Poll Interval: %dmS\n" % poll_interval)
old_x = 0
old_y = 0
old_z = 0
while True:
if imu.IMURead():
# x, y, z = imu.getFusionData()
#... | code_fim | hard | {
"lang": "python",
"repo": "luis-wang/Robotics_408I",
"path": "/movement/turning.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elenalb/geekbrains_python path: /lesson4/list_dict_comprehensions.py
# генераторы списков и словарей
# lists
my_list = [1, 2, 3, 4, 5]
new_list = []
for i in my_list:
new_list.append(i**2)
new_list_comp = [el**2 for el in my_list]
lines = [line.strip() for line in open("text.txt")]
new_li... | code_fim | medium | {
"lang": "python",
"repo": "elenalb/geekbrains_python",
"path": "/lesson4/list_dict_comprehensions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>my_list_of_floats = [2.4324324, 5.3243234, 6.23424]
new_list_round = [round(el, 2) for el in my_list_of_floats]
print(new_list_round)<|fim_prefix|># repo: elenalb/geekbrains_python path: /lesson4/list_dict_comprehensions.py
# генераторы списков и словарей
# lists
my_list = [1, 2, 3, 4, 5]
new_list = []... | code_fim | medium | {
"lang": "python",
"repo": "elenalb/geekbrains_python",
"path": "/lesson4/list_dict_comprehensions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yudongqiu/qc-python path: /qc_python/uhf.py
"""
Author: Yudong Qiu
Functions for solving unrestricted Hartree-Fock
"""
import numpy as np
from qc_python import basis_integrals
from qc_python.common import chemical_elements, calc_nuclear_repulsion
def solve_unrestricted_hartree_fock(elems, coo... | code_fim | hard | {
"lang": "python",
"repo": "yudongqiu/qc-python",
"path": "/qc_python/uhf.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ft = np.einsum("pi,ij,jq->pq",Shalf,Fmat,Shalf)
Feigval, Feigvec = np.linalg.eigh(Ft)
idx = Feigval.argsort()
Feigval = Feigval[idx]
Feigvec = Feigvec[:,idx]
Cmat = np.dot(Shalf, Feigvec)
return Feigval, Cmat
def DIIS_extrapolate_F(diis_err_mats, diis_fmats):
n_diis = len(... | code_fim | hard | {
"lang": "python",
"repo": "yudongqiu/qc-python",
"path": "/qc_python/uhf.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: my-course-work/superDigits path: /homework6_blhylak_yliu17.py
import numpy as np
import sys
class NeuralNetworkClassifier():
def __init__(self, hidden_units, learning_rate, batch_size, epochs, l_1_beta_1, l_1_beta_2, l_2_alpha_1, l_2_alpha_2):
self._hidden_units = hidden_units
... | code_fim | hard | {
"lang": "python",
"repo": "my-course-work/superDigits",
"path": "/homework6_blhylak_yliu17.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> all_hidden_units = [20, 20, 30, 30, 40, 40, 50, 50, 60, 30]
all_learning_rates = [0.0001, 0.001, 0.01, 0.01, 0.01, 0.02, 0.02, 0.1, 0.2, 0.007]
all_minibatch_sizes = [2, 5, 10, 10, 20, 20, 100, 50, 50, 25]
all_num_epochs = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3]
all_l1_strengths = [0.0, 0.0, 0,... | code_fim | hard | {
"lang": "python",
"repo": "my-course-work/superDigits",
"path": "/homework6_blhylak_yliu17.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return g
def _l_1_loss(self, W):
return np.sum(np.absolute(W))
def _l_2_loss(self, W):
return 0.5 * np.linalg.norm(W)
def _cross_entropy_loss(self, y, yhat):
loss = 0
yhat_log = np.log(yhat.T)
for i in range(len(y)):
loss -= y[... | code_fim | hard | {
"lang": "python",
"repo": "my-course-work/superDigits",
"path": "/homework6_blhylak_yliu17.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jocelinoFG017/IntroducaoAoPython path: /01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py
"""
Escreva um programa que leia as coordenadas x e y de um ponto R² e calcule
sua distância da origem(0,0).
"""
import math
<|fim_suffix|>print("Distância da origem {:.2f... | code_fim | medium | {
"lang": "python",
"repo": "jocelinoFG017/IntroducaoAoPython",
"path": "/01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print("Distância da origem {:.2f}".format(dist))<|fim_prefix|># repo: jocelinoFG017/IntroducaoAoPython path: /01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py
"""
Escreva um programa que leia as coordenadas x e y de um ponto R² e calcule
sua distância da origem(0,0).
... | code_fim | easy | {
"lang": "python",
"repo": "jocelinoFG017/IntroducaoAoPython",
"path": "/01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Distância da origem {:.2f}".format(dist))<|fim_prefix|># repo: jocelinoFG017/IntroducaoAoPython path: /01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py
"""
Escreva um programa que leia as coordenadas x e y de um ponto R² e calcule
sua distância da origem(0,0).
"... | code_fim | medium | {
"lang": "python",
"repo": "jocelinoFG017/IntroducaoAoPython",
"path": "/01-Cursos/GeekUniversity/Seção04-Váriaveis_e_tipos_de_dados/Exs_22_ao_53/S04_Ex51.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carllacan/serialseries path: /serialseries.py
# -*- coding: utf-8 -*-
import serial
import time
import argparse
def write_command(serial, comm, verbose = False, dt = None):
""" Encodes a command and sends it over the serial port """
if verbose and comm != "":
if ... | code_fim | hard | {
"lang": "python",
"repo": "carllacan/serialseries",
"path": "/serialseries.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def load_csv(f):
delimiter = ','
ts = []
cs = []
ps = []
for l in f.readlines():
values = l.strip("\n").split(delimiter)
ts.append(float(values[0]))
cs.append(values[1])
if len(values) <= 3: # if there isn't a third field
values.app... | code_fim | hard | {
"lang": "python",
"repo": "carllacan/serialseries",
"path": "/serialseries.py",
"mode": "spm",
"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.