text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> piece = CurrentPiece(
piece.piece, position=Point(piece.position.x, piece.position.y - 1)
)
return self.array_with_piece(piece)
@dataclass
class Point:
"""
Representation of a coordinate point in the tetris field
"""
x: int
y: int
@property
... | code_fim | hard | {
"lang": "python",
"repo": "SamuelNLP/nes-ai",
"path": "/nes_ai/tetris/field.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SamuelNLP/nes-ai path: /nes_ai/tetris/field.py
"""
Class and functions that illustrate a Tetris field
"""
from dataclasses import dataclass
from typing import Optional, Tuple
import numpy as np
from nes_ai.tetris.piece import Piece
from nes_ai.util.prerequisites import require
FIELD_SHAPE = (... | code_fim | hard | {
"lang": "python",
"repo": "SamuelNLP/nes-ai",
"path": "/nes_ai/tetris/field.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ProfileDetachResponse(ProfileResponseBase):
def process_pass(self):
self._result = ProfileManager.detach_profile(
self._channel_oid, self._profile_oid, self._sender_oid, self._target_oid)
class ProfileNameCheckResponse(
HandleChannelOidMixin,
SerializeErrorM... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/JellyBot/api/responses/id/prof.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self._profiles:
self._result = ProfileManager.get_permissions(self._profiles)
class ProfileResponseBase(
RequireSenderMixin, HandleChannelOidMixin,
SerializeErrorMixin, SerializeResultOnSuccessMixin, SerializeResultExtraMixin, BaseApiResponse, ABC):
def __init_... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/JellyBot/api/responses/id/prof.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RxJellyBot/Jelly-Bot path: /JellyBot/api/responses/id/prof.py
from abc import ABC
from bson import ObjectId
from JellyBot.api.responses import BaseApiResponse
from JellyBot.api.static import param
from JellyBot.api.responses.mixin import (
RequireSenderMixin, HandleChannelOidMixin,
Seri... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/JellyBot/api/responses/id/prof.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return sum([x for x in range(1,n) if n%x == 0])
nums = []
check = list(range(10001))
for x in check:
a = sum_fact(x)
if x == sum_fact(a):
nums.append(a)
nums.append(x)
check.remove(a)
print(sum(nums))<|fim_prefix|># repo: jackmitcheltree/Project_Euler_J... | code_fim | easy | {
"lang": "python",
"repo": "jackmitcheltree/Project_Euler_JM",
"path": "/problem_21.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jackmitcheltree/Project_Euler_JM path: /problem_21.py
#If the sum of all factors of a = b and if the sum of all factors of b = a
# then a and b are amicable numbers.
#Find the sum of all amicable numbers under 10000.
def sum_fact(n):
<|fim_suffix|>nums = []
check = list(range(10001))... | code_fim | easy | {
"lang": "python",
"repo": "jackmitcheltree/Project_Euler_JM",
"path": "/problem_21.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fierytermite/tram-1 path: /service/data_svc.py
import re
import json
import logging
from taxii2client import Collection
from stix2 import TAXIICollectionSource, Filter
def defang_text(text):
"""
Function to normalize quoted data to be sql compliant
:param text: Text to be defang'd
... | code_fim | hard | {
"lang": "python",
"repo": "fierytermite/tram-1",
"path": "/service/data_svc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def insert_attack_json_data(self, buildfile):
"""
Function to read in the enterprise attack json file and insert data into the database
:param buildfile: Enterprise attack json file to build from
:return: nil
"""
cur_items = [x['uid'] for x in awai... | code_fim | hard | {
"lang": "python",
"repo": "fierytermite/tram-1",
"path": "/service/data_svc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> words = [Parser.SENTENCE_START_SYMBOL] * (depth - 1) + list_of_words + [Parser.SENTENCE_END_SYMBOL] * (depth - 1)
for n in range(0, len(words) - depth + 1):
self.db.add_word(words[n:n+depth])
self.db.commit()
i += 1
if i % 1000 == 0:
print i
sys.stdout.flush()<|fim_prefix|>... | code_fim | hard | {
"lang": "python",
"repo": "UCI-TPL/geo-poetry-server",
"path": "/markov_text/parse.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> depth = self.db.get_depth()
i = 0
for sentence in sentences:
list_of_words = self.word_regex.findall(sentence)
words = [Parser.SENTENCE_START_SYMBOL] * (depth - 1) + list_of_words + [Parser.SENTENCE_END_SYMBOL] * (depth - 1)
for n in range(0, len(words) - depth + 1):
self.db.add_w... | code_fim | medium | {
"lang": "python",
"repo": "UCI-TPL/geo-poetry-server",
"path": "/markov_text/parse.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UCI-TPL/geo-poetry-server path: /markov_text/parse.py
import sys
import re
class Parser:
SENTENCE_START_SYMBOL = '^'
SENTENCE_END_SYMBOL = '$'
def __init__(self, name, db, sentence_split_char = '\n'):
<|fim_suffix|> for n in range(0, len(words) - depth + 1):
self.db.add_word(words[n:n+... | code_fim | hard | {
"lang": "python",
"repo": "UCI-TPL/geo-poetry-server",
"path": "/markov_text/parse.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def outputCSV(name, data):
name = unicode(name, 'utf-8')
filename = name + '.tsv'
fopen = open(rootdir + '/' + filename, 'a')
for key, value in data.items():
temp = key.encode('utf-8')
temp = temp[5:-7]
if os.path.exists(rootdir + '/' + temp + '.jpg'):
... | code_fim | hard | {
"lang": "python",
"repo": "lljbash/glamorous",
"path": "/script/StyleProcess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return attrDict
def outputCSV(name, data):
name = unicode(name, 'utf-8')
filename = name + '.tsv'
fopen = open(rootdir + '/' + filename, 'a')
for key, value in data.items():
temp = key.encode('utf-8')
temp = temp[5:-7]
if os.path.exists(rootdir + '/'... | code_fim | hard | {
"lang": "python",
"repo": "lljbash/glamorous",
"path": "/script/StyleProcess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lljbash/glamorous path: /script/StyleProcess.py
# encoding=utf-8
import os
import os.path
genres = ['abstract', 'pointillism', 'post_impressionism', 'impressionism', 'suprematism', 'shuimo']
attrs = ['cp', 'fg', 'shape']
rootdir = 'data'
def deepSearch(filename):
filename = fil... | code_fim | hard | {
"lang": "python",
"repo": "lljbash/glamorous",
"path": "/script/StyleProcess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> docs=[self.encode_doc_with_id(doc) for doc in self.docs]
return docs
def __getitem__(self, index):
return self.vocabulary[index]
def get_vocab_size(self):
return len(self.vocabulary)
# end of Vocabulary class<|fim_prefix|># repo: WING-NUS/WING-LDA path: /wang-ka... | code_fim | hard | {
"lang": "python",
"repo": "WING-NUS/WING-LDA",
"path": "/wang-kan/vocabulary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def word_to_id(self, word):
if word not in self.word_id_dict:
word_id = len(self.vocabulary)
self.word_id_dict[word] = word_id
self.vocabulary.append(word)
else:
word_id = self.word_id_dict[word]
return word_id
# end of wor... | code_fim | medium | {
"lang": "python",
"repo": "WING-NUS/WING-LDA",
"path": "/wang-kan/vocabulary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WING-NUS/WING-LDA path: /wang-kan/vocabulary.py
#!/usr/bin/python
'''
Created on 10 Oct, 2013
@author: Aobo Wang
'''
class Vocabulary:
'''
Attrbutes:
docsList: A list of docs where each item is a list of words from a doc
wordList: The full list of unique words. The indexs of words ar... | code_fim | hard | {
"lang": "python",
"repo": "WING-NUS/WING-LDA",
"path": "/wang-kan/vocabulary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param ticker: Return results that contain this ticker.
:param published_utc: Return results published on, before, or after this date.
:param limit: Limit the number of results returned per-page, default is 10 and max is 1000.
:param sort: Sort field used for ordering.
... | code_fim | hard | {
"lang": "python",
"repo": "polygon-io/client-python",
"path": "/polygon/rest/reference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polygon-io/client-python path: /polygon/rest/reference.py
ed on the queried date. Default is true.
:param limit: Limit the size of the response per-page, default is 100 and max is 1000.
:param sort: The field to sort the results on. Default is ticker. If the search query parameter... | code_fim | hard | {
"lang": "python",
"repo": "polygon-io/client-python",
"path": "/polygon/rest/reference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polygon-io/client-python path: /polygon/rest/reference.py
that we support via our Ticker Types API. Defaults to empty string which queries all types.
:param market: Filter by market type. By default all markets are included.
:param exchange: Specify the assets primary exchange Ma... | code_fim | hard | {
"lang": "python",
"repo": "polygon-io/client-python",
"path": "/polygon/rest/reference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_log_healthnmon_audit_formatter(self):
formatter = HealthnmonAuditFormatter()
try:
raise Exception('This is exceptional')
except Exception as ex:
exc_info = sys.exc_info()
logrecord = logging.LogRecord(
'healthnmon', ... | code_fim | hard | {
"lang": "python",
"repo": "jessegonzalez/healthnmon",
"path": "/healthnmon/tests/test_log.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_loglevel_logConf_None(self):
self.flags(healthnmon_log_config="")
log.setup()
self.assert_(True) # do not raise exception
def test_loglevel_manage_logConf_None(self):
self.flags(healthnmon_manage_log_config="")
log.healthnmon_manage_setup()
... | code_fim | hard | {
"lang": "python",
"repo": "jessegonzalez/healthnmon",
"path": "/healthnmon/tests/test_log.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jessegonzalez/healthnmon path: /healthnmon/tests/test_log.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance wi... | code_fim | hard | {
"lang": "python",
"repo": "jessegonzalez/healthnmon",
"path": "/healthnmon/tests/test_log.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for t in spike_times_V2:
plt.plot([t-times[1], t-times[1]], [Vth, Vth+0.5], alpha=0.75, color=c[1])
'''
plt.xlabel('Time ($10^{-2}$ seconds)', size=12)
#plt.xticks([k for k in range(11)])
plt.ylabel('Voltage $V_k, k \in \{1,2\}$', size=12)
plt.legend(loc='upper right', bbox_to_anchor=(1, 0.95))
#plt... | code_fim | medium | {
"lang": "python",
"repo": "helene-todd/M2_thesis_code",
"path": "/with_noise/correlations/xpp_to_py.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: helene-todd/M2_thesis_code path: /with_noise/correlations/xpp_to_py.py
from matplotlib import cm, rcParams
import matplotlib.pyplot as plt
import numpy as np
import math as math
import random as rand
import os
import csv
rcParams.update({'figure.autolayout': True})
plt.figure(figsize=(20,4))
c ... | code_fim | hard | {
"lang": "python",
"repo": "helene-todd/M2_thesis_code",
"path": "/with_noise/correlations/xpp_to_py.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open('gamma=0.1_many.dat', newline='') as file:
datareader = csv.reader(file, delimiter=' ')
for row in datareader:
if float(row[0]) >= 200 and float(row[0]) <= 300 :
times.append(float(row[0]))
V1.append(float(row[1]))
V2.append(float(row[2]))
pl... | code_fim | medium | {
"lang": "python",
"repo": "helene-todd/M2_thesis_code",
"path": "/with_noise/correlations/xpp_to_py.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jimwaldo/HarvardX-Tools path: /src/main/python/classData/personClickUtils.py
#!/usr/bin/env python
"""'
Handy derived data and analysis functions for working with person-click
datasets in Pandas. Most of these functions get passed a person-click
DataFrame.
This product includes GeoLite data ... | code_fim | hard | {
"lang": "python",
"repo": "jimwaldo/HarvardX-Tools",
"path": "/src/main/python/classData/personClickUtils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # When users aren't logged in, logged events don't have usernames.
# When we don't have usernames, it's harder to do person-level
# analyses.
n_anonymous = len(df[df.actor.isnull()])
n_total = len(df)
return float(n_anonymous) / n_total if pct else n_anonymous
def getAxisLookupFai... | code_fim | hard | {
"lang": "python",
"repo": "jimwaldo/HarvardX-Tools",
"path": "/src/main/python/classData/personClickUtils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wancy86/tornado-seed path: /secu/models/todo_work.py
import uuid
from datetime import datetime
from sqlalchemy import DateTime, String, Integer, Boolean
from .__basemodel__ import Model, Column
import common.form as form
class Work(Model):
'''工作日志表'''
__tablename__ = 'todo_wor... | code_fim | hard | {
"lang": "python",
"repo": "wancy86/tornado-seed",
"path": "/secu/models/todo_work.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class PutForm(form.Form):
desp = form.String(name="工作内容", maxlength=1000, message="不符合规则(0-1000位)!")
duration = form.Integer(name="消耗时间", maxvalue=480, message="不符合规则(0-480)!")<|fim_prefix|># repo: wancy86/tornado-seed path: /secu/models/todo_work.py
import uuid
from datetime impor... | code_fim | hard | {
"lang": "python",
"repo": "wancy86/tornado-seed",
"path": "/secu/models/todo_work.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sudhakaran7/Virtual-piano path: /Virtual_Piano.py
import cv2
import numpy as np
import time
import pygame
pygame.init()
w,h = 78,110
x1,y1= 10,10
x2,y2 = 10+w,10
x3,y3 = 10+2*w,10
x4,y4 = 10+3*w,10
x5,y5 = 10+4*w,10
x6,y6 = 10+5*w,10
x7,y7 = 10+6*w,10
x8,y8 =10+7*w,10
def draw_piano(frame):
c... | code_fim | hard | {
"lang": "python",
"repo": "Sudhakaran7/Virtual-piano",
"path": "/Virtual_Piano.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>and x+w1<(x5 + w) and y+h1<(y5+h):
cv2.rectangle(frame, (x5, y5), (x5 + w, y5 + h), (211,211,211), -1)
pygame.mixer.Sound('wav/d1.wav').play()
time.sleep(0.10)
pygame.mixer.Sound('wav/d1.wav').stop()
elif x>x6 and y>y6 and x+w1<(x6 + w) and y+h1<(y6+h):
cv2.rect... | code_fim | hard | {
"lang": "python",
"repo": "Sudhakaran7/Virtual-piano",
"path": "/Virtual_Piano.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_count_curve(count, level=1, scope=500, func=math.sin):
res = func(count % scope / math.pi)
return pow(res, level) if level != 1 else res
if __name__ == "__main__":
from dialog import draw_dialog_alpha
from ui_canvas import ui, print_mem_free
import time
last =... | code_fim | medium | {
"lang": "python",
"repo": "vamoosebbf/MaixUI",
"path": "/lib/creater.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vamoosebbf/MaixUI path: /lib/creater.py
# This file is part of MaixUI
# Copyright (c) sipeed.com
#
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
#
import time, math
<|fim_suffix|> res = func(time.ticks_ms() / scope / math.pi)
return pow(res, leve... | code_fim | medium | {
"lang": "python",
"repo": "vamoosebbf/MaixUI",
"path": "/lib/creater.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> height = 50 + (int(get_time_curve(3, 250) * 40))
pos = draw_dialog_alpha(ui.canvas, 20, height, 200, 20, 10, color=(255, 0, 0), alpha=150)
ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, "time_curve(3, 250)", scale=2, color=(0,0,0))
height = 100 + (int(get_time_curve(2, 50... | code_fim | medium | {
"lang": "python",
"repo": "vamoosebbf/MaixUI",
"path": "/lib/creater.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> verbose_name='ID')),
('title', models.CharField(max_length=255)),
('description', models.TextField()),
('date', models.CharField(blank=True, max_length=255, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
... | code_fim | hard | {
"lang": "python",
"repo": "TukaTukaru/TukaTuka-by-Django",
"path": "/TukaTuka/app/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TukaTukaru/TukaTuka-by-Django path: /TukaTuka/app/migrations/0001_initial.py
# Generated by Django 2.0.4 on 2018-05-03 15:33
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import phonenumber_field.modelfields
class Migration(migration... | code_fim | hard | {
"lang": "python",
"repo": "TukaTukaru/TukaTuka-by-Django",
"path": "/TukaTuka/app/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, max_length=200)),
('email', models.EmailField(blank=True, db_index=True, max_length=254, null=True, unique=True)),
('site', models.URLField(blank=True, null=True)),
('ad', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE... | code_fim | hard | {
"lang": "python",
"repo": "TukaTukaru/TukaTuka-by-Django",
"path": "/TukaTuka/app/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>i)
print(inputs[i])
counter = 1
for j in inputs[i]:
if counter % 2 == 0:
evenList += j
else:
oddList += j
counter += 1
print(evenList, oddList)
oddList, evenList = "", ""<|fim_prefix|># repo: li... | code_fim | medium | {
"lang": "python",
"repo": "linkeshkanna/ProblemSolving",
"path": "/HackerRank.30.Days/splitStringOddEven.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linkeshkanna/ProblemSolving path: /HackerRank.30.Days/splitStringOddEven.py
# HackerRank
# https://www.hackerrank.com/challenges/30-review-loop/problem
if __name__ == '__main__':
n = int(input())
inputs = []<|fim_suffix|>i)
print(inputs[i])
counter = 1
for j in in... | code_fim | medium | {
"lang": "python",
"repo": "linkeshkanna/ProblemSolving",
"path": "/HackerRank.30.Days/splitStringOddEven.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
oddList += j
counter += 1
print(evenList, oddList)
oddList, evenList = "", ""<|fim_prefix|># repo: linkeshkanna/ProblemSolving path: /HackerRank.30.Days/splitStringOddEven.py
# HackerRank
# https://www.hackerrank.com/challenges/30-review-loo... | code_fim | hard | {
"lang": "python",
"repo": "linkeshkanna/ProblemSolving",
"path": "/HackerRank.30.Days/splitStringOddEven.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pfeerick/extra-scripts path: /save_hex_elf.py
# Written by dsb
# Origin: https://community.platformio.org/t/how-to-build-without-uploading-specific-source-files-using-src-filter/8972/3
Import("env", "projenv")
from shutil import copyfile
def save_hex(*args, **kwargs):
print("Copying hex out... | code_fim | medium | {
"lang": "python",
"repo": "pfeerick/extra-scripts",
"path": "/save_hex_elf.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def save_hex(*args, **kwargs):
print("Copying hex output to project directory...")
target = str(kwargs['target'][0])
copyfile(target, 'output.hex')
print("Done.")
def save_elf(*args, **kwargs):
print("Copying elf output to project directory...")
target = str(kwargs['target'][0])
... | code_fim | medium | {
"lang": "python",
"repo": "pfeerick/extra-scripts",
"path": "/save_hex_elf.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wate123/FakeNewsDetection path: /classfiers.py
'learning_rate': 0.1, 'n_estimators': 90, 'random_state': 1})
return clf, "Ada Boost", combine_parameters
else:
print("Start AdaBoost hyperperameter tuning")
print("Start " + str(datetime.datetime.fromtimestamp(time.ti... | code_fim | hard | {
"lang": "python",
"repo": "wate123/FakeNewsDetection",
"path": "/classfiers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cv == 1:
# tricks to do without cross validation
clf = GCV(SVC(), parameters, cv=ShuffleSplit(test_size=0.20, n_splits=1), n_jobs=40)
else:
clf = GCV(SVC(), parameters, cv=cv, n_jobs=40)
return clf, "SVM", parameters
def random_forest(gcv, defau... | code_fim | hard | {
"lang": "python",
"repo": "wate123/FakeNewsDetection",
"path": "/classfiers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wate123/FakeNewsDetection path: /classfiers.py
action_leaf=0.0, presort=False, random_state=seed)
elif dataset == 'politifact':
# {'class_weight': 'balanced', 'criterion': 'gini', 'max_depth': None, 'max_features': None,
# 'max_leaf_nodes': None, 'min_impurity_dec... | code_fim | hard | {
"lang": "python",
"repo": "wate123/FakeNewsDetection",
"path": "/classfiers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""
Plugin interface class
"""
class BasePlugin:
def __init__(self):
self.vendor = "Acme corp."
self.model = "Unknown"
return
# Deep detection. Fill class fields with device-specific info
# Return false in case of mis-detection by basic detection method
def Detect(self, dctl, force=... | code_fim | hard | {
"lang": "python",
"repo": "Retro-Junk/chipinfo",
"path": "/chipinfo/controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Retro-Junk/chipinfo path: /chipinfo/controller.py
"""
# The MIT License (MIT)
#
# Copyright (c) 2019 VL
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without... | code_fim | hard | {
"lang": "python",
"repo": "Retro-Junk/chipinfo",
"path": "/chipinfo/controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SKZhao97/NYC_Taxi_Price_Prediction_model_and_web path: /team25final/CODE/3.regression model/train.py
import pandas as pd
import lightgbm as lgb
from sklearn.metrics import mean_squared_error
import utils as utils
# data = pd.read_csv('./data.csv')
# # Y_data = pd.read_csv('./taxi_01.csv', usec... | code_fim | hard | {
"lang": "python",
"repo": "SKZhao97/NYC_Taxi_Price_Prediction_model_and_web",
"path": "/team25final/CODE/3.regression model/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('Saving model...')
# save model to file
gbm.save_model('model.txt')
# print(X_train)
print('Starting predicting...')
# predict
Y_pred = gbm.predict(X_test, num_iteration=gbm.best_iteration)
# eval
print('The rmse of prediction is:', mean_squared_error(Y_test, Y_pred) ** 0.5)
mean_percentage_error =... | code_fim | hard | {
"lang": "python",
"repo": "SKZhao97/NYC_Taxi_Price_Prediction_model_and_web",
"path": "/team25final/CODE/3.regression model/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('Unspecified')
for key in sorted(alldistances):
print('Minimal distance from ', a.name, ' to ', key, ' is ', alldistances[key])
print('\n\nSpecified')
print('Minimal distance from ', a.name, ' to ', e.name, ' is ', a.find_minimal_distance_to(e))<|fim_prefix|># repo: herrjemand/dijkstras-algorit... | code_fim | medium | {
"lang": "python",
"repo": "herrjemand/dijkstras-algorithm-py",
"path": "/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: herrjemand/dijkstras-algorithm-py path: /example.py
from vertex import Vertex
a = Vertex('a')
b = Vertex('b')
c = Vertex('c')
d = Vertex('d')
e = Vertex('e')
f = Vertex('f')
<|fim_suffix|>alldistances = a.find_all_minimal_distances()
print('Unspecified')
for key in sorted(alldistances):
pr... | code_fim | hard | {
"lang": "python",
"repo": "herrjemand/dijkstras-algorithm-py",
"path": "/example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jorgeclone/goscalecms path: /goscale/plugins/forms/cms_plugins.py
from goscale.cms_plugins import GoscaleCMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
import models
<|fim_suffix|> """
Feed plu... | code_fim | hard | {
"lang": "python",
"repo": "jorgeclone/goscalecms",
"path": "/goscale/plugins/forms/cms_plugins.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Feed plugin for GoScale
"""
model = models.Form
name = _("Google Form")
plugin_templates = GOSCALE_FORMS_PLUGIN_TEMPLATES
render_template = GOSCALE_FORMS_PLUGIN_TEMPLATES[0][0]
fieldsets = [
[_('Form options'), {
'fields': ['url', 'form_class']
... | code_fim | medium | {
"lang": "python",
"repo": "jorgeclone/goscalecms",
"path": "/goscale/plugins/forms/cms_plugins.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: regg00/docker-xmedius-adsync path: /app/adsync.py
#!/usr/bin/python
#////////////////////////////////////////////////////////////////////////////
# Copyright (c) 2012 Sagemcom Canada Permission to use this work
# for any purpose must be obtained in writing from Sagemcom Canada
# 5252 de Maisonne... | code_fim | hard | {
"lang": "python",
"repo": "regg00/docker-xmedius-adsync",
"path": "/app/adsync.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> retry_list = self._database_handler.get_retry_entries()
if retry_list:
logger.info('Retry procedure begins on %s entry(ies)' % len(retry_list))
not_deleted_entries = {}
deleted_entries = {}
for entry in retry_list:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "regg00/docker-xmedius-adsync",
"path": "/app/adsync.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._load_config(command_args)
self._load_modules()
#In : None
#Out : None
def _load_modules(self):
self._ldap_handler = LDAPWrapper(self._config['active_directory'], page_size)
self._database_handler = DatabaseWrapper()
self._user_repository = UserRep... | code_fim | hard | {
"lang": "python",
"repo": "regg00/docker-xmedius-adsync",
"path": "/app/adsync.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for user in data1["usuarios"]:
usuario = User()
usuario.id = user["id"]
usuario.username=user["nome"]
usuario.email = user["email"]
usuario.first_name = user["nomeCompleto"].split(" ", 1)[0]
usuario.date_joined = user["dataCadastro"]
if user["grupo"] == 1:
usuario.is_st... | code_fim | medium | {
"lang": "python",
"repo": "gstvob/SignBank-Brasil",
"path": "/signbank/dictionary/user_parser.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>for sinal in data2["dictionary_gloss"]:
if sinal["inWeb"] != "4":
try :
usuario = User.objects.get(pk=sinal["nomePostador"])
gloss = Gloss.objects.get(pk=sinal["id"])
except ObjectDoesNotExist:
continue
else:
gloss.creator.add(usu... | code_fim | hard | {
"lang": "python",
"repo": "gstvob/SignBank-Brasil",
"path": "/signbank/dictionary/user_parser.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gstvob/SignBank-Brasil path: /signbank/dictionary/user_parser.py
from django.db import *
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import User
from signbank.dictionary.models import *
from signbank.video.models import *
import os
import shutil
import js... | code_fim | medium | {
"lang": "python",
"repo": "gstvob/SignBank-Brasil",
"path": "/signbank/dictionary/user_parser.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Arg check
_x_sanity(lo, hi)
_range_sanity(p_range, a_range)
if dp <= 0:
raise ValueError('Width of lo frequency range must be positive')
if da <= 0:
raise ValueError('Width of hi frequency range must be positive')
# method check
method2fun = {'plv': plv, 'mi_... | code_fim | hard | {
"lang": "python",
"repo": "parenthetical-e/pacpy",
"path": "/pacpy/pac.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: parenthetical-e/pacpy path: /pacpy/pac.py
s is identical to that of the filtered signal
with a longer filter.
"""
if len(lo) == len(hi):
return lo, hi # Die early if there's nothing to do.
elif len(lo) < len(hi):
Ndiff = len(hi) - len(lo)
if Ndiff % 2... | code_fim | hard | {
"lang": "python",
"repo": "parenthetical-e/pacpy",
"path": "/pacpy/pac.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: parenthetical-e/pacpy path: /pacpy/pac.py
ency time-series to use as the phase component
hi : array-like, 1d
The high frequency time-series to use as the amplitude component
f_lo : (low, high), Hz
The low frequency filtering range
f_hi : (low, high), Hz
The low... | code_fim | hard | {
"lang": "python",
"repo": "parenthetical-e/pacpy",
"path": "/pacpy/pac.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #
# Writting file.
#
try:
with open(output_path, 'wb') as f:
writter = csv.writer(f, delimiter=',', quotechar='"')
i = 0
for row in data:
if i == 0:
writter.writerow([ k for k in row.keys() ])
writter.writerow([ k for k in row.values() ])
... | code_fim | hard | {
"lang": "python",
"repo": "luiscape/unosat-product-scraper-analysis",
"path": "/scripts/unosat_analysis/export.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #
# Read json file.
#
try:
with open(json_path) as data_file:
data = json.load(data_file)
except Exception as e:
print '%s Could not ope JSON file.' % item('prompt_error')
print e
return False
#
# Writting file.
#
try:
with open(output_path, 'wb') as f:... | code_fim | hard | {
"lang": "python",
"repo": "luiscape/unosat-product-scraper-analysis",
"path": "/scripts/unosat_analysis/export.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luiscape/unosat-product-scraper-analysis path: /scripts/unosat_analysis/export.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import csv
import json
import requests
dir = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
sys.path.append(dir)
from utilities.promp... | code_fim | hard | {
"lang": "python",
"repo": "luiscape/unosat-product-scraper-analysis",
"path": "/scripts/unosat_analysis/export.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bodyUids = p.createMultiBody(baseMass=0,
baseInertialFramePosition=[0, 0, 0],
baseCollisionShapeIndex=collisionShapeId,
baseVisualShapeIndex=visualShapeId,
basePosition=[0, 0, 2],
... | code_fim | hard | {
"lang": "python",
"repo": "WolfireGames/overgrowth",
"path": "/Projects/bullet3-2.89/examples/pybullet/examples/createMultiBodyBatch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WolfireGames/overgrowth path: /Projects/bullet3-2.89/examples/pybullet/examples/createMultiBodyBatch.py
import pybullet as p
import time
import math
cid = p.connect(p.SHARED_MEMORY)
if (cid < 0):
p.connect(p.GUI, options="--minGraphicsUpdateTimeMs=16000")
p.setPhysicsEngineParameter(numSolver... | code_fim | hard | {
"lang": "python",
"repo": "WolfireGames/overgrowth",
"path": "/Projects/bullet3-2.89/examples/pybullet/examples/createMultiBodyBatch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for x in range(32):
for y in range(32):
for z in range(10):
batchPositions.append(
[x * meshScale[0] * 5.5, y * meshScale[1] * 5.5, (0.5 + z) * meshScale[2] * 2.5])
bodyUids = p.createMultiBody(baseMass=0,
baseInertialFramePosition=[0, 0, 0],
... | code_fim | hard | {
"lang": "python",
"repo": "WolfireGames/overgrowth",
"path": "/Projects/bullet3-2.89/examples/pybullet/examples/createMultiBodyBatch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def translate_boxes_to_open3d_instance(gt_boxes):
"""
4-------- 6
/| /|
5 -------- 3 .
| | | |
. 7 -------- 1
|/ |/
2 -------- 0
"""
center = gt_boxes[0:3]
lwh = gt_boxes[3:6]
axis_angles =... | code_fim | hard | {
"lang": "python",
"repo": "OrangeSodahub/CRLFnet",
"path": "/src/site_model/src/LidCamFusion/OpenPCDet/tools/visual_utils/open3d_vis_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ref_boxes is not None:
vis = draw_box(vis, ref_boxes, (0, 1, 0), ref_labels, ref_scores)
vis.run()
vis.destroy_window()
def translate_boxes_to_open3d_instance(gt_boxes):
"""
4-------- 6
/| /|
5 -------- 3 .
| | | |
... | code_fim | hard | {
"lang": "python",
"repo": "OrangeSodahub/CRLFnet",
"path": "/src/site_model/src/LidCamFusion/OpenPCDet/tools/visual_utils/open3d_vis_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OrangeSodahub/CRLFnet path: /src/site_model/src/LidCamFusion/OpenPCDet/tools/visual_utils/open3d_vis_utils.py
"""
Open3d visualization tool box
Written by Jihan YANG
All rights preserved from 2021 - present.
"""
import open3d
import torch
import matplotlib
import numpy as np
box_colormap = [
... | code_fim | hard | {
"lang": "python",
"repo": "OrangeSodahub/CRLFnet",
"path": "/src/site_model/src/LidCamFusion/OpenPCDet/tools/visual_utils/open3d_vis_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def nsFound():
print("\nNo such department found here! ")
print("we only have 4 Depts. in FCP\n 1. Soft. Engineering\n 2. Cyber Security\n 3. Computer Science\n 4. Information Technology")
if __name__ == "__main__":
main()<|fim_prefix|># repo: salisu14/learn-python-programming path: /fcp.py... | code_fim | hard | {
"lang": "python",
"repo": "salisu14/learn-python-programming",
"path": "/fcp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: salisu14/learn-python-programming path: /fcp.py
#!/usr/bin/env python3
def display(name):
print("Congratulations", str.title(name), "you can now get addmission in FCP")
course = input("which course do u apply for? ")
<|fim_suffix|> if score < 180:
print("Sorry", name, "unfort... | code_fim | hard | {
"lang": "python",
"repo": "salisu14/learn-python-programming",
"path": "/fcp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RichardSZ/OMOOC2py path: /_src/om2py1w/1wex1/main.py
prompt=">"
filename=raw_input(prompt)
Mydairy=open(filename)
print("Historic dairy:" )
print Mydairy.read()
print "\n"
print"Dairy now..."
strq = "q"
strh = "h"
typein = raw_input(">>>")
while typein <> strq:
i<|fim_suffix... | code_fim | medium | {
"lang": "python",
"repo": "RichardSZ/OMOOC2py",
"path": "/_src/om2py1w/1wex1/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print("h for help")
print("q for abort")
typein = raw_input(">>>")
print "goodbye! and goodbye"<|fim_prefix|># repo: RichardSZ/OMOOC2py path: /_src/om2py1w/1wex1/main.py
prompt=">"
filename=raw_input(prompt)
Mydairy=open(filename)
print("Historic dairy:" )
print Mydairy.read(... | code_fim | hard | {
"lang": "python",
"repo": "RichardSZ/OMOOC2py",
"path": "/_src/om2py1w/1wex1/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shubham-Kr-Shaw/Hands_on_ML path: /preprocess.py
def cleanpy(cols,changetype,encodecol,scaling,scalingcol,targetcol,dftest,cleandatapath,rawdatapath):
import pandas as pd
import numpy as np
from sklearn import preprocessing
import os
cols=cols
changetype=changetype
en... | code_fim | hard | {
"lang": "python",
"repo": "Shubham-Kr-Shaw/Hands_on_ML",
"path": "/preprocess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #test data creation
if dftest=="":
msk=np.random.rand(len(df))<0.75
dftrain=df[msk]
dftest=df[~msk]
else:
dftrain=df
#target variable seperation
ytrain=pd.DataFrame(dftrain[targetcol])
ytest=pd.DataFrame(dftest[targetcol])
dftrain.drop(targetco... | code_fim | hard | {
"lang": "python",
"repo": "Shubham-Kr-Shaw/Hands_on_ML",
"path": "/preprocess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: erikriver/calculator path: /backend/tests.py
import pytest
from click.testing import CliRunner
from app import calculator, cli
def test_add():
assert calculator("2+2.0") == 4.0
assert calculator(".2 + 2.0") == 2.2
def test_subtract():
assert calculator(" 2-2") == 0
assert roun... | code_fim | hard | {
"lang": "python",
"repo": "erikriver/calculator",
"path": "/backend/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {"number1": "3.1415926", "number2": "0", "operator": "/"}
test_client = app.test_client()
response = test_client.post("/api", json=data)
expected_json = {"msg": "E: Zero Division"}
assert response.status_code == 200
assert response.get_json() == expected_json<|fim_prefix|># ... | code_fim | hard | {
"lang": "python",
"repo": "erikriver/calculator",
"path": "/backend/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: metmit/easyMitmproxy path: /loader.py
from addons.aweme.filter import Filter as AwemeFilter
from addons.gifmaker.filter import Filter as GifMakerFilter
fro<|fim_suffix|> AwemeFilter(),
GifMakerFilter(),
RedFilter(),
]<|fim_middle|>m addons.red.filter import Filter as RedFilter
addons ... | code_fim | easy | {
"lang": "python",
"repo": "metmit/easyMitmproxy",
"path": "/loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: metmit/easyMitmproxy path: /loader.py
from addons.aweme.filter import Filter as AwemeFilter
from<|fim_suffix|>m addons.red.filter import Filter as RedFilter
addons = [
AwemeFilter(),
GifMakerFilter(),
RedFilter(),
]<|fim_middle|> addons.gifmaker.filter import Filter as GifMakerFilter... | code_fim | easy | {
"lang": "python",
"repo": "metmit/easyMitmproxy",
"path": "/loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> AwemeFilter(),
GifMakerFilter(),
RedFilter(),
]<|fim_prefix|># repo: metmit/easyMitmproxy path: /loader.py
from addons.aweme.filter import Filter as AwemeFilter
from addons.gifmaker.filter import Filter as GifMakerFilter
fro<|fim_middle|>m addons.red.filter import Filter as RedFilter
addons ... | code_fim | easy | {
"lang": "python",
"repo": "metmit/easyMitmproxy",
"path": "/loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QPC-database/CoCosNet-v2 path: /models/pix2pix_model.py
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
import torch.nn.functional as F
import models.networks as networks
import util.util as util
import itertools
try:
from torch.cuda.amp import autocast
... | code_fim | hard | {
"lang": "python",
"repo": "QPC-database/CoCosNet-v2",
"path": "/models/pix2pix_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def preprocess_input(self, data):
if self.use_gpu():
for k in data.keys():
try:
data[k] = data[k].cuda()
except:
continue
label = data['label'][:,:3,:,:].float()
label_ref = data['label_ref'][:,... | code_fim | hard | {
"lang": "python",
"repo": "QPC-database/CoCosNet-v2",
"path": "/models/pix2pix_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generate_fake(self, input_semantics, real_image, ref_semantics=None, ref_image=None, self_ref=None):
generate_out = {}
generate_out['ref_features'] = self.vggnet_fix(ref_image, ['r12', 'r22', 'r32', 'r42', 'r52'], preprocess=True)
generate_out['real_features'] = self.vggnet... | code_fim | hard | {
"lang": "python",
"repo": "QPC-database/CoCosNet-v2",
"path": "/models/pix2pix_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Episode : ", e, " Delta: ", deltaMax, " isConverged: ", isConverged, " isPolicyStable: ", isPolicyStable)
env.printEnv(agent)
if(isPolicyStable):
print("Stable policy achieved!")
break<|fim_prefix|># repo: cemkaraoguz/reinforcement-learning-an-introduction-seco... | code_fim | hard | {
"lang": "python",
"repo": "cemkaraoguz/reinforcement-learning-an-introduction-second-edition",
"path": "/chapter04/04_JCR_PI.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cemkaraoguz/reinforcement-learning-an-introduction-second-edition path: /chapter04/04_JCR_PI.py
'''
04_JCR_PI.py : replication of Figure 4.2
Cem Karaoguz, 2020
MIT License
'''
import numpy as np
import pylab as pl
from IRL.environments.ResourceAllocationTasks import JacksCarRental
from IRL.age... | code_fim | hard | {
"lang": "python",
"repo": "cemkaraoguz/reinforcement-learning-an-introduction-second-edition",
"path": "/chapter04/04_JCR_PI.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='student',
name='birthday',
field=models.DateField(blank=True, db_index=True, null=True),
),
]<|fim_prefix|># repo: da-semenov/loft_test path: /api_students/api/migrations/0004_alter_student_birth... | code_fim | medium | {
"lang": "python",
"repo": "da-semenov/loft_test",
"path": "/api_students/api/migrations/0004_alter_student_birthday.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: da-semenov/loft_test path: /api_students/api/migrations/0004_alter_student_birthday.py
# Generated by Django 3.2 on 2021-04-24 16:24
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AlterField(
model... | code_fim | medium | {
"lang": "python",
"repo": "da-semenov/loft_test",
"path": "/api_students/api/migrations/0004_alter_student_birthday.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rechardchen123/Classification-and-regression-of-vessel-AIS-data path: /train/compute_metrics.py
ference_path))
if not os.path.exists(inference_path):
subprocess.check_call(
['gsutil', 'cp', args.inference_path, inference_path])
else:
inference_path ... | code_fim | hard | {
"lang": "python",
"repo": "rechardchen123/Classification-and-regression-of-vessel-AIS-data",
"path": "/train/compute_metrics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> agreement = np.concatenate(agreement, axis=0)
counts = np.concatenate(counts, axis=0)
human_agreement = np.concatenate(human_agreement)
human_pairs = np.concatenate(human_pairs)
logging.info('Model agreement with humans over predicted ranges: %s',
agreement.sum() / cou... | code_fim | hard | {
"lang": "python",
"repo": "rechardchen123/Classification-and-regression-of-vessel-AIS-data",
"path": "/train/compute_metrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rechardchen123/Classification-and-regression-of-vessel-AIS-data path: /train/compute_metrics.py
line('h3', 'Overall RMS Error')
text('{:.2f}'.format(
RMS(consolidated.true_attrs[true_mask & infer_mask],
consolidated.inferred_attrs[true_mask & infer_mas... | code_fim | hard | {
"lang": "python",
"repo": "rechardchen123/Classification-and-regression-of-vessel-AIS-data",
"path": "/train/compute_metrics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ueue)))
tasks.append(asyncio.create_task(consumer(portsQueue, print, 2)))
await asyncio.gather(*tasks)
asyncio.run(main())<|fim_prefix|># repo: pombredanne/mist path: /examples/demo/python/scenario-01.py
import sys, asyncio
from catalog import searchDomains, findOpenPorts
from aux import consume... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/mist",
"path": "/examples/demo/python/scenario-01.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/mist path: /examples/demo/python/scenario-01.py
import sys, asyncio
from catalog import searchDomains, findOpenPorts
from aux import consumer, producer
async def main():
tasks = []
foundDomains = asyncio.Queue()
portsQueue = asyncio.Queue()
tasks.append(asyncio.create... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/mist",
"path": "/examples/demo/python/scenario-01.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for k, v in sorted(d.items(), key=lambda x: x[0]):
if isinstance(v, dict):
recursive_walk(v, depth+1, parent + [k])
else:
path = "/".join(parent + [k])
if os.path.exists(path):
paths.append(path)
def main():
with open('_repos.yml', 'r') as f:
repos = yaml.load(f)... | code_fim | hard | {
"lang": "python",
"repo": "lvtao-sec/batch-git-clone",
"path": "/pull.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lvtao-sec/batch-git-clone path: /pull.py
from common import *
from joblib import Parallel, delayed
import yaml, os
def success(path, out):
out = [filter_output(l) for l in out]
out.append("Done fetching {}".format(path))
return '\n'.join(out)
def failure(path):
print(colored("Failed to ... | code_fim | medium | {
"lang": "python",
"repo": "lvtao-sec/batch-git-clone",
"path": "/pull.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>def recursive_walk(d, depth=0, parent=[]):
for k, v in sorted(d.items(), key=lambda x: x[0]):
if isinstance(v, dict):
recursive_walk(v, depth+1, parent + [k])
else:
path = "/".join(parent + [k])
if os.path.exists(path):
paths.append(path)
def main():
with open('_repo... | code_fim | medium | {
"lang": "python",
"repo": "lvtao-sec/batch-git-clone",
"path": "/pull.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If first in queue and batching by time
if 'time' in settings.HOOK_DELIVERER_SETTINGS:
if current_count == 1:
batch_and_send.apply_async(args=(target_url,),
countdown=settings.HOOK_DELIVERER_SETTINGS['time'],
link_error=fail_handler.s(target_url... | code_fim | hard | {
"lang": "python",
"repo": "GradConnection/django-rest-hooks-delivery",
"path": "/rest_hooks_delivery/tasks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.