text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: SemaphoreSolutions/s4-clarity-lib path: /s4/clarity/iomaps.py
# Copyright 2016 Semaphore Solutions, Inc.
# ---------------------------------------------------------------------------
from collections import defaultdict
from ._internal import ClarityElement
class IOMapsMixin(ClarityElement):
... | code_fim | hard | {
"lang": "python",
"repo": "SemaphoreSolutions/s4-clarity-lib",
"path": "/s4/clarity/iomaps.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> artifact_type = output_node.get(self.IOMAPS_OUTPUT_TYPE_ATTRIBUTE)
generation_type = output_node.get("output-generation-type")
return input_artifact, output_artifact, artifact_type, generation_type
def iomaps_input_keyed(self):
"""
:return: a mapping of input... | code_fim | hard | {
"lang": "python",
"repo": "SemaphoreSolutions/s4-clarity-lib",
"path": "/s4/clarity/iomaps.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vstconsulting/vstutils path: /vstutils/api/schema/schema.py
import typing as _t
from copy import copy
from warnings import warn
from django.http import FileResponse
from rest_framework import status
from drf_yasg.inspectors.view import SwaggerAutoSchema
from drf_yasg.app_settings import swagger_... | code_fim | hard | {
"lang": "python",
"repo": "vstconsulting/vstutils",
"path": "/vstutils/api/schema/schema.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'x-list' in self.overrides:
return self.overrides['x-list']
action = getattr(self.view, 'action', '')
method = getattr(self.view, action, None) or self.method
detail = getattr(method, 'detail', None)
suffix = getattr(self.view, 'suffix', None)
... | code_fim | hard | {
"lang": "python",
"repo": "vstconsulting/vstutils",
"path": "/vstutils/api/schema/schema.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_creation_of_temporary_tiff_file(pdf_path):
"""PdfReader should create TIFF files in alphabetical order wrt. page num"""
pdf_reader = PdfReader(path=pdf_path)
tiff_directory = pdf_reader._tiff_directory()
tiff_files = [tiff_file.name for tiff_file in tiff_directory.iterdir()]
a... | code_fim | hard | {
"lang": "python",
"repo": "JakobGM/WikiLinks",
"path": "/examiner/tests/test_pdf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """PdfReader should create TIFF files in alphabetical order wrt. page num"""
pdf_reader = PdfReader(path=pdf_path)
tiff_directory = pdf_reader._tiff_directory()
tiff_files = [tiff_file.name for tiff_file in tiff_directory.iterdir()]
assert sorted(tiff_files) == ['0001.tif', '0002.tif']... | code_fim | hard | {
"lang": "python",
"repo": "JakobGM/WikiLinks",
"path": "/examiner/tests/test_pdf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JakobGM/WikiLinks path: /examiner/tests/test_pdf.py
from os import environ
from pathlib import Path
from examiner.pdf import PdfReader
import pytest
pytestmark = pytest.mark.skipif(
(
'TRAVIS' in environ or
environ.get('LC_ALL') != 'C' or
environ.get('PYTHONIOENCO... | code_fim | hard | {
"lang": "python",
"repo": "JakobGM/WikiLinks",
"path": "/examiner/tests/test_pdf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: artingc/umucv path: /code/hog/pedestrian.py
#!/usr/bin/env python
import cv2 as cv
import time
from umucv.util import putText
from umucv.stream import autoStream
hog = cv.HOGDescriptor()
hog.setSVMDetector(cv.HOGDescriptor_getDefaultPeopleDetector())
MULTISCALE = True
for key, image in autoSt... | code_fim | hard | {
"lang": "python",
"repo": "artingc/umucv",
"path": "/code/hog/pedestrian.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(rects) > 0:
for rect, p in zip(rects,weights.flatten()):
if MULTISCALE:
x,y,w,h = rect
else:
x,y = rect; w,h = 64,128
cv.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
p... | code_fim | hard | {
"lang": "python",
"repo": "artingc/umucv",
"path": "/code/hog/pedestrian.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: worldbank/GOST_PublicGoods path: /Urbanization/GOST_Urban/misc.py
import os, sys, time, math, subprocess, inspect, json, glob
import geopandas as gpd
import shapely
import fiona
import pyproj
import rasterio
import numpy
import ogr
from osgeo import osr
from collections import Counter
from mat... | code_fim | hard | {
"lang": "python",
"repo": "worldbank/GOST_PublicGoods",
"path": "/Urbanization/GOST_Urban/misc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # new envelope for next poly
ringYtop = ringYtop - gridHeight
ringYbottom = ringYbottom - gridHeight
# new envelope for next poly
ringXleftOrigin = ringXleftOrigin + gridWidth
ringXrightOrigin = ringXrightOrigin + gridWidth
# Close DataSour... | code_fim | hard | {
"lang": "python",
"repo": "worldbank/GOST_PublicGoods",
"path": "/Urbanization/GOST_Urban/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create output file
outDriver = ogr.GetDriverByName('ESRI Shapefile')
if os.path.exists(outputGridfn):
os.remove(outputGridfn)
outDataSource = outDriver.CreateDataSource(outputGridfn)
outLayer = outDataSource.CreateLayer(outputGridfn, testSR, geom_type=ogr.wkbPolygon )
fea... | code_fim | hard | {
"lang": "python",
"repo": "worldbank/GOST_PublicGoods",
"path": "/Urbanization/GOST_Urban/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: code4days/ACE path: /lib/saq/engine/test_cloudphish.py
# vim: sw=4:ts=4:et
import os, os.path
import logging
import json
import hashlib
import tarfile
import io
import tempfile
import shutil
from urllib.parse import urlencode
import saq, saq.test
from saq.cloudphish import *
from saq.database ... | code_fim | hard | {
"lang": "python",
"repo": "code4days/ACE",
"path": "/lib/saq/engine/test_cloudphish.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # wait for the request to complete
def condition():
result = self.client.post('/cloudphish/submit', data={
'url': url,
'r': 0,
'a': 0})
json_data = json.loads(result.get_data().decode())
return json_data['s... | code_fim | hard | {
"lang": "python",
"repo": "code4days/ACE",
"path": "/lib/saq/engine/test_cloudphish.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = self.client.get('/cloudphish/download?s={}'.format(json_data['sha256_content']))
self.assertEquals(result.status_code, 200)
# the hash of the content should match the sha256_content
h = hashlib.sha256()
h.update(result.get_data())
self.asse... | code_fim | hard | {
"lang": "python",
"repo": "code4days/ACE",
"path": "/lib/saq/engine/test_cloudphish.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> data:
x_max -> the highest x index of the diles covering the bb
x_min -> the lowest "" "" ""
y_max -> the highest y index of the diles covering the bb
y_min -> the lowest "" "" ""
XSIZE -> the size of the x axis of a single dile grid
YSIZE -> "" "" "" "" y "" "" "" ""
anal... | code_fim | hard | {
"lang": "python",
"repo": "RDCEP/hybrid-dile-server",
"path": "/lib/utils/gridmaker.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RDCEP/hybrid-dile-server path: /lib/utils/gridmaker.py
from diles.netcdfgeometry import NetcdfGeometry
from gridfile import GridFile
from misc import ncOpen
from netCDF4 import *
class GridMaker(object):
"""
Class that regrids a netcdf file generic latlon grid into
a uniform grid... | code_fim | hard | {
"lang": "python",
"repo": "RDCEP/hybrid-dile-server",
"path": "/lib/utils/gridmaker.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
explanation of the size formula:
problem:
retrive how many diles cover a certain bounding box
then create a grid that represent the diles merged
in one grid
data:
x_max -> the highest x index of the diles covering the bb
x_min -> the lowest "" "" ""
y_max -> the highest y... | code_fim | hard | {
"lang": "python",
"repo": "RDCEP/hybrid-dile-server",
"path": "/lib/utils/gridmaker.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> bdd = cudd.BDD()
names = ['a', 'b', 'c']
for var in names:
bdd.add_var(var)
fname = 'sample0.txt'
u = bdd.load(fname)
n = len(u)
assert n == 5, n
s = '~ ( (a /\ (b \/ c)) \/ (~ a /\ (b \/ ~ c)) )'
u_ = bdd.add_expr(s)
assert u == u_, (u, u_)
def test_and_e... | code_fim | hard | {
"lang": "python",
"repo": "krooken/dd",
"path": "/tests/cudd_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_apply():
bdd = cudd.BDD()
for var in ['x', 'y', 'z']:
bdd.add_var(var)
x = bdd.var('x')
y = bdd.var('y')
z = bdd.var('z')
# (x \/ ~ x) \equiv TRUE
not_x = bdd.apply('not', x)
true = bdd.apply('or', x, not_x)
assert true == bdd.true, true
# x /\ ~ x... | code_fim | hard | {
"lang": "python",
"repo": "krooken/dd",
"path": "/tests/cudd_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: krooken/dd path: /tests/cudd_test.py
_var():
bdd = cudd.BDD()
level = 0
j = bdd.insert_var('x', level)
assert j == 0, j # initially indices = levels
x = bdd.var_at_level(level)
assert x == 'x', x
level = 101
bdd.insert_var('y', level)
y = bdd.var_at_level(leve... | code_fim | hard | {
"lang": "python",
"repo": "krooken/dd",
"path": "/tests/cudd_test.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Prashant-JT/PartitionProblem path: /Practica3PR3/PYTHON/PartitionProblemBruteForceIterator/IteratorCombinaciones.py
class IteratorCombinaciones:
def __init__(self, N):
self.valorMaximo = 1
self.valorMinimo = 0
self.combination = []
for i in range(N):
... | code_fim | hard | {
"lang": "python",
"repo": "Prashant-JT/PartitionProblem",
"path": "/Practica3PR3/PYTHON/PartitionProblemBruteForceIterator/IteratorCombinaciones.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> actualSum=0
for i in range(0, len(num)):
if self.combination[i] == 1:
actualSum= actualSum + num[i]
if actualSum == previousSum:
return True<|fim_prefix|># repo: Prashant-JT/PartitionProblem path: /Practica3PR3/PYTHON/PartitionProblemBruteFo... | code_fim | hard | {
"lang": "python",
"repo": "Prashant-JT/PartitionProblem",
"path": "/Practica3PR3/PYTHON/PartitionProblemBruteForceIterator/IteratorCombinaciones.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pdhborges/advent-of-code path: /2017/9.py
from collections import namedtuple, deque
Group = namedtuple('Group', ['groups', 'gc'])
def read(filename):
with open(filename) as f:
return deque(f.read().strip())
def skip_garbage(stream):
assert stream[0] == '<'
stream.popleft()
... | code_fim | medium | {
"lang": "python",
"repo": "pdhborges/advent-of-code",
"path": "/2017/9.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def score(group, level = 1):
return level + sum(score(g, level + 1) for g in group.groups)
def garbage_count(group):
return group.gc + sum(garbage_count(g) for g in group.groups)
groups = parse_group(read('input-9.txt'))
print(score(groups))
print(garbage_count(groups))<|fim_prefix|># repo: pdhb... | code_fim | hard | {
"lang": "python",
"repo": "pdhborges/advent-of-code",
"path": "/2017/9.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> except Planner.DoesNotExist:
raise PermissionDenied
else:
raise PermissionDenied
wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap
def gerent_required(function):
def wrap(request, *args, **kwargs):
if re... | code_fim | hard | {
"lang": "python",
"repo": "Geiade/trainwellProject",
"path": "/trainWellApp/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.user.is_authenticated:
try:
planner = Planner.objects.get(user=request.user)
if planner.is_gerent is True:
return function(request, *args, **kwargs)
else:
raise PermissionDenied
... | code_fim | hard | {
"lang": "python",
"repo": "Geiade/trainwellProject",
"path": "/trainWellApp/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Geiade/trainwellProject path: /trainWellApp/decorators.py
from django.core.exceptions import PermissionDenied
from trainWellApp.models import Planner
def staff_required(function):
def wrap(request, *args, **kwargs):
if request.user.is_authenticated:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "Geiade/trainwellProject",
"path": "/trainWellApp/decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZechyW/cs-toolkit path: /packages/django-backend/frontend/handlers/api.py
"""
Handles `api` topic PubSub connections.
Lets clients perform REST API operations over a channel.
"""
import logging
from django.conf import settings
from rest_framework.test import APIClient
from frontend.handlers.bas... | code_fim | hard | {
"lang": "python",
"repo": "ZechyW/cs-toolkit",
"path": "/packages/django-backend/frontend/handlers/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def handle(self, content):
"""
Received some content with topic `api`.
Process it via our test APIClient and return the results.
https://stackoverflow.com/questions/4576290/can-django-test-client
-be-used-for-api-calls-in-production
:param content:
... | code_fim | hard | {
"lang": "python",
"repo": "ZechyW/cs-toolkit",
"path": "/packages/django-backend/frontend/handlers/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pySin/protein_level_measurement path: /empty_to_null.py
# Change the empty string values to NULL in MySQL
import mysql.connector
import re
def get_col_names(table_name):
# Get the table columns names. A string has to be constructed that looks
# exactly like SQL query. This query ... | code_fim | hard | {
"lang": "python",
"repo": "pySin/protein_level_measurement",
"path": "/empty_to_null.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> conn = mysql.connector.connect(host = 'localhost', user = 'root',
password = 'dance') # MySQL connection
cursor = conn.cursor()
cursor.execute(send_query)
conn.commit()<|fim_prefix|># repo: pySin/protein_level_measurement path: /empty... | code_fim | hard | {
"lang": "python",
"repo": "pySin/protein_level_measurement",
"path": "/empty_to_null.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: piacortes/apero-utils path: /old_code/INTROOT/SpirouDRS/spirouUnitTests/spirouUnitRecipes.py
uments
args = get_args(p, name, rname, inputs, arg_names, arg_types)
return args, name
def unit_test_cal_dark_spirou(p, rname, inputs):
"""
cal_DARK_spirou
input = night_name files... | code_fim | hard | {
"lang": "python",
"repo": "piacortes/apero-utils",
"path": "/old_code/INTROOT/SpirouDRS/spirouUnitTests/spirouUnitRecipes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: piacortes/apero-utils path: /old_code/INTROOT/SpirouDRS/spirouUnitTests/spirouUnitRecipes.py
types = [str, str, str]
# get arguments
args = get_args(p, name, rname, inputs, arg_names, arg_types)
return args, name
def unit_test_cal_dark_spirou(p, rname, inputs):
"""
cal_DAR... | code_fim | hard | {
"lang": "python",
"repo": "piacortes/apero-utils",
"path": "/old_code/INTROOT/SpirouDRS/spirouUnitTests/spirouUnitRecipes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param rname: string, identifier for this run
:param inputs: list of objects, raw parameters to pass to run, if outputs
is None returns parameters to pass to file
:return args: dict, the parameters to pass to the run
"""
# define name and arguments
name = 'cal_D... | code_fim | hard | {
"lang": "python",
"repo": "piacortes/apero-utils",
"path": "/old_code/INTROOT/SpirouDRS/spirouUnitTests/spirouUnitRecipes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Asher-W/Image-Steganography-Tool path: /steg-tool/shared_functions.py
# convert a supplied string to a usable integer
def string_to_num(str : str):
return sum([ord(str[index]) for index in range(len(str))])
def xor(n1, n2):
# remove the 0b string from the beggining of the binary string
... | code_fim | hard | {
"lang": "python",
"repo": "Asher-W/Image-Steganography-Tool",
"path": "/steg-tool/shared_functions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return return_num
# take in a seed base and top to give a semi-random number
def get_sudo_random(seed, base, top):
seed, base, top = int(seed), int(base), int(top) # make sure inputs are the proper format
return_num = xor(xor(seed, top) ** 3, base)
return (((return_num ** 2 + ba... | code_fim | hard | {
"lang": "python",
"repo": "Asher-W/Image-Steganography-Tool",
"path": "/steg-tool/shared_functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return_num = sum([int(value) * (2 ** index) for index, value in enumerate(return_num)])
return return_num
# take in a seed base and top to give a semi-random number
def get_sudo_random(seed, base, top):
seed, base, top = int(seed), int(base), int(top) # make sure inputs are the proper format... | code_fim | hard | {
"lang": "python",
"repo": "Asher-W/Image-Steganography-Tool",
"path": "/steg-tool/shared_functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if get_order_sign(text) in range(97, 123):
return "".join([chr(i) for i in range(ord("a"), ord("a")+26)])
elif get_order_sign(text) in range(1072, 1104):
return "".join([chr(i) for i in range(ord("а"), ord("а")+32)])
def encode(text: str, shift: int, decode=False) -> str:... | code_fim | medium | {
"lang": "python",
"repo": "ilyaLihota/Homework",
"path": "/5/ceaser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ilyaLihota/Homework path: /5/ceaser.py
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-
"""Ceaser's code."""
def check_the_shift(shift: int) -> int:
if ALPHABET != None and shift > len(ALPHABET):
return shift % len(ALPHABET)
return shift
def create_alphabet(text: str) -... | code_fim | medium | {
"lang": "python",
"repo": "ilyaLihota/Homework",
"path": "/5/ceaser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # JSON create
logging.debug('6. create_json()')
msg_pose = create_json(json_pose, json_hand)
# JSON submit
logging.debug('7. send_json()')
send_json(socket, msg_pose)
time.sleep(1.0/rate)
logging.info(' ###### LOOP ######')
while True:
loop_proc()
util_time_profili... | code_fim | hard | {
"lang": "python",
"repo": "leaf918/jetson_virtual_touchpanel",
"path": "/test/test_pose_pub.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leaf918/jetson_virtual_touchpanel path: /test/test_pose_pub.py
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
#
# 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
#
# ht... | code_fim | hard | {
"lang": "python",
"repo": "leaf918/jetson_virtual_touchpanel",
"path": "/test/test_pose_pub.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for idx, dtype in enumerate(dtypes):
nvrtc_kernel_str = nvrtc_kernel_str.replace(
"{%d}" % idx, dtype_strs[idx]
)
kernel_name = f"""{uuid1()
if kernel_name is None
else kernel_name}_{
"".join(dtype_str... | code_fim | hard | {
"lang": "python",
"repo": "rapidsai/cuml",
"path": "/python/cuml/common/kernel_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@functools.lru_cache(maxsize=5000)
def cuda_kernel_factory(nvrtc_kernel_str, dtypes, kernel_name=None):
"""
A factory wrapper function to perform some of the boiler-plate involved in
making cuPy RawKernels type-agnostic.
Until a better method is created, either by RAPIDS or cuPy, this fun... | code_fim | hard | {
"lang": "python",
"repo": "rapidsai/cuml",
"path": "/python/cuml/common/kernel_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rapidsai/cuml path: /python/cuml/common/kernel_utils.py
#
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
#
# 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://... | code_fim | hard | {
"lang": "python",
"repo": "rapidsai/cuml",
"path": "/python/cuml/common/kernel_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #--------------------------------------------------------------------------
# "UpAction" interface:
#--------------------------------------------------------------------------
window = Instance(WorkbenchWindow)
#-----------------------------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "rwl/puddle",
"path": "/puddle/resource/action/up_action.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rwl/puddle path: /puddle/resource/action/up_action.py
#------------------------------------------------------------------------------
# Copyright (C) 2009 Richard W. Lincoln
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated docume... | code_fim | hard | {
"lang": "python",
"repo": "rwl/puddle",
"path": "/puddle/resource/action/up_action.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def perform(self, event):
""" Perform the action.
"""
# Note that we always offer the service via its name, but look it up
# via the actual protocol.
from puddle.resource.i_workspace import IWorkspace
workspace = self.window.application.get_service(IWor... | code_fim | hard | {
"lang": "python",
"repo": "rwl/puddle",
"path": "/puddle/resource/action/up_action.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # flatten and encode
enc_buf = self.dec_buf[buf_id]
data_arr = []
for k in __decode_order__:
if k in enc_buf:
v = enc_buf[k]
data_list = np.ravel(v)
total_number = np.product(v.shape)
data_arr.appen... | code_fim | hard | {
"lang": "python",
"repo": "0x00-pl/kendryte-model-compiler",
"path": "/model_loader/darknet/D2T_lib/darknet_tool.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 0x00-pl/kendryte-model-compiler path: /model_loader/darknet/D2T_lib/darknet_tool.py
from struct import unpack, pack
import numpy as np
from . import bwidth
from . import net
# C-types
__unpack_types__ = {
'float32': 'f',
'float64': 'd',
'float': 'f',
'double': 'd',
'int8': '... | code_fim | hard | {
"lang": "python",
"repo": "0x00-pl/kendryte-model-compiler",
"path": "/model_loader/darknet/D2T_lib/darknet_tool.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cfg_file=None, weights_file=None,
dtype='float32'):
global __count_darknet__
self.name = name if name else 'darknet_%i' % (__count_darknet__)
__count_darknet__ += 1
# virtual network structure
self.net = net.net(name=self.name, dty... | code_fim | hard | {
"lang": "python",
"repo": "0x00-pl/kendryte-model-compiler",
"path": "/model_loader/darknet/D2T_lib/darknet_tool.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prajitdhar/Compounding path: /src/pickle_file_combiner.py
import pandas as pd
import glob
import os
import numpy as np
import pickle as pkl
import time
from fastparquet import write
import fastparquet
import multiprocessing as mp
import snappy
import argparse
import multiprocessing as mp
from mul... | code_fim | hard | {
"lang": "python",
"repo": "prajitdhar/Compounding",
"path": "/src/pickle_file_combiner.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if type(df_list)==str:
df_list=[df_list]
concat_list=[]
for cur_file in df_list:
#print(row.fname)
cur_df=pd.read_pickle(cur_file)
concat_list.append(cur_df)
concat_df=pd.concat(concat_list,ignore_index=True,sort=True)
total_df_shape=concat_df.shape[0]
... | code_fim | hard | {
"lang": "python",
"repo": "prajitdhar/Compounding",
"path": "/src/pickle_file_combiner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hakimkhalafi/linkedin-scraper path: /src/profile_sourcer.py
#!/usr/bin/python
import os
import json
import time
import requests
import traceback
import pandas as pd
from src.core import config
def scrape_search_results(search_string, cookies, headers):
# Fetch the initial page to get result... | code_fim | hard | {
"lang": "python",
"repo": "hakimkhalafi/linkedin-scraper",
"path": "/src/profile_sourcer.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> url = page_url % (config['search_results']
['results_per_page'],
search_string,
p*config['search_results']
['results_per_page'])
r = requests.get(url, cookies=cookies, headers=headers)
... | code_fim | hard | {
"lang": "python",
"repo": "hakimkhalafi/linkedin-scraper",
"path": "/src/profile_sourcer.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>ot(111)
# ax.plot(uc.ms_scale(), data, 'k-')
#
# # decorate axes
# ax.set_yticklabels([])
# ax.set_title("Protein 1D FID")
# ax.set_xlabel("Time (ms)")
# ax.set_ylim(-100000, 100000)
#
# # save the figure
# fig.savefig("fid.png") # this can be to .pdf, .ps, etc<|fim_prefix|># repo: JieHao/nmrML path: /... | code_fim | hard | {
"lang": "python",
"repo": "JieHao/nmrML",
"path": "/tools/Parser_and_Converters/python/var2timepng.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JieHao/nmrML path: /tools/Parser_and_Converters/python/var2timepng.py
import nmrglue as ng
import matplotlib.pyplot as plt
import numpy as np
import pylab
dic,data = ng.varian.read("sucrosesample_varian/")
dic,data = ng.pipe_proc.ft(dic,data,auto=True)
pylab.plot(data)
pylab.savefig("plot_1d.png... | code_fim | hard | {
"lang": "python",
"repo": "JieHao/nmrML",
"path": "/tools/Parser_and_Converters/python/var2timepng.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fschlimb/scale-out-benchs path: /mortgage/mortgage_modin.py
# Derived from https://github.com/rapidsai/notebooks-extended/tree/master/intermediate_notebooks/E2E/mortgage
import numpy as np
import modin.pandas as pd
from pandas.api.types import CategoricalDtype
from collections import OrderedDict... | code_fim | hard | {
"lang": "python",
"repo": "fschlimb/scale-out-benchs",
"path": "/mortgage/mortgage_modin.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_ever_features(pdf, **kwargs):
everdf = pdf[['loan_id', 'current_loan_delinquency_status']]
everdf = everdf.groupby('loan_id').max()
del(pdf)
everdf['ever_30'] = (everdf['current_loan_delinquency_status'] >= 1).astype('int8')
everdf['ever_90'] = (everdf['current_loan_delinque... | code_fim | hard | {
"lang": "python",
"repo": "fschlimb/scale-out-benchs",
"path": "/mortgage/mortgage_modin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: colegrigsby/think-cell path: /examples/complex-example.py
from thinkcell import Thinkcell
chart_1 = {
"categories": ["Employees", "Revenue", "Other"],
"chart_name": "Chart1",
"data": [["Apple", 200, 1.5, 10], ["Amazon", 100, 1.0, 12], ["Slack", 50, 0.5, 16]],
}
<|fim_suffix|>templa... | code_fim | hard | {
"lang": "python",
"repo": "colegrigsby/think-cell",
"path": "/examples/complex-example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>charts = [chart_1, chart_2, chart_3]
template_name = "complex-template.pptx"
filename = "complex-example.ppttc"
tc = Thinkcell()
tc.add_template(template_name)
for chart in charts:
tc.add_chart(
template_name=template_name,
chart_name=chart["chart_name"],
categories=chart["ca... | code_fim | medium | {
"lang": "python",
"repo": "colegrigsby/think-cell",
"path": "/examples/complex-example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acs-um/ServiciosProfesionales path: /servicios_profesionales/servicios/migrations/0022_merge_20180615_1407.py
# Generated by Django 2.0.5 on 2018-06-15 14:07
from django.db import migrations
<|fim_suffix|>
dependencies = [
('servicios', '0020_service_user'),
('servicios', '... | code_fim | easy | {
"lang": "python",
"repo": "acs-um/ServiciosProfesionales",
"path": "/servicios_profesionales/servicios/migrations/0022_merge_20180615_1407.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('servicios', '0020_service_user'),
('servicios', '0021_auto_20180611_2151'),
]
operations = [
]<|fim_prefix|># repo: acs-um/ServiciosProfesionales path: /servicios_profesionales/servicios/migrations/0022_merge_20180615_1407.py
# Generated by Django 2.0.5... | code_fim | easy | {
"lang": "python",
"repo": "acs-um/ServiciosProfesionales",
"path": "/servicios_profesionales/servicios/migrations/0022_merge_20180615_1407.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('servicios', '0020_service_user'),
('servicios', '0021_auto_20180611_2151'),
]
operations = [
]<|fim_prefix|># repo: acs-um/ServiciosProfesionales path: /servicios_profesionales/servicios/migrations/0022_merge_201... | code_fim | easy | {
"lang": "python",
"repo": "acs-um/ServiciosProfesionales",
"path": "/servicios_profesionales/servicios/migrations/0022_merge_20180615_1407.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>RT_ERR_CONNECTIVITY_TEST = "Connectivity test failed"
RT_SUCC_CONNECTIVITY_TEST = "Connectivity test passed"
RT_ERR_CREATE_TICKET_FAILED = "Ticket creation failed"
RT_ERR_LIST_TICKETS_FAILED = "Failed to get ticket listing"
RT_ERR_LOGIN_FAILED = "Login to RT server failed. Text from device '{status}'"
RT_... | code_fim | medium | {
"lang": "python",
"repo": "phantomcyber/phantom-apps",
"path": "/Apps/phrequesttracker/requesttracker_consts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phantomcyber/phantom-apps path: /Apps/phrequesttracker/requesttracker_consts.py
# File: rt_consts.py
# Copyright (c) 2021 Splunk Inc.
RT_JSON_DEVICE_URL = "device_url"
RT_JSON_PRIORITY = "priority"
RT_JSON_ID = "id"
RT_JSON_ATTACHMENT = "attachment_id"
RT_JSON_VAULT = "vault_id"
RT_JSON_QUEUE ... | code_fim | medium | {
"lang": "python",
"repo": "phantomcyber/phantom-apps",
"path": "/Apps/phrequesttracker/requesttracker_consts.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gatita/django-imager path: /imagersite/imager_images/models.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.db import models
from django.contrib.auth.models import User
CHOICES = (
('public', 'public... | code_fim | hard | {
"lang": "python",
"repo": "gatita/django-imager",
"path": "/imagersite/imager_images/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "{} - Photo by {}".format(self.title, self.user.username)
@python_2_unicode_compatible
class Album(models.Model):
user = models.ForeignKey(
User,
related_name='albums',
null=False
)
photos = models.ManyToManyField(
Photo,
related_name='a... | code_fim | hard | {
"lang": "python",
"repo": "gatita/django-imager",
"path": "/imagersite/imager_images/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "{} - Album by {}".format(self.title, self.user.username)
@python_2_unicode_compatible
class Face(models.Model):
photo = models.ForeignKey(
Photo,
related_name='faces',
null=False
)
name = models.CharField(max_length=255)
x = models.IntegerField()
... | code_fim | hard | {
"lang": "python",
"repo": "gatita/django-imager",
"path": "/imagersite/imager_images/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # And we want the configure_ap_tx_power api to be mocked to raise an
# exception when called. This simulates the fail case.
self.device.configure = Mock(side_effect=Exception)
# We expect this step to fail so make sure it raises the signal
with self.assertRais... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genielibs",
"path": "/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/c9800/tests/test_rrm_dca_channel.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiscoTestAutomation/genielibs path: /pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/c9800/tests/test_rrm_dca_channel.py
import logging
import unittest
from unittest.mock import Mock, MagicMock
from genie.libs.clean.stages.iosxe.c9800.stages import ConfigureRrmDcaChannel
from genie.li... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genielibs",
"path": "/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/c9800/tests/test_rrm_dca_channel.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prasadpriyesh1/MLOps_proj path: /feeds/views.py
from django.shortcuts import render,reverse
from django.http import HttpResponse,StreamingHttpResponse,HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.contrib import m... | code_fim | hard | {
"lang": "python",
"repo": "prasadpriyesh1/MLOps_proj",
"path": "/feeds/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while True:
frame=camera.run_on_video(conf_thresh=0.5,video_path=0)
yield(b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')<|fim_prefix|># repo: prasadpriyesh1/MLOps_proj path: /feeds/views.py
from django.shortcuts import render,reverse
from djan... | code_fim | hard | {
"lang": "python",
"repo": "prasadpriyesh1/MLOps_proj",
"path": "/feeds/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SICKAG/sick_lidar_localization path: /test/rest_server/python/lls_udp_sender.py
le endian (default) or big endian.
def createHeader(msg_type, msg_type_version, payload_length, big_endian):
payload = bytearray(16) # header has always 16 byte
payload[0:4] = b"\x... | code_fim | hard | {
"lang": "python",
"repo": "SICKAG/sick_lidar_localization",
"path": "/test/rest_server/python/lls_udp_sender.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> message = bytearray(40) # line measurement messages (type 4, version 4) have always 40 byte
message[0:16] = createHeader(4, 4, 24, big_endian) # type 4, version 4, 40 byte payload
message[16:24] = encode(telegram_count, 8, big_endian) # 8 byte Telegr... | code_fim | hard | {
"lang": "python",
"repo": "SICKAG/sick_lidar_localization",
"path": "/test/rest_server/python/lls_udp_sender.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SICKAG/sick_lidar_localization path: /test/rest_server/python/lls_udp_sender.py
e, length, big_endian = False):
payload = bytearray(length)
if big_endian:
for n in range(0,length):
payload[n] = ((value >> 8*(length - n - 1)) & 0xFF)
else:
for n in range(0,... | code_fim | hard | {
"lang": "python",
"repo": "SICKAG/sick_lidar_localization",
"path": "/test/rest_server/python/lls_udp_sender.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Diss Hirschvogel eq. 2.101
return (K*(t-c1)+1.)*((K*(t-c1)+1.)>0.) - K*(t-c1)*((K*(t-c1))>0.) - K*(t-c2)*((K*(t-c2))>0.) + (K*(t-c2)-1.)*((K*(t-c2)-1.)>0.)
BC_DICT = { 'dirichlet' : [{'dir' : '2dimZ', 'val' : 0.}],
'neumann' : [{'typ... | code_fim | hard | {
"lang": "python",
"repo": "dbaroli/ambit",
"path": "/testing/solid_2Dheart_frankstarling.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dbaroli/ambit path: /testing/solid_2Dheart_frankstarling.py
#!/usr/bin/env python3
### 2D biventricular generic heart, testing of:
# - Mooney-Rivlin material
# - active stress with Frank-Starling law
# - Robin BC in normal direction (spring)
import ambit
import sys, traceback
import numpy as n... | code_fim | hard | {
"lang": "python",
"repo": "dbaroli/ambit",
"path": "/testing/solid_2Dheart_frankstarling.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: natemwilson/PsyNeuLink path: /PsyNeuLink/Components/System.py
for projection in output_state.sendsToProjections)
for output_state in sender_mech.outputStates.values())):
try:
if sender_mech.systems[self] is ORIGIN:
... | code_fim | hard | {
"lang": "python",
"repo": "natemwilson/PsyNeuLink",
"path": "/PsyNeuLink/Components/System.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
prefs : PreferenceSet or specification dict : System.classPreferences
the `PreferenceSet` for system.
Specified in the `prefs` argument of the constructor for the system; if it is not specified, a default is
assigned using `classPreferences` defined in __init__.py
(se... | code_fim | hard | {
"lang": "python",
"repo": "natemwilson/PsyNeuLink",
"path": "/PsyNeuLink/Components/System.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: natemwilson/PsyNeuLink path: /PsyNeuLink/Components/System.py
system. During each phase of execution, only the mechanisms assigned to
that phase are executed. Mechanisms are assigned a phase where they are listed in the `pathway` of a
`process <Process>`. When a mechanism is executed, it rece... | code_fim | hard | {
"lang": "python",
"repo": "natemwilson/PsyNeuLink",
"path": "/PsyNeuLink/Components/System.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARM-software/patrace path: /patrace/src/fakedriver/autogencode.py
= os.path.join(os.path.dirname(os.path.realpath(__file__)), folder)
filename = os.path.join(dirname, fname)
keys = list(protos.keys())
keys.sort()
if not os.path.exists(dirname):
os.makedirs(dirname)
... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/patrace",
"path": "/patrace/src/fakedriver/autogencode.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> keys = list(protos.keys())
keys.sort()
with open(filename, "w") as f:
f.write('// This code is auto-generated by: \n')
f.write('// '+pythonCmd+'\n')
f.write('#include "os_string.hpp"\n')
f.write('#include "gleslayer_helper.h"\n')
f.write('std::unorder... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/patrace",
"path": "/patrace/src/fakedriver/autogencode.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARM-software/patrace path: /patrace/src/fakedriver/autogencode.py
')}
for param in command.findall('param')]
for param in p:
splitted = []
for string in param['strlist']:
for word in string.split():
splitted.append(w... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/patrace",
"path": "/patrace/src/fakedriver/autogencode.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= c
c, selectors[index] = selectors[index] >> 1, selectors[index] & 1
index += 1
return result
if __name__ == "__main__":
print(Solution().subsets([1, 2, 4]))<|fim_prefix|># repo: Satily/leetcode_python_solution path: /solutions/solution78.py
class Solution:
... | code_fim | hard | {
"lang": "python",
"repo": "Satily/leetcode_python_solution",
"path": "/solutions/solution78.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Satily/leetcode_python_solution path: /solutions/solution78.py
class Solution:
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
result = []
ln = len(nums)
selectors = [0] * ln
<|fim_suffix|> result_item.app... | code_fim | hard | {
"lang": "python",
"repo": "Satily/leetcode_python_solution",
"path": "/solutions/solution78.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result_item.append(nums[index])
result.append(result_item)
# Add selectors
index, c = 0, 1
while c == 1 and index < ln:
selectors[index] += c
c, selectors[index] = selectors[index] >> 1, selectors[index] & 1
... | code_fim | hard | {
"lang": "python",
"repo": "Satily/leetcode_python_solution",
"path": "/solutions/solution78.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ajit2704/sunpy path: /sunpy/visualization/tests/test_mapcubeanimator.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import os
import matplotlib.pyplot as plt
import pytest
import sunpy.map
from sunpy.visualization import mapcubeanimator
from sunpy.data import test
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "ajit2704/sunpy",
"path": "/sunpy/visualization/tests/test_mapcubeanimator.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert map_animator.timer is None
assert map_animator.active_slider == 0
assert map_animator.button_func == []
assert map_animator.remove_obj == []
def test_updatefig(map_animator):
t = map_animator.updatefig(0, map_animator.im, 10)
assert t is None
def test_plot_start_image(m... | code_fim | hard | {
"lang": "python",
"repo": "ajit2704/sunpy",
"path": "/sunpy/visualization/tests/test_mapcubeanimator.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lord-Doubi/MDX_Spin_Local path: /MDX_codes/picturemanipulation.py
import cv2
import numpy as np
import os
def readimg(x,locations,flag):
if flag == 1:
return cv2.imread(os.path.join(locations,'%d.png'%(x)))
else:
return cv2.imread(os.path.join(locations,'%dBackg... | code_fim | hard | {
"lang": "python",
"repo": "Lord-Doubi/MDX_Spin_Local",
"path": "/MDX_codes/picturemanipulation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> img = cv2.imread(os.path.join(locations,'%dSubtract.png'%(x)))
## imgs = cv2.imread('testSubtracted.png',0)
imgs = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(imgs,(17,17),0)
ret,th = cv2.threshhold(blur,100,255,cv2.THRESH_TOZERO)
cv2.imwrite(os.path.join(loca... | code_fim | hard | {
"lang": "python",
"repo": "Lord-Doubi/MDX_Spin_Local",
"path": "/MDX_codes/picturemanipulation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
passports = []
inp = [l.strip() for l in sys.stdin]
inp.append('')
cur = []
for l in inp:
if len(l) == 0:
passports.append(cur)
cur = []
continue
r = re.findall(r"(\w+):(\S+)", l)
for kv in r:
... | code_fim | hard | {
"lang": "python",
"repo": "zed-b/advent-of-code",
"path": "/2020/src/day04.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zed-b/advent-of-code path: /2020/src/day04.py
import sys, re
fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
def solve1(passports):
ans = 0
for p in passports:
cur = set()
for kv in p:
if (kv[0] in fields):
cur.add(kv[0])
if... | code_fim | hard | {
"lang": "python",
"repo": "zed-b/advent-of-code",
"path": "/2020/src/day04.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: albertmil97/django_AlbertMIliano path: /blog/api/views.py
from rest_framework import generics, mixins, permissions
from ..models import Post
from .serializers import PostSerializer, UserSerializer
from django.contrib.auth import get_user_model
from .permissions import IsAuthhorOrReadOnly
from dja... | code_fim | hard | {
"lang": "python",
"repo": "albertmil97/django_AlbertMIliano",
"path": "/blog/api/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># class PostDetailView(mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, generics.GenericAPIView):
# queryset = Post.objects.all()
# serializer_class = PostSerializer
# def get(self, request, *args, **kwargs):
# return self.retrieve(request, *args, **kw... | code_fim | hard | {
"lang": "python",
"repo": "albertmil97/django_AlbertMIliano",
"path": "/blog/api/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trim21-archive/pol path: /tests/app/test_md_2_bbc.py
from starlette.testclient import TestClient
import app.fast
import app.md2bbc
client = TestClient(app.fast.app)
<|fim_suffix|> response = client.get("/md2bbc")
assert response.status_code == 200
assert "text/html" in response.hea... | code_fim | easy | {
"lang": "python",
"repo": "trim21-archive/pol",
"path": "/tests/app/test_md_2_bbc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = client.get("/md2bbc")
assert response.status_code == 200
assert "text/html" in response.headers["content-type"]<|fim_prefix|># repo: trim21-archive/pol path: /tests/app/test_md_2_bbc.py
from starlette.testclient import TestClient
<|fim_middle|>import app.fast
import app.md2bbc
cl... | code_fim | medium | {
"lang": "python",
"repo": "trim21-archive/pol",
"path": "/tests/app/test_md_2_bbc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ziweifan177/Data-Science-Knowledge-Base path: /DataScience/python/PythonThread.py
import threading
#1. threading foundation:
def test():
print('threading.active_count():',threading.active_count()) # Current threading number.
print('threading.enumerate():',threading.enumerate())#What... | code_fim | hard | {
"lang": "python",
"repo": "ziweifan177/Data-Science-Knowledge-Base",
"path": "/DataScience/python/PythonThread.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def job2():
global A,lock
lock.acquire()
for i in range(10):
A+=10
print('Job2:',A)
lock.release()
print("\n5. Thread-Lock:")
lock=threading.Lock()
A=0
thread1=threading.Thread(target=job1)
thread2=threading.Thread(target=job2)
thread1.start()
thread1.join()
... | code_fim | hard | {
"lang": "python",
"repo": "ziweifan177/Data-Science-Knowledge-Base",
"path": "/DataScience/python/PythonThread.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Set synchronizer object
if synchronizer:
self.synchronizer = synchronizer
else:
self.synchronizer = self.get_parent().get_synchronizer()
def __getitem__(self, item):
""" Container get-item method can be used to access a specific child object "... | code_fim | hard | {
"lang": "python",
"repo": "rioksusanto/CanvasSync",
"path": "/CanvasSync/local_entities/local_canvas_entity.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.