text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: TrendingTechnology/triangular-tpp path: /ttpp/gen/stationary_renewal.py import numpy as np from pathlib import Path from scipy.stats import lognorm dataset_dir = Path(__file__).parents[2] / 'data' def generate(max_time, n_sequences, filename='stationary_renewal'): times, nll = [], [] fo...
code_fim
medium
{ "lang": "python", "repo": "TrendingTechnology/triangular-tpp", "path": "/ttpp/gen/stationary_renewal.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> times.append(T) nll.append(score) if filename is not None: mean_number_items = sum(len(t) for t in times) / len(times) nll = [n/mean_number_items for n in nll] np.savez(f'{dataset_dir}/{filename}.npz', arrival_times=times, nll=nll, t_max=max_time, mean_number_i...
code_fim
hard
{ "lang": "python", "repo": "TrendingTechnology/triangular-tpp", "path": "/ttpp/gen/stationary_renewal.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> shift : list, numpy.ndarray A list of two coordinate shifts to be applied to coordinates *before* ``matrix`` transformations are applied. meta : dict, None, optional Dictionary that will be merged to the object's ``meta`` fields. **kwargs : opt...
code_fim
hard
{ "lang": "python", "repo": "Shalmalee15/tweakwcs", "path": "/tweakwcs/tpwcs.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Shalmalee15/tweakwcs path: /tweakwcs/tpwcs.py xt[1] * yt[0] - xt[2] * yt[1] - xt[3] * yt[2] - xt[0] * yt[3] ) pscale = float(np.sqrt(area)) return pscale @property def tanp_center_pixel_scale(self): """ Estimate pixel scale in the tangent plane near ...
code_fim
hard
{ "lang": "python", "repo": "Shalmalee15/tweakwcs", "path": "/tweakwcs/tpwcs.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Shalmalee15/tweakwcs path: /tweakwcs/tpwcs.py ] + xt[1] * yt[2] + xt[2] * yt[3] + xt[3] * yt[0] - xt[1] * yt[0] - xt[2] * yt[1] - xt[3] * yt[2] - xt[0] * yt[3] ) pscale = float(np.sqrt(area)) return pscale @property def tanp_center_pixel_scale(self): ...
code_fim
hard
{ "lang": "python", "repo": "Shalmalee15/tweakwcs", "path": "/tweakwcs/tpwcs.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Auto add the requesting user.""" serializer.save(user=self.request.user) def perform_update(self, serializer): """Auto add the requesting user.""" serializer.save(user=self.request.user)<|fim_prefix|># repo: jdalton92/trading-bot path: /server/orders/views.py from ...
code_fim
hard
{ "lang": "python", "repo": "jdalton92/trading-bot", "path": "/server/orders/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jdalton92/trading-bot path: /server/orders/views.py from core.permissions import IsAdminOrOwner from rest_framework import viewsets from rest_framework.permissions import IsAuthenticated from .models import Order from .serializers import OrderCreateSerializer, OrderSerializer class OrderView(v...
code_fim
hard
{ "lang": "python", "repo": "jdalton92/trading-bot", "path": "/server/orders/views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: w-mbugua/Fitness-api path: /app/utilities/validator.py """validation""" import re from ..auth.v1.model.users import UserModels from ..auth.v1.model.exercise import ExerciseModel class Validators: """class to hold validation methods""" def valid_email(self, email): """method to va...
code_fim
medium
{ "lang": "python", "repo": "w-mbugua/Fitness-api", "path": "/app/utilities/validator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def password_confirm(self, password, confirm_password): """Method to confirm the password and confrm password are equal""" return password == confirm_password def hash_password(self, password): """method to hide the password""" new_password = ['*' for i in password...
code_fim
hard
{ "lang": "python", "repo": "w-mbugua/Fitness-api", "path": "/app/utilities/validator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aio-libs/frozenlist path: /tests/test_frozenlist.py from collections.abc import MutableSequence import pytest from frozenlist import FrozenList, PyFrozenList class FrozenListMixin: FrozenList = NotImplemented SKIP_METHODS = {"__abstractmethods__", "__slots__"} def test_subclass(...
code_fim
hard
{ "lang": "python", "repo": "aio-libs/frozenlist", "path": "/tests/test_frozenlist.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_gt(self) -> None: _list = self.FrozenList([2]) assert _list > [1] def test_insert(self) -> None: _list = self.FrozenList([2]) _list.insert(0, 1) assert _list == [1, 2] def test_frozen_setitem(self) -> None: _list = self.FrozenList([1])...
code_fim
hard
{ "lang": "python", "repo": "aio-libs/frozenlist", "path": "/tests/test_frozenlist.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> opcaoMenu = Biblioteca.menu() elif opcaoMenu == 5: # Importar dados print("• IMPORTANDO DADOS •") Biblioteca.livros.append(Biblioteca.importarLivros()) Biblioteca.livros.pop(len(Biblioteca.livros)-1) opcaoMenu = Biblioteca.menu() ...
code_fim
hard
{ "lang": "python", "repo": "eduardojpsena/ProjetoBiblioteca-Python", "path": "/projetoBiblioteca/Main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: eduardojpsena/ProjetoBiblioteca-Python path: /projetoBiblioteca/Main.py import json import os.path import Biblioteca from reportlab.pdfgen import canvas # Grupo: Eduardo José Pereira de Sena # André Luis Moreira da Silva Santos def main(): ##lOGIN DO SISTEMA - id = admin / sen...
code_fim
hard
{ "lang": "python", "repo": "eduardojpsena/ProjetoBiblioteca-Python", "path": "/projetoBiblioteca/Main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def complete_restore(self, text, args, start_index, end_index): if text: return [ command for command in self.logger_manager.all() if command.startswith(text) ] else: return list(self.logger_manager.all...
code_fim
hard
{ "lang": "python", "repo": "P0cL4bs/wifipumpkin3", "path": "/wifipumpkin3/core/common/console.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: P0cL4bs/wifipumpkin3 path: /wifipumpkin3/core/common/console.py cos Bomfim (mh4x0f) # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LIC...
code_fim
hard
{ "lang": "python", "repo": "P0cL4bs/wifipumpkin3", "path": "/wifipumpkin3/core/common/console.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: P0cL4bs/wifipumpkin3 path: /wifipumpkin3/core/common/console.py http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eit...
code_fim
hard
{ "lang": "python", "repo": "P0cL4bs/wifipumpkin3", "path": "/wifipumpkin3/core/common/console.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pairs = [eval(p) for p in inp.splitlines() if p] pairs.append([[2]]) pairs.append([[6]]) pairs.sort(key=cmp_to_key(compare)) for i, p in enumerate(pairs): if p == [[2]]: part2 *= i + 1 if p == [[6]]: part2 *= i + 1 print("Part 1:", part1) ...
code_fim
medium
{ "lang": "python", "repo": "benediktwerner/AdventOfCode", "path": "/2022/day13/sol.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: benediktwerner/AdventOfCode path: /2022/day13/sol.py #!/usr/bin/env python3 from os import path from functools import cmp_to_key def compare(a, b): if type(a) == int: if type(b) == int: return (a > b) - (a < b) return compare([a], b) if type(b) == int: ...
code_fim
hard
{ "lang": "python", "repo": "benediktwerner/AdventOfCode", "path": "/2022/day13/sol.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> #print "TYPE:" + str(event.type) #print "CODE:" + str(event.code) #print "VALUE:" + str(event.value) # DIGITAL # SET KEY if event.type == 1 and event.code == ev and event.value == 1: ui.write(e.EV_KEY, keystroke, 1) ui.syn() # RELEASE KEY if event.type == 1 and event.code == ev and ...
code_fim
hard
{ "lang": "python", "repo": "tjschutte/RASPSWITCH", "path": "/Software/JoyCtrl.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> time.sleep(0.02) # Right controller handle_button(JR_BUTTON_A, e.KEY_Q) handle_button(JR_BUTTON_B, e.KEY_B) handle_button(JR_BUTTON_X, e.KEY_X) handle_button(JR_BUTTON_Y, e.KEY_Y) handle_button(JR_BUTTON_START,e.KEY_RIGHTALT) handle_button(JR_BUTTON_PLUS,e.KEY_ESC) ...
code_fim
hard
{ "lang": "python", "repo": "tjschutte/RASPSWITCH", "path": "/Software/JoyCtrl.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tjschutte/RASPSWITCH path: /Software/JoyCtrl.py #!/usr/bin/python import evdev import uinput import sys import signal import os import time import threading import RPi.GPIO as GPIO from evdev import UInput, ecodes as e # Set pinmode on Broadcom SOC. GPIO.setmode(GPIO.BCM) # disable warnings GPI...
code_fim
hard
{ "lang": "python", "repo": "tjschutte/RASPSWITCH", "path": "/Software/JoyCtrl.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pombredanne/GopherSnakeCrawlers path: /crawl.py #!/usr/bin/env python # monkey-patch import gevent.monkey gevent.monkey.patch_all() import sys import hashlib import re import requests from requests.exceptions import ConnectionError, MissingSchema import gevent.pool from gevent.queue import Join...
code_fim
hard
{ "lang": "python", "repo": "pombredanne/GopherSnakeCrawlers", "path": "/crawl.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while True: item = q.get() try: do_work(item, crawler_id) finally: q.task_done() #Spawning worker threads. crawler_id = 0 for i in range(num_worker_threads): gevent.spawn(worker, crawler_id) crawler_id += 1 q.put(source) links_added += 1 q.jo...
code_fim
hard
{ "lang": "python", "repo": "pombredanne/GopherSnakeCrawlers", "path": "/crawl.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m = hashlib.md5() m.update(response_content) m.digest() #Extract the links and add them to the queue. Using links_added #counter to limit the number of links to fetch. for link in re.findall('<a href="(http.*?)"', response_content): if links_added < num_to_crawl: ...
code_fim
medium
{ "lang": "python", "repo": "pombredanne/GopherSnakeCrawlers", "path": "/crawl.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: otakesh/training-golang path: /sharedbuild/buildshare/client.py from ctypes import POINTER, c_longlong, c_double, c_int, c_void_p, c_char_p, cdll, Structure, CFUNCTYPE, POINTER, sizeof, CDLL import logging log = logging.getLogger(__name__) lib = cdll.LoadLibrary("./awesome.so") # https://medium....
code_fim
hard
{ "lang": "python", "repo": "otakesh/training-golang", "path": "/sharedbuild/buildshare/client.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _fields_ = [("p", c_char_p), ("n", c_longlong)] lib.Log.argtypes = [GoString] msg = GoString(b"Morning Python!", 15) print(lib.Log(msg)) msg = GoString(b"Hello Python!", 13) print(lib.Log(msg)) msg = GoString(b"See you!", 8) print(lib.Log(msg))<|fim_prefix|># repo: otakesh/training-golang path: /sh...
code_fim
hard
{ "lang": "python", "repo": "otakesh/training-golang", "path": "/sharedbuild/buildshare/client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class GoString(Structure): _fields_ = [("p", c_char_p), ("n", c_longlong)] lib.Log.argtypes = [GoString] msg = GoString(b"Morning Python!", 15) print(lib.Log(msg)) msg = GoString(b"Hello Python!", 13) print(lib.Log(msg)) msg = GoString(b"See you!", 8) print(lib.Log(msg))<|fim_prefix|># repo: otakesh...
code_fim
hard
{ "lang": "python", "repo": "otakesh/training-golang", "path": "/sharedbuild/buildshare/client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> parser.add_argument('-q', '--quality', help='quality of a video. Default is 720', choices=['360', '720', '1080'], default='720') parser.add_argument('-o', '--output_dir', help='output directory. Defaul...
code_fim
hard
{ "lang": "python", "repo": "StepicOrg/Stepik-API", "path": "/examples/videos_downloader.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Check a video quality. for url in video_step['video']['urls']: if url['quality'] == args.quality: video_link = url['url'] # If the is no required video quality then download # with the best available quality. ...
code_fim
hard
{ "lang": "python", "repo": "StepicOrg/Stepik-API", "path": "/examples/videos_downloader.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: StepicOrg/Stepik-API path: /examples/videos_downloader.py # 1. Go to https://stepik.org/oauth2/applications/ # # 2. Register your application with settings: # Client type: confidential # Authorization Grant Type: client-credentials # # 3. Install requests module # > pip install requests ...
code_fim
hard
{ "lang": "python", "repo": "StepicOrg/Stepik-API", "path": "/examples/videos_downloader.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chinganc/librl path: /rl/algorithms/__init__.py from rl.algorithms.algorithm import Al<|fim_suffix|>olicyGradient from rl.algorithms.pepg import ParameterExploringPolicyGradient<|fim_middle|>gorithm from rl.algorithms.pg import P
code_fim
easy
{ "lang": "python", "repo": "chinganc/librl", "path": "/rl/algorithms/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>import ParameterExploringPolicyGradient<|fim_prefix|># repo: chinganc/librl path: /rl/algorithms/__init__.py from rl.algorithms.algorithm import Algorithm from rl.algorithms.pg import P<|fim_middle|>olicyGradient from rl.algorithms.pepg
code_fim
easy
{ "lang": "python", "repo": "chinganc/librl", "path": "/rl/algorithms/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pythonyhd/finace path: /land_china/land_china/spiders/exprs.py # -*- coding: utf-8 -*- xpath_list = [ { "name": "行政区:", 'key': "region", "expr": ["//div[@id='p1']//td/span[contains(text(),'行政区:')]/parent::td/following-sibling::td[1]/span/text()", "//s...
code_fim
hard
{ "lang": "python", "repo": "pythonyhd/finace", "path": "/land_china/land_china/spiders/exprs.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>td[1]/span/text()", "//span[@id='mainModuleContainer_1855_1856_ctl00_ctl00_p1_f1_r22_c2_ctrl']/text()"] }, { "name": "约定竣工时间:", "key": "appointed_achieve_date", "expr": ["//div[@id='p1']//td/span[contains(text(),'约定竣工时间:')]/parent::td/following-sibling::td[...
code_fim
hard
{ "lang": "python", "repo": "pythonyhd/finace", "path": "/land_china/land_china/spiders/exprs.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cgoldberg/pywt path: /demo/wp_visualize_coeffs_distribution.py #!/usr/bin/env python # -*- coding: utf-8 -*- import os import numpy as np import matplotlib.pyplot as plt from pywt import WaveletPacket import pywt.data <|fim_suffix|>for level in range(1, wp.maxlevel + 1): ax = fig.add_sub...
code_fim
hard
{ "lang": "python", "repo": "cgoldberg/pywt", "path": "/demo/wp_visualize_coeffs_distribution.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ecg = pywt.data.ecg() wp = WaveletPacket(ecg, 'sym5', maxlevel=4) fig = plt.figure() plt.set_cmap('bone') ax = fig.add_subplot(wp.maxlevel + 1, 1, 1) ax.plot(ecg, 'k') ax.set_xlim(0, len(ecg) - 1) ax.set_title("Wavelet packet coefficients") for level in range(1, wp.maxlevel + 1): ax = fig.add_subp...
code_fim
medium
{ "lang": "python", "repo": "cgoldberg/pywt", "path": "/demo/wp_visualize_coeffs_distribution.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def part_2(self): return get_same_boxes_common_characters(self.items) main = Solution.main if __name__ == "__main__": # pragma: no cover main()<|fim_prefix|># repo: EpicWink/advent-of-code-solutions path: /solutions_2018/day2.py """Day 2 solution. https://adventofcode.com/2018/day/2 "...
code_fim
medium
{ "lang": "python", "repo": "EpicWink/advent-of-code-solutions", "path": "/solutions_2018/day2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: EpicWink/advent-of-code-solutions path: /solutions_2018/day2.py """Day 2 solution. https://adventofcode.com/2018/day/2 """ import logging as lg import _common _logger = lg.getLogger(__name__) def compute_checksum(words): # TODO: document counts2 = 0 counts3 = 0 for word in word...
code_fim
medium
{ "lang": "python", "repo": "EpicWink/advent-of-code-solutions", "path": "/solutions_2018/day2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def part_1(self): return compute_checksum(self.items) def part_2(self): return get_same_boxes_common_characters(self.items) main = Solution.main if __name__ == "__main__": # pragma: no cover main()<|fim_prefix|># repo: EpicWink/advent-of-code-solutions path: /solutions_201...
code_fim
hard
{ "lang": "python", "repo": "EpicWink/advent-of-code-solutions", "path": "/solutions_2018/day2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ydf0509/distributed_framework path: /function_scheduling_distributed_framework/consumers/redis_stream_consumer.py # -*- coding: utf-8 -*- # @Author : ydf # @Time : 2021/4/3 0008 13:32 import json import redis3 from function_scheduling_distributed_framework.consumers.base_consumer import Abstr...
code_fim
hard
{ "lang": "python", "repo": "ydf0509/distributed_framework", "path": "/function_scheduling_distributed_framework/consumers/redis_stream_consumer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # self.redis_db_frame_version3.xack(self._queue_name, 'distributed_frame_group', kw['msg_id']) # self.redis_db_frame_version3.xdel(self._queue_name, kw['msg_id']) # 便于xlen with self.redis_db_frame_version3.pipeline() as pipe: pipe.xack(self._queue_name, self.GROUP, kw['...
code_fim
hard
{ "lang": "python", "repo": "ydf0509/distributed_framework", "path": "/function_scheduling_distributed_framework/consumers/redis_stream_consumer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> lock_key = f'fsdf_lock__requeue_tasks_which_unconfirmed:{self._queue_name}' with decorators.RedisDistributedLockContextManager(self.redis_db_frame, lock_key, ) as lock: if lock.has_aquire_lock: self._distributed_consumer_statistics.send_heartbeat() ...
code_fim
hard
{ "lang": "python", "repo": "ydf0509/distributed_framework", "path": "/function_scheduling_distributed_framework/consumers/redis_stream_consumer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> '''To define the agent's 1-step behavior given the `game`. You can find more instance in [`agents.py`](game2048/agents.py). :return direction: 0: left, 1: down, 2: right, 3: up ''' direction = np.random.randint(0, 10) if direction<3: direction=0 elif...
code_fim
medium
{ "lang": "python", "repo": "dotafreshman/2048-api", "path": "/game2048/myAgent.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: dotafreshman/2048-api path: /game2048/myAgent.py import numpy as np from game2048.agents import Agent class myOwnAgent(Agent): <|fim_suffix|> '''To define the agent's 1-step behavior given the `game`. You can find more instance in [`agents.py`](game2048/agents.py). ...
code_fim
medium
{ "lang": "python", "repo": "dotafreshman/2048-api", "path": "/game2048/myAgent.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Code Below Loop Through A list for word in linelist: # Code Below Determine If A Element In A List Is Equal To "#" Character if word[0] == '#': # Code Below Adds Argument As A Single Element To The End Of A List list_of_hashtags.app...
code_fim
hard
{ "lang": "python", "repo": "Mangalis0/singularityteam10", "path": "/powermetrics/powermetrics.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Mangalis0/singularityteam10 path: /powermetrics/powermetrics.py import numpy as np import pandas as pd # FUNCTION 1 def dictionary_of_metrics(items): """ This function calculates the mean, median, variance, standard deviation, minimum and maximum of list, items, which contains ...
code_fim
hard
{ "lang": "python", "repo": "Mangalis0/singularityteam10", "path": "/powermetrics/powermetrics.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: recski/semantic_parsing_szte_bme path: /nli_baselines/Peter/Baseline_3.py import spacy import jsonlines nlp=spacy.load('en') def pair_avg(sent1,sent2): doc=nlp(sent1) docx=nlp(sent2) simple2=[] simple1=[] for token in docx: if token.is_stop==False: simple2.appen...
code_fim
hard
{ "lang": "python", "repo": "recski/semantic_parsing_szte_bme", "path": "/nli_baselines/Peter/Baseline_3.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> TPC=True_Hit_Contradiction FPC=Judged_Contradiction_When_Entailment+Judged_Contradiction_When_Neutral TNC=all-FPC-TPC-Judged_Entailment_When_Contradiction-Judged_Neutral_When_Contradiction FNC=Judged_Entailment_When_Contradiction+Judged_Neutral_When_Contradiction CPrec=TPC/(TPC+FPC) ...
code_fim
hard
{ "lang": "python", "repo": "recski/semantic_parsing_szte_bme", "path": "/nli_baselines/Peter/Baseline_3.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> except (KeyError, TypeError): logger.warning("No fqdn for %s returning None" % interface["ipv4"]) if fqdn_list and len(fqdn_list) > 1: raise AttributeError("Should be only one: %s" % fqdn_list) return fqdn_list[0] if fqdn_list else None<|fim_prefix|># repo: JulienBalestra/enjo...
code_fim
hard
{ "lang": "python", "repo": "JulienBalestra/enjoliver", "path": "/app/tools.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ A discovery machine give a FQDN. This method will do the resolution before insert in the db :param interface: :return: """ fqdn_list = [] try: for name in interface["fqdn"]: if EC.discovery_fqdn_verify is False: logger.warning("Adding a n...
code_fim
hard
{ "lang": "python", "repo": "JulienBalestra/enjoliver", "path": "/app/tools.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: JulienBalestra/enjoliver path: /app/tools.py import logging import socket import time from configs import EnjoliverConfig logger = logging.getLogger(__file__) EC = EnjoliverConfig() def get_mac_from_raw_query(request_raw_query: str): """ Get MAC address inside a matchbox "request raw...
code_fim
hard
{ "lang": "python", "repo": "JulienBalestra/enjoliver", "path": "/app/tools.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@client.event async def on_command_error(message, error): if isinstance(error, commands.CommandNotFound): await message.send(f'{message.author.mention} Invalid command, please try again.') elif isinstance(error, commands.MissingRequiredArgument): await message.send(f'{message.autho...
code_fim
hard
{ "lang": "python", "repo": "Andrewvlad/planetside_elo", "path": "/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Andrewvlad/planetside_elo path: /main.py import os import discord from discord.ext import commands from discord.utils import get from decouple import config import database_setup database_setup.setup_db() client = commands.Bot(command_prefix='!') client.remove_command('help') # TODO: def playe...
code_fim
hard
{ "lang": "python", "repo": "Andrewvlad/planetside_elo", "path": "/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: openmc-dev/openmc path: /tests/unit_tests/test_deplete_microxs.py """Basic unit tests for openmc.deplete.IndependentOperator instantiation Modifies and resets environment variable OPENMC_CROSS_SECTIONS to a custom file with new depletion_chain node """ from os import remove from pathlib import ...
code_fim
hard
{ "lang": "python", "repo": "openmc-dev/openmc", "path": "/tests/unit_tests/test_deplete_microxs.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_csv(): ref_xs = MicroXS.from_csv(ONE_GROUP_XS) ref_xs.to_csv('temp_xs.csv') temp_xs = MicroXS.from_csv('temp_xs.csv') assert np.all(ref_xs.data == temp_xs.data) remove('temp_xs.csv')<|fim_prefix|># repo: openmc-dev/openmc path: /tests/unit_tests/test_deplete_microxs.py """Bas...
code_fim
hard
{ "lang": "python", "repo": "openmc-dev/openmc", "path": "/tests/unit_tests/test_deplete_microxs.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: texervn/im2latex-5 path: /api_server/streamlit_app.py import base64 import socket import subprocess from time import sleep import requests import streamlit as st API_HOST = "0.0.0.0" API_PORT = 60000 API_BASE_URL = f"http://{API_HOST}:{API_PORT}" API_PREDICT_URL = f"{API_BASE_URL}/v1/predict" ...
code_fim
hard
{ "lang": "python", "repo": "texervn/im2latex-5", "path": "/api_server/streamlit_app.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not is_port_in_use(API_PORT): with st.spinner("Starting the API..."): print("Starting the API") cmd = ["uvicorn", "api_server.main:app", "--host", f"{API_HOST}", "--port", f"{API_PORT}"] subprocess.Popen(cmd, close_fds=True) sleep(5) def mai...
code_fim
medium
{ "lang": "python", "repo": "texervn/im2latex-5", "path": "/api_server/streamlit_app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> st.title("Image to LaTeX") with st.form(key="imputs"): st.markdown("## Upload an Image") image = st.file_uploader("", type=["jpg", "png"]) st.form_submit_button(label="Upload") with st.form(key="outputs"): st.markdown("## Convert to LaTeX") st.text("Up...
code_fim
hard
{ "lang": "python", "repo": "texervn/im2latex-5", "path": "/api_server/streamlit_app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def print_card(self): pprint(vars(self))<|fim_prefix|># repo: ericschmar/hs-clock path: /preprocess/card.py import sys from pprint import pprint class card: def __init__(self, id=None, name=None, cost=None, attack=None, health=None, card_type=None): <|fim_middle|> self.id = id ...
code_fim
hard
{ "lang": "python", "repo": "ericschmar/hs-clock", "path": "/preprocess/card.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ericschmar/hs-clock path: /preprocess/card.py import sys from pprint import pprint class card: <|fim_suffix|> self.id = id self.name = ''.join(e for e in name if e.isalnum()) self.cost = cost self.attack = attack self.health = health self.card_type ...
code_fim
medium
{ "lang": "python", "repo": "ericschmar/hs-clock", "path": "/preprocess/card.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: google/telluride_decoding path: /telluride_decoding/preprocess.py A list containing a list(s) of reference channels that correspond to the parallel lists in channels_to_ref. channels_to_ref: A list containing a list(s) of channels to be referenced that correspond to the parallel l...
code_fim
hard
{ "lang": "python", "repo": "google/telluride_decoding", "path": "/telluride_decoding/preprocess.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: google/telluride_decoding path: /telluride_decoding/preprocess.py lowpass_cutoff, 'lp', output='sos', fs=self.fs_in) self._lowpass_state = None # to be created later when we know sizes else: self._lowpass_sos = None def init_chann...
code_fim
hard
{ "lang": "python", "repo": "google/telluride_decoding", "path": "/telluride_decoding/preprocess.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Sample data using output indices data_out = np.zeros((frames_out, data.shape[1])) for i in range(frames_out): idx = min(frames_in - 1, idx_out[i]) data_out[i, :] = data[int(idx), :] else: # No resampling data_out = data return data_out def rere...
code_fim
hard
{ "lang": "python", "repo": "google/telluride_decoding", "path": "/telluride_decoding/preprocess.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> try: return func(self, *args, **kwargs) except Exception as e: logger.exception('Error %s', e) return error_func(e) return wrapper return _error_response<|fim_prefix|># repo: ojos/python-library path: /ojosjp/decorator.py...
code_fim
hard
{ "lang": "python", "repo": "ojos/python-library", "path": "/ojosjp/decorator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ojos/python-library path: /ojosjp/decorator.py # -*- coding: utf-8 -*- from __future__ import division, print_function, absolute_import, unicode_literals import time from logging import getLogger <|fim_suffix|>def retry_handler(tries_remaining, exception, delay): logger.warning("Caught '%s...
code_fim
hard
{ "lang": "python", "repo": "ojos/python-library", "path": "/ojosjp/decorator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gaoyuanning/index_selection_evaluation path: /tests/test_candidate_generation.py import unittest from unittest.mock import MagicMock from selection.candidate_generation import ( candidates_per_query, syntactically_relevant_indexes, ) from selection.index import Index from selection.workl...
code_fim
hard
{ "lang": "python", "repo": "gaoyuanning/index_selection_evaluation", "path": "/tests/test_candidate_generation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> syntactically_relevant_indexes_mock = MagicMock( return_value=syntactically_relevant_indexes ) result = candidates_per_query( workload, max_index_width=MAX_INDEX_WIDTH, candidate_generator=syntactically_relevant_indexes_mock, ...
code_fim
medium
{ "lang": "python", "repo": "gaoyuanning/index_selection_evaluation", "path": "/tests/test_candidate_generation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: he159ok/bert_crf path: /bert-crf4NER/test_seqeval.py from seqeval.metrics import accuracy_score from seqeval.metrics import classification_report from seqeval.metrics import f1_score # from seqeval.scheme import IOB2 # y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-P...
code_fim
medium
{ "lang": "python", "repo": "he159ok/bert_crf", "path": "/bert-crf4NER/test_seqeval.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>print(f1) print(de) from seqeval.scheme import IOB2 st = classification_report(y_true, y_pred, mode='strict', scheme=IOB2) print(st)<|fim_prefix|># repo: he159ok/bert_crf path: /bert-crf4NER/test_seqeval.py from seqeval.metrics import accuracy_score from seqeval.metrics import classification_report from...
code_fim
medium
{ "lang": "python", "repo": "he159ok/bert_crf", "path": "/bert-crf4NER/test_seqeval.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: elsid/master path: /src/match_pattern/java_source_parser/test/model.py # coding: utf-8 from os.path import dirname, join from hamcrest import assert_that, equal_to, empty from unittest import main from utils import cached_method from pattern_matcher import ( Model, Operation, Type, Primitive...
code_fim
hard
{ "lang": "python", "repo": "elsid/master", "path": "/src/match_pattern/java_source_parser/test/model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Class('ConcreteDecorator', operations=[ Operation('operation', self.VOID, Visibility.PUBLIC, is_static=False), ]) @cached_method def create(self): base = super(Decorator, self).create() return Model(list(base.classifiers) + ...
code_fim
hard
{ "lang": "python", "repo": "elsid/master", "path": "/src/match_pattern/java_source_parser/test/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # don't commit pack_metadata.json if already exists in the branch if file_exists and content_file.file_name == 'pack_metadata.json': return response = demisto.executeCommand('azure-devops-branch-list', args={}) branches_list = response[0].get("Contents", {}).get("value", []) if res...
code_fim
hard
{ "lang": "python", "repo": "demisto/content", "path": "/Packs/ContentManagement/Scripts/CommitFiles/CommitFiles.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: demisto/content path: /Packs/ContentManagement/Scripts/CommitFiles/CommitFiles.py from pathlib import Path import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import os import io from os.path import exists from contextlib import redirect_stderr, redirect_s...
code_fim
hard
{ "lang": "python", "repo": "demisto/content", "path": "/Packs/ContentManagement/Scripts/CommitFiles/CommitFiles.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def searched_file_path(branch_name: str, content_file: ContentFile) -> bool: full_path = Path(content_file.path_to_file, content_file.file_name) if str(full_path) in files_path: # the files list, check if the file already exists in the list return True # try to get the file from bran...
code_fim
hard
{ "lang": "python", "repo": "demisto/content", "path": "/Packs/ContentManagement/Scripts/CommitFiles/CommitFiles.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def run(self): logging.header('File ' + self._extension + ' handled by ' + self._handler) file_handler_tool = self.__class__.file_handler_tool() if file_handler_tool == FiletypeHandlerType.DUTI: return Run(['duti', '-s', self._handler, self._extension, 'all']).run()...
code_fim
medium
{ "lang": "python", "repo": "acoomans/prvsn", "path": "/prvsnlib/tasks/filetype.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> logging.header('File ' + self._extension + ' handled by ' + self._handler) file_handler_tool = self.__class__.file_handler_tool() if file_handler_tool == FiletypeHandlerType.DUTI: return Run(['duti', '-s', self._handler, self._extension, 'all']).run() raise Exce...
code_fim
medium
{ "lang": "python", "repo": "acoomans/prvsn", "path": "/prvsnlib/tasks/filetype.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: acoomans/prvsn path: /prvsnlib/tasks/filetype.py import logging import subprocess from prvsnlib.utils.run import Run class FiletypeHandlerType: DUTI = 'duti' <|fim_suffix|> @classmethod def file_handler_tool(cls, *args, **kwargs): if not cls._file_handler_tool: ...
code_fim
medium
{ "lang": "python", "repo": "acoomans/prvsn", "path": "/prvsnlib/tasks/filetype.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: jasarsoft/examples path: /python/us-opp/poglavlje10/primjer04.py """ Program koji razlicita slova broji u tkestualnom fajlu i prikazuje rezultat. Broja se samo slova is ASCII podskupa bez obzira da li su velika ili mala. """ #brojanje razlicitih slova u sturngu (ASCII podskup) def b...
code_fim
medium
{ "lang": "python", "repo": "jasarsoft/examples", "path": "/python/us-opp/poglavlje10/primjer04.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for linija in infile: #poziv funkcije brojacSlova za svaku liniju brojacSlova(linija.lower(), brojac) #prikaz rezultata for i in range(len(brojac)): if brojac[i] != 0: print(chr(ord("a") + i) + " se pojavljuje " + str(brojac[i]) + (" put " if brojac[i] == 1...
code_fim
medium
{ "lang": "python", "repo": "jasarsoft/examples", "path": "/python/us-opp/poglavlje10/primjer04.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>brojac = 26 * [0] #inicijalizacija brojaca slova for linija in infile: #poziv funkcije brojacSlova za svaku liniju brojacSlova(linija.lower(), brojac) #prikaz rezultata for i in range(len(brojac)): if brojac[i] != 0: print(chr(ord("a") + i) + " se pojavljuje " + str(bro...
code_fim
hard
{ "lang": "python", "repo": "jasarsoft/examples", "path": "/python/us-opp/poglavlje10/primjer04.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hat27/puzzle path: /tests/maya/test_puzzle.py import os import sys import unittest import maya.standalone maya.standalone.initialize() import maya.cmds as cmds MODULE_PATH = os.environ.get("PUZZLE_REPO_PATH") if MODULE_PATH: sys.path.append(MODULE_PATH) PIECES_PATH = os.environ.get("PUZZL...
code_fim
hard
{ "lang": "python", "repo": "hat27/puzzle", "path": "/tests/maya/test_puzzle.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertEqual(cmds.objExists("a"), True) self.assertEqual(cmds.objExists("b"), True) self.assertEqual(cmds.objExists("c"), True) self.assertEqual(cmds.getAttr("a.tx"), 10) self.assertEqual(cmds.getAttr("b.ty"), 10) self.assertEqual(cmds.getAttr("c.tz"), 10) c...
code_fim
hard
{ "lang": "python", "repo": "hat27/puzzle", "path": "/tests/maya/test_puzzle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if vis_variant.get('save_video_exp_policy', False): filename = osp.join(logdir, 'video_{epoch}_exp.mp4'.format(epoch=epoch)) dump_video(image_env, algo.exploration_policy, filename, rollout_function, **dump_video_kwargs...
code_fim
hard
{ "lang": "python", "repo": "wuyx/LeapPaper", "path": "/leap/railrl/launchers/rl_exp_launcher_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert NotImplementedError def get_envs(variant): from multiworld.core.image_env import ImageEnv from railrl.envs.vae_wrappers import VAEWrappedEnv from railrl.misc.asset_loader import load_local_or_remote_file render = variant.get('render', False) vae_path = variant.get("vae_pat...
code_fim
hard
{ "lang": "python", "repo": "wuyx/LeapPaper", "path": "/leap/railrl/launchers/rl_exp_launcher_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wuyx/LeapPaper path: /leap/railrl/launchers/rl_exp_launcher_util.py ) her_kwargs = algo_kwargs['her_kwargs'] her_kwargs['observation_key'] = observation_key her_kwargs['desired_goal_key'] = desired_goal_key algorithm = HerTd3( env, qf1=qf1, qf2=qf2, ...
code_fim
hard
{ "lang": "python", "repo": "wuyx/LeapPaper", "path": "/leap/railrl/launchers/rl_exp_launcher_util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rfrowe/cse547 path: /src/scripts/data/standardize.py #!/usr/bin/env python3 """ standardize an existing dataset. """ from typing import List from scipy import ndimage from tqdm import tqdm import utils.utility as _util import utils.cmd_line as _cmd import data.dataset as _dataset import numpy...
code_fim
hard
{ "lang": "python", "repo": "rfrowe/cse547", "path": "/src/scripts/data/standardize.py", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|>def _get_standardized_name(dataset): standardized_name = "{}_standardized".format(dataset) return standardized_name def main(): args = _cmd.parse_args_for_callable(standardize) varsArgs = vars(args) verbosity = varsArgs.pop('verbosity', _util.DEFAULT_VERBOSITY) _logger.info("Pass...
code_fim
hard
{ "lang": "python", "repo": "rfrowe/cse547", "path": "/src/scripts/data/standardize.py", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|># repo: gugarosa/opytimizer path: /examples/applications/single_objective/discrete_optimization.py import numpy as np from opytimark.markers.n_dimensional import Sphere from opytimizer import Opytimizer from opytimizer.core import Function from opytimizer.optimizers.swarm import PSO from opytimizer.spac...
code_fim
hard
{ "lang": "python", "repo": "gugarosa/opytimizer", "path": "/examples/applications/single_objective/discrete_optimization.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Bundles every piece into Opytimizer class opt = Opytimizer(space, optimizer, function, save_agents=False) # Runs the optimization task opt.start( n_iterations=5, callbacks=[DiscreteSearchCallback(allowed_values=allowed_values)] )<|fim_prefix|># repo: gugarosa/opytimizer path: /examples/applicatio...
code_fim
hard
{ "lang": "python", "repo": "gugarosa/opytimizer", "path": "/examples/applications/single_objective/discrete_optimization.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># on_starting is a gunicorn-specific server hook def on_starting(server): start_archiver_thread()<|fim_prefix|># repo: postmates/prometheus_client_python path: /prometheus_client/multiprocess_exporter.py import logging from .vendor import six if six.PY3: import _thread as thread_module else: ...
code_fim
medium
{ "lang": "python", "repo": "postmates/prometheus_client_python", "path": "/prometheus_client/multiprocess_exporter.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: postmates/prometheus_client_python path: /prometheus_client/multiprocess_exporter.py import logging from .vendor import six if six.PY3: import _thread as thread_module else: import thread as thread_module import time import traceback <|fim_suffix|>def archive_thread(): while True: ...
code_fim
hard
{ "lang": "python", "repo": "postmates/prometheus_client_python", "path": "/prometheus_client/multiprocess_exporter.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Thermodynamic fields ys = [] ys.append(rho_bin[:, 1:kp_end]) ys.append(np.tile(kpbin[1:kp_end], (nt, 1))**(-5./3.)/kpbin[1]*np.tile(rho_bin[:,1], (kp_end-1, 1)).T) ys.append(np.tile(kpbin[1:kp_end], (nt, 1))**(-3./2.)/kpbin[1]*np.tile(rho_bin[:,1], (kp_end-1, 1)).T) ys = np.transpose(ys, (1,...
code_fim
hard
{ "lang": "python", "repo": "ykawazura/calliope", "path": "/diagnostics/MHD_COMP_ISOTH/plot_kspectrum.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ykawazura/calliope path: /diagnostics/MHD_COMP_ISOTH/plot_kspectrum.py # -*- coding: utf-8 -*- from load import * from fft import * from plots import * print('\nplotting kspectrum\n') outdir = './fig_kspectrum/' if nlz == nkz: kp_end = np.argmin(np.abs(kpbin - kpbin.max()*2./3.)) else: kp_e...
code_fim
hard
{ "lang": "python", "repo": "ykawazura/calliope", "path": "/diagnostics/MHD_COMP_ISOTH/plot_kspectrum.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Gets a URL that refers to this file def static_url(path: str): return urllib.parse.urljoin(STATIC_SERVER, path.replace(STATIC_DIR, ''))<|fim_prefix|># repo: guansss/christina path: /christina/net/static.py import os import urllib.parse from pathlib import Path STATIC_SERVER = os.environ['STATIC_S...
code_fim
easy
{ "lang": "python", "repo": "guansss/christina", "path": "/christina/net/static.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: guansss/christina path: /christina/net/static.py import os import urllib.parse from pathlib import Path <|fim_suffix|> return str(STATIC_DIR_PATH.joinpath(*path)) # Gets a URL that refers to this file def static_url(path: str): return urllib.parse.urljoin(STATIC_SERVER, path.replace(STA...
code_fim
hard
{ "lang": "python", "repo": "guansss/christina", "path": "/christina/net/static.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Gets an absolute path where this file should be saved def static_file(*path: str): return str(STATIC_DIR_PATH.joinpath(*path)) # Gets a URL that refers to this file def static_url(path: str): return urllib.parse.urljoin(STATIC_SERVER, path.replace(STATIC_DIR, ''))<|fim_prefix|># repo: guansss/...
code_fim
medium
{ "lang": "python", "repo": "guansss/christina", "path": "/christina/net/static.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Summarize the new activity on the console. def notify_user(threads): print('New messages in {} threads'.format(len(threads))) for t in threads: print('{subject} from {guest}'.format(**t)) def main(): client = lh3.api.Client() mailboxes = [m['id'] for m in client.all('emails').ge...
code_fim
medium
{ "lang": "python", "repo": "GeorgetownMakerHubOrg/libraryh3lpListener", "path": "/libraryh3lp-sdk-python/examples/biff.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: GeorgetownMakerHubOrg/libraryh3lpListener path: /libraryh3lp-sdk-python/examples/biff.py #!/usr/bin/env python # biff.py # ------- # Poll 3mail for new messages and send notifications to the terminal. # See https://www.freebsd.org/cgi/man.cgi?query=biff # # Usage: ./biff.py & from datetime impo...
code_fim
hard
{ "lang": "python", "repo": "GeorgetownMakerHubOrg/libraryh3lpListener", "path": "/libraryh3lp-sdk-python/examples/biff.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Xiangs18/lstm-language-model path: /preprocess.py import torch import argparse import data def preprocess(opt): print("Begin preprocessing") train_dataset = data.DataSet(opt.train_data, display_freq=opt.display_freq) train_dataset.max_dict = opt.dict_size train_dataset.build_di...
code_fim
hard
{ "lang": "python", "repo": "Xiangs18/lstm-language-model", "path": "/preprocess.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": parser = argparse.ArgumentParser("Preprocessing") parser.add_argument( "--train_data", type=str, default="data/penn/train.txt", help="Training data path", ) parser.add_argument( "--val_data", type=str, de...
code_fim
medium
{ "lang": "python", "repo": "Xiangs18/lstm-language-model", "path": "/preprocess.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }