text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> style = None if ref is not None: try: cell = self.oldsheet.cell(ref, c) style = self.book.style_list[cell.xf_index] except: #print 'fallback failed' style = None if not style: try:...
code_fim
hard
{ "lang": "python", "repo": "shaung/xlpy", "path": "/xlpy/xlutils/cne.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mators11/SudokuSolver path: /sudokusolver/common.py #!/usr/bin/env python # encoding: utf-8 def from_vals(vals): if not vals: #Unsolved return False sudoku = [] for i in range(9): line = [] for j in range(9): line.append(int(vals[str(chr(ord('A') ...
code_fim
hard
{ "lang": "python", "repo": "mators11/SudokuSolver", "path": "/sudokusolver/common.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return to_grid(from_vals(vals)) def to_str_vals(vals): return to_str(from_vals(vals)) def to_str(sudoku): if sudoku == False: return 'Unsolved' out = '' for i in range(9): for j in range(9): out = out + str(sudoku[i][j]) out = out + ' ' ...
code_fim
hard
{ "lang": "python", "repo": "mators11/SudokuSolver", "path": "/sudokusolver/common.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """CText_Importer.import_from_string.""" c = self.c root = parent.copy() ft = c.importCommands.fileType.lower() cchar = ( '#' if g.unitTesting else '%' if ft == '.sql' else '-' if ft == '.sql' else '/' if ft == '.js' e...
code_fim
hard
{ "lang": "python", "repo": "leo-editor/leo-editor", "path": "/leo/plugins/importers/ctext.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: leo-editor/leo-editor path: /leo/plugins/importers/ctext.py #@+leo-ver=5-thin #@+node:tbrown.20140801105909.47549: * @file ../plugins/importers/ctext.py from __future__ import annotations import re from typing import TYPE_CHECKING from leo.core import leoGlobals as g # Required from leo.plugins....
code_fim
hard
{ "lang": "python", "repo": "leo-editor/leo-editor", "path": "/leo/plugins/importers/ctext.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> This would be the text in this level one node. And this. ### Another level one node ############################### Another one #### A level 2 node ###################################### See what we did there - one more '#' - this is a subnode. Lea...
code_fim
hard
{ "lang": "python", "repo": "leo-editor/leo-editor", "path": "/leo/plugins/importers/ctext.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: li5ch/Python-Notes path: /gevent_notes/gevent_tests.py import time import threading from threading import Thread, Event <|fim_suffix|>event = Event() t = Thread(target=worker, args=(event,)) t.start()<|fim_middle|>def worker(event_obj): i=3 while i: localtime = time.asctime(time...
code_fim
hard
{ "lang": "python", "repo": "li5ch/Python-Notes", "path": "/gevent_notes/gevent_tests.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>event = Event() t = Thread(target=worker, args=(event,)) t.start()<|fim_prefix|># repo: li5ch/Python-Notes path: /gevent_notes/gevent_tests.py import time import threading from threading import Thread, Event def worker(event_obj): <|fim_middle|> i=3 while i: localtime = time.asctime(time...
code_fim
hard
{ "lang": "python", "repo": "li5ch/Python-Notes", "path": "/gevent_notes/gevent_tests.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tcp_flags = TCPControlBits(['SYN', 'ACK']) assert_is_instance(tcp_flags.to_str(), str) def test_should_return_a_integer(self): """ Should return an int from the informed tcp flags """ tcp_flags = TCPControlBits(['SYN', 'ACK']) assert_is_instance(tcp_flags.to_i...
code_fim
hard
{ "lang": "python", "repo": "globocom/GloboNetworkAPI", "path": "/networkapi/plugins/SDN/ODL/tests/test_tcp_control_bits.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Should return a hex from the informed tcp flags """ tcp_flags = TCPControlBits(['SYN', 'ACK']) assert_is_instance(tcp_flags.to_hex(), str) def test_should_return_the_correct_hexadecimal(self): """ Should return the correct Hexadecimal from tcp flags """ t...
code_fim
hard
{ "lang": "python", "repo": "globocom/GloboNetworkAPI", "path": "/networkapi/plugins/SDN/ODL/tests/test_tcp_control_bits.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: globocom/GloboNetworkAPI path: /networkapi/plugins/SDN/ODL/tests/test_tcp_control_bits.py # -*- coding: utf-8 -*- from nose.tools import assert_raises from nose.tools import assert_equal from nose.tools import assert_false from nose.tools import assert_is_instance from networkapi.test.test_case...
code_fim
hard
{ "lang": "python", "repo": "globocom/GloboNetworkAPI", "path": "/networkapi/plugins/SDN/ODL/tests/test_tcp_control_bits.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E6%B7%B1%E5%9C%B3&needAddtionalResult=false' # 先设定获取页数为1,获取总的职位数 page_1 = get_json(url, 1) total_count = page_1['content']['positionResult']['totalCount'] num = get_page_num(total_count) total_info = [] time.sleep(5) ...
code_fim
hard
{ "lang": "python", "repo": "MisterZhouZhou/python3demo", "path": "/demo/lagou.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def main(): url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E6%B7%B1%E5%9C%B3&needAddtionalResult=false' # 先设定获取页数为1,获取总的职位数 page_1 = get_json(url, 1) total_count = page_1['content']['positionResult']['totalCount'] num = get_page_num(total_count) total_info = [] time....
code_fim
hard
{ "lang": "python", "repo": "MisterZhouZhou/python3demo", "path": "/demo/lagou.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: MisterZhouZhou/python3demo path: /demo/lagou.py import requests import math import time import pandas as pd def get_json(url,num): '''''从网页获取JSON,使用POST请求,加上头部信息''' my_headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chro...
code_fim
hard
{ "lang": "python", "repo": "MisterZhouZhou/python3demo", "path": "/demo/lagou.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> setup( name='logging2telegram', version='1.0.4', packages=['log2tg'], url='https://github.com/tezmen/loging2telegram', author='tezmen', license='Apache License, Version 2.0, see LICENSE file', description='Telegram logging handler', long_description=long_description(), long_description_content_t...
code_fim
hard
{ "lang": "python", "repo": "tezmen/logging2telegram", "path": "/setup.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: tezmen/logging2telegram path: /setup.py # -*- coding: utf-8 -*- from os import path from setuptools import setup def long_description(): this_dir = path.abspath(path.dirname(__file__)) with open(path.join(this_dir, 'README.md'), encoding='utf-8') as f: return f.read() <|fim_suffix|>setup(...
code_fim
hard
{ "lang": "python", "repo": "tezmen/logging2telegram", "path": "/setup.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hsingh23/courseflow path: /course/utils.py # -*- coding: utf-8 -*- from __future__ import division __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation...
code_fim
hard
{ "lang": "python", "repo": "hsingh23/courseflow", "path": "/course/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> from course.content import get_flow_page_desc self.page_desc = get_flow_page_desc( flow_session, self.flow_desc, page_data.group_id, page_data.page_id) self.page = instantiate_flow_page_with_ctx(self, page_data) from course.page import PageContext ...
code_fim
hard
{ "lang": "python", "repo": "hsingh23/courseflow", "path": "/course/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: amoghkokari/weighted path: /weighted.py def enmal(): adj=[] mat={} nod=[] stop = False print() no = int(input("Enter the number of vertices in the graph : ")) print() for i in range(no): print("Enter",i+1,"node ",e...
code_fim
hard
{ "lang": "python", "repo": "amoghkokari/weighted", "path": "/weighted.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> done = False while not done: try: print() print() print("1.Enter value manually ") print("2.Choose from the file ") print("3.Exit") print() ch = int(input("Enter your choice(1-3) ...
code_fim
hard
{ "lang": "python", "repo": "amoghkokari/weighted", "path": "/weighted.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> def _get_plant_facts(self): facts = [] for slot, plant in self._by_slot.items(): tuple_value = ",".join([str(self._arduino_slots.arduino_id), str(slot), str(plant["botanical_name"] ...
code_fim
hard
{ "lang": "python", "repo": "RACPlant/RACAP", "path": "/controller/plants.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: RACPlant/RACAP path: /controller/plants.py from controller.config import PLANTS_ENDPOINT from social.arduino import Slots import pandas as pd MAX_SLOTS = 10 class Plants: def __init__(self, arduino_slots: Slots): self._df = None self._arduino_slots = arduino_slots ...
code_fim
hard
{ "lang": "python", "repo": "RACPlant/RACAP", "path": "/controller/plants.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> training_data = training_data_list[head] # Define the VI inference technique, ie. minimise the KL divergence between q and p. inference = ed.KLqp({W_0: qW_0, W_1[head]: qW_1[head], b_0: qb_0, b_1[head]: qb_1[head]}, data={y[head]:y_ph}) # Initialise the inference...
code_fim
hard
{ "lang": "python", "repo": "jessegeerts/neural-nets", "path": "/bayesnets/split_bayes_proper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in range(inference.n_iter): X_batch, Y_batch = training_data.next_batch(batch_size,shuffle=False) info_dict = inference.update(feed_dict={x: X_batch, y_ph: Y_batch}) inference.print_progress(info_dict) def take_posterior_samples(n_samples,X_test,testhead,qW_0,qb_0,qW_1,q...
code_fim
hard
{ "lang": "python", "repo": "jessegeerts/neural-nets", "path": "/bayesnets/split_bayes_proper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jessegeerts/neural-nets path: /bayesnets/split_bayes_proper.py import matplotlib.pyplot as plt import numpy as np import seaborn as sns import tensorflow as tf from edward.models import Categorical, Normal import edward as ed import pandas as pd from tqdm import tqdm from mnist_loader import Trai...
code_fim
hard
{ "lang": "python", "repo": "jessegeerts/neural-nets", "path": "/bayesnets/split_bayes_proper.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: PyLabCo/pylab-crawler-sdk path: /pylab_crawler_sdk/__init__.py import requests BASE_URL = 'https://crawler.pylab.co' LOG_CRITICAL = 50 LOG_ERROR = 40 LOG_WARNING = 30 LOG_INFO = 20 LOG_DEBUG = 10 LOG_NOTSET = 0 class Session(object): def __init__(self, key, api_server=BASE_URL): t...
code_fim
hard
{ "lang": "python", "repo": "PyLabCo/pylab-crawler-sdk", "path": "/pylab_crawler_sdk/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def terminate_task(self, task_id) -> None: """태스크를 종료""" res = requests.post( f'{self.api_server}/api/sdk/task-terminations/?key={self.key}', data={ 'task': task_id } ) res.raise_for_status() def write_file(self, ...
code_fim
hard
{ "lang": "python", "repo": "PyLabCo/pylab-crawler-sdk", "path": "/pylab_crawler_sdk/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """태스크를 생성""" res = requests.post( f'{self.api_server}/api/sdk/tasks/?key={self.key}', data={ 'taskType': task_type_id } ) res.raise_for_status() task = res.json() return task['id'] def terminate_task(...
code_fim
hard
{ "lang": "python", "repo": "PyLabCo/pylab-crawler-sdk", "path": "/pylab_crawler_sdk/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: matthewhanson/modis-ingestor path: /test/test_main.py import os import unittest import datetime from dateutil.parser import parse from modispds.earthdata import query, download_granule import modispds.main as modis from modispds.pds import s3_list, del_from_s3 from modispds.products import produc...
code_fim
hard
{ "lang": "python", "repo": "matthewhanson/modis-ingestor", "path": "/test/test_main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_convert_to_geotiff(self): """ Convert hdf to individual GeoTIFF files """ fnames = modis.convert_to_geotiff(self.fnames[0], outdir=os.path.dirname(__file__)) for f in fnames: ext = os.path.splitext(f)[1] suffix = os.path.splitext(f)[0].split('_'...
code_fim
hard
{ "lang": "python", "repo": "matthewhanson/modis-ingestor", "path": "/test/test_main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Convert hdf to individual GeoTIFF files """ fnames = modis.convert_to_geotiff(self.fnames[0], outdir=os.path.dirname(__file__)) for f in fnames: ext = os.path.splitext(f)[1] suffix = os.path.splitext(f)[0].split('_')[1] self.assertTrue(os.pat...
code_fim
hard
{ "lang": "python", "repo": "matthewhanson/modis-ingestor", "path": "/test/test_main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def import_object(self): ret = MatModuleLevelDocumenter.import_object(self) # if the class is documented under another name, document it # as data/attribute if ret: if hasattr(self.object, "__name__"): self.doc_as_attr = self.objpath[-1...
code_fim
hard
{ "lang": "python", "repo": "sphinx-contrib/matlabdomain", "path": "/sphinxcontrib/mat_documenters.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def class_object(self): # the associated MatClass object return self.object.cls def auto_link_self(self, docstrings): name = self.object.name # negative look-behind for ` or . or < or * or <non-breaking space> # and negative look-ahead for <non-break...
code_fim
hard
{ "lang": "python", "repo": "sphinx-contrib/matlabdomain", "path": "/sphinxcontrib/mat_documenters.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: sphinx-contrib/matlabdomain path: /sphinxcontrib/mat_documenters.py docstrings[i][j], ) return docstrings def get_object_members(self, want_all): """Return `(members_check_module, members)` where `members` is a list of `(...
code_fim
hard
{ "lang": "python", "repo": "sphinx-contrib/matlabdomain", "path": "/sphinxcontrib/mat_documenters.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: GarrettSocling/Pushjet-Server-Api path: /controllers/subscription.py from flask import Blueprint, jsonify from utils import Error, has_service, has_uuid, queue_zmq_message from shared import db from models import Subscription from json import dumps as json_encode from config import zeromq_relay_u...
code_fim
medium
{ "lang": "python", "repo": "GarrettSocling/Pushjet-Server-Api", "path": "/controllers/subscription.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return jsonify({'service': service.as_dict()}) @subscription.route('/subscription', methods=['GET']) @has_uuid def subscription_get(client): subscriptions = Subscription.query.filter_by(device=client).all() return jsonify({'subscriptions': [_.as_dict() for _ in subscriptions]}) @subscripti...
code_fim
hard
{ "lang": "python", "repo": "GarrettSocling/Pushjet-Server-Api", "path": "/controllers/subscription.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> subscriptions = Subscription.query.filter_by(device=client).all() return jsonify({'subscriptions': [_.as_dict() for _ in subscriptions]}) @subscription.route('/subscription', methods=['DELETE']) @has_uuid @has_service def subscription_delete(client, service): l = Subscription.query.filter_by...
code_fim
medium
{ "lang": "python", "repo": "GarrettSocling/Pushjet-Server-Api", "path": "/controllers/subscription.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>rogramming Language :: Python :: 3.8", ], entry_points={ 'console_scripts': [ 'create-python-app=create_python_app.core:main', ] }, )<|fim_prefix|># repo: averak/create-python-app path: /setup.py from setuptools import setup, find_packages try: long_descriptio...
code_fim
hard
{ "lang": "python", "repo": "averak/create-python-app", "path": "/setup.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: averak/create-python-app path: /setup.py from setuptools import setup, find_packages try: long_description = open("README.md").read() except IOError: long_description = "" setup( name="create_python_app", version="0.1.0", description="CLI tool to quickstart Python app.", ...
code_fim
medium
{ "lang": "python", "repo": "averak/create-python-app", "path": "/setup.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>te_python_app': ['template']}, install_requires=["jinja2"], long_description=long_description, classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3.8", ], entry_points={ 'console_scripts': [ 'create-python-app=create_p...
code_fim
medium
{ "lang": "python", "repo": "averak/create-python-app", "path": "/setup.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ImonEmmanuel/Python_Game path: /Text Adventure/treasure hunt.py """ Coding Challenge 3, hangman.py """ # Coding Challenge 3, hangman.py # Name: Eseka Precious # Student No: 2024170 import time import random import os import csv import sys os.system("clear") inventory = [] def intro(): p...
code_fim
hard
{ "lang": "python", "repo": "ImonEmmanuel/Python_Game", "path": "/Text Adventure/treasure hunt.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Play function to ask user if there would quit or still play """ while True: user = input("Play Again? (Y/N) ").upper() if user == 'Y': main() else: print('Hope to see you again') sys.exit() def main(): """ Main Game D...
code_fim
hard
{ "lang": "python", "repo": "ImonEmmanuel/Python_Game", "path": "/Text Adventure/treasure hunt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Main Game Driver FUnction """ name = input('Enter your Name: ') playagain = "yes" if playagain == "yes": intro() intro_end() choice1_end() part_1() choice2 = attack_or_run() part_1_1(choice2) scorex = encounter_1(choice2) ...
code_fim
hard
{ "lang": "python", "repo": "ImonEmmanuel/Python_Game", "path": "/Text Adventure/treasure hunt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: RockySJ/ampo path: /static/ant.py import numpy as np class StaticFns: @staticmethod def termination_fn(obs, act, next_obs): <|fim_suffix|> done = ~not_done done = done[:, None] return done<|fim_middle|> assert len(obs.shape) == len(next_obs.shape) == len(a...
code_fim
hard
{ "lang": "python", "repo": "RockySJ/ampo", "path": "/static/ant.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x = next_obs[:, 0] not_done = np.isfinite(next_obs).all(axis=-1) \ * (x >= 0.2) \ * (x <= 1.0) done = ~not_done done = done[:, None] return done<|fim_prefix|># repo: RockySJ/ampo path: /static/ant.py import numpy as np class...
code_fim
medium
{ "lang": "python", "repo": "RockySJ/ampo", "path": "/static/ant.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> swagger_paths = ['/ui/css', '/ui/lib', '/ui/images', '/swagger.json'] ui = '/' + self._env.get('swagger_ui', 'ui')+'/' swagger_paths.append(ui) for path in swagger_paths: uri = self._env.swagger.base if len(uri): ...
code_fim
hard
{ "lang": "python", "repo": "ONSdigital/ras-common", "path": "/ons_ras_common/ons_registration.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ONSdigital/ras-common path: /ons_ras_common/ons_registration.py """ Generic Configuration tool for Micro-Service environment discovery License: MIT Copyright (c) 2017 Crown Copyright (Office for National Statistics) ONSRegistration takes care of registering the Micro-service with t...
code_fim
hard
{ "lang": "python", "repo": "ONSdigital/ras-common", "path": "/ons_ras_common/ons_registration.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: salceson/android-copernicus path: /device/device/device.py #!/usr/bin/env python # coding=utf-8 __author__ = 'Michał Ciołczyk' VIRTUAL_COPERNICUS = True MCAST_GRP = '234.6.6.6' MCAST_PORT = 3666 FLOOR = '1' # 1 at the moment only ROOM = 'kitchen' # kitchen|corridor DELAY = 5 # in seconds DEB...
code_fim
hard
{ "lang": "python", "repo": "salceson/android-copernicus", "path": "/device/device/device.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def thread_func(): global sock, light_on while True: command = sock.recv(10240) if DEBUG: print command.split(';') tab = command.split(';') if len(tab) < 4: continue floor = tab[0] room = tab[1] device = tab[2] ...
code_fim
hard
{ "lang": "python", "repo": "salceson/android-copernicus", "path": "/device/device/device.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: juanshishido/codewars path: /kyu7/tests/test_accum.py import unittest from kyu7.accum import accum class TestAccum(unittest.TestCase): <|fim_suffix|> self.assertEqual('C-Ww-Aaa-Tttt', accum('cwAt'))<|fim_middle|> def test_abcd(self): self.assertEqual('A-Bb-Ccc-Dddd', accum('...
code_fim
hard
{ "lang": "python", "repo": "juanshishido/codewars", "path": "/kyu7/tests/test_accum.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertEqual('R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy', accum('RqaEzty')) def test_cwAt(self): self.assertEqual('C-Ww-Aaa-Tttt', accum('cwAt'))<|fim_prefix|># repo: juanshishido/codewars path: /kyu7/tests/test_accum.py import unittest from kyu7.accum import accum class TestAccum(un...
code_fim
easy
{ "lang": "python", "repo": "juanshishido/codewars", "path": "/kyu7/tests/test_accum.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> server_url: str, cid: int, talk: Talk, timeout: Union[Optional[float], Tuple[Optional[float], Optional[float]]] = (3, None), ) -> TalkOnServerResponse: api_url = urljoin(server_url, f'PLAY2/{int(cid)}') headers = { 'Content-Type': 'application/json', } data = talk...
code_fim
medium
{ "lang": "python", "repo": "aoirint/jasmine_zinc", "path": "/jasmine_zinc/talk_on_server.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aoirint/jasmine_zinc path: /jasmine_zinc/talk_on_server.py from urllib.parse import urljoin import json import requests from dataclasses import dataclass from typing import Union, Tuple, Optional from .Talk import ( Talk, talk2dict, ) @dataclass class TalkOnServerResponse: message: ...
code_fim
medium
{ "lang": "python", "repo": "aoirint/jasmine_zinc", "path": "/jasmine_zinc/talk_on_server.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ret = TalkOnServerResponse( message=response['message'], ) return ret<|fim_prefix|># repo: aoirint/jasmine_zinc path: /jasmine_zinc/talk_on_server.py from urllib.parse import urljoin import json import requests from dataclasses import dataclass from typing import Union, Tuple, Option...
code_fim
hard
{ "lang": "python", "repo": "aoirint/jasmine_zinc", "path": "/jasmine_zinc/talk_on_server.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def books_pipeline(): """Read Books Corpus filenames and create Beam pipeline.""" # set a random seed for reproducability rng = random.Random(FLAGS.random_seed) # BooksCorpus is organized into directories of genre and files of books # adventure-all.txt seems to contain all the adventure books...
code_fim
hard
{ "lang": "python", "repo": "google-research/language", "path": "/language/conpono/create_pretrain_data/books_preproc_pipeline.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: google-research/language path: /language/conpono/create_pretrain_data/books_preproc_pipeline.py # coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Licens...
code_fim
hard
{ "lang": "python", "repo": "google-research/language", "path": "/language/conpono/create_pretrain_data/books_preproc_pipeline.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __str__(self): return self.user.username<|fim_prefix|># repo: zxzl/dike path: /dike/webdike/models/user_profile.py from django.db import models from django.contrib.auth.models import User from .sentence import Sentence <|fim_middle|>class UserProfile(models.Model): user = models.Fo...
code_fim
hard
{ "lang": "python", "repo": "zxzl/dike", "path": "/dike/webdike/models/user_profile.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zxzl/dike path: /dike/webdike/models/user_profile.py from django.db import models from django.contrib.auth.models import User from .sentence import Sentence <|fim_suffix|> user = models.ForeignKey(User) work = models.ManyToManyField( Sentence, through='UserHistory', ...
code_fim
easy
{ "lang": "python", "repo": "zxzl/dike", "path": "/dike/webdike/models/user_profile.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return y # Some useful presets spikegadgets_lfp_filter_params = { 'dtype': np.int16, # 'ts_dtype': 'np.uint32', 'fs' : 30000, # sampling rate [Hz] 'fl' : None, # low cut for spike filtering 'fh' : None, # high cut for spike filtering 'gpass' : 0.1, # maximum ...
code_fim
hard
{ "lang": "python", "repo": "kemerelab/jagular", "path": "/jagular/filtering.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kemerelab/jagular path: /jagular/filtering.py """filtering.py Temporal filtering for Jagular. We assume that the original data is in (multiple) files and that they are annoyingly large. So all the methods here work on buffered input, using memory maps. This work is based loosely on simila...
code_fim
hard
{ "lang": "python", "repo": "kemerelab/jagular", "path": "/jagular/filtering.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if filter_epochs is None: filter_epochs = get_contiguous_segments(data=timestamps, assume_sorted=assume_sorted, step=step, index=True) for ...
code_fim
hard
{ "lang": "python", "repo": "kemerelab/jagular", "path": "/jagular/filtering.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zheng568/DECAPS_for_COVID19 path: /models/custom.py import torch.nn as nn import torch.nn.functional as F class Conv2dSame(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, bias=True, padding_layer=nn.ReflectionPad2d): super().__init__() ka = kernel_size...
code_fim
hard
{ "lang": "python", "repo": "zheng568/DECAPS_for_COVID19", "path": "/models/custom.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def forward(self, x): x = F.relu(self.bn1(self.conv1(x))) x = F.relu(self.bn2(self.conv2(x))) x = F.relu(self.bn3(self.conv3(x))) x = F.relu(self.bn4(self.conv4(x))) x = F.relu(self.bn5(self.conv5(x))) x = F.relu(self.bn6(self.conv6(x))) x = F.re...
code_fim
hard
{ "lang": "python", "repo": "zheng568/DECAPS_for_COVID19", "path": "/models/custom.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class CustomNet(nn.Module): def __init__(self): super(CustomNet, self).__init__() self.conv1 = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=3, padding=1) self.bn1 = nn.BatchNorm2d(64) self.conv2 = nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, strid...
code_fim
medium
{ "lang": "python", "repo": "zheng568/DECAPS_for_COVID19", "path": "/models/custom.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CDH-SC/paragon path: /preproc/build/lib/ocrolib/plotutils.py ################################################################ ### Miscellaneous plotting functions based on matplotlib. ################################################################ import matplotlib import __init__ as ocropy # ...
code_fim
medium
{ "lang": "python", "repo": "CDH-SC/paragon", "path": "/preproc/build/lib/ocrolib/plotutils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def plotgrid(data,d=10,shape=(30,30)): """Plot a list of images on a grid.""" ion() gray() clf() for i in range(min(d*d,len(data))): subplot(d,d,i+1) row = data[i] if shape is not None: row = row.reshape(shape) imshow(row) ginput(1,timeout=0.1)<|fim_...
code_fim
hard
{ "lang": "python", "repo": "CDH-SC/paragon", "path": "/preproc/build/lib/ocrolib/plotutils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def unstashCollisions(self): self.collisionNodePath.unstash() def __hitFloor(self, entry): if self.state == 'Dropped' or self.state == 'LocalDropped': self.d_hitFloor() self.demand('SlidingFloor', localAvatar.doId) def __hitGoon(self, entry): i...
code_fim
hard
{ "lang": "python", "repo": "open-toontown/open-toontown", "path": "/toontown/cogdominium/DistCogdoCraneObject.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: open-toontown/open-toontown path: /toontown/cogdominium/DistCogdoCraneObject.py from panda3d.core import * from direct.interval.IntervalGlobal import * from direct.directnotify import DirectNotifyGlobal from direct.distributed import DistributedSmoothNode from toontown.toonbase import ToontownGlo...
code_fim
hard
{ "lang": "python", "repo": "open-toontown/open-toontown", "path": "/toontown/cogdominium/DistCogdoCraneObject.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>B = np.dot((u1-u).T, u1-u) * b1 B += np.dot((u2-u).T, u2-u) * b2 B += np.dot((u3-u).T, u3-u) * b3 eig_vals, eig_vecs = np.linalg.eigh(B) print("evals=", eig_vals, " evecs=", eig_vecs) id = np.argsort(eig_vals)[:: -1] # sort in reverse order eig_vals = eig_vals[id] eig_vecs = eig_vecs[:, id] ...
code_fim
hard
{ "lang": "python", "repo": "shivachawala/Feature-Extraction", "path": "/scatter2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shivachawala/Feature-Extraction path: /scatter2.py import numpy as np import sys if len(sys.argv) != 5: print("usage:", sys.argv[0], "data_file labels_file") sys.exit() # get matrix from file X = np.genfromtxt(sys.argv[1], delimiter=',', autostrip=True) y = np.genfromtxt(sys.ar...
code_fim
hard
{ "lang": "python", "repo": "shivachawala/Feature-Extraction", "path": "/scatter2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>eig_vals, eig_vecs = np.linalg.eigh(B) print("evals=", eig_vals, " evecs=", eig_vecs) id = np.argsort(eig_vals)[:: -1] # sort in reverse order eig_vals = eig_vals[id] eig_vecs = eig_vecs[:, id] r = 2 eig_vecs_2 = eig_vecs[:, :r] eig_vec_T = eig_vecs_2.T np.savetxt(sys.argv[3], eig_vec_T, deli...
code_fim
medium
{ "lang": "python", "repo": "shivachawala/Feature-Extraction", "path": "/scatter2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ''' 825~835MHz,870~880,890~915,935~960,1570.42~1585, 1710~1785,1805~1880,1920~1980,2110~2170, 2570~2620,1880~1915,2300~2400,2400~2483.5 截图三张,一张图最多截10个marker markerlist:[] :return: ''' logger.debug('zvl get_gain_vs_freq') self...
code_fim
hard
{ "lang": "python", "repo": "coderdq/vuetest", "path": "/WEB21-1-12/WEB2/power/zvl_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: coderdq/vuetest path: /WEB21-1-12/WEB2/power/zvl_test.py # coding:utf-8 ''' 矢网的测试项,包括增益,带内波动,VSWR 一个曲线最多建10个marker ''' import os import logging from commoninterface.zvlbase import ZVLBase logger = logging.getLogger('ghost') class HandleZVL(object): def __init__(self, ip, offset): s...
code_fim
hard
{ "lang": "python", "repo": "coderdq/vuetest", "path": "/WEB21-1-12/WEB2/power/zvl_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Make sure the python is current for types.yaml """ self.single_file_generator('py', PythonGenerator, filtr=metadata_filter) # Make sure the python is valid with open(os.path.join(self.source_path, 'types.py')) as f: pydata = f.read() spec = compile(...
code_fim
hard
{ "lang": "python", "repo": "lushacao/biolinkml", "path": "/tests/test_types.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: lushacao/biolinkml path: /tests/test_types.py import os import unittest from types import ModuleType from biolinkml.generators.pythongen import PythonGenerator from tests import targetdir from tests.test_scripts.clicktestcase import metadata_filter from tests.utils.generator_utils import Generat...
code_fim
medium
{ "lang": "python", "repo": "lushacao/biolinkml", "path": "/tests/test_types.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>OUT_DIR = join(PROJ_DIR, 'out') os.makedirs(OUT_DIR, exist_ok=True) OUT_PAPER_DIR = join(OUT_DIR, 'papers') os.makedirs(OUT_PAPER_DIR, exist_ok=True) AUTHOR_TYPE = 0 PAPER_TYPE = 1 VENUE_TYPE = 2<|fim_prefix|># repo: sl1296/ai-test path: /xq-oag/core/utils/settings.py import os from os.path import join,...
code_fim
hard
{ "lang": "python", "repo": "sl1296/ai-test", "path": "/xq-oag/core/utils/settings.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sl1296/ai-test path: /xq-oag/core/utils/settings.py import os from os.path import join, abspath, dirname <|fim_suffix|>OUT_DIR = join(PROJ_DIR, 'out') os.makedirs(OUT_DIR, exist_ok=True) OUT_PAPER_DIR = join(OUT_DIR, 'papers') os.makedirs(OUT_PAPER_DIR, exist_ok=True) AUTHOR_TYPE = 0 PAPER_TYP...
code_fim
hard
{ "lang": "python", "repo": "sl1296/ai-test", "path": "/xq-oag/core/utils/settings.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: centre-for-humanities-computing/hope_dataprep path: /Preprocessing/extract_nordic_tweets.py import os import ndjson import pandas as pd """ Makes daily language specific files in correct format """ # define languages to extract langs = ["da", "no", "sv"] # make a function that transforms a pa...
code_fim
hard
{ "lang": "python", "repo": "centre-for-humanities-computing/hope_dataprep", "path": "/Preprocessing/extract_nordic_tweets.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # loop through the desired language list for language in langs: print(f"extract {language}") # filter data for the desired language using twitter lang tag df_lang = df[df.lang.eq(language)] # convert data to ndjson and write it down print("Writing down..."...
code_fim
hard
{ "lang": "python", "repo": "centre-for-humanities-computing/hope_dataprep", "path": "/Preprocessing/extract_nordic_tweets.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: simongarisch/qstrader path: /tests/unit/system/rebalance/test_end_of_month_rebalance.py import pandas as pd import pytest import pytz from qstrader.system.rebalance.end_of_month import EndOfMonthRebalance @pytest.mark.parametrize( "start_date,end_date,pre_market,expected_dates,expected_tim...
code_fim
hard
{ "lang": "python", "repo": "simongarisch/qstrader", "path": "/tests/unit/system/rebalance/test_end_of_month_rebalance.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> expected_datetimes = [ pd.Timestamp('%s %s' % (expected_date, expected_time), tz=pytz.UTC) for expected_date in expected_dates ] assert actual_datetimes == expected_datetimes<|fim_prefix|># repo: simongarisch/qstrader path: /tests/unit/system/rebalance/test_end_of_month_rebal...
code_fim
medium
{ "lang": "python", "repo": "simongarisch/qstrader", "path": "/tests/unit/system/rebalance/test_end_of_month_rebalance.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> reb = EndOfMonthRebalance( start_dt=sd, end_dt=ed, pre_market=pre_market ) actual_datetimes = reb._generate_rebalances() expected_datetimes = [ pd.Timestamp('%s %s' % (expected_date, expected_time), tz=pytz.UTC) for expected_date in expected_dates ] asser...
code_fim
hard
{ "lang": "python", "repo": "simongarisch/qstrader", "path": "/tests/unit/system/rebalance/test_end_of_month_rebalance.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def copy_dir(src, dest): try: shutil.copytree(src, dest) except OSError as e: if e.errno == errno.ENOTDIR: shutil.copy(src, dest) else: print('Directory not copied. Error: %s' % e) def resize_imgs(root): image_path = os.path.join(root, '*/*/')...
code_fim
hard
{ "lang": "python", "repo": "amzn/xfer", "path": "/leap/leap/utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def random_affine_matrix(img, scale=(0.8, 1.2), rotation=(0, 2*np.pi), translation=(0.2, 0.2)): angle = np.random.uniform(low=rotation[0], high=rotation[1]) tx = translation[0] * img.size[0] ty = translation[1] * img.size[1] translation = (np.round(random.uniform(-tx, tx)), np.round(random...
code_fim
hard
{ "lang": "python", "repo": "amzn/xfer", "path": "/leap/leap/utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: amzn/xfer path: /leap/leap/utils.py # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License is located at # # ...
code_fim
hard
{ "lang": "python", "repo": "amzn/xfer", "path": "/leap/leap/utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bhuman/DeepFieldBoundary path: /Training-Pipeline/evaluate.py import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' import sys sys.path.append(os.path.join(os.path.dirname(__file__), "..", "Utils")) sys.path.insert(0, os.path.join(os.path.dirname(__fi...
code_fim
hard
{ "lang": "python", "repo": "bhuman/DeepFieldBoundary", "path": "/Training-Pipeline/evaluate.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fitted_predictions = [] fitted_predictions_unit_weight = [] for pred in predictions: spots = np.concatenate([np.linspace(0, 1, num=len(pred))[:, np.newaxis], pred], axis=1) fitted_model = fitting.fit_model(spots, step=1) fitted_predictions.append([label_utils.get_field_...
code_fim
hard
{ "lang": "python", "repo": "bhuman/DeepFieldBoundary", "path": "/Training-Pipeline/evaluate.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_ns_pkg_get_one_not_found(self): resp = self.client.get("/api/catalog/v1/nspackages/22") self.assertEqual(resp.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) self.assertEqual( {"error": "Ns package[22] not Found."}, resp.data) #########...
code_fim
hard
{ "lang": "python", "repo": "onap/modeling-etsicatalog", "path": "/catalog/packages/tests/test_nspackage.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: onap/modeling-etsicatalog path: /catalog/packages/tests/test_nspackage.py # Copyright 2017 ZTE Corporation. # # 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 # # ...
code_fim
hard
{ "lang": "python", "repo": "onap/modeling-etsicatalog", "path": "/catalog/packages/tests/test_nspackage.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def tearDown(self): Image.objects.all().delete() Location.objects.all().delete() Category.objects.all().delete() def test_save_image(self): self.monalisa.saveImage() images = Image.objects.all() self.assertTrue(len(images) > 1)<|fim_prefix|># repo: ...
code_fim
hard
{ "lang": "python", "repo": "KellenNjoroge/keller-gallery", "path": "/personal/tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: KellenNjoroge/keller-gallery path: /personal/tests.py from django.test import TestCase from .models import Category, Location, Image class ImageTestClass(TestCase): def setUp(self): <|fim_suffix|> def tearDown(self): Image.objects.all().delete() Location.objects.all().del...
code_fim
hard
{ "lang": "python", "repo": "KellenNjoroge/keller-gallery", "path": "/personal/tests.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.conf = SparkConf() self.conf.setAppName(appName).setMaster(masterName) def getSparkConf(self): return self.conf<|fim_prefix|># repo: rockyCheung/Lambda path: /cobra/spark/SparkConfigSingleton.py # -*- coding:utf-8 -*- from pyspark import SparkConf """ # 创建单例,初始化SparkConf ...
code_fim
hard
{ "lang": "python", "repo": "rockyCheung/Lambda", "path": "/cobra/spark/SparkConfigSingleton.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: rockyCheung/Lambda path: /cobra/spark/SparkConfigSingleton.py # -*- coding:utf-8 -*- from pyspark import SparkConf """ # 创建单例,初始化SparkConf """ class Singleton(object): _instance = None def __new__(cls, *args, **kw): if not cls._instance: cls._instance = super(Singleto...
code_fim
medium
{ "lang": "python", "repo": "rockyCheung/Lambda", "path": "/cobra/spark/SparkConfigSingleton.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: rsnodgrass/python-anthemav-serial path: /anthemav_serial/protocol_sync.py """Simple RS232 communication mechanism for request/reply style commands""" import logging import serial import time from .const import ASCII, CONF_EOL, CONF_THROTTLE_RATE, CONF_TIMEOUT, DEFAULT_TIMEOUT, FIVE_MINUTES LO...
code_fim
hard
{ "lang": "python", "repo": "rsnodgrass/python-anthemav-serial", "path": "/anthemav_serial/protocol_sync.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result = bytearray() while True: c = self._port.read(1) if not c: ret = bytes(result) LOG.info("Received partial: %s", result) raise serial.SerialTimeoutException( 'C...
code_fim
hard
{ "lang": "python", "repo": "rsnodgrass/python-anthemav-serial", "path": "/anthemav_serial/protocol_sync.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write = csv.writer(f) header = [] for th in table_header: header.append(th.text) write.writerow(header) for row in table.find_all('tr'): body = [] for data in row.find_all('td'): body.append(data.text) print(body) write.writerow(bod...
code_fim
medium
{ "lang": "python", "repo": "javier89/web_scraping", "path": "/table.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>l('tr'): body = [] for data in row.find_all('td'): body.append(data.text) print(body) write.writerow(body)<|fim_prefix|># repo: javier89/web_scraping path: /table.py import requests from bs4 import BeautifulSoup import csv url = 'https://webscraper.io/test...
code_fim
medium
{ "lang": "python", "repo": "javier89/web_scraping", "path": "/table.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: javier89/web_scraping path: /table.py import requests from bs4 import BeautifulSoup import csv url = 'https://webscraper.io/test-sites/tables' res = requests.get(url) soup = BeautifulSoup(res<|fim_suffix|>l('tr'): body = [] for data in row.find_all('td'): body.append(...
code_fim
hard
{ "lang": "python", "repo": "javier89/web_scraping", "path": "/table.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: therealAYB/peoplelytics path: /preprocessing/incidents.py import numpy as np import settings def mock_incidents(df): overall_rates = settings.OVERALL_RATES env_rates = settings.ENVIRONMENT_IMPACT death_risk = (1 + df['driver_death_add_risk'])*(1 + df['truck_death_add_risk'])*(1 + df...
code_fim
hard
{ "lang": "python", "repo": "therealAYB/peoplelytics", "path": "/preprocessing/incidents.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> df['Death'] = np.random.rand(len(df)) < death_risk_adj df['Major Incident'] = np.random.rand(len(df)) < major_risk_adj df['Minor Incident'] = np.random.rand(len(df)) < minor_risk_adj return df<|fim_prefix|># repo: therealAYB/peoplelytics path: /preprocessing/incidents.py import numpy as n...
code_fim
hard
{ "lang": "python", "repo": "therealAYB/peoplelytics", "path": "/preprocessing/incidents.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }