text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self,
transition_fn: Callable[[GameState, Action], GameState],
initial_state: GameState,
):
self.tranition_fn = transition_fn
self.current_state = initial_state
def transition(self, action):
self.current_state = self.tranition_fn(
s... | code_fim | hard | {
"lang": "python",
"repo": "shadowCow/gamey",
"path": "/games/game.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_screw.py
#calss header
class _SCREW():
def __init__(self,):
self.name = "SCREW"
self.definitions = [u'to fasten something using a screw: ', u'to fasten something using an object similar to a screw: ', u'If something screws in/together, it fits... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/verbs/_screw.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>list(str(n - i))))) == i:
ans.append(n - i)
print len(ans)
for i in ans:
print i<|fim_prefix|># repo: Anguei/OI-Codes path: /LuoguCodes/AT1194.py
n = int(raw_input())
ans = []
for i in range(m<|fim_middle|>in(n, 1000), 0, -1):
if sum(list(map(int, | code_fim | easy | {
"lang": "python",
"repo": "Anguei/OI-Codes",
"path": "/LuoguCodes/AT1194.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Anguei/OI-Codes path: /LuoguCodes/AT1194.py
n = int(raw_input())
ans = []
for i in range(m<|fim_suffix|>list(str(n - i))))) == i:
ans.append(n - i)
print len(ans)
for i in ans:
print i<|fim_middle|>in(n, 1000), 0, -1):
if sum(list(map(int, | code_fim | easy | {
"lang": "python",
"repo": "Anguei/OI-Codes",
"path": "/LuoguCodes/AT1194.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rc-dining-bot/telegram-bot path: /src/scheduler/scheduler_config.py
from util.util import utc_time
# broadcast timings
BREAKFAST_BROADCAST_TIME = utc_time(hour=0,
minute=0,
<|fim_suffix|> minute=0,
... | code_fim | hard | {
"lang": "python",
"repo": "rc-dining-bot/telegram-bot",
"path": "/src/scheduler/scheduler_config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> minute=0,
second=0)<|fim_prefix|># repo: rc-dining-bot/telegram-bot path: /src/scheduler/scheduler_config.py
from util.util import utc_time
# broadcast timings
BREAKFAST_BROADCAST_TIME = utc_time(hour=0,
minu... | code_fim | hard | {
"lang": "python",
"repo": "rc-dining-bot/telegram-bot",
"path": "/src/scheduler/scheduler_config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: radpointhq/GDCM path: /Examples/Python/PrivateDict.py
############################################################################
#
# Program: GDCM (Grassroots DICOM). A DICOM library
#
# Copyright (c) 2006-2011 Mathieu Malaterre
# All rights reserved.
# See Copyright.txt or http://gdcm.sour... | code_fim | hard | {
"lang": "python",
"repo": "radpointhq/GDCM",
"path": "/Examples/Python/PrivateDict.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> d = globInst.GetDicts()
print d.GetDictEntry( gdcm.Tag(0x0029,0x0010) ,"SIEMENS CSA HEADER" )
pd = d.GetPrivateDict()
print pd.GetDictEntry( gdcm.PrivateTag(0x0029,0x0010,"SIEMENS CSA HEADER") )<|fim_prefix|># repo: radpointhq/GDCM path: /Examples/Python/PrivateDict.py
###########################... | code_fim | medium | {
"lang": "python",
"repo": "radpointhq/GDCM",
"path": "/Examples/Python/PrivateDict.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nadavWeisler/IntroToCS path: /IntroToCS_ex3/check_maximum.py
#############################################################
# FILE : check_maximum.py
# WRITER : Nadav Weisler , weisler , 316493758
# EXERCISE : intro2cs ex3 2019
# DESCRIPTION: Check maximum function with some inputs
###############... | code_fim | medium | {
"lang": "python",
"repo": "nadavWeisler/IntroToCS",
"path": "/IntroToCS_ex3/check_maximum.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_lists = \
[
[1, 1, 1, 1, 1, 1, 1],
[1],
[1, 2, 3, 4, 5],
[5, 4, 3, 2, 1],
[1, 0, 1]
]
test_result = True
for i in range(len(test_lists)):
if maximum(test_lists[i]) == max(test_lists[i]):
print(... | code_fim | medium | {
"lang": "python",
"repo": "nadavWeisler/IntroToCS",
"path": "/IntroToCS_ex3/check_maximum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """cards is str type"""
if isinstance(cards, str):
cards = str2cards(cards)
if not isinstance(cards, list):
return False, None
sorted_cards = sort_cards(cards)
value = Doudizhu.DATA.get(cards2str(sorted_cards))
if value is None:
... | code_fim | hard | {
"lang": "python",
"repo": "aohajin/doudizhu_resolver",
"path": "/doudizhu_resolver/doudizhu/engine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aohajin/doudizhu_resolver path: /doudizhu_resolver/doudizhu/engine.py
'.join(cards)
def str2cards(string):
return string.split('-')
def str2cardmap(string):
cards = str2cards(string)
cardmap = {}
for c in cards:
if c in cardmap:
cardmap[c] += 1
else... | code_fim | hard | {
"lang": "python",
"repo": "aohajin/doudizhu_resolver",
"path": "/doudizhu_resolver/doudizhu/engine.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aohajin/doudizhu_resolver path: /doudizhu_resolver/doudizhu/engine.py
def enum_solo():
"""枚举所有单牌,并附加权重,以便比较大小"""
return [(c, w) for w, c in enumerate(CARDS)]
def enum_solo_chain(length):
"""枚举所有单连顺,并附加权重
length 是连顺的张数,如5连
"""
if length < 5 or length > 12:
raise... | code_fim | hard | {
"lang": "python",
"repo": "aohajin/doudizhu_resolver",
"path": "/doudizhu_resolver/doudizhu/engine.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_list_field_exact(self):
where = WhereNode()
where.add((Constraint("cn", "cn", ListField()), 'exact', "test"), AND)
self.assertEquals(where_as_ldap(where), ("(cn=test)", []))
def test_list_field_in(self):
where = WhereNode()
where.add((Constraint("c... | code_fim | hard | {
"lang": "python",
"repo": "unistra/django-ldapdb",
"path": "/ldapdb/tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: unistra/django-ldapdb path: /ldapdb/tests.py
# -*- coding: utf-8 -*-
#
# django-ldapdb
# Copyright (c) 2009-2011, Bolloré telecom
# All rights reserved.
#
# See AUTHORS file for a full list of contributors.
#
# Redistribution and use in source and binary forms, with or without modification,
# ... | code_fim | hard | {
"lang": "python",
"repo": "unistra/django-ldapdb",
"path": "/ldapdb/tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'telephone')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('telephone', mysql.VARCHAR(length=11), nulla... | code_fim | medium | {
"lang": "python",
"repo": "horizon-hardyzl/HUSTPORT",
"path": "/migrations/versions/90d4efe95c9c_.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: horizon-hardyzl/HUSTPORT path: /migrations/versions/90d4efe95c9c_.py
"""empty message
Revision ID: 90d4efe95c9c
Revises: 7220a6338cca
Create Date: 2019-10-11 17:33:54.654435
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
<|fim_suffix|> # ### command... | code_fim | medium | {
"lang": "python",
"repo": "horizon-hardyzl/HUSTPORT",
"path": "/migrations/versions/90d4efe95c9c_.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('telephone', mysql.VARCHAR(length=11), nullable=False))
# ### end Alembic commands ###<|fim_prefix|># repo: horizon-hardyzl/HUSTPORT path: /migrations/versions/90d4efe95c9c_.py
"""empty message
Revi... | code_fim | hard | {
"lang": "python",
"repo": "horizon-hardyzl/HUSTPORT",
"path": "/migrations/versions/90d4efe95c9c_.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_mass_to_fuel(self):
masses = [12, 14, 1969, 100756]
output_fuel = [2, 2, 654, 33583]
for i in range(len(masses)):
assert fuel_counter(masses[i]) == output_fuel[i]<|fim_prefix|># repo: eleijonmarck/adventofcode2019 path: /1/day1_test.py
import unittest
fr... | code_fim | medium | {
"lang": "python",
"repo": "eleijonmarck/adventofcode2019",
"path": "/1/day1_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eleijonmarck/adventofcode2019 path: /1/day1_test.py
import unittest
from day1 import fuel_counter
<|fim_suffix|> masses = [12, 14, 1969, 100756]
output_fuel = [2, 2, 654, 33583]
for i in range(len(masses)):
assert fuel_counter(masses[i]) == output_fuel[i]<|f... | code_fim | medium | {
"lang": "python",
"repo": "eleijonmarck/adventofcode2019",
"path": "/1/day1_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UnivaCorporation/tortuga path: /src/core/src/tortuga/scripts/get_resource_adapter_list.py
# Copyright 2008-2018 Univa Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the L... | code_fim | hard | {
"lang": "python",
"repo": "UnivaCorporation/tortuga",
"path": "/src/core/src/tortuga/scripts/get_resource_adapter_list.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ra in api.getResourceAdapterList():
data = {
'name': ra['name']
}
if self.getArgs().show_settings:
data['settings'] = ra['settings']
output.append(data)
print(yaml.safe_dump... | code_fim | hard | {
"lang": "python",
"repo": "UnivaCorporation/tortuga",
"path": "/src/core/src/tortuga/scripts/get_resource_adapter_list.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_dir_list(dir_name):
"""
get directory names
"""
child_dir = []
dir_list = os.listdir(dir_name)
for cur_file in dir_list:
path = os.path.join(dir_name, cur_file)
if not os.path.isdir(path):
continue
child_dir.append(path)
return child_... | code_fim | hard | {
"lang": "python",
"repo": "littletomatodonkey/models",
"path": "/PaddleNLP/dialogue_system/dialogue_general_understanding/dgu/scripts/commonlib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
load swda dataset config
"""
conf_dict = dict()
fr = io.open(conf, 'r', encoding="utf8")
for line in fr:
line = line.strip()
elems = line.split('\t')
if elems[0] not in conf_dict:
conf_dict[elems[0]] = []
conf_dict[elems[0]].append(el... | code_fim | hard | {
"lang": "python",
"repo": "littletomatodonkey/models",
"path": "/PaddleNLP/dialogue_system/dialogue_general_understanding/dgu/scripts/commonlib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: littletomatodonkey/models path: /PaddleNLP/dialogue_system/dialogue_general_understanding/dgu/scripts/commonlib.py
# -*- coding: utf-8 -*-
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this fil... | code_fim | medium | {
"lang": "python",
"repo": "littletomatodonkey/models",
"path": "/PaddleNLP/dialogue_system/dialogue_general_understanding/dgu/scripts/commonlib.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gwk/pithy path: /pithytools/bin/lc_name.py
# Dedicated to the public domain under CC0: https://creativecommons.org/publicdomain/zero/1.0/.
# rename files to have lower case extensions.
<|fim_suffix|>
def main() -> None:
parser = ArgumentParser(description='Lower case file names.')
parser.ad... | code_fim | medium | {
"lang": "python",
"repo": "gwk/pithy",
"path": "/pithytools/bin/lc_name.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main() -> None:
parser = ArgumentParser(description='Lower case file names.')
parser.add_argument('paths', nargs='+', help='Paths to explore.')
args = parser.parse_args()
for path in walk_files(*args.paths):
dir, name = split_dir_name(path)
lc_name = name.lower()
if lc_name == na... | code_fim | medium | {
"lang": "python",
"repo": "gwk/pithy",
"path": "/pithytools/bin/lc_name.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for path in walk_files(*args.paths):
dir, name = split_dir_name(path)
lc_name = name.lower()
if lc_name == name:
continue
lc_path = path_join(dir, lc_name)
try: inode = file_inode(lc_path, follow=False)
except FileNotFoundError: pass
else:
# OSX file system is cas... | code_fim | medium | {
"lang": "python",
"repo": "gwk/pithy",
"path": "/pithytools/bin/lc_name.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not verify and request.url.startswith('https'):
args.insert(1, '-k')
for k, v in sorted(request.headers.items()):
args.append('-H ' + json.dumps('{}: {}'.format(k, v)))
if request.body:
args.append('-d ' + json.dumps(request.body))
args.append(request.url)
... | code_fim | hard | {
"lang": "python",
"repo": "Hopetree/py2curl",
"path": "/py2curl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hopetree/py2curl path: /py2curl.py
# -*- coding:utf-8 -*-
import json
def render(request, debug=True, verify=False):
"""request object to curl cmd
<|fim_suffix|> if debug:
args.insert(1, '-v')
if not verify and request.url.startswith('https'):
args.insert(1, '-k')
... | code_fim | hard | {
"lang": "python",
"repo": "Hopetree/py2curl",
"path": "/py2curl.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def calculate_catalan_number(n, memo):
numerator = calculate_factorial(2 * n, memo)
denominator = calculate_factorial(n, memo) * calculate_factorial(n+1, memo)
catalan = numerator // denominator
return catalan
def solution(n):
memo = {0: 1, 1: 1}
answer = get_number_of_parenthes... | code_fim | hard | {
"lang": "python",
"repo": "coco-in-bluemoon/programmers-challenges",
"path": "/Level 4 연습문제/올바른 괄호의 갯수/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: coco-in-bluemoon/programmers-challenges path: /Level 4 연습문제/올바른 괄호의 갯수/solution.py
def get_number_of_parenthesis(num, memo):
if num in memo:
return memo[num]
counter = 0
for left in range(num):
right = num - left - 1
left_counter = get_number_of_parenthesis(le... | code_fim | hard | {
"lang": "python",
"repo": "coco-in-bluemoon/programmers-challenges",
"path": "/Level 4 연습문제/올바른 괄호의 갯수/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def calculate_catalan_number(n, memo):
numerator = calculate_factorial(2 * n, memo)
denominator = calculate_factorial(n, memo) * calculate_factorial(n+1, memo)
catalan = numerator // denominator
return catalan
def solution(n):
memo = {0: 1, 1: 1}
answer = get_number_of_parenthesi... | code_fim | medium | {
"lang": "python",
"repo": "coco-in-bluemoon/programmers-challenges",
"path": "/Level 4 연습문제/올바른 괄호의 갯수/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vicwer/bar_char_det_rec path: /bar_chart_detect/tools/char_gen.py
# -*- coding: utf-8 -*-
"""
@author: kadua
"""
import os
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from tqdm import tqdm
IMAGE_DIR = '../data'
LABEL_DIR = '../data'
... | code_fim | hard | {
"lang": "python",
"repo": "vicwer/bar_char_det_rec",
"path": "/bar_chart_detect/tools/char_gen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#rects = plt_bar('bar.png', [1,2,3], ['a', 'b', 'c'], 'test')
"""
names='groupA', 'groupB', 'groupC', 'groupD',
size=[12,11,3,30]
def plt_pie(fname, values, names, title):
assert len(names) <= 8 and len(names) >= 3
np.random.shuffle(colors)
# create a figure and set different backgr... | code_fim | hard | {
"lang": "python",
"repo": "vicwer/bar_char_det_rec",
"path": "/bar_chart_detect/tools/char_gen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""
names='groupA', 'groupB', 'groupC', 'groupD',
size=[12,11,3,30]
def plt_pie(fname, values, names, title):
assert len(names) <= 8 and len(names) >= 3
np.random.shuffle(colors)
# create a figure and set different background
plt.figure(figsize=(FIG_SIZE,FIG_SIZE), dpi=FIG_DPI)
... | code_fim | hard | {
"lang": "python",
"repo": "vicwer/bar_char_det_rec",
"path": "/bar_chart_detect/tools/char_gen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if parameters['tag_scheme'] == 'iobes':
p_tags = iobes_iob(p_tags)
for i, y_pred in enumerate(y_preds):
new_line = "%s %s" % (raw_sentence[i][0], p_tags[i])
predictions.append(new_line)
predictions.append("")
output_path = os.path.join(opts.... | code_fim | hard | {
"lang": "python",
"repo": "psorianom/tagger",
"path": "/conll_tagger.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: psorianom/tagger path: /conll_tagger.py
#!/usr/bin/env python
import glob
import os
import time
import codecs
import optparse
import numpy as np
from utils import create_input, iobes_iob, iob_ranges, zero_digits
from model import Model
from loader import cap_feature
optparser = optparse.OptionP... | code_fim | hard | {
"lang": "python",
"repo": "psorianom/tagger",
"path": "/conll_tagger.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route('/test')
def test():
with open('./settings/settings.json', 'r') as data:
data = json.load(data)
return data['preferences']
app.run(port=5000, debug=True)<|fim_prefix|># repo: ranganathsb/Lyndor path: /settings/settings.py
from flask import Flask, render_template
import json... | code_fim | easy | {
"lang": "python",
"repo": "ranganathsb/Lyndor",
"path": "/settings/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ranganathsb/Lyndor path: /settings/settings.py
from flask import Flask, render_template
import json
app = Flask(__name__)
<|fim_suffix|> return render_template('settings.html')
@app.route('/test')
def test():
with open('./settings/settings.json', 'r') as data:
data = json.load(d... | code_fim | easy | {
"lang": "python",
"repo": "ranganathsb/Lyndor",
"path": "/settings/settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render_template('settings.html')
@app.route('/test')
def test():
with open('./settings/settings.json', 'r') as data:
data = json.load(data)
return data['preferences']
app.run(port=5000, debug=True)<|fim_prefix|># repo: ranganathsb/Lyndor path: /settings/settings.py
from fl... | code_fim | easy | {
"lang": "python",
"repo": "ranganathsb/Lyndor",
"path": "/settings/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: titilambert/home-assistant path: /homeassistant/components/knx/notify.py
"""Support for KNX/IP notification services."""
from xknx.devices import Notification as XknxNotification
from homeassistant.components.notify import BaseNotificationService
from homeassistant.core import callback
from . i... | code_fim | hard | {
"lang": "python",
"repo": "titilambert/home-assistant",
"path": "/homeassistant/components/knx/notify.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class KNXNotificationService(BaseNotificationService):
"""Implement demo notification service."""
def __init__(self, devices: XknxNotification):
"""Initialize the service."""
self.devices = devices
@property
def targets(self):
"""Return a dictionary of registered... | code_fim | hard | {
"lang": "python",
"repo": "titilambert/home-assistant",
"path": "/homeassistant/components/knx/notify.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Implement demo notification service."""
def __init__(self, devices: XknxNotification):
"""Initialize the service."""
self.devices = devices
@property
def targets(self):
"""Return a dictionary of registered targets."""
ret = {}
for device in self... | code_fim | hard | {
"lang": "python",
"repo": "titilambert/home-assistant",
"path": "/homeassistant/components/knx/notify.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexmihalyk23/SummerSchool2021 path: /yolo_lesson.py
import cv2
import numpy as np
# https://www.murtazahassan.com/yolo-v3-using-opencv-p-2/
cap = cv2.VideoCapture(0)
# cap = cv2.VideoCapture("C:\\Users\\alexm\\Videos\\VID_20190919_204244.mp4")
whT = 256
confThreshold = 0.5
nmsThreshold = 0.2
##... | code_fim | hard | {
"lang": "python",
"repo": "alexmihalyk23/SummerSchool2021",
"path": "/yolo_lesson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in indices:
print(indices)
# мы видим что у нас есть еще одна скобка
# чтобы ее убрать просто напишем так
i = i[0]
# print(i)
# print(bbox)
box = bbox[i]
# print(classNames)
# print(classIds[i]) # номер нашего класса
... | code_fim | hard | {
"lang": "python",
"repo": "alexmihalyk23/SummerSchool2021",
"path": "/yolo_lesson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print(scores)
# и теперь берем максимальное значение
classId = np.argmax(scores)
# теперь в переменную confedence передаем наиболее вероятный элемент в scores
confidence = scores[classId]
# если confidence больше нашего значения
... | code_fim | hard | {
"lang": "python",
"repo": "alexmihalyk23/SummerSchool2021",
"path": "/yolo_lesson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> diffbrowsers = DiffBrowsers(gfr_instance_url=args.gfr_url,
gfr_is_local=args.gfr_local,
dst_dir=args.output_dir,
browsers=browsers_to_test)
if args.command == 'new':
fonts_before = 'from-google... | code_fim | hard | {
"lang": "python",
"repo": "graphicore/diffbrowsers",
"path": "/Lib/diffbrowsers/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: graphicore/diffbrowsers path: /Lib/diffbrowsers/__main__.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Browserdiff
~~~~~~~~~~~
Compare two sets of fonts for regressions
Caveats, script is incredibly slow due to the Browserstack api. Fonts are
matched by filenames.
See README.md for further ... | code_fim | hard | {
"lang": "python",
"repo": "graphicore/diffbrowsers",
"path": "/Lib/diffbrowsers/__main__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def check_setup_errors(self):
return dict(
error=gettext("Unkown platform, please check your settings.")
)<|fim_prefix|># repo: AvanOsch/OctoPrint-Marlin-Flasher path: /octoprint_marlin_flasher/flasher/unsupported_flasher.py
from .base_flasher import BaseFlasher
from flask_babel import gettext
... | code_fim | easy | {
"lang": "python",
"repo": "AvanOsch/OctoPrint-Marlin-Flasher",
"path": "/octoprint_marlin_flasher/flasher/unsupported_flasher.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AvanOsch/OctoPrint-Marlin-Flasher path: /octoprint_marlin_flasher/flasher/unsupported_flasher.py
from .base_flasher import BaseFlasher
from flask_babel import gettext
<|fim_suffix|> def check_setup_errors(self):
return dict(
error=gettext("Unkown platform, please check your settings.")
)<... | code_fim | easy | {
"lang": "python",
"repo": "AvanOsch/OctoPrint-Marlin-Flasher",
"path": "/octoprint_marlin_flasher/flasher/unsupported_flasher.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ProjectFacet/facet path: /project/editorial/models/notes.py
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from . import User
#-----------------------------------------------------------------------#
# Notes:
# Note, NetworkNote, Organiza... | code_fim | hard | {
"lang": "python",
"repo": "ProjectFacet/facet",
"path": "/project/editorial/models/notes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Custom manager for notes."""
def create_note(self, owner, title, text, note_type, important):
"""Method for quick creation of a note."""
note = self.create(owner=owner, title=title, text=text, note_type=note_type, important=important)
return note
@python_2_uni... | code_fim | hard | {
"lang": "python",
"repo": "ProjectFacet/facet",
"path": "/project/editorial/models/notes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ExCiteS/geokey-epicollect path: /geokey_epicollect/tests/test_views.py
models import Project
from geokey.projects.tests.model_factories import ProjectFactory
from geokey.contributions.tests.model_factories import ObservationFactory
from geokey.contributions.tests.media.model_factories import get_... | code_fim | hard | {
"lang": "python",
"repo": "ExCiteS/geokey-epicollect",
"path": "/geokey_epicollect/tests/test_views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = ('location_lat=51.5175205&location_lon=-0.1729205&location_acc='
'20&location_alt=&location_bearing=&category={category}&'
'{field_key}_{category}={checkbox_1}%2c+{checkbox_2}'.format(
category=type1.id,
field_key=field... | code_fim | hard | {
"lang": "python",
"repo": "ExCiteS/geokey-epicollect",
"path": "/geokey_epicollect/tests/test_views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ExCiteS/geokey-epicollect path: /geokey_epicollect/tests/test_views.py
enabled = EpiCollectProjectModel.objects.create(
project=project, enabled=True
)
self.request.user = project.creator
response = self.view(self.request).render()
rendered = render_... | code_fim | hard | {
"lang": "python",
"repo": "ExCiteS/geokey-epicollect",
"path": "/geokey_epicollect/tests/test_views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jbbqqf/okapi path: /news/filters.py
# -*- coding: utf-8 -*-
from django_filters import FilterSet, CharFilter, NumberFilter, DateTimeFilter
from news.models import Event
class EventFilter(FilterSet):
author = NumberFilter(name='author', label='filter by author id')
title = CharFilter(na... | code_fim | hard | {
"lang": "python",
"repo": "jbbqqf/okapi",
"path": "/news/filters.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = Event
fields = (
'author',
'title',
'description',
'link',
'dday_on',
'dday_on',
'dday_before',
'created_after',
'created_before',
)<|fim_prefix|># repo: jbbqqf/okapi... | code_fim | hard | {
"lang": "python",
"repo": "jbbqqf/okapi",
"path": "/news/filters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PrincetonUniversity/PsyNeuLink path: /tests/documentation/test_module_docs.py
import doctest
import re
import graph_scheduler
import pytest
import psyneulink as pnl
@pytest.mark.parametrize("mod", [# Ports
pnl.core.components.ports.parameterport,
... | code_fim | hard | {
"lang": "python",
"repo": "PrincetonUniversity/PsyNeuLink",
"path": "/tests/documentation/test_module_docs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pattern, repl in repls:
# remove any group substitution strings
assert re.sub(r'\\\d', '', repl) in cls.__doc__
# where the pattern is being replaced, check that the pattern is gone
if not re.match(r'\\\d', repl):
assert not re.ma... | code_fim | hard | {
"lang": "python",
"repo": "PrincetonUniversity/PsyNeuLink",
"path": "/tests/documentation/test_module_docs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JJGO/Parallel-LSystem path: /3 Analysis/time_analysis.py
from matplotlib import pyplot
# from mpltools import style
import prettyplotlib as ppl
# from mpltools import layout
from collections import defaultdict
# style.use('ggplot')
# figsize = layout.figaspect(scale=1.2)
# ps = [1,2,4,8]
sto... | code_fim | hard | {
"lang": "python",
"repo": "JJGO/Parallel-LSystem",
"path": "/3 Analysis/time_analysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fig = pyplot.figure()
ax = fig.add_subplot(111)
ax.plot(ps,ps, 'g.-',label='Ideal')
for mode in modes:
color, label = properties[mode]
avs = stored_avs[mode]
ax.plot(ps,[avs[1]/avs[p] for p in ps], color,label=label)
pyplot.xlabel('Processors')
pyplot.ylabel('SpeedUp')
# pyplot.title('Compa... | code_fim | hard | {
"lang": "python",
"repo": "JJGO/Parallel-LSystem",
"path": "/3 Analysis/time_analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
pipeline (list[Task]): A list of curried ``Task`` ready to be
run using data from ``pipe``. This list may be constructed as the
output of :ref:`setup_pipeline`, for example.
pipe (dict): Dictionary storing ``data`` and ``record`` information.
Returns:... | code_fim | medium | {
"lang": "python",
"repo": "c11/yatsm",
"path": "/yatsm/pipeline/_exec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
dask.delayed: A delayed pipeline ready to be executed
"""
_pipeline = delayed(pipeline[0].curry())(pipe)
for task in pipeline[1:]:
_pipeline = delayed(task.curry())(_pipeline)
return _pipeline<|fim_prefix|># repo: c11/yatsm path: /yatsm/pipeline/_exec.py
""" ... | code_fim | hard | {
"lang": "python",
"repo": "c11/yatsm",
"path": "/yatsm/pipeline/_exec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: c11/yatsm path: /yatsm/pipeline/_exec.py
""" Functions for handling the execution of a pipeline graph
"""
import logging
from dask import delayed
<|fim_suffix|>def delay_pipeline(pipeline, pipe):
""" Return a ``dask.delayed`` pipeline ready to execute
Args:
pipeline (list[Task]... | code_fim | medium | {
"lang": "python",
"repo": "c11/yatsm",
"path": "/yatsm/pipeline/_exec.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if uprn in [
"200000670794", # TF16RB -> TF15GH : 27A Castle Houses, Castle Street, Hadley, Telford, Shropshire
"10024238030", # TF87BJ -> TF87DN : Annexe At Greenacres, Buildwas Road, Ironbridge, Telford, Shropshire
]:
rec["accept_suggestion"] = False... | code_fim | hard | {
"lang": "python",
"repo": "dantagg/UK-Polling-Stations",
"path": "/polling_stations/apps/data_collection/management/commands/import_telford.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> should_plot_test = {
'episode_reward': plt.figure("Test Reward").gca(),
'nb_steps': plt.figure("Test Steps").gca(),
}
for k, v in should_plot_test.items():
v.plot(agent.test_history[k])
v.set_xlabel("Test Episodes")
v.xaxis.set_major_locator(MaxNLocator(integer=True))
should_pl... | code_fim | hard | {
"lang": "python",
"repo": "AndreLaranjeira/RL-Risk",
"path": "/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
ans = str(input("Deseja calcular e exibir os gráficos das métricas?\nO nome será {}.(S/n) ".format(name)))
if ans.lower() != 'n':
should_plot = {
'episode_reward': plt.figure("Reward").gca(),
'nb_episode_steps': plt.figure("Steps").gca(),
}
for k, v in should_plot.items():
v.plot(agent.... | code_fim | medium | {
"lang": "python",
"repo": "AndreLaranjeira/RL-Risk",
"path": "/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AndreLaranjeira/RL-Risk path: /src/main.py
# Program to learn how to play War based on reinforcement learning.
# Package imports:
# User imports:
from riskai import StupidAI
from riskenv import *
from riskplayer import PlayerInfo
from riskagent import *
import logging
import matplotlib.pyplot a... | code_fim | hard | {
"lang": "python",
"repo": "AndreLaranjeira/RL-Risk",
"path": "/src/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> LD_val = LineData.values
S_ij = []
P_ij = []
Q_ij = []
i_buses = LD_val[0:,0]
j_buses = LD_val[0:,1]
violation = []
for i in range (0, len(LineData)):
B_tot = (LD_val[i:i+1,4])
V_i = sys_Data[(int(LD_val[i:i+1,0]))-1:(int(LD_val[i:i+1,0])),1]
... | code_fim | hard | {
"lang": "python",
"repo": "BBeatyUW/EE454",
"path": "/PowerSysAnalysis_HeaderFile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BBeatyUW/EE454 path: /PowerSysAnalysis_HeaderFile.py
+ .5B(From==i || To ==i)
sys_Y[i][j] = np.sum(line_Y[np.array(line_From==i+1) + np.array(line_To==i+1)]) \
+.5j*np.sum(line_B[np.array(line_From==i+1) + np.array(line_To==i+1)])
elif i<j: #... | code_fim | hard | {
"lang": "python",
"repo": "BBeatyUW/EE454",
"path": "/PowerSysAnalysis_HeaderFile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if(i==j):
J_ij = P_i-G_ij*(V_i**2)
else:
J_ij = -V_i*V_j*(G_ij*np.cos(T_i-T_j)+B_ij*np.sin(T_i-T_j))
return J_ij
"""
Determines Jacobian value for a given J_22 cell (dQ/dV)
Takes in: i, j, n, V_i, V_j, T_i, T_j, P_i, Q_i, G_ij, B_ij
Returns Jacobian cell value
"""
d... | code_fim | hard | {
"lang": "python",
"repo": "BBeatyUW/EE454",
"path": "/PowerSysAnalysis_HeaderFile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __unicode__(self):
return self.description<|fim_prefix|># repo: 7h3kk1d/picture_ranking path: /photos/models.py
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Photo(models.Model):
<|fim_middle|> image = models.ImageField()
... | code_fim | hard | {
"lang": "python",
"repo": "7h3kk1d/picture_ranking",
"path": "/photos/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 7h3kk1d/picture_ranking path: /photos/models.py
from django.db import models
from django.contrib.auth.models import User
<|fim_suffix|> image = models.ImageField()
upload_date = models.DateTimeField('date uploaded')
rating = models.IntegerField()
description = models.CharField(max... | code_fim | easy | {
"lang": "python",
"repo": "7h3kk1d/picture_ranking",
"path": "/photos/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @overrides
def value(self, distribution: Distribution) -> int:
µ = distribution.µ
x = 0
m = 1.0
while True:
m *= random.uniform()
if m < exp(-µ):
break
else:
x += 1
return x
@final
class N... | code_fim | hard | {
"lang": "python",
"repo": "fedorpashin/statistical-modeling",
"path": "/statistical_modeling/distributions/poisson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fedorpashin/statistical-modeling path: /statistical_modeling/distributions/poisson.py
from .base import (
DiscreteDistribution,
DiscreteDistributionAlgorithm,
DistributionMean,
DistributionVariance,
)
from dataclasses import dataclass
from final_class import final
from overrides i... | code_fim | hard | {
"lang": "python",
"repo": "fedorpashin/statistical-modeling",
"path": "/statistical_modeling/distributions/poisson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return super().__new__(cls, cls.__value(distribution))
@staticmethod
def __value(distribution: Distribution) -> float:
µ = distribution.µ
return µ
@final
class Variance(DistributionVariance):
__distribution: Distribution
def __new__(cls, distribution: Distributi... | code_fim | hard | {
"lang": "python",
"repo": "fedorpashin/statistical-modeling",
"path": "/statistical_modeling/distributions/poisson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if command.instruction() > 2 and command.instruction() <= 4:
params = [params[0]]
logging.info("INFO -> Collected paramters: {0}".format(params))
return params
def translate(self, code):
trans = str(code).split(',')
trans = list(map(int, ... | code_fim | hard | {
"lang": "python",
"repo": "timgrossmann/aoc-2019",
"path": "/day05/python/haro87/enterprise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timgrossmann/aoc-2019 path: /day05/python/haro87/enterprise.py
import logging
from enum import Enum
logging.basicConfig(level=logging.ERROR)
class Instruction(Enum):
ADD = 1
MULTIPLY = 2
STORE = 3
OUTPUT = 4
JUMP_IF_TRUE = 5
JUMP_IF_FALSE = 6
LESS_THAN = 7
EQUALS... | code_fim | hard | {
"lang": "python",
"repo": "timgrossmann/aoc-2019",
"path": "/day05/python/haro87/enterprise.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return params
def translate(self, code):
trans = str(code).split(',')
trans = list(map(int, trans))
return trans
def execute(self, commands):
output = []
count = 0
while count <= len(commands):
c = commands[co... | code_fim | hard | {
"lang": "python",
"repo": "timgrossmann/aoc-2019",
"path": "/day05/python/haro87/enterprise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
# make sure dict is non-empty
assert len(ga_input_dict)
# make sure it is actually a dictionary
assert isinstance(ga_input_dict, dict)
# key names
key_names = {"num_mevs", "num_slots", "num_filled", "num_geoms",
"num_atoms", "t_size", "num_muts", "num_swaps... | code_fim | hard | {
"lang": "python",
"repo": "PaulWAyers/Kaplan",
"path": "/kaplan/ga_input.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PaulWAyers/Kaplan path: /kaplan/ga_input.py
"""This module reads and verifies the input related
to the genetic algorithm. It has two functions:
read_ga_input, which takes a str as an argument,
and verify_ga_input, which takes a dict as an
argument. This module is called by the gac
module."""
NUM... | code_fim | hard | {
"lang": "python",
"repo": "PaulWAyers/Kaplan",
"path": "/kaplan/ga_input.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 'RCToyHMM'
def get_data_info():
return 'Toy HMM data with reverse-cycle transition matrix.'
D = 2
K = 8
initPi = 1.0 / K * np.ones(K)
transPi = np.asarray([
[.01, .99, 0, 0, 0, 0, 0, 0],
[0, .01, .99, 0, 0, 0, 0, 0],
[.85, 0, 0, .15, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0]... | code_fim | hard | {
"lang": "python",
"repo": "bnpy/bnpy",
"path": "/bnpy/datasets/zzz_unsupported/RCToyHMM.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bnpy/bnpy path: /bnpy/datasets/zzz_unsupported/RCToyHMM.py
'''
RCToyHMM: Reverse-cycles toy dataset
From Foti et al. "Stochastic Variational inference for Hidden Markov Models"
'''
import numpy as np
from bnpy.data import GroupXData
from bnpy.viz import GaussViz
def get_data(seed=123456, nDocT... | code_fim | hard | {
"lang": "python",
"repo": "bnpy/bnpy",
"path": "/bnpy/datasets/zzz_unsupported/RCToyHMM.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Each iteration generates one time-series/sequence
# with starting state deterministically rotating among all states
for i in range(nDocTotal):
Z = list()
X = list()
initState = i % K
initX = prng.multivariate_normal(mus[initState, :],
... | code_fim | hard | {
"lang": "python",
"repo": "bnpy/bnpy",
"path": "/bnpy/datasets/zzz_unsupported/RCToyHMM.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: calebpeffer/Maji_Quest path: /character.py
from random import randint
class Character():
def __init__(self, gender: bool(), tattoos, inventory = dict(), name: str(), alive = True, level = 1):
self.gender = c.MALE
self.level = level
if spells == None:
self.... | code_fim | hard | {
"lang": "python",
"repo": "calebpeffer/Maji_Quest",
"path": "/character.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if new_name.is_identifier():
print("A name is the individuals most important trait, for it bestows the magician control over their very makeup; whether it be magical, physical, or devine. Your name must:")
print("\n")
print(format_bullet("A name must start with... | code_fim | hard | {
"lang": "python",
"repo": "calebpeffer/Maji_Quest",
"path": "/character.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Superficial check if some key tables are missing
missing_keys = set(REQUIRED_TABLES) - set(solution.data_vars)
if len(missing_keys) > 0:
logging.warning('Solution {} missing tables: '
'{}'.format(path, missing_keys))
def read_netcdf(path):
"""Read model ... | code_fim | hard | {
"lang": "python",
"repo": "csv2000/calliope-source-csv",
"path": "/calliope/read.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: csv2000/calliope-source-csv path: /calliope/read.py
"""
Copyright (C) 2013-2016 Stefan Pfenninger.
Licensed under the Apache 2.0 License (see LICENSE file).
read.py
~~~~~~~
Functions to read saved model results.
"""
import glob
import logging
import os
import pandas as pd
import xarray as xr... | code_fim | hard | {
"lang": "python",
"repo": "csv2000/calliope-source-csv",
"path": "/calliope/read.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qckpckt/nand2tetris path: /projects/06/hack_assembler/symbol_table.py
CORE_SYMBOLS = {
"R0": 0,
"R1": 1,
"R2": 2,
"R3": 3,
"R4": 4,
"R5": 5,
"R6": 6,
"R7": 7,
"R8": 8,
"R9": 9,
"R10": 10,
"R11": 11,
"R12": 12,
"R13": 13,
"R14": 14,
... | code_fim | hard | {
"lang": "python",
"repo": "qckpckt/nand2tetris",
"path": "/projects/06/hack_assembler/symbol_table.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add(self, symbol, value):
"""Add symbol with value value to symbol table."""
if symbol in self.symbol_map:
raise ValueError(f"symbol {symbol} already exists in map.")
self.symbol_map[symbol] = value<|fim_prefix|># repo: qckpckt/nand2tetris path: /projects/06/ha... | code_fim | hard | {
"lang": "python",
"repo": "qckpckt/nand2tetris",
"path": "/projects/06/hack_assembler/symbol_table.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Retrieve the value of a symbol.
If it does not yet exist, assign it the value of self.symbol_counter and increment self.symbol_counter."""
if symbol not in self.symbol_map:
self.symbol_map[symbol] = self.symbol_counter
self.symbol_counter += 1
ret... | code_fim | hard | {
"lang": "python",
"repo": "qckpckt/nand2tetris",
"path": "/projects/06/hack_assembler/symbol_table.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> string = ""
string += self.name + " • "
string += self.type + " • "
string += self.accuracy + " • "
string += self.concealability + " • "
string += self.availability + " • "
string += self.damage_ammo + " • "
string += self.num_shots + " • "
... | code_fim | hard | {
"lang": "python",
"repo": "ecoberley/The-Refs-Interface",
"path": "/src/weapon.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ecoberley/The-Refs-Interface path: /src/weapon.py
class Weapon:
name = ""
type = ""
accuracy = ""
concealability = ""
availability = ""
damage_ammo = ""
num_shots = ""
rof = ""
reliability = ""
range = ""
cost = ""
def __init__(self, row):
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "ecoberley/The-Refs-Interface",
"path": "/src/weapon.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name = str(row[0])
self.type = str(row[1])
self.accuracy = str(row[2])
self.concealability = str(row[3])
self.availability = str(row[4])
self.damage_ammo = str(row[5])
self.num_shots = str(row[6])
self.rof = str(row[7])
self.reli... | code_fim | medium | {
"lang": "python",
"repo": "ecoberley/The-Refs-Interface",
"path": "/src/weapon.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shahraizali/Bank path: /v1/banks/urls.py
from django.urls import path
<|fim_suffix|> # Banks
path('banks', BankView.as_view()),
path('banks/<str:node_identifier>', BankDetail.as_view()),
]<|fim_middle|>from .views.bank import BankDetail, BankView
urlpatterns = [
| code_fim | medium | {
"lang": "python",
"repo": "shahraizali/Bank",
"path": "/v1/banks/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Banks
path('banks', BankView.as_view()),
path('banks/<str:node_identifier>', BankDetail.as_view()),
]<|fim_prefix|># repo: shahraizali/Bank path: /v1/banks/urls.py
from django.urls import path
<|fim_middle|>from .views.bank import BankDetail, BankView
urlpatterns = [
| code_fim | medium | {
"lang": "python",
"repo": "shahraizali/Bank",
"path": "/v1/banks/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
# Banks
path('banks', BankView.as_view()),
path('banks/<str:node_identifier>', BankDetail.as_view()),
]<|fim_prefix|># repo: shahraizali/Bank path: /v1/banks/urls.py
from django.urls import path
<|fim_middle|>from .views.bank import BankDetail, BankView
| code_fim | easy | {
"lang": "python",
"repo": "shahraizali/Bank",
"path": "/v1/banks/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_prefix = options.input_prefix
# Assign year
if mode == "year":
ymd_vals = [getattr(options, attr)
for attr in ["year", "month", "day"]]
year, month, day = map(lambda x: int(x) if x else None, ymd_vals)
return getpaths_fromymd(input_prefix, year, mo... | code_fim | hard | {
"lang": "python",
"repo": "kleopatra999/filemerge",
"path": "/filemerge/filemerge.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kleopatra999/filemerge path: /filemerge/filemerge.py
# Copyright 2016 Intuit
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICE... | code_fim | hard | {
"lang": "python",
"repo": "kleopatra999/filemerge",
"path": "/filemerge/filemerge.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.