text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: mcolella14/pyppeteer_stealth path: /pyppeteer_stealth/utils.py
from pathlib import Path
<|fim_suffix|>async def with_utils(page: Page, **kwargs) -> None:
await page.evaluateOnNewDocument(
Path(__file__).parent.joinpath("js/utils.js").read_text()
)<|fim_middle|>from pyppeteer.page... | code_fim | easy | {
"lang": "python",
"repo": "mcolella14/pyppeteer_stealth",
"path": "/pyppeteer_stealth/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def with_utils(page: Page, **kwargs) -> None:
await page.evaluateOnNewDocument(
Path(__file__).parent.joinpath("js/utils.js").read_text()
)<|fim_prefix|># repo: mcolella14/pyppeteer_stealth path: /pyppeteer_stealth/utils.py
from pathlib import Path
<|fim_middle|>from pyppeteer.page... | code_fim | easy | {
"lang": "python",
"repo": "mcolella14/pyppeteer_stealth",
"path": "/pyppeteer_stealth/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '<call: %s( %s )>' % (self.name, str(self.tokens))<|fim_prefix|># repo: robotis/pmc path: /pmclib/units/call.py
"""
"""
from ._base import Base
class Call(Base):
def __init__(self, p):
""" t_name '(' <expr> ')'
"""
self.name = p[1]
self.tokens = p[... | code_fim | hard | {
"lang": "python",
"repo": "robotis/pmc",
"path": "/pmclib/units/call.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robotis/pmc path: /pmclib/units/call.py
"""
"""
from ._base import Base
class Call(Base):
def __init__(self, p):
""" t_name '(' <expr> ')'
"""
self.name = p[1]
self.tokens = p[3] if p[3] else []
def emit(self, scope):
<|fim_suffix|> return... | code_fim | hard | {
"lang": "python",
"repo": "robotis/pmc",
"path": "/pmclib/units/call.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self):
return '<call: %s( %s )>' % (self.name, str(self.tokens))<|fim_prefix|># repo: robotis/pmc path: /pmclib/units/call.py
"""
"""
from ._base import Base
class Call(Base):
def __init__(self, p):
""" t_name '(' <expr> ')'
"""
self.name = p[1]
... | code_fim | hard | {
"lang": "python",
"repo": "robotis/pmc",
"path": "/pmclib/units/call.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, para in enumerate(all_data):
if not para in skip:
# if i in [7,10,18,49]: #use this or line below or turn off both to plot all
# if para in incl: #use this or line above or turn off both to plot all
# adjusting pixel... | code_fim | hard | {
"lang": "python",
"repo": "DaniBodor/ConfinedMigrationAnalysis",
"path": "/ViolinPlots_pairwise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DaniBodor/ConfinedMigrationAnalysis path: /ViolinPlots_pairwise.py
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 5 14:45:43 2018
@author: dani
change t-test to
"""
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import os
from matplotlib import colors as mcolors
#... | code_fim | hard | {
"lang": "python",
"repo": "DaniBodor/ConfinedMigrationAnalysis",
"path": "/ViolinPlots_pairwise.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def formatted(v) -> str:
"""
# format the value as the rule as following:
- "" => ''
- "This is a string\r\n" => This is a string\r\n
- "123456" => '123456'
- 123456 => 123456
"""
t = type_of(v)
if t == String:
#... | code_fim | hard | {
"lang": "python",
"repo": "akinaru-lu/json2swagger",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akinaru-lu/json2swagger path: /main.py
import argparse
import json
import re
from collections import OrderedDict
# Data types
# https://swagger.io/docs/specification/data-models/data-types/
String = "string"
Integer = "integer"
Number = "number"
Boolean = "boolean"
Object = "object"
Array = "a... | code_fim | hard | {
"lang": "python",
"repo": "akinaru-lu/json2swagger",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = json.loads(src, object_pairs_hook=OrderedDict)
data = as_swagger_json(data)
output_as_yml(data, prefix=prefix, indent=indent)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--prefix', '-p', type=str, default='')
parser.add_argument('--in... | code_fim | hard | {
"lang": "python",
"repo": "akinaru-lu/json2swagger",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jlerasmus/watsor path: /watsor/detection/tensorrt_gpu.py
import os
import cv2
import numpy as np
import pycuda.driver as cuda
import tensorrt as trt
import watsor.engine as engine
from collections import namedtuple
from operator import itemgetter
from pycuda.tools import clear_context_caches
from... | code_fim | hard | {
"lang": "python",
"repo": "jlerasmus/watsor",
"path": "/watsor/detection/tensorrt_gpu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def device_name(self):
return self.__device.name()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.__finalize()
def detect(self, image_shape, image_np, detections: List[Detection]):
# Resize to model... | code_fim | hard | {
"lang": "python",
"repo": "jlerasmus/watsor",
"path": "/watsor/detection/tensorrt_gpu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate out the constants
args = _optimise_cleanConstants(args)
if not isinstance(args, list): return args
log.debug("\tWithout constants ({0} calls) : {1}".format(rlen(args), args))
# Create nodes
# log.debug("Creating nodes...")
return _create_nodes(args)
# log.debug... | code_fim | hard | {
"lang": "python",
"repo": "SqueezeStudioAnimation/omtk",
"path": "/python/omtk/libs/libFormula.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SqueezeStudioAnimation/omtk path: /python/omtk/libs/libFormula.py
import logging;
import math
import re
import pymel.core as pymel
from maya import cmds
from omtk.libs import libRigging
log = logging.getLogger(__name__);
log.setLevel(logging.INFO)
class Operator(object):
@staticmethod
... | code_fim | hard | {
"lang": "python",
"repo": "SqueezeStudioAnimation/omtk",
"path": "/python/omtk/libs/libFormula.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# TODO: Unify these two functions into one.
# Attemped to add them as methods of instance circuit using MethodType
# but circuit is a pybind11 object
def add_randomly_single_qubit_gates(
nb_single_qubit_gates: int, single_qubit_indices: set, circuit: Circuit
) -> Circuit:
for single_qubit_gate in... | code_fim | hard | {
"lang": "python",
"repo": "qfizik/tket",
"path": "/pytket/tests/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for nb_gates in range(request.param):
circuit.X(0)
return circuit
# TODO: Unify these two functions into one.
# Attemped to add them as methods of instance circuit using MethodType
# but circuit is a pybind11 object
def add_randomly_single_qubit_gates(
nb_single_qubit_gates: int, sin... | code_fim | hard | {
"lang": "python",
"repo": "qfizik/tket",
"path": "/pytket/tests/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qfizik/tket path: /pytket/tests/conftest.py
# Copyright 2019-2021 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | code_fim | hard | {
"lang": "python",
"repo": "qfizik/tket",
"path": "/pytket/tests/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>open(one, "w") as f:
f.write(one)<|fim_prefix|># repo: clerkma/my-ci-tests path: /z.py
if __name__ == "__main__":
task = ["ré-0.txt", "re\u0301-1.txt"]
for one in task<|fim_middle|>:
print(len(one), one)
with | code_fim | easy | {
"lang": "python",
"repo": "clerkma/my-ci-tests",
"path": "/z.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: clerkma/my-ci-tests path: /z.py
if __name__ == "__main__":
task = ["ré-<|fim_suffix|>:
print(len(one), one)
with open(one, "w") as f:
f.write(one)<|fim_middle|>0.txt", "re\u0301-1.txt"]
for one in task | code_fim | easy | {
"lang": "python",
"repo": "clerkma/my-ci-tests",
"path": "/z.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: telefactor/telefactor path: /tfr/src/tfr/commands/repos.py
import click
from tfr.io_utils import echo
from tfr.tfr import TFR
from .base import cli
@cli.group()
def repos():
<|fim_suffix|> raise Exception('Deprecated')
"""Create a private repository with the given NAME."""
if not cl... | code_fim | hard | {
"lang": "python",
"repo": "telefactor/telefactor",
"path": "/tfr/src/tfr/commands/repos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@repos.command()
@click.argument("name")
@click.pass_obj
def new(tfr: TFR, name):
raise Exception('Deprecated')
"""Create a private repository with the given NAME."""
if not click.confirm(f"Create a new repository named {repr(name)}?"):
echo("Okay nevermind")
return
creat... | code_fim | hard | {
"lang": "python",
"repo": "telefactor/telefactor",
"path": "/tfr/src/tfr/commands/repos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CloudSlang/score path: /runtime-management/runtime-management-impl/src/main/resources/main.py
import importlib
import inspect
import json
import os
import sys
import traceback
EXECUTE_METHOD = "execute"
# noinspection PyMethodMayBeStatic
class InvalidExecutionException(Exception):
pass
cl... | code_fim | hard | {
"lang": "python",
"repo": "CloudSlang/score",
"path": "/runtime-management/runtime-management-impl/src/main/resources/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def print_event(self, event):
print(event)
def main(self):
self.print_event("<execution>")
self.print_event("<executionOutput> <![CDATA[")
try:
raw_inputs = input().encode(sys.stdin.encoding).decode()
payload = json.loads(raw_inputs)
... | code_fim | hard | {
"lang": "python",
"repo": "CloudSlang/score",
"path": "/runtime-management/runtime-management-impl/src/main/resources/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tichoi/pyDMPC path: /pyDMPC/ControlFramework/System.py
##################################################################
# System class that can generate subsystem agents
##################################################################
import Subsystem as SubSys
import Init
class System:
... | code_fim | hard | {
"lang": "python",
"repo": "tichoi/pyDMPC",
"path": "/pyDMPC/ControlFramework/System.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> subsystems = []
num_SubSys = Init.amount_consumer+Init.amount_generator
for i in range(0,(num_SubSys)):
if Init.sim_time_global is not None:
Init.sim_time.insert(0, Init.sim_time_global)
if Init.init_DecVars_global is not None:
... | code_fim | hard | {
"lang": "python",
"repo": "tichoi/pyDMPC",
"path": "/pyDMPC/ControlFramework/System.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bands = eigenval.spin_up
# lower_fermi_band_index indicates the band just below Fermi level
lower_fermi_band_index = np.argmax(np.nanmax(bands,axis=1) > 0) - 1
# Find continuous segments in KPOINTS
# For example: segment_sizes => [40, 40, 40, 20]
segment_sizes = kpoints.segment_si... | code_fim | hard | {
"lang": "python",
"repo": "gpilania/EBS-search",
"path": "/create_index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gpilania/EBS-search path: /create_index.py
import os
import argparse
from tqdm import tqdm
from lib import vasp
from lib.preprocessing import path_1D, interpolate, interpolate_normalize
import numpy as np
from annoy import AnnoyIndex
parser = argparse.ArgumentParser()
parser.add_argument('--ban... | code_fim | hard | {
"lang": "python",
"repo": "gpilania/EBS-search",
"path": "/create_index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gap = np.min(window_band_u) - np.max(window_band_l)
window_band_l = interpolate_normalize(window_k, window_band_l, opt.dimensions)
window_band_u = interpolate_normalize(window_k, window_band_u, opt.dimensions)
annoyindex.add_item(len(lookuptable), np.concate... | code_fim | hard | {
"lang": "python",
"repo": "gpilania/EBS-search",
"path": "/create_index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Helper function.
Wraps an action vector of joint angles into a JointTrajectory message.
Velocity must be set now. Duration (self.slowness) does not control velocity now.
"""
# Set up a trajectory message to publish.
actionMsg = JointTrajectory()
actionMsg.joint_names = ... | code_fim | hard | {
"lang": "python",
"repo": "vicb1/miscellaneous-notes",
"path": "/educational-resources/robotics/gym-gazebo2-dashing/gym_gazebo2/utils/ut_mara.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vicb1/miscellaneous-notes path: /educational-resources/robotics/gym-gazebo2-dashing/gym_gazebo2/utils/ut_mara.py
import numpy as np
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
from PyKDL import Jacobian, JntArray # For KDL Jacobians
def processObservations(message, agen... | code_fim | hard | {
"lang": "python",
"repo": "vicb1/miscellaneous-notes",
"path": "/educational-resources/robotics/gym-gazebo2-dashing/gym_gazebo2/utils/ut_mara.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """获取redis"""
try:
v = (self.redis_ctl.get(key)).decode('utf-8')
logger.debug(v)
logger.debug('【微信Meida缓存】getCache>>>key[' + key + '],value[' + v + ']')
return v
except Exception:
return None<|fim_prefix|># repo: wzser/Fil... | code_fim | hard | {
"lang": "python",
"repo": "wzser/FilmHub-Tornado",
"path": "/core/cache/wxmediacache.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> set_cache 添加redis
get_cache 获取redis
"""
def set_cache(self, key, value):
"""添加微信Media相关redis"""
res = self.redis_ctl.set(key, value)
logger.debug('【微信media缓存】setCache>>>key[' + key + '],value[' + value + ']')
return res
def ... | code_fim | medium | {
"lang": "python",
"repo": "wzser/FilmHub-Tornado",
"path": "/core/cache/wxmediacache.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wzser/FilmHub-Tornado path: /core/cache/wxmediacache.py
from core.cache.basecache import BaseCache
from core.logger_helper import logger
<|fim_suffix|> """
media缓存
set_cache 添加redis
get_cache 获取redis
"""
def set_cache(self, key, value):
... | code_fim | medium | {
"lang": "python",
"repo": "wzser/FilmHub-Tornado",
"path": "/core/cache/wxmediacache.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> to_input = day_element.find_element_by_id("pzbuchzbis")
to_input.send_keys(to_value)
# submits the whole form, doesn't matter on which element of the form
#to_input.submit()
pass
# datetimel.time() gives the current time
my_enter = time(9,23)
my_exit = time (17,42)
day_element.click()
#d... | code_fim | hard | {
"lang": "python",
"repo": "ebirn/SageScrape",
"path": "/selenium_scrape.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
day_element = find_current_day_element(calendar_table, check_date)
if(day_element is not None):
print("the day you were looking for:")
elem_info(day_element)
else:
raise SystemExit("cannot find day we are looking for")
def fill_times(day_element, from_time=None, to_time=None):
from_value = "%... | code_fim | hard | {
"lang": "python",
"repo": "ebirn/SageScrape",
"path": "/selenium_scrape.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebirn/SageScrape path: /selenium_scrape.py
#!/usr/bin/env python
from __future__ import print_function
import base64
from time import sleep
from datetime import date, time
import ConfigParser
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from sele... | code_fim | hard | {
"lang": "python",
"repo": "ebirn/SageScrape",
"path": "/selenium_scrape.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _cmd_set_button(self, command):
"""
This runs when ISY calls set button which passes the button index
"""
index = int(command.get('value'))
self.l_debug("_cmd_set_button","index=%d" % (index))
return self._send_command_by_index(index)
de... | code_fim | hard | {
"lang": "python",
"repo": "jimboca/udi-harmony-poly",
"path": "/harmony_hub_nodes/HarmonyDevice.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jimboca/udi-harmony-poly path: /harmony_hub_nodes/HarmonyDevice.py
import polyinterface
LOGGER = polyinterface.LOGGER
class HarmonyDevice(polyinterface.Node):
"""
This is the class that all the Nodes will be represented by. You will add this to
Polyglot/ISY with the control... | code_fim | hard | {
"lang": "python",
"repo": "jimboca/udi-harmony-poly",
"path": "/harmony_hub_nodes/HarmonyDevice.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _cmd_don(self, command):
"""
This runs when ISY calls set button which passes the button index
"""
self.l_debug("_cmd_don","")
# TODO: If no PowerOn command, do PowerToggle
return self._send_command('PowerOn')
def _cmd_dof(self, command)... | code_fim | hard | {
"lang": "python",
"repo": "jimboca/udi-harmony-poly",
"path": "/harmony_hub_nodes/HarmonyDevice.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: betty29/code-1 path: /recipes/Python/578224_DoubleDict/recipe-578224.py
import functools
import threading
################################################################################
class _DDChecker(type):
def __new__(cls, name, bases, classdict):
for key, value in classdict.i... | code_fim | hard | {
"lang": "python",
"repo": "betty29/code-1",
"path": "/recipes/Python/578224_DoubleDict/recipe-578224.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.get_key(value) if self.in_values(value) else default
def in_values(self, value):
return value in self.__reverse
def items(self):
return self.__dict_view('items', ((key, self[key]) for key in self))
def iter_values(self):
return iter(self.__reverse... | code_fim | hard | {
"lang": "python",
"repo": "betty29/code-1",
"path": "/recipes/Python/578224_DoubleDict/recipe-578224.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChenhaoJiang/LeetCode-Solution path: /101-150/123_best_time_to_buy_and_sell_stock_iii.py
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
"""
# 方法一:贪心算法
buy_1 = buy_2 = float("inf")
profit_1 = profit_2 = 0
... | code_fim | hard | {
"lang": "python",
"repo": "ChenhaoJiang/LeetCode-Solution",
"path": "/101-150/123_best_time_to_buy_and_sell_stock_iii.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ices[i])
return dp[-1][-1][0]
"""
思路:方法一为贪心算法,与121题的贪心算法比较类似,只是多了一次交易,通过用第一次的收益抵消掉部分第二次的购买价格即可实现。算法时间复杂度为O(n),空间复杂度为O(1)。方法二为动态规划,状态转移方程为:
dp[i][k][0] = max(dp[i - 1][k][1] + prices[i], dp[i - 1][k][0]) # 右边:今天卖了昨天持有的股票,所以两天买入股票的次数都是j
dp[i][k][1] = max(dp[i - 1][k][1], dp[i - 1][k - 1][0] - pr... | code_fim | hard | {
"lang": "python",
"repo": "ChenhaoJiang/LeetCode-Solution",
"path": "/101-150/123_best_time_to_buy_and_sell_stock_iii.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('ref_data', '0008_auto_20201023_2222'),
]
operations = [
migrations.AlterField(
model_name='classlevel',
name='class_type',
field=models.CharField(choices=[('Cleric', 'Cleric'), ('Fighter', 'Fighter'), ('Rogue', 'Rogue'), (... | code_fim | medium | {
"lang": "python",
"repo": "cmerwin3/Adventure_Project",
"path": "/ref_data/migrations/0009_auto_20210423_2220.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='classlevel',
name='class_type',
field=models.CharField(choices=[('Cleric', 'Cleric'), ('Fighter', 'Fighter'), ('Rogue', 'Rogue'), ('Wizard', 'Wizard')], max_length=30, null=True),
),
]<|fim_prefix... | code_fim | medium | {
"lang": "python",
"repo": "cmerwin3/Adventure_Project",
"path": "/ref_data/migrations/0009_auto_20210423_2220.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmerwin3/Adventure_Project path: /ref_data/migrations/0009_auto_20210423_2220.py
# Generated by Django 3.1.1 on 2021-04-24 03:20
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AlterField(
model_na... | code_fim | medium | {
"lang": "python",
"repo": "cmerwin3/Adventure_Project",
"path": "/ref_data/migrations/0009_auto_20210423_2220.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lpython2006e/student-practices path: /14_Tran_An_Thien/Bai_1.6.py
# Write a guessing game where the user has to guess a secret number.
# After every guess the program tells the user whether their number was too large or too small.
# At the end the number of tries needed s<|fim_suffix|>e:
... | code_fim | hard | {
"lang": "python",
"repo": "lpython2006e/student-practices",
"path": "/14_Tran_An_Thien/Bai_1.6.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e:
number = int(input('so ban vua nhap k dung, moi ban nhap so khac: '))
if (number > sobimat):
print('so ban nhap lon hon')
else:
print('so ban nhap nho hon')<|fim_prefix|># repo: lpython2006e/student-practices path: /14_Tran_An_Thien/Bai_1.6.py
# Write a ... | code_fim | hard | {
"lang": "python",
"repo": "lpython2006e/student-practices",
"path": "/14_Tran_An_Thien/Bai_1.6.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Degget1986/uplexa-network path: /contrib/py/ffi-example/udap.py
#!/usr/bin/env python3
from ctypes import *
import signal
import time
import threading
class UDAP(threading.Thread):
<|fim_suffix|> code = self.lib.udap_main_run(self.ctx)
print("udap_main_run exited with status {... | code_fim | medium | {
"lang": "python",
"repo": "Degget1986/uplexa-network",
"path": "/contrib/py/ffi-example/udap.py",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> udap = UDAP()
udap.lib = CDLL("./libudap.so")
udap.ctx = udap.lib.udap_main_init(b'daemon.ini')
if udap.ctx:
udap.start()
try:
while True:
print("busy loop")
time.sleep(1)
except KeyboardInterrupt:
udap.signal(... | code_fim | hard | {
"lang": "python",
"repo": "Degget1986/uplexa-network",
"path": "/contrib/py/ffi-example/udap.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ...
list_display = ('company', 'job_title', 'location', 'created_at')
admin.site.register(Job, JobAdmin)<|fim_prefix|># repo: bitrecruiter/ats_project path: /ats/admin.py
from django.contrib import admin
from ats.models import Job
<|fim_middle|>class JobAdmin(admin.ModelAdmin):
| code_fim | easy | {
"lang": "python",
"repo": "bitrecruiter/ats_project",
"path": "/ats/admin.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitrecruiter/ats_project path: /ats/admin.py
from django.contrib import admin
from ats.models import Job
<|fim_suffix|> # ...
list_display = ('company', 'job_title', 'location', 'created_at')
admin.site.register(Job, JobAdmin)<|fim_middle|>
class JobAdmin(admin.ModelAdmin):
| code_fim | easy | {
"lang": "python",
"repo": "bitrecruiter/ats_project",
"path": "/ats/admin.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahesford/habis-tools path: /shell/tracer.py
#!/usr/bin/env python
# Copyright (c) 2016 Andrew J. Hesford. All rights reserved.
# Restrictions are listed in the LICENSE file distributed with this package.
import os, sys, math, numpy as np
from numpy.linalg import norm
from scipy.sparse.linalg i... | code_fim | hard | {
"lang": "python",
"repo": "ahesford/habis-tools",
"path": "/shell/tracer.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> stime = time.time()
# Accumulate the total results for every segment
dt, mpt = makedtypes(2, 3, ('tx', 'rx', 'exlen', 'inlen', 'atime'))
results = np.empty((len(segs),), dtype=dt)
nres = 0
# Track the number of odd-intersection paths that are skipped
nodds = 0
# Find the portion of each path in ... | code_fim | hard | {
"lang": "python",
"repo": "ahesford/habis-tools",
"path": "/shell/tracer.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def post():
r = requests.get(url, auth = auth)
result = json.loads(r.text)
if len(result) > 0:
delete()
r = requests.post(url, auth = auth, data = json.dumps(payload), headers = headers)
if r.status_code == 201:
result = json.loads(r.text)
print 'Create network-lagg --> Succeeded!'
... | code_fim | hard | {
"lang": "python",
"repo": "edshuai/freenas",
"path": "/test/api/test-suite/network_lagg.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edshuai/freenas path: /test/api/test-suite/network_lagg.py
#!/usr/local/bin/python
import requests
import json
import sys
import conn
import os
os.system('rm *.pyc')
url = conn.url + 'network/lagg/'
auth = conn.auth
headers = conn.headers
payload = {
"lagg_interfaces": ["em0"],
... | code_fim | hard | {
"lang": "python",
"repo": "edshuai/freenas",
"path": "/test/api/test-suite/network_lagg.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def direction(self):
"""
unit vector of direction
:return: Position
"""
len = self.length()
if len == 0.0:
uvec = pos.Pos(np.transpose(np.array([0, 0, 0])))
else:
uvec = pos.Pos(np.transpose(np.array([(self.end.x - self.st... | code_fim | hard | {
"lang": "python",
"repo": "ICRA-2020/cyphyhouse-CyPyHous3",
"path": "/src/datatypes/motion/seg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self) -> str:
"""
string representation
:return: string
"""
return str(self.start) + ":" + str(self.end)
# ----------------- PROPERTIES --------------------
def length(self) -> float:
"""
length of the segment
:retu... | code_fim | hard | {
"lang": "python",
"repo": "ICRA-2020/cyphyhouse-CyPyHous3",
"path": "/src/datatypes/motion/seg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ICRA-2020/cyphyhouse-CyPyHous3 path: /src/datatypes/motion/seg.py
# Copyright (c) 2019 CyPhyHouse. All Rights Reserved.
import numpy as np
import src.datatypes.motion.pos as pos
class Seg(object):
"""
path segment object, specified by a start and an end position
__start : start po... | code_fim | hard | {
"lang": "python",
"repo": "ICRA-2020/cyphyhouse-CyPyHous3",
"path": "/src/datatypes/motion/seg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/nncf path: /nncf/torch/quantization/statistics.py
# Copyright (c) 2023 Intel 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://www... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/torch/quantization/statistics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class MemoryConsumptionStatistics(Statistics):
"""
Contains statistics of the memory consumption.
"""
def __init__(
self,
fp32_weight_size: int = 0,
quantized_weight_size: int = 0,
max_fp32_activation_size: int = 0,
max_compressed_activation_size: i... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/torch/quantization/statistics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Use this in such a way:
gen_this()
from .this import *
It creates this.py file that does same as `import_all` but the file
can be parsed by IDEs.
"""
frame = stack()[1][0]
_dir = _dir = dirname(getmodule(frame).__file__)
importer_name = join(_dir, "this.py")
code = gen_impor... | code_fim | medium | {
"lang": "python",
"repo": "laerreal/librfunc",
"path": "/importall.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: laerreal/librfunc path: /importall.py
__all__ = [
"ismod",
"gen_this",
"import_all"
]
from os import (
listdir
)
from os.path import (
splitext,
dirname,
join,
isdir,
exists
)
from inspect import (
stack,
getmodule
)
def ismod(n):
if n.startswith(... | code_fim | hard | {
"lang": "python",
"repo": "laerreal/librfunc",
"path": "/importall.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vdbergh/pentanomial path: /sprta5.py
from __future__ import division
import math, sys, argparse
import stats_pentanomial, context, LLRcalc, random_walk
"""
This program computes passing probabilities and expected running times for SPRT tests.
Based on:
[W1] A. Wald, Sequential analysis.
"""
... | code_fim | hard | {
"lang": "python",
"repo": "vdbergh/pentanomial",
"path": "/sprta5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
defaults = context.LTC_defaults
default_biases = defaults.biases()
default_draw_elo = defaults.draw_elo()
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"--alpha", help="pro... | code_fim | hard | {
"lang": "python",
"repo": "vdbergh/pentanomial",
"path": "/sprta5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaksGovor/TheoryOfAlgorytms path: /Python/8-Lab_v2.py
from collections import namedtuple
Thing = namedtuple('Thing', 'price weight')
things = Thing(4, 5), Thing(3, 4), Thing(3, 2), Thing(2, 1)
CAPACITY = 10
<|fim_suffix|> if items == 0 :
return 0
elif things[items - 1].weight > weihgtLi... | code_fim | medium | {
"lang": "python",
"repo": "MaksGovor/TheoryOfAlgorytms",
"path": "/Python/8-Lab_v2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>res = []
weihgtLimit = CAPACITY
for i in reversed(range(len(things))):
if betterThing(i + 1, weihgtLimit, things) > betterThing(i, weihgtLimit, things):
res.append(things[i])
weihgtLimit -= things[i].weight
print(res)<|fim_prefix|># repo: MaksGovor/TheoryOfAlgorytms path: /Python/8-Lab_v2.py
... | code_fim | hard | {
"lang": "python",
"repo": "MaksGovor/TheoryOfAlgorytms",
"path": "/Python/8-Lab_v2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if items == 0 :
return 0
elif things[items - 1].weight > weihgtLimit :
return betterThing(items - 1, weihgtLimit, things)
else :
return max(
betterThing(items - 1, weihgtLimit, things),
betterThing(items - 1, weihgtLimit - things[items - 1].weight, things)
... | code_fim | medium | {
"lang": "python",
"repo": "MaksGovor/TheoryOfAlgorytms",
"path": "/Python/8-Lab_v2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_update_all_city(self):
from weather.models import update_all_city
print('update_all_city',CityInfo.objects.all())
update_all_city()
forecasts = Forecast.objects.filter(city=self.city)
for forecast in forecasts:
print(forecast.forecast_date, ... | code_fim | hard | {
"lang": "python",
"repo": "asd8520383/myweather",
"path": "/weather/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from weather.models import update_forecast
import json
update_forecast(self.city, json.loads(self.qstr))
forecasts = Forecast.objects.filter(city=self.city)
for forecast in forecasts:
print(forecast.forecast_date, ',', forecast.cast_time, ',', forecast.l... | code_fim | hard | {
"lang": "python",
"repo": "asd8520383/myweather",
"path": "/weather/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asd8520383/myweather path: /weather/tests.py
from django.test import TestCase
from weather.models import *
# Create your tests here.
class TestWeather(TestCase):
def setUp(self):
from weather.api_config import query_by_areaid
self.city = CityInfo(areaid='101010100',
... | code_fim | hard | {
"lang": "python",
"repo": "asd8520383/myweather",
"path": "/weather/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>subprocess.check_call(['patch', '-p1', '-i', '../uv.patch'])
shutil.copyfile('deps/uv/include/uv.h', 'include/node/uv.h')<|fim_prefix|># repo: TekBoundary/libnode path: /scripts/patch.py
assert __name__ == "__main__"
<|fim_middle|>import subprocess
import os
import shutil
from . import config
os.chdir... | code_fim | medium | {
"lang": "python",
"repo": "TekBoundary/libnode",
"path": "/scripts/patch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TekBoundary/libnode path: /scripts/patch.py
assert __name__ == "__main__"
import subprocess
import os
import shutil
from . import config
<|fim_suffix|>subprocess.check_call(['patch', '-p1', '-i', '../uv.patch'])
shutil.copyfile('deps/uv/include/uv.h', 'include/node/uv.h')<|fim_middle|>os.chdir... | code_fim | easy | {
"lang": "python",
"repo": "TekBoundary/libnode",
"path": "/scripts/patch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: czs108/LeetCode-Solutions path: /Hard/895. Maximum Frequency Stack/solution (1).py
# 895. Maximum Frequency Stack
from collections import Counter, defaultdict
class FreqStack:
<|fim_suffix|># Your FreqStack object will be instantiated and called as such:
# obj = FreqStack()
# obj.push(val)
# p... | code_fim | hard | {
"lang": "python",
"repo": "czs108/LeetCode-Solutions",
"path": "/Hard/895. Maximum Frequency Stack/solution (1).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Your FreqStack object will be instantiated and called as such:
# obj = FreqStack()
# obj.push(val)
# param_2 = obj.pop()<|fim_prefix|># repo: czs108/LeetCode-Solutions path: /Hard/895. Maximum Frequency Stack/solution (1).py
# 895. Maximum Frequency Stack
from collections import Counter, defaultdict
... | code_fim | hard | {
"lang": "python",
"repo": "czs108/LeetCode-Solutions",
"path": "/Hard/895. Maximum Frequency Stack/solution (1).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> val = self._group[self._max_freq].pop()
self._freq[val] -= 1
if not self._group[self._max_freq]:
self._max_freq -= 1
return val
# Your FreqStack object will be instantiated and called as such:
# obj = FreqStack()
# obj.push(val)
# param_2 = obj.pop()<|fim_prefi... | code_fim | medium | {
"lang": "python",
"repo": "czs108/LeetCode-Solutions",
"path": "/Hard/895. Maximum Frequency Stack/solution (1).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IbraheemWazirUK/Wifi-signal-room-classifier path: /src/splitrule.py
class SplitRule:
def __init__(self, attribute, split_value):
self.attribute = attribute
self.split_value = split_value
<|fim_suffix|> return "A" + str(self.attribute) + " > " + str(self.split_value)<|f... | code_fim | easy | {
"lang": "python",
"repo": "IbraheemWazirUK/Wifi-signal-room-classifier",
"path": "/src/splitrule.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "A" + str(self.attribute) + " > " + str(self.split_value)<|fim_prefix|># repo: IbraheemWazirUK/Wifi-signal-room-classifier path: /src/splitrule.py
class SplitRule:
def __init__(self, attribute, split_value):
self.attribute = attribute
self.split_value = split_value
<|f... | code_fim | easy | {
"lang": "python",
"repo": "IbraheemWazirUK/Wifi-signal-room-classifier",
"path": "/src/splitrule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cd = build_fit_matrix((36, 47), 1e-5)
w = make_mock_jwst_wcs(
v2ref=123.0, v3ref=500.0, roll=115.0, crpix=[512.0, 512.0],
cd=cd, crval=[82.0, 12.0]
)
return w
@pytest.fixture(scope='function')
def mock_fits_wcs():
cd = build_fit_matrix((36, 47), 1e-5)
w = fitswcs.... | code_fim | medium | {
"lang": "python",
"repo": "spacetelescope/tweakwcs",
"path": "/tweakwcs/tests/conftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.fixture(scope='function')
def mock_fits_wcs():
cd = build_fit_matrix((36, 47), 1e-5)
w = fitswcs.WCS(naxis=2)
w.wcs.cd = cd
w.wcs.crval = [82.0, 12.0]
w.wcs.crpix = [512.0, 512.0]
w.wcs.ctype = ['RA---TAN', 'DEC--TAN']
w.pixel_shape = [1024, 2048]
w.pixel_bounds = ... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/tweakwcs",
"path": "/tweakwcs/tests/conftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spacetelescope/tweakwcs path: /tweakwcs/tests/conftest.py
import pytest
from astropy import wcs as fitswcs
from astropy.table import Table
from tweakwcs.linearfit import build_fit_matrix
from . helper_correctors import make_mock_jwst_wcs
@pytest.fixture(scope='module')
def mock_jwst_wcs():
... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/tweakwcs",
"path": "/tweakwcs/tests/conftest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoshGrose/Kratos path: /applications/FluidDynamicsApplication/python_scripts/navier_stokes_embedded_ausas_solver.py
from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7
# Importing the Kratos Library
import Krato... | code_fim | hard | {
"lang": "python",
"repo": "JoshGrose/Kratos",
"path": "/applications/FluidDynamicsApplication/python_scripts/navier_stokes_embedded_ausas_solver.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, model, custom_settings):
super(NavierStokesEmbeddedAusasMonolithicSolver,self).__init__(model,custom_settings)
self.element_name = "EmbeddedAusasNavierStokes"
self.condition_name = "EmbeddedAusasNavierStokesWallCondition"
self.min_buffer_size = 3
... | code_fim | hard | {
"lang": "python",
"repo": "JoshGrose/Kratos",
"path": "/applications/FluidDynamicsApplication/python_scripts/navier_stokes_embedded_ausas_solver.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> KratosMultiphysics.Logger.PrintInfo("NavierStokesEmbeddedAusasMonolithicSolver", "Construction of NavierStokesEmbeddedAusasMonolithicSolver finished.")
def Initialize(self):
# Initialize the solver as in the base embedded solver
super(NavierStokesEmbeddedAusasMonolithicSolver... | code_fim | hard | {
"lang": "python",
"repo": "JoshGrose/Kratos",
"path": "/applications/FluidDynamicsApplication/python_scripts/navier_stokes_embedded_ausas_solver.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name="TestTextDefault",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("description", models.TextField(default="No description provided")),
],
),
... | code_fim | medium | {
"lang": "python",
"repo": "3YOURMIND/django-add-default-value",
"path": "/test_project/dadv/migrations/0002_testtextdefault.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 3YOURMIND/django-add-default-value path: /test_project/dadv/migrations/0002_testtextdefault.py
# Generated by Django 2.0.8 on 2018-08-12 16:09
from django.db import migrations, models
from django_add_default_value import AddDefaultValue
<|fim_suffix|> operations = [
migrations.Create... | code_fim | medium | {
"lang": "python",
"repo": "3YOURMIND/django-add-default-value",
"path": "/test_project/dadv/migrations/0002_testtextdefault.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def send_rpc(channel):
stub = helloworld_pb2_grpc.GreeterStub(channel)
request = helloworld_pb2.HelloRequest(name="you")
try:
response = stub.SayHello(request)
except grpc.RpcError as rpc_error:
_LOGGER.error("Received error: %s", rpc_error)
return rpc_error
els... | code_fim | hard | {
"lang": "python",
"repo": "grpc/grpc",
"path": "/examples/python/auth/customized_auth_client.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser()
parser.add_argument(
"--port",
nargs="?",
type=int,
default=50051,
help="the address of server",
)
args = parser.parse_args()
with create_client_channel(_SERVER_ADDR_TEMPLATE % args.port) as channel:
se... | code_fim | hard | {
"lang": "python",
"repo": "grpc/grpc",
"path": "/examples/python/auth/customized_auth_client.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grpc/grpc path: /examples/python/auth/customized_auth_client.py
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | code_fim | hard | {
"lang": "python",
"repo": "grpc/grpc",
"path": "/examples/python/auth/customized_auth_client.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Return:
Focal损失函数值.
"""
probs = tf.nn.sigmoid(y_pred)
pt = tf.where(condition=K.equal(y_true, 1.0),
x=probs,
y=1.0 - probs)
at = tf.where(condition=K.equal(y_true, 1.0),
x=self.alpha,
... | code_fim | hard | {
"lang": "python",
"repo": "sun1638650145/RetinaNet",
"path": "/RetinaNet/losses/focal_loss.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sun1638650145/RetinaNet path: /RetinaNet/losses/focal_loss.py
import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras.losses import Loss
class FocalLoss(Loss):
"""Focal损失函数.
Attributes:
alpha: float, default=0.75,
权重因子, 用以解决类别不平衡.
... | code_fim | hard | {
"lang": "python",
"repo": "sun1638650145/RetinaNet",
"path": "/RetinaNet/losses/focal_loss.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: micahjsmith/dengue_prediction path: /dengue_prediction/tests/test_input_type_transformers.py
import unittest
import numpy as np
import pandas as pd
from dengue_prediction.models.input_type_transforms import (
FeatureTypeTransformer, TargetTypeTransformer)
from dengue_prediction.tests.util i... | code_fim | hard | {
"lang": "python",
"repo": "micahjsmith/dengue_prediction",
"path": "/dengue_prediction/tests/test_input_type_transformers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with seeded(5):
x_pd = pd.util.testing.makeDataFrame()
feature_type_transformer = FeatureTypeTransformer()
x = feature_type_transformer.fit_transform(x_pd)
# output should be nx2 np.ndarray
self.assertTrue(isinstance(x, np.ndarray))
self.assertE... | code_fim | medium | {
"lang": "python",
"repo": "micahjsmith/dengue_prediction",
"path": "/dengue_prediction/tests/test_input_type_transformers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoranAngevaare/dddm path: /dddm/samplers/nestle.py
from __future__ import absolute_import, unicode_literals
import datetime
import json
import os
import shutil
import numpy as np
import dddm
from .pymultinest import MultiNestSampler, multinest_corner, convert_dic_to_savable
log = dddm.utils.log
... | code_fim | hard | {
"lang": "python",
"repo": "JoranAngevaare/dddm",
"path": "/dddm/samplers/nestle.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_nestle_samples_from_file(load_dir):
log.info(f'load_nestle_samples::\tloading {load_dir}')
keys = ['config', 'res_dict', 'h', 'logl', 'logvol', 'logz', 'logzerr',
'ncall', 'niter', 'samples', 'weights', 'weighted_samples']
result = {}
files_in_dir = os.listdir(load_di... | code_fim | hard | {
"lang": "python",
"repo": "JoranAngevaare/dddm",
"path": "/dddm/samplers/nestle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wfriesen/diceware path: /diceware.py
import random
import sys
def generatekey():
rng = random.SystemRandom()
return ''.join([str(rng.randint(1, 6)) for i in range(5)])
<|fim_suffix|> try:
number_of_words = int(sys.argv[1])
except (ValueError, IndexError):
print('... | code_fim | hard | {
"lang": "python",
"repo": "wfriesen/diceware",
"path": "/diceware.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(generatephrase(number_of_words))
if __name__ == "__main__":
main()<|fim_prefix|># repo: wfriesen/diceware path: /diceware.py
import random
import sys
def generatekey():
rng = random.SystemRandom()
return ''.join([str(rng.randint(1, 6)) for i in range(5)])
<|fim_middle|>
def gene... | code_fim | hard | {
"lang": "python",
"repo": "wfriesen/diceware",
"path": "/diceware.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
number_of_words = int(sys.argv[1])
except (ValueError, IndexError):
print('Usage: python diceware.py NUMBER_OF_WORDS')
sys.exit(1)
print(generatephrase(number_of_words))
if __name__ == "__main__":
main()<|fim_prefix|># repo: wfriesen/diceware path: /diceware... | code_fim | medium | {
"lang": "python",
"repo": "wfriesen/diceware",
"path": "/diceware.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getEvent(self, index):
event = self._events[index]
if event[0] == "status":
return StatusEvent(*event)<|fim_prefix|># repo: freeekanayaka/testlogging path: /testlogging/testing.py
from collections import namedtuple
from testtools.testresult.doubles import StreamResult... | code_fim | easy | {
"lang": "python",
"repo": "freeekanayaka/testlogging",
"path": "/testlogging/testing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: freeekanayaka/testlogging path: /testlogging/testing.py
from collections import namedtuple
from testtools.testresult.doubles import StreamResult
StatusEvent = namedtuple(
"StatusEvent", [
"name", "test_id", "test_status", "test_tags", "runnable", "file_name",
"file_bytes", "... | code_fim | easy | {
"lang": "python",
"repo": "freeekanayaka/testlogging",
"path": "/testlogging/testing.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.