text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
dependencies = [
('scheduyapp', '0008_auto_20180918_1051'),
]
operations = [
migrations.AlterModelOptions(
name='taskgroup',
options={'verbose_name': 'Group'},
),
]<|fim_prefix|># repo: mikgor/Scheduy path: /scheduyapp/migrations/0009_auto... | code_fim | easy | {
"lang": "python",
"repo": "mikgor/Scheduy",
"path": "/scheduyapp/migrations/0009_auto_20180918_1100.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('scheduyapp', '0008_auto_20180918_1051'),
]
operations = [
migrations.AlterModelOptions(
name='taskgroup',
options={'verbose_name': 'Group'},
),
]<|fim_prefix|># repo: mikgor/Scheduy... | code_fim | easy | {
"lang": "python",
"repo": "mikgor/Scheduy",
"path": "/scheduyapp/migrations/0009_auto_20180918_1100.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikgor/Scheduy path: /scheduyapp/migrations/0009_auto_20180918_1100.py
# Generated by Django 2.0.7 on 2018-09-18 09:00
from django.db import migrations
<|fim_suffix|> dependencies = [
('scheduyapp', '0008_auto_20180918_1051'),
]
operations = [
migrations.AlterModelOp... | code_fim | easy | {
"lang": "python",
"repo": "mikgor/Scheduy",
"path": "/scheduyapp/migrations/0009_auto_20180918_1100.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andreadlm/unito path: /anmat1/Esercizi/Collatz.py
# The script plots the sequence of Collatz
# starting from a specific n_0
import sys
import matplotlib.pyplot as plt
from matplotlib import style
style.use("Solarize_Light2")
<|fim_suffix|>seq = [n_0]
# The algorithm ends when 1 is reached
# af... | code_fim | medium | {
"lang": "python",
"repo": "andreadlm/unito",
"path": "/anmat1/Esercizi/Collatz.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Diagram visualization
plt.plot([j for j in range(len(seq))], seq, "mo--")
plt.axis([0, len(seq) + int(0.1 * len(seq)), 0, int(max(seq)) + int(0.1 * max(seq))])
plt.suptitle("Visualizing Collatz sequence for " + "n_0 = " + str(n_0))
plt.show()<|fim_prefix|># repo: andreadlm/unito path: /anmat1/Esercizi/... | code_fim | hard | {
"lang": "python",
"repo": "andreadlm/unito",
"path": "/anmat1/Esercizi/Collatz.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># import `calculator` module from a package
import basicmath.calculator
print( 'basicmath.calculator.add(1, 2) => ', basicmath.calculator.add(1, 2) )
# another module import style
from basicmath import calculator
print( 'calculator.add(1, 2) => ', calculator.add(1, 2) )
# python packages can have neste... | code_fim | hard | {
"lang": "python",
"repo": "Guruscode/getting-started-with-python",
"path": "/modules-and-packages/package.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># like __name__ variable inside a file tells if the file is imported as a module or executed as main. Likewise, __package__ tells how a module is accessed. If a file is executed as main, __package__ is `None`. If a file is accessed as module but does not contains inside a package, __package__ is empty. If... | code_fim | hard | {
"lang": "python",
"repo": "Guruscode/getting-started-with-python",
"path": "/modules-and-packages/package.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Guruscode/getting-started-with-python path: /modules-and-packages/package.py
# a package is collection of modules that can be imported under one name. A package is a directory containing module files. This directory should also contain `__init__.py` which is usually empty to make this directory a... | code_fim | hard | {
"lang": "python",
"repo": "Guruscode/getting-started-with-python",
"path": "/modules-and-packages/package.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LuWang765/logscan path: /match.py
from queue import Queue
import re
class Token:
LEFT_BLACKETS = 'LEFT_BLACKETS'
RIGHT_BLACKETS = 'RIGHT_BLACKETS'
SYMBOL = 'SYMBOL'
EXPRESSION = 'EXPRESSION'
SYMBOLS = '&|!'
def __init__(self, value, types):
self.value = value
... | code_fim | hard | {
"lang": "python",
"repo": "LuWang765/logscan",
"path": "/match.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.root = token
self.left = None
self.right = None
def visit(self):
ret = []
q = Queue()
q.put(self)
while not q.empty():
t = q.get()
ret.append(t.root)
if t.left:
q.put(t.left)
i... | code_fim | hard | {
"lang": "python",
"repo": "LuWang765/logscan",
"path": "/match.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linkserendipity/ICE path: /ice/trainers.py
from __future__ import print_function, absolute_import
import time
import numpy as np
import collections
import torch
import torch.nn as nn
from torch.nn import functional as F
from ice.loss import CrossEntropyLabelSmooth, ViewContrastiveLoss
from .util... | code_fim | hard | {
"lang": "python",
"repo": "linkserendipity/ICE",
"path": "/ice/trainers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._update_ema_variables(self.model_1, self.model_1_ema, self.alpha, epoch * len(data_loader_target) + i)
prec_1, = accuracy(p_out_t1.data, targets.data)
losses_ccl.update(loss_ccl.item())
losses_cam.update(loss_cam.item())
losses_vcl.update(... | code_fim | hard | {
"lang": "python",
"repo": "linkserendipity/ICE",
"path": "/ice/trainers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucasvalhos/books path: /PythoneDjangoDesenvolvimentoAgilDeAplicacoesWeb/1 - Starting/programa1.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# programa1.py - Primeiro programa
<|fim_suffix|>while escolha != numero:
escolha = input("Escolha um número entre 1 e 100:")
tentativas += 1... | code_fim | medium | {
"lang": "python",
"repo": "lucasvalhos/books",
"path": "/PythoneDjangoDesenvolvimentoAgilDeAplicacoesWeb/1 - Starting/programa1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>while escolha != numero:
escolha = input("Escolha um número entre 1 e 100:")
tentativas += 1
if escolha < numero:
print "O número", escolha ,"é menor que o sorteado."
elif escolha > numero:
print "O número", escolha ,"é maior que o sorteado."
print "Parabéns! Você acertou ... | code_fim | medium | {
"lang": "python",
"repo": "lucasvalhos/books",
"path": "/PythoneDjangoDesenvolvimentoAgilDeAplicacoesWeb/1 - Starting/programa1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> highlighter = INIHighligher()
self.snippet(code, highlighter=highlighter, line_numbers=False)
def templatesnippet(
self, code, lineno=1, colno=None, endcolno=None, extralines=3, line_numbers=True
):
with self._lock:
if not code:
return
... | code_fim | hard | {
"lang": "python",
"repo": "fkztw/moya",
"path": "/moya/console.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fkztw/moya path: /moya/console.py
mport struct
(
bufx,
bufy,
curx,
cury,
wattr,
left,
top,
right,
bo... | code_fim | hard | {
"lang": "python",
"repo": "fkztw/moya",
"path": "/moya/console.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> A table should be a list of lists, where each element is either a string
or a tuple of a string and a dictionary of attributes.
"""
table = list(table)
with self._lock:
if cell_processors is None:
cell_processors = {}
if head... | code_fim | hard | {
"lang": "python",
"repo": "fkztw/moya",
"path": "/moya/console.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: horzone/hwPython path: /hw4.py
# -*- coding: utf-8 -*-
# 1. После запуска предлагает пользователю ввести целые неотрицательные числа,
# разделенные любым не цифровым литералом (пробел, запятая, %, буква и т.д.).
# 2. Получив вводные данные, выделяет полученные числа, суммирует их,
# и печатает по... | code_fim | medium | {
"lang": "python",
"repo": "horzone/hwPython",
"path": "/hw4.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_line = []
for i in range(0, len(my_input)):
if my_input[i].isnumeric():
input_line.append(my_input[i])
elif my_input[i] == "-" and i+1 != len(my_input) and my_input[i+1].isnumeric():
if my_input[i+1].isnumeric():
input_line.append(" ")
... | code_fim | medium | {
"lang": "python",
"repo": "horzone/hwPython",
"path": "/hw4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ossdev07/flex path: /tests/loading/definition/parameters/single/test_in_validation.py
import pytest
from flex.constants import (
PARAMETER_IN_VALUES,
PATH,
BODY,
QUERY,
HEADER,
FORM_DATA,
)
from flex.error_messages import MESSAGES
from flex.exceptions import ValidationErr... | code_fim | hard | {
"lang": "python",
"repo": "ossdev07/flex",
"path": "/tests/loading/definition/parameters/single/test_in_validation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_in_must_be_one_of_valid_values():
with pytest.raises(ValidationError) as err:
single_parameter_validator({'in': 'not-a-valid-in-value'})
assert_message_in_errors(
MESSAGES['enum']['invalid'],
err.value.detail,
'in.enum',
)
@pytest.mark.parametrize(
... | code_fim | hard | {
"lang": "python",
"repo": "ossdev07/flex",
"path": "/tests/loading/definition/parameters/single/test_in_validation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akjasim/hmsproject path: /appointments/migrations/0002_auto_20191102_1516.py
# Generated by Django 2.2.6 on 2019-11-02 09:46
<|fim_suffix|> dependencies = [
('appointments', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='appointment'... | code_fim | medium | {
"lang": "python",
"repo": "akjasim/hmsproject",
"path": "/appointments/migrations/0002_auto_20191102_1516.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('appointments', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='appointment',
old_name='category',
new_name='department',
),
]<|fim_prefix|># repo: akjasim/hmsproject path: /appointments/... | code_fim | easy | {
"lang": "python",
"repo": "akjasim/hmsproject",
"path": "/appointments/migrations/0002_auto_20191102_1516.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shinn5112/Load-Testing path: /Examples/utilTests/mypsutil.py
import psutil as util
i = 0
cpuCount = util.cpu_count()
print("System Monitor Example\n"
"--------------------------------------------------------------------------------------------------------")
while i < 5:
cpuUsage = uti... | code_fim | hard | {
"lang": "python",
"repo": "shinn5112/Load-Testing",
"path": "/Examples/utilTests/mypsutil.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # getting the network usage
networkUsage = util.net_io_counters()
# we now need to manipulate the string output
networkUsage = str(networkUsage).split(',')
networkUsage[0] = networkUsage[0].strip("snetio(")
networkUsage[len(networkUsage) - 1] = networkUsage[len(networkUsage) - 1].r... | code_fim | hard | {
"lang": "python",
"repo": "shinn5112/Load-Testing",
"path": "/Examples/utilTests/mypsutil.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print("\n"
"Process info\n"
"--------------------------------------------------------------------------------------------------------")
i = 0
for proc in util.process_iter(): # iterates of all system processes in order of pid.
try:
# gets the info with the attached attribute name... | code_fim | hard | {
"lang": "python",
"repo": "shinn5112/Load-Testing",
"path": "/Examples/utilTests/mypsutil.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (n, k) in bathdata:
return bathdata[(n, k)]
if k == 1:
return (n//2, (n-1)//2)
elif k == 2:
return bath(n//2, 1)
else:
bathdata[(n, k)] = mymin(bath(n//2, k//2), bath((n-1)//2, (k-1)//2))
return bathdata[(n, k)]
import sys
T = sys.stdin.readline()
fo... | code_fim | medium | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_201/869.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_python/Problem_201/869.py
def mymin(a, b):
(x, y) = a
(c, d) = b
if x > c or (x == c and y > d):
return b
else:
return a
<|fim_suffix|> if (n, k) in bathdata:
return bathdata[(n, k)]
if k == 1:
... | code_fim | medium | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_201/869.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>int(tlist[0]),int(tlist[1]),int(tlist[2]))
print rgb
xx=(i*50,0)
yy=(i*50+50,100)
cv2.rectangle(img, xx, yy, rgb, -1)
i=i+1
cv2.imwrite("app/static/uploads/tempture.jpg",img)
#cv2.imshow("img",img)
#cv2.waitKey(0)
if __name_... | code_fim | medium | {
"lang": "python",
"repo": "336655asd/AI-ARTIST",
"path": "/AI-ARTIST/app/color/plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> i=i+1
cv2.imwrite("app/static/uploads/tempture.jpg",img)
#cv2.imshow("img",img)
#cv2.waitKey(0)
if __name__ == "__main__":
plot('feathers.jpg')<|fim_prefix|># repo: 336655asd/AI-ARTIST path: /AI-ARTIST/app/color/plot.py
#-*- coding=utf-8 -*-
import cv2
import numpy as np
im... | code_fim | medium | {
"lang": "python",
"repo": "336655asd/AI-ARTIST",
"path": "/AI-ARTIST/app/color/plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 336655asd/AI-ARTIST path: /AI-ARTIST/app/color/plot.py
#-*- coding=utf-8 -*-
import cv2
import numpy as np
import primary_c
def plot(pic_dir):
primary_c.temperature(pic_dir)
img = np.zeros((100,500,3),np.uint8)
#tem=<|fim_suffix|>int(tlist[0]),int(tlist[1]),int(tlist[2]))
... | code_fim | medium | {
"lang": "python",
"repo": "336655asd/AI-ARTIST",
"path": "/AI-ARTIST/app/color/plot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def cv_imwrite(f_path,im):
cv2.imencode('.jpg',im)[1].tofile(f_path)#保存图片<|fim_prefix|># repo: bandy101/my_git_respository path: /farAwaySFE/telemetry/__init__.py
import requests
import traceback
import os,random,re
from os import path
import json
import datetime,time
import shutil
from concurrent.fu... | code_fim | medium | {
"lang": "python",
"repo": "bandy101/my_git_respository",
"path": "/farAwaySFE/telemetry/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bandy101/my_git_respository path: /farAwaySFE/telemetry/__init__.py
import requests
import traceback
import os,random,re
from os import path
import json
import datetime,time
import shutil
from concurrent.futures import ThreadPoolExecutor,ALL_COMPLETED,wait,FIRST_COMPLETED
import numpy as np
impor... | code_fim | medium | {
"lang": "python",
"repo": "bandy101/my_git_respository",
"path": "/farAwaySFE/telemetry/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dennisbader/chess_game path: /__init__.py
from game_config import GameConfig
from <|fim_suffix|>King
from chess_operations import GameOps<|fim_middle|>game_board import GameBoard
from pieces import Pawn, Rook, Knight, Bishop, Queen, | code_fim | medium | {
"lang": "python",
"repo": "dennisbader/chess_game",
"path": "/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mport Pawn, Rook, Knight, Bishop, Queen, King
from chess_operations import GameOps<|fim_prefix|># repo: dennisbader/chess_game path: /__init__.py
from game_config import GameConfig
from <|fim_middle|>game_board import GameBoard
from pieces i | code_fim | easy | {
"lang": "python",
"repo": "dennisbader/chess_game",
"path": "/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>King
from chess_operations import GameOps<|fim_prefix|># repo: dennisbader/chess_game path: /__init__.py
from game_config import GameConfig
from game_board import GameBoard
from pieces i<|fim_middle|>mport Pawn, Rook, Knight, Bishop, Queen, | code_fim | easy | {
"lang": "python",
"repo": "dennisbader/chess_game",
"path": "/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jameygronewald/algorithmPractice path: /python/recursive_printing.py
def print_staircase(num_of_stairs):
<|fim_suffix|>print_staircase(20)
print_staircase(10)<|fim_middle|> if num_of_stairs == 1:
return print('#')
else:
print_staircase(num_of_stairs - 1)
print('#' *... | code_fim | medium | {
"lang": "python",
"repo": "jameygronewald/algorithmPractice",
"path": "/python/recursive_printing.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print_staircase(20)
print_staircase(10)<|fim_prefix|># repo: jameygronewald/algorithmPractice path: /python/recursive_printing.py
def print_staircase(num_of_stairs):
<|fim_middle|> if num_of_stairs == 1:
return print('#')
else:
print_staircase(num_of_stairs - 1)
print('#' *... | code_fim | medium | {
"lang": "python",
"repo": "jameygronewald/algorithmPractice",
"path": "/python/recursive_printing.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nanara1119/DataScience003 path: /7_ImageDeepLearning/2_makedata.py
import os, glob
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
<|fim_suffix|># 이미지 크기 지정
image_width = 64
image_height = 64
pixels = image_width * image_height
# 이미지 읽기
X = []
... | code_fim | medium | {
"lang": "python",
"repo": "nanara1119/DataScience003",
"path": "/7_ImageDeepLearning/2_makedata.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 이미지 읽기
X = []
Y = []
for idx, cat in enumerate(categories) :
# 레이블 지정
label = [0 for i in range(nb_classes)]
label[idx] = 1
# 이미지
image_dir = caltech_dir + "/" + cat
files = glob.glob(image_dir + "/*.jpg")
print(image_dir)
for i, f in enumerate(files) :
img... | code_fim | hard | {
"lang": "python",
"repo": "nanara1119/DataScience003",
"path": "/7_ImageDeepLearning/2_makedata.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret = BaseResponse()
try:
result = self.cmd("nic")
# ret['data'] = result
ret.data = result
except Exception as e:
# ret['status'] = False
# ret['error'] = traceback.format_exc() #traceback让日志显示的更详细
ret.s... | code_fim | medium | {
"lang": "python",
"repo": "mowangmo/cmdb",
"path": "/autoclient/src/plugins/nic.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mowangmo/cmdb path: /autoclient/src/plugins/nic.py
from . base import BasePlugin
from lib.response import BaseResponse
import traceback
<|fim_suffix|> ret = BaseResponse()
try:
result = self.cmd("nic")
# ret['data'] = result
ret.data = result
... | code_fim | medium | {
"lang": "python",
"repo": "mowangmo/cmdb",
"path": "/autoclient/src/plugins/nic.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def linux(self):
ret = BaseResponse()
try:
result = self.cmd("nic")
# ret['data'] = result
ret.data = result
except Exception as e:
# ret['status'] = False
# ret['error'] = traceback.format_exc() #traceback让日志显示的... | code_fim | medium | {
"lang": "python",
"repo": "mowangmo/cmdb",
"path": "/autoclient/src/plugins/nic.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LucasBoTang/Algorithms-Stanford path: /4 Shortest Paths Revisited, NP-Complete Problems and What To Do About Them/Week 3/4wk1_a3.py
"""
Traveling salesman problem (large)
"""
import numpy as np
f = open('nn.txt', 'r')
ls = f.readlines()[1:]
graph = [list(map(float, i.split(' ')))[1:] for i in l... | code_fim | medium | {
"lang": "python",
"repo": "LucasBoTang/Algorithms-Stanford",
"path": "/4 Shortest Paths Revisited, NP-Complete Problems and What To Do About Them/Week 3/4wk1_a3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (graph[i][0]-graph[j][0])**2+(graph[i][1]-graph[j][1])**2
tour = [0]
travel = 0
g = graph.copy()
g.pop(0)
while len(g) > 0:
plan = 1e9
for c in g:
d = dis(tour[-1], c)
if d < plan:
plan = d
city = c
travel += np.sqrt(plan)
tour += [city... | code_fim | medium | {
"lang": "python",
"repo": "LucasBoTang/Algorithms-Stanford",
"path": "/4 Shortest Paths Revisited, NP-Complete Problems and What To Do About Them/Week 3/4wk1_a3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lawrennd/liquid path: /liquid/token.py
"""Token definitions"""
import sys
from typing import NamedTuple
__all__ = (
"TOKEN_ILLEGAL",
"TOKEN_INITIAL",
"TOKEN_EOF",
"TOKEN_TAG",
"TOKEN_EXPRESSION",
"TOKEN_STATEMENT",
"TOKEN_LITERAL",
"TOKEN_IDENTIFIER",
"TOKEN_... | code_fim | hard | {
"lang": "python",
"repo": "lawrennd/liquid",
"path": "/liquid/token.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Tablerow specific argument
TOKEN_COLS = sys.intern("cols")
# Comparison symbols and logic operators for `if` and `unless` tags.
TOKEN_EQ = sys.intern("eq")
TOKEN_NE = sys.intern("ne")
TOKEN_LG = sys.intern("ltgt")
TOKEN_LT = sys.intern("lt")
TOKEN_GT = sys.intern("gt")
TOKEN_LE = sys.intern("le")
TOKEN... | code_fim | hard | {
"lang": "python",
"repo": "lawrennd/liquid",
"path": "/liquid/token.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henrysky/astroNN path: /tests/test_apogee_tools.py
import unittest
import numpy as np
import numpy.testing as npt
from astroNN.apogee import (
gap_delete,
apogee_default_dr,
bitmask_decompositor,
chips_split,
bitmask_boolean,
apogee_continuum,
aspcap_mask,
combine... | code_fim | hard | {
"lang": "python",
"repo": "henrysky/astroNN",
"path": "/tests/test_apogee_tools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test apogeeid digit extractor
# just to make no error
apogeeid_digit(["2M00380508+5608579", "2M00380508+5608579"])
apogeeid_digit(np.array(["2M00380508+5608579", "2M00380508+5608579"]))
# check accuracy
self.assertEqual(apogeeid_digit("2M00380508+5608579"... | code_fim | hard | {
"lang": "python",
"repo": "henrysky/astroNN",
"path": "/tests/test_apogee_tools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: victor30518/MLDS2018SPRING path: /hw3/generate_3_1.py
import argparse
import numpy as np
import sys
import torch
import torch.nn as nn
from torch.autograd import Variable
cuda = True if torch.cuda.is_available() else False
class Generator(nn.Module):
def __init__(self):
super(Genera... | code_fim | medium | {
"lang": "python",
"repo": "victor30518/MLDS2018SPRING",
"path": "/hw3/generate_3_1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>import matplotlib.pyplot as plt
r, c = 5, 5
fig, axs = plt.subplots(r, c)
cnt = 0
for i in range(r):
for j in range(c):
axs[i,j].imshow(gen_imgs.data[cnt].cpu().numpy().transpose(1,2,0))
axs[i,j].axis('off')
cnt += 1
fig.savefig("./samples/gan.png")
plt.close()<|fim_prefix|># r... | code_fim | hard | {
"lang": "python",
"repo": "victor30518/MLDS2018SPRING",
"path": "/hw3/generate_3_1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def subarraySum(self, nums: List[int], k: int) -> int:
d = defaultdict(int)
acc = count = 0
for num in nums:
acc += num
if acc == k:
count += 1
if acc - k in d:
count += d[acc-k]
d[acc] += 1
... | code_fim | hard | {
"lang": "python",
"repo": "ZhiyuSun/leetcode-practice",
"path": "/501-800/560_和为K的子数组.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def subarraySum(self, nums: List[int], k: int) -> int:
dic = {}
dic[0] = 1
s = 0
count = 0
for i in range(len(nums)):
s += nums[i]
if s - k in dic:
count += dic[s-k]
if s in dic:
dic[s] += 1
... | code_fim | hard | {
"lang": "python",
"repo": "ZhiyuSun/leetcode-practice",
"path": "/501-800/560_和为K的子数组.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZhiyuSun/leetcode-practice path: /501-800/560_和为K的子数组.py
"""
给定一个整数数组和一个整数 k,你需要找到该数组中和为 k 的连续的子数组的个数。
示例 1 :
输入:nums = [1,1,1], k = 2
输出: 2 , [1,1] 与 [1,1] 为两种不同的情况。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/subarray-sum-equals-k
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
"""
from collectio... | code_fim | hard | {
"lang": "python",
"repo": "ZhiyuSun/leetcode-practice",
"path": "/501-800/560_和为K的子数组.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
my_1 = Matrix(matrix_list=[[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(f'Матрица №1: \n{my_1}')
my_2 = Matrix(matrix_list=[[2, 3, 4], [5, 6, 7], [8, 9, 10]])
print(f'Матрица №2: \n{my_2}')
print(f'Сумма матриц: \n{my_1 + my_2}')<|fim_prefix|># repo: Ka1str/Python-GB- path: /lesson-7/task-1-7.py
class Matr... | code_fim | hard | {
"lang": "python",
"repo": "Ka1str/Python-GB-",
"path": "/lesson-7/task-1-7.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ka1str/Python-GB- path: /lesson-7/task-1-7.py
class Matrix:
def __init__(self, matrix_list):
self.matrix_list = matrix_list
def __str__(self):
return '\n'.join(['\t'.join(['%d' % i for i in row]) for row in self.matrix_list])
<|fim_suffix|> for j in range(len(... | code_fim | medium | {
"lang": "python",
"repo": "Ka1str/Python-GB-",
"path": "/lesson-7/task-1-7.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rajat-coder/Database_storing_software path: /Mainframeemp.py
import time
from tkinter import *
import sys
from ADDCLASS import addclass
from ADDTRADEMARK import addtrademark
from LISTBYCLASS import trademarklistbyclass
from TRADEMARKLIST import trademarkdetails
from UPDATE import updatetrademark... | code_fim | medium | {
"lang": "python",
"repo": "Rajat-coder/Database_storing_software",
"path": "/Mainframeemp.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mywindow.bind("<Control-q>", self.quitwindow)
def quitwindow(self, e):
sys.exit()
def addtrademarkform(self):
addtrademark(self.mywindow)
def addclassform(self):
addclass(self.mywindow)
def trademarklistform(self):
trademarkdetails(self.mywindow... | code_fim | hard | {
"lang": "python",
"repo": "Rajat-coder/Database_storing_software",
"path": "/Mainframeemp.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class PseudoPropParent(qstylizer.descriptor.stylerule.StyleRuleParent):
"""Pseudo-property setter.
Contains descriptors for all known pseudo-properties.
"""
_descriptor_cls = PseudoPropDescriptor
left = _descriptor_cls("left")
right = _descriptor_cls("right")
top = _descript... | code_fim | medium | {
"lang": "python",
"repo": "blambright/qstylizer",
"path": "/qstylizer/descriptor/pseudoprop.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Contains descriptors for all known pseudo-properties.
"""
_descriptor_cls = PseudoPropDescriptor
left = _descriptor_cls("left")
right = _descriptor_cls("right")
top = _descriptor_cls("top")
bottom = _descriptor_cls("bottom")<|fim_prefix|># repo: blambright/qstylizer path: /q... | code_fim | hard | {
"lang": "python",
"repo": "blambright/qstylizer",
"path": "/qstylizer/descriptor/pseudoprop.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Starmuckss/Github-Icat path: /cryptoslam_mints.py
# -*- coding: utf-8 -*-
"""
Get historical information of a series from /mints. Eg: https://cryptoslam.io/cryptopunks/mints
@author: HP
"""
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import pandas
import time
i... | code_fim | hard | {
"lang": "python",
"repo": "Starmuckss/Github-Icat",
"path": "/cryptoslam_mints.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> table = pandas.read_html(browser.page_source)[0]
table = table[1:]
table["Original Owner"] = original_owner_data[1:]
table["NFT_links"] = nft_data
table["Minted_link"] = etherscan_links
table["Minted"] = find_transaction_time(table... | code_fim | hard | {
"lang": "python",
"repo": "Starmuckss/Github-Icat",
"path": "/cryptoslam_mints.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SBRG/sbaas path: /sbaas/models/models_stage00.py
ate);
order_standard = Column(Boolean);
standards_storage = Column(Float);
purchase = Column(Boolean)
__table_args__ = (PrimaryKeyConstraint('met_id','provider','provider_reference'),
)
def __init__(self,met_id_I,me... | code_fim | hard | {
"lang": "python",
"repo": "SBRG/sbaas",
"path": "/sbaas/models/models_stage00.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self,sample_id_I,
#sample_dateAndTime_I,
sample_label_I,ph_I,box_I,pos_I):
self.sample_id = sample_id_I
self.sample_label = sample_label_I
#self.sample_dateAndTime = sample_dateAndTime_I
self.ph = ph_I
self.box = bo... | code_fim | hard | {
"lang": "python",
"repo": "SBRG/sbaas",
"path": "/sbaas/models/models_stage00.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SBRG/sbaas path: /sbaas/models/models_stage00.py
(20));
intercept = Column(Float);
slope = Column(Float);
correlation = Column(Float);
use_area = Column(Boolean, default = False)
lloq = Column(Float);
uloq = Column(Float);
points = Column(Integer)
__table_args__ = ... | code_fim | hard | {
"lang": "python",
"repo": "SBRG/sbaas",
"path": "/sbaas/models/models_stage00.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NithyaBS/first_test path: /evenodd.py
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: admin
#
# Created: 18/01/2019
# Copyright: (c) admin 2019
# Licence: <your licence>
#-----------------------... | code_fim | medium | {
"lang": "python",
"repo": "NithyaBS/first_test",
"path": "/evenodd.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> a = [] # start an empty list
n = int(input("Enter no.of elements:")) # read number of element in the list
for i in range(n):
new_element = int(input("Enter element:")) # read next element
a.append(new_element) #
even_lst = []
odd_lst = []
count_even=0
count_... | code_fim | medium | {
"lang": "python",
"repo": "NithyaBS/first_test",
"path": "/evenodd.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vsasvipul0605/Self-Driving-Car-App path: /Car and Pedestrian Tracking.py
import cv2
# create opencv image
img = cv2.imread('car.png')
# video = cv2.VideoCapture('Teslas Avoiding Accidents Compilation.mp4')
video = cv2.VideoCapture('videoplayback.mp4')
# convert to grayscale
grayscale = cv2.cvtC... | code_fim | hard | {
"lang": "python",
"repo": "vsasvipul0605/Self-Driving-Car-App",
"path": "/Car and Pedestrian Tracking.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>while True:
# read the current frame
(read_successful, frame) = video.read()
# safe coding
if read_successful:
# convert to grayscale
grayscale_vid = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
else:
break
# detect cars
cars = car_tracker.detectMultiScal... | code_fim | hard | {
"lang": "python",
"repo": "vsasvipul0605/Self-Driving-Car-App",
"path": "/Car and Pedestrian Tracking.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> telegram_function(message_id=message_id,chat_id=chat_id,message=message)
def telegram_trigger(event, context):
logger.info("lambda event triggered")
logger.info(f"{context}")
logger.info(f"{event}")
requests_body = proccess_lambda_headers(event, 'body')
if not requests_body:
... | code_fim | hard | {
"lang": "python",
"repo": "Javier162380/Serverless-stuff",
"path": "/Telegram-bot/src/telegram_app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> help_message = f'Translate a message to the language you want, follow this steps:\n' \
f'\t\t 1.Choose your target translate language in the two digits code.\n' \
f'\t\t\t\t To see all the differents languages codes use /languages command.\n' \
... | code_fim | hard | {
"lang": "python",
"repo": "Javier162380/Serverless-stuff",
"path": "/Telegram-bot/src/telegram_app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Javier162380/Serverless-stuff path: /Telegram-bot/src/telegram_app.py
import json
import logging
import os
import sys
from dotenv import load_dotenv,find_dotenv
from telebot import TeleBot
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from src.yandex_api import yandex_diccionary
fro... | code_fim | hard | {
"lang": "python",
"repo": "Javier162380/Serverless-stuff",
"path": "/Telegram-bot/src/telegram_app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def run(self):
while True:
if self.enableTempEmulator: #If enableTempEmulator is false then using sense_hat to get current temperature!
self.currentTemp=self.tempSensorEmulator.getCurrValue()
else:
self.currentTemp=self.sh.get_temperature... | code_fim | hard | {
"lang": "python",
"repo": "LeoChengLeo/IoT-Project",
"path": "/iotDeviceApplication/iotConnectedDeviceApp/iotDeviceApp/tempSensorAdaptor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LeoChengLeo/IoT-Project path: /iotDeviceApplication/iotConnectedDeviceApp/iotDeviceApp/tempSensorAdaptor.py
'''
Created on Sep 29, 2018
@author: Leo
'''
from configReader import ConfigReader
from sensorEmulator import SensorEmulator
from threading import Thread
from sensorData import SensorData... | code_fim | medium | {
"lang": "python",
"repo": "LeoChengLeo/IoT-Project",
"path": "/iotDeviceApplication/iotConnectedDeviceApp/iotDeviceApp/tempSensorAdaptor.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qtile/qtile path: /libqtile/scripts/migrate.py
# Copyright (c) 2021, Tycho Andersen. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without rest... | code_fim | hard | {
"lang": "python",
"repo": "qtile/qtile",
"path": "/libqtile/scripts/migrate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def do_migrate(args):
if "bowler" not in sys.modules:
print("bowler can't be found, not migrating config file")
print("install it and try again")
sys.exit(1)
config_dir = os.path.dirname(args.config)
for py, backup in file_and_backup(config_dir):
shutil.copyfi... | code_fim | hard | {
"lang": "python",
"repo": "qtile/qtile",
"path": "/libqtile/scripts/migrate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shizhanmu/Python005-01 path: /week07/simple_map.py
class simplemap:
""" 用迭代器协议实现 map 功能 """
def __init__(self, func, *sequences):
self.func = func
self.sequences = sequences
self.i = -1
def __iter__(self):
<|fim_suffix|>result = simplemap(add_one, lst, ... | code_fim | hard | {
"lang": "python",
"repo": "shizhanmu/Python005-01",
"path": "/week07/simple_map.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lst = [1, 2, 3]
lst2 = [4, 5]
lst3 = [7, 8, 9, 10]
result = simplemap(add_one, lst, lst2, lst3)
result = mapper(add_one, lst, lst2, lst3)
type(result)<|fim_prefix|># repo: shizhanmu/Python005-01 path: /week07/simple_map.py
class simplemap:
""" 用迭代器协议实现 map 功能 """
def __init__(self, func, *sequen... | code_fim | hard | {
"lang": "python",
"repo": "shizhanmu/Python005-01",
"path": "/week07/simple_map.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return x + y + z
lst = [1, 2, 3]
lst2 = [4, 5]
lst3 = [7, 8, 9, 10]
result = simplemap(add_one, lst, lst2, lst3)
result = mapper(add_one, lst, lst2, lst3)
type(result)<|fim_prefix|># repo: shizhanmu/Python005-01 path: /week07/simple_map.py
class simplemap:
""" 用迭代器协议实现 map 功能 """
def __init... | code_fim | hard | {
"lang": "python",
"repo": "shizhanmu/Python005-01",
"path": "/week07/simple_map.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:type employees: Employee
:type id: int
:rtype: int
"""
# Be careful of this.
# This is WRONG. If in doubt, try it.
#id_importance, id_sub = [(employee.importance, employee.subordinates) for employee in employees if employee.id == id]
... | code_fim | medium | {
"lang": "python",
"repo": "MaxMeiY/leetcode",
"path": "/employee_importance.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaxMeiY/leetcode path: /employee_importance.py
"""
# Employee info
class Employee:
def __init__(self, id, importance, subordinates):
# It's the unique id of each node.
# unique id of this employee
self.id = id
# the importance value of this employee
sel... | code_fim | medium | {
"lang": "python",
"repo": "MaxMeiY/leetcode",
"path": "/employee_importance.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KirbyG/popils-np-completeness path: /game.py
from abc import ABC, abstractmethod
from common import COLORS, Vector
# tile-based game, either popils or megalit
class Game(ABC):
# subclasses must expose a method to generate a solving move sequence
@abstractmethod
def solve(self):
... | code_fim | hard | {
"lang": "python",
"repo": "KirbyG/popils-np-completeness",
"path": "/game.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, pos):
self.pos = pos
self.color = (255, 0, 0) # red
self.gripping = Vector(0, 0)
# wrapper for a 2d matrix allowing vector indexing
class Grid:
def __init__(self, *args):
if callable(args[-1]):
initializer = args[-1]
arg... | code_fim | hard | {
"lang": "python",
"repo": "KirbyG/popils-np-completeness",
"path": "/game.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if type(key) == Vector:
return self.grid[int(key.x)][int(key.y)]
else:
x, y = key
return self.grid[int(x)][int(y)]
def __setitem__(self, key, value):
if type(key) == Vector:
self.grid[int(key.x)][int(key.y)] = value
else:... | code_fim | hard | {
"lang": "python",
"repo": "KirbyG/popils-np-completeness",
"path": "/game.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_switchover_system(self):
cs.system.switchover(1)
cs.assert_called('PUT', '/chassis/system/switchover')
def test_writemem_system(self):
cs.system.writemem(1)
cs.assert_called('PUT', '/chassis/system/writeMem')
def test_reload_system(self):
cs.s... | code_fim | medium | {
"lang": "python",
"repo": "ubuntu/python-seamicroclient",
"path": "/seamicroclient/tests/v2/test_system.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ubuntu/python-seamicroclient path: /seamicroclient/tests/v2/test_system.py
# -*- coding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "ubuntu/python-seamicroclient",
"path": "/seamicroclient/tests/v2/test_system.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_writemem_system(self):
cs.system.writemem(1)
cs.assert_called('PUT', '/chassis/system/writeMem')
def test_reload_system(self):
cs.system.reload(1)
cs.assert_called('PUT', '/chassis/system/reload')<|fim_prefix|># repo: ubuntu/python-seamicroclient path: /s... | code_fim | hard | {
"lang": "python",
"repo": "ubuntu/python-seamicroclient",
"path": "/seamicroclient/tests/v2/test_system.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Frankiee/leetcode path: /base_convert/9_palindrome_number.py
# https://leetcode.com/problems/palindrome-number/
# 9. Palindrome Number
# History:
# Google
# 1.
# Mar 13, 2020
# Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same
# backward as forward.... | code_fim | medium | {
"lang": "python",
"repo": "Frankiee/leetcode",
"path": "/base_convert/9_palindrome_number.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:type x: int
:rtype: bool
"""
if x < 0:
return False
ranger = 1
while x / ranger >= 10:
ranger *= 10
while x > 0:
left = x / ranger
right = x % 10
if left != right:
... | code_fim | medium | {
"lang": "python",
"repo": "Frankiee/leetcode",
"path": "/base_convert/9_palindrome_number.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: palakbaphna/pyprac path: /print function/print Numbers/5PrintDivisionResult.py
#N students take K apples and distribute them among each other evenly. The remaining (the undivisible)
# part remains in the basket. How many apples will each single student get? How many apples will remain in the bask... | code_fim | medium | {
"lang": "python",
"repo": "palakbaphna/pyprac",
"path": "/print function/print Numbers/5PrintDivisionResult.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Number of undivisible apples = ", k % n) #example of getting remainder<|fim_prefix|># repo: palakbaphna/pyprac path: /print function/print Numbers/5PrintDivisionResult.py
#N students take K apples and distribute them among each other evenly. The remaining (the undivisible)
# part remains in the b... | code_fim | medium | {
"lang": "python",
"repo": "palakbaphna/pyprac",
"path": "/print function/print Numbers/5PrintDivisionResult.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: massover/django_testing_guide path: /dogs/tests/test_model_serializers.py
"""
3 useful tests that cover ``ModelSerializer`` behavior are:
- ``test_deserialize_all_fields``
- ``test_deserialize_required_fields`` (optional)
- ``test_serialize_all_fields``
For code that implements create functiona... | code_fim | hard | {
"lang": "python",
"repo": "massover/django_testing_guide",
"path": "/dogs/tests/test_model_serializers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.django_db
def test_deserialize_all_fields():
"""
Test all fields of the deserialization. Validate the
``serializer.save()`` deserializes and creates a new object in the
datastore with all fields.
- Initialize ``serializer`` with all fields
- Assert ``serializer.is_va... | code_fim | hard | {
"lang": "python",
"repo": "massover/django_testing_guide",
"path": "/dogs/tests/test_model_serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> - Initialize ``serializer`` with empty data set
- Assert ``serializer.is_valid()`` is ``False``
- Assert ``len(serializer.errors)`` reflects the number of required fields
- Initialize ``serializer`` with only required fields
- Assert ``serializer.is_valid()`` is ``True``
- Deseri... | code_fim | hard | {
"lang": "python",
"repo": "massover/django_testing_guide",
"path": "/dogs/tests/test_model_serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CGayatri/Python-Practice1 path: /string_finding_substring_5.py
## program 5 - to find the first occurrence of sub string in a given string using index() method
<|fim_suffix|>try:
n = str.index(sub, 0, len(str))
except ValueError:
print('Sub string not found')
else:
print('Sub string... | code_fim | hard | {
"lang": "python",
"repo": "CGayatri/Python-Practice1",
"path": "/string_finding_substring_5.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
'''
F:\PY>py string_finding_substring_5.py
Enter main string: This is a boook
Enter sub string: s
Sub string found at position : 4
F:\PY>
'''<|fim_prefix|># repo: CGayatri/Python-Practice1 path: /string_finding_substring_5.py
## program 5 - to find the first occurrence of sub string in a given stri... | code_fim | hard | {
"lang": "python",
"repo": "CGayatri/Python-Practice1",
"path": "/string_finding_substring_5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def event_type(request, slug):
type = get_object_or_404(models.EventType.objects.all(), slug=slug)
occurrences = models.Occurrence.objects.filter(Q(event__primary_type=type) | Q(event__secondary_types=type)).upcoming().visible()
context = RequestContext(request, {
'type': type,
... | code_fim | hard | {
"lang": "python",
"repo": "ic-labs/django-icekit",
"path": "/icekit_events/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ic-labs/django-icekit path: /icekit_events/views.py
"""
Views for ``icekit_events`` app.
"""
# Do not use generic class based views unless there is a really good reason to.
# Functional views are much easier to comprehend and maintain.
import warnings
from django.core.exceptions import Permissi... | code_fim | hard | {
"lang": "python",
"repo": "ic-labs/django-icekit",
"path": "/icekit_events/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mic0ud/Leetcode-py3 path: /src/433.minimum-genetic-mutation.py
#
# @lc app=leetcode id=433 lang=python3
#
# [433] Minimum Genetic Mutation
#
# https://leetcode.com/problems/minimum-genetic-mutation/description/
#
# algorithms
# Medium (39.60%)
# Likes: 342
# Dislikes: 42
# Total Accepted: 2... | code_fim | hard | {
"lang": "python",
"repo": "mic0ud/Leetcode-py3",
"path": "/src/433.minimum-genetic-mutation.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generateNext(self, gene, seen, bank) -> []:
res = []
for i,c in enumerate(gene):
for g in 'ACGT':
if g != c:
tmp = gene[:i]+g+gene[i+1:]
if tmp not in seen and tmp in bank:
res.append(tmp)
... | code_fim | hard | {
"lang": "python",
"repo": "mic0ud/Leetcode-py3",
"path": "/src/433.minimum-genetic-mutation.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.