text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> super().__init__('192.168.1.3', 8083)
class YanexTransportConfig(TransportConfig):
def __init__(self):
super().__init__('asr.yandex.net', 443)<|fim_prefix|># repo: ReanGD/smart-home path: /etc/transport.py
from protocols.transport import TransportConfig
class HassTransportConfig(T... | code_fim | easy | {
"lang": "python",
"repo": "ReanGD/smart-home",
"path": "/etc/transport.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ReanGD/smart-home path: /etc/transport.py
from protocols.transport import TransportConfig
class HassTransportConfig(TransportConfig):
<|fim_suffix|> def __init__(self):
super().__init__('asr.yandex.net', 443)<|fim_middle|> def __init__(self):
super().__init__('192.168.1.3'... | code_fim | medium | {
"lang": "python",
"repo": "ReanGD/smart-home",
"path": "/etc/transport.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: binduchinnasamy/metadata-samples path: /harvestor/adls-gen2/src/Function/EntitySync/ProcessEntity/__init__.py
import logging
import requests
import json
import os
import azure.functions as func
def main(blob: func.InputStream):
logging.info("Blob trigger function started processing ... | code_fim | hard | {
"lang": "python",
"repo": "binduchinnasamy/metadata-samples",
"path": "/harvestor/adls-gen2/src/Function/EntitySync/ProcessEntity/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> qns_request_obj ={}
if entity_type =='resourceset':
qns_request_obj ={
"azure_storage_uri":adls_gen2_uri,
"filesystem_name":file_system,
"resource_set_path":entity_path
}
qns_service_url=qns_service_url+'&typeName=azure_datalake_gen2_resource_... | code_fim | hard | {
"lang": "python",
"repo": "binduchinnasamy/metadata-samples",
"path": "/harvestor/adls-gen2/src/Function/EntitySync/ProcessEntity/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Enselic/git-repo-language-trends path: /src/git_repo_language_trends/_internal/args.py
import os
import sys
import argparse
import git_repo_language_trends
from pathlib import Path
desc = """
Description:
============
Analyze programming language usage over time in a git repository and produce ... | code_fim | hard | {
"lang": "python",
"repo": "Enselic/git-repo-language-trends",
"path": "/src/git_repo_language_trends/_internal/args.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument(
"--list", "-l",
action='store_true',
help="list file extensions and their total line count in the first commit",
)
parser.add_argument(
"--min-interval-days",
metavar="<int>",
type=positive_int,
default=7,
he... | code_fim | hard | {
"lang": "python",
"repo": "Enselic/git-repo-language-trends",
"path": "/src/git_repo_language_trends/_internal/args.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jyoung8607/openpilot path: /selfdrive/ui/update_translations.py
#!/usr/bin/env python3
import argparse
import json
import os
from common.basedir import BASEDIR
UI_DIR = os.path.join(BASEDIR, "selfdrive", "ui")
TRANSLATIONS_DIR = os.path.join(UI_DIR, "translations")
LANGUAGES_FILE = os.path.join... | code_fim | hard | {
"lang": "python",
"repo": "jyoung8607/openpilot",
"path": "/selfdrive/ui/update_translations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Update translation files for UI",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--vanish", action="store_true", help="Remove translations with source text no longe... | code_fim | hard | {
"lang": "python",
"repo": "jyoung8607/openpilot",
"path": "/selfdrive/ui/update_translations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(LANGUAGES_FILE, "r") as f:
translation_files = json.load(f)
for file in translation_files.values():
tr_file = os.path.join(translations_dir, f"{file}.ts")
args = f"lupdate -locations none -recursive {UI_DIR} -ts {tr_file} -I {BASEDIR}"
if vanish:
args += " -no-obsolete... | code_fim | medium | {
"lang": "python",
"repo": "jyoung8607/openpilot",
"path": "/selfdrive/ui/update_translations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebeahan/aeon-ztps path: /aeon_ztp/ztp_os_selector.py
# Copyright 2014-present, Apstra, Inc. All rights reserved.
#
# This source code is licensed under End User License Agreement found in the
# LICENSE file at http://www.apstra.com/community/eula
import os
import yaml
_AEON_TOPDIR = os.getenv... | code_fim | hard | {
"lang": "python",
"repo": "ebeahan/aeon-ztps",
"path": "/aeon_ztp/ztp_os_selector.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
filename = os.path.join(_AEON_TOPDIR, 'etc/profiles/default/{vendor}/os-selector.cfg'.format(vendor=vendor))
return load_yaml(filename)
class Vendor:
""" Describes an Aeon-ZTP vendor specification, focusing on firmware locations
Attributes:
vendor (str): Name of the vend... | code_fim | hard | {
"lang": "python",
"repo": "ebeahan/aeon-ztps",
"path": "/aeon_ztp/ztp_os_selector.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rit-bikeshare/backend path: /extended_permissions/admin.py
import copy
class ExtendedUserAdminMixin:
class Meta:
abstract = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filter_horizontal = list(self.filter_horizontal) if self.f... | code_fim | medium | {
"lang": "python",
"repo": "rit-bikeshare/backend",
"path": "/extended_permissions/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not found: raise TypeError("Couldn't find user_permissions field. Maybe you need a custom admin?")
return fieldsets<|fim_prefix|># repo: rit-bikeshare/backend path: /extended_permissions/admin.py
import copy
class ExtendedUserAdminMixin:
class Meta:
abstract = True
d... | code_fim | medium | {
"lang": "python",
"repo": "rit-bikeshare/backend",
"path": "/extended_permissions/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {}
page_token = None
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', '... | code_fim | hard | {
"lang": "python",
"repo": "VidhiRambhia/VJTI-Navigation",
"path": "/google_drive_util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VidhiRambhia/VJTI-Navigation path: /google_drive_util.py
from __future__ import print_function
import pickle
import os.path
import json
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from... | code_fim | hard | {
"lang": "python",
"repo": "VidhiRambhia/VJTI-Navigation",
"path": "/google_drive_util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Shows basic usage of the Drive v3 API.
Prints the names and ids of the first 10 files the user has access to.
"""
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the f... | code_fim | hard | {
"lang": "python",
"repo": "VidhiRambhia/VJTI-Navigation",
"path": "/google_drive_util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 启动worker时自动发现任务
celery_app.autodiscover_tasks(['celery_tasks.sms', 'celery_tasks.email', 'celery_tasks.html'])<|fim_prefix|># repo: Elvira521feng/Django_demo path: /meiduo_mall/celery_tasks/main.py
from celery import Celery
# 设置Django运行所依赖的环境变量
import os
if not os.getenv('DJANGO_SETTINGS_MODULE'):
... | code_fim | medium | {
"lang": "python",
"repo": "Elvira521feng/Django_demo",
"path": "/meiduo_mall/celery_tasks/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Elvira521feng/Django_demo path: /meiduo_mall/celery_tasks/main.py
from celery import Celery
# 设置Django运行所依赖的环境变量
import os
if not os.getenv('DJANGO_SETTINGS_MODULE'):
os.environ['DJANGO_SETTINGS_MODULE'] = 'meiduo_mall.settings.dev'
<|fim_suffix|># 加载配置
celery_app.config_from_object('celery... | code_fim | easy | {
"lang": "python",
"repo": "Elvira521feng/Django_demo",
"path": "/meiduo_mall/celery_tasks/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iangregson/advent-of-code path: /2021/20/solution.py
#!/usr/bin/env python3
import os
from collections import defaultdict, Counter, deque, namedtuple
from enum import Enum
import itertools
import functools
import operator
import random
dir_path = os.path.dirname(os.path.realpath(__file__))
file... | code_fim | hard | {
"lang": "python",
"repo": "iangregson/advent-of-code",
"path": "/2021/20/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for y in range(self.min_y-5, self.max_y+5):
for x in range(self.min_x-5, self.max_x+10):
alg_idx = 0
bits = ''
for dy in [-1, 0, 1]:
for dx in [-1, 0, 1]:
if ((x+dx,y+dy) in self.coord_set) == track_on:
bits += '1'
else:
... | code_fim | hard | {
"lang": "python",
"repo": "iangregson/advent-of-code",
"path": "/2021/20/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> d = self.obj.Data
self.assertEqual(len(d['children']),7,'The PDF has exactly 7 pages')
def test_2_histo_at_least_one_node(self):
self.assertGreater(self.histoNodeCount, 0, 'at least one histogram line node')
def test_3_histo_exact_node_count(self):
if self.reason_... | code_fim | hard | {
"lang": "python",
"repo": "jw15/imagemagick-identify-parser",
"path": "/tests/basic.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_3_histo_exact_node_count(self):
if self.reason_skip_multipage_pdf:
raise unittest.SkipTest("skip test because version doesn't support multipage")
self.assertEqual(self.histoNodeCount, 632, 'exact histo node count')
def test_4_histo_no_children_for_histogram_n... | code_fim | hard | {
"lang": "python",
"repo": "jw15/imagemagick-identify-parser",
"path": "/tests/basic.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jw15/imagemagick-identify-parser path: /tests/basic.py
import sys
import unittest
from ImageMagickIdentifyParser import ImageMagickIdentifyParser
class TestsPDF(unittest.TestCase):
obj = None
@classmethod
def setUp(self):
if self.obj is None:
self.obj = ImageMagi... | code_fim | medium | {
"lang": "python",
"repo": "jw15/imagemagick-identify-parser",
"path": "/tests/basic.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def empty(ndims):
"""
Creates an identity linear transformation.
@param ndims: number of dimensions
@return: identity matrix transformation
"""
transform = PcaTransformer(w=np.eye(ndims), mu=np.zeros(ndims))
return transform<|fi... | code_fim | medium | {
"lang": "python",
"repo": "eranroz/dnase",
"path": "/src/models/PcaTransformer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eranroz/dnase path: /src/models/PcaTransformer.py
"""
Pca transformer for reducing number of dimensions
"""
import logging
import numpy as np
__author__ = 'eranroz'
class PcaTransformer(object):
"""
Reduce number of dimensions using PCA
"""
def __init__(self, w=None, mu=0):
... | code_fim | hard | {
"lang": "python",
"repo": "eranroz/dnase",
"path": "/src/models/PcaTransformer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def recover(self, reduced):
"""
Inverse for pca, reconstruction of the original data
@param reduced: reduced data
@return: reconstruction of original data
"""
return np.dot(reduced, self.w)+self.mu
def __call__(self, *args, **kwargs):
data_c... | code_fim | medium | {
"lang": "python",
"repo": "eranroz/dnase",
"path": "/src/models/PcaTransformer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xunyuw/thingsboard-gateway-mitsubishi path: /thingsboard_gateway/sin_edge_sdk/mqtt.py
from base_request import BaseRequest
<|fim_suffix|> if ip and port:
BaseRequest.__init__(self, ip=ip, port=port)
else:
BaseRequest.__init__(self)<|fim_middle|>
class MqttC... | code_fim | medium | {
"lang": "python",
"repo": "xunyuw/thingsboard-gateway-mitsubishi",
"path": "/thingsboard_gateway/sin_edge_sdk/mqtt.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ip and port:
BaseRequest.__init__(self, ip=ip, port=port)
else:
BaseRequest.__init__(self)<|fim_prefix|># repo: xunyuw/thingsboard-gateway-mitsubishi path: /thingsboard_gateway/sin_edge_sdk/mqtt.py
from base_request import BaseRequest
<|fim_middle|>
class MqttC... | code_fim | medium | {
"lang": "python",
"repo": "xunyuw/thingsboard-gateway-mitsubishi",
"path": "/thingsboard_gateway/sin_edge_sdk/mqtt.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carpedm20/magenta path: /magenta/lib/melodies_lib.py
ue (that is the pitch), and is held through
subsequent NO_EVENT events until either another non-negative value is reached
(even if the pitch is the same as the previous note), or a NOTE_OFF event is
reached. A NOTE_OFF starts at least one... | code_fim | hard | {
"lang": "python",
"repo": "carpedm20/magenta",
"path": "/magenta/lib/melodies_lib.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carpedm20/magenta path: /magenta/lib/melodies_lib.py
1, 3, 5, 7, 8, 10]
# [C, C#, D#, F, G, G#, A#]
#
# 0 = C
# 1 = C#
# 2 = D
# 3 = D#
# 4 = E
# 5 = F
# 6 = F#
# 7 = G
# 8 = G#
# 9 = A
# 10 = A#
# 11 = B
#
# NOTE_KEYS can be generated using the code below, but is explicitly declared
# for reada... | code_fim | hard | {
"lang": "python",
"repo": "carpedm20/magenta",
"path": "/magenta/lib/melodies_lib.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If a gap of `gap` or more steps is found, end the melody.
if (len(self) and
self._distance_to_last_event(start_step) >= gap):
break
# Add the note-on and off events to the melody.
self._add_note(note.pitch, start_step, end_step)
self._write_all_notes()
... | code_fim | hard | {
"lang": "python",
"repo": "carpedm20/magenta",
"path": "/magenta/lib/melodies_lib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hysts/pytorch_image_classification path: /pytorch_image_classification/utils/utils.py
import pathlib
import random
import numpy as np
import torch
import yacs.config
<|fim_suffix|>def setup_cudnn(config: yacs.config.CfgNode) -> None:
torch.backends.cudnn.benchmark = config.cudnn.benchmark
... | code_fim | medium | {
"lang": "python",
"repo": "hysts/pytorch_image_classification",
"path": "/pytorch_image_classification/utils/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def save_config(config: yacs.config.CfgNode,
output_path: pathlib.Path) -> None:
with open(output_path, 'w') as f:
f.write(str(config))<|fim_prefix|># repo: hysts/pytorch_image_classification path: /pytorch_image_classification/utils/utils.py
import pathlib
import random
imp... | code_fim | hard | {
"lang": "python",
"repo": "hysts/pytorch_image_classification",
"path": "/pytorch_image_classification/utils/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tocyuki/RobotFramework-sample path: /variables_samples/variable_files/variable_file_with_all.py
__all__ = ['include_func', 'INCLUDE_VARIABLE']
<|fim_suffix|>def include_func():
pass
def exclude_func():
pass<|fim_middle|>INCLUDE_VARIABLE = 'foo'
EXCLUDE_VARIABLE = 'bar'
| code_fim | easy | {
"lang": "python",
"repo": "Tocyuki/RobotFramework-sample",
"path": "/variables_samples/variable_files/variable_file_with_all.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def exclude_func():
pass<|fim_prefix|># repo: Tocyuki/RobotFramework-sample path: /variables_samples/variable_files/variable_file_with_all.py
__all__ = ['include_func', 'INCLUDE_VARIABLE']
<|fim_middle|>INCLUDE_VARIABLE = 'foo'
EXCLUDE_VARIABLE = 'bar'
def include_func():
pass
| code_fim | medium | {
"lang": "python",
"repo": "Tocyuki/RobotFramework-sample",
"path": "/variables_samples/variable_files/variable_file_with_all.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def include_func():
pass
def exclude_func():
pass<|fim_prefix|># repo: Tocyuki/RobotFramework-sample path: /variables_samples/variable_files/variable_file_with_all.py
__all__ = ['include_func', 'INCLUDE_VARIABLE']
<|fim_middle|>INCLUDE_VARIABLE = 'foo'
EXCLUDE_VARIABLE = 'bar'
| code_fim | easy | {
"lang": "python",
"repo": "Tocyuki/RobotFramework-sample",
"path": "/variables_samples/variable_files/variable_file_with_all.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> def newton_body(iterand):
"""Performs one iteration of Newton's method."""
next_backward_difference = iterand.next_backward_difference
next_state_vec = iterand.next_state_vec
rhs = newton_coefficient * step_size_cast * ode_fn_vec(
next_time,
next_state_vec) - rhs_constan... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/probability",
"path": "/tensorflow_probability/python/math/ode/bdf_util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tensorflow/probability path: /tensorflow_probability/python/math/ode/bdf_util.py
# Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of t... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/probability",
"path": "/tensorflow_probability/python/math/ode/bdf_util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from torch.optim.lr_scheduler import ReduceLROnPlateau
class LRScheduler(Callback):
def __init__(self, lr_scheduler) -> None:
super(LRScheduler, self).__init__()
self.lr_scheduler = lr_scheduler
def on_epoch_end(self, trainer: Trainer):
if isinstance(self.lr_scheduler, R... | code_fim | hard | {
"lang": "python",
"repo": "shenghuo123/keras4torch",
"path": "/keras4torch/callbacks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shenghuo123/keras4torch path: /keras4torch/callbacks.py
import numpy as np
from ._training import Trainer, StopTrainingError, Events
class Callback():
def __init__(self) -> None:
pass
def get_callbacks_dict(self):
return {i: getattr(self, i.value) for i in Events if ... | code_fim | hard | {
"lang": "python",
"repo": "shenghuo123/keras4torch",
"path": "/keras4torch/callbacks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DoesArt-Studios/RamBrowse path: /venv/Lib/site-packages/PySimpleGUIDesigner/main.py
e os.path.join(
os.environ['HOME'], inputXMLui[2:])
python = 'python'
if gimme_system() == 'Linux':
python += '3'
# idea is simple:
# 1 copy input ui file to .
# 2 run "psg_ui... | code_fim | hard | {
"lang": "python",
"repo": "DoesArt-Studios/RamBrowse",
"path": "/venv/Lib/site-packages/PySimpleGUIDesigner/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# #####
# setup
# #####
if _settings['-memento-file-cb-']:
window['-memento-file-cb-'].update(True)
window['xmlfile'].update(_settings['xmlfile'])
update_app_settings()
psg_vals = window(timeout=0)[1]
parse_n_load_possible_widgets(psg_vals['xmlfile'].strip(... | code_fim | hard | {
"lang": "python",
"repo": "DoesArt-Studios/RamBrowse",
"path": "/venv/Lib/site-packages/PySimpleGUIDesigner/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def parse_n_load_possible_widgets(myxml_file='', window=None, values={}):
'''
возвращает найденые object_names все виджетов
'''
if os.path.exists(myxml_file) and os.path.isfile(myxml_file):
# get xml
with open(myxml_file, 'r', encoding='utf-8') ... | code_fim | hard | {
"lang": "python",
"repo": "DoesArt-Studios/RamBrowse",
"path": "/venv/Lib/site-packages/PySimpleGUIDesigner/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ghe\.','/bao-da/','/op-lung/','/theo-cac-thuong-hieu/']), 'parse_item'),
Rule(LinkExtractor(allow=['/phu-kien-theo-cac-dong-may/','/sac-pin-du-phong\.','/do-choi-cong-nghe\.','/tai-nghe\.','/bao-da/','/op-lung/','/theo-cac-thuong-hieu/']), 'parse'),
#Rule(LinkExtractor(), 'parse_item_and_links'),
... | code_fim | hard | {
"lang": "python",
"repo": "nguyenminhthai/choinho",
"path": "/scraper/storage_spiders/phukiengiarecom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nguyenminhthai/choinho path: /scraper/storage_spiders/phukiengiarecom.py
# Auto generated by generator.py. Delete this line if you make modification.
from scrapy.spiders import Rule
from scrapy.linkextractors import LinkExtractor
XPATH = {
'name' : "//h1[@class='ty-product-block-title']",
... | code_fim | hard | {
"lang": "python",
"repo": "nguyenminhthai/choinho",
"path": "/scraper/storage_spiders/phukiengiarecom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.__update_amount((elapsed_iter / float(self.iterations)) * 100.0)
self.prog_bar += ' %d of %s complete' % (elapsed_iter, self.iterations)
def __update_amount(self, new_amount):
percent_done = int(round((new_amount / 100.0) * 100.0))
all_full = self.width - 2
... | code_fim | hard | {
"lang": "python",
"repo": "jansoe/FUImaging",
"path": "/regnmf/progress_bar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update_iteration(self, elapsed_iter):
self.__update_amount((elapsed_iter / float(self.iterations)) * 100.0)
self.prog_bar += ' %d of %s complete' % (elapsed_iter, self.iterations)
def __update_amount(self, new_amount):
percent_done = int(round((new_amount / 100.0) * 1... | code_fim | hard | {
"lang": "python",
"repo": "jansoe/FUImaging",
"path": "/regnmf/progress_bar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jansoe/FUImaging path: /regnmf/progress_bar.py
# -*- coding: utf-8 -*-
# from http://nbviewer.ipython.org/github/ipython/ipython/blob/3607712653c66d63e0d7f13f073bde8c0f209ba8/docs/examples/notebooks/Animations_and_Progress.ipynb
import sys
import time
import uuid
try:
from IPython.display i... | code_fim | medium | {
"lang": "python",
"repo": "jansoe/FUImaging",
"path": "/regnmf/progress_bar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dials/dials path: /tests/algorithms/refinement/test_angle_derivatives_wrt_vector_elts.py
"""Test analytical expression for the partial derivatives of an angle
between two vectors with respect to each element of the vectors"""
from __future__ import annotations
import math
import random
from l... | code_fim | hard | {
"lang": "python",
"repo": "dials/dials",
"path": "/tests/algorithms/refinement/test_angle_derivatives_wrt_vector_elts.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> theta_fwd = math.acos(self._vec_u.dot(v_fwd) / (v_fwd.length() * self._u))
theta_rev = math.acos(self._vec_u.dot(v_rev) / (v_rev.length() * self._u))
return (theta_fwd - theta_rev) / self._delta
def dtheta_du_1(self):
return self.dtheta_du_elt(0)
def dtheta_du_2(... | code_fim | hard | {
"lang": "python",
"repo": "dials/dials",
"path": "/tests/algorithms/refinement/test_angle_derivatives_wrt_vector_elts.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.multicast is not None:
conf['mcast_ipaddr'] = args.multicast
conf['message_len'] = 5000
if args.length is not None:
conf['message_len'] = args.length
conf['num'] = 10
if args.num is not None:
conf['num'] = args.num
if __name__ == '__main__':
loop ... | code_fim | hard | {
"lang": "python",
"repo": "baessler/pmul",
"path": "/pmul/examples/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: baessler/pmul path: /pmul/examples/client.py
#!/usr/bin/python3
"""
This script creates a P_MUL client which delivers multiple messages to a destination P_MUL server.
"""
import sys
sys.path.append("../")
import pmul
import asyncio
import argparse
class ClientProtocol(pmul.PmulProtocol):
d... | code_fim | hard | {
"lang": "python",
"repo": "baessler/pmul",
"path": "/pmul/examples/client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.bind is not None:
conf['src_ipaddr'] = args.bind
conf['destination'] = '127.0.0.1'
if args.destination is None:
parser.print_help()
exit()
else:
conf['destination'] = args.destination
if args.multicast is not None:
conf['mcast_ipaddr'] ... | code_fim | hard | {
"lang": "python",
"repo": "baessler/pmul",
"path": "/pmul/examples/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate the distance from one observation point to the object
# using the Law of Sines
#
# d L
# -------- --------
# sin(t_1) sin(t_3)
#
# th_3 = 180 - th_1 - th_2
#
# L : separation distance
# th_1 : angle 1
# th_2 : angle 2
#
theta_3 = 180*units.d... | code_fim | medium | {
"lang": "python",
"repo": "CD3/pyErrorProp",
"path": "/examples/triangulation.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(Angle1, Angle2, Seperation)
# enable error propgation
prop = PositiveIntervalPropagator()
prop.set_return_uncertainties(True)
@WithErrorPropagator(prop)
def calc( theta_1, theta_2, seperation ):
# Calculate the distance from one observation point to the object
# using the Law of Sines
#
#... | code_fim | medium | {
"lang": "python",
"repo": "CD3/pyErrorProp",
"path": "/examples/triangulation.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CD3/pyErrorProp path: /examples/triangulation.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from pyErrorProp import *
print()
# CONFIGURATION
#
# measure two angles separated by some distance
Angle1 = UQ_(93.5, 0.8)*units.degree
Angle2 = UQ_(83.1, 0.8)*units.degree
Seperation = UQ... | code_fim | hard | {
"lang": "python",
"repo": "CD3/pyErrorProp",
"path": "/examples/triangulation.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cprecioso/wheelchair-design-platform path: /code/raspberry/mega.py
import os
import signal
from random import randint
import output
from hub import Property, upload
from internal_serial import SEMICOLON, Message, serial
def setup():
None
<|fim_suffix|> messageId = int(args.pop(0))... | code_fim | hard | {
"lang": "python",
"repo": "cprecioso/wheelchair-design-platform",
"path": "/code/raspberry/mega.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> messageId = int(args.pop(0))
if messageId == Message.kStatus:
print("Status:", args[0])
upload(Property.Status, args[0])
elif messageId == Message.kGPS:
lat = float(args[0])
lon = float(args[1])
upload(Property.Location, ... | code_fim | hard | {
"lang": "python",
"repo": "cprecioso/wheelchair-design-platform",
"path": "/code/raspberry/mega.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.setWindowIcon(QtGui.QIcon(self.icon_name))
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self._init_ui_components()
self.show()
def _init_ui_components(self):
btn_event = QPushButton("Click me!", sel... | code_fim | hard | {
"lang": "python",
"repo": "vseenivasan/Python-GUI",
"path": "/YouTube-PyQt5/04_events_signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> btn_close = QPushButton("Close", self)
btn_close.setGeometry(QRect(100, 160, 200, 50))
btn_close.clicked.connect(self._close_click)
def _button_click(self):
print("Hello button click!")
def _close_click(self):
sys.exit()
if __name__ == "__main__":
app... | code_fim | hard | {
"lang": "python",
"repo": "vseenivasan/Python-GUI",
"path": "/YouTube-PyQt5/04_events_signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vseenivasan/Python-GUI path: /YouTube-PyQt5/04_events_signals.py
import sys
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QPushButton, QMainWindow
from PyQt5.QtCore import QRect
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
... | code_fim | hard | {
"lang": "python",
"repo": "vseenivasan/Python-GUI",
"path": "/YouTube-PyQt5/04_events_signals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CaltechExperimentalGravity/RLzoo path: /rlzoo/algorithms/ddpg/default.py
from rlzoo.common.policy_networks import *
from rlzoo.common.value_networks import *
from rlzoo.common.utils import set_seed
"""
full list of algorithm parameters (alg_params)
----------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "CaltechExperimentalGravity/RLzoo",
"path": "/rlzoo/algorithms/ddpg/default.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def dm_control(env, default_seed=True):
if default_seed:
# reproducible
seed = 2
set_seed(seed, env)
alg_params = dict(
replay_buffer_size=10000,
tau=0.01,
)
if alg_params.get('net_list') is None:
num_hidden_layer = 2 # number of hidden la... | code_fim | hard | {
"lang": "python",
"repo": "CaltechExperimentalGravity/RLzoo",
"path": "/rlzoo/algorithms/ddpg/default.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LangJin/BasicsRolePro path: /FlaskServer/run.py
# -*- coding:utf-8 -*-
__author__ = 'LangJin'
from app import create_app
from flask_cors import CORS
import logging
app = create_app()
<|fim_suffix|>if __name__ == "__main__":
app.run(host="0.0.0.0",port=8282)<|fim_middle|>
cors = CORS(app,... | code_fim | easy | {
"lang": "python",
"repo": "LangJin/BasicsRolePro",
"path": "/FlaskServer/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
app.run(host="0.0.0.0",port=8282)<|fim_prefix|># repo: LangJin/BasicsRolePro path: /FlaskServer/run.py
# -*- coding:utf-8 -*-
__author__ = 'LangJin'
from app import create_app
from flask_cors import CORS
import logging
app = create_app()
<|fim_middle|>cors = CORS(app... | code_fim | easy | {
"lang": "python",
"repo": "LangJin/BasicsRolePro",
"path": "/FlaskServer/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Parse MassBank entry.
def _parse_massbank(usi: str) -> Tuple[sus.MsmsSpectrum, str]:
match = _match_usi(usi)
index_flag = match.group(3)
if index_flag.lower() != 'accession':
raise ValueError('Currently supported MassBank index flags: accession')
index = match.group(4)
try:
... | code_fim | hard | {
"lang": "python",
"repo": "cthoyt-forks-and-packages/MetabolomicsSpectrumResolver",
"path": "/parsing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Parse MS2LDA from ms2lda.org.
def _parse_ms2lda(usi: str) -> Tuple[sus.MsmsSpectrum, str]:
match = _match_usi(usi)
ms2lda_task_match = ms2lda_task_pattern.match(match.group(2))
if ms2lda_task_match is None:
raise ValueError('Incorrectly formatted MS2LDA task')
experiment_id = ms... | code_fim | hard | {
"lang": "python",
"repo": "cthoyt-forks-and-packages/MetabolomicsSpectrumResolver",
"path": "/parsing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cthoyt-forks-and-packages/MetabolomicsSpectrumResolver path: /parsing.py
import functools
import json
import re
from typing import Tuple
import requests
import spectrum_utils.spectrum as sus
import parsing_legacy
MS2LDA_SERVER = 'http://ms2lda.org/basicviz/'
MOTIFDB_SERVER = 'http://ms2lda.org... | code_fim | hard | {
"lang": "python",
"repo": "cthoyt-forks-and-packages/MetabolomicsSpectrumResolver",
"path": "/parsing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: patrickxie/invengine path: /server/api/invengine.py
# -*- coding: utf-8 -*-
from flask import Blueprint, request, jsonify
from flask_restful import Api, Resource
from models import User, Invite #import invenine model here
import uuid
from rq import Queue
from worker import conn
from tasks import ... | code_fim | hard | {
"lang": "python",
"repo": "patrickxie/invengine",
"path": "/server/api/invengine.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def post(invengine_id):
q = Queue('low', connection=conn)
data = request.json
job = q.enqueue_call(
func=parse_invite_data, args=(data,), result_ttl=5000
)
return jsonify({'success': True, 'id': invengine_id})<|fim_prefix|># repo: p... | code_fim | hard | {
"lang": "python",
"repo": "patrickxie/invengine",
"path": "/server/api/invengine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tok = str(uuid.uuid4())
new_user = User(token=tok)
db.session.add(new_user)
db.session.commit()
print('we adding a new user :', new_user.id)
return jsonify({'invengine_id': new_user.id, 'token': tok})
@invengine_api.resource('/invites/<string:invengine_id>... | code_fim | hard | {
"lang": "python",
"repo": "patrickxie/invengine",
"path": "/server/api/invengine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: klmitch/requiem path: /requiem/__init__.py
# Copyright 2011 OpenStack LLC.
# 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. You may obtain
# a copy of the License at
#
# h... | code_fim | hard | {
"lang": "python",
"repo": "klmitch/requiem",
"path": "/requiem/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Import everything
from requiem import client
from requiem import decorators
from requiem import exceptions
from requiem import headers
from requiem import processor
from requiem import request
# Build up our __all__ and import all the symbols
__all__ = []
for _mod in (client, decorators, exceptions, h... | code_fim | hard | {
"lang": "python",
"repo": "klmitch/requiem",
"path": "/requiem/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return resp.read()
To use this client:
>>> hc = HelloClient('http://example.com')
>>> hc.hello()
'world'
For information about the request that is passed to @restmethod()
decorated methods, see the documentation for HTTPRequest, as well as
the documentation for @restmethod() its... | code_fim | medium | {
"lang": "python",
"repo": "klmitch/requiem",
"path": "/requiem/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sabuhish/fastapi-mail path: /fastapi_mail/config.py
from typing import Optional
from aiosmtplib.api import DEFAULT_TIMEOUT
from jinja2 import Environment, FileSystemLoader
from pydantic import DirectoryPath, EmailStr, conint
from pydantic_settings import BaseSettings as Settings
class Connecti... | code_fim | hard | {
"lang": "python",
"repo": "sabuhish/fastapi-mail",
"path": "/fastapi_mail/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def template_engine(self) -> Environment:
"""
Return template environment
"""
folder = self.TEMPLATE_FOLDER
if not folder:
raise ValueError(
"Class initialization did not include a ``TEMPLATE_FOLDER`` ``PathLike`` object."
... | code_fim | hard | {
"lang": "python",
"repo": "sabuhish/fastapi-mail",
"path": "/fastapi_mail/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Return template environment
"""
folder = self.TEMPLATE_FOLDER
if not folder:
raise ValueError(
"Class initialization did not include a ``TEMPLATE_FOLDER`` ``PathLike`` object."
)
template_env = Environment(loader=F... | code_fim | hard | {
"lang": "python",
"repo": "sabuhish/fastapi-mail",
"path": "/fastapi_mail/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ycharts/pycharts path: /pycharts/exceptions.py
class PyChartsRequestException(Exception):
def __init__(self, error_message=''):
self.error_message = error_message
self.error_code = 400
def __str__(self):
return '{0} code:{1}'.format(self.error_message, self.erro... | code_fim | medium | {
"lang": "python",
"repo": "ycharts/pycharts",
"path": "/pycharts/exceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, error_message=None):
self.error_message = error_message
self.error_code = 414<|fim_prefix|># repo: ycharts/pycharts path: /pycharts/exceptions.py
class PyChartsRequestException(Exception):
def __init__(self, error_message=''):
self.error_message = erro... | code_fim | hard | {
"lang": "python",
"repo": "ycharts/pycharts",
"path": "/pycharts/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@login_required(login_url='login')
def camera_video(request):
return StreamingHttpResponse(frame_generator(0), content_type="multipart/x-mixed-replace; boundary=frame")
@login_required(login_url='login')
def live_video(request):
return StreamingHttpResponse(frame_generator("rtsp://admin:admin@5... | code_fim | hard | {
"lang": "python",
"repo": "fang-zh16/Python",
"path": "/live_version/intelligent_monitoring_platform/main/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@login_required(login_url='login')
def new_alarms(request):
alarms = Alarm.objects.order_by("-id").all()
result = []
for alarm in alarms:
if alarm.visible == 1:
result.append({
"id": alarm.id,
"alarm_class": "检测到人",
"time_begi... | code_fim | hard | {
"lang": "python",
"repo": "fang-zh16/Python",
"path": "/live_version/intelligent_monitoring_platform/main/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fang-zh16/Python path: /live_version/intelligent_monitoring_platform/main/views.py
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import sqlite3
import time
import cv2
import base64
import json
import queue
import th... | code_fim | hard | {
"lang": "python",
"repo": "fang-zh16/Python",
"path": "/live_version/intelligent_monitoring_platform/main/views.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jurek333/playful_python path: /rhymer/test.py
#!/usr/bin/env python3
"""tests for rhymer.py"""
import os
from subprocess import getoutput
prg = './rhymer.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# ----------... | code_fim | hard | {
"lang": "python",
"repo": "jurek333/playful_python",
"path": "/rhymer/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out = getoutput('{} apple'.format(prg)).splitlines()
assert len(out) == 57
assert out[10] == 'napple'
assert out[-10] == 'wrapple'
# --------------------------------------------------
def test_no_vowels():
"""no vowels"""
out = getoutput('{} bbb'.format(prg))
assert out == '... | code_fim | hard | {
"lang": "python",
"repo": "jurek333/playful_python",
"path": "/rhymer/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> title
benchmarks[i + 1] = int(benchmark)
benchmarks[N + 1] = 1000000007
titles[N + 1] = 'none'
for j in range(M):
print(bin_search(int(sys.stdin.readline())))<|fim_prefix|># repo: Jin-RHC/daily_algo path: /2021/Oct/1009/19637_IF문좀대신써줘/s1.py
import sys
def bin_search(number):
start = 1
e... | code_fim | hard | {
"lang": "python",
"repo": "Jin-RHC/daily_algo",
"path": "/2021/Oct/1009/19637_IF문좀대신써줘/s1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jin-RHC/daily_algo path: /2021/Oct/1009/19637_IF문좀대신써줘/s1.py
import sys
def bin_search(number):
start = 1
end = N
while start <= end:
mid = (start + end) // 2
if benchmarks[mid - 1] < number <= benc<|fim_suffix|>t, input().split())
benchmarks = [-1] * (N + 2)
titles =... | code_fim | medium | {
"lang": "python",
"repo": "Jin-RHC/daily_algo",
"path": "/2021/Oct/1009/19637_IF문좀대신써줘/s1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evkumar71/py_geo_serv path: /geoservices.py
import json, signal
import tornado.ioloop
import tornado.web
from tornado.httpclient import AsyncHTTPClient
import urllib.parse
import tornado.gen
adrs_request_url = "https://geocoder.api.here.com/6.2/geocode.json?app_id=pb0CIzZpApR3GtVA0b0R&app... | code_fim | medium | {
"lang": "python",
"repo": "evkumar71/py_geo_serv",
"path": "/geoservices.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @tornado.gen.coroutine
def get(self):
# encode user input properly
address_string = urllib.parse.quote(self.get_argument("address"))
http_client = AsyncHTTPClient()
response = yield http_client.fetch(adrs_request_url + address_string, method="GET")
res... | code_fim | medium | {
"lang": "python",
"repo": "evkumar71/py_geo_serv",
"path": "/geoservices.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # encode user input properly
address_string = urllib.parse.quote(self.get_argument("address"))
http_client = AsyncHTTPClient()
response = yield http_client.fetch(coord_request_url + address_string, method="GET")
response_json = json.loads(response.body)
... | code_fim | hard | {
"lang": "python",
"repo": "evkumar71/py_geo_serv",
"path": "/geoservices.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DobroAlex/asyncio_TCP_chat path: /AsyncChatV1/client/src/main.py
import threading
from routines import establish_connection, receiving_routine, forwarding_routine
<|fim_suffix|> main_socket = establish_connection.establish_connection('127.0.0.1', 8088)
receiving = threading.Thread(targ... | code_fim | medium | {
"lang": "python",
"repo": "DobroAlex/asyncio_TCP_chat",
"path": "/AsyncChatV1/client/src/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> running_threads = (receiving, sending)
for thread in running_threads:
thread.start()
while True:
for thread in running_threads:
if not thread.is_alive():
print(f'Thread {thread.name} is dead, aborting execution')
return
if __name_... | code_fim | hard | {
"lang": "python",
"repo": "DobroAlex/asyncio_TCP_chat",
"path": "/AsyncChatV1/client/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while True:
for thread in running_threads:
if not thread.is_alive():
print(f'Thread {thread.name} is dead, aborting execution')
return
if __name__ == '__main__':
main()<|fim_prefix|># repo: DobroAlex/asyncio_TCP_chat path: /AsyncChatV1/client/... | code_fim | hard | {
"lang": "python",
"repo": "DobroAlex/asyncio_TCP_chat",
"path": "/AsyncChatV1/client/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KratosMultiphysics/Kratos path: /applications/TrilinosApplication/TrilinosApplication.py
from KratosMultiphysics import _ImportApplication
from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable
import KratosMultiphysics.mpi # importing the MPI-Core, since the TrilinosApp dir... | code_fim | medium | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/TrilinosApplication/TrilinosApplication.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> *
application = KratosTrilinosApplication()
application_name = "KratosTrilinosApplication"
_ImportApplication(application, application_name)<|fim_prefix|># repo: KratosMultiphysics/Kratos path: /applications/TrilinosApplication/TrilinosApplication.py
from KratosMultiphysics import _ImportApplication
fr... | code_fim | medium | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/TrilinosApplication/TrilinosApplication.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> generator = reverse3(output)
pool = Pool(threads)
while True:
options = np.array([next(generator) for _ in range(BATCH_SIZE)], dtype=np.uint8)
tq = tqdm(range(ROUNDS), leave=False)
for _ in tq:
options = np.vstack(pool.map(reverse21, np.array_split(options, ... | code_fim | medium | {
"lang": "python",
"repo": "rnbwdsh/nintendo_hireme",
"path": "/python/reverse_fast/full.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def reverse(output, threads=32):
generator = reverse3(output)
pool = Pool(threads)
while True:
options = np.array([next(generator) for _ in range(BATCH_SIZE)], dtype=np.uint8)
tq = tqdm(range(ROUNDS), leave=False)
for _ in tq:
options = np.vstack(pool.map(r... | code_fim | medium | {
"lang": "python",
"repo": "rnbwdsh/nintendo_hireme",
"path": "/python/reverse_fast/full.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rnbwdsh/nintendo_hireme path: /python/reverse_fast/full.py
from multiprocessing import Pool
from time import time
from numba import jit
from tqdm import tqdm
from reverse_fast.split import *
from constants import *
@jit(nopython=True)
def reverse21_(options, rfw1np):
return [reverse1(reve... | code_fim | hard | {
"lang": "python",
"repo": "rnbwdsh/nintendo_hireme",
"path": "/python/reverse_fast/full.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> telemetry_logger = utils.TelemetryLogger(enable_telemetry=True)
telemetry_logger.log_trace(
message="A unit test message of shrike.build. Please ignore it.",
level=logging.INFO,
)<|fim_prefix|># repo: Anbang-Hu/shrike path: /tests/tests_build/utils/test_utils.py
# Copyright (c... | code_fim | hard | {
"lang": "python",
"repo": "Anbang-Hu/shrike",
"path": "/tests/tests_build/utils/test_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Unit tests for utils class of opencensus azure monitor"""
telemetry_logger = utils.TelemetryLogger()
assert (
telemetry_logger.instrumentation_key == "aaefce9e-d109-4fac-bb9f-8277c68e91ac"
)
assert telemetry_logger.enable_telemetry
telemetry_logger = utils.TelemetryLogg... | code_fim | hard | {
"lang": "python",
"repo": "Anbang-Hu/shrike",
"path": "/tests/tests_build/utils/test_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Anbang-Hu/shrike path: /tests/tests_build/utils/test_utils.py
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from pathlib import Path
import pytest
import logging
from shrike.build.utils import utils
@pytest.mark.parametrize(
"file_name,expected_hash",
[
... | code_fim | hard | {
"lang": "python",
"repo": "Anbang-Hu/shrike",
"path": "/tests/tests_build/utils/test_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.