text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> actions = np.random.randn(1) * 3
local_state_hist = np.zeros((env.num_steps, env.observation_space.shape[0]))
local_reward_hist = np.zeros((env.num_steps, 1))
local_gate_hist = np.zeros((env.num_steps, 1))
local_action_hist = np.zeros((env.num_steps, 1))
for i in range(env.num_st... | code_fim | hard | {
"lang": "python",
"repo": "sgillen/misc",
"path": "/switching/warm_start.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def do_rollout(trial_num):
np.random.seed(trial_num)
act_hold = 20
hold_count = 0
obs = env.reset()
local_lqr = False
actions = np.random.randn(1) * 3
local_state_hist = np.zeros((env.num_steps, env.observation_space.shape[0]))
local_reward_hist = np.zeros((env.num_step... | code_fim | hard | {
"lang": "python",
"repo": "sgillen/misc",
"path": "/switching/warm_start.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sgillen/misc path: /switching/warm_start.py
# %%
import numpy as np
from numpy import sin, cos, pi
import gym
import seagul.envs
from seagul.integration import rk4,euler
from control import lqr, ctrb
from torch.multiprocessing import Pool
import matplotlib.pyplot as plt
import matplotlib
#matpl... | code_fim | hard | {
"lang": "python",
"repo": "sgillen/misc",
"path": "/switching/warm_start.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_zero_width_space():
try:
char = codecs.encode(u'\u200b', 'translit/long')
assert char == u''
except TypeError:
assert False<|fim_prefix|># repo: pombredanne/translitcodec path: /tests/test_codec.py
# -*- coding: utf-8 -*-
"""Very basic codec tests.
:copyright: th... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/translitcodec",
"path": "/tests/test_codec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return []
def computeDerivedVariables(self, t, state):
return []<|fim_prefix|># repo: eweilow/SF2567-hybrid-rocket-simulation-project path: /src/system/models/base.py
class Model:
def derivativesDependsOn(self, models):
return []
def derivedVariablesDependsOn(self, models):
return... | code_fim | medium | {
"lang": "python",
"repo": "eweilow/SF2567-hybrid-rocket-simulation-project",
"path": "/src/system/models/base.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eweilow/SF2567-hybrid-rocket-simulation-project path: /src/system/models/base.py
class Model:
def derivativesDependsOn(self, models):
return []
def derivedVariablesDependsOn(self, models):
return []
<|fim_suffix|> return []
def computeDerivedVariables(self, t, state):
... | code_fim | hard | {
"lang": "python",
"repo": "eweilow/SF2567-hybrid-rocket-simulation-project",
"path": "/src/system/models/base.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # close log files
outfile.close()
errfile.close()
else:
print("Running (fakemode): {0:s} in directory {1:s}.".format(command, datadir))
t = 1.
# write timing information
timingfile = open(options['timingFile'], 'w')
pickle.dump(t, timingfil... | code_fim | hard | {
"lang": "python",
"repo": "Inchman/Inchman",
"path": "/python/gpgmp/common/jobs.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Inchman/Inchman path: /python/gpgmp/common/jobs.py
'''
Created on 18/10/2012
@author: matthias
'''
import os
import errno
import uuid
import glob
import shutil
import sys
import subprocess
import time
import pickle
import common.pbs
def prepare_directories(options, extension, subversiondir=None... | code_fim | hard | {
"lang": "python",
"repo": "Inchman/Inchman",
"path": "/python/gpgmp/common/jobs.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #change to full directory
os.chdir(datadir)
# run only if it's not set to fake mode
if not options['fakeRun']:
# create files to capture output
outfile = open(options['outlog'], 'w')
errfile = open(options['errlog'], 'w')
# and time it
ts =... | code_fim | hard | {
"lang": "python",
"repo": "Inchman/Inchman",
"path": "/python/gpgmp/common/jobs.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> trig_at = trigger_time
trig = False
playback_ch_id = ctx.message.channel.id
new_reminder = Reminder(
user_id=author_id,
reminder_content=reminder_content,
trigger_at=trig_at,
triggered=trig,
... | code_fim | hard | {
"lang": "python",
"repo": "RyanRMurray/apollo",
"path": "/cogs/commands/reminders.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @reminder.command(
help='Add a reminder, format "yyyy-mm-dd hh:mm" or "mm-dd hh:mm" or hh:mm:ss or hh:mm or xdxhxmxs or any ordered combination of the last format, then finally your reminder (rest of discord message).'
)
async def add(
self, ctx: Context, trigger_time: DateTime... | code_fim | hard | {
"lang": "python",
"repo": "RyanRMurray/apollo",
"path": "/cogs/commands/reminders.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RyanRMurray/apollo path: /cogs/commands/reminders.py
import asyncio
import logging
from datetime import datetime
from discord.ext import commands
from discord.ext.commands import Bot, Context
from humanize import precisedelta
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy_utils impor... | code_fim | hard | {
"lang": "python",
"repo": "RyanRMurray/apollo",
"path": "/cogs/commands/reminders.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #If we treat the current (X,Y) point as the origin, then destination (X,Y) lies in a quadrant (either I,II,III, or IV), because ->
#the dx and dy (above) results in a + or - difference, which indicates the destination quadrant.
#The quadrant will determine the type of angle adjustment needed m... | code_fim | hard | {
"lang": "python",
"repo": "westpoint-robotics/EE489_Battery_Prediction",
"path": "/current_volt_monitor/calc_bearing_and_distance.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #account for declination angle (Westerly declination angle, so add offset)
magUtmBearing = utm_angleTF + declinationAngle #add offset due to Westerly declination
#account for angle wrap
if magUtmBearing < 0:
magUtmBearing = magUtmBearing + 360
elif magUtmBearing > 360:
... | code_fim | hard | {
"lang": "python",
"repo": "westpoint-robotics/EE489_Battery_Prediction",
"path": "/current_volt_monitor/calc_bearing_and_distance.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: westpoint-robotics/EE489_Battery_Prediction path: /current_volt_monitor/calc_bearing_and_distance.py
import math
#variables for current GPS Lat / Lon Readings
currentLat = 41.391240
currentLon = -73.956217
destLat = 41.393035
destLon = -73.953398
#variables for current UTM coordinates
currentX ... | code_fim | hard | {
"lang": "python",
"repo": "westpoint-robotics/EE489_Battery_Prediction",
"path": "/current_volt_monitor/calc_bearing_and_distance.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quaquel/EMAworkbench path: /test/test_analysis/test_clusterer.py
import matplotlib.pyplot as plt
import numpy as np
import unittest
from ema_workbench.analysis import clusterer
from test import utilities
<|fim_suffix|> distances = clusterer.calculate_cid(data)
self.assertEqual(d... | code_fim | medium | {
"lang": "python",
"repo": "quaquel/EMAworkbench",
"path": "/test/test_analysis/test_clusterer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> distances = clusterer.calculate_cid(data)
self.assertEqual(distances.shape, (n, n))
clusterer.plot_dendrogram(distances)
plt.draw()
assignment = clusterer.apply_agglomerative_clustering(distances, 2)
self.assertEqual(assignment.shape, (10,))
distan... | code_fim | hard | {
"lang": "python",
"repo": "quaquel/EMAworkbench",
"path": "/test/test_analysis/test_clusterer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZhihengFeng/mysite_blog path: /blog/views.py
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator
from .models import Blog, BlogType
from django.conf import settings
from read_statistics.utils import read_statistics_once_read
from user.forms import Lo... | code_fim | hard | {
"lang": "python",
"repo": "ZhihengFeng/mysite_blog",
"path": "/blog/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> blog = get_object_or_404(Blog, pk=blog_pk)
read_cookie_key = read_statistics_once_read(request, blog)
context = dict()
context['blog'] = blog
context['blog_author'] = blog.author.get_nickname_or_username()
context['login_form'] = LoginForm()
context['pre_blog'] = Blog.objects.f... | code_fim | hard | {
"lang": "python",
"repo": "ZhihengFeng/mysite_blog",
"path": "/blog/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> blogs_all_list = Blog.objects.filter(created_time__year=year, created_time__month=month)
context = get_blogs_common_data(request, blogs_all_list)
context['blogs_with_date'] = '%s年%s' % (year, month)
return render(request, 'blog/blogs_with_date.html', context)
def blog_detail(request, blog... | code_fim | hard | {
"lang": "python",
"repo": "ZhihengFeng/mysite_blog",
"path": "/blog/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VivekJadeja/CBCode path: /1. Fundamentals/Arrays/GreedyAlgo.py
# Greedy Algorithm solves a problem by building a solution incrementally
# The algorithm is greedy because it chooses the next step that gives the most benefit
# Can save a lot of time when used correctly since they don't have to look... | code_fim | hard | {
"lang": "python",
"repo": "VivekJadeja/CBCode",
"path": "/1. Fundamentals/Arrays/GreedyAlgo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #O(n) runtime b/c iterating through array
#O(1) SC b/c no extra space taken up
def canJump(self, nums):
best_index = 0
# for each index in the array
for i in range(len(nums)):
# if the current index is greater than the best index
if i > best_inde... | code_fim | hard | {
"lang": "python",
"repo": "VivekJadeja/CBCode",
"path": "/1. Fundamentals/Arrays/GreedyAlgo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eb4890/lhsgghc path: /programs/PCSoftware/src/fileops.py
import os
def savelesson(text):
os.path.expanduser("~/.buzzers/lessons")
<|fim_suffix|> path = os.path.expanduser("~/.buzzers")
dirs = os.walk(os.path.expanduser("~/.buzzers/lessons"))
#"/home/loadquo/files/lhsgghc/Programs/PCSoftwar... | code_fim | easy | {
"lang": "python",
"repo": "eb4890/lhsgghc",
"path": "/programs/PCSoftware/src/fileops.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> path = os.path.expanduser("~/.buzzers")
dirs = os.walk(os.path.expanduser("~/.buzzers/lessons"))
#"/home/loadquo/files/lhsgghc/Programs/PCSoftware/src/admin/lessons")
lessons = []
for root, d, fs in dirs:
fullfs = [root +"/"+ f for f in fs]
lessons.extend(fs)
return lessons<|fim_pre... | code_fim | easy | {
"lang": "python",
"repo": "eb4890/lhsgghc",
"path": "/programs/PCSoftware/src/fileops.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for permission in response['Grants']:
self.acl.append(permission['Permission'])
except botocore.exceptions.ClientError as e:
raise<|fim_prefix|># repo: swetha-murali/SimpleS3Scanner path: /src/s3_object.py
... | code_fim | medium | {
"lang": "python",
"repo": "swetha-murali/SimpleS3Scanner",
"path": "/src/s3_object.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swetha-murali/SimpleS3Scanner path: /src/s3_object.py
import botocore
class s3Obj:
def __init__(self, name, bucket_name, size, last_modified, storage_class):
self.name = name
self.size = size
self.last_modified = last_modified
self.storage_class ... | code_fim | medium | {
"lang": "python",
"repo": "swetha-murali/SimpleS3Scanner",
"path": "/src/s3_object.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.acl.append(permission['Permission'])
except botocore.exceptions.ClientError as e:
raise<|fim_prefix|># repo: swetha-murali/SimpleS3Scanner path: /src/s3_object.py
import botocore
class s3Obj:
def __init__(self, name, buc... | code_fim | hard | {
"lang": "python",
"repo": "swetha-murali/SimpleS3Scanner",
"path": "/src/s3_object.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lewisc402/bg path: /bg/__init__.py
#!/usr/bin/env python
#coding=utf-8
"""
__init__.py
:license: BSD, see LICENSE for more details.
"""
import os
import logging
import sys
from logging.handlers import SMTPHandler, RotatingFileHandler
from flask import Flask, g, session, request, flash... | code_fim | hard | {
"lang": "python",
"repo": "lewisc402/bg",
"path": "/bg/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def configure_extensions(app):
# configure extensions
db.init_app(app)
#db.app = app
#db.create_all()
mail.init_app(app)
cache.init_app(app)
#setup_themes(app)
def configure_context_processors(app):
@app.context_processor
def archives():
archives = set()
... | code_fim | hard | {
"lang": "python",
"repo": "lewisc402/bg",
"path": "/bg/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>etailView.as_view(), name='clientfacilitydetail'),
path('events/', ClientEventListView.as_view(),
name='clienteventlist'),
path('events/<slug:slug>/details',
ClientEventDetailView.as_view(), name='clienteventdetail'),
path('notices/', ClientNoticeListView.as_view(), name='cli... | code_fim | hard | {
"lang": "python",
"repo": "primeuser/gymequipmentstore-in-django",
"path": "/gymapp/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: primeuser/gymequipmentstore-in-django path: /gymapp/urls.py
from django.urls import path
from .views import *
from .utils import *
app_name = 'gymapp'
urlpatterns = [
# CLIENT PATHS ##
# CLIENT PATHS ##
# CLIENT PATHS ##
# CLIENT PATHS ##
# general pages
path('', Cl... | code_fim | hard | {
"lang": "python",
"repo": "primeuser/gymequipmentstore-in-django",
"path": "/gymapp/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>>/details',
ClientBlogDetailView.as_view(), name='clientblogdetail'),
path('schedules/', ClientScheduleListView.as_view(), name='clientschedulelist'),
path('404/', ClientPageNotFoundView.as_view(), name='clientpagenotfound'),
path('subscribe/', ClientSubscriberCreateView.as_view(),
... | code_fim | hard | {
"lang": "python",
"repo": "primeuser/gymequipmentstore-in-django",
"path": "/gymapp/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: collective/haufe.requestmonitoring path: /haufe/requestmonitoring/successlogging.py
# -*- coding: utf-8 -*-
"""Success request logging.
This logging is used by "CheckZope" to determine the amount
of work performed by Zope (in order not to bother it with monitor
probes when it is heavily active) ... | code_fim | hard | {
"lang": "python",
"repo": "collective/haufe.requestmonitoring",
"path": "/haufe/requestmonitoring/successlogging.py",
"mode": "psm",
"license": "ZPL-2.1",
"source": "the-stack-v2"
} |
<|fim_suffix|>@adapter(IProcessStarting)
def start_successlogging(unused):
"""start successlogging if configured."""
from App.config import getConfiguration
config = getConfiguration().product_config.get('successlogging')
if config is None:
return # not configured
global _log_good, _log_bad... | code_fim | hard | {
"lang": "python",
"repo": "collective/haufe.requestmonitoring",
"path": "/haufe/requestmonitoring/successlogging.py",
"mode": "spm",
"license": "ZPL-2.1",
"source": "the-stack-v2"
} |
<|fim_suffix|>s = webserver.webserverstart()
lastscan = 0
while True:
webserver.webserver(s, onAdd, onDelete)
print("scanning soon")
if time.time() - lastscan > 10:
print("scanning now...")
bt.gap_scan(10000)
lastscan = time.time()<|fim_prefix|># repo: AdrianMorelle/Automa... | code_fim | medium | {
"lang": "python",
"repo": "AdrianMorelle/AutomaticGate",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(byteToMac(addr))
if addr == memoryview(bytearray(b'\x40\xe8\xe7\x85\x3d\xed')):
print("device found")
elif event == _IRQ_SCAN_DONE:
# Scan duration finished or manually stopped.
print("scan complete")
pass
def onAdd(addBT):
memory... | code_fim | hard | {
"lang": "python",
"repo": "AdrianMorelle/AutomaticGate",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdrianMorelle/AutomaticGate path: /main.py
import gc
import network
import lib.gate as gate
import time
from micropython import const
from ubluetooth import BLE
import lib.webserver as webserver
bt = BLE()
bt.active(True)
_IRQ_SCAN_RESULT = const(5)
_IRQ_SCAN_DONE = const(6)
def ... | code_fim | medium | {
"lang": "python",
"repo": "AdrianMorelle/AutomaticGate",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ds18b20/Microblog path: /sqlite_test.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sqlite3
# 连接到db文件
conn = sqlite3.connect('app.db')
# 创建一个Cursor:
cursor = conn.cursor()
<|fim_suffix|># 执行查询表user内的所有记录:
cursor.execute('select * from user')
print("Table record:", cursor... | code_fim | hard | {
"lang": "python",
"repo": "ds18b20/Microblog",
"path": "/sqlite_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 执行查询表user内的所有记录:
cursor.execute('select * from user')
print("Table record:", cursor.fetchall())
cursor.close()
conn.close()<|fim_prefix|># repo: ds18b20/Microblog path: /sqlite_test.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sqlite3
# 连接到db文件
conn = sqlite3.connect('app.db'... | code_fim | hard | {
"lang": "python",
"repo": "ds18b20/Microblog",
"path": "/sqlite_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Response(response=dumps({"msg":"App successfull"}), status=200, mimetype='application/json')
@app.route("/spamapi/",methods=['GET','POST'])
def apicall():
try:
predTxt = loads(request.data)
predTxt = predTxt['input']
response = spam.predict_data(predTxt)
ret... | code_fim | medium | {
"lang": "python",
"repo": "AnanthaBalaji/Spam-or-Not",
"path": "/api/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnanthaBalaji/Spam-or-Not path: /api/main.py
from flask import Flask,request,Response
from spamapp.spam import SpamIdentify
from json import dumps,loads
app = Flask(__name__)
spam = SpamIdentify()
<|fim_suffix|>@app.route("/spamapi/",methods=['GET','POST'])
def apicall():
try:
predT... | code_fim | medium | {
"lang": "python",
"repo": "AnanthaBalaji/Spam-or-Not",
"path": "/api/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route("/",methods=['GET'])
def home():
return Response(response=dumps({"msg":"App successfull"}), status=200, mimetype='application/json')
@app.route("/spamapi/",methods=['GET','POST'])
def apicall():
try:
predTxt = loads(request.data)
predTxt = predTxt['input']
respo... | code_fim | medium | {
"lang": "python",
"repo": "AnanthaBalaji/Spam-or-Not",
"path": "/api/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(len(result)):
print(result[i], " Rank: ", i)
print(len(result))
if __name__ == "__main__":
main()<|fim_prefix|># repo: Dashuailiu/hello-Python path: /algorithm/lex_subsets.py
"""
k-element subsets of the set [n]
3-element subsets of the set [6]
123
"""
result = []
... | code_fim | medium | {
"lang": "python",
"repo": "Dashuailiu/hello-Python",
"path": "/algorithm/lex_subsets.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dashuailiu/hello-Python path: /algorithm/lex_subsets.py
"""
k-element subsets of the set [n]
3-element subsets of the set [6]
123
"""
result = []
def get_subset(A, k, n):
a_list = [i for i in A]
if len(a_list) == k:
result.append(a_list)
return
s_num = max(a_list)+... | code_fim | medium | {
"lang": "python",
"repo": "Dashuailiu/hello-Python",
"path": "/algorithm/lex_subsets.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tasks.append(Task(enablerecoil, 800))
for angle in range(0, 360, 90):
blasters.append(GasterBlaster(
pos=[150 + 150 / 2, 240 + 150 / 2],
angle=angle,
time1=10,
time2=1000,
width=30,
time3=0,
norecoil=True
... | code_fim | hard | {
"lang": "python",
"repo": "kyv001/sansfight",
"path": "/sansfight/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ...
# ------------------------------------
"""主程序"""
while True:
# ---------------------------------------------------------
'''实例化'''
from locals_ import *
time = 0
_boxpos = [0, 0]
_boxsize = SCREEN_SIZE[:]
rightdown = SCREEN_SIZE[:]
time1 = 0
time2 = 0
del... | code_fim | hard | {
"lang": "python",
"repo": "kyv001/sansfight",
"path": "/sansfight/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyv001/sansfight path: /sansfight/main.py
bones.clear()
players_turn("* ...")
@add_attack
def board_2_1():
set_turn_time(10)
global BOX_POS, BOX_SIZE
BOX_POS = [50, 240]
BOX_SIZE = [500, 140]
sans.hand_direction = DOWN
player.type = BLUE_SOUL
player.direction = DOW... | code_fim | hard | {
"lang": "python",
"repo": "kyv001/sansfight",
"path": "/sansfight/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uni-tue-kn/P4sec path: /common_lib/event/task.py
from time import time
class Task:
def __init__(self, f, ready: float):
self._f = f
self._ready = ready
<|fim_suffix|> return self._ready
def __call__(self) -> None:
self._f()
def __lt__(self, other) ->... | code_fim | medium | {
"lang": "python",
"repo": "uni-tue-kn/P4sec",
"path": "/common_lib/event/task.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "Task(" + str(self._ready) + ")"<|fim_prefix|># repo: uni-tue-kn/P4sec path: /common_lib/event/task.py
from time import time
class Task:
def __init__(self, f, ready: float):
self._f = f
self._ready = ready
def set_ready(self, ready: float) -> None:
<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "uni-tue-kn/P4sec",
"path": "/common_lib/event/task.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._f()
def __lt__(self, other) -> bool:
return self._ready < other.get_ready()
def __str__(self):
return "Task(" + str(self._ready) + ")"<|fim_prefix|># repo: uni-tue-kn/P4sec path: /common_lib/event/task.py
from time import time
class Task:
def __init__(self, f,... | code_fim | easy | {
"lang": "python",
"repo": "uni-tue-kn/P4sec",
"path": "/common_lib/event/task.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AAJAL/Python-Graphics path: /ComputeDistanceGraphics.py
import turtle
def distance(x1, y1, x2, y2):
return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
x1, y1 = eval(input("Enter x1 and y1 for point 1: "))
x2, y2 = eval(input("Enter x2 and y2 for point 2: "))
<|fim_suffix|>turtle... | code_fim | medium | {
"lang": "python",
"repo": "AAJAL/Python-Graphics",
"path": "/ComputeDistanceGraphics.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Center of line
turtle.penup()
turtle.goto((x1 + x2) / 2, (y1 + y2) / 2)
turtle.write("Distance")
turtle.done()<|fim_prefix|># repo: AAJAL/Python-Graphics path: /ComputeDistanceGraphics.py
import turtle
def distance(x1, y1, x2, y2):
return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
x... | code_fim | medium | {
"lang": "python",
"repo": "AAJAL/Python-Graphics",
"path": "/ComputeDistanceGraphics.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unique_links=[]
link_len={}
out_arr=[]
if request.method == 'POST':
url = request.form['url']
main = re.sub(r"([\w:///.]+com|info|in|org)([\w///?/=/&/_-]*)",r"\1",url,0, re.MULTILINE | re.UNICODE | re.IGNORECASE)
req =Request(main, headers={'User-Agent' : "Mozilla/5... | code_fim | medium | {
"lang": "python",
"repo": "rajatjha26/Website_WordCount",
"path": "/data_extract.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rajatjha26/Website_WordCount path: /data_extract.py
from flask import request,Flask, render_template
from bs4 import BeautifulSoup as bs
from urllib.request import Request,urlopen
import re
app = Flask(__name__)
@app.route('/')
def addRegion():
<|fim_suffix|>def output_data():
unique_links=[... | code_fim | medium | {
"lang": "python",
"repo": "rajatjha26/Website_WordCount",
"path": "/data_extract.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def output_data():
unique_links=[]
link_len={}
out_arr=[]
if request.method == 'POST':
url = request.form['url']
main = re.sub(r"([\w:///.]+com|info|in|org)([\w///?/=/&/_-]*)",r"\1",url,0, re.MULTILINE | re.UNICODE | re.IGNORECASE)
req =Request(main, headers={'User-... | code_fim | medium | {
"lang": "python",
"repo": "rajatjha26/Website_WordCount",
"path": "/data_extract.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: djiayong5/test path: /lecture/pylayer.py
import caffe
import numpy as np
class PyLayer(caffe.Layer):
def setup(self, bottom, top):
if len(bottom) != 2:
raise Exception("Need two inputs to compute distance")
<|fim_suffix|> def forward(self, bottom, top):
self.diff[...] = bottom[... | code_fim | hard | {
"lang": "python",
"repo": "djiayong5/test",
"path": "/lecture/pylayer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(2):
if not propagate_down[i]:
continue
if i == 0:
bottom[i].diff[...] = self.diff * (1 / bottom[i].num)
else:
bottom[i].diff[...] = self.diff * (-1 / bottom[i].num)<|fim_prefix|># repo: djiayong5/test path: /lecture/pylayer.py
import caffe
impo... | code_fim | medium | {
"lang": "python",
"repo": "djiayong5/test",
"path": "/lecture/pylayer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EBI-Metagenomics/emg-backlog-schema path: /backlog/models.py
from django.db import models
from django.utils import timezone
class User(models.Model):
class Meta:
db_table = "User"
app_label = "backlog"
webin_id = models.CharField(
"ENA's submission account id", ... | code_fim | hard | {
"lang": "python",
"repo": "EBI-Metagenomics/emg-backlog-schema",
"path": "/backlog/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class AssemblyProteinDB(models.Model):
STATUS_COMPLETED = 1
STATUS_FAIL = 0
STATUS = ((STATUS_COMPLETED, "Completed"), (STATUS_FAIL, "Failed"))
FAIL_FASTA_MISSING = 1
FAIL_PIPELINE_VERSION = 2
FAIL_FASTA_DIR = 3
FAIL_SUPRESSED = 4
FAIL_MGYC = 5
FAIL_MGYP = 6
FAIL... | code_fim | hard | {
"lang": "python",
"repo": "EBI-Metagenomics/emg-backlog-schema",
"path": "/backlog/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chiro2001/WorldExcuteMeVideo path: /Simulator/Sound/sound.py
import pygame
import wave
import threading
import numpy as np
import pylab
import struct
import io
from PIL import Image
import sounddevice as sd
# 处理音频频谱
# voice.wav 格式:8000 rate 16bit 单声道
class SpectrumMap:
def __init__(self):
... | code_fim | hard | {
"lang": "python",
"repo": "chiro2001/WorldExcuteMeVideo",
"path": "/Simulator/Sound/sound.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def raw(self, count, clear: bool=True):
if clear:
pylab.plt.clf()
y = np.zeros(count)
for i in range(count):
val = self.wavefile.readframes(1)
left = val[0:2]
try:
v = struct.unpack('h', left)[0]
y... | code_fim | hard | {
"lang": "python",
"repo": "chiro2001/WorldExcuteMeVideo",
"path": "/Simulator/Sound/sound.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yuwon-shin/emotion_classification path: /Classification/main.py
import os
import torch
from data_loader import FER
from torch.utils.data import DataLoader
from tqdm import tqdm
# from tensorboardX import SummaryWriter
import model as md
# train_writer = SummaryWriter(log_dir="log_las... | code_fim | hard | {
"lang": "python",
"repo": "yuwon-shin/emotion_classification",
"path": "/Classification/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>train_data_path = '../../../data/face_data'
train_dataset = FER(train_data_path , image_size=64, mode='train')
train_dataloader = DataLoader(train_dataset, batch_size=batch_size, shuffle = True)
valid_data_path = '../../../data/face_data'
valid_dataset = FER(valid_data_path,image_size=64, mode='val... | code_fim | hard | {
"lang": "python",
"repo": "yuwon-shin/emotion_classification",
"path": "/Classification/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qbss/PastebinDjango path: /pastebinapp/models.py
from django.db import models
<|fim_suffix|> name= models.CharField(max_length=30)
textpaste = models.CharField(max_length=80)
pasteurl = models.AutoField(primary_key=True)
def __str__(self):
return self.name<|fim_middle|># Create your mode... | code_fim | easy | {
"lang": "python",
"repo": "qbss/PastebinDjango",
"path": "/pastebinapp/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> name= models.CharField(max_length=30)
textpaste = models.CharField(max_length=80)
pasteurl = models.AutoField(primary_key=True)
def __str__(self):
return self.name<|fim_prefix|># repo: qbss/PastebinDjango path: /pastebinapp/models.py
from django.db import models
<|fim_middle|># Create your mode... | code_fim | easy | {
"lang": "python",
"repo": "qbss/PastebinDjango",
"path": "/pastebinapp/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __str__(self):
return self.name<|fim_prefix|># repo: qbss/PastebinDjango path: /pastebinapp/models.py
from django.db import models
<|fim_middle|># Create your models here.
class Pastebin(models.Model):
name= models.CharField(max_length=30)
textpaste = models.CharField(max_length=80)
pasteurl ... | code_fim | medium | {
"lang": "python",
"repo": "qbss/PastebinDjango",
"path": "/pastebinapp/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pl.clf()
pl.plot(x, d['reelection'], 'o-', label='reelection')
pl.plot(x, d['rerun'], 'o-', label='rerun')
pl.plot(x, d['ratio'], 'o-', label='incumbent ratio')
pl.fill_between(x, d['ratio'], np.zeros(len(d.index)), facecolor='red',\
alpha=0.1)
pl.legend(loc='upper left')
pl.xlabel('assembly_id')
... | code_fim | medium | {
"lang": "python",
"repo": "teampopong/infographics",
"path": "/2014/rerun/draw.py",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: teampopong/infographics path: /2014/rerun/draw.py
#! /usr/bin/python2.7
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import pylab as pl
<|fim_suffix|>pl.clf()
pl.plot(x, d['reelection'], 'o-', label='reelection')
pl.plot(x, d['rerun'], 'o-', label='rerun')
pl.plot(x, d['ratio'... | code_fim | medium | {
"lang": "python",
"repo": "teampopong/infographics",
"path": "/2014/rerun/draw.py",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>data.index = pd.to_datetime((data.index.values), unit='s')
#data.head(5)
#before_process = data
after_process=data
#before_process = before_process.resample('d').sum()
#before_process['KWh'] = round(((before_process.KWh * 6) / (1000 * 3600)) , 3)
#before_process.head(5)
after_process = after_process.drop(... | code_fim | hard | {
"lang": "python",
"repo": "Shanilka1994/STLFusingMLAlgorithms",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shanilka1994/STLFusingMLAlgorithms path: /test.py
import pandas as pd
import numpy as np
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
#from pandas import datetime
#from pandas.tseries.t
from sklearn.preprocessing import MinMaxScaler
#from statsmodels.tsa.seasonal import se... | code_fim | hard | {
"lang": "python",
"repo": "Shanilka1994/STLFusingMLAlgorithms",
"path": "/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sulladenis/reading-memo path: /test.py
import db
data = {'python book': ['10.09.2019', 200, 50, False]}
def test_insert_and_get_db(data):
<|fim_suffix|>if __name__ == '__main__':
print(f' Test insert dict in to db, and get dict from db is {test_insert_and_get_db(data)}')
print(f'... | code_fim | medium | {
"lang": "python",
"repo": "Sulladenis/reading-memo",
"path": "/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
print(f' Test insert dict in to db, and get dict from db is {test_insert_and_get_db(data)}')
print(f'List books = {db.list_book()}')<|fim_prefix|># repo: Sulladenis/reading-memo path: /test.py
import db
data = {'python book': ['10.09.2019', 200, 50, False]}
de... | code_fim | medium | {
"lang": "python",
"repo": "Sulladenis/reading-memo",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
print(f' Test insert dict in to db, and get dict from db is {test_insert_and_get_db(data)}')
print(f'List books = {db.list_book()}')<|fim_prefix|># repo: Sulladenis/reading-memo path: /test.py
import db
data = {'python book': ['10.09.2019', 200, 50, False]}
def ... | code_fim | medium | {
"lang": "python",
"repo": "Sulladenis/reading-memo",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def orderstatistic(img, row, col, msize=3):
rimg = copy.deepcopy(img)
mr = (msize-1)//2
mc = (msize-1)//2
for i in range(mr, row-mr-1):
for j in range(mc, col-mc-1):
rimg[i][j] = medianflt(img, i, j, msize, mr, mc)
return rimg
d0 = 9
rimg = orderstatistic(img, ro... | code_fim | hard | {
"lang": "python",
"repo": "TiranoGreatLand/digitalimageclassification",
"path": "/problem2/medianfilter.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TiranoGreatLand/digitalimageclassification path: /problem2/medianfilter.py
import cv2
import numpy as np
import copy
imgpath = 'D:\\DIP-Project1/b.jpg'
img = cv2.imread(imgpath)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('img', img)
row = len(img)
col = len(img[0])
def medianflt(img... | code_fim | hard | {
"lang": "python",
"repo": "TiranoGreatLand/digitalimageclassification",
"path": "/problem2/medianfilter.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return rimg
d0 = 9
rimg = orderstatistic(img, row, col, d0)
cv2.imshow('aimg', rimg)
cv2.waitKey(0)<|fim_prefix|># repo: TiranoGreatLand/digitalimageclassification path: /problem2/medianfilter.py
import cv2
import numpy as np
import copy
imgpath = 'D:\\DIP-Project1/b.jpg'
img = cv2.imread(imgpath)... | code_fim | hard | {
"lang": "python",
"repo": "TiranoGreatLand/digitalimageclassification",
"path": "/problem2/medianfilter.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = dict(
kalman_obj_id=table1["obj_id"],
kalman_frame=table1["frame"],
kalman_x=table1["x"],
kalman_y=table1["y"],
kalman_z=table1["z"],
kalman_xvel=table1["xvel"],
kalman_yvel=table1["yvel"],
kalman_zvel=table1["zvel"],
P00=t... | code_fim | hard | {
"lang": "python",
"repo": "elhananby/flydra",
"path": "/flydra_analysis/flydra_analysis/analysis/flydra_analysis_convert_to_mat.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elhananby/flydra path: /flydra_analysis/flydra_analysis/analysis/flydra_analysis_convert_to_mat.py
from __future__ import division
from __future__ import print_function
import numpy
import tables as PT
import scipy.io
import sys, math
import tables.flavor
from flydra_analysis.analysis.save_as_fly... | code_fim | hard | {
"lang": "python",
"repo": "elhananby/flydra",
"path": "/flydra_analysis/flydra_analysis/analysis/flydra_analysis_convert_to_mat.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if "xaccel" in table1:
# acceleration state not in newer dynamic models
dict2 = dict(
kalman_xaccel=table1["xaccel"],
kalman_yaccel=table1["yaccel"],
kalman_zaccel=table1["zaccel"],
)
data.update(dict2)
if not ignore_observations... | code_fim | hard | {
"lang": "python",
"repo": "elhananby/flydra",
"path": "/flydra_analysis/flydra_analysis/analysis/flydra_analysis_convert_to_mat.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rwu780/DatabaseManage path: /patient.py
import sqlite3
import os
#Search for a patient name
#Every doctor enter a name, it will find the patinet name that is similar to the patient name
#Once a match is found, the system will output a list of matched patient names.
#Then, the doctor select the p... | code_fim | hard | {
"lang": "python",
"repo": "rwu780/DatabaseManage",
"path": "/patient.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#View a list of charts that related to the patient
def viewChart(CONN, chart_id, staff, patient, editAble):
c = CONN.cursor()
os.system('clear')
print("Patient HCNO: " + patient[0] + ", Patient Name: " + patient[1])
print("symptoms table")
c.execute('''SELECT *
FRO... | code_fim | hard | {
"lang": "python",
"repo": "rwu780/DatabaseManage",
"path": "/patient.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asmitamahamuni/python_programs path: /file_list.py
# Print list of files and directories
import os
def file_list(dir):
<|fim_suffix|>file_list('D:\Workspace\test\PythonProject')<|fim_middle|> subdir_list = []
for item in os.listdir(dir):
fullpath = os.path.join(dir,item)
i... | code_fim | hard | {
"lang": "python",
"repo": "asmitamahamuni/python_programs",
"path": "/file_list.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for d in subdir_list:
file_list(d)
file_list('D:\Workspace\test\PythonProject')<|fim_prefix|># repo: asmitamahamuni/python_programs path: /file_list.py
# Print list of files and directories
import os
def file_list(dir):
<|fim_middle|> subdir_list = []
for item in os.listdir(dir):
... | code_fim | hard | {
"lang": "python",
"repo": "asmitamahamuni/python_programs",
"path": "/file_list.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RenkoT97/OrganizatorNakupov path: /izracuni.py
import itertools
import numpy
import math
import psycopg2
import podatki
baza = podatki.baza
dom = podatki.preberi_lokacijo()
seznam_trgovin =["spar", "mercator", "tus", "hofer", "lidl"]
id_in_opis = podatki.id_izdelka_v_opis()
seznam_izdelkov = [el... | code_fim | hard | {
"lang": "python",
"repo": "RenkoT97/OrganizatorNakupov",
"path": "/izracuni.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def razporeditev(obiskane_trgovine, izdelki, slovar):
izdelki2 = izdelki.copy()
razporeditev = []
for trgovina in obiskane_trgovine:
sez = []
for izdelek in izdelki:
if {izdelek}.issubset(slovar[trgovina]):
izd = podatki.id_izdelka_v_opis()[izdelek-1... | code_fim | hard | {
"lang": "python",
"repo": "RenkoT97/OrganizatorNakupov",
"path": "/izracuni.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: optroodt/rovers path: /rovers.py
class Rover(object):
DIRECTIONS = 'NESW'
MOVEMENTS = {
'N': (0, 1),
'E': (1, 0),
'S': (0, -1),
'W': (-1, 0)
}
def __init__(self, init_string, plateau_dimensions):
'''
give the rover a sense of ... | code_fim | hard | {
"lang": "python",
"repo": "optroodt/rovers",
"path": "/rovers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute(self):
for c in self.commands:
if c == 'L':
self.rotate_left()
elif c == 'R':
self.rotate_right()
elif c == 'M':
self.move()
else:
print 'unknown command: %s' % c
... | code_fim | hard | {
"lang": "python",
"repo": "optroodt/rovers",
"path": "/rovers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zegkljan/evo path: /evo/sr/gp.py
# -*- coding: utf-8 -*-
"""TODO
"""
import logging
import numpy
import evo.gp.support
import evo.sr
import evo.utils.stats
class RegressionFitness(evo.Fitness):
LOG = logging.getLogger(__name__ + '.RegressionFitness')
def __init__(self, train_inputs,... | code_fim | hard | {
"lang": "python",
"repo": "zegkljan/evo",
"path": "/evo/sr/gp.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> args):
return individual.genotype[0].eval(args=args)
def get_error(self, output, individual: evo.gp.support.ForestIndividual):
e = self.train_output - output
ae = numpy.abs(e)
sse = e.dot(e)
r2 = 1 - sse / self.ssw
mse = sse / numpy.ale... | code_fim | hard | {
"lang": "python",
"repo": "zegkljan/evo",
"path": "/evo/sr/gp.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> e = self.train_output - output
ae = numpy.abs(e)
sse = e.dot(e)
r2 = 1 - sse / self.ssw
mse = sse / numpy.alen(e)
mae = numpy.sum(ae) / numpy.alen(e)
worst_case_ae = ae.max()
individual.set_data('R2', r2)
individual.set_data('MSE', ms... | code_fim | hard | {
"lang": "python",
"repo": "zegkljan/evo",
"path": "/evo/sr/gp.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> choice = i + 1
choose_test_set(str(choice))
train_data, train_labels = get_network_input(train_path)
test_data, test_labels = get_network_input(test_path)
fold_accuracy = 0
for i in range(len(test_data)):
nn_index = sess.run(pred, feed_dict={x... | code_fim | medium | {
"lang": "python",
"repo": "ianmarci/timpanigestureanalysis",
"path": "/run_experiment.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> train_data, train_labels = get_network_input(train_path)
test_data, test_labels = get_network_input(test_path)
fold_accuracy = 0
for i in range(len(test_data)):
nn_index = sess.run(pred, feed_dict={x_train: train_data,
... | code_fim | hard | {
"lang": "python",
"repo": "ianmarci/timpanigestureanalysis",
"path": "/run_experiment.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ianmarci/timpanigestureanalysis path: /run_experiment.py
################################################################################
# run_experiment.py #
# Ian Marci 2017 ... | code_fim | hard | {
"lang": "python",
"repo": "ianmarci/timpanigestureanalysis",
"path": "/run_experiment.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aasthaj01/DSA-questions path: /Misc/finding_position.py
#Some people are standing in a queue. A selection process follows a rule where people standing on even positions are selected. Of the selected people a queue is formed and again out of these only people on even position are selected. This co... | code_fim | hard | {
"lang": "python",
"repo": "Aasthaj01/DSA-questions",
"path": "/Misc/finding_position.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n == 0 or n == 1:
return
elif n == 2:
return 2
else:
for i in reversed(range(n+1)):
if 2**i < n:
return 2**i
t = int(input("Enter number of test cases:"))
arr = []
for i in range(t):
n = int(input())
ans = even(n)
arr.appe... | code_fim | hard | {
"lang": "python",
"repo": "Aasthaj01/DSA-questions",
"path": "/Misc/finding_position.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: christophbrgr/ood_detection_framework path: /methods/mcp.py
import torch
import numpy as np
from torch.autograd import Variable
from util import helpers
from util.metrics import ECELoss, ece_score
import sklearn.metrics as skm
import os
import pandas as pd
import pickle
def eval(path_in, path_... | code_fim | hard | {
"lang": "python",
"repo": "christophbrgr/ood_detection_framework",
"path": "/methods/mcp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('| Classification confidence for OOD is saved at: {}'.format(path_out))
with torch.no_grad():
for batch_idx, (inputs, targets) in enumerate(oodloader):
if use_cuda:
inputs, targets = inputs.cuda(), targets.cuda()
inputs, targets = Variable(inpu... | code_fim | hard | {
"lang": "python",
"repo": "christophbrgr/ood_detection_framework",
"path": "/methods/mcp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>))
for n, k in queries:
print(n, k)<|fim_prefix|># repo: wiwitrifai/competitive-programming path: /gcj/2020_qual/indicium_gen.py
queries = []
for n in range(2, 51):
<|fim_middle|> for k in range(n, n*n+1):
queries.append((n, k))
print(len(queries | code_fim | medium | {
"lang": "python",
"repo": "wiwitrifai/competitive-programming",
"path": "/gcj/2020_qual/indicium_gen.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wiwitrifai/competitive-programming path: /gcj/2020_qual/indicium_gen.py
queries = []
for n in range(2, 51):
<|fim_suffix|>))
for n, k in queries:
print(n, k)<|fim_middle|> for k in range(n, n*n+1):
queries.append((n, k))
print(len(queries | code_fim | medium | {
"lang": "python",
"repo": "wiwitrifai/competitive-programming",
"path": "/gcj/2020_qual/indicium_gen.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return np.sort(data), np.arange(1, len(data)+1) / len(data)
# Generate x, y values
x, y = ecdf(t_bt)
plt.figure(2)
# Plot CDF from random numbers
plt.semilogx(x, y, '.', markersize=10)
# Clean up plot
plt.margins(y=0.02)
plt.xlabel('time (s)')
plt.ylabel('ECDF')
plt.figure(3)
# Plot the CCDF
plt.... | code_fim | hard | {
"lang": "python",
"repo": "mayziyuhuang/bootcamp",
"path": "/ex4_3_sol.py",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.