text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> objs = json.loads(response[1])
try:
rid = str(o)
name = str(objs[0]["result"]["description"]["name"])
desc = str(objs[0]["result"]["description"])
basicinfo = str(objs[0]["result"]["basic"])
print ''
print '-----------------'
print 'Device Na... | code_fim | hard | {
"lang": "python",
"repo": "exosite-garage/utility_scripts",
"path": "/rpc_list_portal_clients.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: demisto/content path: /Packs/ThinkstCanary/Integrations/ThinkstCanary/ThinkstCanary_test.py
import demistomock as demisto
import pytest
MOCK_PARAMS = {
'access-key': 'fake_access_key',
'secret-key': 'fake_access_key',
'server': 'http://123-fake-api.com/',
'unsecure': True,
'p... | code_fim | hard | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/ThinkstCanary/Integrations/ThinkstCanary/ThinkstCanary_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Given: demisto params.
When: Running list_tokens_command.
Then: ensure the expected result returned.
"""
mocker.patch.object(demisto, 'results')
mocker.patch.object(demisto, 'params', return_value=MOCK_PARAMS)
import ThinkstCanary
mocker.patch.object(ThinkstCana... | code_fim | hard | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/ThinkstCanary/Integrations/ThinkstCanary/ThinkstCanary_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> import ThinkstCanary
mocker.patch.object(ThinkstCanary, 'http_request', return_value={'tokens': [{'canarytoken': 'CanaryToken',
'created_printable': 'CreatedTime',
... | code_fim | hard | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/ThinkstCanary/Integrations/ThinkstCanary/ThinkstCanary_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>router = SimpleRouter(trailing_slash=False)
router.register('roadmaps', RoadmapViewSet)<|fim_prefix|># repo: akabhi5/Website-API path: /v1/roadmap/urls.py
from rest_framework.routers import SimpleRouter
<|fim_middle|>from .views.roadmap import RoadmapViewSet
| code_fim | easy | {
"lang": "python",
"repo": "akabhi5/Website-API",
"path": "/v1/roadmap/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akabhi5/Website-API path: /v1/roadmap/urls.py
from rest_framework.routers import SimpleRouter
<|fim_suffix|>router = SimpleRouter(trailing_slash=False)
router.register('roadmaps', RoadmapViewSet)<|fim_middle|>from .views.roadmap import RoadmapViewSet
| code_fim | easy | {
"lang": "python",
"repo": "akabhi5/Website-API",
"path": "/v1/roadmap/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for call in ansible_roles.get_role_vars('sf_install'):
osVersion = node_os['family'] + node_os['distribution_major_version']
linux_install_defaults = json.loads(linux_defaults)['linux_install']
linux_tmp = call.get('linux_tmp', linux_tmp)
sf_version = call.get('sf_ver... | code_fim | hard | {
"lang": "python",
"repo": "mndarren/Code-Lib",
"path": "/Ansible_lib/role-software_install/tests/linux.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mndarren/Code-Lib path: /Ansible_lib/role-software_install/tests/linux.py
from testinfra.utils import ansible_roles
import pytest
import json
node_os = ansible_roles.get_node_os()
@pytest.mark.skipif(node_os['family'] != 'RedHat' and node_os['family'] != 'Suse', reason='RedHat/Suse only test')... | code_fim | hard | {
"lang": "python",
"repo": "mndarren/Code-Lib",
"path": "/Ansible_lib/role-software_install/tests/linux.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pkg = host.package(pkg)
assert pkg.is_installed
def test_vxdisk(self, host):
assert host.file('/opt/VRTS/bin/vxdisk').exists
def test_response_file(self, host):
assert host.file('%s/response_file' % self.linux_tmp)<|fim_prefix|># repo: mndarren/Code-Lib path: /An... | code_fim | hard | {
"lang": "python",
"repo": "mndarren/Code-Lib",
"path": "/Ansible_lib/role-software_install/tests/linux.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # load data
df = pd.read_csv("tmpData100/tmp" + str(i + 1) + ".csv")
dataset = np.array(df)
# choose 35 samples from whole 53 samples for training
X_train = dataset[:35,:-1]
# add the smote sample to the unbalanced dataset
X_train = np.vstack((X_train, X_samp))
... | code_fim | hard | {
"lang": "python",
"repo": "dddtqshmpmz/PDX",
"path": "/cross_validation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dddtqshmpmz/PDX path: /cross_validation.py
from numpy import loadtxt
from xgboost import XGBClassifier
from catboost import CatBoostClassifier
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
from sklearn.metrics import roc_auc_score, f1_score
from sklearn impor... | code_fim | hard | {
"lang": "python",
"repo": "dddtqshmpmz/PDX",
"path": "/cross_validation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # caculate the test scores
y_pred = model.predict(X_test)
fpr, tpr, thresholds = metrics.roc_curve(y_test, y_pred)
roc_auc = metrics.auc(fpr, tpr)
precision = metrics.precision_score(y_test, y_pred)
recall = metrics.recall_score(y_test, y_pred)
... | code_fim | hard | {
"lang": "python",
"repo": "dddtqshmpmz/PDX",
"path": "/cross_validation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def gen_problems(self, cfg, n_problems, size=20, **kwargs):
problems = np.random.randint(0, 100, (n_problems, size))
return [{"numbers": problem} for problem in problems]<|fim_prefix|># repo: mpofukelvintafadzwa/qubo-nn path: /qubo_nn/problems/number_partitioning.py
i... | code_fim | hard | {
"lang": "python",
"repo": "mpofukelvintafadzwa/qubo-nn",
"path": "/qubo_nn/problems/number_partitioning.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mpofukelvintafadzwa/qubo-nn path: /qubo_nn/problems/number_partitioning.py
import numpy as np
from qubo_nn.problems.problem import Problem
class NumberPartitioning(Problem):
def __init__(self, cfg, numbers):
<|fim_suffix|> Q = np.zeros((n, n))
for i in range(n):
f... | code_fim | hard | {
"lang": "python",
"repo": "mpofukelvintafadzwa/qubo-nn",
"path": "/qubo_nn/problems/number_partitioning.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DummyRecord(_base_types.Record):
_boto_create_method = "create"
_boto_update_method = "update"
_boto_delete_method = "delete"
_boto_update_members = ["a"]
_boto_delete_members = ["a", "b"]
def update(self):
"""Placeholder docstring"""
return self._invoke_ap... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-experiments",
"path": "/tests/unit/test_base_types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aws/sagemaker-experiments path: /tests/unit/test_base_types.py
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is loc... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-experiments",
"path": "/tests/unit/test_base_types.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_list_empty(sagemaker_boto_client):
sagemaker_boto_client.list.return_value = {"TestRecordSummaries": []}
assert [] == list(
DummyRecord._list(
"list",
DummyRecordSummary.from_boto,
"TestRecordSummaries",
sagemaker_boto_client=sagema... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-experiments",
"path": "/tests/unit/test_base_types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> check_strings = (
"Echo Handler: setup method called.",
"Echo Behaviour: setup method called.",
"Echo Behaviour: act method called.",
"content={}".format(message_content),
)
missing_strings = self.missing_from_output(process, check_st... | code_fim | hard | {
"lang": "python",
"repo": "ejfitzgerald/agents-aea",
"path": "/tests/test_packages/test_skills/test_echo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ejfitzgerald/agents-aea path: /tests/test_packages/test_skills/test_echo.py
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# ... | code_fim | hard | {
"lang": "python",
"repo": "ejfitzgerald/agents-aea",
"path": "/tests/test_packages/test_skills/test_echo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # add sending and receiving envelope from input/output files
sender = "sender"
default_dialogues = DefaultDialogues(sender)
message_content = b"hello"
message = DefaultMessage(
performative=DefaultMessage.Performative.BYTES,
dialogue_referenc... | code_fim | hard | {
"lang": "python",
"repo": "ejfitzgerald/agents-aea",
"path": "/tests/test_packages/test_skills/test_echo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name = 'libvdpau'
self.version = '1.1.1'
self.depends = ['doxygen', 'dot', 'texlive', 'xorg-libs']
self.url = 'http://people.freedesktop.org/~aplattner/vdpau/' \
'libvdpau-$version.tar.bz2'<|fim_prefix|># repo: stangelandcl/hardhat path: /hardhat/re... | code_fim | hard | {
"lang": "python",
"repo": "stangelandcl/hardhat",
"path": "/hardhat/recipes/libvdpau.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stangelandcl/hardhat path: /hardhat/recipes/libvdpau.py
from .base import GnuRecipe
class LibVdPauRecipe(GnuRecipe):
def __init__(self, *args, **kwargs):
<|fim_suffix|> self.name = 'libvdpau'
self.version = '1.1.1'
self.depends = ['doxygen', 'dot', 'texlive', 'xorg-li... | code_fim | hard | {
"lang": "python",
"repo": "stangelandcl/hardhat",
"path": "/hardhat/recipes/libvdpau.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dbbudd/Python-Experiments path: /EmuBot/EmuBot USB2AX 2017/Working-Code-CCGS/Wless_code_RC17/RoboCupServer-Current.py
import socketserver as SocketServer
import sys
from GPIO import *
#SwitchOFF()
from emuBot import *
wheelMode(1)
wheelMode(2)
wheelMode(3)
wheelMode(4)
jointMode(5)
jo... | code_fim | hard | {
"lang": "python",
"repo": "dbbudd/Python-Experiments",
"path": "/EmuBot/EmuBot USB2AX 2017/Working-Code-CCGS/Wless_code_RC17/RoboCupServer-Current.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
HOST, PORT = "", 9999
SocketServer.TCPServer.allow_reuse_address = True
server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
print('Servre Started')
server.serve_forever()<|fim_prefix|># repo: dbbudd/Python-Experiments path: /EmuBot/EmuBot USB2AX 2017/Wo... | code_fim | hard | {
"lang": "python",
"repo": "dbbudd/Python-Experiments",
"path": "/EmuBot/EmuBot USB2AX 2017/Working-Code-CCGS/Wless_code_RC17/RoboCupServer-Current.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jesiqueira/selenium path: /aula_09/acoes.py
from selenium.webdriver import Chrome
from bs4 import BeautifulSoup
import time
from selenium.webdriver.support.ui import WebDriverWait
def esperar_page(webdriver):
elements = webdriver.find_element_by_id('conteudo-principal')
print('Tentand... | code_fim | medium | {
"lang": "python",
"repo": "jesiqueira/selenium",
"path": "/aula_09/acoes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>page = driver.page_source
soup = BeautifulSoup(page, 'html.parser')
print(soup.prettify())<|fim_prefix|># repo: jesiqueira/selenium path: /aula_09/acoes.py
from selenium.webdriver import Chrome
from bs4 import BeautifulSoup
import time
from selenium.webdriver.support.ui import WebDriverWait
def espera... | code_fim | hard | {
"lang": "python",
"repo": "jesiqueira/selenium",
"path": "/aula_09/acoes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>wdw.until(esperar_page)
page = driver.page_source
soup = BeautifulSoup(page, 'html.parser')
print(soup.prettify())<|fim_prefix|># repo: jesiqueira/selenium path: /aula_09/acoes.py
from selenium.webdriver import Chrome
from bs4 import BeautifulSoup
import time
from selenium.webdriver.support.ui import W... | code_fim | medium | {
"lang": "python",
"repo": "jesiqueira/selenium",
"path": "/aula_09/acoes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geoflows/D-Claw path: /python/convert43to44.py
running Clawpack.
INPUT:
claw_pkg expected to be "classic" for this setrun.
OUTPUT:
rundata - object of class ClawRunData
""")
setrun.write('\n """ ')
setrun.write("""
assert claw_pkg.lower() == 'cla... | code_fim | hard | {
"lang": "python",
"repo": "geoflows/D-Claw",
"path": "/python/convert43to44.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geoflows/D-Claw path: /python/convert43to44.py
check outstyle in setrun.py")
dt_initial = float(next(lines))
dt_max = float(next(lines))
cfl_max = float(next(lines))
cfl_desired = float(next(lines))
max_steps = int(next(lines))
dt_varia... | code_fim | hard | {
"lang": "python",
"repo": "geoflows/D-Claw",
"path": "/python/convert43to44.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Number of auxiliary variables in the aux array (initialized in setaux)
clawdata.maux = %s
# Index of aux array corresponding to capacity function, if there is one:
clawdata.mcapa = %s
# -------------
# Initial time:
# -------------
clawdata.t0 = %s
... | code_fim | hard | {
"lang": "python",
"repo": "geoflows/D-Claw",
"path": "/python/convert43to44.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Do the NVM import to kapture using the parameters given on the command line.
"""
parser = argparse.ArgumentParser(
description='import nvm file to the kapture format.')
parser_verbosity = parser.add_mutually_exclusive_group()
parser_verbosity.add_argument(
'-v',... | code_fim | hard | {
"lang": "python",
"repo": "naver/kapture",
"path": "/tools/kapture_import_nvm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: naver/kapture path: /tools/kapture_import_nvm.py
imports an NVM model in the kapture format.
VisualSFM saves SfM workspaces into NVM files, which contain input image paths and multiple 3D models.
Below is the format description
NVM_V3 [optional calibration] # file version... | code_fim | hard | {
"lang": "python",
"repo": "naver/kapture",
"path": "/tools/kapture_import_nvm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: naver/kapture path: /tools/kapture_import_nvm.py
3D models.
Below is the format description
NVM_V3 [optional calibration] # file version header
<Model1> <Model2> ... # multiple reconstructed models
<Empty Model containing the unregistered Im... | code_fim | hard | {
"lang": "python",
"repo": "naver/kapture",
"path": "/tools/kapture_import_nvm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: king960/pyCraft path: /network/types.py
"""Contains definitions for minecraft's different data types
Each type has a method which is used to read and write it.
These definitions and methods are used by the packet definitions
"""
import struct
class Type:
@staticmethod
def read(file_obje... | code_fim | hard | {
"lang": "python",
"repo": "king960/pyCraft",
"path": "/network/types.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@staticmethod
def read(file_object):
return struct.unpack('>f', file_object.read(4))[0]
@staticmethod
def send(svalue, socket):
socket.send(struct.pack('>f', value))
class Double(Type):
@staticmethod
def read(file_object):
return struct.unpack('>d', file... | code_fim | hard | {
"lang": "python",
"repo": "king960/pyCraft",
"path": "/network/types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def createFigureWidget(self):
x_id = self.dimensions[0]
y_id = self.dimensions[1]
z_id = self.dimensions[2]
x_value = self.data[x_id].flatten().astype('float')
y_value = self.data[y_id].flatten().astype('float')
x_value, x_inv = np.unique(x_value, retur... | code_fim | hard | {
"lang": "python",
"repo": "denphi/jupyterlab-floatview",
"path": "/floatview/plotly/image.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: denphi/jupyterlab-floatview path: /floatview/plotly/image.py
from .glueplotly import GluePlotly
from plotly.graph_objects import FigureWidget
import numpy as np
from ipywidgets import IntText, Dropdown, FloatText, BoundedIntText
class GlueImagePlotly (GluePlotly):
def __init__(self, data, di... | code_fim | hard | {
"lang": "python",
"repo": "denphi/jupyterlab-floatview",
"path": "/floatview/plotly/image.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jakul/bravado path: /tests/integration/requests_client_test.py
# -*- coding: utf-8 -*-
from bravado.requests_client import RequestsClient
from bravado.swagger_model import Loader
from tests.integration.conftest import ROUTE_1_RESPONSE
from tests.integration.conftest import ROUTE_2_RESPONSE
clas... | code_fim | medium | {
"lang": "python",
"repo": "jakul/bravado",
"path": "/tests/integration/requests_client_test.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> http_future = self.http_client.request(request_args)
resp = http_future.result(timeout=1)
assert resp.text == self.encode_expected_response(b'6')
def test_boolean_header(self, threaded_http_server):
response = self.http_client.request({
'method': 'GET',
... | code_fim | hard | {
"lang": "python",
"repo": "jakul/bravado",
"path": "/tests/integration/requests_client_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> http_future_1 = self.http_client.request(request_one_params)
http_future_2 = self.http_client.request(request_two_params)
resp_one = http_future_1.result(timeout=1)
resp_two = http_future_2.result(timeout=1)
assert resp_one.text == self.encode_expected_response(ROU... | code_fim | hard | {
"lang": "python",
"repo": "jakul/bravado",
"path": "/tests/integration/requests_client_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google-cloud-sdk-unofficial/google-cloud-sdk path: /lib/googlecloudsdk/command_lib/compute/tpus/execution_groups/util.py
y(.*)$')
_PATCH_NUMBER_REGEX = re.compile('^\\.(\\d+)$')
@staticmethod
def ParseVersion(tf_version):
"""Helper to parse the tensorflow version into it's subcomponent... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/compute/tpus/execution_groups/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Retrieves all Instances created by Execution Group."""
project = properties.VALUES.core.project.Get(required=True)
request = self.messages.ComputeInstancesListRequest(
zone=zone, project=project)
instances = list_pager.YieldFromList(
service=self.client.instances,
... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/compute/tpus/execution_groups/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return True
_VERSION_REGEX = re.compile('^(\\d+)\\.(\\d+)(.*)$')
_NIGHTLY_REGEX = re.compile('^nightly(.*)$')
_PATCH_NUMBER_REGEX = re.compile('^\\.(\\d+)$')
@staticmethod
def ParseVersion(tf_version):
"""Helper to parse the tensorflow version into it's subcomponents."""
if not t... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/compute/tpus/execution_groups/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>, tokens[1], tokens[2])
entries.setdefault(entry, 0)
entries[entry] += 1
for entry, count in entries.iteritems():
if count > 1:
print(entry, count)<|fim_prefix|># repo: akrherz/radcomp path: /scripts/check_colorramp_dups.py
import sys
entries = {}
for line in open(sys.argv[1]):
... | code_fim | medium | {
"lang": "python",
"repo": "akrherz/radcomp",
"path": "/scripts/check_colorramp_dups.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>r entry, count in entries.iteritems():
if count > 1:
print(entry, count)<|fim_prefix|># repo: akrherz/radcomp path: /scripts/check_colorramp_dups.py
import sys
entries = {}
for line in open(sys.argv[1]):
tokens = line.strip().s<|fim_middle|>plit()
if len(tokens) != 3:
continu... | code_fim | medium | {
"lang": "python",
"repo": "akrherz/radcomp",
"path": "/scripts/check_colorramp_dups.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akrherz/radcomp path: /scripts/check_colorramp_dups.py
import sys
entries = {}
for line in open(sys.argv[1]):
tokens = line.strip().s<|fim_suffix|>r entry, count in entries.iteritems():
if count > 1:
print(entry, count)<|fim_middle|>plit()
if len(tokens) != 3:
continu... | code_fim | medium | {
"lang": "python",
"repo": "akrherz/radcomp",
"path": "/scripts/check_colorramp_dups.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#{
# Driver Code Starts
#Initial Template for Python 3
if __name__ == '__main__':
t=int(input())
for _ in range(t):
n=int(input())
arr=[int(x) for x in input().split()]
ans=Solution().productExceptSelf(arr,n)
print(*ans)
# } Driver Code Ends<|fim_prefix|># rep... | code_fim | hard | {
"lang": "python",
"repo": "htrahddis-hub/DSA-Together-HacktoberFest",
"path": "/Arrays/Easy/ArrayPuzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: htrahddis-hub/DSA-Together-HacktoberFest path: /Arrays/Easy/ArrayPuzzle.py
# https://practice.geeksforgeeks.org/problems/product-array-puzzle4525/1/
class Solution:
def productExceptSelf(self, nums, n):
#code here
totalProduct = 1
if(0 in nums):
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "htrahddis-hub/DSA-Together-HacktoberFest",
"path": "/Arrays/Easy/ArrayPuzzle.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Find the index with 0 value
index = nums.index(0)
# nums[index] == 0
nums[index] = 1
for i in range(0 , n):
totalProduct *= nums[i]
# Rest all values will be 0
op = [0]*n
op[index] = totalProd... | code_fim | hard | {
"lang": "python",
"repo": "htrahddis-hub/DSA-Together-HacktoberFest",
"path": "/Arrays/Easy/ArrayPuzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hyperrixel/pong path: /python/data_structure_object.py
"""
pong - The Artwork Recommendation System
========================================
License: MIT
This file contains data structure object class.
"""
class DataStructureObject:
"""
Provide data srturcture object frame... | code_fim | hard | {
"lang": "python",
"repo": "hyperrixel/pong",
"path": "/python/data_structure_object.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def length(self) -> int:
"""
Get length of the data
======================
Returns
-------
int
The length of the data in processed form.
"""
return self.__length
@property
def processi... | code_fim | hard | {
"lang": "python",
"repo": "hyperrixel/pong",
"path": "/python/data_structure_object.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polca/premise path: /premise/utils.py
"""
Various utils functions.
"""
import os
import sys
import uuid
from functools import lru_cache
from pathlib import Path
from typing import List
import pandas as pd
import xarray as xr
import yaml
from bw2data import databases
from bw2io.importers.base_lc... | code_fim | hard | {
"lang": "python",
"repo": "polca/premise",
"path": "/premise/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return exc
def reset_all_codes(data):
"""
Re-generate all codes in each dataset of a database
Remove all code for each production and technosphere exchanges
in each dataset.
"""
for ds in data:
ds["code"] = str(uuid.uuid4())
for exc in ds["exchanges"]:
... | code_fim | hard | {
"lang": "python",
"repo": "polca/premise",
"path": "/premise/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Re-generate all codes in each dataset of a database
Remove all code for each production and technosphere exchanges
in each dataset.
"""
for ds in data:
ds["code"] = str(uuid.uuid4())
for exc in ds["exchanges"]:
if exc["type"] in ["production", "techn... | code_fim | hard | {
"lang": "python",
"repo": "polca/premise",
"path": "/premise/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thomasLensicaen/weightin path: /tests/test_initialization.py
import unittest
from tests.helper import WIClient
from datetime import datetime, timedelta
import random
from weightin.apps.weightin import FORMAT_DATE
class WeightInTest(unittest.TestCase):
def setUp(self):
<|fim_suffix|> def ... | code_fim | hard | {
"lang": "python",
"repo": "thomasLensicaen/weightin",
"path": "/tests/test_initialization.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.wi_client = WIClient('localhost',8080)
def test_add_weight(self):
results = list()
for i in range(1,20):
obj = {'date' : (datetime(2019,1,1) + timedelta(days=i)).strftime(FORMAT_DATE),
'weight' : 80 + random.random() * 4}
res = ... | code_fim | medium | {
"lang": "python",
"repo": "thomasLensicaen/weightin",
"path": "/tests/test_initialization.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_get_data(self):
data = self.wi_client.request_get_data()
print("{}".format(data))<|fim_prefix|># repo: thomasLensicaen/weightin path: /tests/test_initialization.py
import unittest
from tests.helper import WIClient
from datetime import datetime, timedelta
import random
from w... | code_fim | hard | {
"lang": "python",
"repo": "thomasLensicaen/weightin",
"path": "/tests/test_initialization.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, name="test"):
self._uuid = str(uuid.uuid4())
self._name = f"{self._uuid}.menu.pb"
self._algos = dict()
self._seqs = dict()
self._chains = dict()
@property
def algos(self):
return self._algos
def _algo_builder(self):
... | code_fim | hard | {
"lang": "python",
"repo": "artemis-analytics/artemis",
"path": "/artemis/configurables/configurable.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: artemis-analytics/artemis path: /artemis/configurables/configurable.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © Her Majesty the Queen in Right of Canada, as represented
# by the Minister of Statistics Canada, 2019.
#
# Licensed under the Apache License, Vers... | code_fim | hard | {
"lang": "python",
"repo": "artemis-analytics/artemis",
"path": "/artemis/configurables/configurable.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fh0.savefig(os.path.join(save_directory, 'object_tracking_schem.svg'), transparent=True)
fh1.savefig(os.path.join(save_directory, 'object_tracking_trace_spot.svg'), transparent=True)
fh2.savefig(os.path.join(save_directory, 'object_tracking_trace_bg.svg'), transparent=True)
# %%
fh4, ax4 = plt.subplots(1,... | code_fim | hard | {
"lang": "python",
"repo": "mhturner/glom_pop",
"path": "/figs/object_tracking_snr.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> img_tmp = img.copy()
img_tmp[int(ctr_y-spot_radius):int(ctr_y+spot_radius), int(schem_spot_loc-spot_radius):int(schem_spot_loc+spot_radius)] = spot_intensity
ax0.imshow(img_tmp, cmap='Greys_r')
circle1 = plt.Circle((rf_ctr_x, ctr_y), rf_radius, color=[1, 1, ... | code_fim | hard | {
"lang": "python",
"repo": "mhturner/glom_pop",
"path": "/figs/object_tracking_snr.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhturner/glom_pop path: /figs/object_tracking_snr.py
import numpy as np
import os
import glob
from glom_pop import dataio
from skimage.io import imread
from skimage.transform import resize
import matplotlib.pyplot as plt
import seaborn as sns
sync_dir = dataio.get_config_file()['sync_dir']
save_... | code_fim | hard | {
"lang": "python",
"repo": "mhturner/glom_pop",
"path": "/figs/object_tracking_snr.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for bf, aft in swap_pairs:
srl_list = re.split(r'(<.*?>)', events[bf])
srl_list[verbs_n_idxs[bf][0]] = verbs_n_idxs[aft][1]
events[bf] = ''.join(srl_list)
return events
def event_intra_shuffle(true_end, only_verb=False):
shuffled_end = []
count = 0
for line in... | code_fim | hard | {
"lang": "python",
"repo": "PlusLabNLP/story-gen-BART",
"path": "/fairseq/create_classifier_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PlusLabNLP/story-gen-BART path: /fairseq/create_classifier_dataset.py
import sys, argparse, random, os, re
parser = argparse.ArgumentParser('Split text data into context and continuation')
parser.add_argument('data_dir', type=str,
help='directory with data splits in it')
pars... | code_fim | hard | {
"lang": "python",
"repo": "PlusLabNLP/story-gen-BART",
"path": "/fairseq/create_classifier_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kenlost/selfkit path: /tf/tfidentity.py
import tensorflow as tf
x = tf.Variable(0, dtype=tf.int32, name='x')
old_val = tf.identity(x, name<|fim_suffix|>summary.FileWriter('./tfid', tf.get_default_graph())
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in ran... | code_fim | medium | {
"lang": "python",
"repo": "kenlost/selfkit",
"path": "/tf/tfidentity.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bal_variables_initializer())
for i in range(3):
print(sess.run([new_val, old_val, x]))<|fim_prefix|># repo: kenlost/selfkit path: /tf/tfidentity.py
import tensorflow as tf
x = tf.Variable(0, dtype=tf.int32, name='x')
old_val = tf.identity(x, name="old_same_x")
old_val = old_val + 10
new_val... | code_fim | medium | {
"lang": "python",
"repo": "kenlost/selfkit",
"path": "/tf/tfidentity.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> lvl = record.levelname
name = record.name
t = int(round(record.relativeCreated/1000.0))
msg = record.getMessage()
logstr = "+{}s {} {} [P{}]: {}".format(t, lvl, name, mpiops.chunk_index, msg)
return logstr
def warn_with_traceback(message, category, filenam... | code_fim | medium | {
"lang": "python",
"repo": "GeoscienceAustralia/uncover-ml",
"path": "/uncoverml/mllog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GeoscienceAustralia/uncover-ml path: /uncoverml/mllog.py
"""
Logging config.
"""
import logging
import sys
import traceback
import warnings
from uncoverml import mpiops
def configure(verbosity):
log = logging.getLogger("")
log.setLevel(verbosity)
ch = MPIStreamHandler()
formatt... | code_fim | medium | {
"lang": "python",
"repo": "GeoscienceAustralia/uncover-ml",
"path": "/uncoverml/mllog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Add MPI index to exception traceback.
"""
exc_msg = traceback.format_exception(exc_type, exc_value, exc_traceback)
exc_msg.insert(0, 'Uncaught exception on processor {}\n'.format(mpiops.chunk_index))
exc_msg = "".join(exc_msg)
print(exc_msg, file=sys.stderr)
sys.excepthook... | code_fim | hard | {
"lang": "python",
"repo": "GeoscienceAustralia/uncover-ml",
"path": "/uncoverml/mllog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, msg):
Exception.__init__(self, msg)
def placevalue(n, base=10):
exp = 0
while n >= base:
exp += 1
n /= 10
return exp<|fim_prefix|># repo: keepsoftware/words2num path: /words2num/core.py
"""Commonly used tools
"""
<|fim_middle|>
class NumberPar... | code_fim | easy | {
"lang": "python",
"repo": "keepsoftware/words2num",
"path": "/words2num/core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def placevalue(n, base=10):
exp = 0
while n >= base:
exp += 1
n /= 10
return exp<|fim_prefix|># repo: keepsoftware/words2num path: /words2num/core.py
"""Commonly used tools
"""
class NumberParseException(Exception):
def __init__(self, msg):
<|fim_middle|> Exceptio... | code_fim | easy | {
"lang": "python",
"repo": "keepsoftware/words2num",
"path": "/words2num/core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keepsoftware/words2num path: /words2num/core.py
"""Commonly used tools
"""
<|fim_suffix|>def placevalue(n, base=10):
exp = 0
while n >= base:
exp += 1
n /= 10
return exp<|fim_middle|>
class NumberParseException(Exception):
def __init__(self, msg):
Exceptio... | code_fim | medium | {
"lang": "python",
"repo": "keepsoftware/words2num",
"path": "/words2num/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mratmartinez/Web path: /tests/unit/test.py
import unittest
import locale
from juancito import format_date, slugify
class TestMarkdown(unittest.TestCase):
def test_format_date(self):
data = '2019-11-28'
result = format_date(data)
self.assertEqual(result, "Jueves 28 de... | code_fim | hard | {
"lang": "python",
"repo": "mratmartinez/Web",
"path": "/tests/unit/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_slugify(self):
data = "¡Este podría ser el mejor título del mundo si no fuera testing!"
result = slugify(data)
expected = "este-podria-ser-el-mejor-titulo-del-mundo-si-no-fuera-testing"
self.assertEqual(result, expected)
if __name__ == '__main__':
locale.... | code_fim | hard | {
"lang": "python",
"repo": "mratmartinez/Web",
"path": "/tests/unit/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
locale.setlocale(locale.LC_TIME, 'es_AR')
unittest.main()<|fim_prefix|># repo: mratmartinez/Web path: /tests/unit/test.py
import unittest
import locale
from juancito import format_date, slugify
class TestMarkdown(unittest.TestCase):
def test_format_date(self):
... | code_fim | hard | {
"lang": "python",
"repo": "mratmartinez/Web",
"path": "/tests/unit/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JonatanMariscal/3DUnetCNN path: /spine/get_spines.py
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
from scipy.ndimage import label
from skimage.measure import regionprops
import numpy as np
import nibabel as nib
import os
import glob
import argparse
import sys
from os impor... | code_fim | hard | {
"lang": "python",
"repo": "JonatanMariscal/3DUnetCNN",
"path": "/spine/get_spines.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (spine_x<=60 and spine_y<=60 and spine_z<=20):
spine_folder = os.path.abspath(os.path.join(case_folder_spine,"spine_"+str(spine+1)))
if path.exists(spine_folder) != True:
os.mkdir(spine_folder)
#Obtain BB ... | code_fim | hard | {
"lang": "python",
"repo": "JonatanMariscal/3DUnetCNN",
"path": "/spine/get_spines.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Compute the oxidation states of metals using oximachine
:param cif: AiiDA CifData instance
:return: AiiDA Dict node
"""
try:
results_dict = OXIMACHINE_RUNNER.run_oximachine(cif.get_ase())
except Exception: # pylint: disable=broad-except
results_dict = {
... | code_fim | medium | {
"lang": "python",
"repo": "lsmo-epfl/aiida-lsmo",
"path": "/aiida_lsmo/calcfunctions/oxidation_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lsmo-epfl/aiida-lsmo path: /aiida_lsmo/calcfunctions/oxidation_state.py
# -*- coding: utf-8 -*-
"""CalcFunction to compute the oxidation states of metals using oximachine"""
from aiida.engine import calcfunction
from aiida.orm import Dict
import oximachinerunner
<|fim_suffix|> :param cif: Ai... | code_fim | medium | {
"lang": "python",
"repo": "lsmo-epfl/aiida-lsmo",
"path": "/aiida_lsmo/calcfunctions/oxidation_state.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> results_dict['oximachine_version'] = str(OXIMACHINE_RUNNER)
return Dict(dict=results_dict)<|fim_prefix|># repo: lsmo-epfl/aiida-lsmo path: /aiida_lsmo/calcfunctions/oxidation_state.py
# -*- coding: utf-8 -*-
"""CalcFunction to compute the oxidation states of metals using oximachine"""
from aiida.... | code_fim | hard | {
"lang": "python",
"repo": "lsmo-epfl/aiida-lsmo",
"path": "/aiida_lsmo/calcfunctions/oxidation_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: XiaoxiWei/NeurIPS_competition path: /EEG_Lightning/dassl/engine/dg/ADV.py
import torch
from torch.nn import functional as F
import torch.nn as nn
from dassl.data import DataManager
from dassl.optim import build_optimizer, build_lr_scheduler
from dassl.utils import count_num_param
from dassl.engin... | code_fim | hard | {
"lang": "python",
"repo": "XiaoxiWei/NeurIPS_competition",
"path": "/EEG_Lightning/dassl/engine/dg/ADV.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with torch.no_grad():
feat = self.model(input_x)
critic_logits = self.D(feat)
loss_critic = self.ce_1(critic_logits,domain_x)
if backprob:
self.model_backward_and_update(loss_critic,['D'])
if (self.batch_idx + 1) == self.num_batches:
... | code_fim | hard | {
"lang": "python",
"repo": "XiaoxiWei/NeurIPS_competition",
"path": "/EEG_Lightning/dassl/engine/dg/ADV.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> results = self.evaluator.evaluate()
total_loss = losses.meters['loss_x'].avg
for k, v in results.items():
tag = '{}/{}'.format('validation', k)
self.write_scalar(tag, v, self.epoch)
# if full_results:
return [total_loss,losses.dict_results()... | code_fim | hard | {
"lang": "python",
"repo": "XiaoxiWei/NeurIPS_competition",
"path": "/EEG_Lightning/dassl/engine/dg/ADV.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from pyobjc_setup import setup # noqa: E402
VERSION = "9.2.1"
setup(
name="pyobjc-framework-IOBluetoothUI",
description="Wrappers for the framework IOBluetoothUI on macOS",
packages=["IOBluetoothUI"],
version=VERSION,
install_requires=[
"pyobjc-core>=" + VERSION,
"py... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-IOBluetoothUI/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from pyobjc_setup import setup # noqa: E402
VERSION = "9.2.1"
setup(
name="pyobjc-framework-IOBluetoothUI",
description="Wrappers for the framework IOBluetoothUI on macOS",
packages=["IOBluetoothUI"],
version=VERSION,
install_requires=[
"pyobjc-core>=" + VERSION,
"p... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-IOBluetoothUI/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ronaldoussoren/pyobjc path: /pyobjc-framework-IOBluetoothUI/setup.py
"""
Wrappers for the "IOBluetoothUI" framework on macOS.
These wrappers don't include documentation, please check Apple's documentation
for information on how to use this framework and PyObjC's documentation
for general tips an... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-IOBluetoothUI/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Field()
kart = scrapy.Field()
matchRank = scrapy.Field()
rankinggrade2 = scrapy.Field()<|fim_prefix|># repo: Taebyoung/kartrider_api_crawling path: /crawling_project/cartrider/cartrider/items.py
import scrapy
class CartriderItem(scrapy.Item):
<|fim_middle|> matches = scrapy.Field()
tr... | code_fim | easy | {
"lang": "python",
"repo": "Taebyoung/kartrider_api_crawling",
"path": "/crawling_project/cartrider/cartrider/items.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Taebyoung/kartrider_api_crawling path: /crawling_project/cartrider/cartrider/items.py
import scrapy
class CartriderItem(scrapy.Item):
<|fim_suffix|> scrapy.Field()
rankinggrade2 = scrapy.Field()<|fim_middle|> matches = scrapy.Field()
trackId = scrapy.Field()
kart = scrapy.Field()
... | code_fim | medium | {
"lang": "python",
"repo": "Taebyoung/kartrider_api_crawling",
"path": "/crawling_project/cartrider/cartrider/items.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> scrapy.Field()
rankinggrade2 = scrapy.Field()<|fim_prefix|># repo: Taebyoung/kartrider_api_crawling path: /crawling_project/cartrider/cartrider/items.py
import scrapy
class CartriderItem(scrapy.Item):
matches = scrapy.Field()
trackId = scrapy.<|fim_middle|>Field()
kart = scrapy.Field()
... | code_fim | easy | {
"lang": "python",
"repo": "Taebyoung/kartrider_api_crawling",
"path": "/crawling_project/cartrider/cartrider/items.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hnikolov/ws_lcd path: /ws_lcd/lcd_logger.py
#!/usr/bin/python
import paho.mqtt.client as mqtt
import time, datetime, sys
import traceback
from layout_mix import MY_GUI
from log import LOG
# MQTT_SERVER = "192.168.2.100"
# MQTT_SERVER = "192.168.2.101"
MQTT_SERVER = "localhost"
class MQTT_LOGG... | code_fim | hard | {
"lang": "python",
"repo": "hnikolov/ws_lcd",
"path": "/ws_lcd/lcd_logger.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def connect(self):
try:
self.mqtt_client.connect(MQTT_SERVER, 1883, 60)
self.mqtt_client.loop(timeout = 4.0)
time.sleep(4) # Do we need this? loop() will timeout after 4s
except Exception:
self.log.warning(traceback.format_exc())
... | code_fim | hard | {
"lang": "python",
"repo": "hnikolov/ws_lcd",
"path": "/ws_lcd/lcd_logger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpch89/leetcode path: /未分类/01数组/09两数之和2.py
# -*- coding: utf-8 -*-
# @Author: jpch89
# @Time: 18-9-3 上午11:03
"""
给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。
你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。
"""
class Solution:
<|fim_suffix|> """
:type nums: List[int]
:type target: int
:rtype... | code_fim | hard | {
"lang": "python",
"repo": "jpch89/leetcode",
"path": "/未分类/01数组/09两数之和2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for i in range(len(nums)):
other = target - nums[i]
if other in nums:
if nums[i] == other:
... | code_fim | hard | {
"lang": "python",
"repo": "jpch89/leetcode",
"path": "/未分类/01数组/09两数之和2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin
"""
...
def query_url(url: str) -> dict[Any, str]:
"""
?key=value
&key=value
Returns the value in the query string as {key:value}.
"""
...
def try_n(
n: int, sleep: Un... | code_fim | hard | {
"lang": "python",
"repo": "Hitomi-Downloader-extension/Stubs",
"path": "/utils.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hitomi-Downloader-extension/Stubs path: /utils.pyi
"""
Author: Ryu JuHeon(@SaidBySolo)
Not all implemented.
It is designed to provide minimal help for users when writing scripts.
"""
from __future__ import annotations
from size import Size
from customWidget import CustomWidget
from bs... | code_fim | hard | {
"lang": "python",
"repo": "Hitomi-Downloader-extension/Stubs",
"path": "/utils.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> title: str,
mode: Literal["soft", "hard", "safe"],
allow_dot: bool = False,
n: Optional[int] = None,
) -> str:
"""
Return the string after post-processing.
"""
...
@overload
def clean_title(
title: None,
mode: Literal["soft", "hard", "safe"],
allo... | code_fim | hard | {
"lang": "python",
"repo": "Hitomi-Downloader-extension/Stubs",
"path": "/utils.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(binary_search([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4))<|fim_prefix|># repo: rohan8594/DS-Algos path: /algorithms/Searching/BinarySearch.py
def binary_search(arr, ele):
first = 0
last = len(arr) - 1
found = False
<|fim_middle|> while first <= last and found == False:
mid = (fi... | code_fim | hard | {
"lang": "python",
"repo": "rohan8594/DS-Algos",
"path": "/algorithms/Searching/BinarySearch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print(binary_search([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4))<|fim_prefix|># repo: rohan8594/DS-Algos path: /algorithms/Searching/BinarySearch.py
def binary_search(arr, ele):
first = 0
last = len(arr) - 1
found = False
while first <= last and found == False:
mid = (first + last) /... | code_fim | medium | {
"lang": "python",
"repo": "rohan8594/DS-Algos",
"path": "/algorithms/Searching/BinarySearch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rohan8594/DS-Algos path: /algorithms/Searching/BinarySearch.py
def binary_search(arr, ele):
first = 0
last = len(arr) - 1
found = False
while first <= last and found == False:
mid = (first + last) // 2
if arr[mid] == ele:
found = True
else:... | code_fim | easy | {
"lang": "python",
"repo": "rohan8594/DS-Algos",
"path": "/algorithms/Searching/BinarySearch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(self, input, target):
return charbonnier_loss(input, target, eps=self.eps, reduction=self.reduction)<|fim_prefix|># repo: nagadomi/nunif path: /nunif/modules/charbonnier_loss.py
from torch import nn
import torch
def charbonnier_loss(input, target, reduction="mean", eps=1.0e-6):
... | code_fim | medium | {
"lang": "python",
"repo": "nagadomi/nunif",
"path": "/nunif/modules/charbonnier_loss.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.