text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>ext
head=head.next
l2.next=None
l1.next=result1.next
return result.next<|fim_prefix|># repo: iscas-ljc/leetcode-medium path: /1-100/86.Partition List.py
class Solution(object):
def partition(self, head, x):
if head is None:
return None
result=l1=ListNode(0... | code_fim | medium | {
"lang": "python",
"repo": "iscas-ljc/leetcode-medium",
"path": "/1-100/86.Partition List.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>val<x:
l1.next=head
l1=l1.next
else:
l2.next=head
l2=l2.next
head=head.next
l2.next=None
l1.next=result1.next
return result.next<|fim_prefix|># repo: iscas-ljc/leetcode-medium path: /1-100/86.Partition List.py
class Solution(object):
de... | code_fim | medium | {
"lang": "python",
"repo": "iscas-ljc/leetcode-medium",
"path": "/1-100/86.Partition List.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iscas-ljc/leetcode-medium path: /1-100/86.Partition List.py
class Solution(object):
def partition(self, head, x):
if head is None:
return<|fim_suffix|>ext
head=head.next
l2.next=None
l1.next=result1.next
return result.next<|fim_middle|> None
result... | code_fim | medium | {
"lang": "python",
"repo": "iscas-ljc/leetcode-medium",
"path": "/1-100/86.Partition List.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WhiteMagic/JoystickGremlinModules path: /tempo_pulse.py
import threading
import time
import gremlin
t16000 = gremlin.input_devices.JoystickDecorator(
"T.16000M",
72331530,
"Default"
)
# Maximum duration of a "short" press
g_timeout = 0.3
# Seconds to hold the button pressed
g_hold_... | code_fim | hard | {
"lang": "python",
"repo": "WhiteMagic/JoystickGremlinModules",
"path": "/tempo_pulse.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> btn_id = 6
global g_is_running, g_timer
if event.is_pressed:
vjoy[1].button(btn_id).is_pressed = True
g_timer = threading.Timer(g_timeout, lambda: pulse(vjoy, btn_id))
g_timer.start()
else:
g_is_running = False
if g_timer:
g_timer.cancel(... | code_fim | hard | {
"lang": "python",
"repo": "WhiteMagic/JoystickGremlinModules",
"path": "/tempo_pulse.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> btn_id = 6
global g_is_running, g_timer
if event.is_pressed and joy[1].button(3).is_pressed:
vjoy[1].button(btn_id).is_pressed = True
g_timer = threading.Timer(g_timeout, lambda: pulse(vjoy, btn_id))
g_timer.start()
else:
g_is_running = False
if g_ti... | code_fim | hard | {
"lang": "python",
"repo": "WhiteMagic/JoystickGremlinModules",
"path": "/tempo_pulse.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fault" field name for the captcha
captcha = captchaform(settings.DEFAULT_FIELD_NAME)<|fim_prefix|># repo: Kromey/django-simplecaptcha path: /simplecaptcha/__init__.py
from .decorators import captchaform
from <|fim_middle|>. import settings
# A simple shortcut/"de | code_fim | easy | {
"lang": "python",
"repo": "Kromey/django-simplecaptcha",
"path": "/simplecaptcha/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def feedback_cb(feedback):
pass
def joy_cb(msg):
global client
if msg.buttons[7]:
print '------cancelling goal-------'
client.cancel_goal()
#### definition of publisher/subscriber and services ###
rospy.Subscriber('/joy', Joy, joy_cb)
############# main program ##########... | code_fim | hard | {
"lang": "python",
"repo": "sandeepmaddula/Autonomous-Robot-based-on-ROS",
"path": "/src/tb3_navigation/src/auto_navigation.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> global client
if msg.buttons[7]:
print '------cancelling goal-------'
client.cancel_goal()
#### definition of publisher/subscriber and services ###
rospy.Subscriber('/joy', Joy, joy_cb)
############# main program #############################
goal_pose = Pose()
goal_pose.positi... | code_fim | hard | {
"lang": "python",
"repo": "sandeepmaddula/Autonomous-Robot-based-on-ROS",
"path": "/src/tb3_navigation/src/auto_navigation.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sandeepmaddula/Autonomous-Robot-based-on-ROS path: /src/tb3_navigation/src/auto_navigation.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import rospy
import actionlib
import tf_conversions
import math
from sensor_msgs.msg import Joy
from move_base_msgs.msg import MoveBaseActionGoal, MoveBaseA... | code_fim | hard | {
"lang": "python",
"repo": "sandeepmaddula/Autonomous-Robot-based-on-ROS",
"path": "/src/tb3_navigation/src/auto_navigation.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>== cnt_lst[2] and cnt_lst[2] > cnt_lst[1]:
return [1,3]
else:
if cnt_lst[0] == max_val:
return [1]
elif cnt_lst[1] == max_val:
return [2]
else:
return [3]
answers=[1,2,3,4,5]
print(solution(answers))<|fim_prefix|># repo: snoworange0... | code_fim | hard | {
"lang": "python",
"repo": "snoworange0116/TIL",
"path": "/Algorithm_Problem/ETC/programmers/bad_math_students.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: snoworange0116/TIL path: /Algorithm_Problem/ETC/programmers/bad_math_students.py
def solution(answers):
tmp = []
cnt = 0
cnt_lst = [0,0,0]
p1 = [1,2,3,4,5] * ((len(answers) // 5)+1) # enumerate 써서 idx%len(p1) 하면 초기화 늘려줄 필요 없음.
p2 = [2,1,2,3,2,4,2,5] * ((len(answers) // 8)+1)
... | code_fim | hard | {
"lang": "python",
"repo": "snoworange0116/TIL",
"path": "/Algorithm_Problem/ETC/programmers/bad_math_students.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>me="logout_profile"),
path('show_my_profile/', views.show_my_profile, name="show_my_profile"),
path('update_my_profile/', views.update_my_profile, name="update_my_profile"),
]<|fim_prefix|># repo: oWlogona/myDiplom path: /my_profile/urls.py
from django.urls import path
from . import views
urlpatterns ... | code_fim | medium | {
"lang": "python",
"repo": "oWlogona/myDiplom",
"path": "/my_profile/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>file"),
path('update_my_profile/', views.update_my_profile, name="update_my_profile"),
]<|fim_prefix|># repo: oWlogona/myDiplom path: /my_profile/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('get_profile/', views.get_profile, name="get_profile"),
path('logout_profile/... | code_fim | medium | {
"lang": "python",
"repo": "oWlogona/myDiplom",
"path": "/my_profile/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oWlogona/myDiplom path: /my_profile/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('get_profile/', views.get_profile, name="get_profile"),
path('logout_profile/', views.logout_profile, na<|fim_suffix|>file"),
path('update_my_profile/', views.update_my_profile, n... | code_fim | medium | {
"lang": "python",
"repo": "oWlogona/myDiplom",
"path": "/my_profile/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_name(self):
raise NotImplementedError("get_name() is not implemented by its child")<|fim_prefix|># repo: IsaacSmith13/zegend-of-lelda path: /src/states/game_state.py
class GameState():
def tick(self, delta):
<|fim_middle|> raise NotImplementedError("tick() is not implemente... | code_fim | medium | {
"lang": "python",
"repo": "IsaacSmith13/zegend-of-lelda",
"path": "/src/states/game_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IsaacSmith13/zegend-of-lelda path: /src/states/game_state.py
class GameState():
def tick(self, delta):
<|fim_suffix|> def get_name(self):
raise NotImplementedError("get_name() is not implemented by its child")<|fim_middle|> raise NotImplementedError("tick() is not implemente... | code_fim | medium | {
"lang": "python",
"repo": "IsaacSmith13/zegend-of-lelda",
"path": "/src/states/game_state.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: duncanmcelfresh/RobustKidneyExchange path: /kidney_utils.py
import kidney_ndds
from kidney_digraph import *
EPS = 0.00001
class KidneyOptimException(Exception):
pass
def check_validity(opt_result, digraph, ndds, max_cycle, max_chain, min_chain = None):
"""Check that the solution is val... | code_fim | hard | {
"lang": "python",
"repo": "duncanmcelfresh/RobustKidneyExchange",
"path": "/kidney_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># @np.vectorize
def gamma_homogeneous_edge_failure(n, m, p, k, epsilon):
'''
Variable budget function for homogeneous edge failure probability p
input:
- n : number of cycles in the matching
- m : number of chains in the matching
- k : cycle cap... | code_fim | hard | {
"lang": "python",
"repo": "duncanmcelfresh/RobustKidneyExchange",
"path": "/kidney_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pk = math.pow(1 - p, k)
floor_gamma = int(floor(gamma))
return sum(binom_cdf(gamma - y, m, p) * binomial_dist.pmf(y, n, 1 - pk) for y in range(0, n + 1))
def binom_cdf(y, n, p):
'''
CDF of the binomial distribution, using the regularized incomplete beta function
'''
if y >= n... | code_fim | hard | {
"lang": "python",
"repo": "duncanmcelfresh/RobustKidneyExchange",
"path": "/kidney_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("PermutationPalindrome:")
print(str_func_obj.isPermutationPalindrome())<|fim_prefix|># repo: tushar5353/string_programs path: /testcode.py
import string_ques
str1 = "aa bb cc"
str2 = "asodf"
str_func_obj = string_ques.StringFunctions(str1, str2)
print("Test for unique Characters in a string:")
p... | code_fim | medium | {
"lang": "python",
"repo": "tushar5353/string_programs",
"path": "/testcode.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tushar5353/string_programs path: /testcode.py
import string_ques
str1 = "aa bb cc"
str2 = "asodf"
str_func_obj = string_ques.StringFunctions(str1, str2)
<|fim_suffix|>print("PermutationPalindrome:")
print(str_func_obj.isPermutationPalindrome())<|fim_middle|>print("Test for unique Characters in... | code_fim | hard | {
"lang": "python",
"repo": "tushar5353/string_programs",
"path": "/testcode.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: traceofpassion/Optiplace path: /data/crawling/Subway_Station_Crawling.py
print('--------Crawling Started--------')
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
import requests
def SubwayInfoCrawling():
# crawling option = headless
options = webdriver... | code_fim | hard | {
"lang": "python",
"repo": "traceofpassion/Optiplace",
"path": "/data/crawling/Subway_Station_Crawling.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># My own Kakao Developer API Key. Use for Geocoding.
kakao_api_key = pd.read_csv('../../kakao_api.csv')
# Geocode
headers = {'Authorization':f"{kakao_api_key['rest_api'][0]}"}
def Geocoding(st_name, st_line):
url = f'https://dapi.kakao.com/v2/local/search/keyword.json?query={st_name} {st_line}'
... | code_fim | hard | {
"lang": "python",
"repo": "traceofpassion/Optiplace",
"path": "/data/crawling/Subway_Station_Crawling.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for word in words:
if ipv4_pattern.match(word):
print("valid IP:" +word)<|fim_prefix|># repo: murgod/python-automation path: /findIPfromLargeLogFile.py
import collections
import heapq
import re
<|fim_middle|>ipset = set()
prodcount = collections.defaultdict(int)
ipv4_pattern = re... | code_fim | hard | {
"lang": "python",
"repo": "murgod/python-automation",
"path": "/findIPfromLargeLogFile.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: murgod/python-automation path: /findIPfromLargeLogFile.py
import collections
import heapq
import re
ipset = set()
prodcount = collections.defaultdict(int)
ipv4_pattern = re.compile("^(([01]?[0-9][0-9]?|25[0-5]|2[0-4][0-9]|)\\.){3}([01]?[0-9][0-9]?|25[0-5]|2[0-4][0-9]|)$")
file = open('weblog.tx... | code_fim | easy | {
"lang": "python",
"repo": "murgod/python-automation",
"path": "/findIPfromLargeLogFile.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[b:c]+'"'+s[c:d]+'"'+s[d:])
else:
print('"'+s[:b]+'"'+s[b:c]+'"'+s[c:d]+'"'+s[d:])<|fim_prefix|># repo: WAT36/procon_work path: /procon_python/src/atcoder/arc/past/A_049.py
s=input()
a,b,c,d=map(int,input().split())<|fim_middle|>
if(a!=0):
print(s[:a]+'"'+s[a:b]+'"'+s | code_fim | easy | {
"lang": "python",
"repo": "WAT36/procon_work",
"path": "/procon_python/src/atcoder/arc/past/A_049.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WAT36/procon_work path: /procon_python/src/atcoder/arc/past/A_049.py
s=input()
a,b,c,d=map(int,input().split())<|fim_suffix|>[b:c]+'"'+s[c:d]+'"'+s[d:])
else:
print('"'+s[:b]+'"'+s[b:c]+'"'+s[c:d]+'"'+s[d:])<|fim_middle|>
if(a!=0):
print(s[:a]+'"'+s[a:b]+'"'+s | code_fim | easy | {
"lang": "python",
"repo": "WAT36/procon_work",
"path": "/procon_python/src/atcoder/arc/past/A_049.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>import elementpath
from defusedxml.cElementTree import parse
from dusty.tools import log, url, markdown
from dusty.models.finding import DastFinding
from dusty.models.error import Error
from dusty.constants import SEVERITIES
def parse_findings(output_file, scanner):
""" Parse findings (code from du... | code_fim | hard | {
"lang": "python",
"repo": "carrier-io/dusty",
"path": "/dusty/scanners/dast/nmap/parser.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nemesis-Ace/SE-PROJECT path: /SWE/limbo/migrations/0004_auto_20210406_0103.py
# Generated by Django 3.1.7 on 2021-04-05 19:33
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.CreateModel(
name='DefaultList',
fields=[
... | code_fim | hard | {
"lang": "python",
"repo": "Nemesis-Ace/SE-PROJECT",
"path": "/SWE/limbo/migrations/0004_auto_20210406_0103.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('limbo', '0003_auto_20210329_2015'),
]
operations = [
migrations.CreateModel(
name='DefaultList',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
... | code_fim | hard | {
"lang": "python",
"repo": "Nemesis-Ace/SE-PROJECT",
"path": "/SWE/limbo/migrations/0004_auto_20210406_0103.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from torch.utils.tensorboard import SummaryWriter
import torch
from torch.utils.data import DataLoader
import numpy as np
import torch.nn.functional as F
import copy
from collections import OrderedDict
import torch.nn.init as init
from torch.utils.data import Dataset
from torch.utils.da... | code_fim | hard | {
"lang": "python",
"repo": "jansel/pytorch-jit-paritybench",
"path": "/generated/test_vaseline555_Federated_Averaging_PyTorch.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jansel/pytorch-jit-paritybench path: /generated/test_vaseline555_Federated_Averaging_PyTorch.py
import sys
_module = sys.modules[__name__]
del sys
main = _module
src = _module
client = _module
models = _module
server = _module
utils = _module
from _paritybench_helpers import _mock_config, patch_... | code_fim | hard | {
"lang": "python",
"repo": "jansel/pytorch-jit-paritybench",
"path": "/generated/test_vaseline555_Federated_Averaging_PyTorch.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from collections import OrderedDict
import torch.nn.init as init
from torch.utils.data import Dataset
from torch.utils.data import TensorDataset
from torch.utils.data import ConcatDataset
from torchvision import datasets
from torchvision import transforms
class TwoNN(nn.Module):
def __... | code_fim | hard | {
"lang": "python",
"repo": "jansel/pytorch-jit-paritybench",
"path": "/generated/test_vaseline555_Federated_Averaging_PyTorch.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.h = 0
self.g = 0
self.f = 0
# Actions that can be taken
def actions(self):
moves = []
i = self.emptyCell[0]
j = self.emptyCell[1]
if i > 0:
moves.append('U')
if i < len(self.state)-1:
... | code_fim | hard | {
"lang": "python",
"repo": "jessiclin/TileProblem_Solver",
"path": "/TileProblem.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jessiclin/TileProblem_Solver path: /TileProblem.py
'''
This program should be able to define the search problem with clearly labeled components that point to the state, actions, transition function and goal test.
Define a problem in terms of state, actions, transition function, and goal test
Ti... | code_fim | hard | {
"lang": "python",
"repo": "jessiclin/TileProblem_Solver",
"path": "/TileProblem.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HarperHao/ZL_Project path: /apps/forms.py
"""
Author : HarperHao
TIME : 2020/12/9
FUNCTION: 表单的基类
"""
from wtforms import Form
<|fim_suffix|> def get_error(self):
message = self.errors.popitem()[1][0]
return message<|fim_middle|>
class BaseForm(Form):
| code_fim | easy | {
"lang": "python",
"repo": "HarperHao/ZL_Project",
"path": "/apps/forms.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> message = self.errors.popitem()[1][0]
return message<|fim_prefix|># repo: HarperHao/ZL_Project path: /apps/forms.py
"""
Author : HarperHao
TIME : 2020/12/9
FUNCTION: 表单的基类
"""
from wtforms import Form
class BaseForm(Form):
<|fim_middle|> def get_error(self):
| code_fim | easy | {
"lang": "python",
"repo": "HarperHao/ZL_Project",
"path": "/apps/forms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qiubite31/Leetcode path: /Bit_Manipulate/leetcode-476.py
"""
476. Number Complement
Difficulty: Easy
Related Topic: Bit Manipulate, XOR
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
<|fim_suffix|>class So... | code_fim | hard | {
"lang": "python",
"repo": "qiubite31/Leetcode",
"path": "/Bit_Manipulate/leetcode-476.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution(object):
def findComplement(self, num):
"""
:type num: int
:rtype: int
"""
digit = len("{0:b}".format(num))
max_num = pow(2, digit)-1
return num ^ max_num
num = 5
solution = Solution()
output = solution.findComplemen... | code_fim | hard | {
"lang": "python",
"repo": "qiubite31/Leetcode",
"path": "/Bit_Manipulate/leetcode-476.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stalbrec/UHH2Util path: /checkFiles.py
from __future__ import print_function
import ROOT,uproot
xml_files=[
'MC_QCD_Pt_1000to1400_2017v2_46.xml',
'MC_QCD_Pt_1000to1400_2017v2_48.xml',
'MC_QCD_Pt_1000to1400_2017v2_51.xml',
'MC_QCD_Pt_1000to1400_2017v2_52.xml',
'MC_QCD_P<|... | code_fim | hard | {
"lang": "python",
"repo": "stalbrec/UHH2Util",
"path": "/checkFiles.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ng xml:', xml)
root_files=[]
with open(path+xml) as xml_file:
for l in xml_file:
if ".root" in l and 'pnfs' in l:
root_files.append(l.split('"')[1])
xml_file.close()
for root_file in root_files:
f = uproot.open(root_file)
... | code_fim | hard | {
"lang": "python",
"repo": "stalbrec/UHH2Util",
"path": "/checkFiles.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chinmaydas96/twitter_sentiment path: /Sentiment and Emotion/06_FB_Analysis.py
import pandas as pd
from twitter_get_data import query_str
import os
path=os.getcwd()
os.chdir(query_str)
data=pd.read_csv('Final_Results_FB.csv',encoding='ISO-8859-1')
data_pos=0
data_neg=0
data_neu=0
data_h... | code_fim | hard | {
"lang": "python",
"repo": "chinmaydas96/twitter_sentiment",
"path": "/Sentiment and Emotion/06_FB_Analysis.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
import numpy as np
import matplotlib.pyplot as plt
top=[('Positive',data_pos),('Negative',data_neg),('Neutral',data_neu)]
labels, ys = zip(*top)
xs = np.arange(len(labels))
width = 1
plt.bar(xs, ys)
plt.xticks(xs, labels) #Replace de... | code_fim | hard | {
"lang": "python",
"repo": "chinmaydas96/twitter_sentiment",
"path": "/Sentiment and Emotion/06_FB_Analysis.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if client_auth:
builder = builder.add_extension(
x509.ExtendedKeyUsage([x509.ExtendedKeyUsageOID.CLIENT_AUTH]),
critical=True
)
certificate = builder.sign(
signing_key,
hashes.SHA256(),
backends.default_backend()
)
return cer... | code_fim | hard | {
"lang": "python",
"repo": "RickS007/kmip_server",
"path": "/scripts/create_certificates.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RickS007/kmip_server path: /scripts/create_certificates.py
import argparse
import datetime
import os
from cryptography import x509
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography... | code_fim | hard | {
"lang": "python",
"repo": "RickS007/kmip_server",
"path": "/scripts/create_certificates.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_root_certificate(root_ca_cn):
root_key = create_rsa_private_key()
return root_key, create_self_signed_certificate(root_ca_cn, root_key)
def create_server_certificate(server_cert_cn, root_cert, root_key):
server_key = create_rsa_private_key()
return server_key, create_certifica... | code_fim | hard | {
"lang": "python",
"repo": "RickS007/kmip_server",
"path": "/scripts/create_certificates.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@skip_because_stt_removed
def test_run_keyboard_stt():
"""test run with keyboard stt.
At the first run, it will run normally.
On the next run an error will be raised to stop the loop.
"""
profile_data = default_profile_data
profile_data['stt'] = 'keyboard'
with mock.patch('__b... | code_fim | hard | {
"lang": "python",
"repo": "lucifer-008/Melissa-Core",
"path": "/tests/test_stt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> when this test run,
an error will be raised when trying to print the speech_text.
"""
profile_data = default_profile_data
profile_data['stt'] = 'google'
mock_profile.data = profile_data
with mock.patch('__builtin__.__import__', side_effect=import_mock),\
mock.patch(... | code_fim | hard | {
"lang": "python",
"repo": "lucifer-008/Melissa-Core",
"path": "/tests/test_stt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucifer-008/Melissa-Core path: /tests/test_stt.py
"""test stt module."""
import random
import string
try: # py3
from unittest import mock
except ImportError: # py2
import mock
import pytest
skip_because_stt_removed = pytest.mark.skip(reason='stt module removed.')
def get_random_stri... | code_fim | hard | {
"lang": "python",
"repo": "lucifer-008/Melissa-Core",
"path": "/tests/test_stt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected = 4
actual = binary_search([1, 2, 3, 4, 5, 6], 5)
assert expected == actual
def test_finds_indexed_even_num_():
expected = 4
actual = binary_search([1, 2, 4, 5, 6, 7], 6)
assert expected == actual<|fim_prefix|># repo: RaniaAbdullahh/data-structures-and-algorithms-python ... | code_fim | hard | {
"lang": "python",
"repo": "RaniaAbdullahh/data-structures-and-algorithms-python",
"path": "/tests/challenges/array_binary_search.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_finds_indexed_odd_num():
expected = 4
actual = binary_search([1, 2, 3, 4, 5, 6], 5)
assert expected == actual
def test_finds_indexed_even_num_():
expected = 4
actual = binary_search([1, 2, 4, 5, 6, 7], 6)
assert expected == actual<|fim_prefix|># repo: RaniaAbdullahh/data-... | code_fim | hard | {
"lang": "python",
"repo": "RaniaAbdullahh/data-structures-and-algorithms-python",
"path": "/tests/challenges/array_binary_search.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RaniaAbdullahh/data-structures-and-algorithms-python path: /tests/challenges/array_binary_search.py
from data_structures_and_algorithms.challenges.array_binary_search.array_binary_search import binary_search
<|fim_suffix|>def test_finds_indexed_even_num_():
expected = 4
actual = binary_... | code_fim | hard | {
"lang": "python",
"repo": "RaniaAbdullahh/data-structures-and-algorithms-python",
"path": "/tests/challenges/array_binary_search.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiapengyu/python_album path: /egc-usercenter-simulator/utils/RedisUtil.py
import redis
def init_client():
client = redis.StrictRedis(host='192.168.204.128', port=6379, db=0)
return client
def set_key(key, value):
client = init_client()
client.set(key, value)
def... | code_fim | medium | {
"lang": "python",
"repo": "xiapengyu/python_album",
"path": "/egc-usercenter-simulator/utils/RedisUtil.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = init_client()
result = client.get(key)
return result
if __name__ == "__main__":
set_key("foo1", "far")
set_key("foo2", "far")
set_key("foo3", "far")<|fim_prefix|># repo: xiapengyu/python_album path: /egc-usercenter-simulator/utils/RedisUtil.py
import redis
... | code_fim | hard | {
"lang": "python",
"repo": "xiapengyu/python_album",
"path": "/egc-usercenter-simulator/utils/RedisUtil.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
set_key("foo1", "far")
set_key("foo2", "far")
set_key("foo3", "far")<|fim_prefix|># repo: xiapengyu/python_album path: /egc-usercenter-simulator/utils/RedisUtil.py
import redis
def init_client():
client = redis.StrictRedis(host='192.168.204.128', port=6... | code_fim | hard | {
"lang": "python",
"repo": "xiapengyu/python_album",
"path": "/egc-usercenter-simulator/utils/RedisUtil.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nkmprog/python-retrospective path: /task1/solution.py
ZODIACS = ["Козирог", "Водолей", "Риби", "Овен", "Телец", "Близнаци",
"Рак", "Лъв", "Дева", "Везни", "Скорпион", "Стрелец", "Козирог"]
<|fim_suffix|>def what_is_my_sign(day, month):
if day <= SPLIT[month - 1]:
return ZO... | code_fim | easy | {
"lang": "python",
"repo": "nkmprog/python-retrospective",
"path": "/task1/solution.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if day <= SPLIT[month - 1]:
return ZODIACS[month - 1]
return ZODIACS[month]<|fim_prefix|># repo: nkmprog/python-retrospective path: /task1/solution.py
ZODIACS = ["Козирог", "Водолей", "Риби", "Овен", "Телец", "Близнаци",
"Рак", "Лъв", "Дева", "Везни", "Скорпион", "Стрелец", "Ко... | code_fim | easy | {
"lang": "python",
"repo": "nkmprog/python-retrospective",
"path": "/task1/solution.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def fullname(obj):
if hasattr(obj, '__qualname__'):
return obj.__module__ + '.' + obj.__qualname__
return obj.__name__
if __name__ == '__main__':
for d, items in deliverables.items():
for item in items:
if hasattr(item, "__doc__") and item.__doc__:
... | code_fim | hard | {
"lang": "python",
"repo": "CarsonStevens/Mines-Courses",
"path": "/Mines Courses/CSCI_400/SlytherLisp/tests/extract_docstrings - Copy.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CarsonStevens/Mines-Courses path: /Mines Courses/CSCI_400/SlytherLisp/tests/extract_docstrings - Copy.py
#!/usr/bin/env python3
"""
This script extracts docstrings from modules and generates the appropriate
files. It is intended to be run by the instructor before distributing the
starter code.
I... | code_fim | hard | {
"lang": "python",
"repo": "CarsonStevens/Mines-Courses",
"path": "/Mines Courses/CSCI_400/SlytherLisp/tests/extract_docstrings - Copy.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hasattr(obj, '__qualname__'):
return obj.__module__ + '.' + obj.__qualname__
return obj.__name__
if __name__ == '__main__':
for d, items in deliverables.items():
for item in items:
if hasattr(item, "__doc__") and item.__doc__:
f = open("tests/{}... | code_fim | hard | {
"lang": "python",
"repo": "CarsonStevens/Mines-Courses",
"path": "/Mines Courses/CSCI_400/SlytherLisp/tests/extract_docstrings - Copy.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def levelOrder(root):
if root is None:
return []
ret=[]
result=deque()
queue=deque([root, None]) # added None after root, to create None delimited levels to tell we finished one level
is_left = True
while len(queue) > 0:
node = queue.popleft()
... | code_fim | medium | {
"lang": "python",
"repo": "drcpcg/codebase",
"path": "/Tree/tree-traversal-level-order-zig-zag.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: drcpcg/codebase path: /Tree/tree-traversal-level-order-zig-zag.py
# https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
from collections import deque
class Node:
# A utility function to create a new node
def __init__(self, key):
<|fim_suffix|> while len(queue) > 0:
... | code_fim | hard | {
"lang": "python",
"repo": "drcpcg/codebase",
"path": "/Tree/tree-traversal-level-order-zig-zag.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret=[]
result=deque()
queue=deque([root, None]) # added None after root, to create None delimited levels to tell we finished one level
is_left = True
while len(queue) > 0:
node = queue.popleft()
if node:
if is_left: result.append(node.val)
... | code_fim | medium | {
"lang": "python",
"repo": "drcpcg/codebase",
"path": "/Tree/tree-traversal-level-order-zig-zag.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Headers fot the Table
records = [('Station', 'Line', 'Travel Time to Next Station(in mins)')]
# Table Data
for x, y, z in zip(path, line_ID, time_taken):
records.append((x, y, z))
if path_results == "Route Not Possible":
gui.route_not_possible()
else:
... | code_fim | hard | {
"lang": "python",
"repo": "aniket32/London-Underground-Shortest-path-algorithm-with-Dijkstra",
"path": "/Shortest algorithm with Dijkstra/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aniket32/London-Underground-Shortest-path-algorithm-with-Dijkstra path: /Shortest algorithm with Dijkstra/main.py
import Dijkstra_with_DLL as dijk
import GUI as gui
def run(station1, station2, time):
<|fim_suffix|> # Headers fot the Table
records = [('Station', 'Line', 'Travel Time... | code_fim | hard | {
"lang": "python",
"repo": "aniket32/London-Underground-Shortest-path-algorithm-with-Dijkstra",
"path": "/Shortest algorithm with Dijkstra/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.room.status != ROOM_STATUS_VOTE:
return
if info and info.flag:
pass
else:
pass
def event_cb_werewolf(self, info):
if self.room.status != ROOM_STATUS_WEREWOLF:
return
self.kill_info.append(info)
def ev... | code_fim | hard | {
"lang": "python",
"repo": "pengzhuo/gameServer",
"path": "/server/models/judge.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pengzhuo/gameServer path: /server/models/judge.py
# coding: utf-8
from common.constDefine import *
from protocol import game_pb2
from utils.eventUtils import EventUtils
from utils.timerUtils import TimerUtils
class Judge:
"""法官"""
room = None # 房间实例
timer = None ... | code_fim | medium | {
"lang": "python",
"repo": "pengzhuo/gameServer",
"path": "/server/models/judge.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def event_cb_normal(self, info):
if self.room.status != ROOM_STATUS_VOTE:
return
if info and info.flag:
pass
else:
pass
def event_cb_werewolf(self, info):
if self.room.status != ROOM_STATUS_WEREWOLF:
return
se... | code_fim | hard | {
"lang": "python",
"repo": "pengzhuo/gameServer",
"path": "/server/models/judge.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harina9/homework-repository-1 path: /homework8/task1.py
class KeyValueStorage:
def __init__(self, path):
with open(path, "r") as file:
data = file.read().splitlines()
for line in data:
key, value = line.split("=")
<|fim_suffix|> storage = K... | code_fim | hard | {
"lang": "python",
"repo": "harina9/homework-repository-1",
"path": "/homework8/task1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __getitem__(self, key):
return self.__dict__.get(key, None)
if __name__ == "__main__":
storage = KeyValueStorage("task1.txt")
print(storage["name"])
print(storage.song)
print(storage.power)<|fim_prefix|># repo: harina9/homework-repository-1 path: /homework8/task1.py
cla... | code_fim | hard | {
"lang": "python",
"repo": "harina9/homework-repository-1",
"path": "/homework8/task1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>C47AD98F70.root',
'/store/mc/RunIISummer16MiniAODv2/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/MINIAODSIM/PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1/60000/92233F29-C5BB-E611-AC46-20CF3027A613.root',
'/store/mc/RunIISummer16MiniAODv2/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphML... | code_fim | hard | {
"lang": "python",
"repo": "tklijnsma/TreeMaker",
"path": "/Production/python/Summer16/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_cff.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tklijnsma/TreeMaker path: /Production/python/Summer16/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_cff.py
6_TrancheIV_v6-v1/120000/6064DD7D-27BC-E611-9269-FA163E3A554D.root',
'/store/mc/RunIISummer16MiniAODv2/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/MINIAODSIM/PUMoriond17_80X... | code_fim | hard | {
"lang": "python",
"repo": "tklijnsma/TreeMaker",
"path": "/Production/python/Summer16/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_cff.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Priyanshu909090/BUYZONE path: /shop/views.py
from math import ceil
from django.shortcuts import render
from django.http import HttpResponse
from .models import Product, Women, Men, Watch, Kids, Other, Shoes
from .models import Contact
from .models import Order
def index(request):
# # prod... | code_fim | hard | {
"lang": "python",
"repo": "Priyanshu909090/BUYZONE",
"path": "/shop/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, 'shop/checkout.html')
def category(request, womenid):
ladiesproduct = Women.objects.filter(women_id=womenid)
param = {'ladiesproduct': ladiesproduct[0]}
return render(request, 'shop/category.html', param)
def women(request):
allwomenProd = []
womenprod =... | code_fim | hard | {
"lang": "python",
"repo": "Priyanshu909090/BUYZONE",
"path": "/shop/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def shoe(request):
allshoeProd = []
shoeprod = Shoes.objects.values('category')
cats = {item['category'] for item in shoeprod}
for cat in cats:
shoeproduct = Shoes.objects.filter(category=cat)
n = len(shoeproduct)
# nSlide = n // 4 + ceil((n / 4) - (n // 4))
... | code_fim | hard | {
"lang": "python",
"repo": "Priyanshu909090/BUYZONE",
"path": "/shop/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dulude/wfc3_photometry path: /db_querying/query_mast.py
import sys
import os
import time
import re
import json
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
try: # Python 3.x
from urllib.parse import quote as urlencode
from urllib.requ... | code_fim | hard | {
"lang": "python",
"repo": "dulude/wfc3_photometry",
"path": "/db_querying/query_mast.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print(mastData.keys())
print("Query status:",mastData['status'])
# pp.pprint(mastData['fields'])
data = mastData['data']
# pp.pprint(data[0])
print 'N: {}'.format(len(mastData['data']))
df = pd.read_json(json.dumps(data))
# print df['proposal_id']
df = df.loc[(df['ta... | code_fim | hard | {
"lang": "python",
"repo": "dulude/wfc3_photometry",
"path": "/db_querying/query_mast.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
files = glob.glob('D:/ML/BookSourceCode/learning-nlp/chapter-3/data/news/C000013/*.txt')
corpus = [load_content(x) for x in files]
stop_words = load_stop_words('D:/ML/BookSourceCode/learning-nlp/chapter-3/data/stop_words.utf8')
split_words = list(jieba.cut(corp... | code_fim | hard | {
"lang": "python",
"repo": "asnjudy/ml-study",
"path": "/learning-nlp/ch03/sogou_news_cut.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asnjudy/ml-study path: /learning-nlp/ch03/sogou_news_cut.py
import jieba
import random
import glob
def load_stop_words(path):
with open(path, 'r', encoding='utf8', errors='ignore') as f:
return [line.strip() for line in f]
def load_content(path):
with open(path, 'r', encoding=... | code_fim | hard | {
"lang": "python",
"repo": "asnjudy/ml-study",
"path": "/learning-nlp/ch03/sogou_news_cut.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> split_words = list(jieba.cut(corpus[0]))
# 去除停用词
split_words = [w for w in split_words if w not in stop_words]
print('分词效果:' + '/ '.join(split_words))
# 统计高频词
top10_words = get_TF(split_words, topK=10)
print(top10_words)<|fim_prefix|># repo: asnjudy/ml-study path: /learning-n... | code_fim | hard | {
"lang": "python",
"repo": "asnjudy/ml-study",
"path": "/learning-nlp/ch03/sogou_news_cut.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hparnerkar/Client-Server-Python path: /server.py
# File transfer server side
'''
Program for server multithreading
Allows massive transfer from a specific folder in the server side to another folder in the client
'''
import socket
import os, sys
import threading
import time
#import... | code_fim | hard | {
"lang": "python",
"repo": "hparnerkar/Client-Server-Python",
"path": "/server.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ServerThread(object):
def __init__(self,conn,ip,port):
self.ip = ip
self.port = port
print ('{0}-{1}:{2}'.format("New client connected",str(ip),str(port)))
#self.runThread(conn,'{0}:{1}'.format(str(ip),str(port)))
c=input("do you want to ... | code_fim | hard | {
"lang": "python",
"repo": "hparnerkar/Client-Server-Python",
"path": "/server.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Replica Server starts here by initializing cache and starting the HTTPserver
if __name__ == '__main__':
[port, origin] = parse_input(sys.argv)
print port
print origin
serverAddress = ('', port)
RequestHandler.port = port
RequestHandler.origin = origin
cache_max_capacity = 9.9 * 1024 * 1024
Reques... | code_fim | hard | {
"lang": "python",
"repo": "rahulbahal7/content-delivery-network",
"path": "/http/httpserver.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rahulbahal7/content-delivery-network path: /http/httpserver.py
import getopt
import hashlib
import sys
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from os import curdir, sep
import subprocess
#from subprocess import subprocess,Popen,PIPE
import os
import urllib2
#import try_liste... | code_fim | hard | {
"lang": "python",
"repo": "rahulbahal7/content-delivery-network",
"path": "/http/httpserver.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> verbose_name_plural = "Emails"
ordering = ('date',)<|fim_prefix|># repo: elenasacristan/claudia path: /contact/models.py
from django.db import models
from datetime import datetime
class Contact(models.Model):
name = models.CharField(max_length=50)
email = models.EmailField(max_l... | code_fim | medium | {
"lang": "python",
"repo": "elenasacristan/claudia",
"path": "/contact/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elenasacristan/claudia path: /contact/models.py
from django.db import models
from datetime import datetime
class Contact(models.Model):
name = models.CharField(max_length=50)
email = models.EmailField(max_length=100)
phone = models.CharField(max_length=15, blank=True)
message = ... | code_fim | easy | {
"lang": "python",
"repo": "elenasacristan/claudia",
"path": "/contact/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.name
class Meta:
verbose_name_plural = "Emails"
ordering = ('date',)<|fim_prefix|># repo: elenasacristan/claudia path: /contact/models.py
from django.db import models
from datetime import datetime
class Contact(models.Model):
<|fim_middle|>... | code_fim | hard | {
"lang": "python",
"repo": "elenasacristan/claudia",
"path": "/contact/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mawillcockson/dotfiles path: /install_dotfiles.py
est import urlopen
trio = None
if TYPE_CHECKING:
from io import BufferedWriter
from typing import AsyncIterator, List, Tuple, Union
import trio
from trio import MemoryReceiveChannel, MemorySendChannel, Process
WINDOW... | code_fim | hard | {
"lang": "python",
"repo": "mawillcockson/dotfiles",
"path": "/install_dotfiles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mawillcockson/dotfiles path: /install_dotfiles.py
self.print_buffer.write(chunk)
except BlockingIOError:
pass
self.print_buffer.flush()
async def copier_recorder(
self,
) -> None:
"""
records th... | code_fim | hard | {
"lang": "python",
"repo": "mawillcockson/dotfiles",
"path": "/install_dotfiles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # NOTE: don't have to check if the response was sent, because
# sometimes the execution policy is set without ever sending a
# response (i.e. if the execution policy was already set).
# Instead, just check if the policy is set correctly.
re... | code_fim | hard | {
"lang": "python",
"repo": "mawillcockson/dotfiles",
"path": "/install_dotfiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.parametrize('p, expected', [
(5, 'GF(5)'),
(2, 'GF(2)')
])
def test_GFp_str(p, expected):
gf = GFp(p)
assert str(gf) == expected
@pytest.mark.parametrize('integer, p', [
(1, 5),
(2, 11),
(3, 123456791)
])
def test_GFp_elm(integer, p):
gf = GFp(p)
result ... | code_fim | medium | {
"lang": "python",
"repo": "syakoo/galois-field",
"path": "/tests/test_GFp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: syakoo/galois-field path: /tests/test_GFp.py
import pytest
from galois_field.GFp import GFp
from galois_field.core.ElementInGFp import ElementInGFp
@pytest.mark.parametrize('p', [(5), (2), (123456791)])
def test_GFp_init(p):
gf = GFp(p)
assert gf.p == p
@pytest.mark.parametrize('p, e... | code_fim | medium | {
"lang": "python",
"repo": "syakoo/galois-field",
"path": "/tests/test_GFp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while True:
inp = input("Action")
if inp == "r":
env.reset()
elif inp == "c":
env.render("rgb_array")
elif inp.isnumeric():
print(env.step(int(inp), render=True)[0])
env.render()<|fim_prefix|># repo: siddharthverma314/clcp-neurips-2020 path: /ant-hrl-maze/test/... | code_fim | medium | {
"lang": "python",
"repo": "siddharthverma314/clcp-neurips-2020",
"path": "/ant-hrl-maze/test/manual_control_waypoint.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: siddharthverma314/clcp-neurips-2020 path: /ant-hrl-maze/test/manual_control_waypoint.py
import gym
import ant_hrl_maze
from PIL import Image
<|fim_suffix|>while True:
inp = input("Action")
if inp == "r":
env.reset()
elif inp == "c":
env.render("rgb_array")
elif in... | code_fim | medium | {
"lang": "python",
"repo": "siddharthverma314/clcp-neurips-2020",
"path": "/ant-hrl-maze/test/manual_control_waypoint.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yashverma7/NLP-and-NLTK path: /tokenization.py
# -*- coding: utf-8 -*-
"""Untitled16.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1w7qOuuGMSa-n9TVJkPg7PPUjpL2XBTl1
"""
import nltk
nltk.download('punkt')
from nltk.tokeni... | code_fim | medium | {
"lang": "python",
"repo": "yashverma7/NLP-and-NLTK",
"path": "/tokenization.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tokenizer = RegexpTokenizer("[\w']+")
text = "Hello, you are reading about Tokenization. There are many forms of Tokenizers."
tokenizer.tokenize(text)
from nltk.tokenize import regexp_tokenize
text = "Hello, you are reading about Tokenization. There are many forms of Tokenizers."
regexp_tokenize(tex... | code_fim | hard | {
"lang": "python",
"repo": "yashverma7/NLP-and-NLTK",
"path": "/tokenization.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: loveddy/ALI-Competition path: /model/train_model.py
import torch
from utils import Utils
from model import GRUEncoder, Classifier, ContrastiveLoss
import torch.optim as optim
import os
import sys
from gensim.models import Word2Vec
import numpy as np
import jieba
def build_model(voc_size, emb_dim... | code_fim | hard | {
"lang": "python",
"repo": "loveddy/ALI-Competition",
"path": "/model/train_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>encoder, classifier = build_model(len(helper.dic), 128, 128)
encoder_optimizer = optim.Adam(encoder.parameters(), lr=0.0001)
classifier_optimizer = optim.Adam(classifier.parameters(), lr=0.0001)
criterion = torch.nn.CrossEntropyLoss()
loss_list = []
print "epoch precision recall accuracy F... | code_fim | hard | {
"lang": "python",
"repo": "loveddy/ALI-Competition",
"path": "/model/train_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
message_store_bucket_name=None,
message_store_object_name=None):
if message_store_bucket_name is None:
message_store_bucket_name = os.environ['MESSAGE_STORE_S3_BUCKET_NAME']
if message_store_object_name is None:
message_store_object_nam... | code_fim | hard | {
"lang": "python",
"repo": "tcquinn/daily-message",
"path": "/message_database.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.