text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> class WordTokenizer(BaseTokenizer): def __init__(self, vocab_file, ignored_tokens=[]): super().__init__(vocab_file, ignored_tokens) def token2idx(self, text): words = text.split(' ') return [ self._token2idx.get(w, self._token2idx['<unk>']) for w in words ...
code_fim
hard
{ "lang": "python", "repo": "lfelipesv/speech2text", "path": "/asr/lm/tokenizer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ecds/readux path: /apps/iiif/manifests/views.py """Django views for manifests""" import json import logging from datetime import datetime from django.contrib import messages from django.http import JsonResponse from django.views import View from django.views.generic.base import TemplateView from ...
code_fim
hard
{ "lang": "python", "repo": "ecds/readux", "path": "/apps/iiif/manifests/views.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class ManifestRis(TemplateView): """Manifest Ris""" content_type = 'application/x-research-info-systems; charset=UTF-8' template_name = "citation.ris" def get_context_data(self, **kwargs): """Context data for view :return: [description] :rtype: [type] """ ...
code_fim
hard
{ "lang": "python", "repo": "ecds/readux", "path": "/apps/iiif/manifests/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: markokr/cc path: /cc/daemon/infosender.py #! /usr/bin/env python """Read infofiles. """ import glob import os, os.path import sys import threading import time import skytools import cc.util from cc import json from cc.daemon import CCDaemon from cc.message import is_msg_req_valid from cc.reqs...
code_fim
hard
{ "lang": "python", "repo": "markokr/cc", "path": "/cc/daemon/infosender.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def work (self): t = time.time() while self.looping and self.stats_period > time.time() - t: self._work() self.sleep(1) return 1 def stop (self): """ Called from signal handler """ super(InfofileCollector, self).stop() self.l...
code_fim
hard
{ "lang": "python", "repo": "markokr/cc", "path": "/cc/daemon/infosender.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Maxiimeeb/avionix path: /avionix/chart/__init__.py # flake8: noqa from avionix.chart.chart_builder import ChartBuilder fr<|fim_suffix|>hart.chart_info import ChartInfo from avionix.chart.chart_maintainer import ChartMaintainer from avionix.chart.values_yaml import Value, Values<|fim_middle|>om a...
code_fim
medium
{ "lang": "python", "repo": "Maxiimeeb/avionix", "path": "/avionix/chart/__init__.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>hart.chart_info import ChartInfo from avionix.chart.chart_maintainer import ChartMaintainer from avionix.chart.values_yaml import Value, Values<|fim_prefix|># repo: Maxiimeeb/avionix path: /avionix/chart/__init__.py # flake8: noqa from avionix.chart.chart_builder import ChartBuilder fr<|fim_middle|>om a...
code_fim
medium
{ "lang": "python", "repo": "Maxiimeeb/avionix", "path": "/avionix/chart/__init__.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>e.astype(np.uint16),disk(3)) slicing(contr,'gray')<|fim_prefix|># repo: CameraIA/dipmicroct path: /partII/solutions/ex04.py from skimage.filters.rank import enhance_contrast<|fim_middle|> contr = np.empty_like(img) for i, aslice in enumerate(img): contr[i]= enhance_contrast(aslic
code_fim
medium
{ "lang": "python", "repo": "CameraIA/dipmicroct", "path": "/partII/solutions/ex04.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: CameraIA/dipmicroct path: /partII/solutions/ex04.py from skimage.filters.rank import enhance_contrast<|fim_suffix|>merate(img): contr[i]= enhance_contrast(aslice.astype(np.uint16),disk(3)) slicing(contr,'gray')<|fim_middle|> contr = np.empty_like(img) for i, aslice in enu
code_fim
easy
{ "lang": "python", "repo": "CameraIA/dipmicroct", "path": "/partII/solutions/ex04.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: alejandro-ariza/scikit-fda path: /tests/test_elastic.py from skfda import FDataGrid from skfda.datasets import make_multimodal_samples, make_random_warping from skfda.misc.metrics import (fisher_rao_distance, amplitude_distance, phase_distance, pairwise_distance, l...
code_fim
hard
{ "lang": "python", "repo": "alejandro-ariza/scikit-fda", "path": "/tests/test_elastic.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> t = np.linspace(0, np.pi, 1000) id = FDataGrid([t], t) cos = np.cos(id) sin = np.sin(id) gamma = normalize_warping(np.sqrt(id), (0, np.pi)) gamma2 = normalize_warping(np.square(id), (0, np.pi)) distance_original = fisher_rao_distance(cos, sin) ...
code_fim
hard
{ "lang": "python", "repo": "alejandro-ariza/scikit-fda", "path": "/tests/test_elastic.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>""" Normal 10-fold ------- HybridModel === Part full rmse: 0.8908 ± 0.0044 prec@5: 0.8756 ± 0.0035 ------- HybridModel_SVDpp === Part full rmse: 0.8953 ± 0.0048 prec@5: 0.8747 ± 0.0031 ------- HybridModel_AttributeBiasExperimental === Part full rmse: 0.9235 ± 0.0041 prec@5: 0.8633 ± 0.0043 """<|fim_p...
code_fim
medium
{ "lang": "python", "repo": "sbremer/hybrid_rs", "path": "/scripts/test_10fold.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sbremer/hybrid_rs path: /scripts/test_10fold.py import script_chdir from evaluation.eval_script import evaluate_models_xval, print_results, EvalModel from hybrid_model.dataset import get_dataset # Get dataset dataset = get_dataset('ml100k') # dataset = get_dataset('ml1m') <|fim_suffix|>""" Norm...
code_fim
hard
{ "lang": "python", "repo": "sbremer/hybrid_rs", "path": "/scripts/test_10fold.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>model_type = HybridModel config = hybrid_config models.append(EvalModel(model_type.__name__, model_type, config)) results = evaluate_models_xval(dataset, models, coldstart=False, n_fold=10) print('Normal 10-fold') print_results(results) """ Normal 10-fold ------- HybridModel === Part full rmse: 0.8908 ±...
code_fim
medium
{ "lang": "python", "repo": "sbremer/hybrid_rs", "path": "/scripts/test_10fold.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class TestMetricLogger(unittest.TestCase): def test_update(self): meter = MetricLogger() for i in range(10): meter.update(metric=float(i)) m = meter.meters["metric"] self.assertEqual(m.count, 10) self.assertEqual(m.total, 45) self.as...
code_fim
medium
{ "lang": "python", "repo": "KaihuaTang/Scene-Graph-Benchmark.pytorch", "path": "/tests/test_metric_logger.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> _ = meter.not_existent self.assertRaises(AttributeError, broken) if __name__ == "__main__": unittest.main()<|fim_prefix|># repo: KaihuaTang/Scene-Graph-Benchmark.pytorch path: /tests/test_metric_logger.py # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. imp...
code_fim
hard
{ "lang": "python", "repo": "KaihuaTang/Scene-Graph-Benchmark.pytorch", "path": "/tests/test_metric_logger.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: KaihuaTang/Scene-Graph-Benchmark.pytorch path: /tests/test_metric_logger.py # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import unittest from maskrcnn_benchmark.utils.metric_logger import MetricLogger <|fim_suffix|> def test_no_attr(self): meter = MetricLog...
code_fim
hard
{ "lang": "python", "repo": "KaihuaTang/Scene-Graph-Benchmark.pytorch", "path": "/tests/test_metric_logger.py", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|>##CREATE RIVER IMPUT FILE file_name = "compartmentsGenericRiverSec_prop.txt" out_file = open(file_name, "w") out_file.write("riverSection,nameRS,compartment,compType,depth_m,length_m,volume_m3,width_m,G,T_K,vFlow_m_s,SPM_mgL\n") for rs in range(numRS): for comp in range(len(compartments)): #...
code_fim
hard
{ "lang": "python", "repo": "PradoDomercq/JupiterNotebook_sample_FullMulti", "path": "/Inputs/GenerateGenericRiverImputFile.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: PradoDomercq/JupiterNotebook_sample_FullMulti path: /Inputs/GenerateGenericRiverImputFile.py # -*- coding: utf-8 -*- """ Created on Wed Jan 13 19:05:39 2021 @author: PradoDomercq """ #Script to generate the Generic River imput file including #river sections and compartments of constant dimensio...
code_fim
hard
{ "lang": "python", "repo": "PradoDomercq/JupiterNotebook_sample_FullMulti", "path": "/Inputs/GenerateGenericRiverImputFile.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ##CREATE RIVER IMPUT FILE file_name = "compartmentsGenericRiverSec_prop.txt" out_file = open(file_name, "w") out_file.write("riverSection,nameRS,compartment,compType,depth_m,length_m,volume_m3,width_m,G,T_K,vFlow_m_s,SPM_mgL\n") for rs in range(numRS): for comp in range(len(compartments)): ...
code_fim
medium
{ "lang": "python", "repo": "PradoDomercq/JupiterNotebook_sample_FullMulti", "path": "/Inputs/GenerateGenericRiverImputFile.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Hanyu-Li/neurokernel path: /neurokernel/LPU/synapses/AlphaSynapse.py from basesynapse import BaseSynapse import numpy as np import pycuda.gpuarray as garray from pycuda.tools import dtype_to_ctype import pycuda.driver as cuda from pycuda.compiler import SourceModule cuda_src = """ __global__ v...
code_fim
hard
{ "lang": "python", "repo": "Hanyu-Li/neurokernel", "path": "/neurokernel/LPU/synapses/AlphaSynapse.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.gpu_block = (128,1,1) self.gpu_grid = (min( 6*cuda.Context.get_device().MULTIPROCESSOR_COUNT,\ (self.num-1)/self.gpu_block[0] + 1), 1) # cuda_src = open('./alpha_synapse.cu','r') mod = SourceModule( \ cuda_src % {"type": dt...
code_fim
hard
{ "lang": "python", "repo": "Hanyu-Li/neurokernel", "path": "/neurokernel/LPU/synapses/AlphaSynapse.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> arr[i], arr[k] = arr[k], arr[i] print(arr)<|fim_prefix|># repo: vanigupta20024/Programming-Challenges path: /SelectionSort.py def selection_sort(arr): for i in range(len(arr))<|fim_middle|>: k = i for j in range(i, len(arr)): if arr[j] < arr[k]: ...
code_fim
medium
{ "lang": "python", "repo": "vanigupta20024/Programming-Challenges", "path": "/SelectionSort.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vanigupta20024/Programming-Challenges path: /SelectionSort.py def selection_sort(arr): for i in range(len(arr))<|fim_suffix|> if arr[j] < arr[k]: k = j arr[i], arr[k] = arr[k], arr[i] print(arr)<|fim_middle|>: k = i for j in range(i, len(a...
code_fim
easy
{ "lang": "python", "repo": "vanigupta20024/Programming-Challenges", "path": "/SelectionSort.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class PywebsocketServer(local_server.LocalServer): def __init__(self): super(PywebsocketServer, self).__init__(PywebsocketServerBackend) def GetBackendStartupArgs(self): return {}<|fim_prefix|># repo: metux/chromium-suckless path: /tools/perf/benchmarks/pywebsocket_server.py # Copyright 201...
code_fim
hard
{ "lang": "python", "repo": "metux/chromium-suckless", "path": "/tools/perf/benchmarks/pywebsocket_server.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: metux/chromium-suckless path: /tools/perf/benchmarks/pywebsocket_server.py # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import os import sys <|fim_suffix|> def __init__(self): ...
code_fim
hard
{ "lang": "python", "repo": "metux/chromium-suckless", "path": "/tools/perf/benchmarks/pywebsocket_server.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: AlexKent3141/PicASCII path: /picascii.py import os import sys import argparse import itertools import irc.client from ascii_converter import * from pixabay_finder import * from google_finder import * ''' Picascii is an IRC bot which displays pixel art for the specified search terms. ''' image_...
code_fim
hard
{ "lang": "python", "repo": "AlexKent3141/PicASCII", "path": "/picascii.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> online = True reactor = irc.client.Reactor() try: c = reactor.server().connect(args.server, args.port, bot_nick) except irc.client.ServerConnectionError: print "Unable to connect: " print sys.exc_info()[1] print "Running offline..." online = False ...
code_fim
hard
{ "lang": "python", "repo": "AlexKent3141/PicASCII", "path": "/picascii.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fig = plt.gcf() fig.set_size_inches(10, 5) plt.tight_layout() fig.savefig(save_to, dpi=200) fig.clf()<|fim_prefix|># repo: sdss/astra path: /python/astra/contrib/zetapayne/fit_common.py import matplotlib.pyplot as plt <|fim_middle|>def save_figure(save_to):
code_fim
easy
{ "lang": "python", "repo": "sdss/astra", "path": "/python/astra/contrib/zetapayne/fit_common.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: sdss/astra path: /python/astra/contrib/zetapayne/fit_common.py import matplotlib.pyplot as plt <|fim_suffix|> fig = plt.gcf() fig.set_size_inches(10, 5) plt.tight_layout() fig.savefig(save_to, dpi=200) fig.clf()<|fim_middle|>def save_figure(save_to):
code_fim
easy
{ "lang": "python", "repo": "sdss/astra", "path": "/python/astra/contrib/zetapayne/fit_common.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: david-c-stein/Python-Multiprocessing path: /Logger.py #!/usr/bin/env python import logging import logging.config import logging.handlers import traceback import time import os class SizedTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler): def __init__(self, filename, mode=...
code_fim
hard
{ "lang": "python", "repo": "david-c-stein/Python-Multiprocessing", "path": "/Logger.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> logconfig = { 'version': 1, 'formatters': { 'detailed': { 'class': 'logging.Formatter', 'format': '[%(levelname)-4s][%(asctime)-15s][%(processName)-10s][%(filename)-10s][%(funcName)-8s][%(lineno)-3s] : %(message)s' }, 'simple': { 'class'...
code_fim
hard
{ "lang": "python", "repo": "david-c-stein/Python-Multiprocessing", "path": "/Logger.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # check rollover by size if self.maxBytes > 0: msg = "%s\n" % self.format(record) self.stream.seek(0, 2) if self.stream.tell() + len(msg) >= self.maxBytes: return 1 # check rollover by time t = int(time.time()) if...
code_fim
hard
{ "lang": "python", "repo": "david-c-stein/Python-Multiprocessing", "path": "/Logger.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # test loading from database dynamic_agent = DynamicAgent(owner=config["owner"], name=config["name"], game_type=config["game_type"], class_name=config["class_name"], ...
code_fim
hard
{ "lang": "python", "repo": "arenarium/battleground_core", "path": "/unit_tests/test_dynamic_agent.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: arenarium/battleground_core path: /unit_tests/test_dynamic_agent.py from battleground.dynamic_agent import DynamicAgent from battleground.games.basic_game.basic_agent import BasicAgent from battleground.persistence import agent_data from battleground.agent import Agent def test_dynamic_agent_lo...
code_fim
hard
{ "lang": "python", "repo": "arenarium/battleground_core", "path": "/unit_tests/test_dynamic_agent.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> config = { "owner": "test_owner", "name": "test_agent", "game_type": "test_game", "class_name": "BasicAgent", "local_path": "battleground.games.basic_game.basic_agent", "remote_path": None } # create an agent ID agent_id = agent_data.get_agen...
code_fim
hard
{ "lang": "python", "repo": "arenarium/battleground_core", "path": "/unit_tests/test_dynamic_agent.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gudiandian/ElasticFlow path: /ElasticFlow/chronus-scheduler/client/users.py from abc import ABCMeta, abstractmethod import os, sys import math class UserManager(object): def __init__(self, **kwargs): self.user_list = list() def __getitem__(self, idx): return self.us...
code_fim
hard
{ "lang": "python", "repo": "gudiandian/ElasticFlow", "path": "/ElasticFlow/chronus-scheduler/client/users.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return len(self.user_list) class BaseUser(metaclass=ABCMeta): def __init__(self, JOBS, CLUSTER, name, logger, **kwargs): self.job_manager = JOBS self.cluster_manager = CLUSTER self.name = name self.logger = logger self.with_job_list = list() ...
code_fim
hard
{ "lang": "python", "repo": "gudiandian/ElasticFlow", "path": "/ElasticFlow/chronus-scheduler/client/users.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def finish_job(self, job): self.with_job_list.remove(job) class TimeAwareUser(BaseUser): def __init__(self, JOBS, CLUSTER, name, logger, **kwargs): super(TimeAwareUser, self).__init__(JOBS=JOBS, CLUSTER=CLUSTER, name=name, logger=logger) self.quota = kwargs.get('quota')...
code_fim
hard
{ "lang": "python", "repo": "gudiandian/ElasticFlow", "path": "/ElasticFlow/chronus-scheduler/client/users.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Gruschwick/ECG_PLATFORM path: /Framework/Sketch/Procedures/QRS/Ecgpuwave.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 22 03:59:01 2020 @author: mateusz """ from ..Abstract.ProcedureBase import Base from biosppy.signals import ecg from .Resume.Results import * import w...
code_fim
medium
{ "lang": "python", "repo": "Gruschwick/ECG_PLATFORM", "path": "/Framework/Sketch/Procedures/QRS/Ecgpuwave.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return results(ecgpu_detector.xqrs_detect(sig=data.signal, fs=data.freq), data,"Ecgpuwave")<|fim_prefix|># repo: Gruschwick/ECG_PLATFORM path: /Framework/Sketch/Procedures/QRS/Ecgpuwave.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 22 03:59:01 2020 @author: mateusz """ from ...
code_fim
medium
{ "lang": "python", "repo": "Gruschwick/ECG_PLATFORM", "path": "/Framework/Sketch/Procedures/QRS/Ecgpuwave.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>import skimage from skimage import img_as_ubyte, img_as_float32 from sklearn.model_selection import StratifiedShuffleSplit from glob import glob # import albumentations #import nibabel as nib #import pandas as pd<|fim_prefix|># repo: virtualgraham/fgraph path: /src/sc_patch/sc_patch.py import torch i...
code_fim
hard
{ "lang": "python", "repo": "virtualgraham/fgraph", "path": "/src/sc_patch/sc_patch.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: virtualgraham/fgraph path: /src/sc_patch/sc_patch.py import torch import torch.nn as nn from torch.autograd import Variable import torch.optim as optim from torch.utils.data import Dataset, DataLoader from torchvision import models, datasets import torchvision from torchvision import transforms...
code_fim
medium
{ "lang": "python", "repo": "virtualgraham/fgraph", "path": "/src/sc_patch/sc_patch.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: evancohen/home-assistant path: /homeassistant/components/ifttt.py """ homeassistant.components.ifttt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This component enable you to trigger Maker IFTTT recipes. For more details about this component, please refer to the documentation at https://home-assistant.io/comp...
code_fim
medium
{ "lang": "python", "repo": "evancohen/home-assistant", "path": "/homeassistant/components/ifttt.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_LOGGER = logging.getLogger(__name__) DOMAIN = "ifttt" SERVICE_TRIGGER = 'trigger' ATTR_EVENT = 'event' ATTR_VALUE1 = 'value1' ATTR_VALUE2 = 'value2' ATTR_VALUE3 = 'value3' DEPENDENCIES = [] REQUIREMENTS = ['pyfttt==0.3'] def trigger(hass, event, value1=None, value2=None, value3=None): """ Trig...
code_fim
medium
{ "lang": "python", "repo": "evancohen/home-assistant", "path": "/homeassistant/components/ifttt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def trigger_service(call): """ Handle ifttt trigger service calls. """ event = call.data.get(ATTR_EVENT) value1 = call.data.get(ATTR_VALUE1) value2 = call.data.get(ATTR_VALUE2) value3 = call.data.get(ATTR_VALUE3) if event is None: return ...
code_fim
hard
{ "lang": "python", "repo": "evancohen/home-assistant", "path": "/homeassistant/components/ifttt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if numba < 2: return False else: for k in range(2,numba-1): if numba % k == 0: return False else: return True #gen_primes generates a list of primes between 2 and n using a recursive method def gen_primes(n): primes = [] for...
code_fim
medium
{ "lang": "python", "repo": "bugo99iot/mathematics", "path": "/goldbach/goldbach.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bugo99iot/mathematics path: /goldbach/goldbach.py #this programs asks the user to input an even integer greater than 2 and expresses it as the sum of two primes #the program gives all possible combinations of primes #if you like to know how you can go from working in Subway aged 40 to solving one...
code_fim
hard
{ "lang": "python", "repo": "bugo99iot/mathematics", "path": "/goldbach/goldbach.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>print "This code takes an even integer n greater than 2 and expresses all even numbers between 2 and n as a sum of two primes." n = int(input("Enter n: ")) while n % 2 != 0 or n<2: print "You must enter an even number greater than 2." n = int(input("Enter n: ")) else: print "OK, ", n, "is a ...
code_fim
hard
{ "lang": "python", "repo": "bugo99iot/mathematics", "path": "/goldbach/goldbach.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if not word: return True i, n = 0, len(word) for ch in s: if ch == word[i]: i += 1 if i == n: return True return False d.append("") return next((word for word in ...
code_fim
hard
{ "lang": "python", "repo": "wyaadarsh/LeetCode-Solutions", "path": "/Python3/0524-Longest-Word-in-Dictionary-Through-Deleting/soln-1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wyaadarsh/LeetCode-Solutions path: /Python3/0524-Longest-Word-in-Dictionary-Through-Deleting/soln-1.py class Solution(object): def findLongestWord(self, s, d): <|fim_suffix|> if not word: return True i, n = 0, len(word) for ch in s: if ch == ...
code_fim
hard
{ "lang": "python", "repo": "wyaadarsh/LeetCode-Solutions", "path": "/Python3/0524-Longest-Word-in-Dictionary-Through-Deleting/soln-1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nnethercote/symbolic path: /py/tests/test_debug.py import os from symbolic import ObjectLookup, Archive, id_from_breakpad, normalize_code_id, normalize_debug_id def test_object_features_mac(res_path): binary_path = os.path.join(res_path, 'minidump', 'crash_macos') archive = Archive.ope...
code_fim
hard
{ "lang": "python", "repo": "nnethercote/symbolic", "path": "/py/tests/test_debug.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> lookup = ObjectLookup([{ 'code_id': 'DFB8E43A-F242-3D73-A453-AEB6A777EF75', 'code_file': 'CoreFoundation', 'debug_id': 'dfb8e43a-f242-3d73-a453-aeb6a777ef75', 'debug_file': 'CoreFoundation.dSYM', 'image_addr': '0x1000', 'image_size': 1024, }]) f...
code_fim
hard
{ "lang": "python", "repo": "nnethercote/symbolic", "path": "/py/tests/test_debug.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Plusers/ASLServerDjango path: /ASLServerDjango/mysite/polls/migrations/0008_books_options.py # -*- coding: utf-8 -*- # Generated by Django 1.11.9 on 2019-01-31 09:10 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): <|fim_s...
code_fim
medium
{ "lang": "python", "repo": "Plusers/ASLServerDjango", "path": "/ASLServerDjango/mysite/polls/migrations/0008_books_options.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class Migration(migrations.Migration): dependencies = [ ('polls', '0007_auto_20190123_1923'), ] operations = [ migrations.AddField( model_name='books', name='options', field=models.CharField(blank=True, choices=[(1, 'Учебник'), (2, 'Художес...
code_fim
medium
{ "lang": "python", "repo": "Plusers/ASLServerDjango", "path": "/ASLServerDjango/mysite/polls/migrations/0008_books_options.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('polls', '0007_auto_20190123_1923'), ] operations = [ migrations.AddField( model_name='books', name='options', field=models.CharField(blank=True, choices=[(1, 'Учебник'), (2, 'Художественная литература')], max_length=100),...
code_fim
medium
{ "lang": "python", "repo": "Plusers/ASLServerDjango", "path": "/ASLServerDjango/mysite/polls/migrations/0008_books_options.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return upload_time < taken_time def upload_image(file_path): Notify.Notification.new("Uploading image...").show() p = subprocess.Popen(["curl", "-F", "token=@/home/bunogi/.monshot_token", "-F", "image=@{}".format(file_path), upload_target], stdout=subprocess.PIPE) out, err = ...
code_fim
hard
{ "lang": "python", "repo": "Bunogi/dotfiles", "path": "/bin/screentool.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": Notify.init("screentool.py") if len(sys.argv) == 1: # Capture p = subprocess.run(["maim", "-s", "-k", "-c", "1,0.68,0", "-b", "1", ss_file]) if p.returncode != 0: exit() os.system("xclip -sel clipboard -t image/png < " + ss_file) ...
code_fim
hard
{ "lang": "python", "repo": "Bunogi/dotfiles", "path": "/bin/screentool.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Bunogi/dotfiles path: /bin/screentool.py #!/usr/bin/env python import sys import os import time import subprocess import gi import base64 import hashlib import json ss_file = "/tmp/screenshot.png" taken_file = "/tmp/screentool-taken" upload_file = "/tmp/screentool-uploaded" link_file = "/tmp/sc...
code_fim
hard
{ "lang": "python", "repo": "Bunogi/dotfiles", "path": "/bin/screentool.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: feitianyiren/eums path: /eums/api/supply_efficiency_report/supply_efficiency_report_endpoint.py import logging from rest_framework.response import Response from rest_framework.status import HTTP_200_OK, HTTP_503_SERVICE_UNAVAILABLE from rest_framework.views import APIView <|fim_suffix|> t...
code_fim
hard
{ "lang": "python", "repo": "feitianyiren/eums", "path": "/eums/api/supply_efficiency_report/supply_efficiency_report_endpoint.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def post(self, request): try: report_items = SupplyEfficiencyReportService.search_reports(request.data) return Response(report_items, status=HTTP_200_OK) except Exception as e: logger.exception("Try to get response from elasticsearch service failed: ...
code_fim
medium
{ "lang": "python", "repo": "feitianyiren/eums", "path": "/eums/api/supply_efficiency_report/supply_efficiency_report_endpoint.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: APS-XSD-OPT-Group/wavepytools path: /wavepytools/imaging/integration/fourier_integration.py # -*- coding: utf-8 -*- # """ Created on Mon Sep 12 16:40:44 2016 @author: grizolli """ import numpy as np from numpy.fft import fft, ifft from mpl_toolkits.mplot3d import Axes3D import matplotlib.p...
code_fim
hard
{ "lang": "python", "repo": "APS-XSD-OPT-Group/wavepytools", "path": "/wavepytools/imaging/integration/fourier_integration.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bigGprime = fft(del_f_del_x*phaseShift) bigG = bigGprime*mult_factor func_g = ifft(bigG) /phaseShift func_g -= func_g[0] # since the integral have and undefined constant, # here it is applied an arbritary offset return func_g # %% result = fourier_integra...
code_fim
hard
{ "lang": "python", "repo": "APS-XSD-OPT-Group/wavepytools", "path": "/wavepytools/imaging/integration/fourier_integration.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: louietsai/python-xbee path: /examples/Receiver.py #import config import serial import time from xbee import ZigBee def toHex(s): lst = [] for ch in s: hv = hex(ord(ch)).replace('0x', '') if len(hv) == 1: hv = '0'+hv hv = '0x' + hv lst.append(hv...
code_fim
medium
{ "lang": "python", "repo": "louietsai/python-xbee", "path": "/examples/Receiver.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>PORT = '/dev/ttyUSB1' BAUD_RATE = 9600 # Open serial port ser = serial.Serial(PORT, BAUD_RATE) zb = ZigBee(ser, escaped = True) while True: data = zb.wait_read_frame() decodedData = decodeReceivedFrame(data) print decodedData<|fim_prefix|># repo: louietsai/python-xbee path: /examples/Receive...
code_fim
hard
{ "lang": "python", "repo": "louietsai/python-xbee", "path": "/examples/Receiver.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>zb = ZigBee(ser, escaped = True) while True: data = zb.wait_read_frame() decodedData = decodeReceivedFrame(data) print decodedData<|fim_prefix|># repo: louietsai/python-xbee path: /examples/Receiver.py #import config import serial import time from xbee import ZigBee def toHex(s): lst = []...
code_fim
hard
{ "lang": "python", "repo": "louietsai/python-xbee", "path": "/examples/Receiver.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>], 1, 1e8) ndvi = (((b2-b1)/(b2+b1)+1)/2*255+0.5).astype(np.uint8) return (ndvi, raster1[1], raster1[2])<|fim_prefix|># repo: Image-Py/geonumpy path: /geonumpy/indicate/geo_indicate.py import numpy as np def ndvi(raster1, raster2): b1 <|fim_middle|>= np.clip(raster1[0], 1, 1e8) b2 = np.c...
code_fim
easy
{ "lang": "python", "repo": "Image-Py/geonumpy", "path": "/geonumpy/indicate/geo_indicate.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Image-Py/geonumpy path: /geonumpy/indicate/geo_indicate.py import numpy as np def ndvi(raster1, raster2): b1 <|fim_suffix|>type(np.uint8) return (ndvi, raster1[1], raster1[2])<|fim_middle|>= np.clip(raster1[0], 1, 1e8) b2 = np.clip(raster2[0], 1, 1e8) ndvi = (((b2-b1)/(b2+b1)+1)/...
code_fim
medium
{ "lang": "python", "repo": "Image-Py/geonumpy", "path": "/geonumpy/indicate/geo_indicate.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> "2": ["3", "4", "5"], "3": ["4", "5", "6"], }, {"0": "2", "1": "4", "2": "3", "3": "4"}, [1, 2, 3], {1: 0.5, 2: 0.75, 3: 1.0}, ), ], ) def test_hits(nn_ind, gold, k, expected): res = hits(nn_ind, gold, k) assert res...
code_fim
hard
{ "lang": "python", "repo": "cthoyt/kiez", "path": "/tests/evaluate/test_eval_metrics.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cthoyt/kiez path: /tests/evaluate/test_eval_metrics.py import pytest from kiez.evaluate import hits @pytest.mark.parametrize( "nn_ind, gold, k, expected", [ ( [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]], {0: 2, 1: 4, 2: 3, 3: 4}, [1, 2, 3], ...
code_fim
hard
{ "lang": "python", "repo": "cthoyt/kiez", "path": "/tests/evaluate/test_eval_metrics.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AlterField( model_name='temporaryuploadchunked', name='offset', field=models.BigIntegerField(default=0), ), migrations.AlterField( model_name='temporaryuploadchunked', name='total_size', ...
code_fim
medium
{ "lang": "python", "repo": "ImperialCollegeLondon/django-drf-filepond", "path": "/django_drf_filepond/migrations/0010_temp_chunked_biginteger.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: ImperialCollegeLondon/django-drf-filepond path: /django_drf_filepond/migrations/0010_temp_chunked_biginteger.py # Generated by Django 3.0.5 on 2021-06-25 16:33 from django.db import migrations, models class Migration(migrations.Migration): <|fim_suffix|> operations = [ migrations.A...
code_fim
medium
{ "lang": "python", "repo": "ImperialCollegeLondon/django-drf-filepond", "path": "/django_drf_filepond/migrations/0010_temp_chunked_biginteger.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: walnutgeek/D2UX path: /d2ux/model.py ''' ''' from enum import Enum import os class FileType(Enum): DIR=(0,None,) CSV=(1,'.csv') JSON=(2,'.json') MD=(3,'.md') class ContentType(Enum): <|fim_suffix|> os.path.join(self.parts.join('/'),root)<|fim_middle|> DATA_FRAME=(1,)...
code_fim
medium
{ "lang": "python", "repo": "walnutgeek/D2UX", "path": "/d2ux/model.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> os.path.join(self.parts.join('/'),root)<|fim_prefix|># repo: walnutgeek/D2UX path: /d2ux/model.py ''' ''' from enum import Enum import os class FileType(Enum): DIR=(0,None,) CSV=(1,'.csv') JSON=(2,'.json') MD=(3,'.md') class ContentType(Enum): DATA_FRAME=(1,) OBJECT=(2...
code_fim
medium
{ "lang": "python", "repo": "walnutgeek/D2UX", "path": "/d2ux/model.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: BC-SECURITY/Empire path: /empire/server/core/host_service.py from sqlalchemy.orm import Session from empire.server.core.db import models class HostService(object): <|fim_suffix|> return db.query(models.Host).all() @staticmethod def get_by_id(db: Session, uid: int): retu...
code_fim
medium
{ "lang": "python", "repo": "BC-SECURITY/Empire", "path": "/empire/server/core/host_service.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, main_menu): self.main_menu = main_menu @staticmethod def get_all(db: Session): return db.query(models.Host).all() @staticmethod def get_by_id(db: Session, uid: int): return db.query(models.Host).filter(models.Host.id == uid).first()<|fim_pre...
code_fim
easy
{ "lang": "python", "repo": "BC-SECURITY/Empire", "path": "/empire/server/core/host_service.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> STOPPED = "<stopped>" RUNNING = "<running>" COMPLETE = "<complete>" status = StatusFlag()<|fim_prefix|># repo: cedadev/mistamover path: /lib/StatusFlag.py # BSD Licence # Copyright (c) 2012, Science & Technology Facilities Council (STFC) # All rights reserved. # # See the LICENSE file in the sourc...
code_fim
easy
{ "lang": "python", "repo": "cedadev/mistamover", "path": "/lib/StatusFlag.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cedadev/mistamover path: /lib/StatusFlag.py # BSD Licence # Copyright (c) 2012, Science & Technology Facilities Council (STFC) # All rights reserved. # # See the LICENSE file in the source distribution of this software for # the full license text. <|fim_suffix|> STOPPED = "<stopped>" RUNNING ...
code_fim
easy
{ "lang": "python", "repo": "cedadev/mistamover", "path": "/lib/StatusFlag.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: filipknapik/gcp_functions_library path: /aws_s3_to_gcp_gcs/source/main.py import boto3 import json import os from flask import jsonify from google.cloud import storage def execute(request): request_json = request.get_json() access_key_id = request_json['aws_access_key_id'] secre...
code_fim
hard
{ "lang": "python", "repo": "filipknapik/gcp_functions_library", "path": "/aws_s3_to_gcp_gcs/source/main.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fileSize = os.path.getsize(tempFileName) print("filesize="+str(os.path.getsize('/tmp/filedump'))) return fileSize def writeGCS(gcsbucket, path, tempFileName): storage_client = storage.Client() bucket = storage_client.get_bucket(gcsbucket) blob = bucket.blob(path) blob.upload_...
code_fim
hard
{ "lang": "python", "repo": "filipknapik/gcp_functions_library", "path": "/aws_s3_to_gcp_gcs/source/main.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def readS3(access_key_id, secret_access_key, s3bucket, region_input, path, tempFileName): session = boto3.Session(aws_access_key_id=access_key_id,aws_secret_access_key=secret_access_key) s3 = session.resource('s3',region_name=region_input) s3.meta.client.download_file(s3bucket, path, tempFile...
code_fim
hard
{ "lang": "python", "repo": "filipknapik/gcp_functions_library", "path": "/aws_s3_to_gcp_gcs/source/main.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # RecId 查出乘客行程,根据乘客行程,改变乘客行程跟车主行程。 # 乘客行程 try: rec_detail_obj = CarPoolingRecDetail.objects.get(c_id=RecId) if rec_detail_obj.c_userid != request.session[WOPENID]: return HttpResponse(RtnDefault(RtnCode.STATUS_PARAM, "非本人不能退订该行程"), ...
code_fim
hard
{ "lang": "python", "repo": "yangtao4389/pinche", "path": "/carPooling/api_userrec.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: yangtao4389/pinche path: /carPooling/api_userrec.py rt json import requests import traceback from datetime import datetime,timedelta from django.shortcuts import render,HttpResponse,HttpResponseRedirect from django.conf import settings from common import client,uuid_maker,checkparam from common.j...
code_fim
hard
{ "lang": "python", "repo": "yangtao4389/pinche", "path": "/carPooling/api_userrec.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # "CurrentPageIndex": 1, "PageSize": 20, "RowCount": 66, "PageCount": 4, "IsFirstPage": true, "IsLastPage": false, "CurrentRowCount": 20, "CurrentStartIndex": 1, "CurrentEndIndex": 20 resultDict = dict( CurrentPageIndex=pageNum, PageSize=numPerPage, RowC...
code_fim
hard
{ "lang": "python", "repo": "yangtao4389/pinche", "path": "/carPooling/api_userrec.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> class Meta: model = Function fields = ('uuid','movie','group') class ShowtimesSerializer(serializers.ModelSerializer): """ Serializer for Function Model """ uuid = serializers.UUIDField(source='movie.uuid', format='hex') movie = ShowtimeMovieSerializer(many=False,...
code_fim
hard
{ "lang": "python", "repo": "juliancantillo/royal-films", "path": "/royalfilms/cinemas/serializers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """ Serializer for Cinema Model """ uuid = serializers.UUIDField(format='hex') functions = FunctionSerializer(source='function_set', read_only=True, many=True) class Meta: model = Cinema fields = ('uuid','name','functions','address','lat','lng',)<|fim_prefix|># rep...
code_fim
hard
{ "lang": "python", "repo": "juliancantillo/royal-films", "path": "/royalfilms/cinemas/serializers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: juliancantillo/royal-films path: /royalfilms/cinemas/serializers.py from rest_framework import serializers from .models import Cinema, Function, Show, FunctionType, Auditorium from royalfilms.movies.models import Movie from royalfilms.movies.serializers import MovieSerializer,\ ShowtimeMovie...
code_fim
hard
{ "lang": "python", "repo": "juliancantillo/royal-films", "path": "/royalfilms/cinemas/serializers.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Testing with Hong Kong/68""" nuc = "ATGAAGACCATCATTGCTTTGAGCTACATTTTCTGTCTGGCTCTCGGCCAAGACCTTCCAGGAAATGACAACAGCACAGCAACGCTGTGCCTGGGACATCATGCGGTGCCAAACGGAACACTAGTGAAAACAATCACAGATGATCAGATTGAAGTGACTAATGCTACTGAGCTAGTTCAGAGCTCCTCAACGGGGAAAATATGCAACAATCCTCATCGAATCCTTGATGGAATAGACTGCACACTGATAGATGCTCTATTGGGGG...
code_fim
hard
{ "lang": "python", "repo": "5l1v3r1/treetool", "path": "/augur/src/seq_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: 5l1v3r1/treetool path: /augur/src/seq_util.py from itertools import izip import numpy as np def hamming_distance(seq1, seq2): aseq1, aseq2 = np.array(seq1), np.array(seq2) non_gap = (aseq1!='-')*(aseq2!='-') return np.mean(aseq1[non_gap]!=aseq2[non_gap]) def translate(nuc): <|fim_suffix|>def...
code_fim
hard
{ "lang": "python", "repo": "5l1v3r1/treetool", "path": "/augur/src/seq_util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def main(): """Testing with Hong Kong/68""" nuc = "ATGAAGACCATCATTGCTTTGAGCTACATTTTCTGTCTGGCTCTCGGCCAAGACCTTCCAGGAAATGACAACAGCACAGCAACGCTGTGCCTGGGACATCATGCGGTGCCAAACGGAACACTAGTGAAAACAATCACAGATGATCAGATTGAAGTGACTAATGCTACTGAGCTAGTTCAGAGCTCCTCAACGGGGAAAATATGCAACAATCCTCATCGAATCCTTGATGGAATAGACTGCACACTGATAGATG...
code_fim
hard
{ "lang": "python", "repo": "5l1v3r1/treetool", "path": "/augur/src/seq_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> day = (prn-1)//37 prn = prn - 37*day start += chip_rate*86400*day start = start%code_length p_x1 = x1(prn,start,len) p_x2 = x2(prn,start-prn,len) p_last_x2 = last_x2(prn,(start-prn)%code_length,len) idx_x2 = (start - prn + np.arange(len)) % code_length idx_last_x2 = idx_x2>=(code_lengt...
code_fim
hard
{ "lang": "python", "repo": "mfkiwl/GNSS-DSP-tools", "path": "/gnsstools/gps/p.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def chips2hex(c): n = c.shape[0]//4 r = c.shape[0]%4 if r!=0: s = octal_digit(c[0:r]) else: s = "" for i in range(n): s += hex_digit(c[r+4*i:r+4*(i+1)]) return s def first_256_chips_hex(prn): start = 0 len = 256 c = p_code(prn,start,len) return chips2hex(c) def last_1024_...
code_fim
hard
{ "lang": "python", "repo": "mfkiwl/GNSS-DSP-tools", "path": "/gnsstools/gps/p.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mfkiwl/GNSS-DSP-tools path: /gnsstools/gps/p.py # GPS P code construction # # Copyright 2014 Peter Monta import numpy as np chip_rate = 10230000 code_length = chip_rate*86400*7 def x1a_shift(x): return [x[11]^x[10]^x[7]^x[5]] + x[0:11] def x1b_shift(x): return [x[11]^x[10]^x[9]^x[8]^x[7]^...
code_fim
hard
{ "lang": "python", "repo": "mfkiwl/GNSS-DSP-tools", "path": "/gnsstools/gps/p.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Junlin-Yin/Data-Mining-Homework path: /hw3/hw3_code/neural_networks/feedforward_backprop.py from fullyconnect_feedforward import fullyconnect_feedforward from fullyconnect_backprop import fullyconnect_backprop from relu_feedforward import relu_feedforward from relu_backprop import relu_backprop f...
code_fim
medium
{ "lang": "python", "repo": "Junlin-Yin/Data-Mining-Homework", "path": "/hw3/hw3_code/neural_networks/feedforward_backprop.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # feedforward hidden layer and relu fully1_out = fullyconnect_feedforward(data, weights['fully1_weight'], weights['fully1_bias']) #print('fully1_out', fully1_out) relu1_out = relu_feedforward(fully1_out) #print("relu1_out", relu1_out) # softmax loss (probs = e^(w*x+b) / sum(e^(w*...
code_fim
medium
{ "lang": "python", "repo": "Junlin-Yin/Data-Mining-Homework", "path": "/hw3/hw3_code/neural_networks/feedforward_backprop.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # feedforward hidden layer and relu fully1_out = fullyconnect_feedforward(data, weights['fully1_weight'], weights['fully1_bias']) #print('fully1_out', fully1_out) relu1_out = relu_feedforward(fully1_out) #print("relu1_out", relu1_out) # softmax loss (probs = e^(w*x+b) / sum(e^(w...
code_fim
medium
{ "lang": "python", "repo": "Junlin-Yin/Data-Mining-Homework", "path": "/hw3/hw3_code/neural_networks/feedforward_backprop.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>iff//max_diff + 1) if total_diffs*diff_base+len(dense_array_of_diffs)*correction_precision < min_total_diff_cost: min_total_diff_cost = total_diffs*diff_base+len(dense_array_of_diffs)*correction_precision return min_total_diff_cost<|fim_prefix|># repo: pandey-shruti/LC-model-compr...
code_fim
hard
{ "lang": "python", "repo": "pandey-shruti/LC-model-compression", "path": "/lc/compression_types/utils.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pandey-shruti/LC-model-compression path: /lc/compression_types/utils.py import numpy as np """ TODO: This file is poorly documented for now, will fix in future version. """ def diff_based_coding(dense_array_of_diffs, correction_precision=16, diff_bases=range(3, 20)): min_total_diff_cost ...
code_fim
hard
{ "lang": "python", "repo": "pandey-shruti/LC-model-compression", "path": "/lc/compression_types/utils.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>class NamesClassifier(Model): def __init__(self, word_embeddings: TextFieldEmbedder, encoder: Seq2SeqEncoder, vocab: Vocabulary) -> None: super().__init__(vocab) self.word_embeddings = word_embeddings self.encoder = encoder ...
code_fim
hard
{ "lang": "python", "repo": "Murfin/allennlp_lab4", "path": "/modules/homework_4.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Murfin/allennlp_lab4 path: /modules/homework_4.py from typing import Iterator, List, Dict import torch import torch.optim as optim import numpy as np from allennlp.common.params import Params from allennlp.data import Instance from allennlp.data.fields import TextField, SequenceLabelField fro...
code_fim
hard
{ "lang": "python", "repo": "Murfin/allennlp_lab4", "path": "/modules/homework_4.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }