text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: UCL/SUMMIT-blood-samples path: /summit_blood_samples/blood_sample/report_views.py
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db import connection
from django.http import JsonResponse
from django.views import View
class FinalStateChar... | code_fim | hard | {
"lang": "python",
"repo": "UCL/SUMMIT-blood-samples",
"path": "/summit_blood_samples/blood_sample/report_views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Class for getting unresolved records by day wise
"""
def get(self, request, *args, **kwargs):
"""
Method to get the unresolved records by day wise
:param request: request object
:return: JsonResponse object
"""
query = '''
SE... | code_fim | hard | {
"lang": "python",
"repo": "UCL/SUMMIT-blood-samples",
"path": "/summit_blood_samples/blood_sample/report_views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>exclude_patterns = []
# Theme
sys.path.append(os.path.abspath('_themes'))
html_theme_path = ['_themes', ]
html_static_path = ['_static', ]
html_theme = 'kr'
html_sidebars = {
'index': ['sidebar_intro.html', 'localtoc.html', 'relations.html',
'sourcelink.html', 'searchbox.html'],
... | code_fim | hard | {
"lang": "python",
"repo": "inirudebwoy/Flask-HAL",
"path": "/docs/conf.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inirudebwoy/Flask-HAL path: /docs/conf.py
# -*- coding: utf-8 -*-
# Standard Libs
import datetime
import os
import sys
# Add flask_hal to the Path
root = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..',
)
)
<|fim_suffix|>extensions = [
'sphinx.ext.aut... | code_fim | hard | {
"lang": "python",
"repo": "inirudebwoy/Flask-HAL",
"path": "/docs/conf.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qrebjock/fanok path: /tests/test_selection.py
import pytest
import numpy as np
from fanok.selection import adaptive_significance_threshold
<|fim_suffix|> w = np.array(w)
threshold = adaptive_significance_threshold(w, q, offset=offset)
assert threshold == expected<|fim_middle|>
@pyte... | code_fim | hard | {
"lang": "python",
"repo": "qrebjock/fanok",
"path": "/tests/test_selection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> w = np.array(w)
threshold = adaptive_significance_threshold(w, q, offset=offset)
assert threshold == expected<|fim_prefix|># repo: qrebjock/fanok path: /tests/test_selection.py
import pytest
import numpy as np
from fanok.selection import adaptive_significance_threshold
<|fim_middle|>@pyte... | code_fim | hard | {
"lang": "python",
"repo": "qrebjock/fanok",
"path": "/tests/test_selection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>100
63 25 73 1 98 73 56 84 86 57 16 83 8 25 81 56 9 53 98 67 99 12 83 89 80 91
39 86 76 85 74 39 25 90 59 10 94 32 44 3 89 30 27 79 46 96 27 32 18 21 92 69
81 40 40 34 68 78 24 87 42 69 23 41 78 22 6 90 99 89 50 30 20 1 43 3 70 95
33 46 44 9 69 48 33 60 65 16 82 67 61 32 21 79 75 75 13 87 70 33
Sample Out... | code_fim | medium | {
"lang": "python",
"repo": "spradeepv/dive-into-python",
"path": "/hackerrank/domain/algorithms/sorting/countingsort-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Hint: There is no need to sort the data, you just need to count it.
Input Format
There will be two lines of input:
n - the size of the list
ar - n space-separated numbers that make up the list
Output Format
Output the number of times every number from 0 to 99 (inclusive) appears on
the list.
Constraint... | code_fim | hard | {
"lang": "python",
"repo": "spradeepv/dive-into-python",
"path": "/hackerrank/domain/algorithms/sorting/countingsort-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spradeepv/dive-into-python path: /hackerrank/domain/algorithms/sorting/countingsort-1.py
"""
Problem Statement
Comparison Sorting
Quicksort usually has a running time of n*log(n), but is there an algorithm
that can sort even faster? In general, this is not possible. Most sorting
algorithms are c... | code_fim | hard | {
"lang": "python",
"repo": "spradeepv/dive-into-python",
"path": "/hackerrank/domain/algorithms/sorting/countingsort-1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Writes the dataset's name, number of rows, and variables into a csv file for frontend
if results is not None:
f = open(output_dir + "/outputDatamart.csv", 'w+')
for result in results:
f.write("\"")
f.write(result.get_json_metadata()['metadata']['name'])
f.write("\"")
f.write(... | code_fim | hard | {
"lang": "python",
"repo": "TuftsVALT/snowcat",
"path": "/node_middleware/socket_listeners/controllers/datamart_nyu/search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TuftsVALT/snowcat path: /node_middleware/socket_listeners/controllers/datamart_nyu/search.py
from d3m import container
import datamart
import datamart_rest
import csv
import sys
import os
import json
import shutil
searchInput = str(sys.argv[1])
augmentSelect = str(sys.argv[2])
index = int(sys.ar... | code_fim | hard | {
"lang": "python",
"repo": "TuftsVALT/snowcat",
"path": "/node_middleware/socket_listeners/controllers/datamart_nyu/search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cbbbbbbbb/sspywork path: /savecode/threeyears/idownclient/spider/spidersocial/spidermessenger/messengerbase.py
"""messenger base"""
# -*- coding:utf-8 -*-
import ast
import re
import threading
import traceback
from datetime import datetime
from commonbaby.helpers import helper_num, helper_str
... | code_fim | hard | {
"lang": "python",
"repo": "cbbbbbbbb/sspywork",
"path": "/savecode/threeyears/idownclient/spider/spidersocial/spidermessenger/messengerbase.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 处理联系人的相关参数(要返回fb联系人和会话)
self.fb_contact_id = [] # 保存会话中的联系人是fb好友时的id,用来判断messenger会话对象是否为好友
self.messenger_thread_id = [] # 保存messenger会话id,用于去重
self.is_get_chatlog = False # 是否拉取聊天记录的标志。一开始返回fb联系人的时候不用拉(因为返回的都是没聊过天的)
# 缓存所有init页面里的资源js脚本,,用于查找各种docid
... | code_fim | hard | {
"lang": "python",
"repo": "cbbbbbbbb/sspywork",
"path": "/savecode/threeyears/idownclient/spider/spidersocial/spidermessenger/messengerbase.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std_str = io.StringIO()
with redirect_stdout(std_str):
try:
handler_package = '.'.join(handler_name.split('.')[:-1])
method_name = handler_name.split('.')[-1]
module = importlib.import_module(handler_package)
handler_method = getattr(module, ... | code_fim | medium | {
"lang": "python",
"repo": "hubaimaster/aws-interface",
"path": "/aws_interface/resource/standalone/__aws_interface_stand_alone_physical_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hubaimaster/aws-interface path: /aws_interface/resource/standalone/__aws_interface_stand_alone_physical_handler.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import importlib
import time
import traceback
import io
from contextlib import redirect_stdout
# AWS Lambda handler [Stand Alone]
def ma... | code_fim | hard | {
"lang": "python",
"repo": "hubaimaster/aws-interface",
"path": "/aws_interface/resource/standalone/__aws_interface_stand_alone_physical_handler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> maze = np.zeros((row + 3, column + 2))
# print(maze)
for i in range(len(data)):
y = math.floor(data[i][2])
x = math.floor(data[i][1])
maze[y + 1][x + 1] = 1
# print(maze)
return maze<|fim_prefix|># repo: QUAFFquaff/Warehouse-Navigation-Application path: /algori... | code_fim | medium | {
"lang": "python",
"repo": "QUAFFquaff/Warehouse-Navigation-Application",
"path": "/algorithm/MakeMaze.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QUAFFquaff/Warehouse-Navigation-Application path: /algorithm/MakeMaze.py
import numpy as np
import math
def make_maze(data):
<|fim_suffix|> maze = np.zeros((row + 3, column + 2))
# print(maze)
for i in range(len(data)):
y = math.floor(data[i][2])
x = math.floor(data[i... | code_fim | medium | {
"lang": "python",
"repo": "QUAFFquaff/Warehouse-Navigation-Application",
"path": "/algorithm/MakeMaze.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def BasisSurface(self, *args):
"""
:rtype: Handle_Adaptor3d_HSurface
"""
return _Adaptor3d.Adaptor3d_HSurface_BasisSurface(self, *args)
def OffsetValue(self, *args):
"""
:rtype: float
"""
return _Adaptor3d.Adaptor3d_HSurface_Offset... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/step_to_stl/OCC/Adaptor3d.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmcbrayer/lambda_converters path: /app/step_to_stl/OCC/Adaptor3d.py
urve(*args))
def Load(self, *args):
"""
* Changes the curve. The Offset is reset to 0.
:param S:
:type S: Handle_Adaptor2d_HCurve2d &
:rtype: None
* Changes the Offset on the ... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/step_to_stl/OCC/Adaptor3d.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def Adaptor3d_HSurfaceTool_IsUPeriodic(*args):
"""
:param S:
:type S: Handle_Adaptor3d_HSurface &
:rtype: bool
"""
return _Adaptor3d.Adaptor3d_HSurfaceTool_IsUPeriodic(*args)
def Adaptor3d_HSurfaceTool_UPeriod(*args):
"""
:param S:
:type S: Handle_Adaptor3d_HSurface &
:... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/step_to_stl/OCC/Adaptor3d.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: russmatney/unicode-classification-engine path: /features/clusters.py
import re
from constants import *
def consonant_clusters(word):
return clusters(CONSONANTS_REGEX, word)
def obstruent_clusters(word):
<|fim_suffix|>#Slightly different algorithm
def vowel_clusters(word):
set = re.split(CON... | code_fim | medium | {
"lang": "python",
"repo": "russmatney/unicode-classification-engine",
"path": "/features/clusters.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return clusters(OBSTRUENT_REGEX, word)
def clusters(regex, word):
regex = ur'[' + regex + '][' + regex + ']+'
set = re.findall(regex, word, re.UNICODE)
return len(set)
#Slightly different algorithm
def vowel_clusters(word):
set = re.split(CONSONANTS_REGEX, word, re.UNICODE)
vowel_set = [v fo... | code_fim | easy | {
"lang": "python",
"repo": "russmatney/unicode-classification-engine",
"path": "/features/clusters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bayhiker/names path: /setup.py
import names
from setuptools import setup, find_packages
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('CHANGES.rst') as changes_file:
changes = changes_file.read()
<|fim_suffix|>
setup(
name=names.__title__,
versi... | code_fim | medium | {
"lang": "python",
"repo": "bayhiker/names",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
setup(
name=names.__title__,
version=names.__version__,
author=names.__author__,
url="https://github.com/treyhunner/names",
description="Generate random names",
long_description='\n\n'.join((
readme,
changes,
contributing,
)),
license=names.__licens... | code_fim | medium | {
"lang": "python",
"repo": "bayhiker/names",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>setup(
name=names.__title__,
version=names.__version__,
author=names.__author__,
url="https://github.com/treyhunner/names",
description="Generate random names",
long_description='\n\n'.join((
readme,
changes,
contributing,
)),
license=names.__license... | code_fim | medium | {
"lang": "python",
"repo": "bayhiker/names",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add_input_channels_for_conv_node(self, conv, ocs_channels_idxs):
p_node = nu.get_node_input(conv, 0)
nodes = self.get_absorbing_nodes(p_node)
if nodes is None:
return False
for node in nodes:
if node.type == 'Convolution':
w... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/pot/openvino/tools/pot/algorithms/quantization/outlier_channel_splitting/algorithm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/openvino path: /tools/pot/openvino/tools/pot/algorithms/quantization/outlier_channel_splitting/algorithm.py
# Copyright (C) 2020-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from ...algorithm import Algorithm
from ...algorithm_selector import C... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/pot/openvino/tools/pot/algorithms/quantization/outlier_channel_splitting/algorithm.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.demonym:
return self.demonym
return self.name
def get_set_name(self, family=4):
return 'fds-{}-{}'.format(self.code.lower(), family)<|fim_prefix|># repo: dvershinin/fds path: /fds/Country.py
from __future__ import unicode_literals
from builtins import ch... | code_fim | hard | {
"lang": "python",
"repo": "dvershinin/fds",
"path": "/fds/Country.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dvershinin/fds path: /fds/Country.py
from __future__ import unicode_literals
from builtins import chr
class Country:
OFFSET = 127462 - ord('A')
def getFlag(self):
code = self.code
if code:
return chr(ord(code[0]) + Country.OFFSET) + chr(ord(code[1]) + Count... | code_fim | medium | {
"lang": "python",
"repo": "dvershinin/fds",
"path": "/fds/Country.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zziz/3D-Human-Body-Shape path: /src/body_utils.py
ime() - start))
return [vertex, mean_vertex, std_vertex, file_list]
# convert cp from txt to npy
def convert_cp():
print(' [**] begin load_cp ... ')
start = time.time()
f = open(os.path.join(DATA_DIR, 'body_control_points.txt'), "... | code_fim | hard | {
"lang": "python",
"repo": "zziz/3D-Human-Body-Shape",
"path": "/src/body_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zziz/3D-Human-Body-Shape path: /src/body_utils.py
ormals
# load facet information from txt file
def convert_template():
facet = np.zeros((F_NUM, 3), dtype=int)
f = open(os.path.join(DATA_DIR, 'template.txt'), 'r')
i = 0
for line in f:
if line[0] == 'f':
tmp = ... | code_fim | hard | {
"lang": "python",
"repo": "zziz/3D-Human-Body-Shape",
"path": "/src/body_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> d_coeff = np.dot(d_basis.transpose(), d)
d_pca_mean = np.array(np.mean(d_coeff, axis=1))
d_pca_mean.shape = (d_pca_mean.size, 1)
d_pca_std = np.array(np.std(d_coeff, axis=1))
d_pca_std.shape = (d_pca_std.size, 1)
np.save(open(os.path.join(DATA_DIR, "%s_d_basis.npy"%label), "wb"), ... | code_fim | hard | {
"lang": "python",
"repo": "zziz/3D-Human-Body-Shape",
"path": "/src/body_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
digits = [9, 9, 9, 9]
solution = Solution()
result = solution.plusOne(digits)
print(result)<|fim_prefix|># repo: lemonnader/LeetCode-Solution-Well-Formed path: /math/Python/0066-加一.py
# 66. 加一
# 给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。
#
# 最高位数字存放在数组的首位, 数组中每个元素只存储一个数... | code_fim | hard | {
"lang": "python",
"repo": "lemonnader/LeetCode-Solution-Well-Formed",
"path": "/math/Python/0066-加一.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(digits) == 0:
return []
# 进位标识
carry = 1
for i in range(len(digits) - 1, -1, -1):
s = digits[i] + carry
digits[i] = s % 10
# 注意:整除要使用 //
carry = s // 10
if carry == 0:
return d... | code_fim | medium | {
"lang": "python",
"repo": "lemonnader/LeetCode-Solution-Well-Formed",
"path": "/math/Python/0066-加一.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lemonnader/LeetCode-Solution-Well-Formed path: /math/Python/0066-加一.py
# 66. 加一
# 给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。
#
# 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。
#
# 你可以假设除了整数 0 之外,这个整数不会以零开头。
class Solution(object):
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype... | code_fim | medium | {
"lang": "python",
"repo": "lemonnader/LeetCode-Solution-Well-Formed",
"path": "/math/Python/0066-加一.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_pick.py
#calss header
class _PICK():
def __init__(self,):
self.name = "PICK"
self.definitions = [u'choice: ', u'to have a large choice available: ', u'to choose the one(s) you want from the different types available: ', u'a pickaxe : ', u'esp... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_pick.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MwinyiMoha/books-service path: /books/models.py
from datetime import timedelta
from decimal import Decimal
from django.contrib.auth import get_user_model
from django.core.validators import MinValueValidator
from django.db import models
from core.models import BaseModel
User = get_user_model()
... | code_fim | hard | {
"lang": "python",
"repo": "MwinyiMoha/books-service",
"path": "/books/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.title
def save(self, *args, **kwargs):
if (
self.category == self.TYPE_NOVEL
or self.category == self.TYPE_REGULAR
):
self.price = 1.5
else:
self.price = 3.0
super(Book, self).save(*args, **kwargs)
... | code_fim | hard | {
"lang": "python",
"repo": "MwinyiMoha/books-service",
"path": "/books/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def calculate_charge(self, no_of_days):
charge = None
if self.category == self.TYPE_FICTION:
charge = self.price * no_of_days
elif self.category == self.TYPE_REGULAR:
min_charge = 2.0
if no_of_days <= 2:
charge = min_charge
... | code_fim | hard | {
"lang": "python",
"repo": "MwinyiMoha/books-service",
"path": "/books/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ethereum/tests path: /src/EIPTestsFiller/Pyspecs/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py
"""
abstract: Tests beacon block root for [EIP-4788: Beacon block root in the EVM](https://eips.ethereum.org/EIPS/eip-4788)
Test the exposed beacon chain root in the EVM for [EIP-4... | code_fim | hard | {
"lang": "python",
"repo": "ethereum/tests",
"path": "/src/EIPTestsFiller/Pyspecs/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.parametrize(
"timestamps",
[pytest.param(count(start=1000, step=1000), id="fork_transition")],
)
@pytest.mark.parametrize("block_count", [20])
@pytest.mark.valid_at_transition_to("Cancun")
def test_beacon_root_transition_test(
blockchain_test: BlockchainTestFiller,
timestamps... | code_fim | hard | {
"lang": "python",
"repo": "ethereum/tests",
"path": "/src/EIPTestsFiller/Pyspecs/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> actor = d.pop("actor", UNSET)
actee = d.pop("actee", UNSET)
action = d.pop("action", UNSET)
value = d.pop("value", UNSET)
time = d.pop("time", UNSET)
audit = cls(
id=id,
actor=actor,
actee=actee,
action=ac... | code_fim | hard | {
"lang": "python",
"repo": "Nadybot/nadypy",
"path": "/nadypy/models/audit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nadybot/nadypy path: /nadypy/models/audit.py
from typing import Any, Dict, List, Type, TypeVar, Union
import attr
from ..types import UNSET, Unset
T = TypeVar("T", bound="Audit")
@attr.s(auto_attribs=True)
class Audit:
""" """
id: Union[Unset, int] = UNSET
actor: Union[Unset, st... | code_fim | hard | {
"lang": "python",
"repo": "Nadybot/nadypy",
"path": "/nadypy/models/audit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> audit = cls(
id=id,
actor=actor,
actee=actee,
action=action,
value=value,
time=time,
)
audit.additional_properties = d
return audit
@property
def additional_keys(self) -> List[str]:
re... | code_fim | hard | {
"lang": "python",
"repo": "Nadybot/nadypy",
"path": "/nadypy/models/audit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> id: Optional[int] = None
name: Optional[str] = None
content: Optional[str] = None
foo = FooData(id=1, name='val', content='stuff')
data = serialize_to_protobuf(foo, Foo, for_dict=False)
assert data.id == 1
assert data.name == 'val'
assert data.content.value ==... | code_fim | hard | {
"lang": "python",
"repo": "trusttoken/protobuf-serialization-py",
"path": "/protobuf_serialization/tests/test_serialize_to_protobuf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trusttoken/protobuf-serialization-py path: /protobuf_serialization/tests/test_serialize_to_protobuf.py
from typing import Optional
from dataclasses import dataclass
import functools
import pytest
from protobuf_serialization.tests.utils import utcnow
from protobuf_serialization.tests.compiled.ex... | code_fim | hard | {
"lang": "python",
"repo": "trusttoken/protobuf-serialization-py",
"path": "/protobuf_serialization/tests/test_serialize_to_protobuf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: happytk/wagtail-grapple path: /example/home/blocks.py
from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock
from grapple.helpers import register_streamfield_block
from grapple.models import GraphQLForeignKey, GraphQLImage, GraphQLString, GraphQLCollection
from wagt... | code_fim | hard | {
"lang": "python",
"repo": "happytk/wagtail-grapple",
"path": "/example/home/blocks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> min_num = 2
max_num = 15
@register_streamfield_block
class ImageGalleryBlock(blocks.StructBlock):
title = blocks.CharBlock(classname="full title")
images = ImageGalleryImages()
graphql_fields = [
GraphQLString("title"),
GraphQLCollection(
GraphQLF... | code_fim | medium | {
"lang": "python",
"repo": "happytk/wagtail-grapple",
"path": "/example/home/blocks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Learns NTF model
Parameters
----------
X : ndarray with nonnegative entries
The input array
W : ndarray
Optional ndarray that can be broadcasted with X and
gives weights to apply on the cost function
"""
eps =... | code_fim | hard | {
"lang": "python",
"repo": "ANR-kamoulox/denoise-alphamf",
"path": "/code/modules/beta_ntf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ANR-kamoulox/denoise-alphamf path: /code/modules/beta_ntf.py
# -*- coding: utf-8 -*-
"""
Copyright © 2012 Telecom ParisTech, TSI
Auteur(s) : Liutkus Antoine
the beta_ntf module is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as p... | code_fim | hard | {
"lang": "python",
"repo": "ANR-kamoulox/denoise-alphamf",
"path": "/code/modules/beta_ntf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
X : array
The input data
Returns
-------
out : float
The beta-divergence
"""
return _betadiv(X, parafac(self.factors_), self.beta).sum()
def __getitem__(self, key):
"""gets NTF model... | code_fim | hard | {
"lang": "python",
"repo": "ANR-kamoulox/denoise-alphamf",
"path": "/code/modules/beta_ntf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> exp = self.exp.execute(environment)
operator = self.operator
try:
if operator == "ISNULL":
value = exp.value == None
elif operator == "NOTNULL":
value = exp.value != None
elif operator == "ISTRUE":
... | code_fim | hard | {
"lang": "python",
"repo": "joorgej/tytus",
"path": "/parser/team29/analizer/statement/operations/unary/relational.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute(self, environment):
exp = self.exp.execute(environment)
operator = self.operator
try:
if operator == "ISNULL":
value = exp.value == None
elif operator == "NOTNULL":
value = exp.value != None
elif op... | code_fim | hard | {
"lang": "python",
"repo": "joorgej/tytus",
"path": "/parser/team29/analizer/statement/operations/unary/relational.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joorgej/tytus path: /parser/team29/analizer/statement/operations/unary/relational.py
from analizer.abstract.expression import Expression, TYPE, comps
from analizer.abstract import expression
from analizer.reports import Nodo
from analizer.statement.expressions import primitive
class Relational(... | code_fim | hard | {
"lang": "python",
"repo": "joorgej/tytus",
"path": "/parser/team29/analizer/statement/operations/unary/relational.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uob-vil/TRN-pytorch path: /transforms.py
import torch
class FlipChannels:
"""Converts a :math:`(C, T, H, W)` tensor from BGR to RGB or vica versa"""
<|fim_suffix|> return torch.flip(frames, (0,))<|fim_middle|> def __call__(self, frames: torch.Tensor) -> torch.Tensor:
| code_fim | medium | {
"lang": "python",
"repo": "uob-vil/TRN-pytorch",
"path": "/transforms.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return torch.flip(frames, (0,))<|fim_prefix|># repo: uob-vil/TRN-pytorch path: /transforms.py
import torch
class FlipChannels:
"""Converts a :math:`(C, T, H, W)` tensor from BGR to RGB or vica versa"""
<|fim_middle|> def __call__(self, frames: torch.Tensor) -> torch.Tensor:
| code_fim | medium | {
"lang": "python",
"repo": "uob-vil/TRN-pytorch",
"path": "/transforms.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __call__(self, frames: torch.Tensor) -> torch.Tensor:
return torch.flip(frames, (0,))<|fim_prefix|># repo: uob-vil/TRN-pytorch path: /transforms.py
import torch
class FlipChannels:
<|fim_middle|> """Converts a :math:`(C, T, H, W)` tensor from BGR to RGB or vica versa"""
| code_fim | medium | {
"lang": "python",
"repo": "uob-vil/TRN-pytorch",
"path": "/transforms.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: genuss/check_nginx_upstreams path: /check_nginx_upstreams.py
#!/usr/bin/env python
# coding=utf-8
import argparse
import json
from urllib2 import urlopen
from nagiosplugin import ScalarContext, Metric, guarded, Check, Resource
class NginxUpstreams(Resource):
def __init__(self, status, up... | code_fim | hard | {
"lang": "python",
"repo": "genuss/check_nginx_upstreams",
"path": "/check_nginx_upstreams.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser(
description='Check nginx upstreams via nginx_upstream_check_module'
)
parser.add_argument('-u', '--url', required=True,
help='url to check (output must be json-formatted)')
parser.add_argument('-c', '--critical', default=49,... | code_fim | hard | {
"lang": "python",
"repo": "genuss/check_nginx_upstreams",
"path": "/check_nginx_upstreams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@guarded
def main():
parser = argparse.ArgumentParser(
description='Check nginx upstreams via nginx_upstream_check_module'
)
parser.add_argument('-u', '--url', required=True,
help='url to check (output must be json-formatted)')
parser.add_argument('-c', '--c... | code_fim | hard | {
"lang": "python",
"repo": "genuss/check_nginx_upstreams",
"path": "/check_nginx_upstreams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LinearDecoder(Decoder):
# Linear Decoder.
def __init__(self, args):
super(LinearDecoder, self).__init__()
layers = [Linear(2 * args.dim, args.n_classes, args.dropout, lambda x: x, args.bias)]
self.cls = nn.Sequential(*layers)
self.decode_adj = False
model2... | code_fim | hard | {
"lang": "python",
"repo": "HestiaSky/GNN-MTL",
"path": "/models/decoders.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.decode_adj:
input = (x, adj)
probs, _ = self.cls.forward(input)
else:
probs = self.cls.forward(x)
return probs
class GCNDecoder(Decoder):
# Graph Convolution Decoder.
def __init__(self, args):
super(GCNDecoder, self).__... | code_fim | hard | {
"lang": "python",
"repo": "HestiaSky/GNN-MTL",
"path": "/models/decoders.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HestiaSky/GNN-MTL path: /models/decoders.py
"""Graph decoders."""
from layers.att_layers import GraphAttentionLayer
from layers.layers import *
class Decoder(nn.Module):
# Decoder abstract class for node classification tasks.
def __init__(self):
super(Decoder, self).__init__()
... | code_fim | hard | {
"lang": "python",
"repo": "HestiaSky/GNN-MTL",
"path": "/models/decoders.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mushkevych/scheduler path: /db/dao/site_dao.py
__author__ = 'Bohdan Mushkevych'
from threading import RLock
from bson import ObjectId
from db.model.site_statistics import SiteStatistics, DOMAIN_NAME, TIMEPERIOD
from synergy.db.manager import ds_manager
from synergy.system.decorator import thre... | code_fim | hard | {
"lang": "python",
"repo": "mushkevych/scheduler",
"path": "/db/dao/site_dao.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @thread_safe
def update(self, collection_name, instance):
""" method finds Site Statistics record and update it DB representation """
assert isinstance(instance, SiteStatistics)
if instance.db_id:
query = {'_id': ObjectId(instance.db_id)}
else:
... | code_fim | hard | {
"lang": "python",
"repo": "mushkevych/scheduler",
"path": "/db/dao/site_dao.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ inserts a unit of work into MongoDB. """
assert isinstance(instance, SiteStatistics)
collection = self.ds.connection(collection_name)
return collection.insert_one(instance.document).inserted_id
@thread_safe
def remove(self, collection_name, domain_name, timeper... | code_fim | hard | {
"lang": "python",
"repo": "mushkevych/scheduler",
"path": "/db/dao/site_dao.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thoughtspot/community-tools path: /generate_deletes/delete_records.py
#!/usr/bin/env python
"""
Copyright 2017 ThoughtSpot
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 ... | code_fim | hard | {
"lang": "python",
"repo": "thoughtspot/community-tools",
"path": "/generate_deletes/delete_records.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Reads the table descriptions from the database schema and populates the descriptions.
WARNING: This depends on the format of tql output not changing.
:param args: Command line arguments.
"""
table_list = check_output(
'echo "show tables %s;" | tql' % args.database, sh... | code_fim | hard | {
"lang": "python",
"repo": "thoughtspot/community-tools",
"path": "/generate_deletes/delete_records.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Creates and executes the delete statements from from the values file.
:param args: Command line arguments.
"""
start = time.time()
nbr_deletes = 0
# get the column descriptions.
columns = descriptions.get(args.schema, {}).get(args.table, None)
if columns is None:
... | code_fim | hard | {
"lang": "python",
"repo": "thoughtspot/community-tools",
"path": "/generate_deletes/delete_records.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: renatodev95/Python path: /aprendizado/curso_em_video/desafios/desafio018.py
from math import sin, cos, tan, radians
angulo = float(input('Digite um ângulo: '))
seno = sin(radia<|fim_suffix|>° tem o seno de {:0.2f}'.format(angulo, seno))
print('O ângulo de {:.1f}° tem o coseno de {:0.2f}'.forma... | code_fim | medium | {
"lang": "python",
"repo": "renatodev95/Python",
"path": "/aprendizado/curso_em_video/desafios/desafio018.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>° tem o seno de {:0.2f}'.format(angulo, seno))
print('O ângulo de {:.1f}° tem o coseno de {:0.2f}'.format(angulo, cosseno))
print('O ângulo de {:.1f}° tem a tangente de {:0.2f}'.format(angulo, tangente))<|fim_prefix|># repo: renatodev95/Python path: /aprendizado/curso_em_video/desafios/desafio018.py
fr... | code_fim | medium | {
"lang": "python",
"repo": "renatodev95/Python",
"path": "/aprendizado/curso_em_video/desafios/desafio018.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># y = threading.Thread(target=func, args=(10, 2))
# y.start()#start 2 threads
# threadL = []
# for i in range(1,10):
# if (i%2 != 0):
# x = threading.Thread(target=func, args=(10,1, i))
# else:
# x = threading.Thread(target=func2, args=(10, 2, i))
# x.start()
# threa... | code_fim | hard | {
"lang": "python",
"repo": "118020071/bilibili_scrapper",
"path": "/by_api/multiThread.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 118020071/bilibili_scrapper path: /by_api/multiThread.py
#!/usr/bin/env python
#-*- coding: utf8 -*-
import sys
import time
import string
import threading
import datetime
## Try 1
# def func(y):
# print('round 1, 1s sleep', y)
# time.sleep(1)
# print('done')
# x = threading.Threa... | code_fim | hard | {
"lang": "python",
"repo": "118020071/bilibili_scrapper",
"path": "/by_api/multiThread.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(outname, "w") as out:
for source in list:
out.write("j2000; circle " + str(phot_utils.convertRA(source.ra)) + "," +
str(phot_utils.convertDEC(source.dec)) + " .1' #color=red \n")<|fim_prefix|># repo: SAGES-UCSC/Photometry path: /makeRegionFile.py
... | code_fim | medium | {
"lang": "python",
"repo": "SAGES-UCSC/Photometry",
"path": "/makeRegionFile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SAGES-UCSC/Photometry path: /makeRegionFile.py
'''
A program to turn a SCAMSources into a ds9 region files.
'''
import phot_utils
import Sources
<|fim_suffix|> with open(outname, "w") as out:
for source in list:
out.write("j2000; circle " + str(phot_utils.convertRA(source... | code_fim | hard | {
"lang": "python",
"repo": "SAGES-UCSC/Photometry",
"path": "/makeRegionFile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def file_search_in_folder(name, dir):
files = os.listdir(dir)
for f in files:
if name in f:
return True
return False
def read_early_dataset_fgnet(name="fgnet"):
dataset_dir = path_constants.IMAGES[name]
paths = []
ages = []
for root, __dirs, files in os.wal... | code_fim | hard | {
"lang": "python",
"repo": "torchipeppo/C3AE-tf2",
"path": "/master/dataprocessing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dataset_dir = path_constants.IMAGES[name]
paths = []
ages = []
for root, __dirs, files in os.walk(dataset_dir):
for fname in files:
if ".jpg" not in fname: continue
m = re.match(r'^([\d]+).*$', fname)
age = int(m.group(1))
path = os.p... | code_fim | hard | {
"lang": "python",
"repo": "torchipeppo/C3AE-tf2",
"path": "/master/dataprocessing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: torchipeppo/C3AE-tf2 path: /master/dataprocessing.py
'''
questo modulo andrà chiamato una volta sola
e trasforma il dataset di immagini
in dataframe con tutte le info
'''
import numpy as np
import pandas as pd
import tensorflow as tf
from cv2 import cv2 # for visual studio code
import pickle
i... | code_fim | hard | {
"lang": "python",
"repo": "torchipeppo/C3AE-tf2",
"path": "/master/dataprocessing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def transform(self, graphs):
x = graph_embedding(
graphs,
feature_embeddings=self.feature_embeddings,
encoding_func=self.encoding_func,
importance_dict=self.importance_dict,
intercept=self.intercept)
return x
def embed2D(gra... | code_fim | hard | {
"lang": "python",
"repo": "smautner/EGO",
"path": "/ego/embed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smautner/EGO path: /ego/embed.py
#!/usr/bin/env python
"""Provides scikit interface."""
import numpy as np
import networkx as nx
from sklearn import manifold
from ego.vectorize import get_feature_dict
from ego.vectorize import set_feature_size
from ego.encode import make_encoder
import matplotli... | code_fim | hard | {
"lang": "python",
"repo": "smautner/EGO",
"path": "/ego/embed.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BBN-Q/QGL path: /tests/test_APS2Pattern.py
import unittest
import os
import pickle
import numpy as np
from copy import copy
from QGL import *
from QGL.drivers import APS2Pattern
class APSPatternUtils(unittest.TestCase):
def setUp(self):
self.cl = ChannelLibrary(":memory:")
... | code_fim | hard | {
"lang": "python",
"repo": "BBN-Q/QGL",
"path": "/tests/test_APS2Pattern.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #### QUBIT 1 ######################################################
#### Qubit 1 Instruments ##########################################
AM1 = self.cl.new_source("AutodyneM1",
"HolzworthHS9000",
"HS9004A-492-1",
... | code_fim | hard | {
"lang": "python",
"repo": "BBN-Q/QGL",
"path": "/tests/test_APS2Pattern.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ''' Generates every truncation of a number. '''
digits = str(prime)
for i in range(1, len(digits)):
yield int(digits[i:])
yield int(digits[:-i])
def truncatable_primes():
''' Finds the sum of the only eleven primes that are
both truncatable from left to right and right to left. '''
li... | code_fim | medium | {
"lang": "python",
"repo": "jwmcgettigan/project-euler-solutions",
"path": "/solutions/037/037.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwmcgettigan/project-euler-solutions path: /solutions/037/037.py
"""
Project Euler - Problem Solution 037
Problem Title - Truncatable primes
Copyright (c) Justin McGettigan. All rights reserved.
https://github.com/jwmcgettigan/project-euler-solutions
"""
def truncated_nums(prime):
''' Generate... | code_fim | hard | {
"lang": "python",
"repo": "jwmcgettigan/project-euler-solutions",
"path": "/solutions/037/037.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
# PARSE THE ARGS
parser = argparse.ArgumentParser(description='split generation')
parser.add_argument('-tr', '--training', default=1.0, type=float,
help='training data splitting proportion with test')
parser.add_argument('-te', '--test', ... | code_fim | hard | {
"lang": "python",
"repo": "xiaochengcike/Cross-Consistency-Prostate",
"path": "/data/split_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaochengcike/Cross-Consistency-Prostate path: /data/split_data.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
import warnings
import random
import argparse
from operator import itemgetter
class split_data_txt :
def __init__(self, split_tr, split_te, spl... | code_fim | hard | {
"lang": "python",
"repo": "xiaochengcike/Cross-Consistency-Prostate",
"path": "/data/split_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> action = self._file_actions.setdefault(path,
FileAction(path, log=self.log))
action.append(callback_wrapper, 'modified')
def watch_recursive(self, path, callback, path_filter=None):
dir_path = realPath(path)
if os.path.exi... | code_fim | hard | {
"lang": "python",
"repo": "joaduo/smoothtest",
"path": "/smoothtest/autotest/SourceWatcher.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Append new callback to the action's list of callbacks
If you add callbacks to a registered action, you need to re-watch the
action on the InotifyManager. (no need to remove)
:param callback: callback to call when an inotify event matches the event_type
... | code_fim | hard | {
"lang": "python",
"repo": "joaduo/smoothtest",
"path": "/smoothtest/autotest/SourceWatcher.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joaduo/smoothtest path: /smoothtest/autotest/SourceWatcher.py
# -*- coding: utf-8 -*-
'''
Smoothtest
Copyright (c) 2014 Juju. Inc
Code Licensed under MIT License. See LICENSE file.
'''
import rel_imp
rel_imp.init()
import os
from .base import AutoTestBase
from collections import defaultdict
from... | code_fim | hard | {
"lang": "python",
"repo": "joaduo/smoothtest",
"path": "/smoothtest/autotest/SourceWatcher.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhuxiangxiao/leetcode path: /2.Add Two Numbers.py
import json
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
<|fim_suffix|> ptr = dummyRoot.next
return ptr
def listNodeToString(... | code_fim | hard | {
"lang": "python",
"repo": "zhuxiangxiao/leetcode",
"path": "/2.Add Two Numbers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = ""
while node:
result += str(node.val) + ", "
node = node.next
return "[" + result[:-2] + "]"
l1=stringToListNode('[2,4,3]')
l2=stringToListNode('[2,4,3]')
print listNodeToString(Solution().addTwoNumbers(l1, l2))<|fim_prefix|># repo: zhuxiangxiao/leetcode path: /2.Ad... | code_fim | medium | {
"lang": "python",
"repo": "zhuxiangxiao/leetcode",
"path": "/2.Add Two Numbers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not node:
return "[]"
result = ""
while node:
result += str(node.val) + ", "
node = node.next
return "[" + result[:-2] + "]"
l1=stringToListNode('[2,4,3]')
l2=stringToListNode('[2,4,3]')
print listNodeToString(Solution().addTwoNumbers(l1, l2))<|fim_prefix|># re... | code_fim | hard | {
"lang": "python",
"repo": "zhuxiangxiao/leetcode",
"path": "/2.Add Two Numbers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rskonnord-plos/rhyno path: /rhyno/tests/api_test.py
from __future__ import absolute_import
import unittest
from ..api import Rhyno
API_HOST = 'https://webprod.plosjournals.org/api'
SHELL_HOST = 'iad-webprod-devstack01.int.plos.org'
TEST_PACKAGE_FILENAME = 'pone.0057000.zip'
TEST_PACKAGE_DOI = ... | code_fim | hard | {
"lang": "python",
"repo": "rskonnord-plos/rhyno",
"path": "/rhyno/tests/api_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.r.get_crossref_syndication_state(TEST_PACKAGE_DOI, verbose=True)
def test_syndicate_pmc(self):
self.r.syndicate_pmc(TEST_PACKAGE_DOI, verbose=True)
def test_syndicate_crossref(self):
self.r.syndicate_crossref(TEST_PACKAGE_DOI, verbose=True)
if __name__ ... | code_fim | medium | {
"lang": "python",
"repo": "rskonnord-plos/rhyno",
"path": "/rhyno/tests/api_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
model (nn.Module): The loaded segmentor.
img (str or np.ndarray): Image filename or loaded image.
result (SegDataSample): The prediction SegDataSample result.
opacity(float): Opacity of painted segmentation map.
Default 0.5. Must be in (0, 1] range.
... | code_fim | hard | {
"lang": "python",
"repo": "open-mmlab/mmsegmentation",
"path": "/mmseg/apis/inference.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: open-mmlab/mmsegmentation path: /mmseg/apis/inference.py
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
from collections import defaultdict
from pathlib import Path
from typing import Optional, Sequence, Union
import mmcv
import numpy as np
import torch
from mmengine import Conf... | code_fim | hard | {
"lang": "python",
"repo": "open-mmlab/mmsegmentation",
"path": "/mmseg/apis/inference.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def drive(self, carstate: State) -> Command:
# # NN_MODEL
# x_test = self.convert_carstate_to_array(carstate)
# predicted = self.nn_model(Variable(torch.from_numpy(x_test))).data.numpy()
#
# command = Command()
#
# command.accelerator = predicted... | code_fim | hard | {
"lang": "python",
"repo": "akashrajkn/ruimte-auto",
"path": "/torcs-client/my_driver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> command.accelerator = self.control[0]
command.brake = self.control[1]
command.steering = self.control[2]
return command
def convert_carstate_to_array(self, carstate):
'''
Convert the carstate to numpy array
'''
speed = carstate.speed_x
... | code_fim | hard | {
"lang": "python",
"repo": "akashrajkn/ruimte-auto",
"path": "/torcs-client/my_driver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akashrajkn/ruimte-auto path: /torcs-client/my_driver.py
import torch
import numpy as np
import dill as pickle
from torch.autograd import Variable
from pytocl.nn_linear_regression import LinearRegression
from pytocl.pyESN_for_TORCS import ESN
from pytocl.driver import Driver
from pytocl.car impo... | code_fim | hard | {
"lang": "python",
"repo": "akashrajkn/ruimte-auto",
"path": "/torcs-client/my_driver.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for visibility in vislist:
flagdata(vis=visibility, antenna=[ [RS508HBA, RS509HBA], [RS208HBA, RS509HBA], [CS302HBA0], [RS205HBA] ], mode='manual')
print "Finished flagging measurement sets. Enjoy!"<|fim_prefix|># repo: mpbusch/LOFAR-ForegroundGalaxyCollaboration path: /flagAntennas.py
# This short pro... | code_fim | easy | {
"lang": "python",
"repo": "mpbusch/LOFAR-ForegroundGalaxyCollaboration",
"path": "/flagAntennas.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.