text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: MPIBGC-TEE/CompartmentalSystems path: /src/CompartmentalSystems/bins/FieldsPerTimeStep.py
# vim: set ff=unix expandtab ts=4 sw=4:
import numpy as np
class FieldsPerTimeStep(list):
def __init__(self, listOfTimeFields, start):
super().__init__(listOfTimeFields)
self.start = st... | code_fim | medium | {
"lang": "python",
"repo": "MPIBGC-TEE/CompartmentalSystems",
"path": "/src/CompartmentalSystems/bins/FieldsPerTimeStep.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def t_max(self):
return max(self.times)<|fim_prefix|># repo: MPIBGC-TEE/CompartmentalSystems path: /src/CompartmentalSystems/bins/FieldsPerTimeStep.py
# vim: set ff=unix expandtab ts=4 sw=4:
import numpy as np
class FieldsPerTimeStep(list):
def __init__(self, listOfTimeFie... | code_fim | hard | {
"lang": "python",
"repo": "MPIBGC-TEE/CompartmentalSystems",
"path": "/src/CompartmentalSystems/bins/FieldsPerTimeStep.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def tss(self):
return self[0].tss
@property
def times(self):
return np.arange(len(self)) * self.tss + self.start
@property
def t_min(self):
return min(self.times)
@property
def t_max(self):
return max(self.times)<|fim_prefix|># r... | code_fim | medium | {
"lang": "python",
"repo": "MPIBGC-TEE/CompartmentalSystems",
"path": "/src/CompartmentalSystems/bins/FieldsPerTimeStep.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # compute crops
if crop_size == -1:
crop_size = self._size_high
if crop_size % upscaling != 0:
raise ValueError("crop size of %d is not a multiple of the upscaling factor %d"%(
crop_size, upscaling))
self._crops = getCropsForDataset(
... | code_fim | hard | {
"lang": "python",
"repo": "PeterZhouSZ/AdaptiveSampling",
"path": "/network/dataset/denseDatasetLoaderHDF5_v2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get(self, index, mode):
idx = self._crops[index+self.index_offset, 0]
x = self._crops[index+self.index_offset, 1]
y = self._crops[index+self.index_offset, 2]
if mode=='high':
d = self.dset_high[
idx,
:, :self._output_chan... | code_fim | hard | {
"lang": "python",
"repo": "PeterZhouSZ/AdaptiveSampling",
"path": "/network/dataset/denseDatasetLoaderHDF5_v2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PeterZhouSZ/AdaptiveSampling path: /network/dataset/denseDatasetLoaderHDF5_v2.py
import torch.utils.data as data
import os.path
import collections
import random
import numpy as np
import torch
import time
import h5py
from typing import Callable, Optional, Union, List
from dataset.datasetUtils ... | code_fim | hard | {
"lang": "python",
"repo": "PeterZhouSZ/AdaptiveSampling",
"path": "/network/dataset/denseDatasetLoaderHDF5_v2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0
self.thumbnail_link = ""
self.comments_disabled = True
self.ratings_disabled = True
self.description = ""<|fim_prefix|># repo: Valzavator/YouTubeTrendingVideosAnalysis path: /entity/video.py
import time
class YouTubeVideo:
def __init__(self):
self._id = "... | code_fim | hard | {
"lang": "python",
"repo": "Valzavator/YouTubeTrendingVideosAnalysis",
"path": "/entity/video.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>%m")
self.tags = "[none]"
self.view_count = 0
self.likes = 0
self.dislikes = 0
self.comment_count = 0
self.thumbnail_link = ""
self.comments_disabled = True
self.ratings_disabled = True
self.description = ""<|fim_prefix|># repo: Valza... | code_fim | medium | {
"lang": "python",
"repo": "Valzavator/YouTubeTrendingVideosAnalysis",
"path": "/entity/video.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Valzavator/YouTubeTrendingVideosAnalysis path: /entity/video.py
import time
class YouTubeVideo:
def __init__(self):
self._id = ""
self.country_code = ""
self.title = ""
<|fim_suffix|>%m")
self.tags = "[none]"
self.view_count = 0
self.likes... | code_fim | medium | {
"lang": "python",
"repo": "Valzavator/YouTubeTrendingVideosAnalysis",
"path": "/entity/video.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: khshim/lemontree path: /lemontree/optimizers.py
"""
This code includes various optimizer algorithms.
Optimizers compute gradients for shared variables, based on gradient descent algorithm.
Planning not to use T.grad anymore, instead we are using theano.gradient.grad.
If you don't have the functio... | code_fim | hard | {
"lang": "python",
"repo": "khshim/lemontree",
"path": "/lemontree/optimizers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class AdaDelta(BaseOptimizer):
def __init__(self, lr_init=1.0, rho_init=0.9,
clipnorm=None, clipvalue=None):
rho = np.array(rho_init).astype('float32')
self.rho = theano.shared(rho, 'rho')
self.rho.tags = ['rho']
super(AdaDelta, self).__init__(lr_init... | code_fim | hard | {
"lang": "python",
"repo": "khshim/lemontree",
"path": "/lemontree/optimizers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def gradients_to_updates(self, params, grads):
updates = OrderedDict()
for pp, gg in zip(params, grads):
value = pp.get_value(borrow=True)
self.velocity = theano.shared(np.zeros(value.shape, dtype=theano.config.floatX), 'momentum_velocity_'+pp.name)
... | code_fim | hard | {
"lang": "python",
"repo": "khshim/lemontree",
"path": "/lemontree/optimizers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # multidim scaling
feature_range = (np.ones((1, n_ord)) * -1e10, np.ones((1, n_ord)) * 1e10)
d_abs = multidim_scaling(d_pair,
n_components=2,
use_metric=True,
standardize_cat_vars=Tru... | code_fim | hard | {
"lang": "python",
"repo": "ryandawsonuk/alibi-detect",
"path": "/alibi_detect/utils/perturbation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryandawsonuk/alibi-detect path: /alibi_detect/utils/perturbation.py
import numpy as np
import random
from typing import List, Tuple
from alibi_detect.utils.data import Bunch
from alibi_detect.utils.discretizer import Discretizer
from alibi_detect.utils.distance import abdm, multidim_scaling
from ... | code_fim | hard | {
"lang": "python",
"repo": "ryandawsonuk/alibi-detect",
"path": "/alibi_detect/utils/perturbation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
X
Tabular data to perturb (inject outliers).
cols
Columns of X that are numerical and can be perturbed.
perc_outlier
Percentage of observations which are perturbed to outliers. For multiple numerical features,
the percentage is even... | code_fim | hard | {
"lang": "python",
"repo": "ryandawsonuk/alibi-detect",
"path": "/alibi_detect/utils/perturbation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FGtatsuro/myatcoder path: /beginner_contest/124/C.py
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
<|fim_suffix|>ans1 = 0
ans2 = 0
for i, v in enumerate(s):
if v != (i % 2):
ans1 += 1
else:
ans2 += 1
print(min(ans1, ans2))<|fim_middle|>s = list(map... | code_fim | easy | {
"lang": "python",
"repo": "FGtatsuro/myatcoder",
"path": "/beginner_contest/124/C.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ans1 = 0
ans2 = 0
for i, v in enumerate(s):
if v != (i % 2):
ans1 += 1
else:
ans2 += 1
print(min(ans1, ans2))<|fim_prefix|># repo: FGtatsuro/myatcoder path: /beginner_contest/124/C.py
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
<|fim_middle|>s = list(map... | code_fim | easy | {
"lang": "python",
"repo": "FGtatsuro/myatcoder",
"path": "/beginner_contest/124/C.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>gamepad = usb_hid.Device(
report_descriptor=GAMEPAD_REPORT_DESCRIPTOR,
usage_page=0x01, # Generic Desktop Control
usage=0x05, # Gamepad
report_ids=(4,), # Descriptor uses report ID 4.
in_report_lengths=(6,), # This gamepad sends 6 bytes in its repo... | code_fim | hard | {
"lang": "python",
"repo": "dglaude/CircuitPython_Joystic_Controller",
"path": "/examples/sneswii2gamepad/boot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dglaude/CircuitPython_Joystic_Controller path: /examples/sneswii2gamepad/boot.py
# boot.py
# SPDX-FileCopyrightText: Copyright (c) 2021 Dan Halbert for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
### From: https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/hid-dev... | code_fim | hard | {
"lang": "python",
"repo": "dglaude/CircuitPython_Joystic_Controller",
"path": "/examples/sneswii2gamepad/boot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adrszad/robotframework-tidy path: /tests/atest/transformers/MergeAndOrderSections/test_transformer.py
import pytest
from .. import run_tidy_and_compare, run_tidy
class TestMergeAndOrderSections:
TRANSFORMER_NAME = 'MergeAndOrderSections'
def test_merging_and_ordering(self):
ru... | code_fim | hard | {
"lang": "python",
"repo": "adrszad/robotframework-tidy",
"path": "/tests/atest/transformers/MergeAndOrderSections/test_transformer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_parsing_error(self):
run_tidy_and_compare(self.TRANSFORMER_NAME, source='parsing_error.robot')
def test_too_few_calls_in_keyword(self):
run_tidy_and_compare(self.TRANSFORMER_NAME, source='too_few_calls_in_keyword.robot')
def test_default_order(self):
run_tidy... | code_fim | hard | {
"lang": "python",
"repo": "adrszad/robotframework-tidy",
"path": "/tests/atest/transformers/MergeAndOrderSections/test_transformer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # [2, 3, 4] Add no-assigned regions to used box list
asn_idx[key] = entry['asn_{}_idx'.format(key)].value
asn_order_idx[key] = np.arange(len(asn_idx[key]), dtype=np.int32)
no_asn_idx = entry['no_asn_{}_idx'.format(key)].value
num_asn = len(asn_i... | code_fim | hard | {
"lang": "python",
"repo": "HyeonwooNoh/VQA-Transfer-ExternalData",
"path": "/vlmap/datasets/dataset_vlmap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data_shapes = {
'image': [self.height, self.width, 3],
'box': [MAX_USED_BOX, 4],
'normal_box': [MAX_USED_BOX, 4],
'desc': [MAX_BOX_PER_ENTRY['region'], None],
'desc_len': [MAX_BOX_PER_ENTRY['region']],
'desc_box_idx': [MAX_BOX... | code_fim | hard | {
"lang": "python",
"repo": "HyeonwooNoh/VQA-Transfer-ExternalData",
"path": "/vlmap/datasets/dataset_vlmap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HyeonwooNoh/VQA-Transfer-ExternalData path: /vlmap/datasets/dataset_vlmap.py
art['neg_box'],
num_neg_box)
used_neg_box_selector = list(range(num_neg_box))
RANDOM_STATE.shuffle(used_neg_box_selector)
used_neg_box_selector = used_neg_box_select... | code_fim | hard | {
"lang": "python",
"repo": "HyeonwooNoh/VQA-Transfer-ExternalData",
"path": "/vlmap/datasets/dataset_vlmap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> batch_size = source.shape[0]
if out_seq_len is None:
seq_len = source.shape[1]
#############################################################################
# TODO: #
# Imple... | code_fim | hard | {
"lang": "python",
"repo": "Kuga23/Deep-Learning",
"path": "/Pytorch/NLP/models/seq2seq/Seq2Seq.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#############################################################################
# TODO: #
# Implement the forward pass of the Seq2Seq model. Please refer to the #
# following steps: ... | code_fim | medium | {
"lang": "python",
"repo": "Kuga23/Deep-Learning",
"path": "/Pytorch/NLP/models/seq2seq/Seq2Seq.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kuga23/Deep-Learning path: /Pytorch/NLP/models/seq2seq/Seq2Seq.py
import random
import torch
import torch.nn as nn
import torch.optim as optim
# import custom models
class Seq2Seq(nn.Module):
""" The Sequence to Sequence model.
You will need to complete the init function and the ... | code_fim | medium | {
"lang": "python",
"repo": "Kuga23/Deep-Learning",
"path": "/Pytorch/NLP/models/seq2seq/Seq2Seq.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mark-MDO47/MDOpythonUtils path: /mdoUniq/mdoUniq.py
#
# mdoUniq.py - my crude "uniq" for comparing only between start and end strings
#
# Author: Mark Olson 2019-12-21
#
# This trivial code must have been written dozens of times in various languages, but I needed a version for myself.
#
# mdoUniq... | code_fim | hard | {
"lang": "python",
"repo": "Mark-MDO47/MDOpythonUtils",
"path": "/mdoUniq/mdoUniq.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> return numLines
if __name__ == "__main__":
my_parser = argparse.ArgumentParser(prog='mdoUniq',
formatter_class=argparse.RawTextHelpFormatter,
description="simple uniq between startStr to endStr on each line",
epilog="""Example: suppose mdo.txt has the following lines
<<<o... | code_fim | hard | {
"lang": "python",
"repo": "Mark-MDO47/MDOpythonUtils",
"path": "/mdoUniq/mdoUniq.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryuz/BinaryBrain path: /python/binarybrain/storage.py
# -*- coding: utf-8 -*-
import os
import datetime
import glob
import re
import shutil
import pickle
import binarybrain as bb
def get_date_string():
# データ保存パス用の日付文字列を生成
return datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
def i... | code_fim | hard | {
"lang": "python",
"repo": "ryuz/BinaryBrain",
"path": "/python/binarybrain/storage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def save_models(path: str, net, *, write_layers=True, file_format=None):
''' save networks
ネットを構成するモデルの保存
Args:
path (str): 保存するパス
net (Model): 保存するネット
write_layers (bool) : レイヤー別にも出力するかどうか
'''
# make dir
os.makedirs(path,... | code_fim | hard | {
"lang": "python",
"repo": "ryuz/BinaryBrain",
"path": "/python/binarybrain/storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # make dir
os.makedirs(path, exist_ok=True)
# save with date
if name is None:
name = get_date_string()
data_path = os.path.join(path, name)
save_models(data_path, net, write_layers=write_layers, file_format=file_format)
if backups >= 0:
remove_bac... | code_fim | hard | {
"lang": "python",
"repo": "ryuz/BinaryBrain",
"path": "/python/binarybrain/storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gjaiswal108/Automatic-Notification-Sender path: /app.py
import smtplib,requests,bs4,mysql.connector
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
if(True):
print("Program started")
mydb=mysql.connector.connect(host="localhost",user="root",password=""... | code_fim | hard | {
"lang": "python",
"repo": "gjaiswal108/Automatic-Notification-Sender",
"path": "/app.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for elem in elemText:
if(elem[0] not in res_set):
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login("sender_gmail_id", "password")
text="New Notice-> "+elem[0]
html="<h3>New Noti... | code_fim | hard | {
"lang": "python",
"repo": "gjaiswal108/Automatic-Notification-Sender",
"path": "/app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> sys.path.append(os.path.join(TEST_DIR, "testdata"))
confs = configure(models="test_module")
assert len(confs) == 5
def test_configure_module():
sys.path.append(os.path.join(TEST_DIR, "testdata"))
confs = configure(models="test_module.module_a")
assert len(confs) == 3<|fim_prefix|... | code_fim | easy | {
"lang": "python",
"repo": "CyrilLeMat/modelkit",
"path": "/tests/test_module_configure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CyrilLeMat/modelkit path: /tests/test_module_configure.py
import os
import sys
from modelkit.core.model_configuration import configure
from tests import TEST_DIR
def test_configure_package():
<|fim_suffix|> sys.path.append(os.path.join(TEST_DIR, "testdata"))
confs = configure(models="te... | code_fim | medium | {
"lang": "python",
"repo": "CyrilLeMat/modelkit",
"path": "/tests/test_module_configure.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sys.path.append(os.path.join(TEST_DIR, "testdata"))
confs = configure(models="test_module.module_a")
assert len(confs) == 3<|fim_prefix|># repo: CyrilLeMat/modelkit path: /tests/test_module_configure.py
import os
import sys
from modelkit.core.model_configuration import configure
from tests i... | code_fim | easy | {
"lang": "python",
"repo": "CyrilLeMat/modelkit",
"path": "/tests/test_module_configure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.fast_model:
with pytest.warns(
FutureWarning,
match="The argument parallel is deprecated",
):
pm.sample_smc(draws=10, chains=1, parallel=False)
def test_deprecated_abc_args(self):
with self.fast_model:
... | code_fim | hard | {
"lang": "python",
"repo": "pymc-devs/pymc",
"path": "/tests/smc/test_smc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.fast_model:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", ".*number of samples.*", UserWarning)
warnings.filterwarnings("ignore", "More chains .* than draws .*", UserWarning)
idata = pm.sample_smc(chains=chai... | code_fim | hard | {
"lang": "python",
"repo": "pymc-devs/pymc",
"path": "/tests/smc/test_smc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pymc-devs/pymc path: /tests/smc/test_smc.py
# Copyright 2023 The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org... | code_fim | hard | {
"lang": "python",
"repo": "pymc-devs/pymc",
"path": "/tests/smc/test_smc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return args[::-1]
print(average(3, 4, 5, 1))
print(print_tuple("hi", "there", 'friend'))
print(average_length("hi", 'there', 'friend'))
print(largest(3, 6, 1, 39, 839, 929, 3, 0))
print(reverse("Hi", 'there', 'friend'))
words = ["Hi", "there", "friend"]
print(words)
print(*words)
numbers = [1, 3, ... | code_fim | medium | {
"lang": "python",
"repo": "BrandonP321/Python-masterclass",
"path": "/Databases/star_args.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mean = 0
for arg in args:
mean += len(arg)
return mean / len(args)
def largest(*args: int) -> int:
sorted_tuple = sorted(args)
return sorted_tuple[-1]
def reverse(*args: str) -> tuple:
return args[::-1]
print(average(3, 4, 5, 1))
print(print_tuple("hi", "there", 'frie... | code_fim | hard | {
"lang": "python",
"repo": "BrandonP321/Python-masterclass",
"path": "/Databases/star_args.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BrandonP321/Python-masterclass path: /Databases/star_args.py
# from __future__ import print_function
# allows the following print() to work if using python 2
# print("Hello", "planet", "earth")
def average(*args: int) -> float:
print(type(args))
print("args is {}".format(args)) # (3, 4... | code_fim | hard | {
"lang": "python",
"repo": "BrandonP321/Python-masterclass",
"path": "/Databases/star_args.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: texttochange/vusion-backend path: /vusion/persist/unattached_message/tests/test_unattached_message.py
from twisted.trial.unittest import TestCase
from vusion.persist import UnattachedMessage, Participant
from tests.utils import ObjectMaker
class TestUnattachedMessage(TestCase, ObjectMaker):
... | code_fim | hard | {
"lang": "python",
"repo": "texttochange/vusion-backend",
"path": "/vusion/persist/unattached_message/tests/test_unattached_message.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_is_selectable_match_any(self):
participant = Participant(
**self.mkobj_participant_v2(
tags=['geek', 'cool'],
profile=[{'label': 'city', 'value': 'kampala', 'raw': None}]))
um_tag = UnattachedMessage(
**self.mkobj_unatta... | code_fim | hard | {
"lang": "python",
"repo": "texttochange/vusion-backend",
"path": "/vusion/persist/unattached_message/tests/test_unattached_message.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print('all_network.edges:', all_network.edges())
if dst in all_network:
if dst not in self.paths[src]:
# print('0000000000000000000000000000000000000000000000000000000')
path = nx.shortest_path(all_network, src, dst)
self.paths[... | code_fim | hard | {
"lang": "python",
"repo": "wwmm1/MC",
"path": "/ryu/app/short_path_stp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wwmm1/MC path: /ryu/app/short_path_stp.py
ARD: 'FORWARD'}
self.logger.debug("[dpid=%s][port=%d] state=%s",
dpid_str, ev.port_no, of_state[ev.port_state])
self.port_forwarded.setdefault(ev.dp.id, [])
if of_state[ev.port_state] == 'FORWARD':
... | code_fim | hard | {
"lang": "python",
"repo": "wwmm1/MC",
"path": "/ryu/app/short_path_stp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> switch_ip, switch_port = switch_address_port # get switch ip and port
# get local_host all process
all_process = psutil.net_connections()
for x in all_process:
if str(x.status) == 'ESTABLISHED':
if x.raddr.ip == switch_ip and x.raddr.port == swi... | code_fim | hard | {
"lang": "python",
"repo": "wwmm1/MC",
"path": "/ryu/app/short_path_stp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yandex-cloud/python-sdk path: /yandex/cloud/logging/v1/log_group_service_pb2.py
from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
from google.protobuf import field_mask_pb2 as google_dot_... | code_fim | hard | {
"lang": "python",
"repo": "yandex-cloud/python-sdk",
"path": "/yandex/cloud/logging/v1/log_group_service_pb2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> DESCRIPTOR._options = None
DESCRIPTOR._serialized_options = b'\n\033yandex.cloud.api.logging.v1ZCgithub.com/yandex-cloud/go-genproto/yandex/cloud/logging/v1;logging'
_GETLOGGROUPREQUEST.fields_by_name['log_group_id']._options = None
_GETLOGGROUPREQUEST.fields_by_name['log_group_id']._serialized_op... | code_fim | hard | {
"lang": "python",
"repo": "yandex-cloud/python-sdk",
"path": "/yandex/cloud/logging/v1/log_group_service_pb2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yandex-cloud/python-sdk path: /yandex/cloud/logging/v1/log_group_service_pb2.py
protobuf_dot_field__mask__pb2
from yandex.cloud.api import operation_pb2 as yandex_dot_cloud_dot_api_dot_operation__pb2
from yandex.cloud.access import access_pb2 as yandex_dot_cloud_dot_access_dot_access__pb2
from ya... | code_fim | hard | {
"lang": "python",
"repo": "yandex-cloud/python-sdk",
"path": "/yandex/cloud/logging/v1/log_group_service_pb2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def download(self):
if self._check_exists():
return
if not os.path.exists(self.root):
os.makedirs(self.root)
print('Downloading from {}...'.format(self.url))
local_filename = os.path.join(self.root, 'chardata.mat')
urllib.request.urlretr... | code_fim | hard | {
"lang": "python",
"repo": "mukami12/REM",
"path": "/data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mukami12/REM path: /data.py
import h5py
import torch
import torch.utils.data as data
from torchvision import datasets, transforms
import os
import numpy as np
from PIL import Image
import urllib.request
import scipy.io
class fixedMNIST(data.Dataset):
""" Binarized MNIST dataset, proposed in... | code_fim | hard | {
"lang": "python",
"repo": "mukami12/REM",
"path": "/data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prawn-cake/lecs path: /core/atoms.py
# -*- coding: utf-8 -*-
"""Different core pieces. This file will be split into several ones"""
import collections.abc
class Block(object):
"""Block primitive. Should be immutable and contain set of transactions
as a Merkle-tree"""
pass
class B... | code_fim | hard | {
"lang": "python",
"repo": "prawn-cake/lecs",
"path": "/core/atoms.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Blockchain(collections.abc.Sequence):
"""Immutable blockchain data structure.
To add a new item into a blockchain you need to clone it and pass new item
as a parameter
>>> blockchain = Blockchain.empty()
>>> blockchain = blockchain.clone('new_block')
>>> assert len(blockcha... | code_fim | medium | {
"lang": "python",
"repo": "prawn-cake/lecs",
"path": "/core/atoms.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.block_chain = Blockchain.empty()
if __name__ == '__main__':
pass<|fim_prefix|># repo: prawn-cake/lecs path: /core/atoms.py
# -*- coding: utf-8 -*-
"""Different core pieces. This file will be split into several ones"""
import collections.abc
class Block(object... | code_fim | hard | {
"lang": "python",
"repo": "prawn-cake/lecs",
"path": "/core/atoms.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = self.pool(F.relu(self.bn1(self.conv1(x))))
x = self.pool(F.relu(self.bn2(self.conv2(x))))
x = self.pool(F.relu(self.bn3(self.conv3(x))))
x = self.pool(F.relu(self.bn4(self.conv4(x))))
x = x.view(-1, 128 * 5 * 5)
x = F.relu(self.fc1(x))
x = ... | code_fim | hard | {
"lang": "python",
"repo": "lidongYang22/Autonomous-microrobot-swarm-navigation",
"path": "/demo of swarm distribution planning/DQN_ratio.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> conv1_out = 32
kernel_1 = 5
pool = 2
pool_stride = 2
conv2_out = 64
kernel_2 = 5
conv3_out = 128
kernel_3 = 4
conv4_out = 128
kernel_4 = 4
linear_size_1 = int(conv4_out * ((((((128 - kernel_1 + 1) / 2 - kernel_2 + 1) /... | code_fim | medium | {
"lang": "python",
"repo": "lidongYang22/Autonomous-microrobot-swarm-navigation",
"path": "/demo of swarm distribution planning/DQN_ratio.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lidongYang22/Autonomous-microrobot-swarm-navigation path: /demo of swarm distribution planning/DQN_ratio.py
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import torchvision.transforms as transforms
import numpy as np
import math
is_support = torch.cuda.is_... | code_fim | hard | {
"lang": "python",
"repo": "lidongYang22/Autonomous-microrobot-swarm-navigation",
"path": "/demo of swarm distribution planning/DQN_ratio.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mozumder/django-mozumder path: /mozumder/management/writers/models.py
import os
from .base import Writer
from ...models.development import *
from ..utilities.name_case import *
from ... import ConstraintType
class ModelWriter(Writer):
sub_directory = 'models'
extension = '.py'
def ge... | code_fim | hard | {
"lang": "python",
"repo": "mozumder/django-mozumder",
"path": "/mozumder/management/writers/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output += f"class {model_obj.name}(models.Model):\n"
field_objs = TrackedField.objects.filter(owner=model_obj)
for field_obj in field_objs:
output += get_field(field_obj)
meta = get_meta(model_obj)
if meta:
output ... | code_fim | hard | {
"lang": "python",
"repo": "mozumder/django-mozumder",
"path": "/mozumder/management/writers/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@views.route('/installed')
def success():
with open("plusplus/content/success.md", "r") as f:
text = markdown.markdown(f.read())
return render_template("document.html", title="Install Complete!", content=text)
@views.route('/not_installed')
def failure():
with open("plusplus/content... | code_fim | hard | {
"lang": "python",
"repo": "taviani/pluspl.us",
"path": "/plusplus/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open("plusplus/content/success.md", "r") as f:
text = markdown.markdown(f.read())
return render_template("document.html", title="Install Complete!", content=text)
@views.route('/not_installed')
def failure():
with open("plusplus/content/fail.md", "r") as f:
text = markdo... | code_fim | medium | {
"lang": "python",
"repo": "taviani/pluspl.us",
"path": "/plusplus/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: taviani/pluspl.us path: /plusplus/views.py
from flask import Blueprint, render_template
import markdown
views = Blueprint('views', __name__, template_folder='/template')
@views.route('/')
def index():
return render_template("index.html")
<|fim_suffix|> return render_template("support.... | code_fim | hard | {
"lang": "python",
"repo": "taviani/pluspl.us",
"path": "/plusplus/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """All of the required config must not be None"""
base_config = BaseConfig()
setattr(base_config, 'required_config', ['TEST_CONF'])
setattr(base_config, 'TEST_CONF', None)
self.assertRaises(Exception, base_config.check_required_config)<|fim_prefix|># repo: openknow... | code_fim | medium | {
"lang": "python",
"repo": "openknowledge-archive/dpr-api",
"path": "/tests/test_basics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openknowledge-archive/dpr-api path: /tests/test_basics.py
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
import sys
import os
import unittest
from app import create_app, ... | code_fim | medium | {
"lang": "python",
"repo": "openknowledge-archive/dpr-api",
"path": "/tests/test_basics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
class Migration(migrations.Migration):
dependencies = [("legalaid", "0010_complaints_mi_permissions")]
operations = [
migrations.AddField(
model_name="case", name="assigned_out_of_hours", field=models.NullBooleanField(), preserve_default=True
),
mig... | code_fim | medium | {
"lang": "python",
"repo": "ministryofjustice/cla_backend",
"path": "/cla_backend/apps/legalaid/migrations/0011_case_assigned_out_of_hours.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ministryofjustice/cla_backend path: /cla_backend/apps/legalaid/migrations/0011_case_assigned_out_of_hours.py
# coding=utf-8
from __future__ import unicode_literals
import datetime
from django.db import models, migrations
from django.conf import settings
def add_assigned_at(apps, schema_editor... | code_fim | medium | {
"lang": "python",
"repo": "ministryofjustice/cla_backend",
"path": "/cla_backend/apps/legalaid/migrations/0011_case_assigned_out_of_hours.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chromium/chromium path: /tools/binary_size/libsupersize/obj_analyzer.py
urce code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Analyzer for Object Files.
This file works around Python's lack of concurrency.
_BulkObjectFileAnalyzerWorker:
Performs the actual ... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/tools/binary_size/libsupersize/obj_analyzer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chromium/chromium path: /tools/binary_size/libsupersize/obj_analyzer.py
ht 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Analyzer for Object Files.
This file works around Python's lack of concurrency.
_BulkObj... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/tools/binary_size/libsupersize/obj_analyzer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser()
parser.add_argument('--multiprocess', action='store_true')
parser.add_argument('--output-directory', required=True)
parser.add_argument('--elf-file', type=os.path.realpath)
parser.add_argument('--show-names', action='store_true')
parser.add_argument('--show-s... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/tools/binary_size/libsupersize/obj_analyzer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: miroslavradojevic/python-snippets path: /general/save_float_image.py
#!/usr/bin/env python
import numpy as np
import cv2
if __nam<|fim_suffix|>rr), np.amax(arr), arr.dtype))
cv2.imwrite("arr.jpg", arr)<|fim_middle|>e__ == '__main__':
arr = np.random.rand(512, 512) * 255
print("arr {}... | code_fim | medium | {
"lang": "python",
"repo": "miroslavradojevic/python-snippets",
"path": "/general/save_float_image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rr), np.amax(arr), arr.dtype))
cv2.imwrite("arr.jpg", arr)<|fim_prefix|># repo: miroslavradojevic/python-snippets path: /general/save_float_image.py
#!/usr/bin/env python
import numpy as np
import cv2
if __nam<|fim_middle|>e__ == '__main__':
arr = np.random.rand(512, 512) * 255
print("arr {}... | code_fim | medium | {
"lang": "python",
"repo": "miroslavradojevic/python-snippets",
"path": "/general/save_float_image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ilastik/ndstructs path: /ndstructs/caching/LockingCache.py
import threading
from typing import Dict
import time
from collections import deque
def hashable_dict(d):
return tuple((key, value) for key, value in d.items())
<|fim_suffix|> def __init__(self, maxsize=1024):
self.locks:... | code_fim | hard | {
"lang": "python",
"repo": "ilastik/ndstructs",
"path": "/ndstructs/caching/LockingCache.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __call__(self, f):
def wrapper(*args, **kwargs):
key = (args, hashable_dict(kwargs))
with self.cache_lock:
if key not in self.locks:
self.locks[key] = threading.Lock()
with self.locks[key]:
if key not i... | code_fim | hard | {
"lang": "python",
"repo": "ilastik/ndstructs",
"path": "/ndstructs/caching/LockingCache.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ' '.join(text.split())
def main(args):
with open(args.input, encoding='utf-8') as f:
dataset = json.load(f)
with open(args.output, 'w', encoding='utf-8') as f:
for example in tqdm(dataset):
question = example['question']
answer = example['answe... | code_fim | hard | {
"lang": "python",
"repo": "Ben-wu14/deformer",
"path": "/tools/convert_hotpotqa.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ben-wu14/deformer path: /tools/convert_hotpotqa.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import re
import ujson as json
from tqdm import tqdm
"""
Hotpot QA format:
[
{
"_id": "5a8b57f25542995d1e6f1371",
"answer": "yes",
"question": "Were Scott Derrickson a... | code_fim | hard | {
"lang": "python",
"repo": "Ben-wu14/deformer",
"path": "/tools/convert_hotpotqa.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NoDanCoder/ToDoList path: /applications/tasks/migrations/0001_initial.py
# Generated by Django 3.1.3 on 2020-11-28 14:53
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.CreateModel(
name='TasksMode... | code_fim | hard | {
"lang": "python",
"repo": "NoDanCoder/ToDoList",
"path": "/applications/tasks/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='TasksModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=32, unique=True)),
... | code_fim | hard | {
"lang": "python",
"repo": "NoDanCoder/ToDoList",
"path": "/applications/tasks/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boydgreenfield/onecodex path: /onecodex/lib/upload.py
self._lines_per_record = 4
else:
raise OneCodexException("file_format must be one of: fastq, fasta")
self._tell = 0
self._fsize = file_size
self._buf = Buffer()
self.progressbar = pro... | code_fim | hard | {
"lang": "python",
"repo": "boydgreenfield/onecodex",
"path": "/onecodex/lib/upload.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _make_retry_fields(file_name, metadata, tags, project, sample_id=None, external_sample_id=None):
"""Generate fields to send to init_multipart_upload.
The fields returned by this function are used when a Sample upload via fastx-proxy fails.
Parameters
----------
file_name : `stri... | code_fim | hard | {
"lang": "python",
"repo": "boydgreenfield/onecodex",
"path": "/onecodex/lib/upload.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> atexit_register(cancel_atexit)
# if the upload via init_upload fails, upload_sequence_fileobj will call
# init_multipart_upload, which accepts metadata to be integrated into a newly-created
# Sample model. if the s3 intermediate route is used, two Sample models will ultima... | code_fim | hard | {
"lang": "python",
"repo": "boydgreenfield/onecodex",
"path": "/onecodex/lib/upload.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # all Visa numbers start with 5
# Visa uses 13- and 16-digit numbers
if num_str[0] == '4' and (num_len == 13 or num_len == 16):
return "VISA"
return "INVALID"
if __name__ == "__main__":
main()<|fim_prefix|># repo: MartySalamea/CS50x path: /ProblemSet6/credit/credit.py
from ... | code_fim | hard | {
"lang": "python",
"repo": "MartySalamea/CS50x",
"path": "/ProblemSet6/credit/credit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # All American Express numbers start with 34 or 37
# American Express uses 15-digit numbers
if num_len == 15 and (start_binum == 34 or start_binum == 37):
return "AMEX"
# most MasterCard numbers start with 51, 52, 53, 54, or 55...
# MasterCard uses 16-digit numbers
if num_... | code_fim | hard | {
"lang": "python",
"repo": "MartySalamea/CS50x",
"path": "/ProblemSet6/credit/credit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MartySalamea/CS50x path: /ProblemSet6/credit/credit.py
from cs50 import get_int
def main():
num = get_int("Number: ")
print(define_card(num))
def digits_sum(num):
sum = 0
while num > 0:
sum += num % 10
num //= 10
return sum
def luhns_check(num):
s = s... | code_fim | hard | {
"lang": "python",
"repo": "MartySalamea/CS50x",
"path": "/ProblemSet6/credit/credit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Respond ANYWAY
return JsonResponse({
'ok':True,
'id':newdoc.id,
'name':request.FILES['docfile']._name,
'size':request.FILES['docfile']._size,
'match':'new'}
)
else:
... | code_fim | hard | {
"lang": "python",
"repo": "mwschouten/gps",
"path": "/files/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mwschouten/gps path: /files/views.py
# from django.shortcuts import render
# Create your views here.
from django.core.urlresolvers import reverse
from django.http import JsonResponse
from files.models import Document
from files.forms import DocumentForm
from django.contrib.auth.decorators impor... | code_fim | hard | {
"lang": "python",
"repo": "mwschouten/gps",
"path": "/files/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: okfn-brasil/querido-diario path: /data_collection/gazette/spiders/ba_prado.py
from gazette.spiders.base.doem import DoemGazetteSpider
<|fim_suffix|> TERRITORY_ID = "2925501"
name = "ba_prado"
state_city_url_part = "ba/prado"<|fim_middle|>
class BaPradoSpider(DoemGazetteSpider):
| code_fim | easy | {
"lang": "python",
"repo": "okfn-brasil/querido-diario",
"path": "/data_collection/gazette/spiders/ba_prado.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> TERRITORY_ID = "2925501"
name = "ba_prado"
state_city_url_part = "ba/prado"<|fim_prefix|># repo: okfn-brasil/querido-diario path: /data_collection/gazette/spiders/ba_prado.py
from gazette.spiders.base.doem import DoemGazetteSpider
<|fim_middle|>class BaPradoSpider(DoemGazetteSpider):
| code_fim | easy | {
"lang": "python",
"repo": "okfn-brasil/querido-diario",
"path": "/data_collection/gazette/spiders/ba_prado.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.invoice.__str__()
def pre_save_conflict(sender, instance, *args, **kwargs):
conflict = "{}-{}".format(
instance.invoice.slug,
instance.origin
)
instance.slug = slugify(conflict)
pre_save.connect(pre_save_conflict, sender=CustomerConf... | code_fim | hard | {
"lang": "python",
"repo": "xinsec/LHVent_app",
"path": "/src/customer_finance/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xinsec/LHVent_app path: /src/customer_finance/models.py
from __future__ import unicode_literals
import datetime
from decimal import Decimal
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.urls import r... | code_fim | hard | {
"lang": "python",
"repo": "xinsec/LHVent_app",
"path": "/src/customer_finance/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lqkweb/sqlflow path: /tests/testply/parsetab.py
elation_list opwhere_clause oplimit_clause opas_clause insert : INSERT INTO ID VALUES inservalue_list inservalue_list : '(' non_mvalue_list ')' ',' inservalue_list\n | '(' non_mvalue_list ')' delete : DELETE FROM ID opwhere... | code_fim | hard | {
"lang": "python",
"repo": "lqkweb/sqlflow",
"path": "/tests/testply/parsetab.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lqkweb/sqlflow path: /tests/testply/parsetab.py
elation ',' non_mrelation_list\n | relation relation : ID opwhere_clause : WHERE non_mcond_list\n | nothing oplimit_clause : LIMIT value\n | nothing opas_clause : AS ID\n ... | code_fim | hard | {
"lang": "python",
"repo": "lqkweb/sqlflow",
"path": "/tests/testply/parsetab.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'start': ([0, ], [1, ]), 'command': ([0, ], [2, ]),
'ddl': ([0, ], [3... | code_fim | hard | {
"lang": "python",
"repo": "lqkweb/sqlflow",
"path": "/tests/testply/parsetab.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 3191110276/APIC-EM-Spark-Bot path: /intents/F_get_devices_with_license.py
from connectors import apicem
import concurrent.futures
def main(parameters):
'''Returns a list of all devices that have a certain license'''
devices = apicem.get_network_device_with_license(parameters['licensenam... | code_fim | hard | {
"lang": "python",
"repo": "3191110276/APIC-EM-Spark-Bot",
"path": "/intents/F_get_devices_with_license.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for devlic in results:
if devlic != None:
for lic in devlic:
license_names.append(lic['name'])
license_names = list(set(license_names))
if len(license_names) > 0:
text = 'This is not a valid na... | code_fim | hard | {
"lang": "python",
"repo": "3191110276/APIC-EM-Spark-Bot",
"path": "/intents/F_get_devices_with_license.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stspbu/TinkoffInvestmentsAnalyser path: /main.py
import investments
def main():
print(f'Profit: {investments.manager.get_profit(investme<|fim_suffix|>: {investments.manager.get_currency_to_commission()}')
if __name__ == '__main__':
main()<|fim_middle|>nts.Currency.RUB)}')
print(f'... | code_fim | medium | {
"lang": "python",
"repo": "stspbu/TinkoffInvestmentsAnalyser",
"path": "/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(f'Dividend: {investments.manager.get_currency_to_dividend()}')
print(f'Commission: {investments.manager.get_currency_to_commission()}')
if __name__ == '__main__':
main()<|fim_prefix|># repo: stspbu/TinkoffInvestmentsAnalyser path: /main.py
import investments
def main():
print(f'Pr... | code_fim | medium | {
"lang": "python",
"repo": "stspbu/TinkoffInvestmentsAnalyser",
"path": "/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>: {investments.manager.get_currency_to_commission()}')
if __name__ == '__main__':
main()<|fim_prefix|># repo: stspbu/TinkoffInvestmentsAnalyser path: /main.py
import investments
def main():
print(f'Profit: {investments.manager.get_profit(investme<|fim_middle|>nts.Currency.RUB)}')
print(f'... | code_fim | medium | {
"lang": "python",
"repo": "stspbu/TinkoffInvestmentsAnalyser",
"path": "/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.execution_function = getattr(CallbackOptions, self.execution_function_name)
self.break_number = context.active_object.cs_individual_VG_.breaks
if context.space_data.type == 'VIEW_3D':
self.save_mode = context.active_object.mode
bpy.context.spac... | code_fim | hard | {
"lang": "python",
"repo": "paigeco/VirtualGoniometer",
"path": "/src/Operators/RaycastSelect.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.