text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> l = []
for b in tiltlist:
l.append(
{
"measurement": "tilt",
"tags": {
"name": b["name"],
},
"time": b["time"],
"fields": {
"gravity": b["gravity"],
... | code_fim | hard | {
"lang": "python",
"repo": "KenN7/PyTiltWebsite",
"path": "/pytilt-api/influxmodels.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ksmaheshkumar/barf-project path: /barf/barf/arch/x86/x86translator.py
import logging
import sys
import traceback
import barf
import barf.arch.x86.x86disassembler
from barf.arch import ARCH_X86_MODE_32
from barf.arch import ARCH_X86_MODE_64
from barf.arch.x86.x86base import X86ArchitectureInform... | code_fim | hard | {
"lang": "python",
"repo": "ksmaheshkumar/barf-project",
"path": "/barf/barf/arch/x86/x86translator.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return instrs
def _generate_write_instrs(self, operand, dst_reg):
"""Return operand write memory access translation.
"""
addr_reg, instrs = self._compute_memory_address(operand, None)
return instrs + [self.ir_builder.gen_stm(dst_reg, addr_reg)]
def _compu... | code_fim | hard | {
"lang": "python",
"repo": "ksmaheshkumar/barf-project",
"path": "/barf/barf/arch/x86/x86translator.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrandrewGR/The-Python-Workshop path: /Chapter03/Activity08/current_time.py
"""
This script returns the current system time.
"""
<|fim_suffix|># If the script is being executed, this if statement will be true,
# and therefore the time will be printed
if __name__ == '__main__':
print(time)<|f... | code_fim | hard | {
"lang": "python",
"repo": "MrandrewGR/The-Python-Workshop",
"path": "/Chapter03/Activity08/current_time.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># If the script is being executed, this if statement will be true,
# and therefore the time will be printed
if __name__ == '__main__':
print(time)<|fim_prefix|># repo: MrandrewGR/The-Python-Workshop path: /Chapter03/Activity08/current_time.py
"""
This script returns the current system time.
"""
<|f... | code_fim | hard | {
"lang": "python",
"repo": "MrandrewGR/The-Python-Workshop",
"path": "/Chapter03/Activity08/current_time.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # the below throws exceptions a lot, so be careful
# this is only needed because the card reader is not always reliable
try:
user_id, user_dob = regex.findall(user_input)[0]
except:
print('Invalid read of DL, try again')
continue
... | code_fim | hard | {
"lang": "python",
"repo": "autobar/AutoBarRpi",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # use a flag
# => 0 means incorrect license number
# => 1 means success
# => 2 means underage user
flag = 0
while flag is 0:
# wait for the user to slide their drivers license
user_input = str(raw_input('Enter DL: '))
# the below throws ... | code_fim | hard | {
"lang": "python",
"repo": "autobar/AutoBarRpi",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: autobar/AutoBarRpi path: /main.py
#!/usr/bin/python
import requests
import json
import re
from dateutil.relativedelta import relativedelta
import datetime
from Controllers import PumpController
from Controllers import MotorController
# returns a Boolean of whether the user is over 21 or not
def... | code_fim | hard | {
"lang": "python",
"repo": "autobar/AutoBarRpi",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cedadev/arrivals-uploader path: /uploader/rsync/update/file_handler.py
""" Rsync configuration file handling. """
__author__ = "William Tucker"
__date__ = "2018-07-25"
__copyright__ = "Copyright 2019 United Kingdom Research and Innovation"
__license__ = "BSD - see LICENSE file in top-level packa... | code_fim | hard | {
"lang": "python",
"repo": "cedadev/arrivals-uploader",
"path": "/uploader/rsync/update/file_handler.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class RsyncConf(RsyncFileHandler):
USER_MATCH_TEMPLATE = '^\[{username}\].*'
NEW_USER_TEMPLATE = ('[{username}]\n'
' uid = {uid}\n'
' path = {data_directory}\n'
' auth users = {username}\n')
def __init__(s... | code_fim | hard | {
"lang": "python",
"repo": "cedadev/arrivals-uploader",
"path": "/uploader/rsync/update/file_handler.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ezuk-i/shuter path: /shooter_game.py
from pygame import *
from random import randint
finish = False
mixer.init()
mixer.music.load('space.ogg')
mixer.music.play()
window = display.set_mode((700, 500))
display.set_caption("Шутер")
background = transform.scale(image.load("galaxy.jpg"),(700, 500)... | code_fim | hard | {
"lang": "python",
"repo": "ezuk-i/shuter",
"path": "/shooter_game.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rect.y = self.rect.y + self.speed
if self.rect.y > 500:
self.rect.y = 1
self.rect.x = randint(1, 700)
class Bullet(GameSprite):
def update(self):
self.rect.y = self.rect.y - self.speed
if self.rect.y < 1:
self.kill()
player1 =... | code_fim | hard | {
"lang": "python",
"repo": "ezuk-i/shuter",
"path": "/shooter_game.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pylhc/omc3 path: /omc3/scripts/write_madx_macros.py
"""
Write MAD-X Macros
------------------
Write out madx scripts for the tracking macros.
**Arguments:**
*--Required--*
- **outputdir**:
Directory where the observation_points.def will be put.
- **twissfile**:
Path to twissfile wi... | code_fim | hard | {
"lang": "python",
"repo": "pylhc/omc3",
"path": "/omc3/scripts/write_madx_macros.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro = ""
for tracker, prefix in (("ptc", "ptc_"), ("madx", "")):
macro += f"define_{tracker}_observation_points(): macro = {{\n"
macro += "".join([f" {prefix}observe, place='{bpm}';\n" for bpm in list_of_bpms])
macro += "};\n"
return macro
def tracking_macros(lis... | code_fim | hard | {
"lang": "python",
"repo": "pylhc/omc3",
"path": "/omc3/scripts/write_madx_macros.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> obs_macro_file = outdir / OBS_POINTS
with open(obs_macro_file, 'w') as obs_script:
obs_script.write(define_observation_points_macros(list_of_bpms))
track_macros = _call(obs_macro_file)
track_macros += """
/*
* Performs a single particle tracking of the active sequence.
... | code_fim | hard | {
"lang": "python",
"repo": "pylhc/omc3",
"path": "/omc3/scripts/write_madx_macros.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fpath, outpath = params
print('mfcc: ' + fpath)
fs, signal = wavfile.read(fpath)
mfcc = MFCC.extract(fs, signal)
mkdirp(os.path.dirname(outpath))
with open(outpath, 'w') as fout:
for x in mfcc:
print >> fout, " " . join(map(str, x))
def extract_mfcc_data(dirnam... | code_fim | hard | {
"lang": "python",
"repo": "jainal09/speaker-recognition",
"path": "/src/test/extract-mfcc-data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jainal09/speaker-recognition path: /src/test/extract-mfcc-data.py
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# $File: extract-mfcc-data.py
# $Date: Tue Dec 24 20:23:39 2013 +0000
# $Author: Xinyu Zhou <zxytim[at]gmail[dot]com>
from sample import Sample
from scipy.io import wavfile
import matplo... | code_fim | hard | {
"lang": "python",
"repo": "jainal09/speaker-recognition",
"path": "/src/test/extract-mfcc-data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for style in ['Style_Spontaneous', 'Style_Whisper', 'Style_Reading']:
dirname = '../test-data/corpus.silence-removed/' + style
mfcc_output_dir = "mfcc-data/" + style
extract_mfcc_data(dirname, mfcc_output_dir)
if __name__ == '__main__':
main()
# vim: foldmethod=marker<|f... | code_fim | hard | {
"lang": "python",
"repo": "jainal09/speaker-recognition",
"path": "/src/test/extract-mfcc-data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(f'уникальных слов в тексте/ коротких слов {len(text_items_counter)}/ {len(short_text_items_counter)}')
text_items_counter_ordered = dict(
sorted(text_items_counter.items(), key=lambda x: x[1], reverse=True)[:100]
)
short_text_items_counter_ordered = dict(
sorted(short_text_items_counter.ite... | code_fim | hard | {
"lang": "python",
"repo": "ShadowLore/lesson_201226",
"path": "/step_1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ShadowLore/lesson_201226 path: /step_1.py
with open('data/fairy_tail.txt', 'r', encoding='utf-8') as f:
content = f.read()
# task 1 -> найти уникальные слова в тексте и подсчитать их количество
# task 1 -> отсортировать слова в тексте по частоте
# task 1 -> найти перевод TOP-100
<|fim_su... | code_fim | medium | {
"lang": "python",
"repo": "ShadowLore/lesson_201226",
"path": "/step_1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aduV24/python_exercises path: /9.Dictionaries_and_sets/charcter_count.py
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 14:25:40 2020
@author: NOTEBOOK
"""
import pyperclip
import pprint
#Get the string to be counted from the clipboard
message = pyperclip.paste()
#Create an empty dictionary
c... | code_fim | medium | {
"lang": "python",
"repo": "aduV24/python_exercises",
"path": "/9.Dictionaries_and_sets/charcter_count.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> message.lower():
count.setdefault(character,0)
count[character] += 1
#initialize accumulator
total = 0
for i in count.values():
total += i
#Display the string and frequency
pprint.pprint(count)
print()
print('Total amount of characters is ' ,total)<|fim_prefix|># repo: aduV24/python_e... | code_fim | medium | {
"lang": "python",
"repo": "aduV24/python_exercises",
"path": "/9.Dictionaries_and_sets/charcter_count.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result_lst = list(''.join(result_lst))
for unit_sep in chinese_unit_sep:
flag = result_lst.count(unit_sep)
while flag > 1:
result_lst.pop(result_lst.index(unit_sep))
flag -= 1
'''
length = len(str(number))
if 4 < length <= 8:
flag = res... | code_fim | hard | {
"lang": "python",
"repo": "terryyizhong/tacotron2",
"path": "/text/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: terryyizhong/tacotron2 path: /text/__init__.py
""" from https://github.com/keithito/tacotron """
import re
from text import cleaners
from text.symbols import symbols, symbols_chs
# Regular expression matching text enclosed in curly braces:
_curly_re = re.compile(r'(.*?)\{(.+?)\}(.*)')
def te... | code_fim | hard | {
"lang": "python",
"repo": "terryyizhong/tacotron2",
"path": "/text/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _to_cn(number):
""" convert integer to Chinese numeral """
chinese_numeral_dict = {
'0': '零',
'1': '一',
'2': '二',
'3': '三',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九'
}
chinese_unit_map = [... | code_fim | hard | {
"lang": "python",
"repo": "terryyizhong/tacotron2",
"path": "/text/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: drallensmith/pycma path: /cma/recombination_weights.py
"""Define a list of recombination weights for the CMA-ES. The most
delicate part is the correct setting of negative weights depending
on learning rates to prevent negative definite matrices when using the
weights in the covariance matrix upda... | code_fim | hard | {
"lang": "python",
"repo": "drallensmith/pycma",
"path": "/cma/recombination_weights.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Details:
- To guaranty 3., the input vectors associated to negative
weights must obey ||.||^2 <= dimension in Mahalanobis norm.
- The third argument, ``cmu``, usually depends on the
(raw) weights, in particular it depends on ``self.mueff``.
For this r... | code_fim | hard | {
"lang": "python",
"repo": "drallensmith/pycma",
"path": "/cma/recombination_weights.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adijo/ift6135-rnn path: /assignment2/ptb-lm-loss-compute.py
#!/bin/python
# coding: utf-8
import argparse
import time
import collections
import os
import sys
import torch
import torch.nn
from torch.autograd import Variable
import torch.nn as nn
import numpy as np
from models_grad import RNN, GRU... | code_fim | hard | {
"lang": "python",
"repo": "adijo/ift6135-rnn",
"path": "/assignment2/ptb-lm-loss-compute.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Wraps hidden states in new Tensors, to detach them from their history.
This prevents Pytorch from trying to backpropagate into previous input
sequences when we use the final hidden states from one mini-batch as the
initial hidden states for the next mini-batch.
Usin... | code_fim | hard | {
"lang": "python",
"repo": "adijo/ift6135-rnn",
"path": "/assignment2/ptb-lm-loss-compute.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mask = (data != pad).unsqueeze(-2)
mask = mask & Variable(
subsequent_mask(data.size(-1)).type_as(mask.data))
return mask
# LOAD DATA
print('Loading data from '+args.data)
raw_data = ptb_raw_data(data_path=args.data)
train_data, valid_data, test_data, word_to_id, id_2... | code_fim | hard | {
"lang": "python",
"repo": "adijo/ift6135-rnn",
"path": "/assignment2/ptb-lm-loss-compute.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> _LINGO.__init__(self)
self.name = "LINGOS"
self.specie = 'nouns'
self.basic = "lingo"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_lingos.py
from xai.brain.wordbase.nouns._lingo import _LINGO
#calss header
class _LINGOS(_LINGO, ):
<|fim_middle|> def _... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_lingos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self,):
_LINGO.__init__(self)
self.name = "LINGOS"
self.specie = 'nouns'
self.basic = "lingo"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_lingos.py
from xai.brain.wordbase.nouns._lingo import _LINGO
<|fim_middle|>#calss header
class _L... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_lingos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_lingos.py
from xai.brain.wordbase.nouns._lingo import _LINGO
#calss header
class _LINGOS(_LINGO, ):
<|fim_suffix|> _LINGO.__init__(self)
self.name = "LINGOS"
self.specie = 'nouns'
self.basic = "lingo"
self.jsondata = {}<|fim_middle|> def _... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_lingos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.mock_load_import.assert_called_once()
self.mock_load_list.assert_called_once()
self.mock_load_show.assert_called_once()
self.mock_load_import.assert_called_with(**self.patch_expected)
@patch('os.path.isfile', lambda x: True)
def test_load_import_inactive(self... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/config",
"path": "/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_load_shell.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: starlingx/config path: /sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_load_shell.py
#
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from mock import patch
from cgtsclient.exc import CommandError
from cgtsclient.tests import test_shell
from cgt... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/config",
"path": "/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_load_shell.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.make_env()
self.mock_load_list.return_value = [
{
'id': 1,
'state': 'ACTIVE',
'software_version': '5',
},
{
'id': 2,
'state': 'IMPORTED',
'software_vers... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/config",
"path": "/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_load_shell.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> paths = [os.path.join(from_dir, d) for d in os.listdir(from_dir)]
# arr = np.array(pool.map(process.process, paths), dtype='uint8')
images = pool.map(process.read_bytes, paths)
with h5py.File(to_path, 'w') as f:
dt = h5py.special_dtype(vlen=np.dtype('uint8'))
dset = f.crea... | code_fim | medium | {
"lang": "python",
"repo": "beibuwandeluori/CLDC",
"path": "/datasets/FMix-master/utils/imagenet_to_hdf5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for subdir in subdirs:
from_dir = os.path.join(imagenet_dir, subdir)
to_path = os.path.join(target_dir, subdir + '.hdf5')
paths = [os.path.join(from_dir, d) for d in os.listdir(from_dir)]
# arr = np.array(pool.map(process.process, paths), dtype='uint8')
images = pool.map(process.read... | code_fim | medium | {
"lang": "python",
"repo": "beibuwandeluori/CLDC",
"path": "/datasets/FMix-master/utils/imagenet_to_hdf5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: beibuwandeluori/CLDC path: /datasets/FMix-master/utils/imagenet_to_hdf5.py
import numpy as np
import h5py
import multiprocessing
import os
# from PIL import Image
import pickle
import process
SIZE = 256
imagenet_dir = '/ssd/ILSVRC2012/train'
target_dir = '/data/imagenet_hdf5/train'
subdirs = [... | code_fim | hard | {
"lang": "python",
"repo": "beibuwandeluori/CLDC",
"path": "/datasets/FMix-master/utils/imagenet_to_hdf5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>E)),
('exam', models.ForeignKey(verbose_name='Exam', to='course.Exam', on_delete=models.CASCADE)),
('participation', models.ForeignKey(verbose_name='Participation', to='course.Participation', on_delete=models.CASCADE)),
],
options={
'... | code_fim | hard | {
"lang": "python",
"repo": "inducer/relate",
"path": "/course/migrations/0068_exam_tickets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inducer/relate path: /course/migrations/0068_exam_tickets.py
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
... | code_fim | hard | {
"lang": "python",
"repo": "inducer/relate",
"path": "/course/migrations/0068_exam_tickets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ("happy" != mood):
raise(Exception("Not happy, only %d %s" % (self.n, self.what)))<|fim_prefix|># repo: jonas/cucumber-jvm path: /jython/src/test/resources/cucumber/runtime/jython/step_definitions/cuke_steps.py
@Given('I have (\d+) "(.+)" in my belly')
def something_in_the_belly(self, n, what):
... | code_fim | medium | {
"lang": "python",
"repo": "jonas/cucumber-jvm",
"path": "/jython/src/test/resources/cucumber/runtime/jython/step_definitions/cuke_steps.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jonas/cucumber-jvm path: /jython/src/test/resources/cucumber/runtime/jython/step_definitions/cuke_steps.py
@Given('I have (\d+) "(.+)" in my belly')
def something_in_the_belly(self, n, what):
<|fim_suffix|> if ("happy" != mood):
raise(Exception("Not happy, only %d %s" % (self.n, self.what)))... | code_fim | medium | {
"lang": "python",
"repo": "jonas/cucumber-jvm",
"path": "/jython/src/test/resources/cucumber/runtime/jython/step_definitions/cuke_steps.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyprism/Hiren-news path: /news/views.py
from django.http import HttpResponse
from news.models import Bunny
from .posts import posts
from datetime import datetime, timedelta
from .models import Bunny
<|fim_suffix|>def cleaner(request):
"""
Cron endpoint for db cleanup
:param request:
... | code_fim | hard | {
"lang": "python",
"repo": "pyprism/Hiren-news",
"path": "/news/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def scheduler(request):
"""
cron based job runner ! :/
:param request:
:return:
"""
posts()
return HttpResponse("Hello Hiren :D !")
def cleaner(request):
"""
Cron endpoint for db cleanup
:param request:
:return:
"""
last_month = datetime.today() - time... | code_fim | medium | {
"lang": "python",
"repo": "pyprism/Hiren-news",
"path": "/news/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('', file=fp)
print('# Define lists of all / KHR / KHX extensions', file=fp)
print('allExts=' + shList(allExts), file=fp)
print('khrExts=' + shList(khrExts), file=fp)
print('khxExts=' + shList(khxExts), file=fp)
fp.close()
if args.outpy:
f... | code_fim | hard | {
"lang": "python",
"repo": "TrevorDev/OpenXR-SDK",
"path": "/specification/scripts/extDependency.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrevorDev/OpenXR-SDK path: /specification/scripts/extDependency.py
#!/usr/bin/env python3
#
# Copyright (c) 2017-2019 The Khronos Group Inc.
#
# 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 co... | code_fim | hard | {
"lang": "python",
"repo": "TrevorDev/OpenXR-SDK",
"path": "/specification/scripts/extDependency.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># -extension name - may be a single extension name, a space-separated list
# of names, or a regular expression.
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-registry', action='store',
default='registry/xr.xml',
... | code_fim | hard | {
"lang": "python",
"repo": "TrevorDev/OpenXR-SDK",
"path": "/specification/scripts/extDependency.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ng", # 404
"d/d2/StaatslijnC.png", # 404
"2/28/Logo_de_la_F%C3%A9d%C3%A9ration_de_Parkour.png", # 404
)
]<|fim_prefix|># repo: lmmx/wikitransp path: /src/wikitransp/scraper/ban_list.py
__all__ = ["BANNED_URLS"]
_URL_PREFIX = "https://upload.wikimedia.org/wikipedia/commons/"
BANNE... | code_fim | medium | {
"lang": "python",
"repo": "lmmx/wikitransp",
"path": "/src/wikitransp/scraper/ban_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lmmx/wikitransp path: /src/wikitransp/scraper/ban_list.py
__all__ = ["BANNED_URLS"]
_URL_PREFIX = "https://upload.wikimedia.org/wikipedia/commons/"
BANNED_URLS = [
f"{_URL_PREFIX}<|fim_suffix|>anische_Kulturareale_en.png", # 404
"e/ea/Park_Jihoon_GQ.png", # 404
"2/21/Break... | code_fim | medium | {
"lang": "python",
"repo": "lmmx/wikitransp",
"path": "/src/wikitransp/scraper/ban_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-nanoAOD/cmssw path: /DQMOffline/Trigger/python/Tau3MuMonitor_cfi.py
from math import pi
import FWCore.ParameterSet.Config as cms
from DQMOffline.Trigger.tau3muMonitoring_cfi import tau3muMonitoring
hltTau3Mumonitoring = tau3muMonitoring.clone()
# DQM directory
hltTau3Mumonitoring.FolderNa... | code_fim | hard | {
"lang": "python",
"repo": "cms-nanoAOD/cmssw",
"path": "/DQMOffline/Trigger/python/Tau3MuMonitor_cfi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>hltTau3Mumonitoring.GenericTriggerEventPSet.andOr = cms.bool( False ) # https://github.com/cms-sw/cmssw/blob/76d343005c33105be1e01b7b7278c07d753398db/CommonTools/TriggerUtils/src/GenericTriggerEventFlag.cc#L249
hltTau3Mumonitoring.GenericTriggerEventPSet.andOrHlt = cms.bool( True ) # https... | code_fim | medium | {
"lang": "python",
"repo": "cms-nanoAOD/cmssw",
"path": "/DQMOffline/Trigger/python/Tau3MuMonitor_cfi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dphero/char_cnn_rnn_pytorch path: /char_cnn_rnn/char_cnn_rnn.py
import torch
import torch.nn as nn
from .net_modules.fixed_rnn import fixed_rnn
from .net_modules.fixed_gru import fixed_gru
class char_cnn_rnn(nn.Module):
'''
Char-CNN-RNN model, described in ``Learning Deep Representati... | code_fim | hard | {
"lang": "python",
"repo": "dphero/char_cnn_rnn_pytorch",
"path": "/char_cnn_rnn/char_cnn_rnn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def onehot_to_labelvec(tensor):
labels = torch.zeros(tensor.size(1), dtype=torch.long)
val, idx = torch.nonzero(tensor).split(1, dim=1)
labels[idx] = val+1
return labels
def labelvec_to_str(labels):
'''
Converts a text description from one-hot tensor format to string format.
... | code_fim | hard | {
"lang": "python",
"repo": "dphero/char_cnn_rnn_pytorch",
"path": "/char_cnn_rnn/char_cnn_rnn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def prepare_text(string, max_str_len=201):
'''
Converts a text description from string format to one-hot tensor format.
'''
labels = str_to_labelvec(string, max_str_len)
one_hot = labelvec_to_onehot(labels)
return one_hot
def str_to_labelvec(string, max_str_len):
string = st... | code_fim | hard | {
"lang": "python",
"repo": "dphero/char_cnn_rnn_pytorch",
"path": "/char_cnn_rnn/char_cnn_rnn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GATECH-EIC/HALO path: /l2o-scale-regularize-test/mnist.py
"""MNIST handwritten digits dataset.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
<|fim_suffix|>def load_mnist(path='mnist/mnist.npz'):
"""Loads the MNIST dataset.
Ar... | code_fim | medium | {
"lang": "python",
"repo": "GATECH-EIC/HALO",
"path": "/l2o-scale-regularize-test/mnist.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># train, test = load_mnist()
# imgs, labels = train
#
# plt.imshow(imgs[0])
# plt.show()
# print(imgs[0].dtype)
# print(labels[0].dtype)<|fim_prefix|># repo: GATECH-EIC/HALO path: /l2o-scale-regularize-test/mnist.py
"""MNIST handwritten digits dataset.
"""
from __future__ import absolute_import
from __fu... | code_fim | hard | {
"lang": "python",
"repo": "GATECH-EIC/HALO",
"path": "/l2o-scale-regularize-test/mnist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lishulongVI/leetcode path: /python3/123.Best Time to Buy and Sell Stock III(买卖股票的最佳时机 III).py
"""
<p>Say you have an array for which the <em>i</em><sup>th</sup> element is the price of a given stock on day <em>i</em>.</p>
<p>Design an algorithm to find the maximum profit. You may complete at mos... | code_fim | hard | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python3/123.Best Time to Buy and Sell Stock III(买卖股票的最佳时机 III).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><pre><strong>输入:</strong> [1,2,3,4,5]
<strong>输出:</strong> 4
<strong>解释:</strong> 在第 1 天(股票价格 = 1)的时候买入,在第 5 天 (股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5-1 = 4 。
注意你不能在第 1 天和第 2 天接连购买股票,之后再将它们卖出。
因为这样属于同时参与了多笔交易,你必须在再次购买前出售掉之前的股票。
</pre>
<p><strong>示例 3:</strong></p>
<pre><stron... | code_fim | hard | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python3/123.Best Time to Buy and Sell Stock III(买卖股票的最佳时机 III).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><p>设计一个算法来计算你所能获取的最大利润。你最多可以完成 <em>两笔 </em>交易。</p>
<p><strong>注意:</strong> 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。</p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:</strong> [3,3,5,0,0,3,1,4]
<strong>输出:</strong> 6
<strong>解释:</strong> 在第 4 天(股票价格 = 0)的时候买入,在第 6 天(股票价格 = 3)的时候卖出,这笔交易所能获得利润... | code_fim | hard | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python3/123.Best Time to Buy and Sell Stock III(买卖股票的最佳时机 III).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: code-haven/Django-treasurehunt-demo path: /treasurehunt/views.py
from django.views.generic import View
from django.http import HttpResponse
from django.shortcuts import render
<|fim_suffix|> return render(request, 'treasurehunt/treasurehunt_index.html')<|fim_middle|>def index(request):
| code_fim | easy | {
"lang": "python",
"repo": "code-haven/Django-treasurehunt-demo",
"path": "/treasurehunt/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, 'treasurehunt/treasurehunt_index.html')<|fim_prefix|># repo: code-haven/Django-treasurehunt-demo path: /treasurehunt/views.py
from django.views.generic import View
from django.http import HttpResponse
from django.shortcuts import render
<|fim_middle|>def index(request):
| code_fim | easy | {
"lang": "python",
"repo": "code-haven/Django-treasurehunt-demo",
"path": "/treasurehunt/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# box_1=(1372,744,1628,1000)# 中
# box_2=(1244,616,1500,872)# 左上
# box_3=(1244,872,1500,1128)# 左下
# box_4=(1500,616,1756,872)# 右上
# box_5=(1500,872,1756,1128)# 右下
# img_1=img.crop(box_1)
# img_2=img.crop(box_2)
# img_3=img.crop(box_3)
# img_4=img.crop(box_4... | code_fim | hard | {
"lang": "python",
"repo": "Buster-maker/classify",
"path": "/img_crop.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Buster-maker/classify path: /img_crop.py
from os import scandir
from PIL import Image
from PIL import ImageEnhance
import os
image_1="./IDADP-PRCV2019-training/1-600"
image_2="./IDADP-PRCV2019-training/2-600"
image_3="./IDADP-PRCV2019-training/3-600"
image_4="./IDADP-PRCV2019-training/4-40... | code_fim | hard | {
"lang": "python",
"repo": "Buster-maker/classify",
"path": "/img_crop.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# box_1=(1372,744,1628,1000)# 中
# box_2=(1244,616,1500,872)# 左上
# box_3=(1244,872,1500,1128)# 左下
# box_4=(1500,616,1756,872)# 右上
# box_5=(1500,872,1756,1128)# 右下
# img_1=img.crop(box_1)
# img_2=img.crop(box_2)
# img_3=img.crop(box_3)
# img_... | code_fim | hard | {
"lang": "python",
"repo": "Buster-maker/classify",
"path": "/img_crop.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hzjkaka/LDP_Protocols path: /svim.py
import copy
import logging
import math
import itertools
from scipy.stats import norm
import numpy as np
class SVSM():
def find(self, fixed_threshold=0):
single_test_user = self.users.get_size() / 2
keys, values = self.find_singleton(sing... | code_fim | hard | {
"lang": "python",
"repo": "hzjkaka/LDP_Protocols",
"path": "/svim.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # step 1: running limit
phase_one_user = int(single_test_user * self.args.single_random_alloc)
singleton_list, value_result = self.singleton_random(phase_one_user, thres=thres)
key_result = {}
for i in xrange(len(singleton_list)):
key_result[(singleton_... | code_fim | hard | {
"lang": "python",
"repo": "hzjkaka/LDP_Protocols",
"path": "/svim.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deltasherlock/django-server path: /deltasherlock_server/admin.py
from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin
from .models import ChangesetWrapper, FingerprintWrapper, EventLabel, QueueItem
from .models imp<|fim_suffix|>n)
#admin.site.register(ChangesetWrap... | code_fim | hard | {
"lang": "python",
"repo": "deltasherlock/django-server",
"path": "/deltasherlock_server/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>n)
#admin.site.register(ChangesetWrapper, ChangesetWrapperAdmin)
#admin.site.register(FingerprintWrapper, SimpleHistoryAdmin)
admin.site.site_header = "DeltaSherlock Database Admin"<|fim_prefix|># repo: deltasherlock/django-server path: /deltasherlock_server/admin.py
from django.contrib import admin
fro... | code_fim | medium | {
"lang": "python",
"repo": "deltasherlock/django-server",
"path": "/deltasherlock_server/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> m.load()
for i in range(I):
for j in range(J):
m.drawRectangle(height*i//I, width*j//J, height//I-1, width//J-1, thickness=2,newObject=False)
plt.figure()
for i in range(I):
for j in range(J):
try:
plt.subplot(I, J, 1+j+ J*(... | code_fim | hard | {
"lang": "python",
"repo": "yaukwankiu/armor",
"path": "/tests/powerSpecLocalTest.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yaukwankiu/armor path: /tests/powerSpecLocalTest.py
#powerSpecLocalTest.py
thisScript = 'powerSpecLocalTest.py'
import shutil, os, time
from armor.initialise import *
##########################################################################
# setting
#L = monsoon.list + march.list + kongrey.l... | code_fim | hard | {
"lang": "python",
"repo": "yaukwankiu/armor",
"path": "/tests/powerSpecLocalTest.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#plt.figure()
###
for count in range(30):
I = int(3+np.random.random()*2)
J = I
N = int(np.random.random() * len(L))
m = L[N]
m.load()
m.show() #debug
height, width = m.matrix.shape
m.mask=0
m.setThreshold(0)
psResults={}
maxSpecs={}
for i in range(I):
... | code_fim | hard | {
"lang": "python",
"repo": "yaukwankiu/armor",
"path": "/tests/powerSpecLocalTest.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ppinko/python_exercises path: /dict/dict_unique_sorted_string.py
"""
Question:
Write a program that accepts a sequence of whitespace separated words as input and prints the
words after removing all duplicate words and sorting them alphanumerically.
Suppose the following input is supplied to the ... | code_fim | hard | {
"lang": "python",
"repo": "ppinko/python_exercises",
"path": "/dict/dict_unique_sorted_string.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> inp = input("Please enter a sentence: ").split()
dic = {}
for element in inp:
if dic.get(element, 0) == 0:
dic[element] = 1
ans = list(dic.keys())
ans.sort()
print(" ".join(ans))
sort_string()
"""
# Alternative Solution
# We use set container to remove duplica... | code_fim | medium | {
"lang": "python",
"repo": "ppinko/python_exercises",
"path": "/dict/dict_unique_sorted_string.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kolbt/whingdingdilly path: /phase_diagrammer/lennard-jones_diameter_overlay_mono.py
'''
# This is an 80 character line #
This file:
1. Reads in data for diameter from textfiles
2. Computes the LJ force for given distances
3. Plots th... | code_fim | hard | {
"lang": "python",
"repo": "kolbt/whingdingdilly",
"path": "/phase_diagrammer/lennard-jones_diameter_overlay_mono.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
for i in range(0, len(txtFiles)):
peA[i] = getFromTxt(txtFiles[i], "pa", "_pb")
peB[i] = getFromTxt(txtFiles[i], "pb", "_xa")
xA[i] = getFromTxt(txtFiles[i], "xa", "_ep")
ep[i] = getFromTxt(txtFiles[i], "ep", ".txt")
except:
for i in range(0, len(txtFiles)):
... | code_fim | hard | {
"lang": "python",
"repo": "kolbt/whingdingdilly",
"path": "/phase_diagrammer/lennard-jones_diameter_overlay_mono.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: networkcube/vistorian-web path: /web/demodata/anonymize.py
import csv;
from random import shuffle;
newNames = [];
persons = [];
newPlaces = [];
oldPlaces = [];
oldRelations = [];
newRelations = [
'Academic Work',
'Friendship',
'Politics',
'Colleges',
'Food'
]
# Extract new names
with op... | code_fim | hard | {
"lang": "python",
"repo": "networkcube/vistorian-web",
"path": "/web/demodata/anonymize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> l1 = row[1];
l2 = row[4];
if not l1 in oldPlaces:
oldPlaces.append(l1)
if not l2 in oldPlaces:
oldPlaces.append(l2)
r = row[2].strip();
if not r in oldRelations:
oldRelations.append(r)
newline = [
newNames[persons.index(p1)],
newPlaces[oldPlaces.index(l1)],
newRela... | code_fim | hard | {
"lang": "python",
"repo": "networkcube/vistorian-web",
"path": "/web/demodata/anonymize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Vipermdl/SegLossBias path: /seglossbias/evaluation/citycapes_evaluator.py
import numpy as np
import logging
from typing import Optional
from terminaltables import AsciiTable
from .evaluator import DatasetEvaluator
from .metric import intersect_and_union
logger = logging.getLogger(__name__)
cl... | code_fim | hard | {
"lang": "python",
"repo": "Vipermdl/SegLossBias",
"path": "/seglossbias/evaluation/citycapes_evaluator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return iou
def mean_score(self):
miou = (self.total_area_intersect / (np.spacing(1) + self.total_area_union)).mean()
return miou
def class_score(self):
class_acc = self.total_area_intersect / (np.spacing(1) + self.total_area_label)
class_iou = self.total_a... | code_fim | hard | {
"lang": "python",
"repo": "Vipermdl/SegLossBias",
"path": "/seglossbias/evaluation/citycapes_evaluator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if vasya.count(25) >= 3:
i = 3
while i > 0:
del vasya[vasya.index(25)]
i -= 1
vasya.append(p)
continue
return 'NO'
return "YES"<|fim_prefix|># repo: qamine-test/codewars path: /kyu_6/vasya_clerk/tickets.py
def tickets(people: list) -> str:
"""
Return YES, if Vasya c... | code_fim | hard | {
"lang": "python",
"repo": "qamine-test/codewars",
"path": "/kyu_6/vasya_clerk/tickets.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qamine-test/codewars path: /kyu_6/vasya_clerk/tickets.py
def tickets(people: list) -> str:
"""
Return YES, if Vasya can sell a ticket to every
person and give change with the bills he has at
hand at that moment. Otherwise return NO.
:param people:
:return:
"""
print(peop... | code_fim | medium | {
"lang": "python",
"repo": "qamine-test/codewars",
"path": "/kyu_6/vasya_clerk/tickets.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if p == 100:
if 25 in vasya and 50 in vasya:
del vasya[vasya.index(25)]
del vasya[vasya.index(50)]
vasya.append(p)
continue
if vasya.count(25) >= 3:
i = 3
while i > 0:
del vasya[vasya.index(25)]
i -= 1
vasya.append(p)
continue
return 'NO'
return "YES... | code_fim | medium | {
"lang": "python",
"repo": "qamine-test/codewars",
"path": "/kyu_6/vasya_clerk/tickets.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
A dict mapping key hashes to keys in raw_keys. Falsy elements of raw_keys
and non-CSEKs are skipped.
"""
index = {}
if raw_keys:
for raw_key in raw_keys:
if not raw_key:
continue
key = parse_key(raw_key)
if key.type == KeyType.CSEK:
index[key.... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/storage/encryption_util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _get_raw_key(args, key_field_name):
"""Searches for key values in flags, falling back to a file if necessary.
Args:
args: An object containing flag values from the command surface.
key_field_name (str): Corresponds to a flag name or field name in the key
file.
Returns:
The ... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/storage/encryption_util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google-cloud-sdk-unofficial/google-cloud-sdk path: /lib/googlecloudsdk/command_lib/storage/encryption_util.py
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compl... | code_fim | hard | {
"lang": "python",
"repo": "google-cloud-sdk-unofficial/google-cloud-sdk",
"path": "/lib/googlecloudsdk/command_lib/storage/encryption_util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nawrotlab/SpikingNeuralProgramForagingInsect-PNAS path: /make_paper_figures.py
from olnet.plotting.figures import figure1
import numpy as np
import matplotlib.pyplot as plt
fileType = "png"
# plot LabConditioning single-trial
file = 'cache/LabCond_0-3-5-8-15-3sec/sim-odor-0-0-58.npz'
mstMATFile ... | code_fim | hard | {
"lang": "python",
"repo": "nawrotlab/SpikingNeuralProgramForagingInsect-PNAS",
"path": "/make_paper_figures.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>file = 'cache/GaussianCone_15-0-3-15_10sec/sim-13-27.npz'
mstMATFile = 'matlab/model_cache/predictions/msp_classicalLabCond-0-15.odor-15.1-sp.1/Gaussian_15-0-3-15_10sec.mat'
data = np.load(file)['data'][()]
figure_3 = figure1(data, t_max=10, orn_range=-1, pn_range=[0,35], cmap='seismic',mstMatFile=mstMATF... | code_fim | hard | {
"lang": "python",
"repo": "nawrotlab/SpikingNeuralProgramForagingInsect-PNAS",
"path": "/make_paper_figures.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_model(resource: str = Path(...)):
model = app.models.get(resource)
return model
async def parse_body(request: Request, resource: str = Path(...)):
body = await request.json()
resource = await app.get_resource(resource, exclude_pk=True, exclude_m2m_field=False)
resource_fields... | code_fim | hard | {
"lang": "python",
"repo": "bubthegreat/fastapi-admin",
"path": "/fastapi_admin/depends.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bubthegreat/fastapi-admin path: /fastapi_admin/depends.py
import json
import jwt
from fastapi import Depends, HTTPException, Path, Query
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.security.utils import get_authorization_scheme_param
from pydantic import Ba... | code_fim | hard | {
"lang": "python",
"repo": "bubthegreat/fastapi-admin",
"path": "/fastapi_admin/depends.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def __call__(self, resource: str = Path(...), user=Depends(get_current_user)):
if not app.permission or user.is_superuser:
return
if not user.is_active:
raise HTTPException(status_code=HTTP_403_FORBIDDEN)
has_permission = False
await user.f... | code_fim | hard | {
"lang": "python",
"repo": "bubthegreat/fastapi-admin",
"path": "/fastapi_admin/depends.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bingran-you/Data-Structure-Final path: /多关键字排序/qt_gui/c_wrap.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Author : WZR ZZY
File : c_wrap.py
Time : 2020-06-13
Software: PyCharm
'''
from ctypes import *
sort = CDLL('../lib/libsort.so')
class TIME(Structure):
_fields_ = [("sumt... | code_fim | medium | {
"lang": "python",
"repo": "bingran-you/Data-Structure-Final",
"path": "/多关键字排序/qt_gui/c_wrap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def sortList(j):
sort_data = sort.get_sorted_result
sort_data.restype = POINTER(LIST)
FiveIntegers = c_int * 5
sort_data.argtypes = (c_int, POINTER(FiveIntegers), c_int, c_int, POINTER(FiveIntegers))
seq = FiveIntegers(j[1], j[2], j[3], j[4], j[5])
endian = FiveIntegers(j[8], j[9],... | code_fim | hard | {
"lang": "python",
"repo": "bingran-you/Data-Structure-Final",
"path": "/多关键字排序/qt_gui/c_wrap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scottishs/dataviewfortableau path: /docapi.py
import os
import pandas as pd
import numpy as np
import unicodedata
from tableaudocumentapi import Workbook
# from tableaudocumentapi import Connection
# from tableaudocumentapi import dbclass
# Setup
#sourceWB = Workbook('tableauworkbook.twb')
pri... | code_fim | hard | {
"lang": "python",
"repo": "scottishs/dataviewfortableau",
"path": "/docapi.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># d1_1_1 = d1_1.query('Field_Calc_Count > 1') # Multipe fields, diff calcs
# d1_1_1['Dup_Calc'] = 1
# d1_1_2 = d1_1.query('Field_Calc_Count <=1') # Non duplicate field calcs
# d1_1_2['Agg_Null'] = np.where(d1_1_2['Default Aggregation'].isnull(),1,0)
# d1_1_2 = d1_1_2.query('Agg_Null==0') # Non Duplicate... | code_fim | hard | {
"lang": "python",
"repo": "scottishs/dataviewfortableau",
"path": "/docapi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tweet_vars_validate()
Base.metadata.create_all(engine)
logger = getLogger(__name__)
logger.debug("[Start DailyJob]")
try:
daily_job = TodayCancel(tweet_queue)
daily_job.tweet_today_cancel()
for model in [Info, Cancel, News]:
delete_olds(model)
ex... | code_fim | hard | {
"lang": "python",
"repo": "pddg/qkouserver",
"path": "/qkoubot/main_cron.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pddg/qkouserver path: /qkoubot/main_cron.py
import asyncio
from logging import getLogger
from datetime import datetime
from multiprocessing import Queue
from .cron import TodayCancel
from .database import LoginFailureLog, add, update_info, delete_olds
from .network import login_and_get_html
from... | code_fim | medium | {
"lang": "python",
"repo": "pddg/qkouserver",
"path": "/qkoubot/main_cron.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def add_comparison_expression(prop, object_path):
if prop is not None and prop.value is not None:
if hasattr(prop, "condition"):
cond = prop.condition
else:
warn("No condition given - assume '='", 714)
cond = None
return create_term(object_p... | code_fim | hard | {
"lang": "python",
"repo": "oasis-open/cti-stix-elevator",
"path": "/stix2elevator/convert_pattern.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oasis-open/cti-stix-elevator path: /stix2elevator/convert_pattern.py
make_constant(key_value_term)))
if reg_key.values:
values_expressions = []
for v in reg_key.values:
value_expressions = []
for prop_spec in _REGIST... | code_fim | hard | {
"lang": "python",
"repo": "oasis-open/cti-stix-elevator",
"path": "/stix2elevator/convert_pattern.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def select_file_properties():
if get_option_value("spec_version") == "2.1":
return _FILE_PROPERTIES_2_1
else:
return _FILE_PROPERTIES_2_0
def convert_file_to_pattern(f):
expressions = []
if f.hashes is not None:
hash_expression = convert_hashes_to_pattern(f.hashe... | code_fim | hard | {
"lang": "python",
"repo": "oasis-open/cti-stix-elevator",
"path": "/stix2elevator/convert_pattern.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.