text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: victorfengming/python_projects path: /history_pro/python_January/python10/random随机模块.py #!/usr/bin/env python # -*- coding:utf-8 -*- # coding by xiaoming ''' 当你的才华还撑不起你的野心时,那你就应该静下心来学习 当你的能力还驾驭不了你的目标时,那就应该沉下心来历练 ''' <|fim_suffix|>随机获取指定范围内的所有数值包括小数 格式:random.uniform(开始值,结束值) 返回值:随机返回范围内的所有数值(浮点...
code_fim
hard
{ "lang": "python", "repo": "victorfengming/python_projects", "path": "/history_pro/python_January/python10/random随机模块.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>获取指定范围内指定间隔的随机整数数 格式:random.randrange(开始值,结束值[,间隔值]) 返回值:整数 uniform() 随机获取指定范围内的所有数值包括小数 格式:random.uniform(开始值,结束值) 返回值:随机返回范围内的所有数值(浮点型) '''<|fim_prefix|># repo: victorfengming/python_projects path: /history_pro/python_January/python10/random随机模块.py #!/usr/bin/env python # -*- coding:utf-8 -*- # codin...
code_fim
hard
{ "lang": "python", "repo": "victorfengming/python_projects", "path": "/history_pro/python_January/python10/random随机模块.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: TechNetDemo/t-was path: /install-app.py AdminApp.install('/work/app/sample.war', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -nodeployejb -appname sample -createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=...
code_fim
hard
{ "lang": "python", "repo": "TechNetDemo/t-was", "path": "/install-app.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lientModule -clientMode isolated -novalidateSchema -contextroot /sample -MapModulesToServers [[ "Hello, World Application" sample.war,WEB-INF/web.xml WebSphere:cell=DefaultCell01,node=DefaultNode01,server=server1 ]] -MapWebModToVH [[ "Hello, World Application" sample.war,WEB-INF/web.xml default_host ]] -C...
code_fim
hard
{ "lang": "python", "repo": "TechNetDemo/t-was", "path": "/install-app.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>erver1 ]] -MapWebModToVH [[ "Hello, World Application" sample.war,WEB-INF/web.xml default_host ]] -CtxRootForWebMod [[ "Hello, World Application" sample.war,WEB-INF/web.xml /sample ]]]' ) AdminConfig.save()<|fim_prefix|># repo: TechNetDemo/t-was path: /install-app.py AdminApp.install('/work/app/sample.wa...
code_fim
hard
{ "lang": "python", "repo": "TechNetDemo/t-was", "path": "/install-app.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Load Data #new getAudioDatasets util lets you specify subjects to hold out from training and val datasets. #train_dataset = AudioDataset(config) train_dataset, test_dataset = getAudioDatasets(config,hold_out={15}) train_idx, val_idx = splitIndices(train_dataset, config.nt, config.nv, shuffle...
code_fim
hard
{ "lang": "python", "repo": "asim-v/lie-detector", "path": "/models/rnn_audio.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: asim-v/lie-detector path: /models/rnn_audio.py # Python Imports import argparse import copy # Torch Imports import torch #from torch import LongTensor #from torchtext.vocab import load_word_vectors from torch.autograd import Variable #from torch.nn.utils.rnn import pack_padded_sequence#, pad_pa...
code_fim
hard
{ "lang": "python", "repo": "asim-v/lie-detector", "path": "/models/rnn_audio.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rint("b is largest number") else: print("c is largest number")<|fim_prefix|># repo: Niranjana55/basic_problems path: /12_find_largestamong_3_numbers.py #find largest among 3 numbers a=int(input("enter the number a:")) b=int(input("enter the number b:")) c=int(input("enter the number<|fim_middle|> c:"...
code_fim
medium
{ "lang": "python", "repo": "Niranjana55/basic_problems", "path": "/12_find_largestamong_3_numbers.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Niranjana55/basic_problems path: /12_find_largestamong_3_numbers.py #find largest among 3 numbers a=int(input("enter the number a:")) b=int(input("enter the number b:")) c=int(input("enter the number<|fim_suffix|>rint("b is largest number") else: print("c is largest number")<|fim_middle|> c:"...
code_fim
medium
{ "lang": "python", "repo": "Niranjana55/basic_problems", "path": "/12_find_largestamong_3_numbers.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Algebra8/pyopenapi3 path: /src/pyopenapi3/__init__.py # flake8: noqa from .builders import OpenApiBuilder import pyopenapi3.objects import pyopenapi3.data_types <|fim_suffix|>__all__ = ( "OpenApiBuilder", "objects", "data_types", "create_schema" ) __version__ = "0.1.dev0"<|fim_...
code_fim
easy
{ "lang": "python", "repo": "Algebra8/pyopenapi3", "path": "/src/pyopenapi3/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>__all__ = ( "OpenApiBuilder", "objects", "data_types", "create_schema" ) __version__ = "0.1.dev0"<|fim_prefix|># repo: Algebra8/pyopenapi3 path: /src/pyopenapi3/__init__.py # flake8: noqa from .builders import OpenApiBuilder import pyopenapi3.objects import pyopenapi3.data_types <|fim_...
code_fim
easy
{ "lang": "python", "repo": "Algebra8/pyopenapi3", "path": "/src/pyopenapi3/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> start = time.time() t = str(random.getrandbits(64)).encode('utf-8') val = hashlib.sha256(t).hexdigest() nonce = 0 while int(val,16)>int(tgt,16): temp = int(val,16) + nonce val = hashlib.sha256((hex(temp)).encode('utf-8')).hexdigest() nonce+=1 return ...
code_fim
medium
{ "lang": "python", "repo": "betcherj/CSCI3394", "path": "/Systems_HW3_Server.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: betcherj/CSCI3394 path: /Systems_HW3_Server.py import random import hashlib import time import socket <|fim_suffix|>tgt = hex(10**10) s = socket.socket() host = socket.gethostname() port = 5005 s.bind((host, port)) s.listen(5) ...
code_fim
hard
{ "lang": "python", "repo": "betcherj/CSCI3394", "path": "/Systems_HW3_Server.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tgt = hex(10**10) s = socket.socket() host = socket.gethostname() port = 5005 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() val = tHeader(tgt) c.send(int(val, 16)) c.close()<|fim_prefix|># repo: betcherj/CSCI33...
code_fim
hard
{ "lang": "python", "repo": "betcherj/CSCI3394", "path": "/Systems_HW3_Server.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ophwsjtu18/ohw20s path: /students/wmh/homework8/serial.py import serial ser=serial.Serial("COM21") while True: a=input("please type your cmd here, q <|fim_suffix|>f a=='q': break ser.write(a.encode())<|fim_middle|>for quit, e for remote quit.") print(a) i
code_fim
easy
{ "lang": "python", "repo": "ophwsjtu18/ohw20s", "path": "/students/wmh/homework8/serial.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>f a=='q': break ser.write(a.encode())<|fim_prefix|># repo: ophwsjtu18/ohw20s path: /students/wmh/homework8/serial.py import serial ser=serial.Serial("COM21") whil<|fim_middle|>e True: a=input("please type your cmd here, q for quit, e for remote quit.") print(a) i
code_fim
medium
{ "lang": "python", "repo": "ophwsjtu18/ohw20s", "path": "/students/wmh/homework8/serial.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>for quit, e for remote quit.") print(a) if a=='q': break ser.write(a.encode())<|fim_prefix|># repo: ophwsjtu18/ohw20s path: /students/wmh/homework8/serial.py import serial ser=serial.Serial("COM21") whil<|fim_middle|>e True: a=input("please type your cmd here, q
code_fim
easy
{ "lang": "python", "repo": "ophwsjtu18/ohw20s", "path": "/students/wmh/homework8/serial.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ashrafcloud/Python_Programs path: /calculator.py # Write a Program to pass two variable into a function and then perform arthemtic operations (+,-,*,/).print the result def cal(a,b): print("sum is:" ,a+b) print("diff is:", a-b) print("product is:",a*b) print("quotient is",a/b) ...
code_fim
medium
{ "lang": "python", "repo": "ashrafcloud/Python_Programs", "path": "/calculator.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Output enter a no 2: 2 sum is: 6 diff is: 2 ...
code_fim
medium
{ "lang": "python", "repo": "ashrafcloud/Python_Programs", "path": "/calculator.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: whoiskx/com_code path: /history/Facebook/rewrite/kafka/redis_insert.py import redis # 导入redis模块,通过python操作redis 也可以直接在redis主机的服务端操作缓存数据库 r = redis.Redis(host='localhost', port=6379, db=0) # host是redis主机,需要redis服务端和客户端都启动 redis默认端口是6379 # r.set('tasklist', 'junxi') # key是"foo" value是"bar" 将键...
code_fim
medium
{ "lang": "python", "repo": "whoiskx/com_code", "path": "/history/Facebook/rewrite/kafka/redis_insert.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># 字典 # r.hset('dict', 'url3', 'wwww123') # print(r.hgetall('dict')) # 列表 r.lpush('list', "{url:123555}") r.lpush('list', "{url:1235554}") print(r.lrange('list', 0, -1))<|fim_prefix|># repo: whoiskx/com_code path: /history/Facebook/rewrite/kafka/redis_insert.py import redis # 导入redis模块,通过python操作redis ...
code_fim
hard
{ "lang": "python", "repo": "whoiskx/com_code", "path": "/history/Facebook/rewrite/kafka/redis_insert.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># 列表 r.lpush('list', "{url:123555}") r.lpush('list', "{url:1235554}") print(r.lrange('list', 0, -1))<|fim_prefix|># repo: whoiskx/com_code path: /history/Facebook/rewrite/kafka/redis_insert.py import redis # 导入redis模块,通过python操作redis 也可以直接在redis主机的服务端操作缓存数据库 r = redis.Redis(host='localhost', port=6379...
code_fim
medium
{ "lang": "python", "repo": "whoiskx/com_code", "path": "/history/Facebook/rewrite/kafka/redis_insert.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: moran-ai/Python_Adavnce path: /复习/生成器实现生产者消费者模式.py def produce(c): print("--3、启动生成器,开始执行生成器consumer--") c.send(None) # 3、启动生成器,开始执行生成器consumer print("--6、继续往下执行--") n = 0 while n < 5: n += 1 print("[Producer]: producing {} ..".format(n)) print("--7、第{}...
code_fim
hard
{ "lang": "python", "repo": "moran-ai/Python_Adavnce", "path": "/复习/生成器实现生产者消费者模式.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def m(s): print('启动生成器') s.send(None) n = 0 while n < 5: n += 1 print(f'第{n}次启动生成器') r = s.send(n) print(r) s.close() def n(): print('开启生成器') response = None while True: print('中断保存上下文') c = yield response print(c) ...
code_fim
hard
{ "lang": "python", "repo": "moran-ai/Python_Adavnce", "path": "/复习/生成器实现生产者消费者模式.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># def mm(): # a, b = 0, 1 # response = 0 # while True: # c = yield response # print(c) # a, b = b, a + b # # response = response + a # m = mm() # print(m.__next__()) # print(m.__next__()) def m(s): print('启动生成器') s.send(None) n = 0 while n < ...
code_fim
hard
{ "lang": "python", "repo": "moran-ai/Python_Adavnce", "path": "/复习/生成器实现生产者消费者模式.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mean_absolute_error_score = mean_absolute_error(y_true=y_true, y_pred=y_pred, multioutput='uniform_average') print("mean_absolute_error:", mean_absolute_error_score) mean_squared_error_score = mean_squared_error(y_true=y_true, y_pred=y_pred, multioutput='uniform_average') print("mean_squared_error:", ...
code_fim
hard
{ "lang": "python", "repo": "CyberCrack/TestAing-Regression", "path": "/Utility.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: CyberCrack/TestAing-Regression path: /Utility.py import datetime import os import pickle import h2o.automl import pandas as pd import xgboost as xg from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score from sklearn.model_selection import train_test_split from sklearn.pipe...
code_fim
hard
{ "lang": "python", "repo": "CyberCrack/TestAing-Regression", "path": "/Utility.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> count = query.count() groups = query.order_by(Group.id.desc()).offset(offset).limit(limit).all() return render_template('login/groups.html', groups=groups, int=int, abs=abs, offset=offset, limit=limit, count=count) @app.route('/robots/', methods=['GET']) def data_ro...
code_fim
hard
{ "lang": "python", "repo": "lyflm/wx_chat", "path": "/app/chat/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: lyflm/wx_chat path: /app/chat/views.py # -*- coding: utf-8 -*- import os import time import shutil from threading import Thread from flask import render_template, Response, request from app import app from app.chat import itchat_run from app.utils import generator_string_id from app.models impo...
code_fim
hard
{ "lang": "python", "repo": "lyflm/wx_chat", "path": "/app/chat/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if group: query = query.filter_by(group=group) if nick_name: query = query.filter_by(nick_name=nick_name) if remark_name: query = query.filter_by(remark_name=remark_name) if display_name: query = query.filter_by(display_name=display_name) if sex: ...
code_fim
hard
{ "lang": "python", "repo": "lyflm/wx_chat", "path": "/app/chat/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> luas_segitiga = alas * tinggi / 2 return luas_segitiga<|fim_prefix|># repo: KazeCrowz/crash-course-2-modularisasi path: /Geometry/segitiga.py def info(): return 'Modul tentang menghitung luas segitiga' <|fim_middle|>def hitung_segitiga(alas, tinggi):
code_fim
easy
{ "lang": "python", "repo": "KazeCrowz/crash-course-2-modularisasi", "path": "/Geometry/segitiga.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: KazeCrowz/crash-course-2-modularisasi path: /Geometry/segitiga.py def info(): return 'Modul tentang menghitung luas segitiga' <|fim_suffix|> luas_segitiga = alas * tinggi / 2 return luas_segitiga<|fim_middle|>def hitung_segitiga(alas, tinggi):
code_fim
easy
{ "lang": "python", "repo": "KazeCrowz/crash-course-2-modularisasi", "path": "/Geometry/segitiga.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Andreskcrs21/Modulo-Administracion-JISA path: /Clientes/admin.py from django.contrib import admin from .models import Clientes # Register your models here. class ClientesAdmin(admin.ModelAdmin): <|fim_suffix|>admin.site.register(Clientes, ClientesAdmin)<|fim_middle|> list_display = ( ...
code_fim
medium
{ "lang": "python", "repo": "Andreskcrs21/Modulo-Administracion-JISA", "path": "/Clientes/admin.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> admin.site.register(Clientes, ClientesAdmin)<|fim_prefix|># repo: Andreskcrs21/Modulo-Administracion-JISA path: /Clientes/admin.py from django.contrib import admin from .models import Clientes <|fim_middle|># Register your models here. class ClientesAdmin(admin.ModelAdmin): list_display = ( ...
code_fim
hard
{ "lang": "python", "repo": "Andreskcrs21/Modulo-Administracion-JISA", "path": "/Clientes/admin.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>admin.site.register(Clientes, ClientesAdmin)<|fim_prefix|># repo: Andreskcrs21/Modulo-Administracion-JISA path: /Clientes/admin.py from django.contrib import admin from .models import Clientes # Register your models here. class ClientesAdmin(admin.ModelAdmin): <|fim_middle|> list_display = ( ...
code_fim
medium
{ "lang": "python", "repo": "Andreskcrs21/Modulo-Administracion-JISA", "path": "/Clientes/admin.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: kaspiotr/Sentiment-Analyzer path: /data_generator.py from os import listdir import random import numpy as np TEST_DATA_PERCENTAGE = 30 class DataGenerator: def __init__(self, neg_reviews_dir_path, pos_reviews_dir_path): self.neg_reviews_dir_path = neg_reviews_dir_path self....
code_fim
hard
{ "lang": "python", "repo": "kaspiotr/Sentiment-Analyzer", "path": "/data_generator.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return self.train_samples_count def get_test_samples_count(self): return self.test_samples_count def get_train_generator(self, batch_size): idx = 0 while True: x = [] y = [] counter = 0 while counter < batch_size: ...
code_fim
hard
{ "lang": "python", "repo": "kaspiotr/Sentiment-Analyzer", "path": "/data_generator.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.CreateModel( name='Comments', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('userName', models.CharField(max_length=1000)), ('userID'...
code_fim
hard
{ "lang": "python", "repo": "abiralmahdi/ECommerceWebsite", "path": "/home/migrations/0003_auto_20210211_1557.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: abiralmahdi/ECommerceWebsite path: /home/migrations/0003_auto_20210211_1557.py # Generated by Django 3.0.8 on 2021-02-11 09:57 from django.db import migrations, models class Migration(migrations.Migration): <|fim_suffix|> operations = [ migrations.CreateModel( name='Comm...
code_fim
hard
{ "lang": "python", "repo": "abiralmahdi/ECommerceWebsite", "path": "/home/migrations/0003_auto_20210211_1557.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def add_model_args(parser): group = parser.add_argument_group('Model configuration') group.add_argument('--vae-arch', default='conv_vae', metavar='ARCH', help='VAE model architecture') return group def add_optimization_args(parser): group = parser.add_argument...
code_fim
hard
{ "lang": "python", "repo": "yjxiao/disentrepr_wtc", "path": "/disent/options.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> parser = argparse.ArgumentParser() parser.add_argument('--no-progress-bar', action='store_true', help='disable progress bar') parser.add_argument('--log-interval', type=int, default=1000, metavar='N', help='log progress every N batches (when progress bar is disabled)')...
code_fim
hard
{ "lang": "python", "repo": "yjxiao/disentrepr_wtc", "path": "/disent/options.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yjxiao/disentrepr_wtc path: /disent/options.py import argparse from functools import partial import torch from disent.metrics import METRIC_REGISTRY from disent.models import MODEL_REGISTRY from disent.optim import OPTIMIZER_REGISTRY from disent.optim.lr_scheduler import LR_SCHEDULER_REGISTRY f...
code_fim
hard
{ "lang": "python", "repo": "yjxiao/disentrepr_wtc", "path": "/disent/options.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dfdf.loc[col] = [xunique, xset, xmode, xmodep, xnas, xcorr, xcorr2, xcorr3, xaction] # save results so can duplicate on test set later dfdf.to_csv("FeatureSuggestion.csv", index = True) return dfdf # Get all cats cols #cat_df = df.drop(df._get_numeric_dat...
code_fim
hard
{ "lang": "python", "repo": "mattsavoca/ames_housingregression", "path": "/Katy/Scripts/CatAnalysis.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mattsavoca/ames_housingregression path: /Katy/Scripts/CatAnalysis.py # -*- coding: utf-8 -*- """ CATS ANALYSIS """ # Basic Libraries import pandas as pd import numpy as np # Pull in data test = pd.read_csv('./test.csv') train = pd.read_csv('./train.csv') df = train.copy() df['logy...
code_fim
hard
{ "lang": "python", "repo": "mattsavoca/ames_housingregression", "path": "/Katy/Scripts/CatAnalysis.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: AnushSomasundaram/Anush_Python_projects path: /chap4_fuctions/pass.py #the pass keyword can be used to leave areas of the code empty so that they can be worked on later bool=True <|fim_suffix|>#if the pass keyword was not inserted after else and a set of commands were also not present then the ...
code_fim
medium
{ "lang": "python", "repo": "AnushSomasundaram/Anush_Python_projects", "path": "/chap4_fuctions/pass.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#pass is a placeholder # the continue keyword is another place holder which can be used at the end of a if statement<|fim_prefix|># repo: AnushSomasundaram/Anush_Python_projects path: /chap4_fuctions/pass.py #the pass keyword can be used to leave areas of the code empty so that they can be worked on lat...
code_fim
hard
{ "lang": "python", "repo": "AnushSomasundaram/Anush_Python_projects", "path": "/chap4_fuctions/pass.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: MengYing/leetcode path: /python/1_TwoSum.py class Solution(object): def twoSum(self, nums, target): map = {} diff = 0 for i in range(0, len(nums), 1): map[str(i)] = nums[i] #print map['1'] for k in range(0, len(nums), 1): ...
code_fim
medium
{ "lang": "python", "repo": "MengYing/leetcode", "path": "/python/1_TwoSum.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># if __name__ == '__main__': # test = Solution() # nums = [5,20,75] # #nums = [3, 2, 4] # print type(nums) # target = 95 # result = test.twoSum(nums, target) # print result<|fim_prefix|># repo: MengYing/leetcode path: /python/1_TwoSum.py class Solution(object): def...
code_fim
medium
{ "lang": "python", "repo": "MengYing/leetcode", "path": "/python/1_TwoSum.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: twstokes/garage-pi path: /garage.py #!/usr/bin/python import RPi.GPIO as GPIO import time # set the GPIO mode GPIO.setmode(GPIO.BCM) # set pin 18 for output GPIO.setup(18, GPIO.OUT) # out<|fim_suffix|>rn off output for pin 18 GPIO.output(18, False) # gpio cleanup GPIO.cleanup()<|fim_middle|>put...
code_fim
medium
{ "lang": "python", "repo": "twstokes/garage-pi", "path": "/garage.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>put to pin 18 GPIO.output(18, True) # sleep for one second time.sleep(1) # turn off output for pin 18 GPIO.output(18, False) # gpio cleanup GPIO.cleanup()<|fim_prefix|># repo: twstokes/garage-pi path: /garage.py #!/usr/bin/python import RPi.GPIO as GPIO import time # set the GPIO mode <|fim_middle|>GPI...
code_fim
medium
{ "lang": "python", "repo": "twstokes/garage-pi", "path": "/garage.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> class _Mode(object): def __init__(self): self.switch = False self.screen = setup.SCREEN self.pos = (0, 0) self.font = setup.FONT_DICT def update(self): pass def startup(self): pass def get_event(self, event): pass<|fim_prefix|># r...
code_fim
hard
{ "lang": "python", "repo": "Dark15/Gomoku-AI", "path": "/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while True: self.event_loop() self.update() pg.display.update() class _Mode(object): def __init__(self): self.switch = False self.screen = setup.SCREEN self.pos = (0, 0) self.font = setup.FONT_DICT def update(self): ...
code_fim
medium
{ "lang": "python", "repo": "Dark15/Gomoku-AI", "path": "/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Dark15/Gomoku-AI path: /main.py import pygame as pg import constants as c from sys import exit import setup class Main(object): def __init__(self): self.modes_dict = None self.now_mode = None <|fim_suffix|> class _Mode(object): def __init__(self): self.switch = ...
code_fim
hard
{ "lang": "python", "repo": "Dark15/Gomoku-AI", "path": "/main.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: asumisora-dev/TEST2 path: /Untitled-1.py number = 1 number2 = 1.0 getattr = 'こんにちは' is_ok = True <|fim_suffix|>print(2 > 1) print(1 < 1) print(3 > 4) print(5 * 2) print('テスト・テスト')<|fim_middle|>print(number, type(number)) print(number2, type(number2)) print(getattr, type(getattr)) pri...
code_fim
medium
{ "lang": "python", "repo": "asumisora-dev/TEST2", "path": "/Untitled-1.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>print(2 > 1) print(1 < 1) print(3 > 4) print(5 * 2) print('テスト・テスト')<|fim_prefix|># repo: asumisora-dev/TEST2 path: /Untitled-1.py number = 1 number2 = 1.0 getattr = 'こんにちは' is_ok = True <|fim_middle|>print(number, type(number)) print(number2, type(number2)) print(getattr, type(getattr)) pri...
code_fim
medium
{ "lang": "python", "repo": "asumisora-dev/TEST2", "path": "/Untitled-1.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: DunZhang/DPTrees path: /tree/CARTClassifier.py # -*- coding: utf-8 -*- """ Created on Mon May 7 14:28:31 2018 @author: Administrator """ from copy import deepcopy from sklearn import datasets from FeatureEvaluate import CartGini from FeatureEvaluate import gini from FeatureEvaluate import SE fr...
code_fim
hard
{ "lang": "python", "repo": "DunZhang/DPTrees", "path": "/tree/CARTClassifier.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def fit(self,X,y): x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=10,stratify=y) self.x,self.y=np.array(x_train),np.array(y_train) self.__LabelEncoder() self.root=self.__build(ins=list(range(len(self.x))), ...
code_fim
hard
{ "lang": "python", "repo": "DunZhang/DPTrees", "path": "/tree/CARTClassifier.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> res=[] for i in range(len(X)): res.append(self.__predict(self.root,X[i,:])) res=list( res) ins=dict() y=np.array(y) for i in range(len(res)): if(res[i] not in ins.keys()): ins[res[i]]=[] ...
code_fim
hard
{ "lang": "python", "repo": "DunZhang/DPTrees", "path": "/tree/CARTClassifier.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Fluidy/tvtl2021 path: /plot_figures.py import numpy as np import pandas as pd import matplotlib matplotlib.use("TkAgg") import matplotlib.pyplot as plt matplotlib.rcParams['text.usetex'] = True matplotlib.rc('font', size=12) def plot_learning(result_dir, ax, smooth=50, interval=50, err...
code_fim
hard
{ "lang": "python", "repo": "Fluidy/tvtl2021", "path": "/plot_figures.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ax.set_xlim([100, 2500]) ax.set_ylim([60, 450]) ax.set_xlabel('Episode') ax.set_xticks(np.arange(500, 3000, 500)) ax.set_yticks([60, 70, 80, 90, 100, 200, 300, 400]) ax.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) ax.set_ylabel('E2E Delay (ms)') ax.grid() ax.legend(handle...
code_fim
hard
{ "lang": "python", "repo": "Fluidy/tvtl2021", "path": "/plot_figures.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: RL-OtherApps/logistic path: /base_enh/models/weight_type.py # -*- coding: utf-8 -*- from odoo import models, fields, api class WeightType(models.Model): _name = 'weight.type' _inherit = ['mail.thread', 'mail.activity.mixin'] _description = "WeightType" name = fields.Char('...
code_fim
hard
{ "lang": "python", "repo": "RL-OtherApps/logistic", "path": "/base_enh/models/weight_type.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ('express', 'Express')],string="Shipment Method") weight_from=fields.Float(string='Weight From', default=0.0) weight_to=fields.Float(string='Weight To', default=0.0) uom_id=fields.Many2one('uom.uom', default=lambda self: self.env['uom.uom'].search([('...
code_fim
hard
{ "lang": "python", "repo": "RL-OtherApps/logistic", "path": "/base_enh/models/weight_type.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: zyga/arrowhead path: /examples/tutorial4.py #!/usr/bin/env python3 """ Tutorial Lesson 4 ================= This is the fourth tutorial arrowhead program. The previous lessons introduced all of the baisc concepts of arrowhead. Now we'll look at how one can work with flow state. <|fim_suffix|>So...
code_fim
hard
{ "lang": "python", "repo": "zyga/arrowhead", "path": "/examples/tutorial4.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>So there you have it, each step can store any state attribute (except Meta, that's reserved), then you can each out to any other step by accepting the flow argument. Through that argument you get the instance of the flow class you are executing in and you can access each step as it were an attribute. """ ...
code_fim
hard
{ "lang": "python", "repo": "zyga/arrowhead", "path": "/examples/tutorial4.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> i = linalg.inv(b) print(i) ab = matmul(a, b) print(ab)<|fim_prefix|># repo: nicosalu/inteligencia-2017 path: /Matrices-Ejercicio-Clase-1/prueba.py from numpy import array, linalg, matmul a = array([[1, -1, 0], [3, 0, -1], [1, 3, -2]]) print(a) b = array([[2, -1, 1], [0, 3, -1], [-1, 2, 0]]) print(b)...
code_fim
easy
{ "lang": "python", "repo": "nicosalu/inteligencia-2017", "path": "/Matrices-Ejercicio-Clase-1/prueba.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: nicosalu/inteligencia-2017 path: /Matrices-Ejercicio-Clase-1/prueba.py from numpy import array, linalg, matmul a = array([[1, -1, 0], [3, 0, -1], [1, 3, -2]]) print(a) b = array([[2, -1, 1], [0, 3, -1], [-1, 2, 0]]) print(b) <|fim_suffix|>i = linalg.inv(b) print(i) ab = matmul(a, b) print(ab...
code_fim
easy
{ "lang": "python", "repo": "nicosalu/inteligencia-2017", "path": "/Matrices-Ejercicio-Clase-1/prueba.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ab = matmul(a, b) print(ab)<|fim_prefix|># repo: nicosalu/inteligencia-2017 path: /Matrices-Ejercicio-Clase-1/prueba.py from numpy import array, linalg, matmul a = array([[1, -1, 0], [3, 0, -1], [1, 3, -2]]) print(a) b = array([[2, -1, 1], [0, 3, -1], [-1, 2, 0]]) print(b) <|fim_middle|> inv = linalg....
code_fim
medium
{ "lang": "python", "repo": "nicosalu/inteligencia-2017", "path": "/Matrices-Ejercicio-Clase-1/prueba.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Sathyasree-Sundaravel/sathya path: /Program_to_print_product_of_two_numbers_is_odd_or_even.py #Program to print product of two numbers<|fim_suffix|> print("even") else: print("odd")<|fim_middle|> is odd or even N1,N2=map(int,input().split()) product=N1*N2 if((product%2)==0):
code_fim
medium
{ "lang": "python", "repo": "Sathyasree-Sundaravel/sathya", "path": "/Program_to_print_product_of_two_numbers_is_odd_or_even.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lit()) product=N1*N2 if((product%2)==0): print("even") else: print("odd")<|fim_prefix|># repo: Sathyasree-Sundaravel/sathya path: /Program_to_print_product_of_two_numbers_is_odd_or_even.py #Program to print product of two numbers<|fim_middle|> is odd or even N1,N2=map(int,input().sp
code_fim
easy
{ "lang": "python", "repo": "Sathyasree-Sundaravel/sathya", "path": "/Program_to_print_product_of_two_numbers_is_odd_or_even.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> print("even") else: print("odd")<|fim_prefix|># repo: Sathyasree-Sundaravel/sathya path: /Program_to_print_product_of_two_numbers_is_odd_or_even.py #Program to print product of two numbers is odd or even N1,N2=map(int,input().sp<|fim_middle|>lit()) product=N1*N2 if((product%2)==0):
code_fim
easy
{ "lang": "python", "repo": "Sathyasree-Sundaravel/sathya", "path": "/Program_to_print_product_of_two_numbers_is_odd_or_even.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Matje1979/festival_manager path: /manager/forms.py from django import forms from.models import Visitor <|fim_suffix|> model = Visitor fields = ['first_name', 'last_name', 'email']<|fim_middle|>class EventVisitorForm(forms.ModelForm): class Meta:
code_fim
easy
{ "lang": "python", "repo": "Matje1979/festival_manager", "path": "/manager/forms.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> class Meta: model = Visitor fields = ['first_name', 'last_name', 'email']<|fim_prefix|># repo: Matje1979/festival_manager path: /manager/forms.py from django import forms from.models import Visitor <|fim_middle|>class EventVisitorForm(forms.ModelForm):
code_fim
easy
{ "lang": "python", "repo": "Matje1979/festival_manager", "path": "/manager/forms.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>needs = TweetReader('/home/long/TTU-SOURCES/harvey-need/data/daily-need/needs.csv', text_column=0, separator='|', encoding='utf8') need_corpus = needs.get_corpus() words_names = [] words_count = [] need_wfreq = dict() frequencies = [] total_frequency = 0 for (word, freq) in wfreq: if word not in n...
code_fim
medium
{ "lang": "python", "repo": "yangzhou95/opioid_on_reddit", "path": "/code/text_classifier/src/top_words_frequency.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yangzhou95/opioid_on_reddit path: /code/text_classifier/src/top_words_frequency.py from collections import Counter import numpy as np import matplotlib.pyplot as plt from core.tweet_reader import TweetReader import statistics import operator reader = TweetReader('data/need/full-day-need/09_02.c...
code_fim
hard
{ "lang": "python", "repo": "yangzhou95/opioid_on_reddit", "path": "/code/text_classifier/src/top_words_frequency.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>median_freq = statistics.median(frequencies) ## remove low frequency items final_wfreq = dict() for word, freq in need_wfreq.items(): if freq > median_freq: final_wfreq[word] = freq sorted_wfreq = sorted(final_wfreq.items(), key=operator.itemgetter(1)) for word, freq in sorted_wfreq: word...
code_fim
hard
{ "lang": "python", "repo": "yangzhou95/opioid_on_reddit", "path": "/code/text_classifier/src/top_words_frequency.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: arthur0496/SMI-Master path: /transductors/urls.py from rest_framework import routers <|fim_suffix|>router = routers.DefaultRouter() router.register(r'energy_transductors', EnergyTransductorViewSet) urlpatterns = []<|fim_middle|>from .views import EnergyTransductorViewSet app_name = "transducto...
code_fim
medium
{ "lang": "python", "repo": "arthur0496/SMI-Master", "path": "/transductors/urls.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>app_name = "transductors" router = routers.DefaultRouter() router.register(r'energy_transductors', EnergyTransductorViewSet) urlpatterns = []<|fim_prefix|># repo: arthur0496/SMI-Master path: /transductors/urls.py from rest_framework import routers <|fim_middle|>from .views import EnergyTransductorView...
code_fim
easy
{ "lang": "python", "repo": "arthur0496/SMI-Master", "path": "/transductors/urls.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>router = routers.DefaultRouter() router.register(r'energy_transductors', EnergyTransductorViewSet) urlpatterns = []<|fim_prefix|># repo: arthur0496/SMI-Master path: /transductors/urls.py from rest_framework import routers from .views import EnergyTransductorViewSet <|fim_middle|>app_name = "transducto...
code_fim
easy
{ "lang": "python", "repo": "arthur0496/SMI-Master", "path": "/transductors/urls.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: fmelodb/NoSQL-Demo-on-Oracle-DB path: /REST/dropCollection.py import requests import sys url = 'http://localhost:9<|fim_suffix|>quests.delete(url) if (response.status_code == 200): print("Collection droped") else: print("Erro")<|fim_middle|>090/ords/hr/soda/latest/' + sys.argv[1] respons...
code_fim
easy
{ "lang": "python", "repo": "fmelodb/NoSQL-Demo-on-Oracle-DB", "path": "/REST/dropCollection.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>quests.delete(url) if (response.status_code == 200): print("Collection droped") else: print("Erro")<|fim_prefix|># repo: fmelodb/NoSQL-Demo-on-Oracle-DB path: /REST/dropCollection.py import requests import sys url = 'http://localhost:9<|fim_middle|>090/ords/hr/soda/latest/' + sys.argv[1] respons...
code_fim
easy
{ "lang": "python", "repo": "fmelodb/NoSQL-Demo-on-Oracle-DB", "path": "/REST/dropCollection.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Light07/Mobile_FrameWork path: /EvcMobile/android/tests/enter_class/test_chats.py from ef_common.take_screenshot import take_screenshot from hamcrest import assert_that, equal_to import settings from android.pages.evc.login_page import LoginPage from settings import UAT_Account from teacher_comm...
code_fim
medium
{ "lang": "python", "repo": "Light07/Mobile_FrameWork", "path": "/EvcMobile/android/tests/enter_class/test_chats.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Student enter class. student_name =UAT_Account.EFEC_BEG_IN_WHITE_LIST_Account['username'] login_page = LoginPage(self.browser) debug_page = login_page.go_to_debug_option_page() class_room_entry_page = debug_page.go_to_class_room_entry_page() room_name = cl...
code_fim
medium
{ "lang": "python", "repo": "Light07/Mobile_FrameWork", "path": "/EvcMobile/android/tests/enter_class/test_chats.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def SolveGame(self): for round in itertools.combinations_with_replacement(range(1, self.numActions + 1), self.TotalMoves): self.reset() print("Before: \n") self.printGameState() self.tryMoves(round) print("After: \n") #To...
code_fim
hard
{ "lang": "python", "repo": "sumanthneerumalla/CalculatorSolver", "path": "/CalculatorGameSolver.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.Goal = value def setTotalMoves(self,value): self.MovesLeft = self.TotalMoves = value def addMove(self,moveName,moveValue = None): self.numActions += 1 if moveName == "Add": self.Actions[self.numActions] = (self.AddNum,moveValue,"Add") eli...
code_fim
hard
{ "lang": "python", "repo": "sumanthneerumalla/CalculatorSolver", "path": "/CalculatorGameSolver.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: sumanthneerumalla/CalculatorSolver path: /CalculatorGameSolver.py import itertools class Game(): def __init__(self): self.Actions = {} self.numActions = 0 self.Start = None self.Value = None self.Goal = None self.MovesLeft = None self.T...
code_fim
hard
{ "lang": "python", "repo": "sumanthneerumalla/CalculatorSolver", "path": "/CalculatorGameSolver.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_logger.info('disabling parso logging') logging.getLogger('parso').setLevel(level=logging.WARNING)<|fim_prefix|># repo: danodonovan/dotfiles path: /ipython_config.py # resides at $HOME/.ipython/profile_default/ipython_config.py from pathlib import Path import logging <|fim_middle|>_logger = logging.getL...
code_fim
easy
{ "lang": "python", "repo": "danodonovan/dotfiles", "path": "/ipython_config.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: danodonovan/dotfiles path: /ipython_config.py # resides at $HOME/.ipython/profile_default/ipython_config.py from pathlib import Path import logging <|fim_suffix|>_logger.info('disabling parso logging') logging.getLogger('parso').setLevel(level=logging.WARNING)<|fim_middle|>_logger = logging.getL...
code_fim
easy
{ "lang": "python", "repo": "danodonovan/dotfiles", "path": "/ipython_config.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bennymuller/glTools path: /tools/lockSurfaceLength.py import maya.cmds as cmds import glTools.utils.stringUtils import glTools.utils.surface def loadPlugin(): """ Load glCurveUtils plugin. """ # Check if plugin is loaded if not cmds.pluginInfo('glCurveUtils', q=True, l=True)...
code_fim
hard
{ "lang": "python", "repo": "bennymuller/glTools", "path": "/tools/lockSurfaceLength.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Add Control Attribute cmds.addAttr(dupCurve, ln='lockLength', min=0, max=1, dv=1, k=True) cmds.addAttr(dupCurve, ln='lengthBias', min=0, max=1, dv=0, k=True) cmds.connectAttr(dupCurve + '.lockLength', blendLen + '.attributesBlender', f=True) cmds.connectAttr(dupCu...
code_fim
hard
{ "lang": "python", "repo": "bennymuller/glTools", "path": "/tools/lockSurfaceLength.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Rebuild 0-1 rebuildSrf = cmds.rebuildSurface(srfV, ch=True, rpo=True, rt=0, end=1, kr=0, kcp=1, su=0, du=3, sv=0, dv=3, tol=0) rebuildSrfNode = cmds.rename(rebuildSrf[1], prefix + '_rebuildV_rebuildSurface') # Add Control Attribute cmds.addAttr(srfV, ln='lockLength', min=0, max=1, d...
code_fim
hard
{ "lang": "python", "repo": "bennymuller/glTools", "path": "/tools/lockSurfaceLength.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def get_current_user(self): return self.get_secure_cookie("username")<|fim_prefix|># repo: lenovowebcto/Dashboard path: /libriarys/baseclass.py from tornado.web import RequestHandler <|fim_middle|>class BaseHandler(RequestHandler):
code_fim
easy
{ "lang": "python", "repo": "lenovowebcto/Dashboard", "path": "/libriarys/baseclass.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: lenovowebcto/Dashboard path: /libriarys/baseclass.py from tornado.web import RequestHandler <|fim_suffix|> def get_current_user(self): return self.get_secure_cookie("username")<|fim_middle|>class BaseHandler(RequestHandler):
code_fim
easy
{ "lang": "python", "repo": "lenovowebcto/Dashboard", "path": "/libriarys/baseclass.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> too_close = [1, 1] values = [] while any(too_close): values = [random.random() for i in range(l)] diffs = [values[(i + 1) % l] - values[i] for i in range(l)] too_close = [abs(b) < thresh for b in diffs] return values def sine_phase(x): # compute sine # pri...
code_fim
hard
{ "lang": "python", "repo": "samcooler/seraph", "path": "/seraph_utils.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if len(angles) == 0: return 0 elif len(angles) == 1: return angles[0] else: angles_radians = [(p % 1.0) * math.pi * 2 for p in angles] vectors = [[math.cos(a), math.sin(a)] for a in angles_radians] vectors_t = list(zip(*vectors)) #print(vectors_t...
code_fim
hard
{ "lang": "python", "repo": "samcooler/seraph", "path": "/seraph_utils.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: samcooler/seraph path: /seraph_utils.py import random, math def clamp_color(rgb): return map(rgb, clamp_value) def clamp_value(val): if val < 0: return 0 if val > 1.0: return 0.999 return val <|fim_suffix|> def sine(x): # compute sine x %= 6.28318531 ...
code_fim
medium
{ "lang": "python", "repo": "samcooler/seraph", "path": "/seraph_utils.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> distance_array = self.V*[sys.maxint] distance_array[src] = 0 visited = self.V*[False] for _ in xrange(self.V): u = self.min_distance(distance_array, visited) visited[u] = True for j in xrange(self.V): if self.graph[u][j] ...
code_fim
hard
{ "lang": "python", "repo": "adwaraka/algorithms", "path": "/dijkstra.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def main(): g = Graph(9) g.graph = [[0, 4, 0, 0, 0, 0, 0, 8, 0], [4, 0, 8, 0, 0, 0, 0, 11, 0], [0, 8, 0, 7, 0, 4, 0, 0, 2], [0, 0, 7, 0, 9, 14, 0, 0, 0], [0, 0, 0, 9, 0, 10, 0, 0, 0], [0, 0, 4, 14, 10, 0, 2, 0, 0], ...
code_fim
hard
{ "lang": "python", "repo": "adwaraka/algorithms", "path": "/dijkstra.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: adwaraka/algorithms path: /dijkstra.py import sys class Graph(): def __init__(self, vertices): self.V = vertices self.graph = [[0 for column in range(vertices)] for row in range(vertices)] def min_distance(self, distance_array, visited): min...
code_fim
hard
{ "lang": "python", "repo": "adwaraka/algorithms", "path": "/dijkstra.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: JCPedroza/freeCodeCamp-coding-interview-prep-python path: /algorithms/no_repeats_please/permute_repeat.py from itertools import permutations def char_has_twin(index: int, string: str) -> bool: <|fim_suffix|>def str_has_twins(string: str) -> bool: return any(char_has_twin(index, string) for ...
code_fim
medium
{ "lang": "python", "repo": "JCPedroza/freeCodeCamp-coding-interview-prep-python", "path": "/algorithms/no_repeats_please/permute_repeat.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> perms_twins = (str_has_twins(perm) for perm in permutations(string)) perms_alone = filter(lambda perm: not perm, perms_twins) return len(list(perms_alone))<|fim_prefix|># repo: JCPedroza/freeCodeCamp-coding-interview-prep-python path: /algorithms/no_repeats_please/permute_repeat.py from itert...
code_fim
medium
{ "lang": "python", "repo": "JCPedroza/freeCodeCamp-coding-interview-prep-python", "path": "/algorithms/no_repeats_please/permute_repeat.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }