text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: tomaae/homeassistant-mikrotik_router path: /custom_components/mikrotik_router/device_tracker_types.py
"""Definitions for Mikrotik Router device tracker entities."""
from dataclasses import dataclass, field
from typing import List
from homeassistant.helpers.device_registry import CONNECTION_NETWOR... | code_fim | hard | {
"lang": "python",
"repo": "tomaae/homeassistant-mikrotik_router",
"path": "/custom_components/mikrotik_router/device_tracker_types.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> key: str = ""
name: str = ""
device_class = None
icon_enabled: str = ""
icon_disabled: str = ""
ha_group: str = ""
ha_connection: str = ""
ha_connection_value: str = ""
data_path: str = ""
data_attribute: str = "available"
data_name: str = ""
data_uid: str =... | code_fim | medium | {
"lang": "python",
"repo": "tomaae/homeassistant-mikrotik_router",
"path": "/custom_components/mikrotik_router/device_tracker_types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.a,self.b = self.b,self.a+self.b
return self.a
def __iter__(self):
return self
# fibs=Fibs()
# for i in fibs:
# print(i)
# if i>100:
# break
ls=[1,2,3]
it=iter(ls)
# print(next(ls))
print(next(it))
print(next(it))<|fim_prefix|># repo: wangjinyu124419/begi... | code_fim | easy | {
"lang": "python",
"repo": "wangjinyu124419/beginning-python",
"path": "/9_魔法方法/9.6迭代器.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangjinyu124419/beginning-python path: /9_魔法方法/9.6迭代器.py
class Fibs():
def __init__(self):
self.a=1
self.b=1
def __next__(self):
<|fim_suffix|>ls=[1,2,3]
it=iter(ls)
# print(next(ls))
print(next(it))
print(next(it))<|fim_middle|> self.a,self.b = self.b,self.a+self.... | code_fim | medium | {
"lang": "python",
"repo": "wangjinyu124419/beginning-python",
"path": "/9_魔法方法/9.6迭代器.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self
# fibs=Fibs()
# for i in fibs:
# print(i)
# if i>100:
# break
ls=[1,2,3]
it=iter(ls)
# print(next(ls))
print(next(it))
print(next(it))<|fim_prefix|># repo: wangjinyu124419/beginning-python path: /9_魔法方法/9.6迭代器.py
class Fibs():
def __init__(self):
self.a=1... | code_fim | medium | {
"lang": "python",
"repo": "wangjinyu124419/beginning-python",
"path": "/9_魔法方法/9.6迭代器.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jabesq/netatmo-api-python path: /src/pyatmo/thermostat.py
import logging
from collections import defaultdict
from typing import Any, Dict, Optional
from .auth import NetatmoOAuth2
from .exceptions import InvalidRoom, NoDevice, NoSchedule
from .helpers import _BASE_URL
LOG = logging.getLogger(__... | code_fim | hard | {
"lang": "python",
"repo": "jabesq/netatmo-api-python",
"path": "/src/pyatmo/thermostat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return the setpointmode of a given room."""
return self.get_room(room_id).get("therm_setpoint_mode")
def measured_temperature(self, room_id: str) -> Optional[float]:
"""Return the measured temperature of a given room."""
return self.get_room(room_id).get("therm_meas... | code_fim | hard | {
"lang": "python",
"repo": "jabesq/netatmo-api-python",
"path": "/src/pyatmo/thermostat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> project = "project"
feature_set = "FeatureSet"
background_task = "BackgroundTask"
feature_vector = "FeatureVector"
model_endpoint = "model-endpoint"
marketplace_source = "MarketplaceSource"
marketplace_item = "MarketplaceItem"
marketplace_catalog = "MarketplaceCatalog"<|fim... | code_fim | hard | {
"lang": "python",
"repo": "eran-nussbaum/mlrun",
"path": "/mlrun/api/schemas/object.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eran-nussbaum/mlrun path: /mlrun/api/schemas/object.py
from datetime import datetime
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Extra
class ObjectMetadata(BaseModel):
name: str
project: Optional[str]
tag: Optional[str]
labels: Option... | code_fim | medium | {
"lang": "python",
"repo": "eran-nussbaum/mlrun",
"path": "/mlrun/api/schemas/object.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> bbox: Tuple[float, float, float, float]) -> xr.Dataset:
"""Create a spatial subset from given dataset."""
x1, y1, x2, y2 = bbox
gm = GridMapping.from_dataset(dataset)
x_name, y_name = gm.xy_dim_names
return dataset.sel({
x_name: slice(x1, x2),
y_name:... | code_fim | hard | {
"lang": "python",
"repo": "dcs4cop/xcube",
"path": "/xcube/webapi/compute/operations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dcs4cop/xcube path: /xcube/webapi/compute/operations.py
from typing import Tuple
import xarray as xr
from xcube.core.gridmapping import GridMapping
<|fim_suffix|>
@operation
@op_param("bbox",
title="Bounding box",
description="Bounding box using the dataset's CRS coordinate... | code_fim | medium | {
"lang": "python",
"repo": "dcs4cop/xcube",
"path": "/xcube/webapi/compute/operations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tanyaweaver/code-katas path: /src/list_rotation.py
from collections import deque
def rotation1(l, num):
<|fim_suffix|>def list_rotation(l, num):
if l and num and num != 0 and abs(num) < len(l):
if num > 0:
return l[len(l)-num:] + l[:len(l)-num]
elif num < 0:
... | code_fim | easy | {
"lang": "python",
"repo": "tanyaweaver/code-katas",
"path": "/src/list_rotation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if l and num and num != 0 and abs(num) < len(l):
if num > 0:
return l[len(l)-num:] + l[:len(l)-num]
elif num < 0:
return l[-num:] + l[:-num]
else:
return l<|fim_prefix|># repo: tanyaweaver/code-katas path: /src/list_rotation.py
from collections impo... | code_fim | medium | {
"lang": "python",
"repo": "tanyaweaver/code-katas",
"path": "/src/list_rotation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kami93/SortMyConf path: /errors.py
class Error(Exception):
"""Base class for exceptions in this module."""
pass
class RobotError(Error):
"""Exception raised for robot detection (solvable).
<|fim_suffix|> """Exception raised for auto-query detection.
Attributes:
messa... | code_fim | medium | {
"lang": "python",
"repo": "kami93/SortMyConf",
"path": "/errors.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> Attributes:
message -- explanation of the error (non-solvable).
"""
def __init__(self):
self.message = "No more alternative addresses. Restart this program."<|fim_prefix|># repo: kami93/SortMyConf path: /errors.py
class Error(Exception):
"""Base class for exceptions in th... | code_fim | hard | {
"lang": "python",
"repo": "kami93/SortMyConf",
"path": "/errors.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nickliqian/keep_learning path: /ReadBook/MachineLearning/code/均方误差.py
import random
array = []
for i in range(10):
a = random.random()*10
b = random.random()*10
array.append((a, b))
<|fim_suffix|>result = 0
for j in array:
s = (j[0]-j[1])**2
result += s
print(result)<|fim_m... | code_fim | easy | {
"lang": "python",
"repo": "nickliqian/keep_learning",
"path": "/ReadBook/MachineLearning/code/均方误差.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>result = 0
for j in array:
s = (j[0]-j[1])**2
result += s
print(result)<|fim_prefix|># repo: nickliqian/keep_learning path: /ReadBook/MachineLearning/code/均方误差.py
import random
array = []
for i in range(10):
a = random.random()*10
b = random.random()*10
array.append((a, b))
<|fim_m... | code_fim | easy | {
"lang": "python",
"repo": "nickliqian/keep_learning",
"path": "/ReadBook/MachineLearning/code/均方误差.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jmribeiro/yaaf path: /yaaf/agents/HumanAgent.py
from yaaf.agents import Agent
class HumanAgent(Agent):
def __init__(self, action_meanings=None, num_actions=None, name="Human Agent", prompt="Enter an action"):
<|fim_suffix|> try:
action = int(input("> "))
... | code_fim | hard | {
"lang": "python",
"repo": "jmribeiro/yaaf",
"path": "/yaaf/agents/HumanAgent.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def action(self, observation):
invalid = True
while invalid:
print(f"{self._prompt}\n", end="")
if len(self._action_meanings) > 0:
[print(f"{a}: {meaning}\n", end="") for a, meaning in enumerate(self._action_meanings)]
else:
... | code_fim | hard | {
"lang": "python",
"repo": "jmribeiro/yaaf",
"path": "/yaaf/agents/HumanAgent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(f"{self._prompt}\n", end="")
if len(self._action_meanings) > 0:
[print(f"{a}: {meaning}\n", end="") for a, meaning in enumerate(self._action_meanings)]
else:
[print(f"{a}\n", end="") for a in range(self._num_actions)]
t... | code_fim | hard | {
"lang": "python",
"repo": "jmribeiro/yaaf",
"path": "/yaaf/agents/HumanAgent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xtblock/chromium path: /third_party/tensorflow-text/src/tensorflow_text/python/ops/pad_model_inputs_ops.py
# coding=utf-8
# Copyright 2021 TF.Text Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You ... | code_fim | hard | {
"lang": "python",
"repo": "xtblock/chromium",
"path": "/third_party/tensorflow-text/src/tensorflow_text/python/ops/pad_model_inputs_ops.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
input: A `RaggedTensor` with rank >= 2.
max_seq_length: An int, or scalar `Tensor`. The "input" `Tensor` will be
flattened down to 2 dimensions and then have its 2nd dimension either
padded out or truncated to this size.
pad_value: An int or scalar `Tensor` specifying the v... | code_fim | hard | {
"lang": "python",
"repo": "xtblock/chromium",
"path": "/third_party/tensorflow-text/src/tensorflow_text/python/ops/pad_model_inputs_ops.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Pad model input and generate corresponding input masks.
`pad_model_inputs` performs the final packaging of a model's inputs commonly
found in text models. This includes padding out (or simply truncating) to a
fixed-size, 2-dimensional `Tensor` and generating mask `Tensor`s (of the same
2D sh... | code_fim | medium | {
"lang": "python",
"repo": "xtblock/chromium",
"path": "/third_party/tensorflow-text/src/tensorflow_text/python/ops/pad_model_inputs_ops.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codingPingjun/SuspiciousRegionWSI path: /genFeas/deep_fea.py
# -*- coding: utf-8 -*-
import os, sys
import argparse
import numpy as np
import torch
import torch.backends.cudnn as cudnn
from fea_gen import gen_deep_features
def set_args():
parser = argparse.ArgumentParser(description='Thyro... | code_fim | medium | {
"lang": "python",
"repo": "codingPingjun/SuspiciousRegionWSI",
"path": "/genFeas/deep_fea.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_full_path = os.path.join(args.model_dir, args.model_name, args.model_path)
ft_model = torch.load(model_full_path)
ft_model.cuda()
print("Starting feature generation...")
gen_deep_features(args.roi_dir, args.fea_dir, args.data_mode, ft_model, args)<|fim_prefix|># repo: codingPing... | code_fim | medium | {
"lang": "python",
"repo": "codingPingjun/SuspiciousRegionWSI",
"path": "/genFeas/deep_fea.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
args = set_args()
os.environ["CUDA_VISIBLE_DEVICES"] = args.device_id
model_full_path = os.path.join(args.model_dir, args.model_name, args.model_path)
ft_model = torch.load(model_full_path)
ft_model.cuda()
print("Starting feature generation...")
gen... | code_fim | hard | {
"lang": "python",
"repo": "codingPingjun/SuspiciousRegionWSI",
"path": "/genFeas/deep_fea.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kalyons11/kevin path: /kevin/tests/leet/test_check_binary_codes.py
"""
https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/589/week-2-march-8th-march-14th/3669/
"""
from unittest import TestCase
from kevin.leet.check_binary_codes import Solution
<|fim_suffix|> s ... | code_fim | hard | {
"lang": "python",
"repo": "kalyons11/kevin",
"path": "/kevin/tests/leet/test_check_binary_codes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = '00110110'
k = 2
expected = True
self._base_test_check_binary_codes(s, k, expected)
def test_check_binary_codes_medium(self):
s = '00110'
k = 2
expected = True
self._base_test_check_binary_codes(s, k, expected)
def test_check_bi... | code_fim | medium | {
"lang": "python",
"repo": "kalyons11/kevin",
"path": "/kevin/tests/leet/test_check_binary_codes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zge/tacotron2-vae path: /visualize_tsne.py
import sys
sys.path.append('waveglow/')
import numpy as np
import torch
from hparams_soe import create_hparams
from model import Tacotron2
from layers import TacotronSTFT
from train import load_model
from text import text_to_sequence
from utils import... | code_fim | hard | {
"lang": "python",
"repo": "zge/tacotron2-vae",
"path": "/visualize_tsne.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> model.eval()
prosody_outputs = []
emotions = []
mus = []
zs = []
for audio_path, _, _, emotion in tqdm(filepaths_and_text):
melspec = load_mel(audio_path)
prosody, mu, _, z = model.vae_gst(melspec)
prosody_outputs.append(prosody.squeeze(1).cpu().data)
mus.a... | code_fim | hard | {
"lang": "python",
"repo": "zge/tacotron2-vae",
"path": "/visualize_tsne.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> raw_docstring = '\n'.join([
'Return the number four.',
'',
'Returns',
'-------',
'number : int',
' A number to use.',
'',
])
tokens = condense(lex(raw_docstring))
docstring = parse(tokens... | code_fim | hard | {
"lang": "python",
"repo": "terrencepreilly/darglint",
"path": "/tests/test_numpy_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: terrencepreilly/darglint path: /tests/test_numpy_parser.py
ge_template=None,
style=DocstringStyle.NUMPY,
strictness=Strictness.FULL_DESCRIPTION,
)
self.config = self.config_context.__enter__()
def tearDown(self):
self.config_context.__exit__(No... | code_fim | hard | {
"lang": "python",
"repo": "terrencepreilly/darglint",
"path": "/tests/test_numpy_parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: terrencepreilly/darglint path: /tests/test_numpy_parser.py
import (
ArgumentItemIdentifier,
ArgumentTypeIdentifier,
NoqaIdentifier,
ExceptionIdentifier,
ExceptionItemIdentifier,
)
from darglint.errors import (
EmptyTypeError,
)
from darglint.utils import (
Configuratio... | code_fim | hard | {
"lang": "python",
"repo": "terrencepreilly/darglint",
"path": "/tests/test_numpy_parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tim1512/Wall-of-Shame path: /APP/app.py
#!/usr/bin/env python3
import json
import mysql.connector
from flask import Flask,render_template
with open("config",'r') as file:
CONFIG = json.load(file)
<|fim_suffix|>
@app.route('/')
def home():
cnx = mysql.connector.connect(user=CONFIG['db_user... | code_fim | hard | {
"lang": "python",
"repo": "Tim1512/Wall-of-Shame",
"path": "/APP/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route('/')
def home():
cnx = mysql.connector.connect(user=CONFIG['db_user'],password=CONFIG['db_pass'],host="localhost",database='pine_db')
cursor = cnx.cursor()
cursor.execute('select * from clientcreds')
clientcreds = cursor.fetchall()
cursor.execute('select * from clients')
clientdata... | code_fim | hard | {
"lang": "python",
"repo": "Tim1512/Wall-of-Shame",
"path": "/APP/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> await time_out_assert(20, wallet_is_synced, True, wallet_nodes[0], full_node_api)
status: PoolWalletInfo = (await client.pw_status(wallet_id))[0]
leave_pool_tx: Dict[str, Any] = await client.pw_self_pool(wallet_id, fee)
assert leave_pool_tx["transaction"].... | code_fim | hard | {
"lang": "python",
"repo": "xorinox/chia-blockchain",
"path": "/tests/pools/test_pool_rpc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xorinox/chia-blockchain path: /tests/pools/test_pool_rpc.py
assert status.tip_singleton_coin_id != new_status.tip_singleton_coin_id
status = new_status
assert ret["fee_transaction"] is None
bal2 = await client.get_wallet_balance(2)
... | code_fim | hard | {
"lang": "python",
"repo": "xorinox/chia-blockchain",
"path": "/tests/pools/test_pool_rpc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xorinox/chia-blockchain path: /tests/pools/test_pool_rpc.py
llet_node_0.wallet_state_manager.blockchain.get_peak_height, PREFARMED_BLOCKS)
await time_out_assert(20, wallet_is_synced, True, wallet_node_0, full_node_api)
our_ph = await wallet_0.get_new_puzzlehash()
assert l... | code_fim | hard | {
"lang": "python",
"repo": "xorinox/chia-blockchain",
"path": "/tests/pools/test_pool_rpc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ved-mohan/python-kanban path: /tests/test_no_tasks_view.py
from mock import Mock
from prompt_toolkit.key_binding.key_processor import KeyPress, KeyProcessor
<|fim_suffix|>
def test_keybinding_add_task():
"""
When 'a' is pressed, it should trigger the main app to load the 'add task
vi... | code_fim | medium | {
"lang": "python",
"repo": "ved-mohan/python-kanban",
"path": "/tests/test_no_tasks_view.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mocked_app.load_add_task_view.assert_called_once()
def test_keybinding_quit():
"""
When 'q' is pressed, check if the `exit` method was called
"""
mocked_app = Mock()
view = NoTasksView(app=mocked_app)
processor = KeyProcessor(view.load_key_bindings())
processor.feed(Key... | code_fim | hard | {
"lang": "python",
"repo": "ved-mohan/python-kanban",
"path": "/tests/test_no_tasks_view.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rivergillis/pytis path: /tests.py
self.assertIsNone(n3.adjacency["RIGHT"])
self.assertIsNone(n3.adjacency["UP"])
self.assertEqual(n4.adjacency["LEFT"], n2)
self.assertIsNone(n4.adjacency["DOWN"])
self.assertIsNone(n4.adjacency["RIGHT"])
self.assert... | code_fim | hard | {
"lang": "python",
"repo": "rivergillis/pytis",
"path": "/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(n2.acc, 4) # n2 picked up 4 from n1
self.assertEqual(n2.pc, 1) # n2 moved past mov
self.assertIsNone(n2.receiving) # n2 not receiving
self.assertFalse(n2.receiving_into_acc) # into its acc
self.assertIsNone(n2.sending) # n2 not trying to send t... | code_fim | hard | {
"lang": "python",
"repo": "rivergillis/pytis",
"path": "/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(n2.acc, 36) # n2 has added
self.assertEqual(n2.pc, 0) # left the mov, now back to 0
self.assertEqual(n2.receiving, n1) # n2 receiving from n1
self.assertTrue(n2.receiving_into_acc) # into its acc
self.assertIsNone(n2.sending) # n2 not sending
... | code_fim | hard | {
"lang": "python",
"repo": "rivergillis/pytis",
"path": "/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def send_password_reset(self, recipient, link):
subject = _("Password reset request from ajenti")
html_template = self.get_template('reset_email')
logo_path = aj.config.data['logo']
with open(logo_path, "rb") as image:
base64_logo = base64.b64encode(image.r... | code_fim | hard | {
"lang": "python",
"repo": "ajenti/ajenti",
"path": "/ajenti-core/aj/api/mail.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ajenti/ajenti path: /ajenti-core/aj/api/mail.py
import os
import smtplib
import ssl
import logging
import base64
from bs4 import BeautifulSoup
from jinja2 import Template
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import aj
DEFAULT_TEMPLATES = {
'res... | code_fim | hard | {
"lang": "python",
"repo": "ajenti/ajenti",
"path": "/ajenti-core/aj/api/mail.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> html = MIMEText(content['html'], "html")
text = MIMEText(content['plain'], "plain")
message.attach(text)
message.attach(html)
return message.as_string()
def _send_starttls(self, subject, recipient, content):
message = self._prepare_content(subject, rec... | code_fim | hard | {
"lang": "python",
"repo": "ajenti/ajenti",
"path": "/ajenti-core/aj/api/mail.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>irrpAngles
from .header import Header
__all__ = [
"BirrpParameters",
"BirrpBlock",
"BirrpAngles",
"Header",
]<|fim_prefix|># repo: kujaku11/mt_metadata path: /mt_metadata/transfer_functions/io/jfiles/metadata/__init__.py
# package file
from .birrp_parameters import BirrpParameters
<|fim... | code_fim | medium | {
"lang": "python",
"repo": "kujaku11/mt_metadata",
"path": "/mt_metadata/transfer_functions/io/jfiles/metadata/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kujaku11/mt_metadata path: /mt_metadata/transfer_functions/io/jfiles/metadata/__init__.py
# package file
from .birrp_parameters import BirrpParameters
<|fim_suffix|>rameters",
"BirrpBlock",
"BirrpAngles",
"Header",
]<|fim_middle|>from .birrp_block import BirrpBlock
from .birrp_angles... | code_fim | medium | {
"lang": "python",
"repo": "kujaku11/mt_metadata",
"path": "/mt_metadata/transfer_functions/io/jfiles/metadata/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zw007981/MonocularSLAMBaxter path: /vision.py
#!/usr/bin/env python
from std_msgs.msg import String
import rospy
import baxter_interface
import sys
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
class file_saver():
<|fim_suffix|> def save(self, data... | code_fim | hard | {
"lang": "python",
"repo": "zw007981/MonocularSLAMBaxter",
"path": "/vision.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save(self, data):
global scene_number
#duration = (rospy.Time.now()-last_time).to_sec()
#Get end effector pose
left = baxter_interface.Limb('left').endpoint_pose()
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
except CvBridgeErr... | code_fim | hard | {
"lang": "python",
"repo": "zw007981/MonocularSLAMBaxter",
"path": "/vision.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: plotly/dash-docs path: /dash_docs/chapters/dash_core_components/Input/index.py
# -*- coding: utf-8 -*-
import dash_core_components as dcc
import dash_html_components as html
from dash_docs import styles
from dash_docs import tools
from dash_docs import reusable_components as rc
examples = tools... | code_fim | hard | {
"lang": "python",
"repo": "plotly/dash-docs",
"path": "/dash_docs/chapters/dash_core_components/Input/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _Fixed and enhanced in Dash v1.1.0_
Number type is now close to native HTML5 `input` behavior across
browsers. We also apply a strict number casting in callbacks:
valid number converts into corresponding number types, and invalid number
converts into None. E.g.
`dcc.Input(id='rang... | code_fim | hard | {
"lang": "python",
"repo": "plotly/dash-docs",
"path": "/dash_docs/chapters/dash_core_components/Input/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> There is a limitation when converting numbers like 1.0 or 0.0, the
corresponding number type in callbacks is **Integer** instead of **Float**.
Please add extra guard casting like `float()` within callbacks if needed.
"""),
rc.Syntax(examples['input_number_type.py'][0]),
rc.Example(... | code_fim | hard | {
"lang": "python",
"repo": "plotly/dash-docs",
"path": "/dash_docs/chapters/dash_core_components/Input/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: congnghiakhiem/django-vue-aiohttp path: /myapp/events_handler.py
import asyncio
from datetime import datetime
from aiohttp import web
from aiohttp_sse import sse_response
<|fim_suffix|>@event_routes.get('/events')
async def event_handler(request):
loop = request.app.loop
async with sse_... | code_fim | easy | {
"lang": "python",
"repo": "congnghiakhiem/django-vue-aiohttp",
"path": "/myapp/events_handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@event_routes.get('/events')
async def event_handler(request):
loop = request.app.loop
async with sse_response(request) as resp:
while True:
data = 'Server Time : {}'.format(datetime.now())
print(data)
await resp.send(data)
await asyncio.slee... | code_fim | easy | {
"lang": "python",
"repo": "congnghiakhiem/django-vue-aiohttp",
"path": "/myapp/events_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If current status is started or pending or break then return error_robotworking message
elif ValidateError.check_current_status() in ['started', 'pending', 'break']:
return_data = {'status': 'error', 'error': 'robotworking'}
logger.error('validatio... | code_fim | hard | {
"lang": "python",
"repo": "Gee-log/rico-frontend",
"path": "/backend/webapp/libs/for_embest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gee-log/rico-frontend path: /backend/webapp/libs/for_embest.py
"""for running robot
"""
import logging.handlers
from rest_framework.parsers import JSONParser
from rest_framework.response import Response
from rest_framework.views import status
from webapp.libs.connectionlist_connection import C... | code_fim | hard | {
"lang": "python",
"repo": "Gee-log/rico-frontend",
"path": "/backend/webapp/libs/for_embest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'east' not in request_data:
return_data = {'error': 'No east'}
logger.error('validate_input method: error:{} request:{}'.format(return_data, request))
return Response(return_data, status=status.HTTP_400_BAD_REQUEST)
if 'west' not in request_data:
... | code_fim | hard | {
"lang": "python",
"repo": "Gee-log/rico-frontend",
"path": "/backend/webapp/libs/for_embest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mgrandi/telegram_dl path: /telegram_dl/test/aides/chat_aide/test_chat_aide_super_group_nophoto.py
import unittest
import pathlib
import unittest
import arrow
from telegram_dl import utils
from telegram_dl import tdlib_generated as tdg
from telegram_dl import db_model_enums as dbe
from telegram_... | code_fim | hard | {
"lang": "python",
"repo": "mgrandi/telegram_dl",
"path": "/telegram_dl/test/aides/chat_aide/test_chat_aide_super_group_nophoto.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
`ChatAide.new_chat_from_tdlib_chat`, get new `db_model.Chat` from `tdlib_generated.chat`
'''
pass
@unittest.skip("TODO")
def test_new_chat_version_from_tdlib_chat(self):
'''
`ChatAide.new_chat_version_from_tdlib_chat`, get new `db_model.ChatVer... | code_fim | hard | {
"lang": "python",
"repo": "mgrandi/telegram_dl",
"path": "/telegram_dl/test/aides/chat_aide/test_chat_aide_super_group_nophoto.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> GET /auth/saml/v0/provider_data/?enterprise-id=uuid
POST /auth/saml/v0/provider_data/ -d postData (must contain 'enterprise_customer_uuid')
DELETE /auth/saml/v0/provider_data/:pk -d postData (must contain 'enterprise_customer_uuid')
PATCH /auth/saml/v0/provider_data/:pk -d ... | code_fim | hard | {
"lang": "python",
"repo": "luque/better-ways-of-thinking-about-software",
"path": "/Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/common/djangoapps/third_party_auth/samlproviderdata/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The enterprise customer uuid from request params or post body
"""
if self.request.method in ('POST', 'PATCH'):
uuid_str = self.request.POST.get('enterprise_customer_uuid')
if uuid_str is None:
raise ParseError('Required enterprise... | code_fim | hard | {
"lang": "python",
"repo": "luque/better-ways-of-thinking-about-software",
"path": "/Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/common/djangoapps/third_party_auth/samlproviderdata/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zywillc/fugue path: /tests/fugue/extensions/transformer/test_convert_transformer.py
from typing import Any, Dict, Iterable, List
from fugue.dataframe import ArrayDataFrame
from fugue.exceptions import FugueInterfacelessError
from fugue.extensions.transformer import Transformer, _to_transformer, ... | code_fim | hard | {
"lang": "python",
"repo": "zywillc/fugue",
"path": "/tests/fugue/extensions/transformer/test_convert_transformer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@transformer(["*", None, "b:int"])
def t1(df: Iterable[Dict[str, Any]]) -> Iterable[Dict[str, Any]]:
for r in df:
r["b"] = 1
yield r
@transformer([Schema("b:int"), "*"])
def t2(df: Iterable[Dict[str, Any]]) -> Iterable[Dict[str, Any]]:
for r in df:
r["b"] = 1
yiel... | code_fim | hard | {
"lang": "python",
"repo": "zywillc/fugue",
"path": "/tests/fugue/extensions/transformer/test_convert_transformer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@transformer(["*", None, "b:int"])
def t1(df: Iterable[Dict[str, Any]]) -> Iterable[Dict[str, Any]]:
for r in df:
r["b"] = 1
yield r
@transformer([Schema("b:int"), "*"])
def t2(df: Iterable[Dict[str, Any]]) -> Iterable[Dict[str, Any]]:
for r in df:
r["b"] = 1
yie... | code_fim | hard | {
"lang": "python",
"repo": "zywillc/fugue",
"path": "/tests/fugue/extensions/transformer/test_convert_transformer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if probe == '1' and datatype == 'ion':
flux_omni = flux_omni*iGfact[0]
if probe == '2' and datatype == 'ion':
flux_omni = flux_omni*iGfact[1]
if probe == '3' and datatype == 'ion':
flux_omni = flux_omni*iGfact[2]
if probe == '4' and datat... | code_fim | hard | {
"lang": "python",
"repo": "spedas/pyspedas",
"path": "/pyspedas/mms/feeps/mms_feeps_omni.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spedas/pyspedas path: /pyspedas/mms/feeps/mms_feeps_omni.py
import logging
import warnings
import numpy as np
from pytplot import get, store, options
# use nanmean from bottleneck if it's installed, otherwise use the numpy one
# bottleneck nanmean is ~2.5x faster
try:
import bottleneck as bn... | code_fim | hard | {
"lang": "python",
"repo": "spedas/pyspedas",
"path": "/pyspedas/mms/feeps/mms_feeps_omni.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tmpdata is not None:
if level != 'sitl':
dalleyes = np.empty((len(tmpdata[0]), len(tmpdata[2]), len(top_sensors)+len(bot_sensors)))
dalleyes[:] = np.nan
for idx, sensor in enumerate(top_sensors):
var_name = prefix+data_rate+'_'+level+'_'+... | code_fim | hard | {
"lang": "python",
"repo": "spedas/pyspedas",
"path": "/pyspedas/mms/feeps/mms_feeps_omni.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dpilger26/NumCpp path: /test/pytest/test_timer.py
import numpy as np
import NumCppPy as NumCpp # noqa E402
####################################################################################
def test_timer():
<|fim_suffix|> SLEEP_TIME = int(
np.random.randint(
0,
... | code_fim | hard | {
"lang": "python",
"repo": "dpilger26/NumCpp",
"path": "/test/pytest/test_timer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> SLEEP_TIME = int(
np.random.randint(
0,
10,
[
1,
],
).item()
* 1e6
) # microseconds
timer = NumCpp.Timer("Python Test Case")
timer.tic()
timer.sleep(SLEEP_TIME)
elapsedTime = timer.toc(True) #... | code_fim | hard | {
"lang": "python",
"repo": "dpilger26/NumCpp",
"path": "/test/pytest/test_timer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsumura-h/masonite_blog path: /project/tests/unit/api/test_toppage.py
import pytest
from masonite.testing import UnitTest
from app.http.controllers.BlogController import BlogController
from app.models.Toppage import Toppage
import json
class TestToppage(UnitTest):
def setup_method(self):
... | code_fim | medium | {
"lang": "python",
"repo": "itsumura-h/masonite_blog",
"path": "/project/tests/unit/api/test_toppage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_api(self):
assert self.model.title == self.response['value']['toppage']['title']
assert self.model.article_html == self.response['value']['toppage']['article_html']
assert self.model.meta_description == self.response['value']['toppage']['meta_description']
def tes... | code_fim | hard | {
"lang": "python",
"repo": "itsumura-h/masonite_blog",
"path": "/project/tests/unit/api/test_toppage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert self.route(
'/api/blog/toppage').has_controller(BlogController)
assert self.route(
'/api/blog/toppage_en').has_controller(BlogController)
def test_api(self):
assert self.model.title == self.response['value']['toppage']['title']
assert sel... | code_fim | hard | {
"lang": "python",
"repo": "itsumura-h/masonite_blog",
"path": "/project/tests/unit/api/test_toppage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adina-calin/contracts path: /src/ev_contracte/contr_clienti/migrations/0008_auto_20200722_0910.py
# Generated by Django 3.0.7 on 2020-07-22 06:10
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('contr_clienti', '0007_contractscan_uploaded_at'),
]
... | code_fim | easy | {
"lang": "python",
"repo": "adina-calin/contracts",
"path": "/src/ev_contracte/contr_clienti/migrations/0008_auto_20200722_0910.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='contractscan',
name='uploaded_at',
field=models.DateField(auto_now_add=True),
),
]<|fim_prefix|># repo: adina-calin/contracts path: /src/ev_contracte/contr_clienti/migrations/0008_auto_20200722_0... | code_fim | medium | {
"lang": "python",
"repo": "adina-calin/contracts",
"path": "/src/ev_contracte/contr_clienti/migrations/0008_auto_20200722_0910.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('contr_clienti', '0007_contractscan_uploaded_at'),
]
operations = [
migrations.AlterField(
model_name='contractscan',
name='uploaded_at',
field=models.DateField(auto_now_add=True),
),
]<|fim_prefix|># repo: adin... | code_fim | easy | {
"lang": "python",
"repo": "adina-calin/contracts",
"path": "/src/ev_contracte/contr_clienti/migrations/0008_auto_20200722_0910.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # the action identifier
if (sys.argv[1].lower() == 'add'):
# TODO: add some more preprocessing. This is very simple.
missionName = ' '.join(sys.argv[3:])
addNewMission(missionName, sys.argv[2])
if __name__ == "__main__":
main()<|fim_prefix|># repo: wesrer/Player-Me p... | code_fim | easy | {
"lang": "python",
"repo": "wesrer/Player-Me",
"path": "/project/src/Controller/redirect.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wesrer/Player-Me path: /project/src/Controller/redirect.py
import sys
from project.src.Model.missions.AddNewMission import addNewMission
def main ():
<|fim_suffix|>if __name__ == "__main__":
main()<|fim_middle|>
# the action identifier
if (sys.argv[1].lower() == 'add'):
# TO... | code_fim | hard | {
"lang": "python",
"repo": "wesrer/Player-Me",
"path": "/project/src/Controller/redirect.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# the action identifier
if (sys.argv[1].lower() == 'add'):
# TODO: add some more preprocessing. This is very simple.
missionName = ' '.join(sys.argv[3:])
addNewMission(missionName, sys.argv[2])
if __name__ == "__main__":
main()<|fim_prefix|># repo: wesrer/Player-Me ... | code_fim | easy | {
"lang": "python",
"repo": "wesrer/Player-Me",
"path": "/project/src/Controller/redirect.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Renjue823/MLOps_June2021 path: /src/models/predict_model.py
import os
import torch
import pathlib
os.chdir(pathlib.Path().absolute())
from model import NeuralNetwork
import pathlib
ROOT_PATH = 'C:/Users/Laura/Documents/MLOps/MLOps_June2021'
MODEL_PATH = ROOT_PATH + "/src/models/trained_models... | code_fim | hard | {
"lang": "python",
"repo": "Renjue823/MLOps_June2021",
"path": "/src/models/predict_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_accuracy(self,y_hat):
for i in y_hat:
for val in i:
if val != 2:
print(val)
print(len(y_hat))
if __name__ == "__main__":
images = torch.load(DATA_PATH+"/val/images.pt")
y = torch.load(DATA_PATH+"/val/labels.pt")
y_ha... | code_fim | hard | {
"lang": "python",
"repo": "Renjue823/MLOps_June2021",
"path": "/src/models/predict_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fjhzwl/gammapy path: /gammapy/irf/psf_3d.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy import units as u
from astropy.coordinates import Angle
from astropy.io import fits
from astropy.table import Table
from astropy.utils import lazyproperty
fr... | code_fim | hard | {
"lang": "python",
"repo": "fjhzwl/gammapy",
"path": "/gammapy/irf/psf_3d.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self, energy, theta="0 deg", fraction=0.68, interp_kwargs=None
):
"""Containment radius.
Parameters
----------
energy : `~astropy.units.Quantity`
Energy
theta : `~astropy.coordinates.Angle`
Offset in the field of view. Default th... | code_fim | hard | {
"lang": "python",
"repo": "fjhzwl/gammapy",
"path": "/gammapy/irf/psf_3d.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: appinho/SADailyCodingProblem path: /01/python/startpoint.py
def has_a_sum(arr, K):
pass
if __name__ == '__main__':
<|fim_suffix|> # Number of test cases
T = int(f.readline())
# Loop over test cases
for __ in xrange(T):
# Read length of array N and sum K
N,K = map(int, f.readline().sp... | code_fim | easy | {
"lang": "python",
"repo": "appinho/SADailyCodingProblem",
"path": "/01/python/startpoint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Print solution
print("Case #%d: %s" % (__+1, has_a_sum(arr, K)))
# Close file
f.close()<|fim_prefix|># repo: appinho/SADailyCodingProblem path: /01/python/startpoint.py
def has_a_sum(arr, K):
pass
if __name__ == '__main__':
# Read test file
f = open("../testcase.txt", "r")
<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "appinho/SADailyCodingProblem",
"path": "/01/python/startpoint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Number of test cases
T = int(f.readline())
# Loop over test cases
for __ in xrange(T):
# Read length of array N and sum K
N,K = map(int, f.readline().split())
# Fill array
arr = map(int, f.readline().split())
# Print solution
print("Case #%d: %s" % (__+1, has_a_sum(arr, K)))
# Clos... | code_fim | easy | {
"lang": "python",
"repo": "appinho/SADailyCodingProblem",
"path": "/01/python/startpoint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kcyu1993/keras path: /build/lib/kyu/tensorflow/ops/math.py
"""
Implement math operations
"""
import tensorflow as tf
import keras.backend as K
from keras.optimizers import SGD
def matrix_log(x, eps=1e-5):
"""
Define the matrix logarithm with the gradients
Parameters
----------
... | code_fim | hard | {
"lang": "python",
"repo": "kcyu1993/keras",
"path": "/build/lib/kyu/tensorflow/ops/math.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # apply constraints
if p in constraints:
c = constraints[p]
new_p = c(new_p)
self.updates.append(K.update(p, new_p))
return self.updates
def stiefel_update(self, param, constraints, grad, moment, lr):
"""
Ove... | code_fim | hard | {
"lang": "python",
"repo": "kcyu1993/keras",
"path": "/build/lib/kyu/tensorflow/ops/math.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> QBtn = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
self.button_box = QDialogButtonBox(QBtn)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.layout = QVBoxLayout()
self.layout.addWidget(QLabel("Invalidate re... | code_fim | hard | {
"lang": "python",
"repo": "AlexanderFabisch/slither",
"path": "/slither/gui/record_table.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexanderFabisch/slither path: /slither/gui/record_table.py
try:
from PyQt4.QtGui import *
except ImportError:
from PyQt5.QtWidgets import *
from slither.core.ui_text import d
class RecordTable(QTableWidget):
def __init__(self, controller, parent=None):
super(RecordTable, se... | code_fim | hard | {
"lang": "python",
"repo": "AlexanderFabisch/slither",
"path": "/slither/gui/record_table.py",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
in_channels: int,
kernel_size: int = 31,
expansion_factor: int = 2,
dropout_p: float = 0.1,
) -> None:
super(ConformerConvModule, self).__init__()
assert (kernel_size - 1) % 2 == 0, "kernel_size should be a odd number fo... | code_fim | hard | {
"lang": "python",
"repo": "wuxiuzhi738/openspeech",
"path": "/openspeech/modules/conformer_convolution_module.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wuxiuzhi738/openspeech path: /openspeech/modules/conformer_convolution_module.py
# MIT License
#
# Copyright (c) 2021 Soohwan Kim and Sangchun Ha and Soyoung Cho
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files ... | code_fim | hard | {
"lang": "python",
"repo": "wuxiuzhi738/openspeech",
"path": "/openspeech/modules/conformer_convolution_module.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hibetterheyj/basic_unet_example path: /configs/Config_unet.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 Division of Medical Image Computing, German Cancer Research Center (DKFZ)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file ... | code_fim | hard | {
"lang": "python",
"repo": "hibetterheyj/basic_unet_example",
"path": "/configs/Config_unet.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> c = Config(
update_from_argv=True, # If set 'True', it allows to update each configuration by a cmd/terminal parameter.
# Train parameters
num_classes=3,
in_channels=1,
batch_size=8,
patch_size=64,
n_epochs=10,
learning_rate=0.0002,
... | code_fim | medium | {
"lang": "python",
"repo": "hibetterheyj/basic_unet_example",
"path": "/configs/Config_unet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> data_root_dir=data_root_dir, # The path where the downloaded dataset is stored.
data_dir=os.path.join(data_root_dir, 'Task04_Hippocampus/preprocessed'), # This is where your training and validation data is stored
data_test_dir=os.path.join(data_root_dir, 'Task04_Hippocampus/prepr... | code_fim | hard | {
"lang": "python",
"repo": "hibetterheyj/basic_unet_example",
"path": "/configs/Config_unet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: echodaemon/synapse path: /synapse/tests/common.py
import os
import shutil
import logging
import tempfile
import unittest
import threading
import contextlib
logging.basicConfig(level=logging.WARNING)
from synapse.eventbus import Waiter
import synapse.lib.output as s_output
import synapse.lib.thi... | code_fim | hard | {
"lang": "python",
"repo": "echodaemon/synapse",
"path": "/synapse/tests/common.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @contextlib.contextmanager
def getTestDir(self):
tempdir = tempfile.mkdtemp()
yield tempdir
shutil.rmtree(tempdir)
def eq(self, x, y):
self.assertEqual(x,y)
def nn(self, x):
self.assertIsNotNone(x)
testdir = os.path.dirname(__file__)
def getTestPa... | code_fim | hard | {
"lang": "python",
"repo": "echodaemon/synapse",
"path": "/synapse/tests/common.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for bus in self.tofini:
bus.fini()
class SynTest(unittest.TestCase):
def getTestWait(self, bus, size, *evts):
return Waiter(bus, size, *evts)
def getTestOutp(self):
return s_output.OutPutStr()
def thisHostMust(self, **props):
for k,v in props.it... | code_fim | hard | {
"lang": "python",
"repo": "echodaemon/synapse",
"path": "/synapse/tests/common.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: irom-lab/Invariant-Policy-Optimization path: /DoorGym/train_ppo_domains.py
import os
import sys
import time
import pickle
from collections import deque
import gym
import numpy as np
import torch
import torch.nn as nn
from tensorboardX import SummaryWriter
from trained_visionmodel.visionmodel im... | code_fim | hard | {
"lang": "python",
"repo": "irom-lab/Invariant-Policy-Optimization",
"path": "/DoorGym/train_ppo_domains.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pos_control = False
total_switches = 0
prev_selection = ""
for step in range(args.num_steps):
with torch.no_grad():
value, action, action_log_prob, recurrent_hidden_states = actor_critic.act(
rollouts.obs[step], rollouts.recur... | code_fim | hard | {
"lang": "python",
"repo": "irom-lab/Invariant-Policy-Optimization",
"path": "/DoorGym/train_ppo_domains.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.