text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> for page_name in iter_page_names():
metadata, text_html = load_doc_page(page_name)
if text_html is None:
continue
title = get_page_title(page_name, metadata)
rank = sum(
title.lower().count(word) * 2 + text_html.lowe... | code_fim | hard | {
"lang": "python",
"repo": "tjresearch/research-theo_john",
"path": "/manager/director/apps/docs/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tjresearch/research-theo_john path: /manager/director/apps/docs/views.py
# SPDX-License-Identifier: MIT
# (c) 2019 The TJHSST Director 4.0 Development Team & Contributors
import os
import re
from typing import Any, Dict, List, Tuple, Union
from django.contrib.auth.decorators import login_requir... | code_fim | hard | {
"lang": "python",
"repo": "tjresearch/research-theo_john",
"path": "/manager/director/apps/docs/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hattne/dials path: /algorithms/scaling/test_plots.py
"""
Tests for the dials.algorithms.scaling.plots module
"""
from __future__ import absolute_import, division, print_function
from dials.algorithms.scaling.plots import (
plot_scaling_models,
plot_outliers,
normal_probability_plot,
... | code_fim | medium | {
"lang": "python",
"repo": "hattne/dials",
"path": "/algorithms/scaling/test_plots.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test outlier plot, for standard and null data."""
data = {"x": [1.0, 2.0], "y": [0.0, 1.0], "z": [1.0, 1.0], "image_size": [100, 200]}
d = plot_outliers(data)
assert "outliers_vs_z" in d
assert "outlier_xy_positions" in d
data = {"x": [], "y": [], "z": [], "image_size": [100, 2... | code_fim | hard | {
"lang": "python",
"repo": "hattne/dials",
"path": "/algorithms/scaling/test_plots.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Contador: {}".format(contador))<|fim_prefix|># repo: CodeXfull/Numpy path: /numpy_condição_5.py
import numpy as np
<|fim_middle|>array = np.arange(20)
print(array)
cond = array > 5
contador = 0
for elemento in cond:
if elemento:
contador += 1
| code_fim | medium | {
"lang": "python",
"repo": "CodeXfull/Numpy",
"path": "/numpy_condição_5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CodeXfull/Numpy path: /numpy_condição_5.py
import numpy as np
<|fim_suffix|>print("Contador: {}".format(contador))<|fim_middle|>array = np.arange(20)
print(array)
cond = array > 5
contador = 0
for elemento in cond:
if elemento:
contador += 1
| code_fim | medium | {
"lang": "python",
"repo": "CodeXfull/Numpy",
"path": "/numpy_condição_5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pythonitalia/pycon path: /backend/participants/migrations/0002_add_more_socials_to_participants.py
# Generated by Django 3.2.12 on 2022-11-19 00:30
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('participants', '0001_store_participants'),
]
operat... | code_fim | medium | {
"lang": "python",
"repo": "pythonitalia/pycon",
"path": "/backend/participants/migrations/0002_add_more_socials_to_participants.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='participant',
name='facebook_url',
field=models.CharField(blank=True, max_length=2048),
),
migrations.AddField(
model_name='participant',
name='instagram_handle',
... | code_fim | medium | {
"lang": "python",
"repo": "pythonitalia/pycon",
"path": "/backend/participants/migrations/0002_add_more_socials_to_participants.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tedlu-tw/Practicing-with-Leetcode path: /0136-Single-Number.py
class Solution:
def singleNumber(self, nums: List[int]) -> int:
for i in range(0, len(nums), 1):
<|fim_suffix|>ontinue
else:
return nums[i]<|fim_middle|> if nums.count(nums[i]) > 1:
... | code_fim | easy | {
"lang": "python",
"repo": "tedlu-tw/Practicing-with-Leetcode",
"path": "/0136-Single-Number.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ontinue
else:
return nums[i]<|fim_prefix|># repo: tedlu-tw/Practicing-with-Leetcode path: /0136-Single-Number.py
class Solution:
def singleNumber(self, nums: List[i<|fim_middle|>nt]) -> int:
for i in range(0, len(nums), 1):
if nums.count(nums[i]) > 1:
... | code_fim | hard | {
"lang": "python",
"repo": "tedlu-tw/Practicing-with-Leetcode",
"path": "/0136-Single-Number.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# form exception message
message = render_template("error/ex_message.html",
request=request,
session=session,
traceback=traceback.format_exc())
# get admin email
admins = tools.get_conf(host, '-1', 'admins', '')
recipients = []
for admin in jinja.getlist(a... | code_fim | hard | {
"lang": "python",
"repo": "unkyulee/elastic-cms",
"path": "/src/web/util/web_mod.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_module(navigation):
# Imports from Web folder and looks for a module
path = "web.modules.{}.control".format(navigation['module']['name'])
mod = importlib.import_module(path)
return mod
def get_nav_list(host, navigation):
query = "site_id:{} AND is_displayed:1".format(navigat... | code_fim | hard | {
"lang": "python",
"repo": "unkyulee/elastic-cms",
"path": "/src/web/util/web_mod.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: unkyulee/elastic-cms path: /src/web/util/web_mod.py
import os
import json
import importlib
import traceback
from flask import session, render_template, request
import lib.es as es
import web.util.tools as tools
import web.util.jinja as jinja
import web.modules.admin.services.notification as noti... | code_fim | hard | {
"lang": "python",
"repo": "unkyulee/elastic-cms",
"path": "/src/web/util/web_mod.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#
# 3.3.3 定义模型
# 在上一节从零开始的实现中,我们需要定义模型参数,并使用它们一步步描述模型是怎样计算的。
# 当模型结构变得更复杂时,这些步骤将变得更繁琐。
# 其实,PyTorch提供了大量预定义的层,这使我们只需关注使用哪些层来构造模型。
# 下面将介绍如何使用PyTorch更简洁地定义线性回归。
#
# 首先,导入torch.nn模块。
# 实际上,“nn”是neural networks(神经网络)的缩写。
# 顾名思义,该模块定义了大量神经网络的层。
# 之前我们已经用过了autograd,而nn就是利用autograd来定义模型。
# nn的核心数据结构是Module,它是一... | code_fim | hard | {
"lang": "python",
"repo": "RoRyou/nn",
"path": "/3_3_brief_linreg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RoRyou/nn path: /3_3_brief_linreg.py
import torch
from time import time
from IPython import display
import numpy as np
import matplotlib.pyplot as plt
import random
import torch.utils.data as Data
from torch.nn import init
import torch.nn as nn
# 3.3.1 生成数据集
# 我们生成与上一节中相同的数据集。其中features是训练数据特征,la... | code_fim | hard | {
"lang": "python",
"repo": "RoRyou/nn",
"path": "/3_3_brief_linreg.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>init.normal_(net[0].weight, mean=0, std=0.01)
init.constant_(net[0].bias, val=0) # 也可以直接修改bias的data: net[0].bias.data.fill_(0)
# 注:如果这里的net是用3.3.3节一开始的代码自定义的,那么上面代码会报错,net[0].weight应改为net.linear.weight,bias亦然。因为net[0]这样根据下标访问子模块的写法只有当net是个ModuleList或者Sequential实例时才可以,详见4.1节。
# 3.3.5 定义损失函数
# PyTorch在nn模... | code_fim | hard | {
"lang": "python",
"repo": "RoRyou/nn",
"path": "/3_3_brief_linreg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mensagem = input("Digite a mensagem para decodificar: ")
print("Mensagem decodificada: ", mostra(mensagem))<|fim_prefix|># repo: brunohprada/Python-para-zumbis path: /exercicios-e-exemplos/criptoCesar.py
'''
Programa de xemplo utilizando a criptografia de Cesar Desenvolvido por uma aluna de 12 anos
'''
... | code_fim | easy | {
"lang": "python",
"repo": "brunohprada/Python-para-zumbis",
"path": "/exercicios-e-exemplos/criptoCesar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brunohprada/Python-para-zumbis path: /exercicios-e-exemplos/criptoCesar.py
'''
Programa de xemplo utilizando a criptografia de Cesar Desenvolvido por uma aluna de 12 anos
'''
def esconde(msg):
s = ''
for c in msg: s += chr(ord(c) + 30000)
return s
<|fim_suffix|> s = ''
for c ... | code_fim | easy | {
"lang": "python",
"repo": "brunohprada/Python-para-zumbis",
"path": "/exercicios-e-exemplos/criptoCesar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Mensagem codificada: ", esconde(mensagem))
mensagem = input("Digite a mensagem para decodificar: ")
print("Mensagem decodificada: ", mostra(mensagem))<|fim_prefix|># repo: brunohprada/Python-para-zumbis path: /exercicios-e-exemplos/criptoCesar.py
'''
Programa de xemplo utilizando a criptografia ... | code_fim | hard | {
"lang": "python",
"repo": "brunohprada/Python-para-zumbis",
"path": "/exercicios-e-exemplos/criptoCesar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marroni1103/exercicios-pyton path: /pythonexercicios/ex058-jogoadivinhaV2.py
from random import randint
from time import sleep
while True:
npensado = randint(0, 10)
<|fim_suffix|> print('-='*22)
print('Pensei em um numero entre 0 e 10...')
print('-='*22)
numero = int(input('Te... | code_fim | medium | {
"lang": "python",
"repo": "marroni1103/exercicios-pyton",
"path": "/pythonexercicios/ex058-jogoadivinhaV2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(f'Parabens... vc acertou.. tinha pensado no {npensado}.')
print(f'Você precisou de {palpites} chances para acertar.')
r = input(f'QUER JOGAR NOVAMENTE? [S/N] ').strip().upper()[0]
if r == 'N':
break<|fim_prefix|># repo: marroni1103/exercicios-pyton path: /pythonexercicios/ex... | code_fim | hard | {
"lang": "python",
"repo": "marroni1103/exercicios-pyton",
"path": "/pythonexercicios/ex058-jogoadivinhaV2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kaadi2000/Sudoku-Solver path: /Sudoku Solver.py
import numpy
def possiblity_check(y,x,n):
global sudoku_puzzle
for i in range(9):
if sudoku_puzzle[y][i] == n:
return False
if sudoku_puzzle[i][x] == n:
return False
x0=(x//3)*3
y0=(... | code_fim | medium | {
"lang": "python",
"repo": "kaadi2000/Sudoku-Solver",
"path": "/Sudoku Solver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sudoku_puzzle = []
try:
for i in range(9):
temp=[int(x) for x in input().split()]
if len(temp) != 9:
raise "Invalid Length"
sudoku_puzzle.append(temp)
except:
print("Error Occured")
else:
solution()<|fim_prefix|># repo: kaadi2000/Sudoku-Solver pa... | code_fim | hard | {
"lang": "python",
"repo": "kaadi2000/Sudoku-Solver",
"path": "/Sudoku Solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ax.tick_params(**kwargs)
def show(self):
self.fig.show()
def clear(self):
self.fig.clf()
def vline(self, x=0, **kwargs):
self.ax.axvline(x=x, **kwargs)
def hline(self, y=0, **kwargs):
self.ax.axhline(y=y, **kwargs)
def save(self, output... | code_fim | hard | {
"lang": "python",
"repo": "dwhan89/pitas",
"path": "/pitas/visualize.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dwhan89/pitas path: /pitas/visualize.py
#
# visualize.py
##
#
import pitas
import os
import matplotlib.pyplot as plt
class plotter(object):
def __init__(self, **kargs):
xscale, yscale = 'linear', 'linear'
if pitas.util.get_from_dict(kargs, 'xscale'):
xscale = k... | code_fim | hard | {
"lang": "python",
"repo": "dwhan89/pitas",
"path": "/pitas/visualize.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ntomita/maf-lib path: /maflib/__main__.py
#!/usr/bin/env python3
<|fim_suffix|>
if __name__ == "__main__":
main()
# __END__<|fim_middle|>try:
from maflib import __version__
except ImportError:
__version__ = "0.0.0"
def main():
print(__version__)
| code_fim | medium | {
"lang": "python",
"repo": "ntomita/maf-lib",
"path": "/maflib/__main__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(__version__)
if __name__ == "__main__":
main()
# __END__<|fim_prefix|># repo: ntomita/maf-lib path: /maflib/__main__.py
#!/usr/bin/env python3
try:
from maflib import __version__
except ImportError:
__version__ = "0.0.0"
<|fim_middle|>
def main():
| code_fim | easy | {
"lang": "python",
"repo": "ntomita/maf-lib",
"path": "/maflib/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
main()
# __END__<|fim_prefix|># repo: ntomita/maf-lib path: /maflib/__main__.py
#!/usr/bin/env python3
try:
from maflib import __version__
except ImportError:
__version__ = "0.0.0"
<|fim_middle|>def main():
print(__version__)
| code_fim | easy | {
"lang": "python",
"repo": "ntomita/maf-lib",
"path": "/maflib/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: suen049/AdMRL path: /slbo/partial_envs.py
import numpy as np
from slbo.envs.mujoco.half_cheetah_env import HalfCheetahEnv
from slbo.envs.mujoco.ant_env import AntEnv
from slbo.envs.mujoco.hopper_env import HopperEnv
from slbo.envs.mujoco.walker_env import WalkerEnv
from slbo.envs.mujoco.ant_task_... | code_fim | medium | {
"lang": "python",
"repo": "suen049/AdMRL",
"path": "/slbo/partial_envs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def make_env(id: str, task_config=None):
if id in task_envs:
env = task_envs[id](task_config=task_config)
else:
raise Exception(f"env {id} not recognized")
if not hasattr(env, 'reward_range'):
env.reward_range = (-np.inf, np.inf)
if not hasattr(env, 'metada... | code_fim | medium | {
"lang": "python",
"repo": "suen049/AdMRL",
"path": "/slbo/partial_envs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: airmoor/learnweb path: /blog/migrations/0011_questionanswer_questionpage.py
# Generated by Django 3.0.4 on 2020-04-09 11:21
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
class Migration(migrations.Migration):
<|fim_suffix|> operations =... | code_fim | hard | {
"lang": "python",
"repo": "airmoor/learnweb",
"path": "/blog/migrations/0011_questionanswer_questionpage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='QuestionPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
... | code_fim | hard | {
"lang": "python",
"repo": "airmoor/learnweb",
"path": "/blog/migrations/0011_questionanswer_questionpage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> import sys
submission_checker_dir = os.path.join(mlperf_path, "tools", "submission")
sys.path.append(submission_checker_dir)
if not os.path.exists(os.path.join(submission_checker_dir, "submission_checker.py")):
shutil.copy(os.path.join(submission_checker_dir,"submission-checker.p... | code_fim | hard | {
"lang": "python",
"repo": "mlcommons/ck",
"path": "/cm-mlops/script/get-mlperf-inference-src/customize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_valid_models(mlperf_version, mlperf_path):
import sys
submission_checker_dir = os.path.join(mlperf_path, "tools", "submission")
sys.path.append(submission_checker_dir)
if not os.path.exists(os.path.join(submission_checker_dir, "submission_checker.py")):
shutil.copy(os.p... | code_fim | hard | {
"lang": "python",
"repo": "mlcommons/ck",
"path": "/cm-mlops/script/get-mlperf-inference-src/customize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mlcommons/ck path: /cm-mlops/script/get-mlperf-inference-src/customize.py
from cmind import utils
import os
import shutil
def preprocess(i):
os_info = i['os_info']
# if os_info['platform'] == 'windows':
# return {'return':1, 'error': 'Windows is not supported in this script yet'}... | code_fim | hard | {
"lang": "python",
"repo": "mlcommons/ck",
"path": "/cm-mlops/script/get-mlperf-inference-src/customize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return [e["artifact_group"] for e in self.events_captured if "artifact_group" in e.keys()]
def test_all_artifacts_from_same_event_have_same_group(self):
EventBroker.publish(event=TestEvent.test_failed)
groups = set(self.extract_artifact_groups())
expect(groups).to(have... | code_fim | hard | {
"lang": "python",
"repo": "filfreire/questions-three",
"path": "/optional_packages/selenium/tests/browser/test_artifact_grouping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: filfreire/questions-three path: /optional_packages/selenium/tests/browser/test_artifact_grouping.py
from unittest import TestCase, main
from expects import expect, have_length
from questions_three.constants import TestEvent
from questions_three.event_broker import EventBroker
from selenium impor... | code_fim | hard | {
"lang": "python",
"repo": "filfreire/questions-three",
"path": "/optional_packages/selenium/tests/browser/test_artifact_grouping.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_artifacts_from_different_events_have_different_groups(self):
events = 3
for n in range(events):
EventBroker.publish(event=TestEvent.test_failed)
groups = set(self.extract_artifact_groups())
expect(groups).to(have_length(events))
if "__main__" == _... | code_fim | hard | {
"lang": "python",
"repo": "filfreire/questions-three",
"path": "/optional_packages/selenium/tests/browser/test_artifact_grouping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>end = time.time()
elapsed = end -start
print(elapsed)
#connect()<|fim_prefix|># repo: cartellefo/projet path: /SQL_python/DataBasePython/connection2.py
import psycopg2
import time
start = time.time()
try:
conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' password='dbpass'"... | code_fim | medium | {
"lang": "python",
"repo": "cartellefo/projet",
"path": "/SQL_python/DataBasePython/connection2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>db_version = cur.fetchone()
print(db_version)
end = time.time()
elapsed = end -start
print(elapsed)
#connect()<|fim_prefix|># repo: cartellefo/projet path: /SQL_python/DataBasePython/connection2.py
import psycopg2
import time
start = time.time()
try:
conn = psycopg2.connect("dbname='postgres' user... | code_fim | medium | {
"lang": "python",
"repo": "cartellefo/projet",
"path": "/SQL_python/DataBasePython/connection2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cartellefo/projet path: /SQL_python/DataBasePython/connection2.py
import psycopg2
import time
start = time.time()
try:
conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' password='dbpass'")
except:
print("I am unable to connect to the database")
#cur.execute("""... | code_fim | easy | {
"lang": "python",
"repo": "cartellefo/projet",
"path": "/SQL_python/DataBasePython/connection2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tylerholland12/SPD-2.31-Testing-and-Architecture- path: /SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_superclass2.py
# by Kami Bigdely
# Extract superclass.
class Shape:
def __init__(self, x, y, visible=True):
self.x = x
self.y = y
self.visible = visible
... | code_fim | hard | {
"lang": "python",
"repo": "Tylerholland12/SPD-2.31-Testing-and-Architecture-",
"path": "/SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_superclass2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # left-bottom corner.
super().__init__(x, y, visible)
self.width = width
self.height = height
def display(self):
if self.visible:
super().display("drew the rectangle.")
def hide(self):
super().set_visible(False)
... | code_fim | medium | {
"lang": "python",
"repo": "Tylerholland12/SPD-2.31-Testing-and-Architecture-",
"path": "/SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_superclass2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
circle = Circle(0,0,10, False)
circle.set_visible(True)
circle.display()
print('center point',circle.get_center())
rect = Rectangle(10, 10, 20, 5)
rect.hide()
rect.display() # does not display because it's hidden.
rect.make_visible()
rect.di... | code_fim | hard | {
"lang": "python",
"repo": "Tylerholland12/SPD-2.31-Testing-and-Architecture-",
"path": "/SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_superclass2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model1 = OrmHasManyThroughModelStub()
model1.id = 1
model2 = OrmHasManyThroughModelStub()
model2.id = 2
model3 = OrmHasManyThroughModelStub()
model3.id = 3
relation.get_related().should_receive('new_collection').replace_with(lambda l=None: Collectio... | code_fim | hard | {
"lang": "python",
"repo": "KarthickNamakkalKrishnan/eloquent",
"path": "/tests/orm/relations/test_has_many_through.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KarthickNamakkalKrishnan/eloquent path: /tests/orm/relations/test_has_many_through.py
# -*- coding: utf-8 -*-
import arrow
from flexmock import flexmock, flexmock_teardown
from ... import EloquentTestCase
from ...utils import MockConnection
from eloquent.query.builder import QueryBuilder
from e... | code_fim | hard | {
"lang": "python",
"repo": "KarthickNamakkalKrishnan/eloquent",
"path": "/tests/orm/relations/test_has_many_through.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result1 = OrmHasManyThroughModelStub()
result1.country_id = 1
result2 = OrmHasManyThroughModelStub()
result2.country_id = 2
result3 = OrmHasManyThroughModelStub()
result3.country_id = 2
model1 = OrmHasManyThroughModelStub()
model1.id = 1
... | code_fim | hard | {
"lang": "python",
"repo": "KarthickNamakkalKrishnan/eloquent",
"path": "/tests/orm/relations/test_has_many_through.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> paper = total_data['Paper']
author = total_data['Author']
paper_author = total_data['PaperAuthor']
for (paper_id,author_id) in paper_author.keys():
if (paper_id in paper.keys()) and (author_id in author.keys()):
paper_topic = paper[paper_id]['topic_sum']
author_topic = author[author_id]['topi... | code_fim | hard | {
"lang": "python",
"repo": "leeopop/2015-CS570-Project",
"path": "/create_feature.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leeopop/2015-CS570-Project path: /create_feature.py
##header begins
from collections import defaultdict
from extract_keywords import split_line
import numpy
import csv
__do_cross = True
##header ends
def author_topic(total_data, num_topics=150):
assert('Author' in total_data.keys())
assert('Pap... | code_fim | hard | {
"lang": "python",
"repo": "leeopop/2015-CS570-Project",
"path": "/create_feature.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Isa2187/M3SC-Project1 path: /Python Code For Project 1.py
import numpy as np
import scipy as sp
import math as ma
import sys
import time
def Dijkst(ist,isp,wei):
# Dijkstra algorithm for shortest path in a graph
# ist: index of starting node
# isp: index of stopp... | code_fim | hard | {
"lang": "python",
"repo": "Isa2187/M3SC-Project1",
"path": "/Python Code For Project 1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #If we are at the end node, then compute 40%
#of the cars that are currently there to the
#nearest integer and remove them from the
#network by subtracting them from the end node
else:
... | code_fim | hard | {
"lang": "python",
"repo": "Isa2187/M3SC-Project1",
"path": "/Python Code For Project 1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # jinja2 templates
return render_template('hello.html', name="noname")
@app.route('/console', methods=['GET'])
def console():
return render_template('console.html')<|fim_prefix|># repo: kmacdough/hack-harvard path: /web/src/project/controllers/front_end.py
from flask import render_template,... | code_fim | easy | {
"lang": "python",
"repo": "kmacdough/hack-harvard",
"path": "/web/src/project/controllers/front_end.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kmacdough/hack-harvard path: /web/src/project/controllers/front_end.py
from flask import render_template, jsonify
from .. import app
@app.route('/startgame', methods=['GET'])
def hello():
<|fim_suffix|>
@app.route('/console', methods=['GET'])
def console():
return render_template('console.... | code_fim | medium | {
"lang": "python",
"repo": "kmacdough/hack-harvard",
"path": "/web/src/project/controllers/front_end.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>(y).encode('hex'),x)), rgb_tuples)
hex_tuples = map(lambda x: "".join(x), hex_tuples)
return hex_tuples<|fim_prefix|># repo: mmautner/flaskpd path: /utils.py
"""
utility functions
"""
import colorsys
def get_n_hex_colors(n=5):
hsv_tuples = [(x*1.0/n, 0.5, 0.5) for x in range(n)]
rgb_tup... | code_fim | medium | {
"lang": "python",
"repo": "mmautner/flaskpd",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mmautner/flaskpd path: /utils.py
"""
utility functions
"""
import colorsys
def get_n_hex_colors(n=5):
hsv_tuples = [(x*1.0/n, 0.5, 0.5) f<|fim_suffix|>(y).encode('hex'),x)), rgb_tuples)
hex_tuples = map(lambda x: "".join(x), hex_tuples)
return hex_tuples<|fim_middle|>or x in range(n... | code_fim | hard | {
"lang": "python",
"repo": "mmautner/flaskpd",
"path": "/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: augustjd/ups path: /ups/views/errors.py
from flask import current_app, Response
import json
import jsonschema
from .blueprint import blueprint
RESPONSE_SCHEMA = json.load(open('./schemas/response.json'))
class ErrorResponse(Exception):
def __init__(self, errors=[], status=500):
... | code_fim | hard | {
"lang": "python",
"repo": "augustjd/ups",
"path": "/ups/views/errors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_name = model_name or model.__name__
if detail is None:
if id is None:
detail = f"No {model_name} found."
else:
detail = f"No {model_name} with id {id} found."
super().__init__(
code='not-found',
... | code_fim | hard | {
"lang": "python",
"repo": "augustjd/ups",
"path": "/ups/views/errors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, model=None, model_name=None, id=None, detail=None, title=None, status=404):
model_name = model_name or model.__name__
if detail is None:
if id is None:
detail = f"No {model_name} found."
else:
detail = f"No {mo... | code_fim | hard | {
"lang": "python",
"repo": "augustjd/ups",
"path": "/ups/views/errors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not filesAndTimepointsDict:
print("NO ENV1.npy FILES FOUND, PLEASE GENERATE ENVELOPES")
exit(-1)
files = filesAndTimepointsDict.keys()
files = sorted(files)
totalTimePoints = sum([len(data) for data in filesAndTimepointsDict.values()])
print(len(filesAndTimepointsDic... | code_fim | hard | {
"lang": "python",
"repo": "tictacmenthe/F2CNN",
"path": "/scripts/processing/InputGenerator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tictacmenthe/F2CNN path: /scripts/processing/InputGenerator.py
import os
import csv
import time
from configparser import ConfigParser
import numpy
def GetListOfEnvelopeFilesAndTimepoints(labelFilename):
"""
Takes a label csv file, and generates a list of [['TEST' or 'TRAIN', filename],... | code_fim | hard | {
"lang": "python",
"repo": "tictacmenthe/F2CNN",
"path": "/scripts/processing/InputGenerator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> savePath = inputFile or (os.path.join('trainingData', 'input_data_LPF{}.npy'.format(CUTOFF) if LPF else 'input_data_NOLPF.npy'))
print("Saving as {}...".format(savePath))
os.makedirs(os.path.split(savePath)[0], exist_ok=True)
numpy.save(savePath, inputData)
numpy.save(os.path.join('tra... | code_fim | hard | {
"lang": "python",
"repo": "tictacmenthe/F2CNN",
"path": "/scripts/processing/InputGenerator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ubarkai/rulu path: /test/ruledefs/update_delete.py
from rulu import *
class Pair(Fact):
first = IntegerField()
second = IntegerField()
<|fim_suffix|>RuleDef(
match(SumByFirst[0].first, SumByFirst[1].first),
condition(fact_index(SumByFirst[0]) != fact_index(SumByFirst[1])),
a... | code_fim | medium | {
"lang": "python",
"repo": "ubarkai/rulu",
"path": "/test/ruledefs/update_delete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in (0, 1):
RuleDef(
match(MaxByFirst[0].first, MaxByFirst[1].first),
condition(MaxByFirst[i].value < MaxByFirst[1-i].value),
action(Delete(MaxByFirst[i]))
)<|fim_prefix|># repo: ubarkai/rulu path: /test/ruledefs/update_delete.py
from rulu import *
class Pair(Fact):
... | code_fim | hard | {
"lang": "python",
"repo": "ubarkai/rulu",
"path": "/test/ruledefs/update_delete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class MetricMixin:
def test_str(self):
self.assertEqual(str(self.instance), self.instance.name)
def test_get_absolute_url(self):
url_path = "/metric/%s/" % self.instance.slug
self.assertTrue(url_path in self.instance.get_absolute_url())
class TracTicketMetricTestCase(Te... | code_fim | hard | {
"lang": "python",
"repo": "django/djangoproject.com",
"path": "/dashboard/tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: django/djangoproject.com path: /dashboard/tests.py
import datetime
import json
from unittest import mock
import requests_mock
from django.core import management
from django.http import Http404
from django.test import RequestFactory, TestCase
from django_hosts.resolvers import reverse
from .mode... | code_fim | hard | {
"lang": "python",
"repo": "django/djangoproject.com",
"path": "/dashboard/tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_metric_404(self):
request = self.factory.get(
reverse("metric-detail", args=["new-tickets-week"], host="dashboard")
)
with self.assertRaisesRegex(Http404, r"Could not find metric with slug [\w-]+"):
metric_detail(request, "404")
def test_me... | code_fim | hard | {
"lang": "python",
"repo": "django/djangoproject.com",
"path": "/dashboard/tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Iristyle/ChocolateyPackages path: /EthanBrown.SublimeText2.UtilPackages/tools/PackageCache/Package Control/package_control/commands/add_channel_command.py
import re
import sublime
import sublime_plugin
from ..show_error import show_error
class AddChannelCommand(sublime_plugin.WindowCommand):
... | code_fim | hard | {
"lang": "python",
"repo": "Iristyle/ChocolateyPackages",
"path": "/EthanBrown.SublimeText2.UtilPackages/tools/PackageCache/Package Control/package_control/commands/add_channel_command.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def on_done(self, input):
"""
Input panel handler - adds the provided URL as a channel
:param input:
A string of the URL to the new channel
"""
input = input.strip()
if re.match('https?://', input, re.I) == None:
show_error(u"U... | code_fim | hard | {
"lang": "python",
"repo": "Iristyle/ChocolateyPackages",
"path": "/EthanBrown.SublimeText2.UtilPackages/tools/PackageCache/Package Control/package_control/commands/add_channel_command.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input = input.strip()
if re.match('https?://', input, re.I) == None:
show_error(u"Unable to add the channel \"%s\" since it does not appear to be served via HTTP (http:// or https://)." % input)
return
settings = sublime.load_settings('Package Control.subl... | code_fim | medium | {
"lang": "python",
"repo": "Iristyle/ChocolateyPackages",
"path": "/EthanBrown.SublimeText2.UtilPackages/tools/PackageCache/Package Control/package_control/commands/add_channel_command.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>NUTE", "MINUTE"),
("DAY", "DAY"),
],
max_length=127,
),
),
("logs", models.TextField(blank=True, null=True)),
(
"total_profit_percent",
... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/super-quant",
"path": "/sphinxquant/api/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/super-quant path: /sphinxquant/api/migrations/0001_initial.py
# Generated by Django 2.2.1 on 2019-05-10 10:23
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = []
... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/super-quant",
"path": "/sphinxquant/api/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Neoklosch/Motey path: /samples/docker/__main__.py
import signal
import sys
import docker
def signal_handler(signal, frame):
<|fim_suffix|>
def main():
client = docker.DockerClient(base_url='unix://var/run/docker.sock')
kwargs = {
'ports': {
'5238/tcp': 5239
... | code_fim | easy | {
"lang": "python",
"repo": "Neoklosch/Motey",
"path": "/samples/docker/__main__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = docker.DockerClient(base_url='unix://var/run/docker.sock')
kwargs = {
'ports': {
'5238/tcp': 5239
},
'name': 'motey_alpine'
}
client.containers.run(image='alpine', **kwargs)
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_ha... | code_fim | easy | {
"lang": "python",
"repo": "Neoklosch/Motey",
"path": "/samples/docker/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pdf_writer.integral_texte = []
pdf = lambda txt: self.pdf_writer.integral_texte.append(txt) if self.pdf_writer is not None else False
if self.zwischen_graphen and len(self.differenz_stammfunktion.funktionen) >= 1:
stammfunktion = self.differenz_stammfunktion.funkti... | code_fim | hard | {
"lang": "python",
"repo": "astroPythoner/Kurvendiskussion_Integrale_und_Wahrscheinlichkeitsrechnung",
"path": "/Integral_Frame.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astroPythoner/Kurvendiskussion_Integrale_und_Wahrscheinlichkeitsrechnung path: /Integral_Frame.py
None
graph = None
funktionen = None
parameter = None
def __init__(self, master=None, stammfunktion=None, differenz_stammfunktion=None, nullstellen=None, graph=None, parameter=None, p... | code_fim | hard | {
"lang": "python",
"repo": "astroPythoner/Kurvendiskussion_Integrale_und_Wahrscheinlichkeitsrechnung",
"path": "/Integral_Frame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while True:
t = sensor.readTemperature()
h = sensor.readHumidity()
print("Temp: {:.1f} F Humidity: {}%".format(t, h))
sleep(2.0)<|fim_prefix|># repo: mborders/rpi-temp-humidity path: /main.py
from time import sleep
from sensor import Sensor
import config
<|fim_middle|>sensor = Sensor... | code_fim | easy | {
"lang": "python",
"repo": "mborders/rpi-temp-humidity",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mborders/rpi-temp-humidity path: /main.py
from time import sleep
from sensor import Sensor
import config
<|fim_suffix|>while True:
t = sensor.readTemperature()
h = sensor.readHumidity()
print("Temp: {:.1f} F Humidity: {}%".format(t, h))
sleep(2.0)<|fim_middle|>sensor = Sensor... | code_fim | easy | {
"lang": "python",
"repo": "mborders/rpi-temp-humidity",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elaspic/elaspic-rest-api path: /src/elaspic_rest_api/jobsubmitter/monitor.py
import asyncio
import logging
import shlex
import time
from typing import Callable, Mapping, Set, Tuple
import aiofiles
from elaspic_rest_api import config
from elaspic_rest_api import jobsubmitter as js
logger = logg... | code_fim | hard | {
"lang": "python",
"repo": "elaspic/elaspic-rest-api",
"path": "/src/elaspic_rest_api/jobsubmitter/monitor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def _validate_finished_item(
item: js.Item, validation_passphrase: str
) -> Tuple[bool, str, str, str]:
system_command = 'grep "{}" {}'.format(validation_passphrase, item.stdout_path)
proc = await asyncio.create_subprocess_exec(
*shlex.split(system_command),
stdout=async... | code_fim | hard | {
"lang": "python",
"repo": "elaspic/elaspic-rest-api",
"path": "/src/elaspic_rest_api/jobsubmitter/monitor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, path):
dataset = pd.read_csv(path + '/spambase.csv', header=None)
self.labels = dataset[57].to_numpy()
dataset = dataset.drop([57], axis=1)
self.feature_names = dataset.columns
self.dataset = dataset.to_numpy()
f = open(path + '/spamb... | code_fim | hard | {
"lang": "python",
"repo": "marcopost-it/PASTLE",
"path": "/src/data_handlers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marcopost-it/PASTLE path: /src/data_handlers.py
import pandas as pd
import sklearn
import sklearn.preprocessing
import sklearn.model_selection
import numpy as np
class DataHandler():
def split(self, test_size, seed,stratify = True):
stratify = self.labels if stratify==True else Non... | code_fim | hard | {
"lang": "python",
"repo": "marcopost-it/PASTLE",
"path": "/src/data_handlers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.class_names = ['<=50K', '>50K']
class BanknoteDataHandler(DataHandler):
def __init__(self, path):
dataset = pd.read_csv(path + '/data_banknote_authentication.csv')
self.labels = dataset["Col4"].to_numpy()
dataset = dataset.drop(["Col4"], axis=1)
self.feat... | code_fim | hard | {
"lang": "python",
"repo": "marcopost-it/PASTLE",
"path": "/src/data_handlers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Artemigos/advent-of-code path: /2019/03/solution.py
import common
data = common.read_file('2019/03/data.txt').splitlines()
moves1 = data[0].split(',')
moves2 = data[1].split(',')
def generate_positions(moves):
at = [0, 0]
for move in moves:
direction = move[0]
amount = ... | code_fim | medium | {
"lang": "python",
"repo": "Artemigos/advent-of-code",
"path": "/2019/03/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>intersection = line1_points.intersection(line2_points)
min_dist = None
for pos in intersection:
dist = abs(pos[0]) + abs(pos[1])
if min_dist is None or dist < min_dist:
min_dist = dist
print('part 1:', min_dist)
# part 2
line1_points = list(generate_positions(moves1))
line2_points = lis... | code_fim | medium | {
"lang": "python",
"repo": "Artemigos/advent-of-code",
"path": "/2019/03/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raw_csv = resource_filename('iamapackage', 'data/raw.csv')
print('Path iamapackage.read_data :{}'.format(os.getcwd()))
print(pd.read_csv(raw_csv))
def write_data():
output_csv = resource_filename('iamapackage', 'data/output_csv.csv')
print('Path iamapackage.write_data :{}'.format(os.g... | code_fim | medium | {
"lang": "python",
"repo": "BenJoyenConseil/pybbl",
"path": "/iamapackage/lib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BenJoyenConseil/pybbl path: /iamapackage/lib.py
import os
import numpy as np
import pandas as pd
from pkg_resources import resource_filename
<|fim_suffix|> output_csv = resource_filename('iamapackage', 'data/output_csv.csv')
print('Path iamapackage.write_data :{}'.format(os.getcwd()))
... | code_fim | medium | {
"lang": "python",
"repo": "BenJoyenConseil/pybbl",
"path": "/iamapackage/lib.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> db = dataset.connect('sqlite:///'+output_name)
table = db['links']
for x in content:
table.insert(dict(raw_link=x.raw_link, title=x.title, link=x.link, source=source))<|fim_prefix|># repo: alan1world/onetab_data_archiver path: /backup_db.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
... | code_fim | medium | {
"lang": "python",
"repo": "alan1world/onetab_data_archiver",
"path": "/backup_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
db = dataset.connect('sqlite:///'+output_name)
table = db['links']
for x in content:
table.insert(dict(raw_link=x.raw_link, title=x.title, link=x.link, source=source))<|fim_prefix|># repo: alan1world/onetab_data_archiver path: /backup_db.py
#!/usr/bin/python3
# -*- coding: utf-8 ... | code_fim | easy | {
"lang": "python",
"repo": "alan1world/onetab_data_archiver",
"path": "/backup_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alan1world/onetab_data_archiver path: /backup_db.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
<|fim_suffix|>def create_db(content, source, output_name='daily.db'):
db = dataset.connect('sqlite:///'+output_name)
table = db['links']
for x in content:
table.insert(dict(raw... | code_fim | easy | {
"lang": "python",
"repo": "alan1world/onetab_data_archiver",
"path": "/backup_db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pangealab/cronus path: /cronus/now.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
__version__ = "1.0.5"
# Local Imports
from cronus import configure
from cronus import cmdb
from cronus import event
from cronus import incident
from cronus import properties
# Repo Imports
import os
import sys
imp... | code_fim | hard | {
"lang": "python",
"repo": "pangealab/cronus",
"path": "/cronus/now.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># DevOps Parser
devops_parser = commands_parser.add_parser('devops', help='devops')
devops_parser.add_argument('register-tools', help='register tools')
# Parse Arguments
args = parser.parse_args()
# Set the entry point
if __name__ == '__main__':
main()<|fim_prefix|># repo: pangealab/cronus path: /cron... | code_fim | hard | {
"lang": "python",
"repo": "pangealab/cronus",
"path": "/cronus/now.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Configure Parser
configure_parser = commands_parser.add_parser('configure', help='configure profile')
configure_group = configure_parser.add_mutually_exclusive_group(required=False)
configure_group.add_argument('-g','--get', help='get a configuration value from the config file')
configure_group.add_argu... | code_fim | hard | {
"lang": "python",
"repo": "pangealab/cronus",
"path": "/cronus/now.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> app.run(port=61712)<|fim_prefix|># repo: kdmukai/bonsai_dca path: /python/app.py
if __name__ == "__main__":
from server import app
from models import create_tables
<|fim_middle|> # Creates sqlite DB tables if necessary
create_tables()
| code_fim | medium | {
"lang": "python",
"repo": "kdmukai/bonsai_dca",
"path": "/python/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kdmukai/bonsai_dca path: /python/app.py
if __name__ == "__main__":
from server import app
from models import create_tables
<|fim_suffix|> app.run(port=61712)<|fim_middle|> # Creates sqlite DB tables if necessary
create_tables()
| code_fim | medium | {
"lang": "python",
"repo": "kdmukai/bonsai_dca",
"path": "/python/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bim = {
"chrom": StringDtype(),
"snp": StringDtype(),
"cm": float64,
"pos": int32,
"a0": StringDtype(),
"a1": StringDtype(),
}
fam = {
"fid": StringDtype(),
"iid": StringDtype(),
"father": StringDtype(),
"mother": StringDtype(),
"gender": StringDtype(),
"tr... | code_fim | easy | {
"lang": "python",
"repo": "ji-younkim/pandas-plink",
"path": "/pandas_plink/_type.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fam = {
"fid": StringDtype(),
"iid": StringDtype(),
"father": StringDtype(),
"mother": StringDtype(),
"gender": StringDtype(),
"trait": StringDtype(),
}<|fim_prefix|># repo: ji-younkim/pandas-plink path: /pandas_plink/_type.py
from numpy import float64, int32
from pandas import St... | code_fim | medium | {
"lang": "python",
"repo": "ji-younkim/pandas-plink",
"path": "/pandas_plink/_type.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ji-younkim/pandas-plink path: /pandas_plink/_type.py
from numpy import float64, int32
from pandas import StringDtype
<|fim_suffix|>fam = {
"fid": StringDtype(),
"iid": StringDtype(),
"father": StringDtype(),
"mother": StringDtype(),
"gender": StringDtype(),
"trait": Strin... | code_fim | medium | {
"lang": "python",
"repo": "ji-younkim/pandas-plink",
"path": "/pandas_plink/_type.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open("cd_gender.txt", 'w') as fout:
for article_id in mallet_articles:
article = mallet_articles[article_id]
if article['gender'] == 'male' or article['gender'] == 'female':
if article['prob'] > 0.8:
print("%s\t%s\t%s" % (article_id, article['gender'], ... | code_fim | hard | {
"lang": "python",
"repo": "Unlocking-Environmental-Narratives/Unlocking-Environmental-Narratives-Book",
"path": "/chapter-8/make_mallet_input.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Unlocking-Environmental-Narratives/Unlocking-Environmental-Narratives-Book path: /chapter-8/make_mallet_input.py
from genderize import Genderize
import csv
mallet_articles = {}
with open("country_diary_articles.csv", 'r') as fin:
reader = csv.DictReader(fin)
for row in reader:
a... | code_fim | hard | {
"lang": "python",
"repo": "Unlocking-Environmental-Narratives/Unlocking-Environmental-Narratives-Book",
"path": "/chapter-8/make_mallet_input.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: microsoft/archai path: /archai/discrete_search/evaluators/functional.py
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Callable, Optional
from overrides import overrides
<|fim_suffix|> """Initialize the evaluator.
Args:
e... | code_fim | hard | {
"lang": "python",
"repo": "microsoft/archai",
"path": "/archai/discrete_search/evaluators/functional.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.