text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: bpRsh/a2_devExp_galfit path: /expdisk/missing_and_bad_fitted_galaxies.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-#
#
# Author : Bhishan Poudel; Physics Graduate Student, Ohio University
# Date : Jan 4, 2017
# Last update : Feb 12, 2017
# Est time :
# Imports
import os
import... | code_fim | hard | {
"lang": "python",
"repo": "bpRsh/a2_devExp_galfit",
"path": "/expdisk/missing_and_bad_fitted_galaxies.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # total summary
nmissing300 = nmissing100 + nmissing200
nbad300 = nbad100 + nbad200
nmissing_bad300 = nmissing300 + nbad300
ngood300 = total - nmissing_bad300
print('total = ', total)
print('nmissing300 = ', nmissing300)
print('nbad300 = ', nbad300... | code_fim | hard | {
"lang": "python",
"repo": "bpRsh/a2_devExp_galfit",
"path": "/expdisk/missing_and_bad_fitted_galaxies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>## Draw the event horizon.
z=-0.05
rad = np.sqrt(-t/z-t**2)
generalized_circle2(draw, r=r, center=np.array([0,0,z]),
vec=np.array([0,0,1]),
radius=rad,
rgba="red")<|fim_prefix|># repo: ryu577/pyray path: /gifs/black_hole/bh_warp.py
import numpy ... | code_fim | hard | {
"lang": "python",
"repo": "ryu577/pyray",
"path": "/gifs/black_hole/bh_warp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ix=0
z1 = -0.000001
while abs(z1) < 1/t:
ix += 1
z1 -= 0.0001*ix**1.1
z = z1
rad = np.sqrt(-t/z-t**2)
generalized_circle2(draw, r=r,
center=np.array([0,0,z]),
vec=np.array([0, 0, 1]),
radius=rad,
... | code_fim | hard | {
"lang": "python",
"repo": "ryu577/pyray",
"path": "/gifs/black_hole/bh_warp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryu577/pyray path: /gifs/black_hole/bh_warp.py
import numpy as np
from PIL import Image, ImageDraw, ImageFont, ImageMath
import os
from pyray.shapes.twod.paraboloid import *
from pyray.shapes.twod.functional import *
from pyray.rotation import *
<|fim_suffix|>r1 = np.eye(4)
rot = general_rotatio... | code_fim | medium | {
"lang": "python",
"repo": "ryu577/pyray",
"path": "/gifs/black_hole/bh_warp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jzbahrai/tabbycat path: /standings/urls_admin.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.standings_index, name='standings-index'),
url(r'^team/$', views.TeamStandingsView.as_view(), name='standings-team'),
... | code_fim | medium | {
"lang": "python",
"repo": "jzbahrai/tabbycat",
"path": "/standings/urls_admin.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>^speaker/$', views.speaker_standings, name='standings-speaker'),
url(r'^novices/$', views.novice_standings, name='standings-novice'),
url(r'^reply/$', views.reply_standings, name='standings-reply'),
url(r'^motions/$', views.motion_standings, ... | code_fim | medium | {
"lang": "python",
"repo": "jzbahrai/tabbycat",
"path": "/standings/urls_admin.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>class HeatMapData(Qwt.QwtRasterData):
def __init__(self, x, y, nx, ny):
Qwt.QwtRasterData.__init__(self, Qt.QRectF(min(x), min(y), max(x)-min(x), max(y)-min(y)))
self.x = x
self.y = y
self.nx = nx
self.ny = ny
self.minx = min(x)
self.miny = min... | code_fim | hard | {
"lang": "python",
"repo": "JuliaPackageMirrors/Qwt.jl",
"path": "/src/python/BasicPlot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def legendclick(self, item):
if item.isVisible():
item.hide()
else:
item.show()
item.setItemAttribute(Qwt.QwtPlotItem.AutoScale, item.isVisible())
self.startUpdate()
self.finishUpdate()
def __initZooming(self):
zoomer = Qwt.... | code_fim | hard | {
"lang": "python",
"repo": "JuliaPackageMirrors/Qwt.jl",
"path": "/src/python/BasicPlot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JuliaPackageMirrors/Qwt.jl path: /src/python/BasicPlot.py
import sys, os, time
import PyQt4.Qwt5 as Qwt
from PyQt4 import Qt
import numpy as np
# this is a bare bones wrapper around Qwt5's plotting
# it was built to be called from Julia code, and doesn't have full functionality by itself
# inclu... | code_fim | hard | {
"lang": "python",
"repo": "JuliaPackageMirrors/Qwt.jl",
"path": "/src/python/BasicPlot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # optimizer take step forward.
optimizer.step()
# tabulate the steps from the evaluation
eval_result = {k: eval_result[k].item() for k in eval_result}
# update every hundreds' of
if index % 100 == 0:
print(index, eva... | code_fim | hard | {
"lang": "python",
"repo": "Julienbeaulieu/kaggle-computer-vision-competition",
"path": "/src/models/model_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Take a configuration node and train the model from it.
:param config:
:return:
"""
if config is None:
config = self.config
# Create writable timestamp for easier record keeping
timestamp = datetime.now().isoformat(sep="T", tim... | code_fim | hard | {
"lang": "python",
"repo": "Julienbeaulieu/kaggle-computer-vision-competition",
"path": "/src/models/model_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Julienbeaulieu/kaggle-computer-vision-competition path: /src/models/model_train.py
"""
train model
Usage:
train.py -path_output=<path> [--path_cfg_data=<path>] [--path_cfg_override=<path>]
train.py -h | --help
Options:
-h --help show this screen help
-path_output=... | code_fim | hard | {
"lang": "python",
"repo": "Julienbeaulieu/kaggle-computer-vision-competition",
"path": "/src/models/model_train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: icexmoon/python-learning-notes path: /note38/metaclass_test2.py
class TestMetaClass(type):
def __init__(cls, clsName, bases, clsBody):
super().__init__(clsName, bases, clsBody)
print('TestMetaClass.__init__() is called')
def new_func(self):
print("new_func(... | code_fim | medium | {
"lang": "python",
"repo": "icexmoon/python-learning-notes",
"path": "/note38/metaclass_test2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class SubTestClass(TestClass):
def func_x(self):
print('SubTestClass.func_x() is called')
class SubTestClass2(TestClass):
def func_x(self):
super().func_x()
test = TestClass()
test.func_x()
test2 = SubTestClass()
test2.func_x()
test3 = SubTestClass2()
test3.func_x()
# TestMetaC... | code_fim | medium | {
"lang": "python",
"repo": "icexmoon/python-learning-notes",
"path": "/note38/metaclass_test2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_size:
## add all sequences in the cluster to be sure
## clust shold include rep already but just in case
out.write("\n".join(list(set(clust)|set([rep])))+"\n")<|fim_prefix|># repo: andreyto/YAP path: /MakeAccnosFromName.py
import argparse
import os
parser... | code_fim | hard | {
"lang": "python",
"repo": "andreyto/YAP",
"path": "/MakeAccnosFromName.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andreyto/YAP path: /MakeAccnosFromName.py
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("-n","--name", help="name file")
parser.add_argument("-s","--min-cluster-size", type=int, help="cluster size cutoff")
args = parser.parse_args()
name = args.name.strip()
as... | code_fim | hard | {
"lang": "python",
"repo": "andreyto/YAP",
"path": "/MakeAccnosFromName.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_write_lines(tmp_pathplus):
tmp_file = tmp_pathplus / "test.txt"
contents = [
"this ",
"is",
'a',
"list",
"of",
"words",
"to",
"write\t\t\t",
"to",
"the",
"file",
]
tmp_file.write_lines(contents)
content = tmp_file.read_text()
assert content == "this\n... | code_fim | hard | {
"lang": "python",
"repo": "domdfcoding/domdf_python_tools",
"path": "/tests/test_paths.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: domdfcoding/domdf_python_tools path: /tests/test_paths.py
pathplus / "test.txt"
contents = [
"this ",
"is",
'a',
"list",
"of",
"words",
"to",
"write\t\t\t",
"to",
"the",
"file",
]
tmp_file.write_lines(contents, trailing_whitespace=True)
content = tmp_fil... | code_fim | hard | {
"lang": "python",
"repo": "domdfcoding/domdf_python_tools",
"path": "/tests/test_paths.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tmp_file.dump_json({"key": "value", "int": 1234, "float": 12.34}, compress=True)
assert tmp_file.load_json(decompress=True) == {"key": "value", "int": 1234, "float": 12.34}
tmp_file.dump_json({"key": "value", "int": 1234, "float": 12.34}, indent=2, compress=True)
assert tmp_file.load_json(decompress=... | code_fim | hard | {
"lang": "python",
"repo": "domdfcoding/domdf_python_tools",
"path": "/tests/test_paths.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KathleenLabrie/KLpyastro path: /klpyastro/utils/throughput.py
from astropy.io import ascii
from astropy import units as u
import numpy as np
class AtmosphericTransparency:
def __init__(self, filename, wunit='Angstrom'):
data = ascii.read(filename)
self.wlen = data.field('wlen... | code_fim | hard | {
"lang": "python",
"repo": "KathleenLabrie/KLpyastro",
"path": "/klpyastro/utils/throughput.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_bands_for_range(self, lower, upper):
bands = []
for (wlen, name) in bands_table:
if wlen >= lower and wlen <= upper:
band = TransmissionBand(name)
bands.append(band)
return bands
BANDS_TABLE = [(1.2 * u.micron, 'J-band'),
... | code_fim | hard | {
"lang": "python",
"repo": "KathleenLabrie/KLpyastro",
"path": "/klpyastro/utils/throughput.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoaoCostaIFG/MNUM path: /exams/2014/6_golden_rule.py
#!/usr/bin/env python3
from math import sin, sqrt
def f(x):
return x + ((x - 2)**2) / (sin(x) + 4)
B = (sqrt(5) - 1) / 2
A = B**2
x1 = -1
x2 = 1.5
x3 = -0.045080
x4 = 0.545085
# x3 = A * (x2 - x1) + x1
# x4 = B * (x2 - x1) + x1
print... | code_fim | medium | {
"lang": "python",
"repo": "JoaoCostaIFG/MNUM",
"path": "/exams/2014/6_golden_rule.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("x1:", x1, "x2:", x2, "x3:", x3, "x4:", x4)
print("f(x1)", f(x1), "f(x2)", f(x2), "f(x3)", f(x3), "f(x4)", f(x4), "\n")<|fim_prefix|># repo: JoaoCostaIFG/MNUM path: /exams/2014/6_golden_rule.py
#!/usr/bin/env python3
from math import sin, sqrt
def f(x):
return x + ((x - 2)**2) / (sin... | code_fim | medium | {
"lang": "python",
"repo": "JoaoCostaIFG/MNUM",
"path": "/exams/2014/6_golden_rule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(2):
if (f(x3) < f(x4)):
x2 = x4
x4 = x3
x3 = x1 + A * (x2 - x1)
else:
x1 = x3
x3 = x4
x4 = x1 + B * (x2 - x1)
print("x1:", x1, "x2:", x2, "x3:", x3, "x4:", x4)
print("f(x1)", f(x1), "f(x2)", f(x2), "f(x3)", f(x3), "f(x4)", f(x... | code_fim | hard | {
"lang": "python",
"repo": "JoaoCostaIFG/MNUM",
"path": "/exams/2014/6_golden_rule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Kill the service. Note killing the service for a ManagedConnection will
# result in a ServiceError because we have not ended the session we started
# with env.reset() above. For UnmanagedConnection, this error will not be
# raised.
try:
env.service.close()
except ServiceE... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/CompilerGym",
"path": "/tests/llvm/service_connection_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: facebookresearch/CompilerGym path: /tests/llvm/service_connection_test.py
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Integrations tests for the LLVM CompilerGym... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/CompilerGym",
"path": "/tests/llvm/service_connection_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>stdio.writeln(str((-b + d) / 2))
stdio.writeln(str((-b - d) / 2))<|fim_prefix|># repo: h-dychko/IntroToPython path: /Chapter1/quadratic.py
import math
import sys
import stdio
<|fim_middle|>
b, c = map(float, sys.argv[1:3])
discriminant = b ** 2 - 4 * c
d = math.sqrt(discriminant)
| code_fim | medium | {
"lang": "python",
"repo": "h-dychko/IntroToPython",
"path": "/Chapter1/quadratic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: h-dychko/IntroToPython path: /Chapter1/quadratic.py
import math
import sys
import stdio
b, c = map(float, sys.argv[1:3])
<|fim_suffix|>stdio.writeln(str((-b + d) / 2))
stdio.writeln(str((-b - d) / 2))<|fim_middle|>discriminant = b ** 2 - 4 * c
d = math.sqrt(discriminant)
| code_fim | easy | {
"lang": "python",
"repo": "h-dychko/IntroToPython",
"path": "/Chapter1/quadratic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: h-dychko/IntroToPython path: /Chapter1/quadratic.py
import math
import sys
import stdio
<|fim_suffix|>stdio.writeln(str((-b + d) / 2))
stdio.writeln(str((-b - d) / 2))<|fim_middle|>
b, c = map(float, sys.argv[1:3])
discriminant = b ** 2 - 4 * c
d = math.sqrt(discriminant)
| code_fim | medium | {
"lang": "python",
"repo": "h-dychko/IntroToPython",
"path": "/Chapter1/quadratic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def run_send_nologin():
muser = MUser()
user_recs = muser.query_nologin()
for user_rec in user_recs:
email_add = user_rec.user_email
print(email_add)
send_mail([email_add], "{0}|{1}".format(smtp_cfg['name'], email_cfg['title']), email_cfg['content'])
muse... | code_fim | hard | {
"lang": "python",
"repo": "strogo/TorCMS",
"path": "/torcms/script/script_sendemail_all.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: strogo/TorCMS path: /torcms/script/script_sendemail_all.py
# -*- coding: utf-8
from torcms.core.tool.send_email import send_mail
from torcms.model.user_model import MUser
import time
from config_email import email_cfg
from config import smtp_cfg
<|fim_suffix|> muser = MUser()
... | code_fim | hard | {
"lang": "python",
"repo": "strogo/TorCMS",
"path": "/torcms/script/script_sendemail_all.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> state = self._pin_states[pin.location]
return pingo.HIGH if state else pingo.LOW
def _get_pin_value(self, pin):
return self._pin_states[pin.location]
def _get_pwm_duty_cycle(self, pin):
return self._pin_states[pin.location]
def _set_pwm_duty_cycle(self, pin, ... | code_fim | hard | {
"lang": "python",
"repo": "garoa/pingo",
"path": "/pingo/ghost/ghost.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: garoa/pingo path: /pingo/ghost/ghost.py
import pingo
class GhostBoard(
pingo.Board,
pingo.AnalogInputCapable,
pingo.PwmOutputCapable
):
def __init__(self, filepath=None):
super(GhostBoard, self).__init__()
# Arduino ATmega168/328 pin mapping
pins = set(... | code_fim | hard | {
"lang": "python",
"repo": "garoa/pingo",
"path": "/pingo/ghost/ghost.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('GhostBoard: cleaning up.')
def _set_pin_mode(self, pin, mode):
print('GhostBoard: %r mode -> %s' % (pin, mode))
def _set_analog_mode(self, pin, mode):
self._set_pin_mode(pin, mode)
def _set_pwm_mode(self, pin, mode):
self._set_pin_mode(pin, mode)
... | code_fim | hard | {
"lang": "python",
"repo": "garoa/pingo",
"path": "/pingo/ghost/ghost.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deirdresm/swarfarm path: /bestiary/parse/util.py
import difflib
def update_bestiary_obj(model, com2us_id, defaults):
obj, created = model.objects.get_or_create(com2us_id=com2us_id, defaults=defaults)
if created:
print(f'!!! Created new {model.__name__} {com2us_id}')
else:
... | code_fim | hard | {
"lang": "python",
"repo": "deirdresm/swarfarm",
"path": "/bestiary/parse/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def show_diff(seqm):
"""Unify operations between two compared strings
seqm is a difflib.SequenceMatcher instance whose a & b are strings"""
output= []
for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
if opcode == 'equal':
output.append(seqm.a[a0:a1])
elif opcode ==... | code_fim | hard | {
"lang": "python",
"repo": "deirdresm/swarfarm",
"path": "/bestiary/parse/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/ec2-api path: /ec2api/api/image.py
apshots.
# As other code doesn't take it into consideration, here we don't
# care of it for now. Ostrich algorithm
def create_image(context, instance_id, name=None, description=None,
no_reboot=False, block_device_mapping=None):
ins... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/api/image.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'is_public' not in item:
return None
# NOTE(ft): process creating images, ignoring ids mapping
# NOTE(ft): the image is being creating, Glance had created
# image, but creating thread doesn't yet update db item
os_image = self.ec2_created_os_images.g... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/api/image.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # NOTE(andrey-mp): launchPermission structure is converted here
# to plain parameters: attribute, user_group, operation_type, user_id
if launch_permission is not None:
attributes.add('launchPermission')
user_group = list()
user_id = list()
if len(launch_permissi... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/api/image.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: songjiguo2019/CarND-Advanced-Lane-Lines path: /examples/example.py
t_img = '../camera_cal/calibration1.jpg'
test_images_path = '../test_images/'
output_images_path = '../output_images/'
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((chessboard_height*chessb... | code_fim | hard | {
"lang": "python",
"repo": "songjiguo2019/CarND-Advanced-Lane-Lines",
"path": "/examples/example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Convert pixel offset to meters
vehicle_offset *= xm_per_pix
return vehicle_offset
def final_viz(undist, left_fit, right_fit, m_inv, left_curve, right_curve, vehicle_offset):
"""
Final lane line prediction visualized and overlayed on top of original image
"""
# Generate x ... | code_fim | hard | {
"lang": "python",
"repo": "songjiguo2019/CarND-Advanced-Lane-Lines",
"path": "/examples/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def measure_curvature_pixels(ploty, leftx, lefty, rightx, righty):
"""
Calculates the curvature of polynomial functions in pixels.
"""
# Start by generating our fake example data
# Make sure to feed in your real data instead in your project!
#ploty, left_fit, right_fit = generate... | code_fim | hard | {
"lang": "python",
"repo": "songjiguo2019/CarND-Advanced-Lane-Lines",
"path": "/examples/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_next_task(empty):
mutable_obj = dict()
next_task = Task(mutate_dict, None, call_args=(mutable_obj, "test", 3))
t = Task(empty, lambda: 5, next_task=next_task)
t.invoke()
# since empty does nothing, it will not fail, and next_task should be called
assert mutable_obj == {"te... | code_fim | hard | {
"lang": "python",
"repo": "dleonard-nasuni/occasionally",
"path": "/tests/test_tasks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dleonard-nasuni/occasionally path: /tests/test_tasks.py
import time
import pytest
from occasionally.task import Task, MaxCallException
def mutate_dict(d, k, v):
# dict[key] = value. lambda's can't have assignments in them
d[k] = v
def raise_exception():
raise Exception("Error")
de... | code_fim | medium | {
"lang": "python",
"repo": "dleonard-nasuni/occasionally",
"path": "/tests/test_tasks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NNgen/nngen path: /nngen/verilog.py
for obj in unified_storage_list])
i = ('variables %s (size: %s)' %
(names, size_str(unified_storage_used)))
global_map_info[unified_global_index] = i
# temporal
for obj in sorted(objs, key=lambda x: x.... | code_fim | hard | {
"lang": "python",
"repo": "NNgen/nngen",
"path": "/nngen/verilog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NNgen/nngen path: /nngen/verilog.py
t.is_output_chainable_operator(obj) and
not obj.chain_head):
continue
srcs = obj.collect_sources()
for src in srcs:
if src.global_index is not None:
continue
if bt.is_view(sr... | code_fim | hard | {
"lang": "python",
"repo": "NNgen/nngen",
"path": "/nngen/verilog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
# miss
width_dict, signed_dict = calc_control_param_width(control_param_list)
obj.make_control_params(control_param_len, width_dict, signed_dict,
use_param_ram=config['use_param_ram'],
... | code_fim | hard | {
"lang": "python",
"repo": "NNgen/nngen",
"path": "/nngen/verilog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_message(self, title, package, text, image):
print("Displaying notification")
self.label_title['text'] = title
self.label_package['text'] = package
self.label_text['text'] = text
self.image = ImageTk.PhotoImage(Image.open(image))
self.image_p... | code_fim | hard | {
"lang": "python",
"repo": "JustinLokHinWu/OpenEyeTap",
"path": "/OpenEyetap_Applications/Bluetooth/interface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.label_title = Label(self.topFrame, text="Waiting for connection...", fg="white", bg="black")
self.label_title.config(font=("Arial", 40))
self.image = ImageTk.PhotoImage(Image.open("resources/notif.png"))
self.image_panel = Label(self.topFrame, image=self.image... | code_fim | hard | {
"lang": "python",
"repo": "JustinLokHinWu/OpenEyeTap",
"path": "/OpenEyetap_Applications/Bluetooth/interface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JustinLokHinWu/OpenEyeTap path: /OpenEyetap_Applications/Bluetooth/interface.py
from tkinter import *
import PIL
from PIL import ImageTk, Image
import os
import threading
import time
class interface(threading.Thread):
def run(self):
self.root = Tk()
self.root.configure(backgr... | code_fim | hard | {
"lang": "python",
"repo": "JustinLokHinWu/OpenEyeTap",
"path": "/OpenEyetap_Applications/Bluetooth/interface.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def id(self) -> Optional[int]:
if self.user:
return self.user.id
return<|fim_prefix|># repo: dontbanmeplz/dippy.core path: /dippy/core/models/member.py
from datetime import datetime
from dippy.core.models.model import DippyCoreCacheableModel
from dippy.core.m... | code_fim | hard | {
"lang": "python",
"repo": "dontbanmeplz/dippy.core",
"path": "/dippy/core/models/member.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dontbanmeplz/dippy.core path: /dippy/core/models/member.py
from datetime import datetime
from dippy.core.models.model import DippyCoreCacheableModel
from dippy.core.models.user import UserModel
from dippy.core.snowflake import Snowflake
from pydantic import Field
from typing import Optional
cla... | code_fim | hard | {
"lang": "python",
"repo": "dontbanmeplz/dippy.core",
"path": "/dippy/core/models/member.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> datetime = DatetimeHandler()
current = datetime.get_current_date()
dict_contents = [{'username': content} for content in contents]
csv_file_name = FILE_PATH + title + '_' + current + '.csv'
with open(csv_file_name, 'w', newline='') as f:
field_names = ['... | code_fim | hard | {
"lang": "python",
"repo": "chloe-codes1/iam-manager",
"path": "/src/utils/file_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def write_csv_file(self, title, contents):
datetime = DatetimeHandler()
current = datetime.get_current_date()
dict_contents = [{'username': content} for content in contents]
csv_file_name = FILE_PATH + title + '_' + current + '.csv'
with open(csv_file_name, 'w',... | code_fim | hard | {
"lang": "python",
"repo": "chloe-codes1/iam-manager",
"path": "/src/utils/file_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chloe-codes1/iam-manager path: /src/utils/file_handler.py
import csv
from utils.datetime_handler import DatetimeHandler
from configs.configs import FILE_PATH
<|fim_suffix|> with open(title, 'r') as f:
print(f.read())
def write_csv_file(self, title, contents):
da... | code_fim | hard | {
"lang": "python",
"repo": "chloe-codes1/iam-manager",
"path": "/src/utils/file_handler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
content_file_path = args.content_file
content_file_type = mimetypes.guess_type(content_file_path)
readability = None
if content_file_type[0][:4] == "text" or \
(content_file_type[0] == None and content_file_type[1] == None):
readability = 'r'
else:
readabilit... | code_fim | hard | {
"lang": "python",
"repo": "arcsector/cabby",
"path": "/cabby/cli/push.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arcsector/cabby path: /cabby/cli/push.py
import logging
import mimetypes
from cabby.entities import ContentBinding
from cabby.constants import CB_STIX_XML_111
from .commons import run_client, get_basic_arg_parser
log = logging.getLogger(__name__)
DEFAULT_BINDING = CB_STIX_XML_111
<|fim_suff... | code_fim | hard | {
"lang": "python",
"repo": "arcsector/cabby",
"path": "/cabby/cli/push.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.binding and args.subtypes:
binding = ContentBinding(args.binding, subtypes=args.subtypes)
elif args.binding:
binding = args.binding
else:
binding = None
client.push(content, binding, collection_names=args.collections, uri=path)
log.info("Content block ... | code_fim | hard | {
"lang": "python",
"repo": "arcsector/cabby",
"path": "/cabby/cli/push.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> LaunchMethod.__init__(self, name, cfg, session)
# --------------------------------------------------------------------------
#
def _configure(self):
# ccmrun: Cluster Compatibility Mode (CCM) job launcher for Cray systems
self.launch_command = ru.which('ccmrun')
... | code_fim | hard | {
"lang": "python",
"repo": "karahbit/radical.pilot",
"path": "/src/radical/pilot/agent/launch_method/ccmrun.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karahbit/radical.pilot path: /src/radical/pilot/agent/launch_method/ccmrun.py
__copyright__ = "Copyright 2016, http://radical.rutgers.edu"
__license__ = "MIT"
import radical.utils as ru
from .base import LaunchMethod
# ----------------------------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "karahbit/radical.pilot",
"path": "/src/radical/pilot/agent/launch_method/ccmrun.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smcclennon/SongID path: /SongID.py
print(' _ _ ---==== SongID ====--- _ _\n')
from SongIDProcessor import SIDProcessor
from SongIDCore import *
from telegram import ParseMode
from telegram.utils.helpers import mention_html
import sys, traceback
from threading import Thread
import url... | code_fim | hard | {
"lang": "python",
"repo": "smcclennon/SongID",
"path": "/SongID.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Respond when the user sends the '/start' command
# (When the user adds a telegram bot, they are forced to send '/start')
def startCMD(update, context):
logusr(update)
userID=str(update.effective_chat.id)
username=str(update.effective_chat.username)
if userID not in userdata:
SIDP... | code_fim | hard | {
"lang": "python",
"repo": "smcclennon/SongID",
"path": "/SongID.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>SongID was originally created as a proof of concept, and I had no idea that it would become this popular.
View SongID and my other projects here: github.com/smcclennon
''')
devsend(update, context, '\'{update.message.text}\'')
logbot(update, '*Sent \'/limit\' response*')
# Respond when the user... | code_fim | hard | {
"lang": "python",
"repo": "smcclennon/SongID",
"path": "/SongID.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def upgrade():
connection = op.get_bind()
op.add_column("snapshots", sa.Column("submitted_url", sa.Text, nullable=True))
for snapshot in connection.execute(snapshot_helper.select()):
connection.execute(
snapshot_helper.update()
.where(snapshot_helper.c.id == ... | code_fim | hard | {
"lang": "python",
"repo": "Blue-infosec/uzen",
"path": "/migrations/versions/830b79ba652c_add_submitted_url_to_snapshots.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Blue-infosec/uzen path: /migrations/versions/830b79ba652c_add_submitted_url_to_snapshots.py
"""add submitted_url to snapshots
Revision ID: 830b79ba652c
Revises: b1cf161d2071
Create Date: 2020-03-14 09:04:29.633742
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used... | code_fim | hard | {
"lang": "python",
"repo": "Blue-infosec/uzen",
"path": "/migrations/versions/830b79ba652c_add_submitted_url_to_snapshots.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.figury.append(graphic)
def remove(self, graphic):
self.figury.remove(graphic)
def GetChild(self, child):
return self.figury[child]<|fim_prefix|># repo: Paarzivall/Wzorce-Projektowe path: /Zad_Composite/Picture.py
from Graphic import Graphic
class Picture(Graphic):... | code_fim | medium | {
"lang": "python",
"repo": "Paarzivall/Wzorce-Projektowe",
"path": "/Zad_Composite/Picture.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Paarzivall/Wzorce-Projektowe path: /Zad_Composite/Picture.py
from Graphic import Graphic
class Picture(Graphic):
def __init__(self):
self.figury = []
def draw(self):
for figura in self.figury:
figura.draw()
<|fim_suffix|> def remove(self, graphic):
... | code_fim | medium | {
"lang": "python",
"repo": "Paarzivall/Wzorce-Projektowe",
"path": "/Zad_Composite/Picture.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># read atomic masses
state_folder = 'matfiles_allpoly_iptotal_12'
M = read_atom(state_folder)
M = np.array([M]).T
N_atom = len(M)
M = np.reshape(np.matlib.repmat(M,1,3),(3*N_atom,1))
ev2ieu = 9.648e-3 # convert 1 eV to internal energy units [IEU = amu * angstrom^2 fs^(-2)]
# set input record
inpRec = d... | code_fim | hard | {
"lang": "python",
"repo": "zbmorrow/mixed_basis_rrmd",
"path": "/examples/md_rrSurf_poly.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zbmorrow/mixed_basis_rrmd path: /examples/md_rrSurf_poly.py
import numpy as np
import numpy.matlib
import os, sys
sys.path.append('../src/')
import Tasmanian as tsg # must have Tasmanian in PYTHONPATH variable
import time
from rrmd_core import *
import scipy.optimize
if len(sys.argv) > 3:
... | code_fim | hard | {
"lang": "python",
"repo": "zbmorrow/mixed_basis_rrmd",
"path": "/examples/md_rrSurf_poly.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>dataE = ev2ieu * np.loadtxt('%s/energy.dat' % state_folder)
dataE = np.reshape(dataE,(N_poly,1))
sg_energy.loadNeededPoints(dataE)
inpRec['UQ'] = lambda Q: sg_energy.evaluate(pbcfun(Q, inpRec['N_per']))
inpRec['dUdQ'] = lambda Q: eval_grad(pbcfun(Q, inpRec['N_per']), sg=sg_energy)
# Cartesian geometry
s... | code_fim | hard | {
"lang": "python",
"repo": "zbmorrow/mixed_basis_rrmd",
"path": "/examples/md_rrSurf_poly.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whai362/PSENet path: /dataset/__init__.py
from .psenet import PSENET_IC15, PSENET_TT, <|fim_suffix|>', 'PSENET_TT', 'PSENET_CTW', 'PSENET_Synth']<|fim_middle|>PSENET_Synth, PSENET_CTW
from .builder import build_data_loader
__all__ = ['PSENET_IC15 | code_fim | medium | {
"lang": "python",
"repo": "whai362/PSENet",
"path": "/dataset/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whai362/PSENet path: /dataset/__init__.py
from .psenet import PSENET_IC15, PSENET_TT, PSENET_Synth, PSENET_CTW
from .builder impor<|fim_suffix|>', 'PSENET_TT', 'PSENET_CTW', 'PSENET_Synth']<|fim_middle|>t build_data_loader
__all__ = ['PSENET_IC15 | code_fim | easy | {
"lang": "python",
"repo": "whai362/PSENet",
"path": "/dataset/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>', 'PSENET_TT', 'PSENET_CTW', 'PSENET_Synth']<|fim_prefix|># repo: whai362/PSENet path: /dataset/__init__.py
from .psenet import PSENET_IC15, PSENET_TT, <|fim_middle|>PSENET_Synth, PSENET_CTW
from .builder import build_data_loader
__all__ = ['PSENET_IC15 | code_fim | medium | {
"lang": "python",
"repo": "whai362/PSENet",
"path": "/dataset/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IntelligentNetworkingLAB/Deep-Learning-Model-Generator path: /Resouce allocation module/BILP.py
from gekko import GEKKO
import random
FinalResults = []
for iter in range(1, 5):
m = GEKKO()
m.options.SOLVER = 1
m.solver_options = ['minlp_max_iter_with_int_sol 1000000','minlp_maximum_... | code_fim | medium | {
"lang": "python",
"repo": "IntelligentNetworkingLAB/Deep-Learning-Model-Generator",
"path": "/Resouce allocation module/BILP.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Objective Function'''
m.Maximize(Z)
'''Constraints'''
for i in X :
i.lower = 0
for i in range(int(len(X)/len(R))) :
eq = 0
for j in range(len(R)) :
eq += X[i*len(R) + j]
m.Equation(eq == 1)
for i in range(len(R)) :
eq = 0
... | code_fim | medium | {
"lang": "python",
"repo": "IntelligentNetworkingLAB/Deep-Learning-Model-Generator",
"path": "/Resouce allocation module/BILP.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_content(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
def test_command_line_interface():
"""Test the CLI."""
runner = CliRunner()
res... | code_fim | medium | {
"lang": "python",
"repo": "wooyek/django-opt-out",
"path": "/tests/test_cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wooyek/django-opt-out path: /tests/test_cli.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `django-opt-out` package."""
import unittest
import django
import pytest
from click.testing import CliRunner
from django.test import TestCase
import django_opt_out
from django_opt_out impor... | code_fim | hard | {
"lang": "python",
"repo": "wooyek/django-opt-out",
"path": "/tests/test_cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif card == 'any':
if not name.endswith('s'):
name += 's'
case_bodies[vpi] = (case_bodies.get(vpi, (None, None))[0], name)
content = []
content.append(f'std::tuple<const BaseClass*, UHDM_OBJECT_TYPE, const std::vector<const BaseClas... | code_fim | hard | {
"lang": "python",
"repo": "alainmarcel/UHDM",
"path": "/scripts/classes.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alainmarcel/UHDM path: /scripts/classes.py
st<ElaboratorContext*>(context);')
content.append(f' elaboratorContext->m_elaborator.enter{Classname}(this, nullptr);')
if 'Net' in vpi_name:
includes.add('ElaboratorListener')
content.append( ' ElaboratorCo... | code_fim | hard | {
"lang": "python",
"repo": "alainmarcel/UHDM",
"path": "/scripts/classes.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alainmarcel/UHDM path: /scripts/classes.py
stant', 'tagged_pattern', 'gen_scope_array', 'hier_path', 'cont_assign' ]:
return content, includes # Use hardcoded implementations of DeepClone
if modeltype == 'obj_def':
# DeepClone() not implemented for class_def; just declare to... | code_fim | hard | {
"lang": "python",
"repo": "alainmarcel/UHDM",
"path": "/scripts/classes.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>toEncode = "The quick brown fox jumps over the lazy dog"
print("Encoding:", toEncode)
encoded = encode(toEncode, key)
print("Encoded: ", encoded)
print("Decoded: ", decode(encoded, key))<|fim_prefix|># repo: BaptisteMiq/hill-cipher-algorithm-python path: /main.py
import numpy as np
from hill_cypher impo... | code_fim | hard | {
"lang": "python",
"repo": "BaptisteMiq/hill-cipher-algorithm-python",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BaptisteMiq/hill-cipher-algorithm-python path: /main.py
import numpy as np
from hill_cypher import encode, decode
<|fim_suffix|>print("Encoding:", toEncode)
encoded = encode(toEncode, key)
print("Encoded: ", encoded)
print("Decoded: ", decode(encoded, key))<|fim_middle|># key = np.array([[9, 4],... | code_fim | hard | {
"lang": "python",
"repo": "BaptisteMiq/hill-cipher-algorithm-python",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService",
generator = cms.PSet(
initialSeed = cms.untracked.uint32(123456789),
engineName = cms.untracked.string('HepJamesRandom')
)
)
process.randomEngineStateProducer = cms.EDProducer("RandomEngineStateProdu... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/GeneratorInterface/ExternalDecays/test/Py8GenFilter_W2TauNu_Tauola_cfg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(5)
)
process.GEN = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('Test_Py8_W2TauNu_TauolaCxx.root')
)
process.p = cms.Path(process.generator)
process.p1 = cms.Path(process.randomEngineStateProducer)
proces... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/GeneratorInterface/ExternalDecays/test/Py8GenFilter_W2TauNu_Tauola_cfg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /GeneratorInterface/ExternalDecays/test/Py8GenFilter_W2TauNu_Tauola_cfg.py
import FWCore.ParameterSet.Config as cms
process = cms.Process("TEST")
process.load("FWCore.Framework.test.cmsExceptionsFatal_cff")
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.sour... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/GeneratorInterface/ExternalDecays/test/Py8GenFilter_W2TauNu_Tauola_cfg.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rosebotics/PythonGameDesign2018 path: /camp/Thomas/Day 1 - The Game Loop, Colors, Drawing and Animation/06-InteractingWithAPlayer.py
import pygame
import sys
nose_y_position=242
pygame.init()
pygame.display.set_caption('Animation')
screen = pygame.display.set_mode((640, 480))
clock = pygame.tim... | code_fim | hard | {
"lang": "python",
"repo": "Rosebotics/PythonGameDesign2018",
"path": "/camp/Thomas/Day 1 - The Game Loop, Colors, Drawing and Animation/06-InteractingWithAPlayer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ame.draw.circle(screen, (255, 230, 130), (21, nose_y_position), 200, 40)
pygame.draw.circle(screen, (23, 29, 255), (321, nose_y_position), 160, 40)
pygame.draw.circle(screen, (242, 239, 255,), (321, nose_y_position), 140, 40)
pygame.draw.circle(screen, (83, 239, 170,), (321, nose_y_position), ... | code_fim | hard | {
"lang": "python",
"repo": "Rosebotics/PythonGameDesign2018",
"path": "/camp/Thomas/Day 1 - The Game Loop, Colors, Drawing and Animation/06-InteractingWithAPlayer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juryowl/hypothesis path: /hypothesis/auto/training/amortized_ratio_estimation.py
import hypothesis
import numpy as np
import os
import re
import torch
from .base import BaseTrainer
from hypothesis.nn.amortized_ratio_estimation import BaseCriterion
from hypothesis.nn.amortized_ratio_estimation im... | code_fim | hard | {
"lang": "python",
"repo": "juryowl/hypothesis",
"path": "/hypothesis/auto/training/amortized_ratio_estimation.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self,
estimator,
optimizer,
dataset_train,
criterion,
accelerator=hypothesis.accelerator,
batch_size=hypothesis.default.batch_size,
checkpoint=None,
dataset_test=None,
epochs=hy... | code_fim | hard | {
"lang": "python",
"repo": "juryowl/hypothesis",
"path": "/hypothesis/auto/training/amortized_ratio_estimation.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def create_trainer(criterion, denominator):
r"""Variables of the dataset must by sorted by variable name."""
variables = re.split(",|\|", denominator)
variables.sort()
assert(set(variables) == set(criterion.variables()))
# Allocate the batch-feeder based on the specified random vari... | code_fim | hard | {
"lang": "python",
"repo": "juryowl/hypothesis",
"path": "/hypothesis/auto/training/amortized_ratio_estimation.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dpritsos/DoGSWrapper path: /dogswrapper/wrappedmodels/ovssvm.py
import numpy as np
import scipy.spatial.distance as spd
import subprocess as subp
class OVSSVM_Wrapped(object):
def __init__(self, fpath, genres):
self.fpath = fpath
self.genres_lst = genres
self.gnrs_... | code_fim | hard | {
"lang": "python",
"repo": "dpritsos/DoGSWrapper",
"path": "/dogswrapper/wrappedmodels/ovssvm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get the part of matrices required for the model prediction phase.
# ###crossval_Y = cls_gnr_tgs [crv_idxs, :]
# Initialize Predicted-Classes-Arrays List
predicted_Y_per_gnr = list()
predicted_d_near_per_gnr = list()
predicted_d_far_per_gnr = list()
... | code_fim | hard | {
"lang": "python",
"repo": "dpritsos/DoGSWrapper",
"path": "/dogswrapper/wrappedmodels/ovssvm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dsz_X = self.lsvm.decision_function(X)
if self.svm_type == 'oneclass':
dsz_X = np.transpose(dsz_X)[0]
dsz_N = far_H - dsz_X
dsz_F = dsz_X - near_H
return dsz_N, dsz_F
"""
def predict(self, *args):
print 'PREDICTING'
# Get Inpu... | code_fim | hard | {
"lang": "python",
"repo": "dpritsos/DoGSWrapper",
"path": "/dogswrapper/wrappedmodels/ovssvm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheHalfling/LegendaryLivesCharacterGenerator path: /PhysicalFeatures.py
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 7 22:50:06 2018
@author: Sherry
Physical Features
<|fim_suffix|>LEFT = eyeColor(diceRolls.d99())
RIGHT = eyeColor(diceRolls.d99())
print (eyeColor(diceRolls.d100()... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/PhysicalFeatures.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if roll <= 10:
result = "Light blue"
elif roll <= 20:
result = "Black"
elif roll <= 30:
result = "Gray"
elif roll <= 40:
result = "Green"
elif roll <= 50:
result = "Hazel"
elif roll <= 60:
result = "Violet"
elif roll <... | code_fim | medium | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/PhysicalFeatures.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>LEFT = eyeColor(diceRolls.d99())
RIGHT = eyeColor(diceRolls.d99())
print (eyeColor(diceRolls.d100()))<|fim_prefix|># repo: TheHalfling/LegendaryLivesCharacterGenerator path: /PhysicalFeatures.py
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 7 22:50:06 2018
@author: Sherry
Physical Features
... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/PhysicalFeatures.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weizushuai/rt1 path: /rt1/rt1.py
self.t_0 = old_t_0[valid_index[0]]
self.p_0 = old_p_0[valid_index[0]]
self.t_ex = old_t_ex[valid_index[0]]
self.p_ex = old_p_ex[valid_index[0]]
# squeezing the arrays is necessary since the setter-function for... | code_fim | hard | {
"lang": "python",
"repo": "weizushuai/rt1",
"path": "/rt1/rt1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> vol = ((self.I0 * self.V.omega *
self._mu_0 / (self._mu_0 + self._mu_ex))
* (1. - np.exp(-(self.V.tau / self._mu_0) -
(self.V.tau / self._mu_ex)))
* self.V.p(self.t_0, self.t_ex, self.p_0, self.p_ex,
... | code_fim | hard | {
"lang": "python",
"repo": "weizushuai/rt1",
"path": "/rt1/rt1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> symengines lambdify is used since it turns out to be superior
in terms of computational speed compared to symengines
currently available Lambdify function.
'''
self.prv(1,
'use symengines cse and symp... | code_fim | hard | {
"lang": "python",
"repo": "weizushuai/rt1",
"path": "/rt1/rt1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.