text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """
update or insert a client_id - rate pair.
:param client_id: string, e.g. 'client1'
:param rate: float, e.g. 0.1
:return:
"""
import pandas as pd
df = pd.read_json("client_rate.json")
df_dict = df.to_dict()
if client_id in df_dict:
df_dict[str(client_id... | code_fim | hard | {
"lang": "python",
"repo": "honor04/2021-summer-bootcamp",
"path": "/week5-web/mini-project-2 - HaoChen/server/web-server.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: honor04/2021-summer-bootcamp path: /week5-web/mini-project-2 - HaoChen/server/web-server.py
from flask import Flask
from flask import request
from flask import json
app = Flask(__name__)
# -- DO NOT EDIT
# sample end point for HTTP Get
@app.route("/")
def default():
"""
default endpoin... | code_fim | hard | {
"lang": "python",
"repo": "honor04/2021-summer-bootcamp",
"path": "/week5-web/mini-project-2 - HaoChen/server/web-server.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>ampler, GroupSampler
__all__ = ['DistributedSampler', 'DistributedGroupSampler', 'GroupSampler']<|fim_prefix|># repo: Ascend/ModelZoo-PyTorch path: /PyTorch/dev/perf/CascadeMaskRCNN_iflytek_for_PyTorch/mmdet/datasets/samplers/__init__.py
from .distributed_sampler import DistributedSamp<|fim_middle|>ler
... | code_fim | easy | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/dev/perf/CascadeMaskRCNN_iflytek_for_PyTorch/mmdet/datasets/samplers/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ascend/ModelZoo-PyTorch path: /PyTorch/dev/perf/CascadeMaskRCNN_iflytek_for_PyTorch/mmdet/datasets/samplers/__init__.py
from .distributed_sampler import DistributedSamp<|fim_suffix|>pler', 'DistributedGroupSampler', 'GroupSampler']<|fim_middle|>ler
from .group_sampler import DistributedGroupSampl... | code_fim | medium | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/dev/perf/CascadeMaskRCNN_iflytek_for_PyTorch/mmdet/datasets/samplers/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """TRANSLATES STRINGS TO APPROPRIATE LANGUAGE
Args:
phrase: string to be translated
input_language: optional, specifies the original language of the phrase. Defaults to English
output_language: optional, specifies the output language of the phra... | code_fim | hard | {
"lang": "python",
"repo": "SocioProphet/Vida_Modeling",
"path": "/SD_UI_v1_5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def make_fig(self, graph_setting):
"""GENERATE FIGURE PLOTTING OBJECT VALUES OVER TIME
Args:
graph_setting: name of SD object to be plotted
Returns:
fig: matplotlib figure object
"""
#Initialize Figure
fig, ... | code_fim | hard | {
"lang": "python",
"repo": "SocioProphet/Vida_Modeling",
"path": "/SD_UI_v1_5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SocioProphet/Vida_Modeling path: /SD_UI_v1_5.py
osite'
self.color_range = 'NO2 Percent Change'
self.default_graph1 = 'National Measured Infected Population'
self.default_graph2 = "Ships in Offshore Area"
self.map_loc = [13.295026, -8.847543, 0.01]
... | code_fim | hard | {
"lang": "python",
"repo": "SocioProphet/Vida_Modeling",
"path": "/SD_UI_v1_5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GitExl/DoomPath path: /src/navedit/camera.py
class Camera(object):
def __init__(self, x, y, width, height, zoom):
self.x = x
self.y = y
self.zoom = zoom
self.screen_width = width
self.screen_height = height
self.m... | code_fim | medium | {
"lang": "python",
"repo": "GitExl/DoomPath",
"path": "/src/navedit/camera.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return int((x / self.zoom) + self.x), int((y / self.zoom) + self.y)
def map_to_screen(self, x, y):
return int((x - self.x) * self.zoom), int((y - self.y) * self.zoom)<|fim_prefix|># repo: GitExl/DoomPath path: /src/navedit/camera.py
class Camera(object):
def __init_... | code_fim | medium | {
"lang": "python",
"repo": "GitExl/DoomPath",
"path": "/src/navedit/camera.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geomet/geomet path: /geomet/util.py
# Copyright 2013 Lars Butler & individual contributors
#
# 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.apach... | code_fim | hard | {
"lang": "python",
"repo": "geomet/geomet",
"path": "/geomet/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Flatten a multi-dimensional array-like to a single dimensional sequence
(as a generator).
"""
for x in sequence:
if (isinstance(x, collections.Iterable)
and not isinstance(x, six.string_types)):
for y in flatten_multi_dim(x):
yield y
... | code_fim | hard | {
"lang": "python",
"repo": "geomet/geomet",
"path": "/geomet/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Builds page with the basic layout from *basicApp.py* and adds all the relevant plots from *homepageStats.py*.
"""
args = {}
args['valueCol'] = 'value'
args['textCol'] = 'size'
args['y'] = 'index'
args['x'] = 'number'
args['orienta... | code_fim | medium | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/report_manager/apps/homepageApp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hhefzi/CKG path: /src/report_manager/apps/homepageApp.py
import config.ckg_config as ckg_config
from apps import basicApp
from apps import homepageStats as hpstats
class HomePageApp(basicApp.BasicApp):
"""
Defines what the HomePage App is in the report_manager.
Enables the tracking ... | code_fim | medium | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/report_manager/apps/homepageApp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def buildPage(self):
"""
Builds page with the basic layout from *basicApp.py* and adds all the relevant plots from *homepageStats.py*.
"""
args = {}
args['valueCol'] = 'value'
args['textCol'] = 'size'
args['y'] = 'index'
args['x'] = 'numb... | code_fim | medium | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/report_manager/apps/homepageApp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: roadt/scrapymongo path: /util.py
def convert(data):
''' convert bytes to string in py3'''
if isinstance(data, bytes): return data.decode()
<|fim_suffix|>ist(data.items()))))
if isinstance(data, tuple): return tuple(map(convert, data))
if isinstance(data, list): return li... | code_fim | medium | {
"lang": "python",
"repo": "roadt/scrapymongo",
"path": "/util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ist(data.items()))))
if isinstance(data, tuple): return tuple(map(convert, data))
if isinstance(data, list): return list(map(convert, data))
if isinstance(data, set): return set(map(convert, data))
return data<|fim_prefix|># repo: roadt/scrapymongo path: /util.py
def convert(d... | code_fim | medium | {
"lang": "python",
"repo": "roadt/scrapymongo",
"path": "/util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "Decode the URL info as encoded in `.crawler.GET_book_metadata_pages`"
if len(url) <= len(base_url):
raise ValueError(f"This URL is too short: {url}")
url_suffix = url[url.find("-")+1:].rstrip("/")
suffix_list = url_suffix.split("-")
if to_int:
vol_number = int(suffix_l... | code_fim | medium | {
"lang": "python",
"repo": "lmmx/dx",
"path": "/src/dx/share/scraper/url_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lmmx/dx path: /src/dx/share/scraper/url_utils.py
__all__ = ["base_url", "get_url_suffix"]
base_url = "https://bookstore.ams.org/"
<|fim_suffix|> "Decode the URL info as encoded in `.crawler.GET_book_metadata_pages`"
if len(url) <= len(base_url):
raise ValueError(f"This URL is too... | code_fim | medium | {
"lang": "python",
"repo": "lmmx/dx",
"path": "/src/dx/share/scraper/url_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Rodrigues Formula
k = np.cross(n0, n1) # rotation axis for Rodrigues formula
k = k / np.linalg.norm(k)
K = np.array([[0, -k[2], k[1]], [k[2], 0, -k[0]], [-k[1], k[0], 0]])
R = np.eye(3) + np.sin(theta) * K + (1- np.cos(theta)) * K.dot(K)
# build Transfo... | code_fim | hard | {
"lang": "python",
"repo": "dorianhenning/SPIN",
"path": "/process_images.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dorianhenning/SPIN path: /process_images.py
#!/vol/bitbucket/dfh17/miniconda3/envs/detection/bin/python
# Script created by Dorian Henning on 23/10/2019
import pdb
# General imports
import os
import numpy as np
import cv2
import torch
import matplotlib.pyplot as plt
import argparse
import trim... | code_fim | hard | {
"lang": "python",
"repo": "dorianhenning/SPIN",
"path": "/process_images.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # get correct predicted distance from camera
# camera translation == t_BC
camera_translation = torch.stack([pred_camera[:,1],
pred_camera[:,2],
2 * SPIN.constants.FOCAL_LENGTH[0] / (pred_camera[:,0]... | code_fim | hard | {
"lang": "python",
"repo": "dorianhenning/SPIN",
"path": "/process_images.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codingHahn/Hackathon_Mannheim path: /main.py
from flask import Flask, request, render_template
import random
from filereader import random_line, generate_birthdate, rand_phone
from postleitzahl import rand_street
app = Flask(__name__, static_url_path='/static')
@app.route('/')
def index():
<|... | code_fim | hard | {
"lang": "python",
"repo": "codingHahn/Hackathon_Mannheim",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> iban = random_line("iban.csv")
print("Got IBAN")
g_address = address.replace(" ", "%20")
return render_template("result.html", firstname=firstname, lastname=lastname, address=address, place=place, picture=picture, birthdate=birthdate, cellphone=cellphone, landline=landline, iban=iban, g_... | code_fim | hard | {
"lang": "python",
"repo": "codingHahn/Hackathon_Mannheim",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stare-star/qqbot path: /awesome/plugins/weather/getwea.py
import requests
url = 'https://free-api.heweather.net/s6/weather/now?key=ed8124e2f448448297102f6ae9226667&location='
def getweather(city):
<|fim_suffix|>def weaList(str):
list = ''
list += str["basic"]['cnty'] + "/" + str["basic... | code_fim | hard | {
"lang": "python",
"repo": "stare-star/qqbot",
"path": "/awesome/plugins/weather/getwea.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def weaList(str):
list = ''
list += str["basic"]['cnty'] + "/" + str["basic"]['admin_area'] + "/" + str["basic"]['parent_city'] + "/" + str["basic"]['location'] + '的天气:\n' + \
'气温:' + str["now"]['tmp'] + '°C\n' + \
'天气:' + str["now"]['cond_txt'] + '\n' +\
'风向:' + str["now"]... | code_fim | hard | {
"lang": "python",
"repo": "stare-star/qqbot",
"path": "/awesome/plugins/weather/getwea.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
read_list = [self.server]
select_timeout = 1
while True:
# receive a connection request from client and get conn, addrr tuple
readable, _, _= select.select(read_list, [], [], select_timeout)
if self.server in ... | code_fim | hard | {
"lang": "python",
"repo": "saneletm/sample_chat_app",
"path": "/lib/server/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saneletm/sample_chat_app path: /lib/server/server.py
"""
This is a server implementation of a chat app
This is only safe to use on the same machine (as in run both the server and client on the same machine)
Further cleanup would need to be done to support real clients on different machines (as of... | code_fim | hard | {
"lang": "python",
"repo": "saneletm/sample_chat_app",
"path": "/lib/server/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ervice",
"VirtualMachineInterfaceService",
"DistributedPortGroupService",
"VirtualPortGroupService",
"DistributedVirtualSwitchService",
"PhysicalInterfaceService",
]<|fim_prefix|># repo: atsgen/tf-vcenter-fabric-manager path: /cvfm/services/__init__.py
from __future__ import absolute_... | code_fim | medium | {
"lang": "python",
"repo": "atsgen/tf-vcenter-fabric-manager",
"path": "/cvfm/services/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: atsgen/tf-vcenter-fabric-manager path: /cvfm/services/__init__.py
from __future__ import absolute_import
from .vm import *
from .vmi import *
from .dpg import<|fim_suffix|>ervice",
"VirtualMachineInterfaceService",
"DistributedPortGroupService",
"VirtualPortGroupService",
"Distrib... | code_fim | medium | {
"lang": "python",
"repo": "atsgen/tf-vcenter-fabric-manager",
"path": "/cvfm/services/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>alPortGroupService",
"DistributedVirtualSwitchService",
"PhysicalInterfaceService",
]<|fim_prefix|># repo: atsgen/tf-vcenter-fabric-manager path: /cvfm/services/__init__.py
from __future__ import absolute_import
from .vm import *
from .vmi import *
from .dpg import<|fim_middle|> *
from .vpg impor... | code_fim | medium | {
"lang": "python",
"repo": "atsgen/tf-vcenter-fabric-manager",
"path": "/cvfm/services/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> l1,l2,ans=[0]*26,[0]*26,0
for i in range(len(a)): l1[ord(a[i])-ord('a')]+=1
for i in range(len(b)): l2[ord(b[i])-ord('a')]+=1
for i in range(26): ans+=abs(l1[i]-l2[i])
return ans
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
a = input()
b = input... | code_fim | hard | {
"lang": "python",
"repo": "abphilip-codes/Hackerrank_Interview",
"path": "/4_Strings/1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abphilip-codes/Hackerrank_Interview path: /4_Strings/1.py
# https://www.hackerrank.com/challenges/ctci-making-anagrams/problem
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'makeAnagram' function below.
#
# The function is expected to return an INTEGE... | code_fim | medium | {
"lang": "python",
"repo": "abphilip-codes/Hackerrank_Interview",
"path": "/4_Strings/1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jdf/processing.py path: /examples.py/Library/PDF Export/OneFrame.py
""" One Frame.
Saves one PDF with the contents of the display window.
Because this example uses beginRecord, the image is shown
on the display window and is saved to the file.
"""
add_library('pdf') # from proc... | code_fim | easy | {
"lang": "python",
"repo": "jdf/processing.py",
"path": "/examples.py/Library/PDF Export/OneFrame.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>beginRecord(PDF, "line.pdf")
background(255)
stroke(0, 20)
strokeWeight(20.0)
line(200, 0, 400, height)
endRecord()<|fim_prefix|># repo: jdf/processing.py path: /examples.py/Library/PDF Export/OneFrame.py
""" One Frame.
Saves one PDF with the contents of the display window.
Because this exampl... | code_fim | medium | {
"lang": "python",
"repo": "jdf/processing.py",
"path": "/examples.py/Library/PDF Export/OneFrame.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>background(255)
stroke(0, 20)
strokeWeight(20.0)
line(200, 0, 400, height)
endRecord()<|fim_prefix|># repo: jdf/processing.py path: /examples.py/Library/PDF Export/OneFrame.py
""" One Frame.
Saves one PDF with the contents of the display window.
Because this example uses beginRecord, the image ... | code_fim | easy | {
"lang": "python",
"repo": "jdf/processing.py",
"path": "/examples.py/Library/PDF Export/OneFrame.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.foo.name + self.name
def __str__(self):
return self.name
@python_2_unicode_compatible
class Baz(ComputedFieldsModel):
name = models.CharField(max_length=32)
bar = models.ForeignKey(Bar, on_delete=models.CASCADE)
@computed(models.CharField(max_length=32), dep... | code_fim | hard | {
"lang": "python",
"repo": "olivierdalang/django-computedfields",
"path": "/example/exampleapp/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = models.CharField(max_length=32)
bar = models.ForeignKey(Bar, on_delete=models.CASCADE)
@computed(models.CharField(max_length=32), depends=['bar#foo_bar'])
def foo_bar_baz(self):
return self.bar.foo_bar + self.name
def __str__(self):
return self.name<|fim_prefix... | code_fim | hard | {
"lang": "python",
"repo": "olivierdalang/django-computedfields",
"path": "/example/exampleapp/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: olivierdalang/django-computedfields path: /example/exampleapp/models.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from computedfields.models import ComputedFieldsModel, computed
from django.utils.encoding import python_2_unicode_compatible
@py... | code_fim | hard | {
"lang": "python",
"repo": "olivierdalang/django-computedfields",
"path": "/example/exampleapp/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def invokeCommand(self, input_name, xsl):
dest_dir = dirname(input_name)
output_file = join(dirname(input_name), 'tr_output')
command = '%(binary_path)s %(command_line)s' % self.config
data = {'input': input_name, 'output': output_file, 'transform': xsl}
system(... | code_fim | hard | {
"lang": "python",
"repo": "dtgit/dtedu",
"path": "/PortalTransforms/unsafe_transforms/xml.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dtgit/dtedu path: /PortalTransforms/unsafe_transforms/xml.py
"""
A custom transform using external command
"""
__revision__ = '$Id: xml.py 4787 2005-08-19 21:43:41Z dreamcatcher $'
from os.path import join, dirname, exists
import re
from os import popen3, popen4, system
from cStringIO import St... | code_fim | hard | {
"lang": "python",
"repo": "dtgit/dtedu",
"path": "/PortalTransforms/unsafe_transforms/xml.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('<h3>dataCollection Status</h3>')
print('<p id="PID">PID: ' + str(result) + '</p>')<|fim_prefix|># repo: CISSROV/2019-Project path: /code/cgi-bin/statusDataCollection.py
#!/usr/bin/env python3.4
import os
print ("Content-type: text/html\n\n")
<|fim_middle|>f = os.popen('pgrep -f "sudo python3.4 d... | code_fim | hard | {
"lang": "python",
"repo": "CISSROV/2019-Project",
"path": "/code/cgi-bin/statusDataCollection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CISSROV/2019-Project path: /code/cgi-bin/statusDataCollection.py
#!/usr/bin/env python3.4
import os
print ("Content-type: text/html\n\n")
<|fim_suffix|>print('<h3>dataCollection Status</h3>')
print('<p id="PID">PID: ' + str(result) + '</p>')<|fim_middle|>f = os.popen('pgrep -f "sudo python3.4 d... | code_fim | hard | {
"lang": "python",
"repo": "CISSROV/2019-Project",
"path": "/code/cgi-bin/statusDataCollection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # option
field_option = dict()
field_option["field_index"] = etl_field_index
etl_field_index += 1
# ES_TYPE
field_option["es_type"] = FieldDataTypeEnum.get_es_field_type(
field["field_type"], is_analyzed=field["is_ana... | code_fim | hard | {
"lang": "python",
"repo": "jiazhizhong/bk-log",
"path": "/apps/log_databus/handlers/etl_storage/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jiazhizhong/bk-log path: /apps/log_databus/handlers/etl_storage/base.py
support the open source community by making BK-LOG 蓝鲸日志平台 available.
Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
BK-LOG 蓝鲸日志平台 is licensed under the MIT License.
License for BK-LOG 蓝鲸日志平台:
---... | code_fim | hard | {
"lang": "python",
"repo": "jiazhizhong/bk-log",
"path": "/apps/log_databus/handlers/etl_storage/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jiazhizhong/bk-log path: /apps/log_databus/handlers/etl_storage/base.py
luding without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following... | code_fim | hard | {
"lang": "python",
"repo": "jiazhizhong/bk-log",
"path": "/apps/log_databus/handlers/etl_storage/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wiesmanyaroo/glasses path: /glasses/models/classification/alexnet/__init__.py
from __future__ import annotations
from torch import nn
from torch import Tensor
from collections import OrderedDict
from typing import List
from functools import partial
from ..resnet import ReLUInPlace
from glasses.nn... | code_fim | hard | {
"lang": "python",
"repo": "wiesmanyaroo/glasses",
"path": "/glasses/models/classification/alexnet/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__()
self.avg = nn.AdaptiveAvgPool2d((self.filter_size, self.filter_size))
self.block = nn.Sequential(
OrderedDict({
'drop1': nn.Dropout(p=0.5),
'fc1': nn.Linear(self.filter_size * self.filter_size * in_features, 4096),
... | code_fim | hard | {
"lang": "python",
"repo": "wiesmanyaroo/glasses",
"path": "/glasses/models/classification/alexnet/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r+=1
if c == ')':
floor-=1
print floor<|fim_prefix|># repo: ujjwalgulecha/AdventOfCode path: /2015/Day_01/Part_1.py
floor = 0
with open("Day_1.input") as f:
while True:
c = f.read(1)
if not c:
p<|fim_middle|>rint "Done"
break
if c == '(':
floo | code_fim | easy | {
"lang": "python",
"repo": "ujjwalgulecha/AdventOfCode",
"path": "/2015/Day_01/Part_1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ujjwalgulecha/AdventOfCode path: /2015/Day_01/Part_1.py
floor = 0
with open("Day_1.input") as f:
w<|fim_suffix|>rint "Done"
break
if c == '(':
floor+=1
if c == ')':
floor-=1
print floor<|fim_middle|>hile True:
c = f.read(1)
if not c:
p | code_fim | easy | {
"lang": "python",
"repo": "ujjwalgulecha/AdventOfCode",
"path": "/2015/Day_01/Part_1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request_cookies.append(cookie.name + "=" + cookie.value)
return "; ".join(request_cookies)<|fim_prefix|># repo: hamishgibbs/fb_dfg path: /fb_dfg/cookies.py
from http.cookiejar import CookieJar
def get_cookies(cookiejar: CookieJar,
fb_cookies=["datr", "sb", "c_user", "dp... | code_fim | medium | {
"lang": "python",
"repo": "hamishgibbs/fb_dfg",
"path": "/fb_dfg/cookies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hamishgibbs/fb_dfg path: /fb_dfg/cookies.py
from http.cookiejar import CookieJar
def get_cookies(cookiejar: CookieJar,
fb_cookies=["datr", "sb", "c_user", "dpr", "spin", "xs", "fr"],
domain=".facebook.com"):
cookies = list(cookiejar)
request_cookies = [... | code_fim | medium | {
"lang": "python",
"repo": "hamishgibbs/fb_dfg",
"path": "/fb_dfg/cookies.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ype': '<!(["invalid-command-name-egtyevNif3", "netDurj9"])',
},
]
}<|fim_prefix|># repo: tmikov/jscomp path: /runtime/deps/gyp/test/errors/missing_command.gyp
# Copyright (c) 2015 Google Inc. All rights reserved.
# Use of this sour<|fim_middle|>ce code is governed by a BSD-style license that can be... | code_fim | medium | {
"lang": "python",
"repo": "tmikov/jscomp",
"path": "/runtime/deps/gyp/test/errors/missing_command.gyp",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tmikov/jscomp path: /runtime/deps/gyp/test/errors/missing_command.gyp
# Copyright (c) 2015 Google Inc. All rights reserved.
# Use of this sour<|fim_suffix|>CENSE file.
{
'targets': [
{
'target_name': 'foo',
'type': '<!(["invalid-command-name-egtyevNif3", "netDurj9"])',
},
... | code_fim | medium | {
"lang": "python",
"repo": "tmikov/jscomp",
"path": "/runtime/deps/gyp/test/errors/missing_command.gyp",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
for w in example_words:
print(ps.stem(w))
'''
#=============================================================
#===================== classification ========================
import xgboost as xgb
import numpy as np
import pandas as pd
df = pd.DataFrame([[number_of_questions, JJ_count, DT_count... | code_fim | hard | {
"lang": "python",
"repo": "Innovelogic/sentence-logic",
"path": "/com-logic/Natbool.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Innovelogic/sentence-logic path: /com-logic/Natbool.py
import nltk
import csv
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize,sent_tokenize
number_of_questions = 1
#=================Text data aquisition process===============================
with open('data.txt', 'r')... | code_fim | hard | {
"lang": "python",
"repo": "Innovelogic/sentence-logic",
"path": "/com-logic/Natbool.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RadioAstronomySoftwareGroup/pyuvdata path: /pyuvdata/uvdata/fhd.py
obs_loc = ind
if line.startswith("User"):
user_line = ind
if (
main_loc is not None
and command_loc is not None
and obs_loc is not None
and user_line is n... | code_fim | hard | {
"lang": "python",
"repo": "RadioAstronomySoftwareGroup/pyuvdata",
"path": "/pyuvdata/uvdata/fhd.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # we don't have layout info, so go ahead and set the antenna_names,
# antenna_numbers and Nants_telescope from the baseline info struct.
self.antenna_names = [
ant.decode("utf8") for ant in bl_info["TILE_NAMES"][0].tolist()
]
self... | code_fim | hard | {
"lang": "python",
"repo": "RadioAstronomySoftwareGroup/pyuvdata",
"path": "/pyuvdata/uvdata/fhd.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.Ntimes = int(obs["N_TIME"][0])
self.Nbls = int(obs["NBASELINES"][0])
self.Nblts = params["UU"][0].size
self.Nfreqs = int(obs["N_FREQ"][0])
self.Nspws = 1
self.spw_array = np.array([0])
# Future proof: set the flex_spw_id_array.
self.fle... | code_fim | hard | {
"lang": "python",
"repo": "RadioAstronomySoftwareGroup/pyuvdata",
"path": "/pyuvdata/uvdata/fhd.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dotunpeters/coding_challenge path: /toptal.py
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(S, K):
<|fim_suffix|> print(S_dict)
checks = False
for key in S_dict:
if checks:
S_dict[key] -= K
... | code_fim | medium | {
"lang": "python",
"repo": "dotunpeters/coding_challenge",
"path": "/toptal.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> # write your code in Python 3.6
S = list(S)
S.sort()
S_set = set(S)
S_dict = {}
for each in S_set:
S_dict[each] = S.count(each)
print(S_dict)
checks = False
for key in S_dict:
if checks:
S_dict[key] -= K
K = ... | code_fim | medium | {
"lang": "python",
"repo": "dotunpeters/coding_challenge",
"path": "/toptal.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(S_dict)
checks = False
for key in S_dict:
if checks:
S_dict[key] -= K
K = 0
if K == 0:
value = "".join([f"{S_dict[key]}{key}" for key in S_dict if S_dict[key] > 0])
value = "".join([x for x in value if x != "1"])
... | code_fim | medium | {
"lang": "python",
"repo": "dotunpeters/coding_challenge",
"path": "/toptal.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pulumi/pulumi-azure path: /sdk/python/pulumi_azure/cdn/get_frontdoor_firewall_policy.py
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import copy
import warni... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-azure",
"path": "/sdk/python/pulumi_azure/cdn/get_frontdoor_firewall_policy.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The redirect URL for the client.
"""
return pulumi.get(self, "redirect_url")
@property
@pulumi.getter(name="resourceGroupName")
def resource_group_name(self) -> str:
return pulumi.get(self, "resource_group_name")
@property
@pulumi.getter(na... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-azure",
"path": "/sdk/python/pulumi_azure/cdn/get_frontdoor_firewall_policy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.retract(e1)
self.retract(e2)
self.retract(e3)
print(f'Computer wins! {explaination}')
self.modify(board, lose=loses + 1)
self.declare(Action('game-over'))
@Rule(AS.e1 << Action('Judge'),
AS.e2 << Move(answer=MATCH.player_answer, role='pl... | code_fim | hard | {
"lang": "python",
"repo": "goagain/Durham-College-AIDI",
"path": "/AIDI-2004 - AI IN ENTERPRISE SYSTEMS/Rock-Paper-Scissors - Pyknow/rock-paper-scissor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: goagain/Durham-College-AIDI path: /AIDI-2004 - AI IN ENTERPRISE SYSTEMS/Rock-Paper-Scissors - Pyknow/rock-paper-scissor.py
from pyknow import *
from pyknow.fact import *
import random
class ScoreBoard(Fact):
win = Field(int, default=0)
lose = Field(int, default=0)
tie = Field(int, d... | code_fim | hard | {
"lang": "python",
"repo": "goagain/Durham-College-AIDI",
"path": "/AIDI-2004 - AI IN ENTERPRISE SYSTEMS/Rock-Paper-Scissors - Pyknow/rock-paper-scissor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('tie')
self.modify(board, tie=ties + 1)
self.declare(Action('game-over'))
@Rule(AS.e << Action('game-over'),
AS.board << ScoreBoard(lose=MATCH.loses, win=MATCH.wins, tie=MATCH.ties))
def game_over(self, e, board, loses, wins, ties):
self.retract(e)
... | code_fim | hard | {
"lang": "python",
"repo": "goagain/Durham-College-AIDI",
"path": "/AIDI-2004 - AI IN ENTERPRISE SYSTEMS/Rock-Paper-Scissors - Pyknow/rock-paper-scissor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> submitted_form = SubmittedForm(name, email, advisor_name, advisor_email)
app.logger.info(submitted_form.name)
# TODO: empty the form field
# redirect the browser to another route and template
return render_template('email.html', form=submitted_form)
# return... | code_fim | hard | {
"lang": "python",
"repo": "sualehasif/comm-advising-form",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sualehasif/comm-advising-form path: /app.py
from flask import Flask, render_template, redirect, url_for
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, RadioField
from wtforms.fields.html5 import EmailField
from wtforms import va... | code_fim | hard | {
"lang": "python",
"repo": "sualehasif/comm-advising-form",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mivanovitch/pdf_to_txt path: /ocr_to_csv/__main__.py
import argparse
import os
from pdf_to_txt.ocr_to_csv import text_files_to_csv
parser = argparse.ArgumentParser()
parser.add_argument("files", nargs="+")
def main(files):
<|fim_suffix|>
if __name__ == "__main__":
args = parser.parse_args... | code_fim | easy | {
"lang": "python",
"repo": "mivanovitch/pdf_to_txt",
"path": "/ocr_to_csv/__main__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(text_files_to_csv(files))
if __name__ == "__main__":
args = parser.parse_args()
files = args.files
files.sort()
main(files)<|fim_prefix|># repo: mivanovitch/pdf_to_txt path: /ocr_to_csv/__main__.py
import argparse
import os
from pdf_to_txt.ocr_to_csv import text_files_to_csv
... | code_fim | easy | {
"lang": "python",
"repo": "mivanovitch/pdf_to_txt",
"path": "/ocr_to_csv/__main__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from . import infra
ACCEL_TYPES = ["ethos-u55-256", "ethos-u55-128", "ethos-u55-64", "ethos-u55-32"]
def test_forward_mobilenet_v1(accel_type="ethos-u55-256"):
"""Test the Mobilenet V1 TF Lite model."""
np.random.seed(23)
tflite_model_file = tf_testing.get_workload_official(
"https:... | code_fim | hard | {
"lang": "python",
"repo": "neo-ai/tvm",
"path": "/tests/python/contrib/test_ethosu/test_networks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> relay_mod, params = convert_to_relay(tflite_model_buf, input_data, "input")
input_data = {input_tensor: input_data}
output_data = generate_ref_data(relay_mod, input_data)
mod = partition_for_ethosu(relay_mod, params)
compiled_models = infra.build_source(
mod, input_data, outpu... | code_fim | hard | {
"lang": "python",
"repo": "neo-ai/tvm",
"path": "/tests/python/contrib/test_ethosu/test_networks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neo-ai/tvm path: /tests/python/contrib/test_ethosu/test_networks.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF license... | code_fim | hard | {
"lang": "python",
"repo": "neo-ai/tvm",
"path": "/tests/python/contrib/test_ethosu/test_networks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> res_pod_md5sum = get_pod_data_md5sum(core_api, pod_name, pod_data_path)
assert res_pod_md5sum == pod_md5sum
check_volume_data(vol_revision_enabled,
vol_revision_enabled_data_after_sys_upgrade)
check_volume_data(vol_revision_disabled,
vol_revisio... | code_fim | hard | {
"lang": "python",
"repo": "shuo-wu/longhorn-tests",
"path": "/manager/integration/tests/test_upgrade.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shuo-wu/longhorn-tests path: /manager/integration/tests/test_upgrade.py
import os
import pytest
import subprocess
import time
from common import create_volume_and_write_data
from common import volume_name # NOQA
from common import get_self_host_id
from common import wait_for_volume_detached
fro... | code_fim | hard | {
"lang": "python",
"repo": "shuo-wu/longhorn-tests",
"path": "/manager/integration/tests/test_upgrade.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GrebenyukV/pytonbot path: /IryoAirdrop-master/EOS/base58_encoder.py
import argparse
from binascii import hexlify, unhexlify
b58_digits = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def encode(b):
"""Encode bytes to a base58-encoded string"""
# Convert big-endian by... | code_fim | hard | {
"lang": "python",
"repo": "GrebenyukV/pytonbot",
"path": "/IryoAirdrop-master/EOS/base58_encoder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Base58 string encode/decode')
parser.add_argument('-e', "--encode", help='encode string to base58')
parser.add_argument('-d', "--decode", help='decode base58 string')
args = parser.parse_args()
if(args.encode):
... | code_fim | hard | {
"lang": "python",
"repo": "GrebenyukV/pytonbot",
"path": "/IryoAirdrop-master/EOS/base58_encoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>image_dir = os.path.abspath(args.image_dir)
tmp_list = os.listdir(args.image_dir)
txt_dir = image_dir.replace('JPEGImages', 'labels').replace('images','labels')
xml_dir = image_dir.replace('JPEGImages', 'annotations').replace('images','annotations')
if not os.path.isdir(xml_dir):
xml_dir.replace('anno... | code_fim | medium | {
"lang": "python",
"repo": "Dai-z/label-converters",
"path": "/rename.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dai-z/label-converters path: /rename.py
import os
from os.path import join
import argparse
import random
parser = argparse.ArgumentParser()
parser.add_argument('--image_dir',
dest='image_dir',
type=str,
required=True,
... | code_fim | hard | {
"lang": "python",
"repo": "Dai-z/label-converters",
"path": "/rename.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.basic = ['gabby']<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_gabbier.py
#calss header
class _GABBIER():
<|fim_middle|> def __init__(self,):
self.name = "GABBIER"
self.definitions = gabby
self.parents = []
self.childen = []
self.properties = []
self.json... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_gabbier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_gabbier.py
#calss header
class _GABBIER():
def __init__(self,):
self.name = "GABBIER"
self.definitions = gabby
<|fim_suffix|>
self.basic = ['gabby']<|fim_middle|> self.parents = []
self.childen = []
self.properties = []
self.jso... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_gabbier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = ["x", "y", "xy", "yy", "", "yx"]
assert answer(x) == 5<|fim_prefix|># repo: gongbudaizhe/bilib path: /demos/access_codes/solution.py
if __name__ == '__main__':
def answer(x):
differset = set()
differnum = 0
for word in x:
if word not in differset:
... | code_fim | medium | {
"lang": "python",
"repo": "gongbudaizhe/bilib",
"path": "/demos/access_codes/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gongbudaizhe/bilib path: /demos/access_codes/solution.py
if __name__ == '__main__':
def answer(x):
<|fim_suffix|> x = ["x", "y", "xy", "yy", "", "yx"]
assert answer(x) == 5<|fim_middle|> differset = set()
differnum = 0
for word in x:
if word not in di... | code_fim | hard | {
"lang": "python",
"repo": "gongbudaizhe/bilib",
"path": "/demos/access_codes/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BeamIO-Inc/sarpy path: /tests/io/complex/sicd_elements/test_rma.py
from sarpy.io.complex.sicd_elements import RMA
from . import generic_construction_test, unittest
rm_ref_dict = {'PosRef': {'X': 0, 'Y': 0, 'Z': 0}, 'VelRef': {'X': 1, 'Y': 1, 'Z': 1}, 'DopConeAngRef': 45}
inca_dict = {
'Time... | code_fim | hard | {
"lang": "python",
"repo": "BeamIO-Inc/sarpy",
"path": "/tests/io/complex/sicd_elements/test_rma.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.subTest(msg='ImageType'):
self.assertEqual(item1.ImageType, 'RMCR')
def test_construction3(self):
the_type = RMA.RMAType
the_dict = rma_dict3
item1 = generic_construction_test(self, the_type, the_dict)
with self.subTest(msg='ImageType'):
... | code_fim | hard | {
"lang": "python",
"repo": "BeamIO-Inc/sarpy",
"path": "/tests/io/complex/sicd_elements/test_rma.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyscrape/alltheplaces path: /locations/spiders/7_11.py
# -*- coding: utf-8 -*-
import scrapy
import json
import re
from locations.items import GeojsonPointItem
from locations.hours import OpeningHours
class SevenElevenSpider(scrapy.Spider):
name = "seven_eleven"
item_attributes = { 'br... | code_fim | hard | {
"lang": "python",
"repo": "pyscrape/alltheplaces",
"path": "/locations/spiders/7_11.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> yield GeojsonPointItem(**properties)
def parse(self, response):
urls = response.xpath('//div[contains(@class, "locations-specifics")]//li/a/@href').extract()
for url in urls:
yield scrapy.Request(response.urljoin(url))
if not urls:
stores = res... | code_fim | hard | {
"lang": "python",
"repo": "pyscrape/alltheplaces",
"path": "/locations/spiders/7_11.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> properties['opening_hours'] = self.parse_hours(response.xpath('//div[@id="se-local-store-hours"]'))
yield GeojsonPointItem(**properties)
def parse(self, response):
urls = response.xpath('//div[contains(@class, "locations-specifics")]//li/a/@href').extract()
for url in... | code_fim | hard | {
"lang": "python",
"repo": "pyscrape/alltheplaces",
"path": "/locations/spiders/7_11.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mc2dao/rarity-integration path: /tests/test_claim_gold.py
import brownie
def test_claim_no_approval(rm, daily, gold, owner, summoners2):
assert len(summoners2) == 3
for s in summoners2:
assert gold.balanceOf(s) == 0
with brownie.reverts():
daily.claim_gold(summoners... | code_fim | medium | {
"lang": "python",
"repo": "mc2dao/rarity-integration",
"path": "/tests/test_claim_gold.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_claim(rm, daily, gold, owner, summoners2):
rm.setApprovalForAll(daily, True)
daily.level_up(summoners2)
for s in summoners2:
assert gold.balanceOf(s) == 0
assert rm.level(s) == 2
is_approved = daily.is_approved(summoners2)
need_approval = [s for s, approved i... | code_fim | hard | {
"lang": "python",
"repo": "mc2dao/rarity-integration",
"path": "/tests/test_claim_gold.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(1, number):
if i in range(0, number, fizznumber) and i in range(0, number, buzznumber):
print("FizzBuzz")
else:
if i in range(0, number, fizznumber):
print("Fizz")
else:
if i in range(0, number, buzznumber):
print("Buzz... | code_fim | hard | {
"lang": "python",
"repo": "esHathck05/fizzbuzz",
"path": "/fizzbuzz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: esHathck05/fizzbuzz path: /fizzbuzz.py
#fizzbuzz.py
#Author: Esther Hacker
#Credit: N/A
#Assignment: FizzBuzz
<|fim_suffix|>for i in range(1, number):
if i in range(0, number, fizznumber) and i in range(0, number, buzznumber):
print("FizzBuzz")
else:
if i in range(0, num... | code_fim | hard | {
"lang": "python",
"repo": "esHathck05/fizzbuzz",
"path": "/fizzbuzz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # # module.params_name = node.op.params
# # handle by ModuleHooker
# # module.params_name = [v.name for v in node.op.params.values()]
def organize_quant_pos(self):
# Transfer inplace operation fragpos forward,
# to replace configerComannder in future
if NndctOption... | code_fim | hard | {
"lang": "python",
"repo": "WeelCJ/Vitis-AI",
"path": "/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/torchquantizer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WeelCJ/Vitis-AI path: /Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/torchquantizer.py
import json
import copy
import numpy as np
from scipy import stats
import torch
from os import environ
from torch.autograd import Variable
import pytorch_nndct as py_nndct
from n... | code_fim | hard | {
"lang": "python",
"repo": "WeelCJ/Vitis-AI",
"path": "/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/torchquantizer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> topicLine = soup.findAll('meta', key_name="topic")[0]
topicStartSplit = topicLine.encode('utf-8').split('<meta key_name="topic" content="')[1]
topic = topicStartSplit.split('" />')[0]
# Title #
titleLine = soup.findAll('meta', key_name="title")[0]
titleStartSplit = titleLine.encode('utf-... | code_fim | hard | {
"lang": "python",
"repo": "leonhandreke/ruegenhoeren",
"path": "/cachegen/cachegen.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leonhandreke/ruegenhoeren path: /cachegen/cachegen.py
#!/usr/bin/env python
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import os
import plistlib
from BeautifulSoup import BeautifulSoup
# Path to HTML file and resulting plist file
pathHTML = "../html/"
pathPlist = "../audioLocation... | code_fim | hard | {
"lang": "python",
"repo": "leonhandreke/ruegenhoeren",
"path": "/cachegen/cachegen.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #print encodedCoverImage
finDict = {'topic': topic, 'title': title, 'subtitle': subtitle, 'longitude': longitude, 'latitude': latitude, 'uuid': uuid, 'descriptionPage': htmlbody, 'audioFileRemoteLocation': audioFileRemoteLocation, 'coverImageRemoteLocation': coverImageLocation}
mai... | code_fim | hard | {
"lang": "python",
"repo": "leonhandreke/ruegenhoeren",
"path": "/cachegen/cachegen.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if node is None:
return 0
s = node.val + cal_sum(node.left) + cal_sum(node.right)
counter[s] += 1
return s
counter = Counter()
cal_sum(root)
highest_freq = max(counter.values())
return [key for key in counter.k... | code_fim | hard | {
"lang": "python",
"repo": "ChuanleiGuo/AlgorithmsPlayground",
"path": "/LeetCodeSolutions/python/508_Most_Frequent_Subtree_Sum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChuanleiGuo/AlgorithmsPlayground path: /LeetCodeSolutions/python/508_Most_Frequent_Subtree_Sum.py
from collections import Counter
class TreeNode(object):
def __init__(self, x):
<|fim_suffix|> def findFrequentTreeSum(self, root):
"""
:type root: TreeNode
:rtype: Lis... | code_fim | medium | {
"lang": "python",
"repo": "ChuanleiGuo/AlgorithmsPlayground",
"path": "/LeetCodeSolutions/python/508_Most_Frequent_Subtree_Sum.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:type root: TreeNode
:rtype: List[int]
"""
if root is None:
return []
def cal_sum(node):
if node is None:
return 0
s = node.val + cal_sum(node.left) + cal_sum(node.right)
counter[s] += 1
... | code_fim | medium | {
"lang": "python",
"repo": "ChuanleiGuo/AlgorithmsPlayground",
"path": "/LeetCodeSolutions/python/508_Most_Frequent_Subtree_Sum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.