text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> with open('logfile.txt', 'r+') as f:
file_data = f.read()
file_data = linebreaks(file_data)
return """
<html>
<header><title>Email Attachment</title></header>
<body>
{}
</body>
</html>
""".format(file_data)
@app.route('/get_mail', m... | code_fim | hard | {
"lang": "python",
"repo": "jamesboone/gmail_reader",
"path": "/main_app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jamesboone/gmail_reader path: /main_app.py
#!/usr/bin/env python
import re
from jinja2 import Markup
from flask import Flask, request
import gmail_api
import logging
app = Flask(__name__)
logger = logging.getLogger('main_app')
app.gmail_api = gmail_api.gapi()
<|fim_suffix|>@app.route('/')
def... | code_fim | hard | {
"lang": "python",
"repo": "jamesboone/gmail_reader",
"path": "/main_app.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Does the job"""
keep = True
photos = request_photos()
page = 1
t = False
while keep is True:
p = next(photos, False)
if p is False:
photos = request_photos(page + 1)
continue
trial = Photo.objects(flickr=p["id"]).first()
... | code_fim | hard | {
"lang": "python",
"repo": "onhernandes/capybara",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Found a valid photo, posting")
keep = False
url = make_photo_url(p["farm"], p["server"], p["id"], p["secret"])
t = tweet(url)
Photo(flickr=p["id"], tweet=t["id_str"]).save()
return t
if __name__ == "__main__":
print(main())<|fim_prefix|># repo: onhe... | code_fim | hard | {
"lang": "python",
"repo": "onhernandes/capybara",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: onhernandes/capybara path: /main.py
from photo import Photo
from tt import tweet
import mongoengine
import requests
import config
config.ensure()
mongoengine.connect('capybara')
def get_flickr_photos(page = 1):
<|fim_suffix|> while keep is True:
p = next(photos, False)
if p... | code_fim | hard | {
"lang": "python",
"repo": "onhernandes/capybara",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> uuid = models.CharField(max_length=256)
type_name = models.CharField(max_length=256, default="")
user_id = models.IntegerField()
app_id = models.IntegerField()<|fim_prefix|># repo: xlmvm1984/robot_pi path: /message_switch/models.py
from django.db import models
ROBOT_TYPE_LIST = (
RO... | code_fim | easy | {
"lang": "python",
"repo": "xlmvm1984/robot_pi",
"path": "/message_switch/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xlmvm1984/robot_pi path: /message_switch/models.py
from django.db import models
ROBOT_TYPE_LIST = (
ROBOT_TYPE_INGOING,
ROBOT_TYPE_OUTGOING,
) = (
1000,
2000,
)
<|fim_suffix|> uuid = models.CharField(max_length=256)
type_name = models.CharField(max_length=256, default=""... | code_fim | easy | {
"lang": "python",
"repo": "xlmvm1984/robot_pi",
"path": "/message_switch/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QudevETH/PycQED_py3 path: /pycqed/instrument_drivers/physical_instruments/arduino_switch_control.py
in_group (bool): Whether this method is called to for an
individual group. Needed to handle the recursion
of the method.
... | code_fim | hard | {
"lang": "python",
"repo": "QudevETH/PycQED_py3",
"path": "/pycqed/instrument_drivers/physical_instruments/arduino_switch_control.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create connection
connection = ArduinoSwitchControlConnection(start, end)
# add connection to attributes
self.connections.append(connection)
def _add_route(self, connections):
"""Create a route and add it to the routes dictionary
Args:
c... | code_fim | hard | {
"lang": "python",
"repo": "QudevETH/PycQED_py3",
"path": "/pycqed/instrument_drivers/physical_instruments/arduino_switch_control.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: laurafeier/code-metrics path: /code_metrics/radon_metrics.py
import operator
from collections import OrderedDict
import radon.complexity as cc_mod
from radon.cli.harvest import CCHarvester, MIHarvester, RawHarvester
from radon.cli import Config
def get_files_complexity_data(paths, ignore):
... | code_fim | medium | {
"lang": "python",
"repo": "laurafeier/code-metrics",
"path": "/code_metrics/radon_metrics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> config = Config(
exclude=ignore,
ignore=ignore,
summary=False,
)
harvester = RawHarvester(paths, config)
data = []
for filename, raw_data in harvester.results:
if not raw_data:
continue
data.append((filename, raw_data['loc'],))
... | code_fim | medium | {
"lang": "python",
"repo": "laurafeier/code-metrics",
"path": "/code_metrics/radon_metrics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_files_lines_of_code(paths, ignore):
config = Config(
exclude=ignore,
ignore=ignore,
summary=False,
)
harvester = RawHarvester(paths, config)
data = []
for filename, raw_data in harvester.results:
if not raw_data:
continue
dat... | code_fim | hard | {
"lang": "python",
"repo": "laurafeier/code-metrics",
"path": "/code_metrics/radon_metrics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_simple_file_name_with_multiple_extensions(self):
touch(os.path.join(self.dir_name, 'test.boo.txt'))
assert mod.create_unique_file_name(self.dir_name, 'test.boo.txt') == 'test.boo.1.txt'
def test_simple_file_name_with_multiple_empty_extensions(self):
touch(os.path.... | code_fim | hard | {
"lang": "python",
"repo": "kenfar/DataGristle",
"path": "/scripts/tests/test_gristle_dir_merger.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kenfar/DataGristle path: /scripts/tests/test_gristle_dir_merger.py
#!/usr/bin/env python
""" See the file "LICENSE" for the full license governing this code.
Copyright 2011,2012,2013,2017 Ken Farmer
"""
#adjust pylint for pytest oddities:
#pylint: disable=missing-docstring
#pylint: disable=un... | code_fim | hard | {
"lang": "python",
"repo": "kenfar/DataGristle",
"path": "/scripts/tests/test_gristle_dir_merger.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: christinali/sqlproject path: /server/condensed_classes.py
jun = {"name": "Jun Yang", "id": 1, "rating": 4.7}
rob = {"name": "Robert Duvall", "id": 2, "rating": 4.3}
jeff = {"name": "Jeff Forbes", "id": 3, "rating": 4.1}
susan = {"name": "Susan Rodger", "id": 4, "rating": 2.1}
astrachan = {"name":... | code_fim | hard | {
"lang": "python",
"repo": "christinali/sqlproject",
"path": "/server/condensed_classes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class5 = {"id": "5", "num": 101, "dept": "CulAnth", "name": "Cultural Anthropology", "overall": 3.2,
"difficulty": 3.1, "nextSemProf": orin}
class6 = {"id": "6", "num": 101, "dept": "Educ", "name": "Foundations of Education", "overall": 4.3,
"difficulty": 3.6, "nextSemProf": amy}
def getMajors():
... | code_fim | medium | {
"lang": "python",
"repo": "christinali/sqlproject",
"path": "/server/condensed_classes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># cv2.waitKey(0)
# cv2.destroyAllWindows()<|fim_prefix|># repo: kairatomurbek2/idmatch path: /idmatch/idcardocr/processing/__init__.py
# if show:
# cv2.drawContours(image, [screenCnt], -1, (0, 255, 0), 2)
# cv2.imwrite('outline<|fim_middle|>d.jpg', image)
# cv2.imshow("Outline", image... | code_fim | easy | {
"lang": "python",
"repo": "kairatomurbek2/idmatch",
"path": "/idmatch/idcardocr/processing/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kairatomurbek2/idmatch path: /idmatch/idcardocr/processing/__init__.py
# if show:
# cv2.drawContours(image, [screenCn<|fim_suffix|>d.jpg', image)
# cv2.imshow("Outline", image)
# cv2.waitKey(0)
# cv2.destroyAllWindows()<|fim_middle|>t], -1, (0, 255, 0), 2)
# cv2.imwrite('outli... | code_fim | easy | {
"lang": "python",
"repo": "kairatomurbek2/idmatch",
"path": "/idmatch/idcardocr/processing/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def showHistogramIris(setosa, versicolor, virginica, column_name):
plt.figure()
plt.title(column_name)
plt.xlabel('Centimeters')
plt.ylabel('Count')
y1 = setosa[column_name]
y2 = versicolor[column_name]
y3 = virginica[column_name]
plt.hist(y1, bins=12)
plt.hist(y2, bins... | code_fim | hard | {
"lang": "python",
"repo": "emmapatton/Programming-and-Scripting-Project-2018",
"path": "/iris_stats_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emmapatton/Programming-and-Scripting-Project-2018 path: /iris_stats_data.py
# Emma Patton, Programming and Scripting Project - 2018
# Analysis of Iris Stats Data Set
# The data was investigated using a number of mathematical functions
# The data has also been grouped and visually represented i... | code_fim | hard | {
"lang": "python",
"repo": "emmapatton/Programming-and-Scripting-Project-2018",
"path": "/iris_stats_data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def showScatterIris(setosa, versicolor, virginica, column_1, column_2):
x1 = setosa[column_1]
y1 = setosa[column_2]
x2 = versicolor[column_1]
y2 = versicolor[column_2]
x3 = virginica[column_1]
y3 = virginica[column_2]
plt.title(column_1 + " vs. " + column_2)
plt.xlabe... | code_fim | hard | {
"lang": "python",
"repo": "emmapatton/Programming-and-Scripting-Project-2018",
"path": "/iris_stats_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # make layers
hidden_layer1 = mlp.Tanh(layer_name='hidden1', dim=20, irange=0.5, init_bias=1.0)
hidden_layer2 = mlp.Tanh(layer_name='hidden2', dim=4, irange=0.5, init_bias=1.0)
output_layer = mlp.Linear(layer_name='out', dim=1, irange=0.5, init_bias=1)
# set layers
layers = [hidde... | code_fim | hard | {
"lang": "python",
"repo": "rekpon/regression-problem-practice-in-pylearn2",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rekpon/regression-problem-practice-in-pylearn2 path: /train.py
#coding: utf-8
""" pylearn2 でsin関数を近似するサンプルプログラム。
[実行方法]
$ python train.py
[オプション]
-p : epoch毎にモデルの予測値を保存、学習終了後にアニメーションで遷移を表示。
-f, --file <finename> : -pオプションのアニメーションをmp4ファイルで保存(要ffmpeg)
[出力]
学習結果は ./funcmodel.pkl に保存。
[note]
1. ... | code_fim | hard | {
"lang": "python",
"repo": "rekpon/regression-problem-practice-in-pylearn2",
"path": "/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Examples:")
printIndent()
print("ccl some-project-dir")
print()
printIndent()
print("ccl some-project-dir-inner1,some-project-dir-inner2")
printIndent()
printIndent()
print("This will search in two directories")
print()
printIndent()
print("ccl --blackbox build,static,fonts,... | code_fim | hard | {
"lang": "python",
"repo": "webkadiz/count-code-lines",
"path": "/print_help.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webkadiz/count-code-lines path: /print_help.py
optionDescCarry = "\n\t\t"
helpInfo = [
{
"keys": ["-e", "--ext"],
"desc": "Option's value is a list of extensions with dot separate comma. This files will be" +
f"{optionDescCarry}counted. By default - [.js]."
},
{
"ke... | code_fim | hard | {
"lang": "python",
"repo": "webkadiz/count-code-lines",
"path": "/print_help.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("PATHS - paths to directories which you wish to scan. They separate with comma")
print()
def printParamsInfo():
print("OPTIONS:")
for paramInfo in helpInfo:
paramKeys = paramInfo["keys"]
paramDesc = paramInfo["desc"]
printIndent()
print(", ".join(paramKeys), ":", sep="")
... | code_fim | hard | {
"lang": "python",
"repo": "webkadiz/count-code-lines",
"path": "/print_help.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
pass
def list(self):
print (_("%(version)s (%(vcs)s)") %
{'version': version.version_string(),
'vcs': version.version_string_with_vcs()})
def __call__(self):
self.list()
CATEGORIES = [
('db', DbCo... | code_fim | hard | {
"lang": "python",
"repo": "fengkaicnic/traffic",
"path": "/bin/traffic-manage",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fengkaicnic/traffic path: /bin/traffic-manage
#!/usr/bin/python
import ast
import errno
import gettext
import math
import netaddr
import optparse
import os
import sys
from gettext import gettext
from traffic.compute import rpcapi as compute_rpcapi
from traffic import context
from ... | code_fim | hard | {
"lang": "python",
"repo": "fengkaicnic/traffic",
"path": "/bin/traffic-manage",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @args('--version', dest='version', metavar='<version>',
help='Database version')
def sync(self, version=None):
"""Sync the database up to the most recent version."""
return migration.db_sync(version)
def version(self):
"""Print the current database v... | code_fim | hard | {
"lang": "python",
"repo": "fengkaicnic/traffic",
"path": "/bin/traffic-manage",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
print(f"Log: {context.log_group_name}")
print(f"Param: {event}")
config.source = event["source"]
config.product = event["code"]
except KeyError as err:
raise SystemExit(f"Missing parameters, check the payload: {err}")
main()
if __name__ == "__main_... | code_fim | hard | {
"lang": "python",
"repo": "uknbr/lambda-price",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uknbr/lambda-price path: /main.py
#!/usr/bin/python3
import requests
import time
from bs4 import BeautifulSoup
import config
def amazon_request(code):
url = f"https://www.amazon.com.br/gp/product/{code}"
print(f"Accessing {url}")
try:
response = requests.get(
url... | code_fim | hard | {
"lang": "python",
"repo": "uknbr/lambda-price",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('simple')
widget.show()
sys.exit(app.exec_())<|fim_prefix|># repo: hitli/iiwa_stack path: /iiwa_li/scripts/test/pyqttest.py
#!/usr/bin/python
# simple.py
<|fim_middle|>import sys
from PyQt5 ... | code_fim | easy | {
"lang": "python",
"repo": "hitli/iiwa_stack",
"path": "/iiwa_li/scripts/test/pyqttest.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hitli/iiwa_stack path: /iiwa_li/scripts/test/pyqttest.py
#!/usr/bin/python
# simple.py
<|fim_suffix|>app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('simple')
widget.show()
sys.exit(app.exec_())<|fim_middle|>import sys
from PyQt5 ... | code_fim | easy | {
"lang": "python",
"repo": "hitli/iiwa_stack",
"path": "/iiwa_li/scripts/test/pyqttest.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scriptgalih/ReDirect-discord-message path: /cogs/redirectmail.py
import discord
from discord.ext import commands
from datetime import datetime
import pymongo
import json
import asyncio
import math
with open('cogs/dbCred.json') as json_file:
db_cred = json.load(json_file)
myClient = pymongo.... | code_fim | hard | {
"lang": "python",
"repo": "scriptgalih/ReDirect-discord-message",
"path": "/cogs/redirectmail.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(mutual_servers) <= 3:
guild_itter = mutual_servers[0:len(mutual_servers)]
else:
guild_itter = mutual_servers[3 ** page:3 ** page + 3]
for guild_id in guild_itter:
guild_list.append(guild_id)
guild =... | code_fim | hard | {
"lang": "python",
"repo": "scriptgalih/ReDirect-discord-message",
"path": "/cogs/redirectmail.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>loy:main",
]
},
install_requires=[
"numpy",
"ase",
"tqdm",
"torch>=1.8",
"torch_geometric==1.7.2",
"e3nn>=0.3.3",
"pyyaml",
"contextlib2;python_version<'3.7'", # backport of nullcontext
"typing_extensions;python_versi... | code_fim | hard | {
"lang": "python",
"repo": "shuaijiang-ustc/nequip",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shuaijiang-ustc/nequip path: /setup.py
from setuptools import setup, find_packages
from pathlib import Path
# see https://packaging.python.org/guides/single-sourcing-package-version/
version_dict = {}
with open(Path(__file__).parents[0] / "nequip/_version.py") as fp:
exec(fp.read(), version_... | code_fim | hard | {
"lang": "python",
"repo": "shuaijiang-ustc/nequip",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chebSa3id/Final-Project path: /Software/Pose Detection/mlp_model - Talos.py
import math
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers.core import Dense,Activation,Dropout
from keras.optimizers impo... | code_fim | hard | {
"lang": "python",
"repo": "chebSa3id/Final-Project",
"path": "/Software/Pose Detection/mlp_model - Talos.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
model=Sequential()
model.add(Dense(params['first_neuron'],input_dim=trainX.shape[1], activation=params['activation'], kernel_initializer= 'normal'))
model.add(Dropout(params['dropout']))
hidden_layers(model,params,1)
model.add(Dense(1, activation=params['last_activation'],kernel_initi... | code_fim | hard | {
"lang": "python",
"repo": "chebSa3id/Final-Project",
"path": "/Software/Pose Detection/mlp_model - Talos.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'error' in data:
raise base.ExecutorException(result, data['error'])
has_retransmits = False
if (len(data['intervals']) > 0 and
'retransmits' in data['intervals'][0]['sum']):
has_retransmits = True
if self.test_definition.get('ud... | code_fim | hard | {
"lang": "python",
"repo": "performa-labs/shaker",
"path": "/shaker/engine/executors/iperf.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: performa-labs/shaker path: /shaker/engine/executors/iperf.py
# Copyright (c) 2015 Mirantis Inc.
#
# 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.... | code_fim | hard | {
"lang": "python",
"repo": "performa-labs/shaker",
"path": "/shaker/engine/executors/iperf.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture
def files_abc(tmp_path) -> List[Path]:
"""Create files in tmp_path: a.md, b.md, c.md."""
files = [tmp_path/"a.md", tmp_path/"b.md", tmp_path/"c.md"]
for path in files:
path.touch()
yield files
@pytest.fixture
def mnote(tmp_path) -> Path:
"""Mock markdown note i... | code_fim | hard | {
"lang": "python",
"repo": "Chris-May/slipbox",
"path": "/cli/slipbox/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Chris-May/slipbox path: /cli/slipbox/conftest.py
# type: ignore
"""Functions for mocking the database."""
from pathlib import Path
import sqlite3
from typing import Iterable, List
import pytest
from .initializer import initialize_database, DotSlipbox
from .slipbox import Slipbox
@pytest.fixtu... | code_fim | hard | {
"lang": "python",
"repo": "Chris-May/slipbox",
"path": "/cli/slipbox/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture
def sbox(tmp_path) -> Slipbox:
"""Create automatically configured Slipbox object."""
dot = DotSlipbox(tmp_path)
with Slipbox(dot) as slipbox:
yield slipbox
@pytest.fixture
def files_abc(tmp_path) -> List[Path]:
"""Create files in tmp_path: a.md, b.md, c.md."""
... | code_fim | hard | {
"lang": "python",
"repo": "Chris-May/slipbox",
"path": "/cli/slipbox/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def getstudentxuehao():
banjiids = tuple(range(1, 2))# 各个班级的Id元组
for banjiid in banjiids:
print(banjiid)
sql = "select stuno from student where banjiid =" + str(banjiid)
cur.execute(sql)
results = cur.fetchall() # 用于返回多条数据,得到全部学生学号
for stuno in results: # ... | code_fim | hard | {
"lang": "python",
"repo": "sunlupeng2020/stuoj",
"path": "/zznuojfenxi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunlupeng2020/stuoj path: /zznuojfenxi.py
# selenium结合PhantomJS()访问郑州师范学院OJ平台,统计学生在OJ平台上C语言题目的提交情况
# 写入数据库stuoj的stuquestionbh表中
# 导入selenium的
from selenium import webdriver
# import MySQLdb
from selenium.webdriver.common.by import By
import pymysql
<|fim_suffix|> banjiids = tuple(range(1, 2)... | code_fim | hard | {
"lang": "python",
"repo": "sunlupeng2020/stuoj",
"path": "/zznuojfenxi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>with Connection('amqp://guest:guest@127.0.0.1:5672//') as conn:
simple_queue = conn.SimpleQueue('simple_queue')
while True:
with tracer.trace('consume', service='consumer'):
message = simple_queue.get(block=True, timeout=2)
message.ack()
process_message(... | code_fim | medium | {
"lang": "python",
"repo": "DataDog/trace-examples",
"path": "/python/kombu/consumer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DataDog/trace-examples path: /python/kombu/consumer.py
import time
import random
from ddtrace import tracer
from kombu import Connection
@tracer.wrap('process_message')
def process_message(message):
<|fim_suffix|>
with Connection('amqp://guest:guest@127.0.0.1:5672//') as conn:
simple_queue... | code_fim | medium | {
"lang": "python",
"repo": "DataDog/trace-examples",
"path": "/python/kombu/consumer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for experiment_path, model_save_path, tensorboard_output_dir in zip(
experiment_paths, model_save_paths, tensorboard_output_dirs):
print('----> Starting experiment {}. <----'.format(experiment_path))
os.system(EXPERIMENT_START_CMD.format(
experiment_path, X_trai... | code_fim | hard | {
"lang": "python",
"repo": "lvrcek/consensus-net",
"path": "/src/python/training/training.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lvrcek/consensus-net path: /src/python/training/training.py
import os
X_TRAIN_PATH = 'X_train_path'
Y_TRAIN_PATH = 'y_train_path'
X_VALIDATE_PATH = 'X_validate_path'
Y_VALIDATE_PATH = 'y_validate_path'
EXPERIMENT_START_CMD = 'python3 {} {} {} {} {} {} {} {}'
EXPERIMENT_MOVE_CMD = 'mv {} {}'
d... | code_fim | hard | {
"lang": "python",
"repo": "lvrcek/consensus-net",
"path": "/src/python/training/training.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> plt.close("all")
@pytest.mark.visual
# this is to check overlay of rendered image and single localization points
def test_render_2d_mpl_show(locdata_blobs_2d):
# print(locdata_blobs_2d.coordinates)
render_2d_mpl(
locdata_blobs_2d,
bin_size=10,
bin_range=None,
... | code_fim | hard | {
"lang": "python",
"repo": "super-resolution/Locan",
"path": "/locan/tests/visualize/render_mpl/test_render2d.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: super-resolution/Locan path: /locan/tests/visualize/render_mpl/test_render2d.py
import matplotlib.pyplot as plt # this import is needed for interactive tests
import numpy as np
import pytest
from locan import ( # noqa: F401 # this import is needed for interactive tests
RenderEngine,
a... | code_fim | hard | {
"lang": "python",
"repo": "super-resolution/Locan",
"path": "/locan/tests/visualize/render_mpl/test_render2d.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return [error_dir[k] for k in text.split() if k != "SUCCESS"]
class NumberServiceResultSchema(Schema):
input_doc = DocumentIdSchema(".//ops:input")
output_doc = DocumentIdSchema(".//ops:output")
service_version = f.Str('.//ops:meta[@name="version"]/@value')
messages = f.Str('.//ops:m... | code_fim | hard | {
"lang": "python",
"repo": "parkerhancock/patent_client",
"path": "/src/patent_client/epo/ops/number_service/schema.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: parkerhancock/patent_client path: /src/patent_client/epo/ops/number_service/schema.py
from patent_client.epo.ops.util import Schema
from yankee.xml import fields as f
from . import error_dir
<|fim_suffix|>
def get_messages(text):
return [error_dir[k] for k in text.split() if k != "SUCCESS"... | code_fim | hard | {
"lang": "python",
"repo": "parkerhancock/patent_client",
"path": "/src/patent_client/epo/ops/number_service/schema.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>'')
lista = list()
while True:
num = randint(1,60)
if num in lista:
continue
else:
lista.append(num)
if len(lista) == 6:
break
lista.sort()
print(lista)<|fim_prefix|># repo: GabrielTrentino/Python_Basico path: ... | code_fim | medium | {
"lang": "python",
"repo": "GabrielTrentino/Python_Basico",
"path": "/02 - Curso Em Video/Aula 18/E - 088.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GabrielTrentino/Python_Basico path: /02 - Curso Em Video/Aula 18/E - 088.py
from random import randint
print('='*40)
print('{:^40}'.format('JOGO DA MEGA SENA'))
print('='*40)
quant = int(input(<|fim_suffix|>'')
lista = list()
while True:
num = randint(1,60)
if nu... | code_fim | medium | {
"lang": "python",
"repo": "GabrielTrentino/Python_Basico",
"path": "/02 - Curso Em Video/Aula 18/E - 088.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.skipif(sys.platform != "darwin", reason="macOS specific test")
def test_open_macOS(open_command, first_app_config, tmp_path):
"""On macOS, open uses Finder to open the project folder."""
# Mock the call to verify the existence of java
open_command.tools.subprocess.check_output.re... | code_fim | hard | {
"lang": "python",
"repo": "beeware/briefcase",
"path": "/tests/platforms/android/gradle/test_open.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """On Windows, open invokes `startfile` on the project folder."""
# Create the project folder to mock a created project.
open_command.project_path(first_app_config).mkdir(parents=True)
# Create a stub java binary
create_file(tmp_path / "briefcase" / "tools" / "java17" / "bin" / "java"... | code_fim | hard | {
"lang": "python",
"repo": "beeware/briefcase",
"path": "/tests/platforms/android/gradle/test_open.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: beeware/briefcase path: /tests/platforms/android/gradle/test_open.py
import os
import sys
from collections import defaultdict
from unittest.mock import MagicMock
import pytest
from briefcase.console import Console, Log
from briefcase.exceptions import BriefcaseCommandError
from briefcase.integr... | code_fim | hard | {
"lang": "python",
"repo": "beeware/briefcase",
"path": "/tests/platforms/android/gradle/test_open.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: susumuota/oculomotor path: /application/functions/utils.py
import os
import cv2
import numpy as np
def load_image(file_path):
module_dir, _ = os.path.split(os.path.realpath(__file__))
absolute_path = os.path.join(module_dir, file_path)
image = cv2.imread(absolute_path)
# (h, w, c... | code_fim | hard | {
"lang": "python",
"repo": "susumuota/oculomotor",
"path": "/application/functions/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def save_image(image, file_path):
module_dir, _ = os.path.split(os.path.realpath(__file__))
absolute_path = os.path.join(module_dir + "/../..", file_path)
# Change RGB to BGR
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cv2.imwrite(absolute_path, image)<|fim_prefix|># repo: susumuot... | code_fim | hard | {
"lang": "python",
"repo": "susumuota/oculomotor",
"path": "/application/functions/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mugenZebra/rlgraph path: /rlgraph/tests/components/test_environment_stepper.py
istic_env_action_space),
exploration_spec
)
environment_stepper = EnvironmentStepper(
environment_spec=dict(type="deterministic_env", steps_to_terminal=5),
actor_comp... | code_fim | hard | {
"lang": "python",
"repo": "mugenZebra/rlgraph",
"path": "/rlgraph/tests/components/test_environment_stepper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mugenZebra/rlgraph path: /rlgraph/tests/components/test_environment_stepper.py
r_spec,
dict(network_spec=network_spec, action_space=self.deterministic_env_action_space),
exploration_spec
)
environment_stepper = EnvironmentStepper(
environment_sp... | code_fim | hard | {
"lang": "python",
"repo": "mugenZebra/rlgraph",
"path": "/rlgraph/tests/components/test_environment_stepper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_environment_stepper_on_deepmind_lab(self):
try:
from rlgraph.environments.deepmind_lab import DeepmindLabEnv
except ImportError:
print("DeepmindLab not installed: Skipping this test case.")
return
env_spec = dict(
type="... | code_fim | hard | {
"lang": "python",
"repo": "mugenZebra/rlgraph",
"path": "/rlgraph/tests/components/test_environment_stepper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> delete_task(task_id)
print('Task stopped.')<|fim_prefix|># repo: ihoromi4/neuroseed-mvp path: /examples/delete_task.py
import utils
def delete_task(task_id):
url = 'http://localhost:8080/api/v1/task/{id}'.format(id=task_id)
resp = utils.delete(url)
if resp.status_code == 200:
... | code_fim | medium | {
"lang": "python",
"repo": "ihoromi4/neuroseed-mvp",
"path": "/examples/delete_task.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ihoromi4/neuroseed-mvp path: /examples/delete_task.py
import utils
def delete_task(task_id):
url = 'http://localhost:8080/api/v1/task/{id}'.format(id=task_id)
<|fim_suffix|> if resp.status_code == 200:
print('Delete task status:', resp.status_code, 'data:', resp.text)
re... | code_fim | easy | {
"lang": "python",
"repo": "ihoromi4/neuroseed-mvp",
"path": "/examples/delete_task.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@classmethod
def build_directive(cls, options):
directive = {
"service_type": options.service_type,
"target_type": options.target_type,
}
return directive<|fim_prefix|># repo: yunify/qingcloud-cli path: /qingcloud/cli/iaas_client/actions/s... | code_fim | hard | {
"lang": "python",
"repo": "yunify/qingcloud-cli",
"path": "/qingcloud/cli/iaas_client/actions/s2/describe_s2_default_parameters.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yunify/qingcloud-cli path: /qingcloud/cli/iaas_client/actions/s2/describe_s2_default_parameters.py
# =========================================================================
# Copyright 2012-present Yunify, Inc.
# -------------------------------------------------------------------------
# Licens... | code_fim | medium | {
"lang": "python",
"repo": "yunify/qingcloud-cli",
"path": "/qingcloud/cli/iaas_client/actions/s2/describe_s2_default_parameters.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>KB_SOURCES=[
('https://query.wikidata.org/',
['wd:Q657', # angela merkel
]
) ]
def gen_fn(node):
return node.replace('<', '_').replace('>', '_').replace('/', '_')
for endpoint, nodes in KB_SOURCES:
for node in nodes:
with code... | code_fim | hard | {
"lang": "python",
"repo": "gooofy/sparqlalchemy",
"path": "/utils/wkdmirror.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> query = u"""
CONSTRUCT {
%s ?r ?n .
}
WHERE {
%s ?r ?n .
}
""" % (node, node)
logging.debug('query: %s' % (query))
... | code_fim | hard | {
"lang": "python",
"repo": "gooofy/sparqlalchemy",
"path": "/utils/wkdmirror.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gooofy/sparqlalchemy path: /utils/wkdmirror.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 Guenter Bartsch
#
# 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": "gooofy/sparqlalchemy",
"path": "/utils/wkdmirror.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: minmummax/nlp_toolbox path: /src/__init__.py
__version__ = '0.0.1'
from . import cleaner
from . import co<|fim_suffix|>port metrics
from . import models
from . import readers
from . import transformers
from . import utils
from . import logger<|fim_middle|>stom_algo
from . import layers
from . im... | code_fim | medium | {
"lang": "python",
"repo": "minmummax/nlp_toolbox",
"path": "/src/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>. import transformers
from . import utils
from . import logger<|fim_prefix|># repo: minmummax/nlp_toolbox path: /src/__init__.py
__version__ = '0.0.1'
from . import cleaner
from . import costom_algo
from . import layers
from . import losses
from . im<|fim_middle|>port metrics
from . import models
from .... | code_fim | medium | {
"lang": "python",
"repo": "minmummax/nlp_toolbox",
"path": "/src/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data[numeric] = data[numeric].apply(np.sqrt)
if retain_cols is not None:
return pd.merge(data, temp, left_index=True, right_index=True)
else:
return data<|fim_prefix|># repo: daviddexter/wrangle-mirror path: /wrangle/df/df_rescale_sqrt.py
import numpy as np
import pandas as p... | code_fim | hard | {
"lang": "python",
"repo": "daviddexter/wrangle-mirror",
"path": "/wrangle/df/df_rescale_sqrt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: daviddexter/wrangle-mirror path: /wrangle/df/df_rescale_sqrt.py
import numpy as np
import pandas as pd
def df_rescale_sqrt(data, retain_cols=None, destructive=False):
<|fim_suffix|> if destructive is False:
data = data.copy(deep=True)
if retain_cols is not None:
data = ... | code_fim | hard | {
"lang": "python",
"repo": "daviddexter/wrangle-mirror",
"path": "/wrangle/df/df_rescale_sqrt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.skip_nt
def test_shims_are_removed(monkeypatch, no_virtual_env, setup_pythons):
with monkeypatch.context() as m:
pyenv_dir = pythonfinder.utils.normalize_path("~/.pyenv")
asdf_dir = pythonfinder.utils.normalize_path("~/.asdf")
six.moves.reload_module(pythonfinder.... | code_fim | hard | {
"lang": "python",
"repo": "TebelloX/pythonfinder",
"path": "/tests/test_python.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TebelloX/pythonfinder path: /tests/test_python.py
# -*- coding=utf-8 -*-
from __future__ import absolute_import, print_function
import functools
import os
import sys
import pytest
import six
from packaging.version import Version
import pythonfinder
from .testutils import (
is_in_ospath,
... | code_fim | hard | {
"lang": "python",
"repo": "TebelloX/pythonfinder",
"path": "/tests/test_python.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Joannsaj/blog path: /migrations/versions/254f03c28f61_added_date_col.py
"""added date col
Revision ID: 254f03c28f61
Revises: 9d9a50996925
Create Date: 2020-11-01 22:37:25.259482
"""
from alembic import op
import sqlalchemy as sa
<|fim_suffix|>
def upgrade():
# ### commands auto generated b... | code_fim | medium | {
"lang": "python",
"repo": "Joannsaj/blog",
"path": "/migrations/versions/254f03c28f61_added_date_col.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('blogs', 'posted')
# ### end Alembic commands ###<|fim_prefix|># repo: Joannsaj/blog path: /migrations/versions/254f03c28f61_added_date_col.py
"""added date col
Revision ID: 254f03c28f61
Revises: 9... | code_fim | hard | {
"lang": "python",
"repo": "Joannsaj/blog",
"path": "/migrations/versions/254f03c28f61_added_date_col.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ### commands auto generated by Alembic - please adjust! ###
op.drop_column('blogs', 'posted')
# ### end Alembic commands ###<|fim_prefix|># repo: Joannsaj/blog path: /migrations/versions/254f03c28f61_added_date_col.py
"""added date col
Revision ID: 254f03c28f61
Revises: 9d9a50996925
Create... | code_fim | medium | {
"lang": "python",
"repo": "Joannsaj/blog",
"path": "/migrations/versions/254f03c28f61_added_date_col.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: syfiawoo/30DayLeetCodeChallenge path: /April/Day6/group_anagrams.py
class Solution:
@staticmethod
def group_anagrams(words):
"""
My strategy for solving this is sorting each word
and using the sorted word as the key in a dictionary.
:param words: a list con... | code_fim | hard | {
"lang": "python",
"repo": "syfiawoo/30DayLeetCodeChallenge",
"path": "/April/Day6/group_anagrams.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if sorted_word not in groups:
groups[sorted_word] = [word]
else:
groups[sorted_word].append(word)
return groups.values()<|fim_prefix|># repo: syfiawoo/30DayLeetCodeChallenge path: /April/Day6/group_anagrams.py
class Solution:
@staticmethod
def ... | code_fim | hard | {
"lang": "python",
"repo": "syfiawoo/30DayLeetCodeChallenge",
"path": "/April/Day6/group_anagrams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r word in words:
# sort the current word
sorted_word = ''.join(sorted(word))
# check if the sorted word is a key in the dict
if sorted_word not in groups:
groups[sorted_word] = [word]
else:
groups[sorted_word].appe... | code_fim | hard | {
"lang": "python",
"repo": "syfiawoo/30DayLeetCodeChallenge",
"path": "/April/Day6/group_anagrams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eliseuegewarth/sort_Algorithms path: /bucket_sort/bucket_sort.py
def bucket_sort(vector=None, key = lambda x:x):
if len(vector) < 2:
pass
else:
i = vector[len(vector)//2] # Apply M.o.M. to better pe<|fim_suffix|>st_part.append(y)
elif key(y) == key(i):
... | code_fim | hard | {
"lang": "python",
"repo": "eliseuegewarth/sort_Algorithms",
"path": "/bucket_sort/bucket_sort.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>st_part.append(y)
elif key(y) == key(i):
median_part.append(y)
else:
first_part.append(y)
first_part = bucket_sort(first_part, key)
last_part = bucket_sort(last_part, key)
vector = first_part + median_part + last_part
retu... | code_fim | hard | {
"lang": "python",
"repo": "eliseuegewarth/sort_Algorithms",
"path": "/bucket_sort/bucket_sort.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Niranjan-robotics/NewRover path: /snowboy/SpeechToText/YoutubeSearchWithVoice.py
#
# a quick test for speech to text
#
import speech_recognition as sr
import webbrowser as wb
def main():
<|fim_suffix|> with sr.Microphone() as source:
print ('say something')
audio = r.listen(s... | code_fim | medium | {
"lang": "python",
"repo": "Niranjan-robotics/NewRover",
"path": "/snowboy/SpeechToText/YoutubeSearchWithVoice.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with sr.Microphone() as source:
print ('say something')
audio = r.listen(source)
print ('done')
try:
text = r.recognize_google(audio)
print('Neo said:\n' + text)
#if 'telugu' in text:
# url ='https://www.youtube.com/results?search_query='
... | code_fim | medium | {
"lang": "python",
"repo": "Niranjan-robotics/NewRover",
"path": "/snowboy/SpeechToText/YoutubeSearchWithVoice.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: squarooticus/alta path: /alta/augmented_scheme.py
#! /usr/bin/python3
#
# MIT License
#
# Copyright (C) 2019 Akamai Technologies, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | code_fim | hard | {
"lang": "python",
"repo": "squarooticus/alta",
"path": "/alta/augmented_scheme.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Given a node index, return the list of indices of nodes from which
hashes must be drawn. If first or last is specified, eliminate any node
indices outside of that range.
"""
return sorted([ index + o for o in self.soffsets[index % self.p]
if (first is... | code_fim | hard | {
"lang": "python",
"repo": "squarooticus/alta",
"path": "/alta/augmented_scheme.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.optimizer.step()
def train(self):
# Random seed
torch.manual_seed(self.seed)
np.random.seed(self.seed)
self.env.seed(self.seed)
ret_list = []
buffer = ReinforceBuffer()
for i in range(self.episodes):
buffer.clear()
... | code_fim | hard | {
"lang": "python",
"repo": "RayYoh/BasicRL",
"path": "/pg_cpu/reinforce.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RayYoh/BasicRL path: /pg_cpu/reinforce.py
import gym
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt
from torch.optim import Adam
class ReinforceBuffer():
def __init__(self):
pass
def store(self, o, a, next_o,... | code_fim | hard | {
"lang": "python",
"repo": "RayYoh/BasicRL",
"path": "/pg_cpu/reinforce.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#: East (opposite: WEST).
EAST = _EAST_WEST.direction
#: West (opposite: EAST).
WEST = _EAST_WEST.opposite
#: Up (opposite: DOWN).
UP = _UP_DOWN.direction
#: Down (opposite: UP).
DOWN = _UP_DOWN.opposite
#: In (opposite: OUT).
IN = _IN_OUT.direction
#: Out (opposite: IN).
OUT = _IN_OUT.opposite<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "mmurdoch/Vengeance",
"path": "/vengeance/directions.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mmurdoch/Vengeance path: /vengeance/directions.py
"""
Common directions.
"""
from vengeance.game import Direction
class _DirectionPair(object):
"""
A pair of directions, each of which is the opposite of the other.
:param string direction_name: The name of one direction
:param s... | code_fim | hard | {
"lang": "python",
"repo": "mmurdoch/Vengeance",
"path": "/vengeance/directions.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> ans_sparse = A_sparse_corner_solver(v[A_block_sparse.sparse_row_indices].flatten())
ans_dense = A_inv_dense_corner.dot(v[A_block_sparse.dense_row_indices[non_zero_columns]])
ans = np.zeros(len(A_block_sparse.sparse_row_indices) + len(A_block_sparse.dense_row_indices))
ans[A... | code_fim | hard | {
"lang": "python",
"repo": "lillekemiker/blmath",
"path": "/blmath/numerics/linalg/sparse_cg.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lillekemiker/blmath path: /blmath/numerics/linalg/sparse_cg.py
def block_sparse_cg_solve(A, x):
'''
This function can be used by the optimize to solve the sparse matrix A
(which will be J.T.dot(J), where J is the Jacobian of the objective
function). The structure of A is such that... | code_fim | hard | {
"lang": "python",
"repo": "lillekemiker/blmath",
"path": "/blmath/numerics/linalg/sparse_cg.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: transientskp/tkp path: /tests/test_sourcefinder/test_deconv.py
import unittest
from tkp.sourcefinder.deconv import deconv
class DecovolutionTestCase(unittest.TestCase):
"""
Known-good values as calculated by deconv.f from classic AIPS.
"""
def test_known_good(self):
# Ea... | code_fim | hard | {
"lang": "python",
"repo": "transientskp/tkp",
"path": "/tests/test_sourcefinder/test_deconv.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>0)),
((2.7, 1.7, 0, 1, 1, 0), (2.507987240796891, 1.3747727084867518, 0.0, 0)),
((2.7, 1.7, 0, 1, 1, 180), (2.507987240796891, 1.3747727084867518, 0.0, 0)),
((2.7, 1.7, 0, 1, 1, 90), (2.507987240796891, 1.3747727084867518, 0.0, 0)),
((2.7, 1.7, 0, 1, 1, 45),... | code_fim | hard | {
"lang": "python",
"repo": "transientskp/tkp",
"path": "/tests/test_sourcefinder/test_deconv.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>0.0, 0)),
((2.7, 1.7, 20, 1, 1, 180), (2.507987240796891, 1.3747727084867518, 20.0, 0)),
((2.7, 1.7, 30, 1, 1, 90), (2.507987240796891, 1.3747727084867516, 30.0, 0)),
((2.7, 1.7, 40, 1, 1, 45), (2.507987240796891, 1.3747727084867518, 40.0, 0))
]
for args... | code_fim | hard | {
"lang": "python",
"repo": "transientskp/tkp",
"path": "/tests/test_sourcefinder/test_deconv.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> global did_dir
try:
data = load_pkl(fdir=did_dir, f='reports')
return data
except FileNotFoundError:
print('Creating report dataframe...')
return _create_report_dataframe()
def _preprocess_data():
'''Tokenize text into character encoding or word token enco... | code_fim | hard | {
"lang": "python",
"repo": "folagit/examples",
"path": "/vae/utils/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.path.isfile(loadas):
try:
input = open(loadas, mode='rb')
dat = pickle.load(input)
input.close()
return dat
except:
raise OSError('can\'t open file %s' % loadas)
return None
def _create_report_dataframe():
da... | code_fim | hard | {
"lang": "python",
"repo": "folagit/examples",
"path": "/vae/utils/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.