text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: TinaABB/projectpensive path: /civility/classifier/runner.py
import torch
from transformers import DistilBertTokenizerFast, DistilBertForSequenceClassification
class CivilCommentsRunner:
<|fim_suffix|> def run_model(self, string):
encoded_input = self.tokenizer(string, truncation=True... | code_fim | hard | {
"lang": "python",
"repo": "TinaABB/projectpensive",
"path": "/civility/classifier/runner.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabisurita/aulas-unicamp path: /2015s2/mc202/misc/pyio/call.py
import os
Input = "code.c"
Executable = Input.split(".")[0] + ""
Share<|fim_suffix|>t, Executable))
print os.popen('./%s "%s"' % (Executable, StdIn)).read()<|fim_middle|>dLibrary = Input.split(".")[0] + ".so"
StdIn
#os.popen("gcc %s... | code_fim | medium | {
"lang": "python",
"repo": "gabisurita/aulas-unicamp",
"path": "/2015s2/mc202/misc/pyio/call.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t, Executable))
print os.popen('./%s "%s"' % (Executable, StdIn)).read()<|fim_prefix|># repo: gabisurita/aulas-unicamp path: /2015s2/mc202/misc/pyio/call.py
import os
Input = "code.c"
Executable = Input.split(".")[0] + ""
SharedLibrary = Input.split(".")[0] + ".so"
StdIn
#os.popen("gcc %s -shared <|fim... | code_fim | medium | {
"lang": "python",
"repo": "gabisurita/aulas-unicamp",
"path": "/2015s2/mc202/misc/pyio/call.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print "" + app_bin + " " + app_args + " >> " + report_filename
value = ccbench.runBash("" + app_bin + " " + app_args + " >> " + report_filename)
if value != "": print value<|fim_prefix|># repo: CharmyS/thesis path: /Cache_ARM/arch/arm/architecture.py
#! /usr/bin/env python
# Author: Christop... | code_fim | medium | {
"lang": "python",
"repo": "CharmyS/thesis",
"path": "/Cache_ARM/arch/arm/architecture.py",
"mode": "spm",
"license": "LicenseRef-scancode-bsd-3-clause-jtag",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CharmyS/thesis path: /Cache_ARM/arch/arm/architecture.py
#! /usr/bin/env python
# Author: Christopher Celio
# Date : 2014 Feb 21
#
# Hold architecture-specific Python glue in here. In particular, this code
# handles invoking the benchmark binaries on the desired target architecture.
# Pass in... | code_fim | medium | {
"lang": "python",
"repo": "CharmyS/thesis",
"path": "/Cache_ARM/arch/arm/architecture.py",
"mode": "psm",
"license": "LicenseRef-scancode-bsd-3-clause-jtag",
"source": "the-stack-v2"
} |
<|fim_suffix|>def runBenchmark(processor, app_bin, app_args, report_filename):
print "" + app_bin + " " + app_args + " >> " + report_filename
value = ccbench.runBash("" + app_bin + " " + app_args + " >> " + report_filename)
if value != "": print value<|fim_prefix|># repo: CharmyS/thesis path: /Cache_ARM/ar... | code_fim | medium | {
"lang": "python",
"repo": "CharmyS/thesis",
"path": "/Cache_ARM/arch/arm/architecture.py",
"mode": "spm",
"license": "LicenseRef-scancode-bsd-3-clause-jtag",
"source": "the-stack-v2"
} |
<|fim_suffix|> boxes_bev_center = []
for box in boxes_bev:
pts = box.reshape((4, 2))
pts = pts.astype(np.int32)
bx = cv2.minAreaRect(pts)
xc, yc, w, h, angle = bx[0][0], bx[0][1], bx[1][0], bx[1][1], bx[2]
angle *= (np.pi/180)
bx = np.array([xc, yc, w, h, angle])
... | code_fim | hard | {
"lang": "python",
"repo": "YeungLy/Sparse_Pooling",
"path": "/avod/avod/core/box_bev_encoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YeungLy/Sparse_Pooling path: /avod/avod/core/box_bev_encoder.py
import numpy as np
import cv2
from avod.core import box_3d_projector
from avod.core import anchor_bev_encoder
def box_bev_to_iou_h_format(boxes_bev):
"""Return min area aligned box cover the rotate bev box
Args:
box_... | code_fim | hard | {
"lang": "python",
"repo": "YeungLy/Sparse_Pooling",
"path": "/avod/avod/core/box_bev_encoder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def box_bev_to_anchor_3d(boxes_bev, bev_shape, bev_extents, h3d=None):
#set default value
boxes_3d = box_bev_to_box_3d(boxes_bev, bev_shape, bev_extents, h3d)
anchors_3d = boxes_3d[:, :-1]
#(x, y, z, l, w, h, ry) to (x, y, z, dx=l, dy=h, dz=w)
anchors_3d[:, [4, 5]] = anchors_3d[:, [5, 4]... | code_fim | hard | {
"lang": "python",
"repo": "YeungLy/Sparse_Pooling",
"path": "/avod/avod/core/box_bev_encoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: metanitesh/Data-Structure-Algorithm-Python path: /data-structure/recursion/12-tower-of-honoi.py
# Solution
def tower_of_Hanoi_soln(num_disks, source, auxiliary, destination):
<|fim_suffix|> if num_disks == 1:
print("{} {}".format(source, destination))
return
tower_of_H... | code_fim | medium | {
"lang": "python",
"repo": "metanitesh/Data-Structure-Algorithm-Python",
"path": "/data-structure/recursion/12-tower-of-honoi.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tower_of_Hanoi_soln(num_disks, 'S', 'A', 'D')
tower_of_Hanoi(2)<|fim_prefix|># repo: metanitesh/Data-Structure-Algorithm-Python path: /data-structure/recursion/12-tower-of-honoi.py
# Solution
def tower_of_Hanoi_soln(num_disks, source, auxiliary, destination):
if num_disks == 0:
retu... | code_fim | medium | {
"lang": "python",
"repo": "metanitesh/Data-Structure-Algorithm-Python",
"path": "/data-structure/recursion/12-tower-of-honoi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>largest_key = 0
for replicon in repliconList:
key = get_key(replicon[0])
if key > largest_key:
largest_key = key
replicon_index = []
for i in range((largest_key)):
replicon_index.append([])
count = 0
for replicon in repliconList:
key = get_key(replicon[0])
replicon_index[(key-1... | code_fim | hard | {
"lang": "python",
"repo": "katholt/RedDog",
"path": "/deriveAllRepGeneCover.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: katholt/RedDog path: /deriveAllRepGeneCover.py
#!/usr/bin/env python
'''
deriveAllRepGeneCover.py
Copyright (c) 2015, David Edwards, Bernie Pope, Kat Holt
All rights reserved. (see README.txt for more details)
Takes the genbank file for the reference sequence and the coverage file for an isolat... | code_fim | hard | {
"lang": "python",
"repo": "katholt/RedDog",
"path": "/deriveAllRepGeneCover.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, *args, **kwargs):
super().__init__()
self.args = args
self.kwargs = kwargs
# Create a unique subclass for every api_cls so that none of
# them share an ovsdb_connection, a class attribute that
# different tests running in the same proc... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ovsdbapp",
"path": "/ovsdbapp/tests/functional/schema/fixtures.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/ovsdbapp path: /ovsdbapp/tests/functional/schema/fixtures.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses... | code_fim | medium | {
"lang": "python",
"repo": "openstack/ovsdbapp",
"path": "/ovsdbapp/tests/functional/schema/fixtures.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sujitnoronha/hack_a_sol_2021 path: /clientpage/migrations/0003_auto_20210227_1341.py
# Generated by Django 3.1.7 on 2021-02-27 08:11
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> operations = [
migrations.Al... | code_fim | hard | {
"lang": "python",
"repo": "sujitnoronha/hack_a_sol_2021",
"path": "/clientpage/migrations/0003_auto_20210227_1341.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='donationdrives',
name='image',
field=models.ImageField(null=True, upload_to='donationprofiles'),
),
migrations.CreateModel(
name='Appointments',
fields=[
... | code_fim | hard | {
"lang": "python",
"repo": "sujitnoronha/hack_a_sol_2021",
"path": "/clientpage/migrations/0003_auto_20210227_1341.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x1, x2, y1, y2 = vcs.utils.getworldcoordinates(self._gm, data1.getAxis(-1),
data1.getAxis(-2))
if geo is None:
wc = [x1, x2, y1, y2]
else:
xrange = list(act.GetXRange())
yrange = list(act.Get... | code_fim | hard | {
"lang": "python",
"repo": "raverjulie/uvcdat",
"path": "/Packages/vcs/Lib/vcsvtk/vectorpipeline.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> for k in ['vtk_backend_grid', 'xm', 'xM', 'ym', 'yM', 'continents',
'wrap', 'geo']:
exec("%s = gridGenDict['%s']" % (k, k))
grid = gridGenDict['vtk_backend_grid']
self._dataWrapModulo = gridGenDict['wrap']
if geo is not None:
newv ... | code_fim | hard | {
"lang": "python",
"repo": "raverjulie/uvcdat",
"path": "/Packages/vcs/Lib/vcsvtk/vectorpipeline.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raverjulie/uvcdat path: /Packages/vcs/Lib/vcsvtk/vectorpipeline.py
from .pipeline import Pipeline
import vcs
from vcs import vcs2vtk
import vtk
class VectorPipeline(Pipeline):
"""Implementation of the Pipeline interface for VCS vector plots."""
def __init__(self, gm, context_):
... | code_fim | hard | {
"lang": "python",
"repo": "raverjulie/uvcdat",
"path": "/Packages/vcs/Lib/vcsvtk/vectorpipeline.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>def ucitaj_lekara():
with open(datoteka, "r") as f:
return json.load(f)
ucitaj_lekara()<|fim_prefix|># repo: bobanmarinkovic/Projekatoop path: /projekat/pacijent/LekarIO.py
import json
datoteka= './datoteke/lekar.json'
def sacuvaj_lekara(lekar):
<|fim_middle|>
with open(datoteka, "w... | code_fim | medium | {
"lang": "python",
"repo": "bobanmarinkovic/Projekatoop",
"path": "/projekat/pacijent/LekarIO.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bobanmarinkovic/Projekatoop path: /projekat/pacijent/LekarIO.py
import json
datoteka= './datoteke/lekar.json'
<|fim_suffix|> with open(datoteka, "r") as f:
return json.load(f)
ucitaj_lekara()<|fim_middle|>def sacuvaj_lekara(lekar):
with open(datoteka, "w") as f:
json... | code_fim | medium | {
"lang": "python",
"repo": "bobanmarinkovic/Projekatoop",
"path": "/projekat/pacijent/LekarIO.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(datoteka, "r") as f:
return json.load(f)
ucitaj_lekara()<|fim_prefix|># repo: bobanmarinkovic/Projekatoop path: /projekat/pacijent/LekarIO.py
import json
datoteka= './datoteke/lekar.json'
<|fim_middle|>def sacuvaj_lekara(lekar):
with open(datoteka, "w") as f:
json... | code_fim | medium | {
"lang": "python",
"repo": "bobanmarinkovic/Projekatoop",
"path": "/projekat/pacijent/LekarIO.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._hipchat = hypchat.HypChat(token, endpoint=api_url)
self._reactives = []
self._non_reactives = []
def add_reactive(self, reactive):
"""Add a reactive plugin (function) to this hipbot. E.g.
```
def shutup(room, message, bot, hipchat):
if random.random() > 0.9:
message.from.mess... | code_fim | hard | {
"lang": "python",
"repo": "d0c-s4vage/hipbot",
"path": "/hipbot/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bot.add_non_reactive(read_this)
```
"""
self._non_reactives.append(non_reactive)
def run(self):
"""Run the hipbot
"""
self._running.set()
self.rooms = self._fetch_room_infos(*self._room_names)
self._fetch_users()
if self._username in self._user_map:
self.user = self._user_map[se... | code_fim | hard | {
"lang": "python",
"repo": "d0c-s4vage/hipbot",
"path": "/hipbot/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: d0c-s4vage/hipbot path: /hipbot/__init__.py
#!/usr/bin/env python
# encoding: utf-8
import datetime
import dateutil.parser
import hypchat
import logging
import os
import pytz
import sys
import time
import threading
logging.basicConfig(level=logging.INFO)
class Hipbot(object):
"""A bot for hi... | code_fim | hard | {
"lang": "python",
"repo": "d0c-s4vage/hipbot",
"path": "/hipbot/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: damarobe/MDPI path: /2018_Initial/MDPI_maps.py
# This script generates maps for collaborations during the entire time period
# Importing required modules
import numpy as np
import pandas as pd
import geopandas as gpd
import networkx as nx
import matplotlib.pyplot as plt
cm = plt.get_cmap('tab20... | code_fim | hard | {
"lang": "python",
"repo": "damarobe/MDPI",
"path": "/2018_Initial/MDPI_maps.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.figure()
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[(world.pop_est > 0) & (world.name != 'Antarctica')]
base = world.plot(color = 'white', edgecolor = 'black')
rwidths = [rdata.values[i][j] for i in range(6) for j in range(i,6)]
rwidths = [15 * width / max(rwidth... | code_fim | hard | {
"lang": "python",
"repo": "damarobe/MDPI",
"path": "/2018_Initial/MDPI_maps.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rpoliselit/python-for-dummies path: /class/cls_005.py
# Python 3.5+
# Type hinting for cls_002.py
class Book:
TYPES = ('paperback','hardcover')
def __init__(self, title: str, cover_type: str, paper_weight: int):
self.title = title
self.cover_type = cover_type
sel... | code_fim | hard | {
"lang": "python",
"repo": "rpoliselit/python-for-dummies",
"path": "/class/cls_005.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def hardcover(cls, title: str, paper_weight: int) -> "Book":
return cls(title, cls.TYPES[1], paper_weight + 100)<|fim_prefix|># repo: rpoliselit/python-for-dummies path: /class/cls_005.py
# Python 3.5+
# Type hinting for cls_002.py
class Book:
TYPES = ('paperback','hardc... | code_fim | hard | {
"lang": "python",
"repo": "rpoliselit/python-for-dummies",
"path": "/class/cls_005.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.title = title
self.cover_type = cover_type
self.paper_weight = paper_weight
def __repr__(self) -> str:
return f"< Book {self.title}, {self.cover_type}, weighting {self.paper_weight}g >"
@classmethod
def paperback(cls, title: str, paper_weight: int) -> "Bo... | code_fim | medium | {
"lang": "python",
"repo": "rpoliselit/python-for-dummies",
"path": "/class/cls_005.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthelliwell2/grammer path: /lib/text.py
import re
specialCharacterTranslations = {
"?\\question-mark": "?",
":\\colon": ":",
";\\semicolon": ";",
"*\\asterisk": "*",
"~\\tilde": "~",
",\\comma": ",",
".\\period": ".",
".\\dot": ".",
"/\\slash": "/",
"_\<... | code_fim | hard | {
"lang": "python",
"repo": "matthelliwell2/grammer",
"path": "/lib/text.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "--\\dash": "-",
"\x96\\dash": "-",
"-\\hyphen": "-",
"\"\\right-double-quote": "\"",
"\"\\left-double-quote": "\"",
}
specialCharacterTranslationsRe = re.compile('|'.join(re.escape(key) for key in specialCharacterTranslations.keys()))<|fim_prefix|># repo: matthelliwell2/grammer path: ... | code_fim | hard | {
"lang": "python",
"repo": "matthelliwell2/grammer",
"path": "/lib/text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paraVerifier/paraVerifier path: /server/simpserv/server.py
#coding=utf-8
import socket
def echo(conn, addr):
<|fim_suffix|> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
while Tru... | code_fim | medium | {
"lang": "python",
"repo": "paraVerifier/paraVerifier",
"path": "/server/simpserv/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def start_server(host, port, serv=echo, timeout=5):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
while True:
conn, addr = s.accept()
conn.settimeout(timeout)
serv(c... | code_fim | medium | {
"lang": "python",
"repo": "paraVerifier/paraVerifier",
"path": "/server/simpserv/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Get all neighbors (edges) of a vertex.
"""
return self.vertices[vertex_id]
def bft(self, starting_vertex):
"""
Print each vertex in breadth-first order
beginning from starting_vertex.
"""
# create an empty queue and enqueue t... | code_fim | hard | {
"lang": "python",
"repo": "Jazeera-Tul-Kunz/Jazeera-backend",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jazeera-Tul-Kunz/Jazeera-backend path: /utils.py
# class Graph():
# def __init__(self):
# self.vertices = {}
# def add_vertice(self, vertex_id):
# self.vertices[vertex_id] = {'n': '?', 's': '?', 'w': '?', 'e': '?'}
# def add_edge(self, v1, v2):
# if v1 in self.... | code_fim | hard | {
"lang": "python",
"repo": "Jazeera-Tul-Kunz/Jazeera-backend",
"path": "/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create an empty Queue
queue = Queue()
#push the starting vertex ID as list
queue.enqueue([starting_vertex])
# create an empty Set to store the visited vertices
visited = set()
# while the queue is not empty ...
while queue.size() > 0:
... | code_fim | hard | {
"lang": "python",
"repo": "Jazeera-Tul-Kunz/Jazeera-backend",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> series = Series(periods)
assert series[0].period_id == 21
assert series[0].start_hour == 10
assert series[2] != series[1]
assert series[2] == series[3]
assert series.dtype == 'nem_settlement_period'
def test_type_declaration():
"""String name of the DType can be used to insta... | code_fim | hard | {
"lang": "python",
"repo": "ample-tech/electric-units",
"path": "/tests/test_pandas_nem_settlement_period.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ample-tech/electric-units path: /tests/test_pandas_nem_settlement_period.py
"""Are the units usable within pandas."""
from pandas import DataFrame, Series
from electric_units.pandas_compat import NemSettlementPeriodArray
def test_pandas_entension():
"""Can you built a series with the settl... | code_fim | hard | {
"lang": "python",
"repo": "ample-tech/electric-units",
"path": "/tests/test_pandas_nem_settlement_period.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Can you built a series with the settlement period."""
periods = NemSettlementPeriodArray([
'2019-01-01T10:00:00',
'2019-01-01T11:00:00',
'2019-01-01T12:00:00',
'2019-01-01T12:10:00',
])
series = Series(periods)
assert series[0].period_id == 21
as... | code_fim | medium | {
"lang": "python",
"repo": "ample-tech/electric-units",
"path": "/tests/test_pandas_nem_settlement_period.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._compress(kind, mode, name, caller, True)
def _compress_normal(self, kind, mode, name, caller):
return self._compress(kind, mode, name, caller, False)
def _compress(self, kind, mode, name, caller, forced):
mode = mode or compress.OUTPUT_FILE
original_c... | code_fim | hard | {
"lang": "python",
"repo": "django-compressor/django-compressor",
"path": "/compressor/contrib/jinja2ext.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: django-compressor/django-compressor path: /compressor/contrib/jinja2ext.py
from jinja2 import nodes
from jinja2.ext import Extension
from jinja2.exceptions import TemplateSyntaxError
from compressor.templatetags import compress
# Allow django like definitions which assume constants instead of ... | code_fim | hard | {
"lang": "python",
"repo": "django-compressor/django-compressor",
"path": "/compressor/contrib/jinja2ext.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 16vishalsharma/software path: /system_check/syscheck_selftest.py
import os
from test import vehicle, level, Test, ARTEMIS, APOLLO, WARN, ERR
# Syscheck self-tests, so meta
@vehicle(APOLLO)
class IsApollo(Test):
def is_apollo():
return "apollo" == os.getenv("CUAUV_VEHICLE")
clas... | code_fim | medium | {
"lang": "python",
"repo": "16vishalsharma/software",
"path": "/system_check/syscheck_selftest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "artemis" == os.getenv("CUAUV_VEHICLE")
class IsArtemis(Test):
def is_artemis():
return "artemis" == os.getenv("CUAUV_VEHICLE")
@vehicle(APOLLO)
class IsApollo(Test):
def is_apollo():
return "apollo" == os.getenv("CUAUV_VEHICLE")<|fim_pr... | code_fim | hard | {
"lang": "python",
"repo": "16vishalsharma/software",
"path": "/system_check/syscheck_selftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @vehicle(APOLLO)
class IsApollo(Test):
def is_apollo():
return "apollo" == os.getenv("CUAUV_VEHICLE")<|fim_prefix|># repo: 16vishalsharma/software path: /system_check/syscheck_selftest.py
import os
from test import vehicle, level, Test, ARTEMIS, APOLLO, WARN, ERR
# Syscheck ... | code_fim | medium | {
"lang": "python",
"repo": "16vishalsharma/software",
"path": "/system_check/syscheck_selftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asaladino/calc-ml path: /src/helpers/helper_classifier.py
from random import seed
from random import randint
from numpy import array
from math import ceil
from math import log10
from numpy import argmax
seed(1)
def random_sum_pairs(n_examples, largest):
X, y = list(), list()
for i in r... | code_fim | hard | {
"lang": "python",
"repo": "asaladino/calc-ml",
"path": "/src/helpers/helper_classifier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# one hot encode
def one_hot_encode(X, y, max_int):
Xenc = list()
for seq in X:
pattern = list()
for index in seq:
vector = [0 for _ in range(max_int)]
vector[index] = 1
pattern.append(vector)
Xenc.append(pattern)
yenc = list()
f... | code_fim | hard | {
"lang": "python",
"repo": "asaladino/calc-ml",
"path": "/src/helpers/helper_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Xenc = list()
for seq in X:
pattern = list()
for index in seq:
vector = [0 for _ in range(max_int)]
vector[index] = 1
pattern.append(vector)
Xenc.append(pattern)
yenc = list()
for seq in y:
pattern = list()
for ind... | code_fim | hard | {
"lang": "python",
"repo": "asaladino/calc-ml",
"path": "/src/helpers/helper_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_context_data(self, app_name):
app = CloudApp.objects.get(name = app_name)
users = AppUser.objects.filter(app = app)
userlist = [user.user for user in users]
return {'users' : userlist, 'app_name': app_name}<|fim_prefix|># repo: Sighillrob/CloudEngine path: /clo... | code_fim | easy | {
"lang": "python",
"repo": "Sighillrob/CloudEngine",
"path": "/cloudengine/users/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sighillrob/CloudEngine path: /cloudengine/users/views.py
from django.views.generic import TemplateView
from cloudengine.core.models import CloudApp
from cloudengine.users.models import AppUser
<|fim_suffix|> template_name= "app_users.html"
def get_context_data(self, app_name):
... | code_fim | easy | {
"lang": "python",
"repo": "Sighillrob/CloudEngine",
"path": "/cloudengine/users/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>speed = 100
def travel():
spaceship.forward(speed)
wn.ontimer(travel, 10)
wn.onkey(lambda: spaceship.setheading(90), 'Up')
wn.onkey(lambda: spaceship.setheading(180), 'Left')
wn.onkey(lambda: spaceship.setheading(0), 'Right')
wn.onkey(lambda: spaceship.setheading(270), 'Down')
wn.listen()
trav... | code_fim | medium | {
"lang": "python",
"repo": "omer21-meet/meet2019y1lab1",
"path": "/Day6/try.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: omer21-meet/meet2019y1lab1 path: /Day6/try.py
from turtle import Turtle, Screen
wn = Screen()
wn.bgcolor('lightblue')
spaceship = Turtle()
spaceship.color('red')
spaceship.pendown()
speed = 100
<|fim_suffix|> spaceship.forward(speed)
wn.ontimer(travel, 10)
wn.onkey(lambda: spaceship.s... | code_fim | easy | {
"lang": "python",
"repo": "omer21-meet/meet2019y1lab1",
"path": "/Day6/try.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>wn.onkey(lambda: spaceship.setheading(90), 'Up')
wn.onkey(lambda: spaceship.setheading(180), 'Left')
wn.onkey(lambda: spaceship.setheading(0), 'Right')
wn.onkey(lambda: spaceship.setheading(270), 'Down')
wn.listen()
travel()
wn.mainloop()<|fim_prefix|># repo: omer21-meet/meet2019y1lab1 path: /Day6/try... | code_fim | medium | {
"lang": "python",
"repo": "omer21-meet/meet2019y1lab1",
"path": "/Day6/try.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shoggothforever/fashionpedia-api path: /fashionpedia/fp_eval.py
Rng)
numDets = len(p.maxDets)
numImgs = len(p.imgIds)
# -1 for absent categories
precision = - np.ones(
(numIous, numF1s, numRecalls, numCats, numAreaRngs, numDets)
)
recal... | code_fim | hard | {
"lang": "python",
"repo": "shoggothforever/fashionpedia-api",
"path": "/fashionpedia/fp_eval.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def accumulate(self, p=None, fpParams=None):
'''
Accumulate per image evaluation results,
and store the result in self.evaluate
'''
print('Accumulating evaluation results...')
tic = time.time()
if not self.evalImgs:
print('Please run... | code_fim | hard | {
"lang": "python",
"repo": "shoggothforever/fashionpedia-api",
"path": "/fashionpedia/fp_eval.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shoggothforever/fashionpedia-api path: /fashionpedia/fp_eval.py
= min([iouThr, 1 - 1e-10])
m = -1
f1 = min([f1Thr, 1 - 1e-10])
for gtIdx, _ in enumerate(gt):
# if this gt already matched, and not a crowd, continu... | code_fim | hard | {
"lang": "python",
"repo": "shoggothforever/fashionpedia-api",
"path": "/fashionpedia/fp_eval.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> tail_frame_rate=250) -> Experiment2P:
"""
Performs the intial analysis (file collection and segmentation) on the experiment identified by the info file
:param info_file_name: The path and name of the info-file identifying the experiment
:param scope_name: Identifier ... | code_fim | hard | {
"lang": "python",
"repo": "haesemeyer/imaging_pipeline",
"path": "/imaging_pipeline/analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haesemeyer/imaging_pipeline path: /imaging_pipeline/analysis.py
# Copyright (c) 2021. Martin Haesemeyer. All rights reserved.
#
# Licensced under the MIT license. See LICENSE
"""
Functions for Caiman based analysis into experiment classes
"""
from experiment import Experiment2P
from utilities... | code_fim | hard | {
"lang": "python",
"repo": "haesemeyer/imaging_pipeline",
"path": "/imaging_pipeline/analysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> exp.mcorr_dicts.append(params["Motion Correction"])
exp.projections.append(np.mean(images, 0))
stack = np.array(images)
stack -= np.min(stack)
stack[stack > 255] = 255
stack = stack.astype(np.uint8)
exp.func_stacks.append(stack)
if eparser.is... | code_fim | hard | {
"lang": "python",
"repo": "haesemeyer/imaging_pipeline",
"path": "/imaging_pipeline/analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Both errors subclass
:exc:`~ftrack_api.exception.IncorrectResultError` if you want to
catch only one error type.
'''
expression = self._expression
if self._limit is not None:
raise ValueError(
'Expression already con... | code_fim | hard | {
"lang": "python",
"repo": "jrsndl/pype-setup",
"path": "/vendor/python/ftrack-python-api/ftrack_api/query.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jrsndl/pype-setup path: /vendor/python/ftrack-python-api/ftrack_api/query.py
# :coding: utf-8
# :copyright: Copyright (c) 2014 ftrack
import re
import collections
import ftrack_api.exception
class QueryResult(collections.Sequence):
'''Results from a query.'''
OFFSET_EXPRESSION = re.c... | code_fim | hard | {
"lang": "python",
"repo": "jrsndl/pype-setup",
"path": "/vendor/python/ftrack-python-api/ftrack_api/query.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
"test_data",
[
(Scrapli, "system", "ScrapliNetworkDriverWithMethods"),
(AsyncScrapli, "asyncssh", "AsyncScrapliNetworkDriverWithMethods"),
],
ids=["sync_factory", "async_factory"],
)
def test_factory_community_platform_variant_driver_type(test_data... | code_fim | hard | {
"lang": "python",
"repo": "GDGSNF/scrapli",
"path": "/tests/unit/test_factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GDGSNF/scrapli path: /tests/unit/test_factory.py
import importlib
import pytest
from scrapli.driver import AsyncNetworkDriver, NetworkDriver
from scrapli.driver.core import (
AsyncEOSDriver,
AsyncIOSXEDriver,
AsyncIOSXRDriver,
AsyncJunosDriver,
AsyncNXOSDriver,
EOSDriver... | code_fim | hard | {
"lang": "python",
"repo": "GDGSNF/scrapli",
"path": "/tests/unit/test_factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def outRowCaled(self, xlsfile1,sheetname,数据类型,类型标记):
cellsDta =""
# cellsDta += xlsfile1.getCell( "Regular","String", self.row.__class__.__name__.replace("Cls",类型标记) )
# cellsDta += xlsfile1.getCell( "Regular","String", DateStrReg( self.row.get发生日期() ) )
# cells... | code_fim | hard | {
"lang": "python",
"repo": "wangzhongtian/ConTractMngToolSrc",
"path": "/ipycode/账务处理Lib.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangzhongtian/ConTractMngToolSrc path: /ipycode/账务处理Lib.py
#-*- coding: UTF8
from __future__ import print_function
# import pickle
import basicDataProc
from basicDataProcHT import *
from basicDataProcFY import *
from basicDataProcXJ import *
from basicDataProcFP import *
import shutil
... | code_fim | hard | {
"lang": "python",
"repo": "wangzhongtian/ConTractMngToolSrc",
"path": "/ipycode/账务处理Lib.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if "额" == k[-1:] or "率" == k[-1:] :
typeStr = "Number"
# v1 =
else:
typeStr = "String"
cellsDta += xlsfile1.getCell( "Regular",typeStr,v1)
# if "后期维保" in v1 :
# print( ";;"+... | code_fim | hard | {
"lang": "python",
"repo": "wangzhongtian/ConTractMngToolSrc",
"path": "/ipycode/账务处理Lib.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
_EXTENSION_TYPE = "MobileServer"
@property
def capabilities(self):
"""Gets or sets a list of capabilities (as defined by the self.Capabilities enumerator)
that are enabled for this extension.
:type: list(self.Capabilities)
"""
return None
@capabi... | code_fim | medium | {
"lang": "python",
"repo": "dcworldwide/arcpyext",
"path": "/arcpyext/publishing/_mobile_server_extension.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class MobileServerExtension(SDDraftExtension):
_EXTENSION_TYPE = "MobileServer"
@property
def capabilities(self):
"""Gets or sets a list of capabilities (as defined by the self.Capabilities enumerator)
that are enabled for this extension.
:type: list(self.Capabiliti... | code_fim | medium | {
"lang": "python",
"repo": "dcworldwide/arcpyext",
"path": "/arcpyext/publishing/_mobile_server_extension.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dcworldwide/arcpyext path: /arcpyext/publishing/_mobile_server_extension.py
from __future__ import (absolute_import, division, print_function, unicode_literals)
from builtins import (ascii, bytes, chr, dict, filter, hex, input, int, map, next, oct, open, pow,
range, round, s... | code_fim | medium | {
"lang": "python",
"repo": "dcworldwide/arcpyext",
"path": "/arcpyext/publishing/_mobile_server_extension.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def objective_function_test(self, x):
return self.objective_function(x)<|fim_prefix|># repo: mrenoon/datafreezethaw path: /RoBO/robo/task/synthetic_functions/levy.py
'''
Created on 12.07.2015
@author: Aaron Klein
'''
import numpy as np
from robo.task.base_task import BaseTask
class Levy(B... | code_fim | hard | {
"lang": "python",
"repo": "mrenoon/datafreezethaw",
"path": "/RoBO/robo/task/synthetic_functions/levy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self):
X_lower = np.array([-15])
X_upper = np.array([10])
opt = np.array([[1.0]])
fopt = 0.0
super(Levy, self).__init__(X_lower, X_upper, opt=opt, fopt=fopt)
def objective_function(self, x):
z = 1 + ((x - 1.) / 4.)
s = np.power... | code_fim | medium | {
"lang": "python",
"repo": "mrenoon/datafreezethaw",
"path": "/RoBO/robo/task/synthetic_functions/levy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mrenoon/datafreezethaw path: /RoBO/robo/task/synthetic_functions/levy.py
'''
Created on 12.07.2015
@author: Aaron Klein
'''
import numpy as np
<|fim_suffix|> return y
def objective_function_test(self, x):
return self.objective_function(x)<|fim_middle|>from robo.task.base_tas... | code_fim | hard | {
"lang": "python",
"repo": "mrenoon/datafreezethaw",
"path": "/RoBO/robo/task/synthetic_functions/levy.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: voicevon/gogame_bot path: /python/robot_eye/cell_scanner.py
import cv2
import numpy
import sys
import time
sys.path.append('/home/xm/gitrepo/gogame_bot/python')
from app_global.color_print import CONST
from app_global.gogame_config import app_config
class CellScanner():
def __init__(self,... | code_fim | hard | {
"lang": "python",
"repo": "voicevon/gogame_bot",
"path": "/python/robot_eye/cell_scanner.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # detect circles
gray = cv2.cvtColor(cropped_img, cv2.COLOR_BGR2GRAY)
blur = cv2.medianBlur(gray,3)
canny = cv2.Canny(gray,100,200)
circles = cv2.HoughCircles(blur, method=cv2.HOUGH_GRADIENT, dp=1, minDist= 1,
minRadius=8, maxRad... | code_fim | hard | {
"lang": "python",
"repo": "voicevon/gogame_bot",
"path": "/python/robot_eye/cell_scanner.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Wait for two in a seperate thread so we do not block forever if this test
# fails.
def wait_for_two():
client.acquire(two, "A", block_for=timedelta(seconds=0.5))
t = Thread(target=wait_for_two)
t.start()
# Three seconds should be ampl... | code_fim | hard | {
"lang": "python",
"repo": "iCodeIN/throttle",
"path": "/python_client/tests/test_server_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iCodeIN/throttle path: /python_client/tests/test_server_client.py
"""
Integration test of basic server functionality and validation that the `Client` uses the correct
Http routes.
"""
from datetime import timedelta
from threading import Thread
from time import sleep
import pytest # ty... | code_fim | hard | {
"lang": "python",
"repo": "iCodeIN/throttle",
"path": "/python_client/tests/test_server_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: demisto/content path: /Packs/Censys/Integrations/Censys/Censys.py
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
''' IMPORTS '''
import requests
''' GLOBAL VARIABLES '''
API_URL = demisto.params()['url']
API_ID = demisto.params()['apiid']
API_SECRET =... | code_fim | medium | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/Censys/Integrations/Censys/Censys.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def censys_view_command():
args = demisto.args()
query = args.get('query')
index = args.get('index')
url_suffix = 'view/{0}/{1}'.format(index, query)
raw = send_request('GET', url_suffix)
if raw:
demisto.results(raw)
else:
demisto.results("No view results for {... | code_fim | hard | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/Censys/Integrations/Censys/Censys.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: muhammad-masood-ur-rehman/Skillrack path: /Python Programs/longest-substring-with-a-and-b-count.py
Longest Substring with a and b count
Longest Substring with a and b count: A string S containing only the characters a and b is passed as the input. The program must print the length L of the longe... | code_fim | hard | {
"lang": "python",
"repo": "muhammad-masood-ur-rehman/Skillrack",
"path": "/Python Programs/longest-substring-with-a-and-b-count.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>S.
Output Format:
The first line contains the L.
Example Input/Output 1:
Input:
abaabba
Output:
6
Example Input/Output 2:
Input:
aaabaaabbbaaab
Output:
8
def stringLen(str):
m = dict()
m[0] = -1
ca = 0
cb = 0
res = 0
for ele in range(len(str)):
if str[ele] == 'a':
ca += 1
else:
cb += ... | code_fim | hard | {
"lang": "python",
"repo": "muhammad-masood-ur-rehman/Skillrack",
"path": "/Python Programs/longest-substring-with-a-and-b-count.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def is_yaml(self):
return True if self.get_ext() in ['.yml', '.yaml'] else False
def loading_strategy(self):
"""Load file into json object"""
try:
if not self.file_allowed():
raise Exception('File type {} is not allowed'.format(self.get_ext()))
... | code_fim | hard | {
"lang": "python",
"repo": "geeknam/lmdo",
"path": "/lmdo/file_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geeknam/lmdo path: /lmdo/file_loader.py
import os
import json
import yaml
from lmdo.oprint import Oprint
class FileLoader(object):
"""
Loading content from yml, json, template files
and convert them into json object
It can only be used at the top of ChainProcessor,
can not... | code_fim | hard | {
"lang": "python",
"repo": "geeknam/lmdo",
"path": "/lmdo/file_loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> max_offsets = 1
for node_id, tps in leader_tp.iteritems():
# Construct the OffsetRequest
request = OffsetRequest[0](
replica_id=-1,
topics=[
(topic, [
(partition, OffsetResetStrategy.LATEST,... | code_fim | hard | {
"lang": "python",
"repo": "serverdensity/sd-agent-core-plugins",
"path": "/kafka_consumer/check.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: serverdensity/sd-agent-core-plugins path: /kafka_consumer/check.py
= None
cli = self._get_kafka_client(instance)
cli._maybe_refresh_metadata()
kafka_version = self._get_kafka_version(cli)
if get_kafka_consumer_offsets:
# For now, consumer groups are ma... | code_fim | hard | {
"lang": "python",
"repo": "serverdensity/sd-agent-core-plugins",
"path": "/kafka_consumer/check.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.gauge('kafka.consumer_lag', consumer_lag, tags=consumer_group_tags)
def _get_zk_path_children(self, zk_conn, zk_path, name_for_error):
"""Fetch child nodes for a given Zookeeper path."""
children = []
try:
children = zk_conn.get_children(zk_path)
... | code_fim | hard | {
"lang": "python",
"repo": "serverdensity/sd-agent-core-plugins",
"path": "/kafka_consumer/check.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>from bpp.migration_util import load_custom_sql
class Migration(migrations.Migration):
dependencies = [
("rozbieznosci_dyscyplin", "0007_recreate"),
("bpp", "0265_rekord_mat_doi"),
]
operations = [
migrations.RunPython(
lambda *args, **kw: load_custom_sql... | code_fim | easy | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/rozbieznosci_dyscyplin/migrations/0008_recreate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
("rozbieznosci_dyscyplin", "0007_recreate"),
("bpp", "0265_rekord_mat_doi"),
]
operations = [
migrations.RunPython(
lambda *args, **kw: load_custom_sql(
"0002_rok_2017_i_wyzej", app_na... | code_fim | medium | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/rozbieznosci_dyscyplin/migrations/0008_recreate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iplweb/bpp path: /src/rozbieznosci_dyscyplin/migrations/0008_recreate.py
# Generated by Django 3.0.14 on 2021-05-03 22:14
from django.db import migrations
from bpp.migration_util import load_custom_sql
<|fim_suffix|> operations = [
migrations.RunPython(
lambda *args, **k... | code_fim | medium | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/rozbieznosci_dyscyplin/migrations/0008_recreate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pwildenhain/terminal_playing_cards path: /terminal_playing_cards/deck.py
"""Create a class for a deck of playing cards"""
# See terminal_playing_cards/view.py for why these are disabled
# pylint: disable=missing-docstring
# pylint: disable=bad-continuation
from typing import Union
from random im... | code_fim | hard | {
"lang": "python",
"repo": "pwildenhain/terminal_playing_cards",
"path": "/terminal_playing_cards/deck.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Sort a collection of Cards in place according to a given sort order.
Defaults to sorting by Card value ascending and Card suit by
clubs, diamonds, spades, and then hearts.
Args:
sort_order: Specify whether to sort by value, suit, or
both. If bot... | code_fim | hard | {
"lang": "python",
"repo": "pwildenhain/terminal_playing_cards",
"path": "/terminal_playing_cards/deck.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tensorflow/tensorrt path: /tftrt/benchmarking-python/benchmark_utils.py
#!/usr/bin/env python
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# -*- coding: utf-8 -*-
import json
import time
import numpy as np
from contextlib import contextmanager
import tensorflow a... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/tensorrt",
"path": "/tftrt/benchmarking-python/benchmark_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._predicted = dict()
self._expected = dict()
self._total_samples_processed = 0
self._postprocess_model_outputs_fn = postprocess_model_outputs_fn
def _calc_step_batchsize(self, data_arr):
if isinstance(data_arr, (list, tuple)):
return data_arr[... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/tensorrt",
"path": "/tftrt/benchmarking-python/benchmark_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiscoUcs/ucsmsdk path: /ucsmsdk/mometa/storage/StorageEnclosureCap.py
"""This module contains the general information for StorageEnclosureCap ManagedObject."""
from ...ucsmo import ManagedObject
from ...ucscoremeta import MoPropertyMeta, MoMeta
from ...ucsmeta import VersionMeta
class StorageE... | code_fim | hard | {
"lang": "python",
"repo": "CiscoUcs/ucsmsdk",
"path": "/ucsmsdk/mometa/storage/StorageEnclosureCap.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, parent_mo_or_dn, type, **kwargs):
self._dirty_mask = 0
self.type = type
self.child_action = None
self.descr = None
self.disk_base_id = None
self.disk_variant = None
self.id = None
self.num_slots = None
self.remo... | code_fim | hard | {
"lang": "python",
"repo": "CiscoUcs/ucsmsdk",
"path": "/ucsmsdk/mometa/storage/StorageEnclosureCap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
admin.site.register(GlobeeIPN, GlobeeIPNAdmin)<|fim_prefix|># repo: lovvskillz/django-globee path: /globee/admin.py
from django.contrib import admin
from globee.models import GlobeeIPN
<|fim_middle|>
class GlobeeIPNAdmin(admin.ModelAdmin):
list_display = ('payment_id', 'payment_status', 'total', '... | code_fim | hard | {
"lang": "python",
"repo": "lovvskillz/django-globee",
"path": "/globee/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lovvskillz/django-globee path: /globee/admin.py
from django.contrib import admin
from globee.models import GlobeeIPN
<|fim_suffix|> list_display = ('payment_id', 'payment_status', 'total', 'currency', 'custom_payment_id', 'created_at')
date_hierarchy = 'created_at'
search_fields = (... | code_fim | easy | {
"lang": "python",
"repo": "lovvskillz/django-globee",
"path": "/globee/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diwu1990/UnarySim path: /kernel/signabs.py
import torch
class FSUSignAbs(torch.nn.Module):
"""
This module
1) calculates the absolute value of bipolar bitstreams.
2) works for rate coding only.
3) records the entire bistream history with a counter to retreive the sign.
"... | code_fim | hard | {
"lang": "python",
"repo": "diwu1990/UnarySim",
"path": "/kernel/signabs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.depth = hwcfg["depth"]
self.stype = swcfg["stype"]
self.btype = swcfg["btype"]
self.buf_max = torch.nn.Parameter(torch.zeros(1).fill_(2**self.depth - 1).type(self.btype), requires_grad=False)
self.buf_half = torch.nn.Parameter(torch.zeros(1).fill_(2**(self.dept... | code_fim | medium | {
"lang": "python",
"repo": "diwu1990/UnarySim",
"path": "/kernel/signabs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(self, input):
# update the accumulator based on input: +1 for input 1; -1 for input 0
self.acc.data = self.acc.add(input.mul(2).sub(1).type(self.btype)).clamp(0, self.buf_max.item())
sign = torch.lt(self.acc, self.buf_half).type(torch.int8)
input_int8 = inpu... | code_fim | hard | {
"lang": "python",
"repo": "diwu1990/UnarySim",
"path": "/kernel/signabs.py",
"mode": "spm",
"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.