text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: arjunne/CIMapping path: /app.py
#!/usr/bin/env python3
from aws_cdk import core
<|fim_suffix|>
app = core.App()
CiCdkStack(app, "ci-cdk")
app.synth()<|fim_middle|>from ci_cdk.ci_cdk_stack import CiCdkStack
| code_fim | easy | {
"lang": "python",
"repo": "arjunne/CIMapping",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karstenw/nodebox-pyobjc path: /examples/Interactivity/circlepainter.py
size(800, 800)
import time
colormode(RGB)
speed(60)
def setup():
# ovallist is the list of ovals we created by moving the mouse.
global ovallist
stroke(0)
strokewidth(1)
ovallist = []
class Blob:
def... | code_fim | medium | {
"lang": "python",
"repo": "karstenw/nodebox-pyobjc",
"path": "/examples/Interactivity/circlepainter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.x, self.y = x, y
self.color = c
self.radius = r
def draw(self):
fill(self.color)
stroke(0)
strokewidth(1)
circle(self.x, self.y, self.radius)
# oval(self.x-self.radius, self.y-self.radius, self.radius*2, self.radius*2)
... | code_fim | medium | {
"lang": "python",
"repo": "karstenw/nodebox-pyobjc",
"path": "/examples/Interactivity/circlepainter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LucasRR94/RPG_Pirates_and_Fishers path: /RpgPiratesAndFishers/Defense.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from Item import *
class Defense(Item):
"""
This class Define object type Defense, it is a base for object used for defense in the application.
"""
def __init__(self,name,... | code_fim | hard | {
"lang": "python",
"repo": "LucasRR94/RPG_Pirates_and_Fishers",
"path": "/RpgPiratesAndFishers/Defense.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @param damage : (string) contains the value that will be used for calculated update for the attributes
@return : None
"""
defense = self.getDefense()
if(type(damage) is int):
if(damage >= 0):
if(defense <= damage):
self.__del__()
return 0
if(defense > damage):
recalc... | code_fim | hard | {
"lang": "python",
"repo": "LucasRR94/RPG_Pirates_and_Fishers",
"path": "/RpgPiratesAndFishers/Defense.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: triper1022/efficientnet-jax path: /jeffnet/common/loss.py
import jax
from jax import numpy as jnp, lax
# FIXME ended up with multiple cross entropy loss def here while experimenting
# with diff numeric stability issues... will cleanup someday.
def cross_entropy_loss(logits, labels, label_smoo... | code_fim | hard | {
"lang": "python",
"repo": "triper1022/efficientnet-jax",
"path": "/jeffnet/common/loss.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Compute weighted cross entropy for logits and labels w/ label smoothing.
Args:
logits: [batch, length, num_classes] float array.
labels: categorical labels [batch, length] int array.
weights: None or array of shape [batch, length].
label_smoothing: label smoothin... | code_fim | hard | {
"lang": "python",
"repo": "triper1022/efficientnet-jax",
"path": "/jeffnet/common/loss.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sophius/TaobaoAnalyze path: /crawler/comment.py
# -*- coding: utf-8 -*-
import codecs
import json
import math
import re
from selenium import webdriver
from selenium.common.exceptions import *
from utils.path import *
def gen_start_urls():
with codecs.open(DATA_DIR + '/ItemId.txt', 'r', '... | code_fim | hard | {
"lang": "python",
"repo": "Sophius/TaobaoAnalyze",
"path": "/crawler/comment.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
next_elem = revbd_elem.find_element_by_class_name('pg-next')
if 'pg-disabled' in next_elem.get_attribute('class'):
return False
next_elem.click()
except NoSuchElementException: # 只有1页
return False
ex... | code_fim | hard | {
"lang": "python",
"repo": "Sophius/TaobaoAnalyze",
"path": "/crawler/comment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leonardozcm/neural-compressor path: /lpot/adaptor/tf_utils/graph_rewriter/int8/freeze_value.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complianc... | code_fim | hard | {
"lang": "python",
"repo": "leonardozcm/neural-compressor",
"path": "/lpot/adaptor/tf_utils/graph_rewriter/int8/freeze_value.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return GraphAnalyzer().dump_graph(), self.scale_info
def generate_output_graph_ranges(self, max_name_value):
"""
Generate transformed graph for freeze_max/freeze_min transformation.
:param max_name_value: target values
:return: transformed graph
"""
... | code_fim | hard | {
"lang": "python",
"repo": "leonardozcm/neural-compressor",
"path": "/lpot/adaptor/tf_utils/graph_rewriter/int8/freeze_value.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aidencuneo/ProgrammingLanguage path: /src/func.py
def is_int(i):
try:
int(i)
return True
except ValueError:
return False
def is_float(i):
try:
float(i)
return True
except ValueError:
return False
<|fim_suffix|> o = ''
lc = ... | code_fim | medium | {
"lang": "python",
"repo": "aidencuneo/ProgrammingLanguage",
"path": "/src/func.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def remove_comments(src):
o = ''
lc = 0
bc = 0
for a in src:
if a == '/' and lc < 3:
lc += 1
elif a != '/' and lc == 1:
lc = 0
elif a == '#' and not bc:
bc = 1
elif a == '#' and bc == 1:
bc = 2
elif a =... | code_fim | hard | {
"lang": "python",
"repo": "aidencuneo/ProgrammingLanguage",
"path": "/src/func.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gosquadron/squadron path: /tests/helper.py
import filecmp
import os
def get_test_path():
return os.path.dirname(os.path.realpath(__file__))
def are_dir_trees_equal(dir1, dir2):
"""
Compare two directories recursively. Files in each directory are
assumed to be equal if their name... | code_fim | medium | {
"lang": "python",
"repo": "gosquadron/squadron",
"path": "/tests/helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return False
(_, mismatch, errors) = filecmp.cmpfiles(
dir1, dir2, dirs_cmp.common_files, shallow=False)
if len(mismatch)>0 or len(errors)>0:
print "File mismatch: {}, errors: {}".format(mismatch, errors)
return False
for common_dir in dirs_cmp.common_dirs:
... | code_fim | hard | {
"lang": "python",
"repo": "gosquadron/squadron",
"path": "/tests/helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> C_shape = (self._snapshots.shape[1], self._snapshots.shape[0])
if self.compression_matrix is 'uniform':
C = np.random.uniform(0, 1, size=(C_shape))
elif self.compression_matrix is 'sparse':
C = scipy.sparse.random(*C_shape, density=1.)
elif self.compression_matrix is 'normal':
C = np.ran... | code_fim | hard | {
"lang": "python",
"repo": "JeromeWilson6/PyDMD",
"path": "/pydmd/cdmd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeromeWilson6/PyDMD path: /pydmd/cdmd.py
"""
Derived module from dmdbase.py for compressed dmd.
As a reference consult this work by Erichson, Brunton and Kutz:
https://doi.org/10.1007/s11554-016-0655-2
"""
from __future__ import division
import numpy as np
import scipy.sparse
from .dmdbase impor... | code_fim | hard | {
"lang": "python",
"repo": "JeromeWilson6/PyDMD",
"path": "/pydmd/cdmd.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fultoncn/01-IntroductionToPython path: /src/m6_your_turtles.py
"""
Your chance to explore Loops and Turtles!
Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder,
their colleagues and Colleen Fulton.
"""
#################################################################... | code_fim | medium | {
"lang": "python",
"repo": "fultoncn/01-IntroductionToPython",
"path": "/src/m6_your_turtles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> henry.pen_up()
henry.right(45)
henry.forward(10)
henry.left(45)
henry.pen_down()
size = size - 12
luke = rg.SimpleTurtle('turtle')
luke.pen = rg.Pen('black', 5)
luke.speed = 10
size = 300
for k in range(13):
luke.draw_square(size)
luke.pen_down()
luke.left(45)
... | code_fim | hard | {
"lang": "python",
"repo": "fultoncn/01-IntroductionToPython",
"path": "/src/m6_your_turtles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FanWangEcon/pyfan path: /doc/examples/amto/plot_lsdcconvert.py
# -*- coding: utf-8 -*-
"""
List and Dictionary Convertions
========================================================================
Convert between list and dictionary
"""
# Author: Fan Wang (fanwangecon.github.io)
import pyfan.amto... | code_fim | hard | {
"lang": "python",
"repo": "FanWangEcon/pyfan",
"path": "/doc/examples/amto/plot_lsdcconvert.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># check three calling methods all work
print(f'{dc_ls_combo_type_a==dc_ls_combo_type_b=}')
print(f'{dc_ls_combo_type_a==dc_ls_combo_type_c=}')
print(f'{dc_ls_combo_type_a==dc_ls_combo_type_d=}')
print(f'{dc_ls_combo_type_a==dc_ls_combo_type_e=}')
# Start Plot
fig, ax = plt.subplots()
# Text Plot
ax.text... | code_fim | hard | {
"lang": "python",
"repo": "FanWangEcon/pyfan",
"path": "/doc/examples/amto/plot_lsdcconvert.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
import empty_python
print("Succesfully imported empty_python!")
except ImportError:
print("Could not import empty_python! Maybe you forgot to run 'pip install'")<|fim_prefix|># repo: benvanwerkhoven/empty_python path: /examples/example.py
#!/usr/bin/env python
""" This example demonstrat... | code_fim | medium | {
"lang": "python",
"repo": "benvanwerkhoven/empty_python",
"path": "/examples/example.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benvanwerkhoven/empty_python path: /examples/example.py
#!/usr/bin/env python
""" This example demonstrates that you need to run
'pip install .' in the main directory, before you
can do 'import empty_python' in a Python program
<|fim_suffix|>try:
import empty_python
print("Succesfully im... | code_fim | medium | {
"lang": "python",
"repo": "benvanwerkhoven/empty_python",
"path": "/examples/example.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebellocchia/bip_utils path: /bip_utils/substrate/scale/substrate_scale_enc_uint.py
# Copyright (c) 2022 Emanuele Bellocchia
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Sof... | code_fim | hard | {
"lang": "python",
"repo": "ebellocchia/bip_utils",
"path": "/bip_utils/substrate/scale/substrate_scale_enc_uint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
value (any): Value to be encoded
Returns:
bytes: Encoded value
"""
return cls._EncodeWithBytesLength(value, 16)
class SubstrateScaleU256Encoder(SubstrateScaleUintEncoder):
"""Substrate SCALE encoding class for 256-bit unsigned integers."... | code_fim | hard | {
"lang": "python",
"repo": "ebellocchia/bip_utils",
"path": "/bip_utils/substrate/scale/substrate_scale_enc_uint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_get_season(seas, week):
s = ns.get_season(seas)
assert isinstance(s, dict)
def test_season_week(seas, week):
d = datetime.datetime(2018, 10, 13).date()
sw = ns.season_week(d)
logging.info(sw)
assert sw['season'] == 2018
assert sw['week'] == 5
def test_week_end(sea... | code_fim | hard | {
"lang": "python",
"repo": "sansbacon/nfl",
"path": "/tests/test_seasons.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_week_start(seas, week):
"""tests week_start"""
assert isinstance(ns.week_start(seas, week), datetime.date)
y = 2018
w = 5
assert ns.week_start(y, w) < datetime.datetime.now().date()<|fim_prefix|># repo: sansbacon/nfl path: /tests/test_seasons.py
# -*- coding: utf-8 -*-
# test... | code_fim | hard | {
"lang": "python",
"repo": "sansbacon/nfl",
"path": "/tests/test_seasons.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sansbacon/nfl path: /tests/test_seasons.py
# -*- coding: utf-8 -*-
# tests/test_dates.py
# tests for nfl.dates module
import datetime
import logging
import random
import pytest
import nfl.seasons as ns
<|fim_suffix|> y = 2018
w = 5
assert ns.week_end(y, w) < datetime.datetime.now().... | code_fim | hard | {
"lang": "python",
"repo": "sansbacon/nfl",
"path": "/tests/test_seasons.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ComputationalPhysiology/perspect path: /demo/demo_pure_porous.py
import dolfin as df
import numpy as np
import perspect
import pulse
import sys
import time
from geometry import Geometry, MarkerFunctions, Microstructure
comm = df.MPI.comm_world
df.set_log_level(40)
mesh = df.BoxMesh(comm, df.Po... | code_fim | hard | {
"lang": "python",
"repo": "ComputationalPhysiology/perspect",
"path": "/demo/demo_pure_porous.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def xdmf_parameters(xdmf_file):
xdmf_file.parameters["flush_output"] = True
xdmf_file.parameters["rewrite_function_mesh"] = False
xdmf_file.parameters["functions_share_mesh"] = True
mfile = df.XDMFFile(comm, "pure_porous.xdmf")
xdmf_parameters(mfile)
pspect.pprob.prescribed_pressure(pp)
t =... | code_fim | hard | {
"lang": "python",
"repo": "ComputationalPhysiology/perspect",
"path": "/demo/demo_pure_porous.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def inside(self, x, on_boundary):
return on_boundary and df.near(x[0], 1.0)
markers = {'BASE': (10, 1),
'ENDO': (30, 1),
'EPI': (40, 1),
'NONE': (0, 2)}
ffun = df.MeshFunction("size_t", mesh, mesh.topology().dim()-1)
ffun.set_all(markers['NONE'][0])
base = Base()
base.... | code_fim | hard | {
"lang": "python",
"repo": "ComputationalPhysiology/perspect",
"path": "/demo/demo_pure_porous.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vocata/tracklib path: /tracklib/filter/ukf.py
e + K @ innov
self._cov = self._cov - K @ S @ K.T
self._cov = (self._cov + self._cov.T) / 2
return self._state, self._cov
def correct_JPDA(self, zs, probs, **kwargs):
if self._init == False:
raise Runt... | code_fim | hard | {
"lang": "python",
"repo": "vocata/tracklib",
"path": "/tracklib/filter/ukf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vocata/tracklib path: /tracklib/filter/ukf.py
S_base = 0
xz_cov = 0
for pi in range(pts_num):
z_err = h_map[pi] - z_pred
S_base += w_cov[pi] * np.outer(z_err, z_err)
x_err = self.__f_map[pi] - self._state
xz_cov += w_cov[pi] *... | code_fim | hard | {
"lang": "python",
"repo": "vocata/tracklib",
"path": "/tracklib/filter/ukf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def sigma_points(self, mean, cov):
if self._init == False:
raise RuntimeError('point generator must be initialized with init() before use')
# P = C * C'
cov_sqrt = cholcov(cov, lower=True)
pts = np.zeros((self._dim, 2 * self._dim))
for i in range(se... | code_fim | hard | {
"lang": "python",
"repo": "vocata/tracklib",
"path": "/tracklib/filter/ukf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saritepe/earthquake_dmg-drivendata path: /src/models/train_model.py
from sklearn import model_selection
from src.utils.get_model_params import model_param_selector
from src.utils.get_model import get_model
from src.utils.get_config import get_config
from src.features.cross_validation import sel... | code_fim | hard | {
"lang": "python",
"repo": "saritepe/earthquake_dmg-drivendata",
"path": "/src/models/train_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cv = select_cv(cv_name, cv_n_split, cv_n_repeats, random_state)
return getattr(model_selection, search_type)(model, params, cv=cv, verbose=verbose, n_jobs=n_jobs,
random_state=random_state, n_iter=rnd_src_n_iter)
#def model_train()<|fim_prefix|>#... | code_fim | medium | {
"lang": "python",
"repo": "saritepe/earthquake_dmg-drivendata",
"path": "/src/models/train_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crpurcell/RMpipeL5 path: /Imports/__init__.py
#! /usr/bin/env python
"""Dependencies for pipeline """
__all__ = ['util_RM',
'util_PPC',
<|fim_suffix|> 'module_measure_FDF',
'module_RM_clean.py',
'mpfit',
'normalize']<|fim_middle|> 'util... | code_fim | hard | {
"lang": "python",
"repo": "crpurcell/RMpipeL5",
"path": "/Imports/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>otFITS',
'util_plotTk',
'module_spec_extract',
'module_RM_synthesis',
'module_measure_FDF',
'module_RM_clean.py',
'mpfit',
'normalize']<|fim_prefix|># repo: crpurcell/RMpipeL5 path: /Imports/__init__.py
#! /usr/bin/env python
""... | code_fim | hard | {
"lang": "python",
"repo": "crpurcell/RMpipeL5",
"path": "/Imports/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samsonosiomwan/Hotels-Management-System path: /ekohms/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('rooms/', views.rooms, name='rooms'),
path('rooms/<uuid:room_id>/', views.rooms_detailed_view, name='rooms_detailed... | code_fim | medium | {
"lang": "python",
"repo": "samsonosiomwan/Hotels-Management-System",
"path": "/ekohms/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>yment, name='payment'),
path('contact/', views.contact, name='contact'),
path('about/', views.about, name='about'),
]<|fim_prefix|># repo: samsonosiomwan/Hotels-Management-System path: /ekohms/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, nam... | code_fim | medium | {
"lang": "python",
"repo": "samsonosiomwan/Hotels-Management-System",
"path": "/ekohms/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rand = random.randint(2,3)
final_char = ''
for i in range(rand):
char = random.choice(string.ascii_letters)
i += 1
final_char += char
return Response(str.upper(final_char), mimetype ='text/plain')<|fim_prefix|># repo: JackPendlebury1/ProjectDevops2 path: /ser... | code_fim | medium | {
"lang": "python",
"repo": "JackPendlebury1/ProjectDevops2",
"path": "/service-2-char-gen/app/routes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JackPendlebury1/ProjectDevops2 path: /service-2-char-gen/app/routes.py
from flask import render_template, redirect, url_for, request, Response
from app import app
import random
import string
<|fim_suffix|> rand = random.randint(2,3)
final_char = ''
for i in range(rand):
... | code_fim | medium | {
"lang": "python",
"repo": "JackPendlebury1/ProjectDevops2",
"path": "/service-2-char-gen/app/routes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for player in players:
cds.putint(player.pn)
self.respond(str(cds), address)
def ext_send_player_stats(self, address, rcds, player):
cds = get_ext_info_reply_cds(rcds)
cds.putint(EXT_NO_ERROR)
cds.putint(EXT_PLAYERSTATS_RESP_STATS)
cds.p... | code_fim | hard | {
"lang": "python",
"repo": "fdChasm/spyd",
"path": "/src/spyd/server/lan_info/lan_info_responder.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> cds = get_ext_info_reply_cds(rcds)
# TODO: send teamscores correctly
# cds.putint(self.room.is_teammode)
cds.putint(0)
cds.putint(self.room.mode_num)
cds.putint(self.room.timeleft)
# if self.room.is_teammode:
# pass
self.respond... | code_fim | hard | {
"lang": "python",
"repo": "fdChasm/spyd",
"path": "/src/spyd/server/lan_info/lan_info_responder.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fdChasm/spyd path: /src/spyd/server/lan_info/lan_info_responder.py
from cube2protocol.cube_data_stream import CubeDataStream
from spyd.protocol import swh
EXT_ACK = -1
EXT_VERSION = 105
EXT_NO_ERROR = 0
EXT_ERROR = 1
EXT_PLAYERSTATS_RESP_IDS = -10
EXT_PLAYERSTATS_RESP_STATS = -11
EXT_UPTIME = 0
... | code_fim | hard | {
"lang": "python",
"repo": "fdChasm/spyd",
"path": "/src/spyd/server/lan_info/lan_info_responder.py",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: D-Kamunya/grade_it path: /gradeit_app/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.home_page,name='home_page'),
path('p<|fim_suffix|>'my_profile'),
path('api/profiles', views.ProfileList.as_view()),
path('api/projects', views.ProjectsLi... | code_fim | hard | {
"lang": "python",
"repo": "D-Kamunya/grade_it",
"path": "/gradeit_app/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'my_profile'),
path('api/profiles', views.ProfileList.as_view()),
path('api/projects', views.ProjectsList.as_view()),
]<|fim_prefix|># repo: D-Kamunya/grade_it path: /gradeit_app/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.home_page,name='home_pag... | code_fim | hard | {
"lang": "python",
"repo": "D-Kamunya/grade_it",
"path": "/gradeit_app/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'),
path('view/project/<prj_id>',views.view_project,name='view_project'),
path('view/my-profile',views.my_profile,name='my_profile'),
path('api/profiles', views.ProfileList.as_view()),
path('api/projects', views.ProjectsList.as_view()),
]<|fim_prefix|># repo: D-Kamunya/grade_it path: /gra... | code_fim | medium | {
"lang": "python",
"repo": "D-Kamunya/grade_it",
"path": "/gradeit_app/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Let's average the squared ERROR
cost = (0.5) * cost
# Using Hungarian Algorithm assign the
# correct detected measurements to predicted tracks
assignment = []
for _ in range(N):
assignment.append(-1)
row_ind, col_ind = linear_sum_assign... | code_fim | hard | {
"lang": "python",
"repo": "appltini/clever-bee",
"path": "/tracker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: appltini/clever-bee path: /tracker.py
# Import python libraries
import numpy as np
from scipy.optimize import linear_sum_assignment
from track import Track
min_tracker_score_creation = 20
class Tracker(object):
def __init__(self, dist_thresh, max_frames_to_skip, max_trace_length,
... | code_fim | hard | {
"lang": "python",
"repo": "appltini/clever-bee",
"path": "/tracker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return User.query.filter_by(id = id).first()
def find_user_by_email(email):
'''
Find a user by email.
'''
user = User.query.filter_by(email = email).first()
return user
def get_user_by_id(userid):
'''
Get a user by id.
'''
if isinstance(userid, str):
u... | code_fim | hard | {
"lang": "python",
"repo": "harveytoro/open-source-saas-boilerpate",
"path": "/src/shared/services/db_user_service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harveytoro/open-source-saas-boilerpate path: /src/shared/services/db_user_service.py
'''
This component is to abstract working with User, Role, Account, AccountHistory entities.
Implement a concrete implementation of these classes here and in db_models classes. Any other components don't care ho... | code_fim | hard | {
"lang": "python",
"repo": "harveytoro/open-source-saas-boilerpate",
"path": "/src/shared/services/db_user_service.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ghomsy/makani path: /avionics/linux/swig/aio_helper.py
# Copyright 2020 Makani Technologies LLC
#
# 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.apac... | code_fim | hard | {
"lang": "python",
"repo": "ghomsy/makani",
"path": "/avionics/linux/swig/aio_helper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def UnpackMessage(swig_obj_pointer, msg_name):
"""Unpack a SWIG-wrapped memory object into an AIO message.
Args:
swig_obj_pointer: A SWIG-wrapped memory object pointing to the raw AIO
message payload.
msg_name: Name or short name of the message type.
Returns:
An AIO message str... | code_fim | hard | {
"lang": "python",
"repo": "ghomsy/makani",
"path": "/avionics/linux/swig/aio_helper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def TearDown():
aio_util.AioClose()
aio_util.TearDownAioLoop()
def ClockUsToTimestamp(clock_us, reference_clock_us, reference_timestamp):
"""Converts a reported clock measurement (in us) to a timestamp.
Args:
clock_us: Measured clock [us].
reference_clock_us: Measured clock at a refere... | code_fim | hard | {
"lang": "python",
"repo": "ghomsy/makani",
"path": "/avionics/linux/swig/aio_helper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_gathering_audio_files(
requests_mock: rm_Mocker,
json_db_mock: str,
lep_dl: LepDL,
) -> None:
"""It gets all audio files from mocked episodes."""
requests_mock.get(
conf.JSON_DB_URL,
text=json_db_mock,
)
lep_dl.get_remote_episodes()
lep_dl.files = d... | code_fim | hard | {
"lang": "python",
"repo": "hotenov/LEP-downloader",
"path": "/tests/test_downloader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hotenov/LEP-downloader path: /tests/test_downloader.py
lep_dl.get_remote_episodes()
lep_dl.files = downloader.gather_all_files(lep_dl.db_episodes)
audio_files = lep_dl.files.filter_by_type(Audio)
lep_dl.detach_existed_files(tmp_path, audio_files)
assert len(lep_dl.existed) == ... | code_fim | hard | {
"lang": "python",
"repo": "hotenov/LEP-downloader",
"path": "/tests/test_downloader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hotenov/LEP-downloader path: /tests/test_downloader.py
nload_link(
only_audio_links: List[Tuple[str, str]],
) -> None:
"""It returns list of URLs with titles for files."""
excepted_link = (
"[2021-02-03] # 703. Walaa from Syria – WISBOLEP Competition Winner.mp3",
"http... | code_fim | hard | {
"lang": "python",
"repo": "hotenov/LEP-downloader",
"path": "/tests/test_downloader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def change_default_encoding():
# 修改默认的编码格式
try:
LoggerUtils.info('Change Default Encoding')
# 判断Python版本
version = get_python_version()
LoggerUtils.info('Python Version : %s' % version)
if version.startswith('2'):
imp.reload(sys)
... | code_fim | hard | {
"lang": "python",
"repo": "PillowCaseZn/LogCatProject",
"path": "/Scripts/ConfigUtils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PillowCaseZn/LogCatProject path: /Scripts/ConfigUtils.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Author : PillowCase
# Create Time : 2020/3/18 14:02
# Description :
import imp
import importlib
import platform
import re
import sys
<|fim_suffix|> """
:return:系统类型
... | code_fim | hard | {
"lang": "python",
"repo": "PillowCaseZn/LogCatProject",
"path": "/Scripts/ConfigUtils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 获取当前Python版本
version_info = sys.version_info
major = version_info.major
minor = version_info.minor
micro = version_info.micro
return "%s.%s.%s" % (major, minor, micro)
def get_system_type():
"""
:return:系统类型
"""
system = platform.system()
# Logg... | code_fim | hard | {
"lang": "python",
"repo": "PillowCaseZn/LogCatProject",
"path": "/Scripts/ConfigUtils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: superfluidity/RDCL3D path: /code/deploymenthandler/helpers/helper.py
import requests
import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('helper.py')
class Helper():
def __init__(self, agent):
self.agent = agent
pass
<|fim_suffix|> log.de... | code_fim | hard | {
"lang": "python",
"repo": "superfluidity/RDCL3D",
"path": "/code/deploymenthandler/helpers/helper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
r = requests.post(url, data=data, json=json, **kwargs)
except Exception as e:
print "Exception during send POST"
return {'error': 'error during connection to agent'}
return r.json()<|fim_prefix|># repo: superfluidity/RDCL3D path: /code/depl... | code_fim | hard | {
"lang": "python",
"repo": "superfluidity/RDCL3D",
"path": "/code/deploymenthandler/helpers/helper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ai-game-lincoln-uni/ai-game path: /Game/NeuralNetwork.py
"""
Name: NeuralNetwork.py
Version: 0.01
Purpose: Creates/Saves/Loads neural network for Connect-Four game
Author: Graham Mark Broadbent
Date: 12/03/19
"""
import logging
from logManager import log
log.info('Program Begin\n')
import Data... | code_fim | hard | {
"lang": "python",
"repo": "ai-game-lincoln-uni/ai-game",
"path": "/Game/NeuralNetwork.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> except:
log.error('\tUnknown error in NeuralNetwork._add_output_layer\n')
return False
def _compile_model():
try:
log.info('Compiling model')
global model
# log.info('Network compiling')
#
# # model.compile(optimizer='adam', loss='sparse_... | code_fim | hard | {
"lang": "python",
"repo": "ai-game-lincoln-uni/ai-game",
"path": "/Game/NeuralNetwork.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> prediction = model.predict_on_batch(predict_array)
print("Prediction on data:\n{}".format(predict_array))
print(prediction)
print('\tPrediction: ', np.argmax(prediction[0]))
_save_model("Model_0")
_load_model("Model_0")
predict_array = []
predict_array.append(training_inp... | code_fim | hard | {
"lang": "python",
"repo": "ai-game-lincoln-uni/ai-game",
"path": "/Game/NeuralNetwork.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, num_filter, kernel_size=8, stride=4, padding=2, bias=True, activation='prelu', norm=None):
super(DownBlock, self).__init__()
self.down_conv1 = ConvBlock(num_filter, num_filter, kernel_size, stride, padding, bias=bias,
activation=ac... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/models",
"path": "/research/cv/DBPN/src/model/base_network.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mindspore-ai/models path: /research/cv/DBPN/src/model/base_network.py
# Copyright 2021 Huawei Technologies Co., Ltd
#
# 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
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/models",
"path": "/research/cv/DBPN/src/model/base_network.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Called when the mouse moves over this object."""
pass
def on_client_exit(self, game) -> None:
"""Called when the mouse moves out this object."""
pass
def on_roll_up(self, client, game) -> None:
"""Called when the mouse wheel rolls up over this object.""... | code_fim | hard | {
"lang": "python",
"repo": "overdev/SpaceGame",
"path": "/spacegame/ui.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, listeners):
self.listeners = []
self._mouse_listeners = []
for listener in listeners:
self.listeners.append(listener)
# post an mouse motion event to update objects under the mouse
# when the scene starts
pos = pygame.mou... | code_fim | hard | {
"lang": "python",
"repo": "overdev/SpaceGame",
"path": "/spacegame/ui.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: overdev/SpaceGame path: /spacegame/ui.py
__author__ = 'Jorge'
from enum import Enum
import pygame
import pygame.locals as c
from spacegame.core import resource
from spacegame.geometry import Vec
__all__ = [
"BitmapFont",
"blend_color",
"Anchor",
"UIElement",
"Button",
"... | code_fim | hard | {
"lang": "python",
"repo": "overdev/SpaceGame",
"path": "/spacegame/ui.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lannister-Xiaolin/xl_tensorflow path: /scripts/pascal_voc2txt.py
#!usr/bin/env python3
# -*- coding: UTF-8 -*-
import click
import os
from xl_tool.xl_io import read_txt, file_scanning
from xl_tensorflow.preprocessing.annotation import voc2txt_annotation
<|fim_suffix|> valid_file = set(read_t... | code_fim | hard | {
"lang": "python",
"repo": "Lannister-Xiaolin/xl_tensorflow",
"path": "/scripts/pascal_voc2txt.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> voc2txt_annotation(xml_files, val_txt, class_names, seperator="\t",
image_path=os.path.join(voc, "trainval/JPEGImages"))
if __name__ == '__main__':
main()<|fim_prefix|># repo: Lannister-Xiaolin/xl_tensorflow path: /scripts/pascal_voc2txt.py
#!usr/bin/env python3
# -*- cod... | code_fim | hard | {
"lang": "python",
"repo": "Lannister-Xiaolin/xl_tensorflow",
"path": "/scripts/pascal_voc2txt.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yssource/setuptools-cpp path: /tests/test_setup_cpp.py
import importlib.util
import os
import shutil
import sys
from pathlib import Path
from typing import Iterator, List
import pytest
from _pytest.monkeypatch import MonkeyPatch
from setuptools import setup
from setuptools_cpp import CMakeExten... | code_fim | hard | {
"lang": "python",
"repo": "yssource/setuptools-cpp",
"path": "/tests/test_setup_cpp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def prepare_installed_module(name: str) -> None:
for file in (TESTS_DIR / "test_pkg" / name).iterdir():
if file.name.endswith(".so"):
spec = importlib.util.spec_from_file_location(f"test_pkg.{name}.compiled", file)
importlib.util.module_from_spec(spec)
def test_insta... | code_fim | hard | {
"lang": "python",
"repo": "yssource/setuptools-cpp",
"path": "/tests/test_setup_cpp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arjunsinghy96/channels-chat path: /storage/migrations/0001_initial.py
# Generated by Django 2.0.2 on 2018-04-15 10:29
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import storage.models
class Migration(migrations.Migration):
ini... | code_fim | hard | {
"lang": "python",
"repo": "arjunsinghy96/channels-chat",
"path": "/storage/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>deletion.CASCADE, to='storage.League')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Message',
fields=[
('id', models.AutoField... | code_fim | hard | {
"lang": "python",
"repo": "arjunsinghy96/channels-chat",
"path": "/storage/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>],
),
migrations.AddField(
model_name='league',
name='members',
field=models.ManyToManyField(related_name='member_of', through='storage.Membership', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='invite',
... | code_fim | hard | {
"lang": "python",
"repo": "arjunsinghy96/channels-chat",
"path": "/storage/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deeuu/supriya path: /tests/nonrealtime/test_nonrealtime_Node_inspect_children.py
import supriya.nonrealtime
def test_01():
"""
No containment.
"""
session = supriya.nonrealtime.Session()
with session.at(0):
one = session.add_group(duration=10)
session.add_gro... | code_fim | hard | {
"lang": "python",
"repo": "deeuu/supriya",
"path": "/tests/nonrealtime/test_nonrealtime_Node_inspect_children.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_04():
"""
Start at midpoint.
"""
session = supriya.nonrealtime.Session()
with session.at(0):
one = session.add_group(duration=10)
with session.at(5):
two = one.add_group(duration=5)
with session.at(0):
entering, exiting, occupying, starting, st... | code_fim | hard | {
"lang": "python",
"repo": "deeuu/supriya",
"path": "/tests/nonrealtime/test_nonrealtime_Node_inspect_children.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_06():
"""
Exit at midpoint.
"""
session = supriya.nonrealtime.Session()
with session.at(0):
one = session.add_group(duration=10)
two = one.add_group(duration=10)
with session.at(5):
session.move_node(two)
with session.at(0):
entering, e... | code_fim | hard | {
"lang": "python",
"repo": "deeuu/supriya",
"path": "/tests/nonrealtime/test_nonrealtime_Node_inspect_children.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FrankBeatrice/queryjane_app path: /entrepreneur/migrations/0002_auto_20181014_2151.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-10-14 21:51
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> dep... | code_fim | medium | {
"lang": "python",
"repo": "FrankBeatrice/queryjane_app",
"path": "/entrepreneur/migrations/0002_auto_20181014_2151.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('entrepreneur', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='venture',
name='point',
),
migrations.AlterField(
model_name='venture',
name='city',
field=models... | code_fim | medium | {
"lang": "python",
"repo": "FrankBeatrice/queryjane_app",
"path": "/entrepreneur/migrations/0002_auto_20181014_2151.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>client = MongoClient()
db = client.mao
datasets_id = sys.argv[1]
datasets = db.datasets.find_one({"_id": ObjectId(datasets_id)})
quest = TextClassification(train_filename=getAbsPath(datasets["train_file"]),
test_filename=getAbsPath(datasets["test_file"]),
... | code_fim | hard | {
"lang": "python",
"repo": "zhouguangbiao/text_classification-system",
"path": "/python/tfidf_topk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>y_length = len(y_train)
for row in range(len(y_train)):
t = y_train[row]
for col in train_tfidf.getrow(row).nonzero()[1]:
keywords[t][col] = train_tfidf[row, col]
print("%d/%d" % (row, y_length), end='\r')
for i in range(category_length):
keywords[i] = [{"name": feature_names[... | code_fim | hard | {
"lang": "python",
"repo": "zhouguangbiao/text_classification-system",
"path": "/python/tfidf_topk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhouguangbiao/text_classification-system path: /python/tfidf_topk.py
import sys
import os
import json
import numpy as np
from pymongo import MongoClient # 连接mongoDB,读取配置
from bson.objectid import ObjectId
from text_classification import TextClassification
root = os.path.dirname(os.path.abspath... | code_fim | medium | {
"lang": "python",
"repo": "zhouguangbiao/text_classification-system",
"path": "/python/tfidf_topk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyucheolsim/sk-text-classification path: /predict_classifier.py
# written by kylesim
from argparse import ArgumentParser
from sklearn.datasets import load_files
# for directories of text files where the name of each directory is the name of each category and each file inside of each directory cor... | code_fim | hard | {
"lang": "python",
"repo": "kyucheolsim/sk-text-classification",
"path": "/predict_classifier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if PARAM.action == 'batch':
if PARAM.print_y:
print_result(X_word, y, pred_labels)
else:
print_result(X_word, None, pred_labels)
elif PARAM.action == 'accuracy':
accuracy = accuracy_score(y, pred_labels)
print("# Accuracy: {}".format(accuracy))
else:
raise ValueError('unknown action')<|... | code_fim | hard | {
"lang": "python",
"repo": "kyucheolsim/sk-text-classification",
"path": "/predict_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = load_files(PARAM.data_path, encoding="utf-8")
X_word, y, y_names = clean_docs(data.data, True), data.target, data.target_names
if vectorizer:
X = vectorizer.transform(X_word).toarray()
if scaler:
X = scaler.transform(X)
else:
# [vectorizer, scaler, classifier] in pipeline
X = X_word... | code_fim | hard | {
"lang": "python",
"repo": "kyucheolsim/sk-text-classification",
"path": "/predict_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.cmd('advisor recommendation generate')
def test_get_set_configurations_subscription(self):
output = self.cmd('advisor configuration get').get_output_in_json()
self.assertGreater(len(output), 1)
self.cmd('advisor configuration set --low-cpu-threshold 20')
o... | code_fim | hard | {
"lang": "python",
"repo": "mickeymitic/azure-cli",
"path": "/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/latest/test_advisor_commands.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mickeymitic/azure-cli path: /src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/latest/test_advisor_commands.py
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# L... | code_fim | hard | {
"lang": "python",
"repo": "mickeymitic/azure-cli",
"path": "/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/latest/test_advisor_commands.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.cmd('advisor recommendation generate')
output = self.cmd('advisor recommendation list').get_output_in_json()
self.assertGreater(len(output), 1)
output = self.cmd('advisor recommendation list --category cost').get_output_in_json()
self.assertGreater(len(output),... | code_fim | hard | {
"lang": "python",
"repo": "mickeymitic/azure-cli",
"path": "/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/latest/test_advisor_commands.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> submission = models.ForeignKey(Submission)
link = models.CharField(max_length=255)
description = models.CharField(max_length=255, null=True)
embed = models.TextField(null=True,blank=True)
def save(self, *args, **kwargs):
providers = micawber.bootstrap_basic()
try:
... | code_fim | hard | {
"lang": "python",
"repo": "hellocoldworld/memorial-page",
"path": "/submissions/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> providers = micawber.bootstrap_basic()
try:
self.embed = providers.request(self.link)['html']
except micawber.ProviderException as e:
self.embed = None
super(Link,self).save(*args, **kwargs)<|fim_prefix|># repo: hellocoldworld/memorial-page path: /s... | code_fim | hard | {
"lang": "python",
"repo": "hellocoldworld/memorial-page",
"path": "/submissions/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hellocoldworld/memorial-page path: /submissions/models.py
from django.db import models
from django.contrib.auth.models import User
import micawber
import cloudinary
import cloudinary.uploader
import cloudinary.api
from cloudinary.models import CloudinaryField
class Submission(models.Model):
... | code_fim | hard | {
"lang": "python",
"repo": "hellocoldworld/memorial-page",
"path": "/submissions/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: locsta/Glassnode-Studio-Scraper path: /glassnode.py
from selenium_scraper import Scraper
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
import time
import json
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support imp... | code_fim | hard | {
"lang": "python",
"repo": "locsta/Glassnode-Studio-Scraper",
"path": "/glassnode.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Dump json files tree for later use (to organise files into folders)
with open("files_tree.json", "w") as outfile:
json.dump(list_sections, outfile)
# Dump json files tree of non-scraped files (files not available for download on glassnode studio)
with open("not_scraped.json", "w... | code_fim | hard | {
"lang": "python",
"repo": "locsta/Glassnode-Studio-Scraper",
"path": "/glassnode.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_semantic_data(tf_in, tmp_dir, member, access_token):
# Get the new semantic files and save those too
if tf_in.name.endswith('.zip'):
zf = zipfile.ZipFile(tf_in)
for f in zf.filelist:
if f.filename.endswith('.json') and len(f.filename.split('/')) == 5:
... | code_fim | hard | {
"lang": "python",
"repo": "OpenHumans/oh-googlelocation-source",
"path": "/main/celery.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tf_in.name.endswith('.zip'):
zf = zipfile.ZipFile(tf_in)
for f in zf.filelist:
if f.filename.endswith('.json') and len(f.filename.split('/')) == 3:
return zf.read(f)
elif tf_in.name.endswith('.json'):
return open(tf_in.name).read()
else:
... | code_fim | hard | {
"lang": "python",
"repo": "OpenHumans/oh-googlelocation-source",
"path": "/main/celery.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenHumans/oh-googlelocation-source path: /main/celery.py
from django.conf import settings
import os
from celery import Celery
import tempfile
from ohapi import api
import requests
import zipfile
import logging
import json
import arrow
# set the default Django settings module for the 'celery' p... | code_fim | hard | {
"lang": "python",
"repo": "OpenHumans/oh-googlelocation-source",
"path": "/main/celery.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.