text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>def test_epoch_output_buffer(epoch_output, tb1, tb2):
full_waveform1 = tb1.get_samples_remaining()
tb1.reset()
full_waveform2 = tb2.get_samples_remaining()
tb2.reset()
epoch_output.source = tb1
epoch_output.activate(0)
segments = [
(0, 1000),
(1000, 1000),
... | code_fim | hard | {
"lang": "python",
"repo": "psiexperiment/psiexperiment",
"path": "/tests/test_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> segments = [
(0, 1000),
(1000, 1000),
(0, 1000),
(500, 1000),
(1500, 1000),
(2500, 13),
(2513, 13)
]
out = np.empty(1000, dtype=np.double)
for o, s in segments:
epoch_output.get_samples(o, s, out)
np.testing.assert_arr... | code_fim | hard | {
"lang": "python",
"repo": "psiexperiment/psiexperiment",
"path": "/tests/test_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: psiexperiment/psiexperiment path: /tests/test_output.py
import pytest
import numpy as np
from psiaudio.stim import Cos2EnvelopeFactory, ToneFactory
@pytest.fixture()
def tb1(epoch_output):
tone = ToneFactory(fs=epoch_output.fs, level=0, frequency=100,
calibration=ep... | code_fim | hard | {
"lang": "python",
"repo": "psiexperiment/psiexperiment",
"path": "/tests/test_output.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MehnoushFaghani/Ripples--PCP path: /Connect-four/test/test_minimax.py
from typing import List
import numpy as np
import math
from agents.agent_minimax.minimax import (
minimax,
heuristic,
Score_func,
generate_move_minimax
)
from agents.common import BoardPiece, PLAYER2, PLAYER1, N... | code_fim | hard | {
"lang": "python",
"repo": "MehnoushFaghani/Ripples--PCP",
"path": "/Connect-four/test/test_minimax.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert ret == 5
# diagonal
board[0, 6] = PLAYER1
board[1, 5] = PLAYER1
pos_list = (board[0, 6], board[1, 5], board[2, 4], board[3, 3])
ret = Score_func(pos_list, PLAYER1)
assert ret == 2
# block the opponent
board[2, 4] = PLAYER1
pos_list = (board[0, 6], board[1,... | code_fim | hard | {
"lang": "python",
"repo": "MehnoushFaghani/Ripples--PCP",
"path": "/Connect-four/test/test_minimax.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunshuai95/Solar_mark_rcnn path: /index.py
import cv2
import json
import os
import numpy as np
from PIL import Image
#Tham so cho ham HoughLinesP
RHO = 10 #The resolution of the parameter r in pixels.
THRESHOLD = 5 #The minimum number of intersections to “detect” a line
MINLINLENGTH = 450 #The ... | code_fim | hard | {
"lang": "python",
"repo": "sunshuai95/Solar_mark_rcnn",
"path": "/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def index(img, bounding_boxs, rect):
#Create mask:
w, h = img.shape[0:2]
mask = np.zeros((w, h))
bounding_boxs_center = []
for bb in bounding_boxs:
#Center_point
center_point = (int((bb[0] + bb[2])/2), int((bb[1] + bb[3])/2))
bounding_boxs_center.append(list(rev... | code_fim | hard | {
"lang": "python",
"repo": "sunshuai95/Solar_mark_rcnn",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Sắp xếp line theo giá trị y của điểm đầu
line_array = sorted(line_array, key=lambda x: x.points[1])
#Hiển thị lên ảnh
i = 0
for line_object in line_array:
x1, y1 = line_object.start
x2, y2 = line_object.end
cv2.putText(img, str(i), (x1, y1), cv2.FONT_HERSHE... | code_fim | hard | {
"lang": "python",
"repo": "sunshuai95/Solar_mark_rcnn",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
while True:
input()
lapTime = round(time.time() - lastTime, 2)
totalTime = round(time.time() - startTime, 2)
print('Lap #%s:')<|fim_prefix|># repo: Amelen0/Python-Projects path: /stopwatch.py
#! usr/bin/ env Python3
# stopwatch.py
<|fim_middle|>import time
| code_fim | easy | {
"lang": "python",
"repo": "Amelen0/Python-Projects",
"path": "/stopwatch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Amelen0/Python-Projects path: /stopwatch.py
#! usr/bin/ env Python3
# stopwatch.py
<|fim_suffix|>try:
while True:
input()
lapTime = round(time.time() - lastTime, 2)
totalTime = round(time.time() - startTime, 2)
print('Lap #%s:')<|fim_middle|>import time
| code_fim | easy | {
"lang": "python",
"repo": "Amelen0/Python-Projects",
"path": "/stopwatch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .old import QuartInterface as quart_api_doc
from .old import SanicInterface as sanic_api_doc
from .old import TornadoInterface as tornado_api_doc
from .old import BottleInterface as bottle_api_doc<|fim_prefix|># repo: pavel-vorobyev/swagger-ui-pyramid path: /swagger_ui/__init__.py
from .core import Inte... | code_fim | medium | {
"lang": "python",
"repo": "pavel-vorobyev/swagger-ui-pyramid",
"path": "/swagger_ui/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pavel-vorobyev/swagger-ui-pyramid path: /swagger_ui/__init__.py
from .core import Interface as api_doc
from .old import AiohttpInterface as aiohttp_api_doc
from .<|fim_suffix|> .old import QuartInterface as quart_api_doc
from .old import SanicInterface as sanic_api_doc
from .old import TornadoInt... | code_fim | medium | {
"lang": "python",
"repo": "pavel-vorobyev/swagger-ui-pyramid",
"path": "/swagger_ui/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> .old import TornadoInterface as tornado_api_doc
from .old import BottleInterface as bottle_api_doc<|fim_prefix|># repo: pavel-vorobyev/swagger-ui-pyramid path: /swagger_ui/__init__.py
from .core import Interface as api_doc
from .old import AiohttpInterface as aiohttp_api_doc
from .<|fim_middle|>old impo... | code_fim | medium | {
"lang": "python",
"repo": "pavel-vorobyev/swagger-ui-pyramid",
"path": "/swagger_ui/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def color_group(_):
nonlocal group_counter, extractor
group_counter += 1
label_ix = extractor["groupLabel"].get(group_counter)
if label_ix is not None:
color = colors[label_ix % len(colors)]
return f"<font color='#{col... | code_fim | hard | {
"lang": "python",
"repo": "cognitedata/cognite-sdk-python-experimental",
"path": "/cognite/experimental/data_classes/utils/rules_output.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cognitedata/cognite-sdk-python-experimental path: /cognite/experimental/data_classes/utils/rules_output.py
import copy
from typing import Dict, List
import regex
def _label_groups(extractors: List[Dict], conditions: List[Dict]):
colors = [
"".join(f"{int(round(rgb*255)):02x}" for r... | code_fim | hard | {
"lang": "python",
"repo": "cognitedata/cognite-sdk-python-experimental",
"path": "/cognite/experimental/data_classes/utils/rules_output.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for match in matches:
formatted = {
"source": copy.copy(match.get("source")),
"target": copy.copy(match.get("target")),
}
for extractor in extractors:
if extractor["extractorType"] != "regex":
continue
source_targ... | code_fim | hard | {
"lang": "python",
"repo": "cognitedata/cognite-sdk-python-experimental",
"path": "/cognite/experimental/data_classes/utils/rules_output.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> property = Regex(name='name', value='value')
self.assertIsNotNone(property)
self.assertIsNone(property.id)
self.assertEqual('name', property.name)
self.assertEqual('value', property.value)
self.assertEqual({'value': 'value', 'name': 'name'}, property.to_doc... | code_fim | hard | {
"lang": "python",
"repo": "keiffster/program-y",
"path": "/test/programytest/storage/stores/nosql/mongo/dao/test_property.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keiffster/program-y path: /test/programytest/storage/stores/nosql/mongo/dao/test_property.py
import unittest
from programy.storage.stores.nosql.mongo.dao.property import DefaultVariable
from programy.storage.stores.nosql.mongo.dao.property import Property
from programy.storage.stores.nosql.mongo... | code_fim | hard | {
"lang": "python",
"repo": "keiffster/program-y",
"path": "/test/programytest/storage/stores/nosql/mongo/dao/test_property.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> property = DefaultVariable(name='name', value='value')
property.id = '666'
self.assertIsNotNone(property)
self.assertIsNotNone(property.id)
self.assertEqual('666', property.id)
self.assertEqual('name', property.name)
self.assertEqual('value', proper... | code_fim | hard | {
"lang": "python",
"repo": "keiffster/program-y",
"path": "/test/programytest/storage/stores/nosql/mongo/dao/test_property.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: takedarts/hungry-geese path: /src/submission.py
import base64
import io
import itertools
import logging
import time
from typing import Callable, Dict, Optional, Tuple
import numpy as np
import torch.jit
import torch.nn as nn
from kaggle_environments.envs.hungry_geese.hungry_geese \
import Ac... | code_fim | hard | {
"lang": "python",
"repo": "takedarts/hungry-geese",
"path": "/src/submission.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('visit: {}, thread={}, remain={:.2f}'.format(
agent.visit, torch.get_num_threads(), float(obs.remaining_overage_time)))
print('actions:')
for didx, direction in enumerate(['NORTH', 'EAST', 'SOUTH', 'WEST']):
moves = agent.worlds[0].moves[obs.index, didx]
print(' {... | code_fim | hard | {
"lang": "python",
"repo": "takedarts/hungry-geese",
"path": "/src/submission.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def postprocess(agent: Agent, obs: Observation, action: Action):
global MODEL
print('visit: {}, thread={}, remain={:.2f}'.format(
agent.visit, torch.get_num_threads(), float(obs.remaining_overage_time)))
print('actions:')
for didx, direction in enumerate(['NORTH', 'EAST', 'SOUTH'... | code_fim | hard | {
"lang": "python",
"repo": "takedarts/hungry-geese",
"path": "/src/submission.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def __private_decorated_property(self):
return 'private decorated property'
def __private_instance_method(self):
return 'private instance method'
def _private_instance_method(self):
return 'private instance method'
@classmethod
def class_method(... | code_fim | hard | {
"lang": "python",
"repo": "infosmith/helpers",
"path": "/tests/fixtures/oop/reflection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, parent_instance_property='parent instance property value'):
super().__init__()
self.parent_instance_property = parent_instance_property
@property
def __parent_private_decorated_property(self):
return 'parent private decorated property'
def __par... | code_fim | hard | {
"lang": "python",
"repo": "infosmith/helpers",
"path": "/tests/fixtures/oop/reflection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: infosmith/helpers path: /tests/fixtures/oop/reflection.py
import abc
class AbstractTestCase(abc.ABC):
"""Third element of Method Resolution Order."""
abstract_class_property = 'abstract class property'
def __init__(self, abstract_instance_property='abstract instance property value'... | code_fim | hard | {
"lang": "python",
"repo": "infosmith/helpers",
"path": "/tests/fixtures/oop/reflection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jhsmit/PyHDX path: /templates/archive/plot_output.py
"""
Automagically plot all available figures from a fit result
"""
from pyhdx.fileIO import load_fitresult
from pyhdx.plot import FitResultPlot
from pathlib import Path
# %%
# __file__ = Path().cwd() / 'templates'/ 'script.py' # Uncomment f... | code_fim | medium | {
"lang": "python",
"repo": "Jhsmit/PyHDX",
"path": "/templates/archive/plot_output.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
cwd = Path(__file__).parent
output_dir = cwd / "output" / "figures"
output_dir.mkdir(exist_ok=True)
fit_result = load_fitresult(cwd / "output" / "SecB_tetramer_dimer_batch")
fr_plot = FitResultPlot(fit_result, output_path=output_dir)
kwargs = {
"residue_scatter": {"cmap": "BuGn"}, # change default... | code_fim | medium | {
"lang": "python",
"repo": "Jhsmit/PyHDX",
"path": "/templates/archive/plot_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JohnKarima/hood path: /hoodapp/views.py
from django.shortcuts import render, redirect
from django.contrib import messages
from django.http import HttpResponse
from .models import Profile, User, Post, Neighbourhood, Business, Services
from .forms import UserRegisterForm, UserUpdateForm, ProfileUp... | code_fim | hard | {
"lang": "python",
"repo": "JohnKarima/hood",
"path": "/hoodapp/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(request, f'Successfully created account created for {username}! Pl... | code_fim | hard | {
"lang": "python",
"repo": "JohnKarima/hood",
"path": "/hoodapp/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'business' in request.GET and request.GET["business"]:
search_term = request.GET.get("business")
searched_businesses = Business.search_business(search_term)
message = f"{search_term}"
return render(request, 'search.html', {"message":message,"businesses": searched_bus... | code_fim | hard | {
"lang": "python",
"repo": "JohnKarima/hood",
"path": "/hoodapp/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Get physical stats
Height = Strength + d6()
if Height <= 8:
Height = "Very Short"
elif Height <= 10:
Height = "Short"
elif Height <= 13:
Height = "Average"
elif Height <= 15:
Height = "Tall"
elif Height <= 17:
Height = "Very T... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/ElfStats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #get family background
Background = Fate + d6()
if Background == 12:
Background = "Gatherer"
Bronze = 10
Free = 8
new_specs = ["Forage", "Search"]
for ea in new_specs:
if ea not in Specialties:
Specialties.append(ea)
... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/ElfStats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheHalfling/LegendaryLivesCharacterGenerator path: /ElfStats.py
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 21 16:19:46 2018
@author: Sherry
Done
"""
def CorsairStats():
#Get base stats
Agility = 9 + d6()
Alertness =67 + d6()
Charm = 13 + d6()
Cunning = 3 +... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/ElfStats.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avidclam/amshared path: /tests/test_stage_metadata.py
from amshared.stage.metadata import MetaData
from amshared.stage.constants import (
STAGE_HEAP, STAGE_WILD, STAGE_RUBRIC_EMPTY,
MK_PAYLOAD, MK_RUBRIC, MK_NAME, MK_PART, MK_FORMAT
)
def test_stage_metadata_defaults():
meta = MetaD... | code_fim | hard | {
"lang": "python",
"repo": "avidclam/amshared",
"path": "/tests/test_stage_metadata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_stage_metadata_part():
meta = MetaData({MK_PART: ''})
assert MK_PART not in meta
assert meta.is_atomic is False
meta = MetaData({MK_NAME: 0, MK_PART: ''})
assert MK_PART not in meta
assert meta.is_atomic is True
meta = MetaData({MK_NAME: 0, MK_PART: 0})
assert met... | code_fim | hard | {
"lang": "python",
"repo": "avidclam/amshared",
"path": "/tests/test_stage_metadata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pa - position of a-th card
target_list = []
count=int(msg[:8], base=16)
msg = msg[8:]
while len(msg) > 0:
set=int(msg[:8], base=16)
pos=int(msg[8:16], base=16)
target_list.append((set, pos))
... | code_fim | hard | {
"lang": "python",
"repo": "bzbikowski/DuelMasters-game",
"path": "/src/controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bfield.set_untapped(c_pos)
self.master.add_log(f"Opponent creature at pos {c_pos} is now untapped.")
self.master.refresh_screen()
elif command == 17:
# 17,c,s1,p1,s2,p2... - opponent chooses which cards to destroy from the list
# c - how many... | code_fim | hard | {
"lang": "python",
"repo": "bzbikowski/DuelMasters-game",
"path": "/src/controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bzbikowski/DuelMasters-game path: /src/controller.py
pot on gameboard
c_id = int(msg[:8], base=16)
c_pos = int(msg[8:16], base=16)
card = self.master.database.get_card(c_id)
if card.card_type == "Spell":
self.master.opp_sfield.set_ca... | code_fim | hard | {
"lang": "python",
"repo": "bzbikowski/DuelMasters-game",
"path": "/src/controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
... | code_fim | hard | {
"lang": "python",
"repo": "syedwaseemjan/RiskManager",
"path": "/app/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> register_blueprints(app, package_name, package_path)
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access... | code_fim | hard | {
"lang": "python",
"repo": "syedwaseemjan/RiskManager",
"path": "/app/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: syedwaseemjan/RiskManager path: /app/factory.py
import os
from flask import Flask
from app.extensions import db
from app.utils import register_blueprints
from settings import PROJECT_ROOT
def create_app(package_name, package_path, settings_override=None,
<|fim_suffix|> register_blueprints(... | code_fim | hard | {
"lang": "python",
"repo": "syedwaseemjan/RiskManager",
"path": "/app/factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phiysng/leetcode path: /leetcode/python/util.py
# -*- coding=utf-8 -*-
from typing import Optional
<|fim_suffix|> self.val = x
self.left: Optional[TreeNode] = None
self.right: Optional[TreeNode] = None<|fim_middle|>class TreeNode:
def __init__(self, x):
| code_fim | easy | {
"lang": "python",
"repo": "phiysng/leetcode",
"path": "/leetcode/python/util.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.val = x
self.left: Optional[TreeNode] = None
self.right: Optional[TreeNode] = None<|fim_prefix|># repo: phiysng/leetcode path: /leetcode/python/util.py
# -*- coding=utf-8 -*-
from typing import Optional
class TreeNode:
<|fim_middle|> def __init__(self, x):
| code_fim | easy | {
"lang": "python",
"repo": "phiysng/leetcode",
"path": "/leetcode/python/util.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._hasnext
def compareStr(s, t):
# compare each character until there's a difference!!!
this = sum([ord(x) for x in s])
that = sum([ord(x) for x in t])
result = this - that
return result
def xlogx(x):
if x <= 0:
result = 0
else:
... | code_fim | hard | {
"lang": "python",
"repo": "eric-erki/multivac",
"path": "/pymln/utils/Utils.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class java_iter(object):
def __init__(self, it):
self.it = iter(it)
self._hasnext = None
def __iter__(self): return self
def next(self):
if self._hasnext:
result = self._thenext
else:
result = next(self.it)
self._hasnext = N... | code_fim | hard | {
"lang": "python",
"repo": "eric-erki/multivac",
"path": "/pymln/utils/Utils.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eric-erki/multivac path: /pymln/utils/Utils.py
#
# Utility functions for pymln parsing
#
import math
def inc_key(d, key, inc=1):
if key not in d:
d[key] = inc
else:
d[key] += inc
return d
def dec_key(d, key, base=None, dec=1, remove=False):
if key not in d:
... | code_fim | hard | {
"lang": "python",
"repo": "eric-erki/multivac",
"path": "/pymln/utils/Utils.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaoxiae/Robotics-Simplified-Website path: /_includes/code/algorithms/motor-controllers/polynomial-function/example.py
# initialize objects that control robot components
left_motor = Motor(1)
right_motor = Motor(2)
encoder = Encoder()
<|fim_suffix|>while True:
# get the controller valu... | code_fim | medium | {
"lang": "python",
"repo": "xiaoxiae/Robotics-Simplified-Website",
"path": "/_includes/code/algorithms/motor-controllers/polynomial-function/example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # drive the robot using tank drive controlled by the controller value
tank_drive(controller_value, controller_value, left_motor, right_motor)<|fim_prefix|># repo: xiaoxiae/Robotics-Simplified-Website path: /_includes/code/algorithms/motor-controllers/polynomial-function/example.py
# initialize o... | code_fim | medium | {
"lang": "python",
"repo": "xiaoxiae/Robotics-Simplified-Website",
"path": "/_includes/code/algorithms/motor-controllers/polynomial-function/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenbjin/models path: /legacy/sequence_tagging_for_ner/network_conf.py
import math
import paddle.v2 as paddle
import paddle.v2.evaluator as evaluator
def ner_net(word_dict_len, label_dict_len, stack_num=2, is_train=True):
mark_dict_len = 2
word_dim = 50
mark_dim = 5
hidden_dim ... | code_fim | hard | {
"lang": "python",
"repo": "chenbjin/models",
"path": "/legacy/sequence_tagging_for_ner/network_conf.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> crf = paddle.layer.crf(size=label_dict_len,
input=emission,
label=target,
param_attr=paddle.attr.Param(
name="crfw",
initial_std=1. / m... | code_fim | hard | {
"lang": "python",
"repo": "chenbjin/models",
"path": "/legacy/sequence_tagging_for_ner/network_conf.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.parametrize('metrics',
itertools.combinations(['adjusted_rand', 'adjusted_mutual_info', 'v_measure'], 2))
def test_clustering_metrics(app, metrics):
metrics = list(metrics)
url = V01 + '/metrics/clustering'
labels_true = [0, 0, 1, 2]
labels_pred = [0,... | code_fim | hard | {
"lang": "python",
"repo": "FreeDiscovery/FreeDiscovery",
"path": "/freediscovery/server/tests/test_metrics.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.parametrize('metrics',
itertools.combinations(['ratio_duplicates', 'f1_same_duplicates', 'mean_duplicates_count'], 2))
def test_dupdetection_metrics(app, metrics):
metrics = list(metrics)
url = V01 + '/metrics/duplicate-detection'
labels_true = [0, 1, 1, ... | code_fim | hard | {
"lang": "python",
"repo": "FreeDiscovery/FreeDiscovery",
"path": "/freediscovery/server/tests/test_metrics.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FreeDiscovery/FreeDiscovery path: /freediscovery/server/tests/test_metrics.py
# -*- coding: utf-8 -*-
import pytest
import itertools
from numpy.testing import assert_almost_equal
from .. import fd_app
from .base import parse_res, V01, app, app_notest
@pytest.mark.parametrize('metrics',
... | code_fim | hard | {
"lang": "python",
"repo": "FreeDiscovery/FreeDiscovery",
"path": "/freediscovery/server/tests/test_metrics.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def lorentz_factor(
x,
bh_mass,
bh_dimless_spin,
dimless_r_in,
dimless_r_max,
polytropic_constant,
polytropic_exponent,
threshold_density,
plasma_beta,
):
dummy_time = 0.0
return fm_disk.lorentz_factor(
x,
dummy_time,
bh_mass,
bh_... | code_fim | hard | {
"lang": "python",
"repo": "sxs-collaboration/spectre",
"path": "/tests/Unit/PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def pressure(
x,
bh_mass,
bh_dimless_spin,
dimless_r_in,
dimless_r_max,
polytropic_constant,
polytropic_exponent,
threshold_density,
plasma_beta,
):
dummy_time = 0.0
return fm_disk.pressure(
x,
dummy_time,
bh_mass,
bh_dimless_spin... | code_fim | hard | {
"lang": "python",
"repo": "sxs-collaboration/spectre",
"path": "/tests/Unit/PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sxs-collaboration/spectre path: /tests/Unit/PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.py
# Distributed under the MIT License.
# See LICENSE.txt for details.
import numpy as np
import PointwiseFunctions.AnalyticSolutions.RelativisticEuler.FishboneMoncriefDisk as fm_disk
import Pointw... | code_fim | hard | {
"lang": "python",
"repo": "sxs-collaboration/spectre",
"path": "/tests/Unit/PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: starlingx/nfv path: /nfv/nfv-vim/nfv_vim/api/controllers/v1/openstack/_heat_api.py
#
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import functools
import inspect
import pecan
import webob
from nfv_common import debug
from nfv_vim.api import openst... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/nfv",
"path": "/nfv/nfv-vim/nfv_vim/api/controllers/v1/openstack/_heat_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> url_target_index = pecan.request.url.find('/api/openstack/heat')
url_target = pecan.request.url[url_target_index + len('/api/openstack/heat'):]
if '' == url_target or '/' == url_target:
url = token.get_service_url(openstack.OPENSTACK_SERVICE.HEAT,
... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/nfv",
"path": "/nfv/nfv-vim/nfv_vim/api/controllers/v1/openstack/_heat_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> functools.update_wrapper(proxy_http_wrapper, func)
return proxy_http_wrapper
return proxy_http_wrap
class HeatAPI(object):
"""
OpenStack Heat API
"""
@expose_proxy_http()
def _openstack_heat_proxy(self):
"""
OpenStack Heat Proxy
"""
... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/nfv",
"path": "/nfv/nfv-vim/nfv_vim/api/controllers/v1/openstack/_heat_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_doc_date(soup):
target_soup = soup[3]
raw_date = target_soup.get('title')
#date_format = '%Y.%m.%d %H:%M:%S'
#date = datetime.strptime(raw_date, date_format)
date = raw_date
return date
def get_doc_views(soup):
target_soup = soup[4]
views = target_soup.te... | code_fim | hard | {
"lang": "python",
"repo": "bootsofspeed/DCPheonix",
"path": "/dc_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bootsofspeed/DCPheonix path: /dc_api.py
s = sess.get(url, **kwargs)
break
except requests.exceptions.Timeout as error:
tprint('requests get timed out.')
tprint(error)
except requests.exceptions.RequestException as error:
tprint... | code_fim | hard | {
"lang": "python",
"repo": "bootsofspeed/DCPheonix",
"path": "/dc_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> doc_info = {
'title': None, 'no': None,
'user_id': None, 'user_name': None,
'ip': None, 'date': None,
'views': None, 'recommands': None,
}
doc_info['title'] = get_doc_title(doc_soup)
doc_info['no'] = get_doc_no(doc_soup)
doc_info['user_id']... | code_fim | hard | {
"lang": "python",
"repo": "bootsofspeed/DCPheonix",
"path": "/dc_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Khahory/curso_de_python_yacklyon-trabajo-py path: /Video 27/Funciones I.py
def suma_tres(n1):
print(n1 + 10)
suma_tres(10)
suma_tres(20)
suma_tres(30)
<|fim_suffix|>print(convertir_cadena("hola"))<|fim_middle|>def convertir_cadena(cadena):
return cadena.upper()
| code_fim | easy | {
"lang": "python",
"repo": "Khahory/curso_de_python_yacklyon-trabajo-py",
"path": "/Video 27/Funciones I.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def convertir_cadena(cadena):
return cadena.upper()
print(convertir_cadena("hola"))<|fim_prefix|># repo: Khahory/curso_de_python_yacklyon-trabajo-py path: /Video 27/Funciones I.py
def suma_tres(n1):
<|fim_middle|> print(n1 + 10)
suma_tres(10)
suma_tres(20)
suma_tres(30)
| code_fim | medium | {
"lang": "python",
"repo": "Khahory/curso_de_python_yacklyon-trabajo-py",
"path": "/Video 27/Funciones I.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>suma_tres(10)
suma_tres(20)
suma_tres(30)
def convertir_cadena(cadena):
return cadena.upper()
print(convertir_cadena("hola"))<|fim_prefix|># repo: Khahory/curso_de_python_yacklyon-trabajo-py path: /Video 27/Funciones I.py
def suma_tres(n1):
<|fim_middle|> print(n1 + 10)
| code_fim | easy | {
"lang": "python",
"repo": "Khahory/curso_de_python_yacklyon-trabajo-py",
"path": "/Video 27/Funciones I.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rooneyrulz/polls_pro path: /src/framework/migrations/0005_auto_20200705_1845.py
# Generated by Django 3.0.6 on 2020-07-05 13:15
from django.conf import settings
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
migrations.swappable_dependency(settings.AUTH_USE... | code_fim | medium | {
"lang": "python",
"repo": "rooneyrulz/polls_pro",
"path": "/src/framework/migrations/0005_auto_20200705_1845.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='framework',
name='vote',
),
migrations.AddField(
model_name='framework',
name='vote',
field=models.ManyToManyField(to=settings.AUTH_USER_MODEL),
),
]<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "rooneyrulz/polls_pro",
"path": "/src/framework/migrations/0005_auto_20200705_1845.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('framework', '0004_auto_20200705_1818'),
]
operations = [
migrations.RemoveField(
model_name='framework',
name='vote',
),
migrations.AddField(
... | code_fim | medium | {
"lang": "python",
"repo": "rooneyrulz/polls_pro",
"path": "/src/framework/migrations/0005_auto_20200705_1845.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>process_video("project_video.mp4")
#process_video("challenge_video.mp4")
#process_video("harder_challenge_video.mp4")<|fim_prefix|># repo: skopen/CarND-Advanced-Lane-Lines path: /pipeline.py
from main_image_processor import *
<|fim_middle|>init(False)
| code_fim | easy | {
"lang": "python",
"repo": "skopen/CarND-Advanced-Lane-Lines",
"path": "/pipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skopen/CarND-Advanced-Lane-Lines path: /pipeline.py
from main_image_processor import *
<|fim_suffix|>process_video("project_video.mp4")
#process_video("challenge_video.mp4")
#process_video("harder_challenge_video.mp4")<|fim_middle|>init(False)
| code_fim | easy | {
"lang": "python",
"repo": "skopen/CarND-Advanced-Lane-Lines",
"path": "/pipeline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bobloy/aikaterna-cogs path: /forwarding/forwarding.py
# forwarding.py is ported from another bot:
# https://github.com/jacobcheatley/dankbot
import discord
from discord.ext import commands
from .utils.dataIO import dataIO
from .utils import checks
class Forwarding:
def __init__(self, bot... | code_fim | medium | {
"lang": "python",
"repo": "bobloy/aikaterna-cogs",
"path": "/forwarding/forwarding.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> embed = discord.Embed()
if message.author == self.bot.user:
embed.title = 'Sent PM to {}#{} ({}).'.format(message.channel.user.name, message.channel.user.discriminator, message.channel.user.id)
else:
embed.set_author(name=message.author, icon_url=message.aut... | code_fim | hard | {
"lang": "python",
"repo": "bobloy/aikaterna-cogs",
"path": "/forwarding/forwarding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_owner(self):
owner_id = dataIO.load_json("data/red/settings.json")["OWNER"]
return discord.utils.find(lambda m: m.id == owner_id, self.bot.get_all_members())
async def send_to_owner(self, **kwargs):
if self.owner is None:
self.owner = self.get_owner()
... | code_fim | medium | {
"lang": "python",
"repo": "bobloy/aikaterna-cogs",
"path": "/forwarding/forwarding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carsam2021/instagram_api path: /instagram_api/response/switch_personal_profile.py
from .mapper import ApiResponse, ApiResponseInterface
from .mapper.types import Timestamp, AnyType
from .model import User
<|fim_suffix|>class SwitchPersonalProfileResponseInterface(ApiResponseInterface):
users... | code_fim | easy | {
"lang": "python",
"repo": "carsam2021/instagram_api",
"path": "/instagram_api/response/switch_personal_profile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class SwitchPersonalProfileResponse(ApiResponse, SwitchPersonalProfileResponseInterface):
pass<|fim_prefix|># repo: carsam2021/instagram_api path: /instagram_api/response/switch_personal_profile.py
from .mapper import ApiResponse, ApiResponseInterface
from .mapper.types import Timestamp, AnyType
fro... | code_fim | medium | {
"lang": "python",
"repo": "carsam2021/instagram_api",
"path": "/instagram_api/response/switch_personal_profile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Uttam95yadav/CarND-Behavioral-Cloning-P3 path: /model.py
import tensorflow as tf
from keras.models import Sequential, model_from_json, load_model
from keras.layers import Dense, Activation, Flatten, Dropout, Lambda, Cropping2D, ELU
from keras.layers.convolutional import Convolution2D
from scipy.m... | code_fim | hard | {
"lang": "python",
"repo": "Uttam95yadav/CarND-Behavioral-Cloning-P3",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> num_data = len(csv_data)
# itrate through batches
for start in range(0, num_data, batch_size):
images, measurements = [], []
# itrate inside the batch
for csv_line in range(start, start + batch_size):
if csv_line < num_data:
image, measurement = get_image(cs... | code_fim | hard | {
"lang": "python",
"repo": "Uttam95yadav/CarND-Behavioral-Cloning-P3",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: john-sandall/maven path: /tests/datasets/coronavirus/test_csse.py
"""
Running tests in development:
$ cd /path/to/repo
$ python -m pytest ./tests/datasets/coronavirus/test_csse.py
Running tests against installed version (either `pip install .` or `pip install maven`):
$ cd /path/to/r... | code_fim | medium | {
"lang": "python",
"repo": "john-sandall/maven",
"path": "/tests/datasets/coronavirus/test_csse.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_csse():
identifier = "coronavirus/CSSE"
maven.get(identifier, data_directory="./data/")
# CSSE_country.csv
processed_filename = "CSSE_country.csv"
df = pd.read_csv(Path("./data") / identifier / "processed" / processed_filename)
assert df.columns.tolist() == ["date", "coun... | code_fim | medium | {
"lang": "python",
"repo": "john-sandall/maven",
"path": "/tests/datasets/coronavirus/test_csse.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def on_message(client, userdata, msg):
global statePower, stateColor, stateBright, stateHue, stateSat
print(msg.topic+" "+str(msg.payload))
if msg.payload == "true":
newValue = 1
elif msg.payload == "false":
newValue = 0
else:
try:
newValue = int(m... | code_fim | hard | {
"lang": "python",
"repo": "jbieling/tradfri-mqtt",
"path": "/tradfri_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
try:
GPIO.setwarnings (True)
GPIO.setmode (GPIO.BCM)
GPIO.setup (TOUCHLINK_RESET_PIN, GPIO.OUT, initial=True)
GPIO.setup (COLOR_PIN, GPIO.OUT, initial=True)
GPIO.setup (DIM_DOWN_PIN, GPIO.OUT, initial=True)
GPIO.setup (DIM_UP_... | code_fim | hard | {
"lang": "python",
"repo": "jbieling/tradfri-mqtt",
"path": "/tradfri_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jbieling/tradfri-mqtt path: /tradfri_mqtt.py
#!/usr/bin/env python
#
# MIT License
#
# Copyright (c) 2017 Jakob Bieling
#
# 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 Softwa... | code_fim | hard | {
"lang": "python",
"repo": "jbieling/tradfri-mqtt",
"path": "/tradfri_mqtt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>emy_row += 1
if enemy_row > 2 or enemy_count > 12 or x == 0 or y == 0:
tile = '-'
elif tile == '#':
box_row += 1
if box_row > 1 or box_count > 8 or x == 0 or y == 0:
tile = '-'
temp.append(tile)
level.append(temp)
box_row = 0
enemy_row = 0
box_count += box_ro... | code_fim | medium | {
"lang": "python",
"repo": "IoraDungeon/main",
"path": "/randlevels.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>== 0 or y == 0:
tile = '-'
temp.append(tile)
level.append(temp)
box_row = 0
enemy_row = 0
box_count += box_row
enemy_count += enemy_row
return level<|fim_prefix|># repo: IoraDungeon/main path: /randlevels.py
import pygame
import random
# Returns a randomly generated 2d arra... | code_fim | medium | {
"lang": "python",
"repo": "IoraDungeon/main",
"path": "/randlevels.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IoraDungeon/main path: /randlevels.py
import pygame
import random
# Returns a randomly generated 2d array
def genlevel():
level = []
choices = ['-', '-','X','#', '-','-']
temp = []
enemy_count = 0
<|fim_suffix|>emy_row += 1
if enemy_row > 2 or enemy_count > 12 or x == 0 or y =... | code_fim | medium | {
"lang": "python",
"repo": "IoraDungeon/main",
"path": "/randlevels.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Throws KeyError exception if dictionary doesn't contain a key from
"columns".
"""
file = open(path, 'w', newline = '', encoding = 'utf-8')
writer = csv.writer(file, delimiter = '\t', quotechar = '', quoting = csv.QUOTE_NONE)
row = []
for col in columns:
row.append(col)
writer.write... | code_fim | hard | {
"lang": "python",
"repo": "IMCS-DL4media/DL4media_ticker_extractor",
"path": "/code/tsv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IMCS-DL4media/DL4media_ticker_extractor path: /code/tsv.py
import csv
"""
Commonly used functions for operating with TSV files
"""
def read(path):
"""
Returns list of dictionaries.
<|fim_suffix|>def write(l, path, columns):
"""
Writes write list of dictionaries to Tab Seperated Value... | code_fim | hard | {
"lang": "python",
"repo": "IMCS-DL4media/DL4media_ticker_extractor",
"path": "/code/tsv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ginopalazzo/dedomeno path: /dedomeno/houses/migrations/0078_auto_20170104_1050.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-04 09:50
from __future__ import unicode_literals
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.RenameF... | code_fim | medium | {
"lang": "python",
"repo": "ginopalazzo/dedomeno",
"path": "/dedomeno/houses/migrations/0078_auto_20170104_1050.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('houses', '0077_realestate_html'),
]
operations = [
migrations.RenameField(
model_name='realestate',
old_name='source_url',
new_name='web',
),
migrations.RemoveField(
model_name='realestate',
... | code_fim | medium | {
"lang": "python",
"repo": "ginopalazzo/dedomeno",
"path": "/dedomeno/houses/migrations/0078_auto_20170104_1050.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return HttpResponseRedirect('/sales/')
return render(request, self.template_name, {'form': form})
class SalesList(AjaxListView):
'''
List of sales
'''
context_object_name = 'sales'
template_name = '../templates/sales_list.html'
page_template = '../templates/... | code_fim | hard | {
"lang": "python",
"repo": "iabok/sales-tracker",
"path": "/web/sales_app/apps/sales/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iabok/sales-tracker path: /web/sales_app/apps/sales/views.py
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views import View
from django.views.generic import ListView, DetailView
from el_pagination.views import A... | code_fim | hard | {
"lang": "python",
"repo": "iabok/sales-tracker",
"path": "/web/sales_app/apps/sales/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Return all the stations
'''
return Sales.objects.all()
class SalesDetail(DetailView):
'''
View sales details
'''
context_object_name = 'sales'
model = Sales
template_name = '../templates/sales_detail.html'
def get_context_data(self, **... | code_fim | hard | {
"lang": "python",
"repo": "iabok/sales-tracker",
"path": "/web/sales_app/apps/sales/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert 'foo.sh' == \
nodelib.script_deployment('foo.sh', 'l1\nl2\nl3\n').name
def test_node_deployment(self):
nd = nodelib.Deployment(bundles=['mta'])
assert nd.name.startswith(config.DEFAULT_NAME_PREFIX)
assert libcloud.compute.deployment.SSHKeyDeployment ... | code_fim | medium | {
"lang": "python",
"repo": "rskgithub/provision",
"path": "/test/test_deploy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rskgithub/provision path: /test/test_deploy.py
import unittest
import libcloud.compute.deployment
import provision.config as config
import provision.nodelib as nodelib
<|fim_suffix|> nd = nodelib.Deployment(bundles=['mta'])
assert nd.name.startswith(config.DEFAULT_NAME_PREFIX)
... | code_fim | hard | {
"lang": "python",
"repo": "rskgithub/provision",
"path": "/test/test_deploy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> nd = nodelib.Deployment(bundles=['mta'])
assert nd.name.startswith(config.DEFAULT_NAME_PREFIX)
assert libcloud.compute.deployment.SSHKeyDeployment == type(nd.deployment.steps[0])<|fim_prefix|># repo: rskgithub/provision path: /test/test_deploy.py
import unittest
import libcloud.c... | code_fim | hard | {
"lang": "python",
"repo": "rskgithub/provision",
"path": "/test/test_deploy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiscoTestAutomation/genieparser path: /src/genie/libs/parser/junos/tests/ShowSnmpMibWalkSystem/cli/equal/golden_output_1_expected.py
expected_output = {
"snmp-object-information": {
"snmp-object": [
{
"name": "sysDescr.0",
"object-value": "J... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genieparser",
"path": "/src/genie/libs/parser/junos/tests/ShowSnmpMibWalkSystem/cli/equal/golden_output_1_expected.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {"name": "sysUpTime.0", "object-value": "1805867174"},
{"name": "sysContact.0", "object-value": "KHK"},
{"name": "sysName.0", "object-value": "sr_hktGDS201"},
{
"name": "sysLocation.0",
"object-value": "TH-HK2/floor_1B-002/rack_... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genieparser",
"path": "/src/genie/libs/parser/junos/tests/ShowSnmpMibWalkSystem/cli/equal/golden_output_1_expected.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: azgs-geomapmaker/GeMS-Toolbox path: /ArcPro/Scripts/lookup.py
#! /usr/bin/env python3
# Note: https URLs possibly cause Geoprocessing scripts to hang...
<|fim_suffix|># Send back response as JSON
# TODO improve flexibility of call, possibly remove hard-coded indent level
arcpy.AddMessage(... | code_fim | hard | {
"lang": "python",
"repo": "azgs-geomapmaker/GeMS-Toolbox",
"path": "/ArcPro/Scripts/lookup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Retrieve JSON
response = urllib.request.urlopen(url).read().decode()
response_as_json = json.loads(response)
# Send back response as JSON
# TODO improve flexibility of call, possibly remove hard-coded indent level
arcpy.AddMessage(json.dumps(response_as_json, sort_keys=True, indent=4))<|fim_pre... | code_fim | medium | {
"lang": "python",
"repo": "azgs-geomapmaker/GeMS-Toolbox",
"path": "/ArcPro/Scripts/lookup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: optexture/td-components path: /utils/settings/SettingsExt.py
import json
# noinspection PyUnreachableCode
if False:
# noinspection PyUnresolvedReferences
from _stubs import *
from typing import Any
iop.hostedComp = COMP()
ipar.compEditor = Any()
from _stubs.TDCallbacksExt import CallbacksE... | code_fim | hard | {
"lang": "python",
"repo": "optexture/td-components",
"path": "/utils/settings/SettingsExt.py",
"mode": "psm",
"license": "CC0-1.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.