text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: DreamRiverForever/M2det-Keras path: /test.py
from nets.M2det import m2det
model = <|fim_suffix|>s)):
print(i,model.layers[i].name)<|fim_middle|>m2det(21,None, name='m2det')
model.summary()
for i in range(len(model.layer | code_fim | medium | {
"lang": "python",
"repo": "DreamRiverForever/M2det-Keras",
"path": "/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yottabytt/atlas path: /atlas/foundations_rest_api/src/test/v2beta/models/test_artifact_listing.py
from foundations_spec import *
import json
from foundations_rest_api.v2beta.models.artifact_listing import artifact_listing_for_job
class TestArtifactListing(Spec):
@let
def job_id(self):... | code_fim | hard | {
"lang": "python",
"repo": "yottabytt/atlas",
"path": "/atlas/foundations_rest_api/src/test/v2beta/models/test_artifact_listing.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> artifact_metadata_0 = self._artifact_metadata()
artifact_metadata_1 = self._artifact_metadata()
artifact_metadata_2 = self._artifact_metadata()
metadata_in_redis = {
'key_mapping': {
artifact_name_1: 'filename_1',
artifact_name_0:... | code_fim | hard | {
"lang": "python",
"repo": "yottabytt/atlas",
"path": "/atlas/foundations_rest_api/src/test/v2beta/models/test_artifact_listing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().setUp()
def test_field_cleaning(self):
"""
Tests that the specifications for the SANDBOX_QUERY and CLEAN_PPI_NUMERIC_FIELDS_QUERY
perform as designed.
Validates pre conditions, tests execution, and post conditions based on the load
statements a... | code_fim | hard | {
"lang": "python",
"repo": "nishanthpp93/curation",
"path": "/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/deid/ct_pid_rid_map_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> map_query = self.jinja_env.from_string("""
INSERT INTO `{{fq_table}}`
(person_id,research_id,shift)
VALUES
(1234, 234, 256),
(5678, 678, 250),
(2345, 345, 255),
(6789, 789, 256)""").render(fq_table=self.fq_deid_map_table)
... | code_fim | hard | {
"lang": "python",
"repo": "nishanthpp93/curation",
"path": "/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/deid/ct_pid_rid_map_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nishanthpp93/curation path: /tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/deid/ct_pid_rid_map_test.py
# Python Imports
import os
from datetime import datetime
# Project Imports
from app_identity import PROJECT_ID
import cdr_cleaner.cleaning_rules.deid.ct_pid_rid_map as cr
from... | code_fim | hard | {
"lang": "python",
"repo": "nishanthpp93/curation",
"path": "/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/deid/ct_pid_rid_map_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
with open('input.txt', 'r') as f:
image = f.read().splitlines()[0]
print(part1(image))
print(part2(image, 25, 6))<|fim_prefix|># repo: alfphaderp/advent-of-code-2019 path: /src/day8/solution.py
def part1(image):
layers = []
for i in range(0, len(imag... | code_fim | hard | {
"lang": "python",
"repo": "alfphaderp/advent-of-code-2019",
"path": "/src/day8/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alfphaderp/advent-of-code-2019 path: /src/day8/solution.py
def part1(image):
layers = []
for i in range(0, len(image), 25 * 6):
layers.append(image[i:i + 25 * 6])
minZ, minZLayer = 1e99, []
for l in layers:
if l.count("0") < minZ:
minZLayer = l
... | code_fim | hard | {
"lang": "python",
"repo": "alfphaderp/advent-of-code-2019",
"path": "/src/day8/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> layers = []
for i in range(0, len(image), r * c):
rows = []
for j in range(0, r * c, r):
rows.append(image[i + j:i + j + r])
layers.append(rows)
print(layers)
final = []
for i in range(c):
row = []
for j in range(r):
... | code_fim | medium | {
"lang": "python",
"repo": "alfphaderp/advent-of-code-2019",
"path": "/src/day8/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eduardoimagno/materias-programacao path: /materias de programaçao/Algoritmo e estrutura de dados ipg/PROGRAMAÇÃO/Aula05+-+Instruções+iterativas-20191225/examples/ex8Leibniz.py
# Approximating the value of PI/4 using the Leibniz formula.
# JMM 2019
import math
<|fim_suffix|># Prints the values o... | code_fim | hard | {
"lang": "python",
"repo": "eduardoimagno/materias-programacao",
"path": "/materias de programaçao/Algoritmo e estrutura de dados ipg/PROGRAMAÇÃO/Aula05+-+Instruções+iterativas-20191225/examples/ex8Leibniz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Prints the header of the results table
print("{:>8s} {:>12s} {:>12s}".format("N", "sum", "error"))
print("-"*8, "-"*12, "-"*12)
# Prints the values of the approximation of PI/4 for
# N = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]
for exp in range(0, 8):
num = 10**exp
total = LeibnizS... | code_fim | medium | {
"lang": "python",
"repo": "eduardoimagno/materias-programacao",
"path": "/materias de programaçao/Algoritmo e estrutura de dados ipg/PROGRAMAÇÃO/Aula05+-+Instruções+iterativas-20191225/examples/ex8Leibniz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Current file path: {}".format(scene.get_file_path()))
maya_engine_scene = os.path.join(os.path.join(os.environ["USERPROFILE"]), "Desktop", "test.ma")
print("Save at: {}".format(maya_engine_scene))
scene.save(maya_engine_scene)
print("Open {}".format(maya_engine_scene))
scene.open(maya_engine_scene)... | code_fim | medium | {
"lang": "python",
"repo": "Soulayrol/Pipeline",
"path": "/packages/artfx/actionLib/tests/maya_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Uninitialized maya standalone ...")
maya.standalone.uninitialize()
sys.exit(0)<|fim_prefix|># repo: Soulayrol/Pipeline path: /packages/artfx/actionLib/tests/maya_test.py
import os
import sys
import maya.standalone
print("=" * 30)
print("TEST SCRIPT MAYA")
print("=" * 30)
<|fim_middle|>print("In... | code_fim | hard | {
"lang": "python",
"repo": "Soulayrol/Pipeline",
"path": "/packages/artfx/actionLib/tests/maya_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Soulayrol/Pipeline path: /packages/artfx/actionLib/tests/maya_test.py
import os
import sys
import maya.standalone
print("=" * 30)
print("TEST SCRIPT MAYA")
print("=" * 30)
print("Initializing maya standalone ...")
maya.standalone.initialize(name="python")
<|fim_suffix|>print("Uninitialized ma... | code_fim | hard | {
"lang": "python",
"repo": "Soulayrol/Pipeline",
"path": "/packages/artfx/actionLib/tests/maya_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fagan2888/simpy-fsm path: /examples/2-process-interaction/old.py
import simpy
class Car(object):
def __init__(self, env):
self.env = env
self.action = env.process(self.run())
def run(self):
while True:
print('Car: Start parking and charging at %d' % s... | code_fim | medium | {
"lang": "python",
"repo": "fagan2888/simpy-fsm",
"path": "/examples/2-process-interaction/old.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
env = simpy.Environment()
car = Car(env)
env.process(driver(env, car))
env.run(until=15)<|fim_prefix|># repo: fagan2888/simpy-fsm path: /examples/2-process-interaction/old.py
import simpy
class Car(object):
def __init__(self, env):
self.env = env
... | code_fim | medium | {
"lang": "python",
"repo": "fagan2888/simpy-fsm",
"path": "/examples/2-process-interaction/old.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Test_Node(NodeBase):
"""
"""
title = 'test'
type_ = 'modulefinder'
init_inputs = [
]
init_outputs = [
NodeOutputBP(type_='data'),
]
color = '#32DA22'
def update_event(self, inp=-1):
self.set_output_val(0, modulefinder.test())
... | code_fim | hard | {
"lang": "python",
"repo": "AbhirupGhosh92/Breeze",
"path": "/Ryven/packages/auto_generated/modulefinder/nodes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class _Find_Module_Node(NodeBase):
"""
An importlib reimplementation of imp.find_module (for our purposes)."""
title = '_find_module'
type_ = 'modulefinder'
init_inputs = [
NodeInputBP(label='name'),
NodeInputBP(label='path', dtype=dtypes.Data(default=None, size='... | code_fim | hard | {
"lang": "python",
"repo": "AbhirupGhosh92/Breeze",
"path": "/Ryven/packages/auto_generated/modulefinder/nodes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AbhirupGhosh92/Breeze path: /Ryven/packages/auto_generated/modulefinder/nodes.py
from NENV import *
import modulefinder
class NodeBase(Node):
pass
class Addpackagepath_Node(NodeBase):
"""
"""
title = 'AddPackagePath'
type_ = 'modulefinder'
init_inputs = [
... | code_fim | hard | {
"lang": "python",
"repo": "AbhirupGhosh92/Breeze",
"path": "/Ryven/packages/auto_generated/modulefinder/nodes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>setuptools.setup(
name="circuitbreaker",
description="Circuit breaker pattern implemenation to protect systems from external failures",
author="Russell Gunther",
url="https://github.com/rgunther30/circuitbreaker",
version=get_version(),
package_dir={'': 'circuitbreaker'},
py_mo... | code_fim | medium | {
"lang": "python",
"repo": "oogway/circuitbreaker",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oogway/circuitbreaker path: /setup.py
#!/usr/bin/env python
# Copyright (c) 2016 Russell Gunther
# For license information, see the LICENSE file
# I'd like to thank Bryan Worrell for directing me in creating a proper python
# package and for inspiring me to list this on pypi. Also for generally b... | code_fim | medium | {
"lang": "python",
"repo": "oogway/circuitbreaker",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def normalize(version):
return version.split()[-1].strip("\"'")
def get_version():
with open(VERSION_FILE) as f:
version = next(line for line in f if line.startswith("__version__"))
return normalize(version)
setuptools.setup(
name="circuitbreaker",
description="Circuit ... | code_fim | medium | {
"lang": "python",
"repo": "oogway/circuitbreaker",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jooner/Channing path: /channing/prep.py
import re
import string
import numpy as np
import torch
import torch.nn as nn
from stop_words import get_stop_words
from contraction_list import conlst
emb_dim = 50
window = 2
with open('../data/glove.6B.50d.txt', 'r') as f:
glove = f.readlines()
... | code_fim | hard | {
"lang": "python",
"repo": "jooner/Channing",
"path": "/channing/prep.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def check(tokens):
ret = []
for t in tokens:
if t in w2v.keys():
ret.append(t)
return np.stack(ret)
def _prep_train(vectorized_txt):
x, y = [], []
for i in range(window, vectorized_txt.shape[0] - (window + 1), 1):
snippet = []
for j in range(-windo... | code_fim | hard | {
"lang": "python",
"repo": "jooner/Channing",
"path": "/channing/prep.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jina-ai/jina path: /jina/serve/runtimes/gateway/async_request_response_handling.py
import asyncio
import copy
from typing import TYPE_CHECKING, Callable, List, Optional, Tuple, AsyncGenerator
import grpc.aio
from jina._docarray import DocumentArray
from jina.excepts import InternalNetworkError
... | code_fim | hard | {
"lang": "python",
"repo": "jina-ai/jina",
"path": "/jina/serve/runtimes/gateway/async_request_response_handling.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # In case of empty topologies
if not responding_tasks:
r.end_time.GetCurrentTime()
future = asyncio.Future()
future.set_result((request, {}))
responding_tasks.append(future)
return (
asynci... | code_fim | hard | {
"lang": "python",
"repo": "jina-ai/jina",
"path": "/jina/serve/runtimes/gateway/async_request_response_handling.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>''' cron.d job '''
line0 = '# ' + starDate
line1 = '# Generated by User: ' + userName
line2 = '0 * * * * root ' + binary_loc + '/injectTimeStampBashHist.py'
''' functions '''
def check_binary_loc():
if not binary_loc:
print(usage)
def write_crond_job(filename):
with open(filename, 'a') as f:
f... | code_fim | hard | {
"lang": "python",
"repo": "jclingensmith/InfoSecScripts",
"path": "/timeStampBashHistory/install_crond.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not binary_loc:
print(usage)
def write_crond_job(filename):
with open(filename, 'a') as f:
f.write(line0 + os.linesep)
f.write(line1 + os.linesep)
f.write(line2 + os.linesep)
''' script '''
write_crond_job('/etc/cron.d/injectTimeStampBashHist')<|fim_prefix|># repo: jclingensmith/InfoSecScri... | code_fim | hard | {
"lang": "python",
"repo": "jclingensmith/InfoSecScripts",
"path": "/timeStampBashHistory/install_crond.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jclingensmith/InfoSecScripts path: /timeStampBashHistory/install_crond.py
#!/usr/bin/python
# install_crond.py
# write a cron.d job to inject a timestamp to bash history
# Last Edited: 6/8/18 Julian Thies
''' imports '''
import os
import sys
import time
from time import strftime
import getpass
... | code_fim | hard | {
"lang": "python",
"repo": "jclingensmith/InfoSecScripts",
"path": "/timeStampBashHistory/install_crond.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#print '\nthreaded'
#for i in range(TRIALS):
# util.threaded(try_once)(i)
#
#print 'sequential'
#for i in range(TRIALS):
# try_once(i)
key = bits.getrandbytes(16)
c_crypter = c_rijndael(key)
py_crypter = py_rijndael(key)
py_encrypt = lambda _key, x: py_crypter.encrypt(x)
py_decrypt = ... | code_fim | hard | {
"lang": "python",
"repo": "niterain/digsby",
"path": "/digsby/src/tests/testrijndael.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: niterain/digsby path: /digsby/src/tests/testrijndael.py
from __future__ import division
import digsbysite
import sys
import util
import util.threads.threadpool as threadpool
import util.primitives.bits as bits
from tlslite.utils.rijndael.py_rijndael import encrypt as py_encrypt, decrypt a... | code_fim | hard | {
"lang": "python",
"repo": "niterain/digsby",
"path": "/digsby/src/tests/testrijndael.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> py_d = py_decrypt(key, py_e)
c_d = c_decrypt(key, c_e)
py_d_c = py_decrypt(key, c_e)
c_d_py = c_decrypt(key, py_e)
assert py_d_c == bytes
assert py_d == bytes
assert c_d == bytes
assert c_d_py == bytes
if ((i*100)/TRIALS) == ((i*100)//TRIALS):
... | code_fim | medium | {
"lang": "python",
"repo": "niterain/digsby",
"path": "/digsby/src/tests/testrijndael.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __exit__(self, *args):
self.end = time.perf_counter()
self.interval = self.end - self.start
log_timer.info(f"'{self.name}' ran in {self.interval:.2f} seconds")<|fim_prefix|># repo: sdementen/oasapi path: /src/oasapi/timer.py
import logging
import time
log_timer = logging.... | code_fim | medium | {
"lang": "python",
"repo": "sdementen/oasapi",
"path": "/src/oasapi/timer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, name=None):
self.name = "<anonymous code block>" if name is None else name
def __enter__(self):
self.start = time.perf_counter()
# log_timer.info(f"'{self.name}' started")
return self
def __exit__(self, *args):
self.end = time.perf_c... | code_fim | medium | {
"lang": "python",
"repo": "sdementen/oasapi",
"path": "/src/oasapi/timer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sdementen/oasapi path: /src/oasapi/timer.py
import logging
import time
log_timer = logging.getLogger(f"{__name__}.timer")
class Timer:
<|fim_suffix|> self.end = time.perf_counter()
self.interval = self.end - self.start
log_timer.info(f"'{self.name}' ran in {self.interval... | code_fim | hard | {
"lang": "python",
"repo": "sdementen/oasapi",
"path": "/src/oasapi/timer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: toppk/pysandra path: /tests/test_connection.py
import pytest
from pysandra.connection import Connection
from pysandra.exceptions import InternalDriverError
def test_connection_basic():
conn = Connection()
assert conn.host == "127.0.0.1"
<|fim_suffix|> conn = Connection()
conn.... | code_fim | hard | {
"lang": "python",
"repo": "toppk/pysandra",
"path": "/tests/test_connection.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_connection_choices_decgood():
conn = Connection()
conn.make_choices({"COMPRESSION": ["snappy"]})
assert (
conn.decompress(b"\x15\x0crow \x11\x04 your boat") == b"row row row your boat"
)
def test_connection_choices_decbad():
with pytest.raises(InternalDriverError, ma... | code_fim | medium | {
"lang": "python",
"repo": "toppk/pysandra",
"path": "/tests/test_connection.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create a device selection for this enrollment
DeviceSelection = apps.get_model('devices', 'DeviceSelection')
self.device_selection = DeviceSelection.objects.create(
kind=data['kind'], options=prep_data)
# get the device module, and prepare... | code_fim | hard | {
"lang": "python",
"repo": "script3r/oss2fa",
"path": "/enrollment/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # get the enrollment completion model
completion, err = device_module.get_enrollment_completion_model(
payload)
# if we couldn't parse the data, fail
if err:
return self._fail_enrollment(err)
# attempt to complet... | code_fim | hard | {
"lang": "python",
"repo": "script3r/oss2fa",
"path": "/enrollment/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: script3r/oss2fa path: /enrollment/models.py
from __future__ import unicode_literals
import logging
from django.apps import apps
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.utils imp... | code_fim | hard | {
"lang": "python",
"repo": "script3r/oss2fa",
"path": "/enrollment/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _real_extract(self, url):
item_id = self._match_id(url)
return self.playlist_result(self._extract_tracks(item_id, url, self._TYPE), item_id)
class XiamiAlbumIE(XiamiPlaylistBaseIE):
IE_NAME = 'xiami:album'
IE_DESC = '虾米音乐 - 专辑'
_VALID_URL = r'https?://(?:www\.)?xiami\... | code_fim | hard | {
"lang": "python",
"repo": "firsttris/plugin.video.sendtokodi",
"path": "/lib/youtube_dl/extractor/xiami.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firsttris/plugin.video.sendtokodi path: /lib/youtube_dl/extractor/xiami.py
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import compat_urllib_parse_unquote
from ..utils import int_or_none
class XiamiBaseIE(InfoExtractor):
_API_BASE_... | code_fim | hard | {
"lang": "python",
"repo": "firsttris/plugin.video.sendtokodi",
"path": "/lib/youtube_dl/extractor/xiami.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class XiamiSongIE(XiamiBaseIE):
IE_NAME = 'xiami:song'
IE_DESC = '虾米音乐'
_VALID_URL = r'https?://(?:www\.)?xiami\.com/song/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'http://www.xiami.com/song/1775610518',
'md5': '521dd6bea40fd5c9c69f913c232cb57e',
'info_dict': {
... | code_fim | hard | {
"lang": "python",
"repo": "firsttris/plugin.video.sendtokodi",
"path": "/lib/youtube_dl/extractor/xiami.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Return an executable string of console commands representing this
instance and possibly its children.
Will only evaluate children if combine() hasn't been called on them
yet.
"""
# If the contents of this command should be hidden from the main .... | code_fim | hard | {
"lang": "python",
"repo": "bcrtvkcs/csgo-menu-maker",
"path": "/csgomenumaker/command/command.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bcrtvkcs/csgo-menu-maker path: /csgomenumaker/command/command.py
COMMAND_EVAL_NONE = 0
COMMAND_EVAL_REGISTER = 1
COMMAND_EVAL_COMBINE = 2
class Command:
"""
Represents an 'alias' Source engine console command.
A Command instance can have multiple children, and thus resembles a tree... | code_fim | hard | {
"lang": "python",
"repo": "bcrtvkcs/csgo-menu-maker",
"path": "/csgomenumaker/command/command.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Loop through children and register them too, recursively.
for ch in self.children:
# Only register the child if it has not been registered yet;
# therefore its evaluation state has been set to NONE.
if ch.eval_state == COMMAND_EVAL_NONE:
... | code_fim | hard | {
"lang": "python",
"repo": "bcrtvkcs/csgo-menu-maker",
"path": "/csgomenumaker/command/command.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>connector = ' '*(len(data_storage["Publisher/Author"])-1)
for i in article[1:]:
connector = connector + i + ' '
data_storage['Article'] = connector
for data in data_storage.values():
print(data)<|fim_prefix|># repo: pralhad88/Web_scraping path: /scrap_single_news.py
from bs4 import BeautifulSoup
impo... | code_fim | hard | {
"lang": "python",
"repo": "pralhad88/Web_scraping",
"path": "/scrap_single_news.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pralhad88/Web_scraping path: /scrap_single_news.py
from bs4 import BeautifulSoup
import urllib.request
article = []
data_storage = {}
source = urllib.request.urlopen("https://www.ndtv.com/india-news/pm-modi-in-telangana-says-seek-your-support-blessings-for-bjp-in-coming-polls-1953954").read()
so... | code_fim | hard | {
"lang": "python",
"repo": "pralhad88/Web_scraping",
"path": "/scrap_single_news.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>data_storage['Article'] = connector
for data in data_storage.values():
print(data)<|fim_prefix|># repo: pralhad88/Web_scraping path: /scrap_single_news.py
from bs4 import BeautifulSoup
import urllib.request
article = []
data_storage = {}
source = urllib.request.urlopen("https://www.ndtv.com/india-news... | code_fim | hard | {
"lang": "python",
"repo": "pralhad88/Web_scraping",
"path": "/scrap_single_news.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Aggregation group
Args:
count (int): Size of the aggregation group
value (Union(int, str)): A unique value from the requested field
"""
def __init__(self, count: Optional[int] = None, value: Optional[Union[int, str]] = None, **kwargs: Any):
super().__init__(cou... | code_fim | hard | {
"lang": "python",
"repo": "cognitedata/cognite-sdk-python",
"path": "/cognite/client/data_classes/shared.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cognitedata/cognite-sdk-python path: /cognite/client/data_classes/shared.py
from __future__ import annotations
from typing import Any, Dict, List, Literal, Optional, Union
from cognite.client.data_classes._base import CognitePropertyClassUtil
from cognite.client.utils._text import convert_all_k... | code_fim | hard | {
"lang": "python",
"repo": "cognitedata/cognite-sdk-python",
"path": "/cognite/client/data_classes/shared.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aditi73/barati path: /barati/customers/views_cluster/update_review.py
from django.shortcuts import render
from django.template import RequestContext
from django.views.generic import View
from django.http import HttpResponse
from customers import models as m
import sys, json
<|fim_suffix|> try:... | code_fim | medium | {
"lang": "python",
"repo": "aditi73/barati",
"path": "/barati/customers/views_cluster/update_review.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
user = m.Users.objects.get(username=request.user.username)
ref_id = request.POST.get('update_reviewed_ref_id')
review=m.Reviews.objects.get(user_id=user.id,ref_id=ref_id)
review.title = request.POST.get('update_title_review')
review... | code_fim | medium | {
"lang": "python",
"repo": "aditi73/barati",
"path": "/barati/customers/views_cluster/update_review.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harshraj172/Deepwalk path: /deepwalk.py
# -*- coding: utf-8 -*-
"""Deepwalk.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1IsehyRWKpn_DCEG0VvViL_UMaZDOJIWJ
#Importing the necessary libraries
"""
# Commented out IPython m... | code_fim | hard | {
"lang": "python",
"repo": "harshraj172/Deepwalk",
"path": "/deepwalk.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(path_length-1):
temp = list(G.neighbors(node)) # a list containing neighboring nodes
temp = list(set(temp) - set(random_walk)) # discarding the values already traversed
if len(temp) == 0: # if there is no new node then break
break
random_node... | code_fim | hard | {
"lang": "python",
"repo": "harshraj172/Deepwalk",
"path": "/deepwalk.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # =================
# - Set Keyframes -
# =================
mc.setKeyframe(targetNS+seg,at='tx',v=t[0],t=float(frame))
mc.setKeyframe(targetNS+seg,at='ty',v=t[1],t=float(frame))
mc.setKeyframe(targetNS+seg,at='tz',v=t[2],t=float(frame))
mc.setKeyframe(targetNS+seg,at='rx',v=r[0],t=float(f... | code_fim | hard | {
"lang": "python",
"repo": "rituparna/glTools",
"path": "/utils/massive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rituparna/glTools path: /utils/massive.py
import maya.mel as mm
import maya.cmds as mc
import maya.OpenMaya as OpenMaya
import maya.OpenMayaAnim as OpenMayaAnim
import glTools.utils.base
import glTools.utils.matrix
import ast
def buildMatrix(mat):
'''
Build MMatrix From Matrix Cache List
''... | code_fim | hard | {
"lang": "python",
"repo": "rituparna/glTools",
"path": "/utils/massive.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># iterate through the face chips
for face in faces:
rect = face['rect']
# print face['id'], rect['x'], rect['y'], rect['width'], rect['height']
image_blobs.append(base64.b64decode(face['base64Image']))
# Create a Rectangle patch
rect = patches.Rectangle(
(rect['x'], rect['y'])... | code_fim | hard | {
"lang": "python",
"repo": "megasobnlack/dlib-align-faces",
"path": "/align_faces.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: megasobnlack/dlib-align-faces path: /align_faces.py
'''
MIT License
Copyright (c) 2017 Scott Hong
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, inclu... | code_fim | hard | {
"lang": "python",
"repo": "megasobnlack/dlib-align-faces",
"path": "/align_faces.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luisfdez/koku path: /koku/reporting/migrations/0157_auto_20201214_1757.py
# Generated by Django 3.1.3 on 2020-12-14 17:57
from django.db import migrations
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.RunSQL(
"""
UPDATE report... | code_fim | medium | {
"lang": "python",
"repo": "luisfdez/koku",
"path": "/koku/reporting/migrations/0157_auto_20201214_1757.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [("reporting", "0156_auto_20201208_2029")]
operations = [
migrations.RunSQL(
"""
UPDATE reporting_ocpawscostlineitem_daily_summary SET uuid = uuid_generate_v4();
UPDATE reporting_ocpawscostlineitem_project_daily_summary SET uuid = uuid_ge... | code_fim | medium | {
"lang": "python",
"repo": "luisfdez/koku",
"path": "/koku/reporting/migrations/0157_auto_20201214_1757.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _generate_all_vectors(new=False):
crime_types = list(CriminalRecord.objects.values('primary_type').annotate(
count=Count('primary_type')).order_by('-count').values_list(
'primary_type', flat=True)[:3])
crime_types.append(None)
for crime_type in crime_types:
for siz... | code_fim | hard | {
"lang": "python",
"repo": "jayArnel/crimemapping",
"path": "/crimeprediction/vectorize.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def vectorize_weekly(grid, crime_type=None, seasonal=False):
'''
Special vectorization for weekly data
:param grid_size: size of the cell dimension for the grid
:param crime_type: type of crime to be trained, None value will
train all
:param seasonal: implement seasonality or... | code_fim | hard | {
"lang": "python",
"repo": "jayArnel/crimemapping",
"path": "/crimeprediction/vectorize.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jayArnel/crimemapping path: /crimeprediction/vectorize.py
import cPickle as pickle
import os
from dateutil import rrule
from datetime import datetime, timedelta
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.models import Count
from map.... | code_fim | hard | {
"lang": "python",
"repo": "jayArnel/crimemapping",
"path": "/crimeprediction/vectorize.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mpewsey/xsect path: /xsect/calc/round_test.py
from __future__ import division
import pytest
import numpy as np
from .round import *
def test_round_area():
# No thickness
assert pytest.approx(round_area(4), 0.01) == 4*np.pi
# With thickness
assert pytest.approx(round_area(4, 1),... | code_fim | hard | {
"lang": "python",
"repo": "mpewsey/xsect",
"path": "/xsect/calc/round_test.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # No thickness
round_points(4)
# With thickness
round_points(4, 1)
def test_round_summary():
# No thickness
summary = round_summary(4)
odict = dict(
area=4*np.pi,
width=2,
height=2,
inertia_x=np.pi*2**4/4,
inertia_y=np.pi*2**4/4,
... | code_fim | hard | {
"lang": "python",
"repo": "mpewsey/xsect",
"path": "/xsect/calc/round_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_log():
t = threading.Thread(target=worker)
log.info("TEST_BEFORE_THREADING")
with step("Some nesting where the thread logs should go"):
t.start()
t.join()<|fim_prefix|># repo: reportportal/examples-python path: /pytest/tests/multi_thread_logging/thread/test_thread_loggin... | code_fim | hard | {
"lang": "python",
"repo": "reportportal/examples-python",
"path": "/pytest/tests/multi_thread_logging/thread/test_thread_logging_thread_patch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: reportportal/examples-python path: /pytest/tests/multi_thread_logging/thread/test_thread_logging_thread_patch.py
# Copyright (c) 2023 https://reportportal.io .
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#... | code_fim | medium | {
"lang": "python",
"repo": "reportportal/examples-python",
"path": "/pytest/tests/multi_thread_logging/thread/test_thread_logging_thread_patch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CodeForPoznan/codeforpoznan.pl_v3 path: /backend/serializers/participant_serializer.py
from marshmallow import Schema, fields, validate
class ParticipantSchema(Schema):
class Meta:
fields = (
"id",
"first_name",
"last_name",
"email",
... | code_fim | medium | {
"lang": "python",
"repo": "CodeForPoznan/codeforpoznan.pl_v3",
"path": "/backend/serializers/participant_serializer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> first_name = fields.Str(required=True, validate=[validate.Length(min=3, max=50)])
last_name = fields.Str(required=True, validate=[validate.Length(min=3, max=50)])
email = fields.Email(required=True, validate=[validate.Email()])
github_username = fields.Str(
required=True,
v... | code_fim | medium | {
"lang": "python",
"repo": "CodeForPoznan/codeforpoznan.pl_v3",
"path": "/backend/serializers/participant_serializer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: colinleach/400B_Leach path: /Project/notebooks/tot_angmom.py
import numpy as np
from numpy.linalg import norm
import pandas as pd
# from galaxy.db import DB
from galaxy.galaxies import Galaxies
from galaxy.timecourse import TimeCourse
<|fim_suffix|>tc.write_total_angmom()<|fim_middle|>tc = TimeC... | code_fim | easy | {
"lang": "python",
"repo": "colinleach/400B_Leach",
"path": "/Project/notebooks/tot_angmom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tc.write_total_angmom()<|fim_prefix|># repo: colinleach/400B_Leach path: /Project/notebooks/tot_angmom.py
import numpy as np
from numpy.linalg import norm
import pandas as pd
# from galaxy.db import DB
from galaxy.galaxies import Galaxies
from galaxy.timecourse import TimeCourse
<|fim_middle|>tc = TimeC... | code_fim | easy | {
"lang": "python",
"repo": "colinleach/400B_Leach",
"path": "/Project/notebooks/tot_angmom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwuphysics/beast path: /beast/fitting/tests/test_trim_grid.py
from astropy.tests.helper import remote_data
from beast.physicsmodel.grid import SEDGrid
from beast.observationmodel.noisemodel import generic_noisemodel as noisemodel
from beast.fitting.trim_grid import trim_models
from beast.tests.h... | code_fim | hard | {
"lang": "python",
"repo": "jwuphysics/beast",
"path": "/beast/fitting/tests/test_trim_grid.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# download the needed files
vega_fname = download_rename("vega.hd5")
seds_fname = download_rename("beast_example_phat_seds.grid.hd5")
noise_fname = download_rename("beast_example_phat_noisemodel.grid.hd5")
obs_fname = download_rename("b15_4band_det_27_A.fits")
# download cached v... | code_fim | medium | {
"lang": "python",
"repo": "jwuphysics/beast",
"path": "/beast/fitting/tests/test_trim_grid.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpatel3/jtskit-py path: /jtskit/__init__.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
<|fim_suffix|>__all__ = ['exceptions', '_types', 'models', 'utilities', 'compat... | code_fim | medium | {
"lang": "python",
"repo": "jpatel3/jtskit-py",
"path": "/jtskit/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>__all__ = ['exceptions', '_types', 'models', 'utilities', 'compat', 'infer', 'ensure']<|fim_prefix|># repo: jpatel3/jtskit-py path: /jtskit/__init__.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ impo... | code_fim | medium | {
"lang": "python",
"repo": "jpatel3/jtskit-py",
"path": "/jtskit/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sbneto/s3conf path: /s3conf/exceptions.py
from click.exceptions import UsageError
class EnvfilePathNotDefinedUsageError(UsageError):
def __init__(self, message=None, *args, **kwargs):
message = message or ''
if message:
message += '\n'
super().__init__(me... | code_fim | medium | {
"lang": "python",
"repo": "sbneto/s3conf",
"path": "/s3conf/exceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> error_msg = 'Set the environemnt variable S3CONF or provide a section from an existing config file.'
try:
from . import config
sections_detected = ''
settings = config.Settings()
for section in config.ConfigFileResolver(settings.config_file).... | code_fim | medium | {
"lang": "python",
"repo": "sbneto/s3conf",
"path": "/s3conf/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LocalCopyOutdated(UsageError):
def __init__(self, message=None, *args, ctx=None):
message = message or ''
if message:
message = message % args
message += '\n'
super().__init__(message, ctx=ctx)
class EnvfilePathNotDefinedError(Exception):
pa... | code_fim | medium | {
"lang": "python",
"repo": "sbneto/s3conf",
"path": "/s3conf/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
"accessToken" : create_access_token(user.id)
}, 200<|fim_prefix|># repo: rico0821/fridge path: /src/app/views/user/account/refresh.py
# -*- coding: utf-8 -*-
"""
app.views.user.account.refresh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module for access... | code_fim | medium | {
"lang": "python",
"repo": "rico0821/fridge",
"path": "/src/app/views/user/account/refresh.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rico0821/fridge path: /src/app/views/user/account/refresh.py
# -*- coding: utf-8 -*-
"""
app.views.user.account.refresh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module for access token refresh.
<|fim_suffix|> """ Access token refresh API. """
user = context_prope... | code_fim | hard | {
"lang": "python",
"repo": "rico0821/fridge",
"path": "/src/app/views/user/account/refresh.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kevinharvey/redthat path: /redthat/submissions/tests.py
from rest_framework.test import APITestCase, APIClient
from model_mommy import mommy
<|fim_suffix|> def test_submission_detail(self):
"""
Test the detail endpoint for Submissions
"""
submission = mommy.ma... | code_fim | medium | {
"lang": "python",
"repo": "kevinharvey/redthat",
"path": "/redthat/submissions/tests.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class SubmissionsEndpointTestCase(APITestCase):
def test_submission_detail(self):
"""
Test the detail endpoint for Submissions
"""
submission = mommy.make(Submission)
client = APIClient()
response = client.get(f'/submissions/{submission.id}/')
... | code_fim | medium | {
"lang": "python",
"repo": "kevinharvey/redthat",
"path": "/redthat/submissions/tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, {
'url': f'http://testserver/submissions/{submission.id}/',
'title': submission.title,
'external_link': submission.external_link,
'upvotes': submission.upvotes,
... | code_fim | hard | {
"lang": "python",
"repo": "kevinharvey/redthat",
"path": "/redthat/submissions/tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: apmoore1/rtf2xml path: /rtf2xml/tokenize.py
#########################################################################
# #
# #
# copyright 2016 Paul Henry T... | code_fim | hard | {
"lang": "python",
"repo": "apmoore1/rtf2xml",
"path": "/rtf2xml/tokenize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> read_obj.close()
write_obj.close()
def tokenize(self):
"""Main class for handling other methods. Reads in one line \
at a time, usues method self.sub_line to make basic substitutions,\
uses ? to process tokens"""
self.__create_tokens()
copy_obj ... | code_fim | hard | {
"lang": "python",
"repo": "apmoore1/rtf2xml",
"path": "/rtf2xml/tokenize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Felalex57/lookyloo path: /bin/async_capture.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
from lookyloo.abstractmanager import AbstractManager
from lookyloo.helpers import shutdown_requested
from lookyloo.lookyloo import Lookyloo
logging.basicConfig(format='%(asctime)s %(nam... | code_fim | medium | {
"lang": "python",
"repo": "Felalex57/lookyloo",
"path": "/bin/async_capture.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
m = AsyncCapture()
m.run(sleep_in_sec=1)
if __name__ == '__main__':
main()<|fim_prefix|># repo: Felalex57/lookyloo path: /bin/async_capture.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
from lookyloo.abstractmanager import AbstractManager
from lookyloo.helpe... | code_fim | hard | {
"lang": "python",
"repo": "Felalex57/lookyloo",
"path": "/bin/async_capture.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nahyunkwon/multi-ttach path: /venv/lib/python3.7/site-packages/cvxpy/tests/test_derivative.py
s) - np.sum(right_solns)) / delta
values[i] = old
numgrads = []
offset = 0
for param in problem.parameters():
numgrads.append(
numgrad[offset:offset + param.size].... | code_fim | hard | {
"lang": "python",
"repo": "nahyunkwon/multi-ttach",
"path": "/venv/lib/python3.7/site-packages/cvxpy/tests/test_derivative.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> gradcheck(problem, gp=True, atol=1e-3)
perturbcheck(problem, gp=True, atol=1e-3)
def test_analytic_param_in_exponent(self):
# construct a problem with solution
# x^\star(\alpha) = 1 - 2^alpha, and derivative
# x^\star'(\alpha) = -log(2) * 2^\alpha
base ... | code_fim | hard | {
"lang": "python",
"repo": "nahyunkwon/multi-ttach",
"path": "/venv/lib/python3.7/site-packages/cvxpy/tests/test_derivative.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nahyunkwon/multi-ttach path: /venv/lib/python3.7/site-packages/cvxpy/tests/test_derivative.py
=1e-5, eps=1e-10, **kwargs):
"""Checks the analytical adjoint derivative against a numerical computation."""
size = sum(p.size for p in problem.parameters())
values = np.zeros(size)
offse... | code_fim | hard | {
"lang": "python",
"repo": "nahyunkwon/multi-ttach",
"path": "/venv/lib/python3.7/site-packages/cvxpy/tests/test_derivative.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HiroForYou/torchexpo path: /torchexpo/vision/image_classification/__init__.py
from torchexpo.vision.image_classification.alexnet import alexnet
from torchexpo.vision.image_classification.densenet import (densenet121,
densenet161,
... | code_fim | hard | {
"lang": "python",
"repo": "HiroForYou/torchexpo",
"path": "/torchexpo/vision/image_classification/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # shufflenet_v2_x2_0)
from torchexpo.vision.image_classification.squeezenet import squeezenet1_0, squeezenet1_1
from torchexpo.vision.image_classification.vgg import (vgg11, vgg11_bn, vgg13,
vgg13_bn, vgg16, vgg16_bn,
... | code_fim | hard | {
"lang": "python",
"repo": "HiroForYou/torchexpo",
"path": "/torchexpo/vision/image_classification/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gharib85/toqito path: /toqito/state_props/__init__.py
"""Properties of quantum states."""
from toqito.state_props.is_ensemble import is_ensemble
from toqito.state_props.is_pure impo<|fim_suffix|>s.is_ppt import is_ppt
from toqito.state_props.is_product_vector import is_product_vector
from toqito.... | code_fim | medium | {
"lang": "python",
"repo": "gharib85/toqito",
"path": "/toqito/state_props/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mport concurrence
from toqito.state_props.negativity import negativity
from toqito.state_props.schmidt_rank import schmidt_rank<|fim_prefix|># repo: gharib85/toqito path: /toqito/state_props/__init__.py
"""Properties of quantum states."""
from toqito.state_props.is_ensemble import is_ensemble
from toqito... | code_fim | medium | {
"lang": "python",
"repo": "gharib85/toqito",
"path": "/toqito/state_props/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Perform a dictionary learning (and atom extraction) from the MNIST dataset
dl = DictionaryLearning(n_components=36, fit_algorithm='lars', transform_algorithm='lasso_lars')
X_dict = dl.fit_transform(digits.data)
# Show the atoms that have been extracted
fig, ax = plt.subplots(6,... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Machine-Learning-Algorithms",
"path": "/Chapter03/5dictionary_learning.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PacktPublishing/Machine-Learning-Algorithms path: /Chapter03/5dictionary_learning.py
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
<|fim_suffix|>if __name__ == '__main__':
# Load MNIST digits
digits = load_digits()
# Perform a dic... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Machine-Learning-Algorithms",
"path": "/Chapter03/5dictionary_learning.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (X, t, y, header)
class PhenotypingReader(Reader):
r"""
Reader for phenotype classification task.
Parameters
----------
dataset_dir : str
Directory where timeseries files are stored.
listilfe : str
Path to a listfile. If this parameter is left `Non... | code_fim | hard | {
"lang": "python",
"repo": "tianranzhang/mimic3-benchmarks-1",
"path": "/mimic3benchmark/readers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tianranzhang/mimic3-benchmarks-1 path: /mimic3benchmark/readers.py
import os
import numpy as np
import random
class Reader(object):
def __init__(self, dataset_dir, listfile=None):
self._dataset_dir = dataset_dir
if listfile is None:
listfile_path = os.path.join(d... | code_fim | hard | {
"lang": "python",
"repo": "tianranzhang/mimic3-benchmarks-1",
"path": "/mimic3benchmark/readers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: New-Sina/Oreomeow_checkinpanel path: /api_weather.py
# -*- coding: utf-8 -*-
"""
cron: 30 7 * * *
new Env('天气预报');
"""
import json
import os
from datetime import datetime
import requests
from notify_mtr import send
from utils import get_data
class Weather:
def __init__(self, check_items)... | code_fim | hard | {
"lang": "python",
"repo": "New-Sina/Oreomeow_checkinpanel",
"path": "/api_weather.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.