text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: tomasz-pankowski/hackerrank path: /the_coin_change_problem.py
#!/bin/python3
import sys
# import numpy as np
def _get_change_making_matrix(set_of_coins, r):
matrix = [[0 for _ in range(r + 1)] for _ in range(len(set_of_coins) + 1)]
# matrix = np.array(matrix)
for i in range(1,len(s... | code_fim | hard | {
"lang": "python",
"repo": "tomasz-pankowski/hackerrank",
"path": "/the_coin_change_problem.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Closes all previous plots so that we don't have to click them away manually
plt.close('all')
#Defining some constants:
SLHighway10 = 53.5 #dB, this is the sound level of a highway at 10 m distance
d1 = 10. #m, distance between the highway and the sound barrier
#Creating data mesh
b = np.ara... | code_fim | medium | {
"lang": "python",
"repo": "svengeboers/DSE",
"path": "/OptimalSpacingUpdatedSoundLevel.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: svengeboers/DSE path: /OptimalSpacingUpdatedSoundLevel.py
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 25 13:34:46 2017
@author: Sven Geboers
"""
from math import pi,e
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
def LevelToIntensity(NoiseLevelIndB... | code_fim | hard | {
"lang": "python",
"repo": "svengeboers/DSE",
"path": "/OptimalSpacingUpdatedSoundLevel.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>HOUR = 3600 # 3600 seconds in an hour
MINUTE = 60 # 60 seconds in a minute
input_one = time_one * HOUR + time_two * MINUTE + time_three
input_two = time_four * HOUR + time_five * MINUTE + time_six
print(abs(input_one - input_two))<|fim_prefix|># repo: HarryIsSecured/zookeper-python-hyperskill path: /... | code_fim | medium | {
"lang": "python",
"repo": "HarryIsSecured/zookeper-python-hyperskill",
"path": "/Problems/Difference of times/task.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HarryIsSecured/zookeper-python-hyperskill path: /Problems/Difference of times/task.py
# put your python code here
time_one = abs(int(input()))
time_two = abs(int(input()))
time_three = abs(int(input()))
<|fim_suffix|>input_one = time_one * HOUR + time_two * MINUTE + time_three
input_two = time_f... | code_fim | medium | {
"lang": "python",
"repo": "HarryIsSecured/zookeper-python-hyperskill",
"path": "/Problems/Difference of times/task.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("myPickle load file",fileName)
tr = pickle.load( open(fileName,'rb') )
print(" DONE")
return tr<|fim_prefix|># repo: yOyOeK1/printMillPostProcess path: /myPickle.py
import pickle
class myPickle:
def make(self, obj,fileName):
<|fim_middle|> print(... | code_fim | medium | {
"lang": "python",
"repo": "yOyOeK1/printMillPostProcess",
"path": "/myPickle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yOyOeK1/printMillPostProcess path: /myPickle.py
import pickle
class myPickle:
<|fim_suffix|> print("myPickle make file",fileName)
pickle.dump( obj, open(fileName,'wb') )
print(" DONE")
def load(self, fileName):
print("myPickle load file",fileN... | code_fim | easy | {
"lang": "python",
"repo": "yOyOeK1/printMillPostProcess",
"path": "/myPickle.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def load(self, fileName):
print("myPickle load file",fileName)
tr = pickle.load( open(fileName,'rb') )
print(" DONE")
return tr<|fim_prefix|># repo: yOyOeK1/printMillPostProcess path: /myPickle.py
import pickle
class myPickle:
<|fim_middle|> def make(self,... | code_fim | medium | {
"lang": "python",
"repo": "yOyOeK1/printMillPostProcess",
"path": "/myPickle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> figure.add_subplot(1, negative_images.shape[0], count)
plt.imshow(negative_images[i, :, :])
plt.axis('off')
plt.title("0")
plt.show()<|fim_prefix|># repo: MarcBotsford/RocketWreckers-ECEE path: /Custom_Classifier_helpers.py
import matplotlib.pyplot as plt
def vi... | code_fim | hard | {
"lang": "python",
"repo": "MarcBotsford/RocketWreckers-ECEE",
"path": "/Custom_Classifier_helpers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarcBotsford/RocketWreckers-ECEE path: /Custom_Classifier_helpers.py
import matplotlib.pyplot as plt
def visualize_data(positive_images, negative_images):
<|fim_suffix|> figure = plt.figure()
count = 0
for i in range(positive_images.shape[0]):
count += 1
figure.... | code_fim | medium | {
"lang": "python",
"repo": "MarcBotsford/RocketWreckers-ECEE",
"path": "/Custom_Classifier_helpers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> figure = plt.figure()
count = 0
for i in range(positive_images.shape[0]):
count += 1
figure.add_subplot(2, positive_images.shape[0], count)
plt.imshow(positive_images[i, :, :])
plt.axis('off')
plt.title("1")
figure.add_subplot(1, negati... | code_fim | medium | {
"lang": "python",
"repo": "MarcBotsford/RocketWreckers-ECEE",
"path": "/Custom_Classifier_helpers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhems/vgql path: /configuration.py
'''
Module for handling configurable portions of tools
'''
from json import load
default_file_loc = 'config.json'
config = None
def loadConfiguration(fileloc):
<|fim_suffix|>def get(key):
'''Gets the configuration value for key '''
return config[key]
... | code_fim | hard | {
"lang": "python",
"repo": "mhems/vgql",
"path": "/configuration.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Gets the configuration value for key '''
return config[key]
loadConfiguration(default_file_loc)<|fim_prefix|># repo: mhems/vgql path: /configuration.py
'''
Module for handling configurable portions of tools
'''
from json import load
default_file_loc = 'config.json'
config = None
def loadCo... | code_fim | medium | {
"lang": "python",
"repo": "mhems/vgql",
"path": "/configuration.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get(key):
'''Gets the configuration value for key '''
return config[key]
loadConfiguration(default_file_loc)<|fim_prefix|># repo: mhems/vgql path: /configuration.py
'''
Module for handling configurable portions of tools
'''
from json import load
default_file_loc = 'config.json'
config = No... | code_fim | hard | {
"lang": "python",
"repo": "mhems/vgql",
"path": "/configuration.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>um1 / num2
print(result)
else:
print('You didi choose the right operation')
except:
#
print("Impoper numbers or Operation")<|fim_prefix|># repo: spkibe/calc path: /calc.py
operation = input('operation type: ').lower()
num1 = input("First number: ")
num2 = input("First number:... | code_fim | medium | {
"lang": "python",
"repo": "spkibe/calc",
"path": "/calc.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spkibe/calc path: /calc.py
operation = input('operation type: ').lower()
num1 = input("First number: ")
num2 = input("First number: ")
try:
num1, num2 = float(num1), float(n<|fim_suffix|>um1 / num2
print(result)
else:
print('You didi choose the right operation')
except:
... | code_fim | hard | {
"lang": "python",
"repo": "spkibe/calc",
"path": "/calc.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: newcountwhy/LP2T2X path: /ECO/reward/migrations/0003_order.py
# Generated by Django 3.2.6 on 2021-10-10 17:17
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
<|fim_suffix|>
initial = True
dependencies = [
mi... | code_fim | medium | {
"lang": "python",
"repo": "newcountwhy/LP2T2X",
"path": "/ECO/reward/migrations/0003_order.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='order',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('created_date', models.DateField(auto_now_add=True)),
... | code_fim | medium | {
"lang": "python",
"repo": "newcountwhy/LP2T2X",
"path": "/ECO/reward/migrations/0003_order.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('reward', '0002_delete_user'),
]
operations = [
migrations.CreateModel(
name='order',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=Fals... | code_fim | medium | {
"lang": "python",
"repo": "newcountwhy/LP2T2X",
"path": "/ECO/reward/migrations/0003_order.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matteoghera/ProgettoDSP path: /main/EnigmaRotor.py
import main.Tools
class EnigmaRotor:
def __init__(self, entrata, uscita, rotore_succ=None, flag=True):
self.entrata=entrata.copy()
self.uscita=uscita.copy()
self.numeroSpostamenti=0
self.flag=flag
sel... | code_fim | hard | {
"lang": "python",
"repo": "matteoghera/ProgettoDSP",
"path": "/main/EnigmaRotor.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Sposta di una posizione gli elementi dei vettori
def muovi(self):
if self.flag==True:
self.numeroSpostamenti=self.numeroSpostamenti+1
self.sposta()
if self.numeroSpostamenti>26 and not(self.rotore_succ is None):
self.rotore_succ.muovi()
... | code_fim | hard | {
"lang": "python",
"repo": "matteoghera/ProgettoDSP",
"path": "/main/EnigmaRotor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Data la posizione nel vettore 'uscita', si cerca la lettera corrispondente nel vettore 'entrata' e si restituisce
#la sua posizione
def posizioneDestra(self, posizione):
return main.Tools.search(self.entrata, self.uscita[posizione])
#Sposta di una posizione gli elementi dei vetto... | code_fim | hard | {
"lang": "python",
"repo": "matteoghera/ProgettoDSP",
"path": "/main/EnigmaRotor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ascend/ModelZoo-PyTorch path: /PyTorch/contrib/cv/semantic_segmentation/MMseg-swin/mmcv/mmcv/utils/env.py
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2017
# All rights reserved.
# Copyright 2022 Huawei Technologies Co., Ltd
#
# Redistribution and use in source and binary form... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/contrib/cv/semantic_segmentation/MMseg-swin/mmcv/mmcv/utils/env.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cuda_available = torch.cuda.is_available()
env_info['CUDA available'] = cuda_available
if cuda_available:
devices = defaultdict(list)
for k in range(torch.cuda.device_count()):
devices[torch.cuda.get_device_name(k)].append(str(k))
for name, device_ids in de... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/contrib/cv/semantic_segmentation/MMseg-swin/mmcv/mmcv/utils/env.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if('n' not in firts[-1:]):
pass
else:
plu0=firts[:-1]
join1=' '.join(splb[2:])
plu=plu0+' '+join1
else:
plu+=' '+j
ind=valuelist.index(term)
valuelist[ind]=plu.strip()
cont=cont+1
quit_plu=[]
nuevalis... | code_fim | hard | {
"lang": "python",
"repo": "pmchozas/termitup",
"path": "/modules_api/postprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pmchozas/termitup path: /modules_api/postprocess.py
lace('-', ''))
print(deletes)
cont=len(termlist)-len(clean_list)
elapsed_time=time()-start_time
txt='CLEAN_TERMS, DELETE ('+str(cont)+') NEW LIST SIZE: ('+str(len(clean_list))+') TIME: ('+str(elapsed_time)+')'
joind=', '.jo... | code_fim | hard | {
"lang": "python",
"repo": "pmchozas/termitup",
"path": "/modules_api/postprocess.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if('on' in plu[-2:]):
plu=' '+plu[:-2]+'ón'
if('v' in plu[-1:]):
plu=' '+plu+'e'
if('bl' in plu[-2:]):
plu=' '+plu+'e'
if('br' in plu[-2:]):
plu=' '+plu+'e'
elif(('s' in j[-1:]) ):
plu+=' '+j[:-1]
pos=slp.index(j)
if(pos>0)... | code_fim | hard | {
"lang": "python",
"repo": "pmchozas/termitup",
"path": "/modules_api/postprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> d= dict()
for c in word:
if c not in d:
d[c]=1
else:
d[c]+=1
for k in d:
if d[k]==1:
print(k)
else:
print(k,d[k])
return d
#count=0
... | code_fim | medium | {
"lang": "python",
"repo": "jryan0004/pythonBasicProjects",
"path": "/Exerise 11.4 hasduplicateTwo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jryan0004/pythonBasicProjects path: /Exerise 11.4 hasduplicateTwo.py
def non_dupulicates_lette(word):
text = list(word);
print(text)
i=0
for i in range(len(text)):
for k in text:
print(c)
def has_dupulicates(word):
<|fim_suffix|> for k in d:
... | code_fim | medium | {
"lang": "python",
"repo": "jryan0004/pythonBasicProjects",
"path": "/Exerise 11.4 hasduplicateTwo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saiteja93/Range-and-Point-Query-PostgreSQL path: /Assignment2_Interface.py
#!/usr/bin/python2.7
#
# Assignment2 Interface
#
import psycopg2
import os
import sys
import Assignment1 as a
# Donot close the connection inside this file i.e. do not perform openconnection.close()
#range__metadata = Ran... | code_fim | hard | {
"lang": "python",
"repo": "saiteja93/Range-and-Point-Query-PostgreSQL",
"path": "/Assignment2_Interface.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def PointQuery(ratingsTableName, ratingValue, openconnection):
#Implement PointQuery Here.
# Remove this once you are done with implementation
cur = openconnection.cursor()
pointvalue = ratingValue
if ((0.0<=pointvalue<= 5.0)):
cur.execute('SELECT maxrating from RangeRatingsMetadata')
Range_upper... | code_fim | hard | {
"lang": "python",
"repo": "saiteja93/Range-and-Point-Query-PostgreSQL",
"path": "/Assignment2_Interface.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def index(request):
return render(request, 'canyon/index.html')
def results(request):
return render(request, 'canyon/results.html')<|fim_prefix|># repo: nnaumovi/Sort-It- path: /Sort It!/arizona/canyon/views.py
from django.shortcuts import render
# Create your views here.
from django.shortcuts... | code_fim | medium | {
"lang": "python",
"repo": "nnaumovi/Sort-It-",
"path": "/Sort It!/arizona/canyon/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nnaumovi/Sort-It- path: /Sort It!/arizona/canyon/views.py
from django.shortcuts import render
# Create your views here.
from django.shortcuts import redirect
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import Http404, HttpResponseForbidden
from django.shortcuts imp... | code_fim | medium | {
"lang": "python",
"repo": "nnaumovi/Sort-It-",
"path": "/Sort It!/arizona/canyon/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, 'canyon/index.html')
def results(request):
return render(request, 'canyon/results.html')<|fim_prefix|># repo: nnaumovi/Sort-It- path: /Sort It!/arizona/canyon/views.py
from django.shortcuts import render
# Create your views here.
from django.shortcuts import redirect
fro... | code_fim | hard | {
"lang": "python",
"repo": "nnaumovi/Sort-It-",
"path": "/Sort It!/arizona/canyon/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hbm0102/AiDM path: /mf.py
#from getData import getRatings
import numpy as np
num_factors = 10
num_iter = 75
regularization = 0.05
lr = 0.005
folds=5
#to make sure you are able to repeat results, set the random seed to something:
np.random.seed(17)
def split_matrix(ratings, num... | code_fim | hard | {
"lang": "python",
"repo": "hbm0102/AiDM",
"path": "/mf.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> err_train = X_train- X_hat
err_test = X_test - X_hat
#RMSE
e_mf = err_train[np.where(np.isnan(err_train)==False)]
error_train_mf = np.sqrt(np.mean(e_mf**2))
e2_mf = err_test[np.where(np.isnan(err_test)==False)]
error_test_mf = np.sqrt(np.me... | code_fim | hard | {
"lang": "python",
"repo": "hbm0102/AiDM",
"path": "/mf.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #5-fold cross validation
for f in np.arange(folds):
print ("Fold #", f)
#shuffle data for train and test
np.random.shuffle(ratings)
train_set = np.array([ratings[x] for x in np.arange(len(ratings)) if (x%folds) !=f])
test_set = np.array([ratings[x] ... | code_fim | hard | {
"lang": "python",
"repo": "hbm0102/AiDM",
"path": "/mf.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/CISCO-L2NAT-MIB.py
nstraint, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint")
ciscoMgmt, = mib... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/CISCO-L2NAT-MIB.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>2natFixupCipOut = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 806, 1, 10, 1, 19), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cl2natFixupCipOut.setStatus('current')
cl2natFixupProfinetOut = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 806, 1, 10, 1, 20), Counter64()).setMaxAccess("readonly")
if ... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/CISCO-L2NAT-MIB.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/CISCO-L2NAT-MIB.py
), StorageType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cl2natInstConfigStorageType.setStatus('current')
cl2natInstConfigInstanceRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 806, 1, 7, 1, 6), RowStatus()).setMaxAcc... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/CISCO-L2NAT-MIB.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mic0ud/Leetcode-py3 path: /src/14.longest-common-prefix.py
#
# @lc app=leetcode id=14 lang=python3
#
# [14] Longest Common Prefix
#
# https://leetcode.com/problems/longest-common-prefix/description/
#
# algorithms
# Easy (34.95%)
# Likes: 2372
# Dislikes: 1797
# Total Accepted: 718.5K
# Tot... | code_fim | medium | {
"lang": "python",
"repo": "mic0ud/Leetcode-py3",
"path": "/src/14.longest-common-prefix.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not strs:
return ''
strs.sort(key=len)
res = strs[0]
while len(res) > 0:
found = False
for s in strs[1:]:
if res != s[:len(res)]:
res = res[:-1]
found = True
... | code_fim | medium | {
"lang": "python",
"repo": "mic0ud/Leetcode-py3",
"path": "/src/14.longest-common-prefix.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create metadata entry
dates = sorted(list(set(dates)))
metadata = {
'source': source,
'oldest data': dates[0],
'newest data': dates[-1]}
data[u'@metadata'] = metadata
# output
f = codecs.open(outFilename, 'w', 'utf-8')
# f.write(json.dumps(data, sort_... | code_fim | hard | {
"lang": "python",
"repo": "lokal-profil/anon",
"path": "/csvs/csv2json.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # compactify it without minimizing
txt = json.dumps(data, sort_keys=True, indent=4, ensure_ascii=False)
txt = re.sub(
r'\[\n "([^"]*)", \n "([^"]*)"\n \]',
r'["\1", "\2"]',
txt)
txt = txt.replace(u', \n [', u',\n [')
f.... | code_fim | hard | {
"lang": "python",
"repo": "lokal-profil/anon",
"path": "/csvs/csv2json.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lokal-profil/anon path: /csvs/csv2json.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Script for converting the new csv files to the desirable json format
'''
import codecs
import json
import re
def creeper():
'''
Settings for creeper file
'''
ccPrefix = False
inFilename ... | code_fim | hard | {
"lang": "python",
"repo": "lokal-profil/anon",
"path": "/csvs/csv2json.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LoggingPoolTest(unittest.TestCase):
def testUpAndDown(self):
pool = logging_pool.pool(_POOL_SIZE)
pool.shutdown(wait=True)
with logging_pool.pool(_POOL_SIZE) as pool:
self.assertIsNotNone(pool)
def testTaskExecuted(self):
test_list = []
... | code_fim | hard | {
"lang": "python",
"repo": "grpc/grpc",
"path": "/src/python/grpcio_tests/tests/unit/framework/foundation/_logging_pool_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertTrue(test_list)
def testException(self):
with logging_pool.pool(_POOL_SIZE) as pool:
raised_exception = pool.submit(lambda: 1 / 0).exception()
self.assertIsNotNone(raised_exception)
def testCallableObjectExecuted(self):
callable_object = _C... | code_fim | hard | {
"lang": "python",
"repo": "grpc/grpc",
"path": "/src/python/grpcio_tests/tests/unit/framework/foundation/_logging_pool_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Observer(BaseObserver):
def __init__(self, func, signal: Signal = None, kwargs=None):
super().__init__(func)
if kwargs is None:
kwargs = {}
self.signal = signal
self.signal_kwargs = kwargs
self._serializer = None
self.signal.connect(sel... | code_fim | medium | {
"lang": "python",
"repo": "pythoneast/djangochannelsrestframework",
"path": "/djangochannelsrestframework/observer/observer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> yield "{}-{}-signal-{}".format(
self._uuid,
self.func.__name__.replace("_", "."),
".".join(
arg.lower().replace("_", ".") for arg in self.signal.providing_args
),
)<|fim_prefix|># repo: pythoneast/djangochannelsrestframework ... | code_fim | hard | {
"lang": "python",
"repo": "pythoneast/djangochannelsrestframework",
"path": "/djangochannelsrestframework/observer/observer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avidclam/amshared path: /amshared/lov/which.py
from typing import Any, Sequence, Callable, Union, Optional
import pandas as pd
import numpy as np
from .taglov import TagLoV
def which_lov(series: pd.Series,
patterns: Sequence[Sequence[Any]],
method: Optional[Union[Cal... | code_fim | hard | {
"lang": "python",
"repo": "avidclam/amshared",
"path": "/amshared/lov/which.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
elov = [(i + 1, v) for i, lov in enumerate(patterns) for v in lov]
if not elov:
return np.zeros(series.size, int)
num, value = zip(*elov)
lov_idx_plus = np.concatenate(([0], num))
if method is None:
mm = series.to_numpy() == np.array(value)[:, np.newaxis]
el... | code_fim | hard | {
"lang": "python",
"repo": "avidclam/amshared",
"path": "/amshared/lov/which.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> taglov: Union[TagLoV, Any],
na: Any,
donor: pd.Series = None,
method: Optional[Union[Callable, str]] = None,
**kwargs):
"""Returns tag of the first matched List-of-Values.
For each element in ``series`` returned is the tag of t... | code_fim | hard | {
"lang": "python",
"repo": "avidclam/amshared",
"path": "/amshared/lov/which.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ddlcmoddev/DDWC path: /scripts/process.py
import os
import sqlite3
import operator
from collections import OrderedDict
import matplotlib.pyplot as plt
def parse(url):
try:
parsed_url_components = url.split('//')
sublevel_split = parsed_url_components[1].split('/', 1)
domain = sublevel_spl... | code_fim | medium | {
"lang": "python",
"repo": "ddlcmoddev/DDWC",
"path": "/scripts/process.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def analyze(results):
prompt = input("[.] Type <c> to print or <p> to plot\n[>] ")
if prompt == "c":
for site, count in list(sites_count_sorted.items()):
print(site, count)
elif prompt == "p":
plt.bar(list(range(len(results))), list(results.values()), align='edge')
plt.xticks(rotation=45)
... | code_fim | hard | {
"lang": "python",
"repo": "ddlcmoddev/DDWC",
"path": "/scripts/process.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def print(self):
ws = self.get_world_size()
for k in range(ws[0][2], ws[1][2]+1):
print('z={}'.format(k))
print()
for j in range(ws[0][1], ws[1][1]+1):
s = ''
for i in range(ws[0][0], ws[1][0]+1):
i... | code_fim | hard | {
"lang": "python",
"repo": "pyaillet/Aoc2020",
"path": "/17/puzzle1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyaillet/Aoc2020 path: /17/puzzle1.py
#!/usr/bin/env python3
import sys
all_neighbors_coord = []
for i in range(-1, 2):
for j in range(-1, 2):
for k in range(-1, 2):
if i != 0 or j != 0 or k != 0:
all_neighbors_coord.append((i, j, k))
def add_coord(c1, c... | code_fim | hard | {
"lang": "python",
"repo": "pyaillet/Aoc2020",
"path": "/17/puzzle1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alamius/LoMuroxeDowofo path: /marks.py
marks = {
"S":"subject",
"O":"object"<|fim_suffix|>:"O",
"attribute":"A",
"clause":"C",
}<|fim_middle|>,
"A":"attribute",
"C":"clause",
}
marks_reverse = {
"subject":"S",
"object" | code_fim | medium | {
"lang": "python",
"repo": "alamius/LoMuroxeDowofo",
"path": "/marks.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ks_reverse = {
"subject":"S",
"object":"O",
"attribute":"A",
"clause":"C",
}<|fim_prefix|># repo: alamius/LoMuroxeDowofo path: /marks.py
marks = {
"S":"subject",
"O":"object"<|fim_middle|>,
"A":"attribute",
"C":"clause",
}
mar | code_fim | easy | {
"lang": "python",
"repo": "alamius/LoMuroxeDowofo",
"path": "/marks.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edmagnu/PhaseMod path: /2018-09-29.py
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 29 19:10:06 2018
@author: labuser
"""
# 2018-09-29
import os
import numpy as np
from scipy.stats import cauchy
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import pandas as pd
def li... | code_fim | hard | {
"lang": "python",
"repo": "edmagnu/PhaseMod",
"path": "/2018-09-29.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def mwion_scan():
"""Take ratios of MW on / MW off to get ionization rate at different values
of the Variable Attenuator"""
fig, ax = plt.subplots()
# Data from 2018-09-27, using the SFIP
fname = "4_mwion_blnk.txt" # -180 GHz
folder = os.path.join("..", "2018-09-29")
fname = ... | code_fim | hard | {
"lang": "python",
"repo": "edmagnu/PhaseMod",
"path": "/2018-09-29.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def cauchy_model(x, a, loc, scale, y0):
return a*cauchy.pdf(x, loc, scale) + y0
def cauchy_fit(x, y, d):
if d is -1:
a0 = -(max(y) - min(y))*(max(x) - min(x))/10
loc0 = x[np.argmin(y)]
scale0 = (max(x) - min(x))/10
y00 = max(y)
elif d is 1:
a0 = (max(... | code_fim | hard | {
"lang": "python",
"repo": "edmagnu/PhaseMod",
"path": "/2018-09-29.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kgori/phylo_utils path: /phylo_utils/substitution_models/k80.py
from phylo_utils.data import fixed_equal_nucleotide_frequencies
from phylo_utils.substitution_models.tn93 import TN93
<|fim_suffix|> super(K80, self).__init__(kappa, kappa, 1, self._freqs, scale_q=scale_q)<|fim_middle|>
class... | code_fim | medium | {
"lang": "python",
"repo": "kgori/phylo_utils",
"path": "/phylo_utils/substitution_models/k80.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _name = 'K80'
_freqs = fixed_equal_nucleotide_frequencies.copy()
def __init__(self, kappa, scale_q=True):
super(K80, self).__init__(kappa, kappa, 1, self._freqs, scale_q=scale_q)<|fim_prefix|># repo: kgori/phylo_utils path: /phylo_utils/substitution_models/k80.py
from phylo_utils.data... | code_fim | easy | {
"lang": "python",
"repo": "kgori/phylo_utils",
"path": "/phylo_utils/substitution_models/k80.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def enter(world):
world.state = states.Perf
world.configCatX = 0
world.configOptX = -1
world.shouldRedraw = True<|fim_prefix|># repo: jack13berry/metatris path: /py-metatris/perfscreen.py
import pygame, states, events
from settings import all as settings
import gui
def handleInput(worl... | code_fim | hard | {
"lang": "python",
"repo": "jack13berry/metatris",
"path": "/py-metatris/perfscreen.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jack13berry/metatris path: /py-metatris/perfscreen.py
import pygame, states, events
from settings import all as settings
import gui
def handleInput(world, event):
if event == events.btnSelectOn or event == events.btnEscapeOn:
bwd(world)
<|fim_suffix|>def enter(world):
world.s... | code_fim | hard | {
"lang": "python",
"repo": "jack13berry/metatris",
"path": "/py-metatris/perfscreen.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def rules(cls):
"""Return rules for checking."""
rules_CityscapesTestConfig = {"batch_size": {"type": int},
"list_path": {"type": str}
}
return rules_CityscapesTestConfig
class Citysc... | code_fim | hard | {
"lang": "python",
"repo": "huawei-noah/xingtian",
"path": "/zeus/datasets/conf/city_scapes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huawei-noah/xingtian path: /zeus/datasets/conf/city_scapes.py
# -*- coding=utf-8 -*-
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the MIT License.
# This program is distribu... | code_fim | hard | {
"lang": "python",
"repo": "huawei-noah/xingtian",
"path": "/zeus/datasets/conf/city_scapes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> initial = True
dependencies = [
('auth', '0008_alter_user_username_max_length')]
operations = [
migrations.CreateModel(name='User',
fields=[
(
'password', models.CharField(max_length=128, verbose_name='password')),
(
'last_login', models.DateTimeField... | code_fim | medium | {
"lang": "python",
"repo": "zsprn123/yunqu",
"path": "/restful/hawkeye/authx/migrations/0001_initial.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zsprn123/yunqu path: /restful/hawkeye/authx/migrations/0001_initial.py
# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 2.7.5 (default, Jul 13 2018, 13:06:57)
# [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
# Embedded file name: ./authx/migrations/0001_initial.py
# Com... | code_fim | medium | {
"lang": "python",
"repo": "zsprn123/yunqu",
"path": "/restful/hawkeye/authx/migrations/0001_initial.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def filter(self, event):
output = OrderedDict()
output["timestamp"] = render_timestamp(
event["event-second"], event["event-microsecond"])
output["sensor_id"] = event["sensor-id"]
output["event_type"] = "alert"
output["src_ip"] = event["source-ip"]
... | code_fim | hard | {
"lang": "python",
"repo": "aaronst/py-idstools",
"path": "/idstools/scripts/u2eve.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aaronst/py-idstools path: /idstools/scripts/u2eve.py
#! /usr/bin/env python
#
# Copyright (c) 2015 Jason Ish
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistr... | code_fim | hard | {
"lang": "python",
"repo": "aaronst/py-idstools",
"path": "/idstools/scripts/u2eve.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> global money
print("I gave you $" + str(money))
money = 0
coffee_machine()
def stats_print():
print("The coffee machine has:")
print(str(water) + " of water")
print(str(milk) + " of milk")
print(str(coffee) + " of coffee beans")
print(str(cups) + " of dispo... | code_fim | hard | {
"lang": "python",
"repo": "Grendd/JetBrains_Academy",
"path": "/Coffee Machine.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Grendd/JetBrains_Academy path: /Coffee Machine.py
water = 400
milk = 540
coffee = 120
cups = 9
money = 550
def buying():
global water
global coffee
global cups
global milk
global money
choice_coffee = input("What do you want to buy? 1 - espresso, 2 - latte, ... | code_fim | hard | {
"lang": "python",
"repo": "Grendd/JetBrains_Academy",
"path": "/Coffee Machine.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def taking():
global money
print("I gave you $" + str(money))
money = 0
coffee_machine()
def stats_print():
print("The coffee machine has:")
print(str(water) + " of water")
print(str(milk) + " of milk")
print(str(coffee) + " of coffee beans")
print(str(c... | code_fim | hard | {
"lang": "python",
"repo": "Grendd/JetBrains_Academy",
"path": "/Coffee Machine.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test flatten_me() for proper output in test cases."""
from flatten_me import flatten_me
assert flatten_me(n) == result<|fim_prefix|># repo: julienawilson/code-katas path: /src/test_flatten_me.py
"""Tests for flatten_me.flatten_me."""
import pytest
ASSERTIONS = [
[[1, [2, 3], 4], [1, ... | code_fim | medium | {
"lang": "python",
"repo": "julienawilson/code-katas",
"path": "/src/test_flatten_me.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: julienawilson/code-katas path: /src/test_flatten_me.py
"""Tests for flatten_me.flatten_me."""
import pytest
ASSERTIONS = [
[[1, [2, 3], 4], [1, 2, 3, 4]],
[[['a', 'b'], 'c', ['d']], ['a', 'b', 'c', 'd']],
[['!', '?'], ['!', '?']],
[[[True, False], ['!'], ['?'], [71, '@']], [True... | code_fim | medium | {
"lang": "python",
"repo": "julienawilson/code-katas",
"path": "/src/test_flatten_me.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __len__(self):
return len(self.__dict__)
def __getstate__(self):
return self.as_dict()
def __setstate__(self, state):
self.override(state)
def items(self):
return list(self.__dict__.items())
def as_dict(self):
return dict(list(self.items(... | code_fim | hard | {
"lang": "python",
"repo": "GraceGay/Chinese-Annotator",
"path": "/chi_annotator/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GraceGay/Chinese-Annotator path: /chi_annotator/config.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
# Describes where to search for the config file if no location is specified
DEFAULT_CONFIG_LOCATION = "config.json"
DEFAULT_CONFIG = {
"project": None,
"fixed_model_name": N... | code_fim | hard | {
"lang": "python",
"repo": "GraceGay/Chinese-Annotator",
"path": "/chi_annotator/config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: richardcysun/TaipeiTransportation path: /NewTaipeiCityBus/cliGetRouteID.py
import sys, getopt
import sys, locale
import httplib
import json
#sys.argv = [sys.argv[0], '--id=275', '--ofile=275.json']
def getRouteId(routeName, out_filename):
conn = httplib.HTTPConnection("data.ntpc.gov.tw")
... | code_fim | hard | {
"lang": "python",
"repo": "richardcysun/TaipeiTransportation",
"path": "/NewTaipeiCityBus/cliGetRouteID.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main(argv):
route_id = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["id=","ofile="])
except getopt.GetoptError:
print 'cliGetRouteID.py -i <route id> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'cliGetRout... | code_fim | hard | {
"lang": "python",
"repo": "richardcysun/TaipeiTransportation",
"path": "/NewTaipeiCityBus/cliGetRouteID.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shunsuke-t/fes path: /events/models.py
# coding: utf-8
from datetime import datetime
#from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils import timezone
from persol_users.models import PersolUser
f... | code_fim | hard | {
"lang": "python",
"repo": "shunsuke-t/fes",
"path": "/events/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def nobreak_overview(self):
return self.overview.replace("\n", "")
# アンケート削除
def question_delete(self, type):
if type == 'd':
q = self.question_date
self.question_date = None
elif type == 'l':
q = self.question_location
... | code_fim | hard | {
"lang": "python",
"repo": "shunsuke-t/fes",
"path": "/events/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def datetimeForIndex(self):
if self.event_datetime:
return self.event_datetime
if not self.question_date:
return "未定"
else:
return "アンケート中"
def locationForIndex(self):
if self.event_location:
return self.even... | code_fim | hard | {
"lang": "python",
"repo": "shunsuke-t/fes",
"path": "/events/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(len(text)):
if(text[i] == string):
liste.append(i)
for x in liste:
print(x)
else:
print("FALSE")
fonkString("Programlama laboratuvari calisma sorulari dosya string liste kullanma ", "m")<|fim_prefix|># repo: cemreuzun/Prog... | code_fim | medium | {
"lang": "python",
"repo": "cemreuzun/Programlama_Lab",
"path": "/ders14_dosyadastringarama.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cemreuzun/Programlama_Lab path: /ders14_dosyadastringarama.py
"""
Stirng - Liste - Dosya
- Fonksiyon yazıyoruz.
- Bu fonksiyon iki parametre alacak. (dosya, string)
1. sorun : Dosyanın içinde string var ise True döndürecek yok ise False
2. sorun : Dosyanın içinde string bulunursa ilk bul... | code_fim | hard | {
"lang": "python",
"repo": "cemreuzun/Programlama_Lab",
"path": "/ders14_dosyadastringarama.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anazalea/zestlife path: /entities/trophy.py
import pygame
import numpy as np
import glob
from entities.base import AnimatedSprite
images_path = sorted(glob.glob('./resources/trophy_sparkle_*.png'))
trophy_im_dict = {'sparkle':[pygame.transform.scale(pygame.image.load(img_path),(400,400)) for im... | code_fim | medium | {
"lang": "python",
"repo": "anazalea/zestlife",
"path": "/entities/trophy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, position, image_dict, hold_for_n_frames=3,):
super().__init__(position, image_dict, hold_for_n_frames)
self.initial_position = position
self.frames_alive = 0
def update(self):
super().next_frame()<|fim_prefix|># repo: anazalea/zestlife path: /en... | code_fim | hard | {
"lang": "python",
"repo": "anazalea/zestlife",
"path": "/entities/trophy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(position, image_dict, hold_for_n_frames)
self.initial_position = position
self.frames_alive = 0
def update(self):
super().next_frame()<|fim_prefix|># repo: anazalea/zestlife path: /entities/trophy.py
import pygame
import numpy as np
import glob
from e... | code_fim | hard | {
"lang": "python",
"repo": "anazalea/zestlife",
"path": "/entities/trophy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> il = doc.getPageImageList(pno)
imglist.extend([x[0] for x in il])
for img in il:
xref = img[0]
if xref in xreflist:
continue
width = img[2]
height = img[3]
if min(width, height) <= dimlimit:
continue
pix = recoverpix(doc, ... | code_fim | hard | {
"lang": "python",
"repo": "aadam3541/DataExtractor",
"path": "/DataExtractor/models/parsers/extract_imga.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aadam3541/DataExtractor path: /DataExtractor/models/parsers/extract_imga.py
from __future__ import print_function
import os, sys, time
import fitz
import PySimpleGUI as sg
"""
PyMuPDF utility
----------------
For a given entry in a page's getImagleList() list, function "recoverpix"
returns eithe... | code_fim | hard | {
"lang": "python",
"repo": "aadam3541/DataExtractor",
"path": "/DataExtractor/models/parsers/extract_imga.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def recoverpix(doc, item):
x = item[0] # xref of PDF image
s = item[1] # xref of its /SMask
if s == 0: # no smask: use direct image output
return doc.extractImage(x)
def getimage(pix):
if pix.colorspace.n != 4:
return pix
tpix = fitz.Pixmap(fitz.csRG... | code_fim | hard | {
"lang": "python",
"repo": "aadam3541/DataExtractor",
"path": "/DataExtractor/models/parsers/extract_imga.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Zigje9/Algorithm_study path: /python/1197.py
import sys
V, E = map(int, sys.stdin.readline().split())
node = []
graphs = []
for i in range(V+1):
node.append(i)
for _ in range(E):
graphs.append((list(map(int, sys.stdin.readline().split()))))
<|fim_suffix|> union_parent(node, A, B)
... | code_fim | hard | {
"lang": "python",
"repo": "Zigje9/Algorithm_study",
"path": "/python/1197.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
N = 0
distance = 0
idx = 0
while N < V-1:
A, B, dist = graph[idx]
if get_parent(node, A) == get_parent(node, B):
idx += 1
continue
union_parent(node, A, B)
distance += dist
N += 1
idx += 1
print(distance)<|fim_prefix|># repo: Zigje9/Algorithm_study path: /python... | code_fim | hard | {
"lang": "python",
"repo": "Zigje9/Algorithm_study",
"path": "/python/1197.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> union_parent(node, A, B)
distance += dist
N += 1
idx += 1
print(distance)<|fim_prefix|># repo: Zigje9/Algorithm_study path: /python/1197.py
import sys
V, E = map(int, sys.stdin.readline().split())
node = []
graphs = []
for i in range(V+1):
node.append(i)
for _ in range(E):
gra... | code_fim | hard | {
"lang": "python",
"repo": "Zigje9/Algorithm_study",
"path": "/python/1197.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stahura/school-projects path: /CS1400/Py Exercises/animation2.py
# animation2.py
# multiple-shot cannonball animation
from math import sqrt, sin, cos, radians, degrees
from graphics import *
from projectile import Projectile
from button import Button
class Launcher:
def __init__(self, win... | code_fim | hard | {
"lang": "python",
"repo": "stahura/school-projects",
"path": "/CS1400/Py Exercises/animation2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ return the current y coordinate of the shot's center """
return self.proj.getY()
def undraw(self):
""" undraw the shot """
self.marker.undraw()
class ProjectileApp:
def __init__(self):
self.win = GraphWin("Projectile Animation", 640, 480)
sel... | code_fim | hard | {
"lang": "python",
"repo": "stahura/school-projects",
"path": "/CS1400/Py Exercises/animation2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: patyen/GiIZ path: /Set3/Task5/prim.py
import sys
def ReadFile(array, fileName):
with open(fileName, 'r') as f:
if f.readline().rstrip() != 'MS':
print("prosze podac macierz sasiedztwa")
for i in f:
el = list(map(int, i.rstrip().split()))
if... | code_fim | hard | {
"lang": "python",
"repo": "patyen/GiIZ",
"path": "/Set3/Task5/prim.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
if len(sys.argv) < 2:
print("prosze podac plik")
sys.exit()
fileName = sys.argv[1]
matrix = []
ReadFile(matrix, fileName)
#print(matrix[1].index(min(matrix[0])))
Prim(matrix, 0)
if __name__ == "__main__":
main()<|fim_prefix|># repo: pa... | code_fim | hard | {
"lang": "python",
"repo": "patyen/GiIZ",
"path": "/Set3/Task5/prim.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(sys.argv) < 2:
print("prosze podac plik")
sys.exit()
fileName = sys.argv[1]
matrix = []
ReadFile(matrix, fileName)
#print(matrix[1].index(min(matrix[0])))
Prim(matrix, 0)
if __name__ == "__main__":
main()<|fim_prefix|># repo: patyen/GiIZ p... | code_fim | hard | {
"lang": "python",
"repo": "patyen/GiIZ",
"path": "/Set3/Task5/prim.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cn = colander.SchemaNode(
colander.String(),
title='Common or Nick Name',
description='Your full name. How you want to be addressed.',
validator=colander.Length(min=3, max=64),
widget=widget.TextInputWidget(
placeholder='(Optional) How you want to be... | code_fim | hard | {
"lang": "python",
"repo": "itd/nportal",
"path": "/nportal/views/schemas.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.