text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: luwangg/kaptos path: /src/kaptos/resources/v1/transmissions.py """Detected transmissions, computed from station reception reports.""" import kaptos.schema as ks import roax.schema as s from .. import KaptosResource from roax.resource import operation _schema = s.dict( description = "Detec...
code_fim
hard
{ "lang": "python", "repo": "luwangg/kaptos", "path": "/src/kaptos/resources/v1/transmissions.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> super().__init__(name="transmissions") # ---- create ------ @operation( params = {"_body": _schema}, returns = s.dict({"id": _schema.properties["id"]}) ) def create(self, _body): return super().create(_body) # ----- read ------ @operation( ...
code_fim
medium
{ "lang": "python", "repo": "luwangg/kaptos", "path": "/src/kaptos/resources/v1/transmissions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: anadahalli/project-euler path: /p011.py """Problem 011 In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67...
code_fim
hard
{ "lang": "python", "repo": "anadahalli/project-euler", "path": "/p011.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(0, len(l), n): yield l[i:i+n] matrix = list(chunks(grid, 20)) ans = 0 for mat in [[row[i:i+4] for row in matrix[j:j+4]] for j in range(0, 16) for i in range(0, 16)]: horizontal = mat vertical = [[mat[i][j] for i in range(0, 4)] for j in range(0, 4)] di...
code_fim
hard
{ "lang": "python", "repo": "anadahalli/project-euler", "path": "/p011.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: francamacdowell/AnalyzeYou path: /youtube_api/main_app/serializer.py from rest_framework import serializers from .models import * class ChannelDetailsSerializer(serializers.ModelSerializer): def __init__(self, *args, **kwargs): many = kwargs.pop('many', True) super(ChannelDe...
code_fim
hard
{ "lang": "python", "repo": "francamacdowell/AnalyzeYou", "path": "/youtube_api/main_app/serializer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> model = VideoDetails fields = ('id', 'title', 'description', 'tags') class StatisticsDetailsSerializer(serializers.ModelSerializer): def __init__(self, *args, **kwargs): many = kwargs.pop('many', True) super(StatisticsDetailsSerializer, self).__init__(many=many, *args...
code_fim
hard
{ "lang": "python", "repo": "francamacdowell/AnalyzeYou", "path": "/youtube_api/main_app/serializer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, *args, **kwargs): many = kwargs.pop('many', True) super(SetupSerializer, self).__init__(many=many, *args, **kwargs) class Meta: model = Setup fields = ('id', 'link_video', 'user_token')<|fim_prefix|># repo: francamacdowell/AnalyzeYou path: /yout...
code_fim
medium
{ "lang": "python", "repo": "francamacdowell/AnalyzeYou", "path": "/youtube_api/main_app/serializer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async def _get_orders_data_for_chain(self, chain, gram_markets): async def get_size_of_smallest_arr(arrs_lst): return min(map(lambda x: len(x), arrs_lst)) async def cut_off_extra_arrs_els(arrs_lst, required_nums_of_items): arr = np.array([ *map(...
code_fim
hard
{ "lang": "python", "repo": "mkbeh/rin-bitshares-arbitry-bot", "path": "/src/core/bitsharesarbitrage.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return pairs_orders_data_arr async def _get_precisions_arr(self, chain): obj = await Asset().connect(ws_node=self.wallet_uri) assets_arr = itertools.chain.from_iterable( map(lambda x: x.split(':'), chain) ) precisions_arr = np.array(range(4)...
code_fim
hard
{ "lang": "python", "repo": "mkbeh/rin-bitshares-arbitry-bot", "path": "/src/core/bitsharesarbitrage.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mkbeh/rin-bitshares-arbitry-bot path: /src/core/bitsharesarbitrage.py # -*- coding: utf-8 -*- import os import re import time import logging import itertools import asyncio import numpy as np from datetime import datetime as dt from aiohttp.client_exceptions import ClientConnectionError from ...
code_fim
hard
{ "lang": "python", "repo": "mkbeh/rin-bitshares-arbitry-bot", "path": "/src/core/bitsharesarbitrage.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: halmga/pantext path: /pantext/quantifier.py #!/usr/bin/env python # coding: utf-8 # In[ ]: from nltk.corpus import stopwords from nltk import download from re import sub from nltk.tokenize import RegexpTokenizer, sent_tokenize, word_tokenize from tqdm import tqdm download('stopwords') download...
code_fim
hard
{ "lang": "python", "repo": "halmga/pantext", "path": "/pantext/quantifier.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Returns ------- count_list: list Returns a list of regex counts per string in list Examples -------- >>> text = ["'Anselmo,' the old man said. 'I am called Anselmo and I come from Barco deAvila. Let me help you with that pack'"] ...
code_fim
hard
{ "lang": "python", "repo": "halmga/pantext", "path": "/pantext/quantifier.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #counts percentage of words in text that are stopwords def stopword_percent(self, stop_words = 'english'): """ generate stopword percentage in each piece of text. Parameters ---------- stop_words: str, default 'english' see nltk.corpus.s...
code_fim
hard
{ "lang": "python", "repo": "halmga/pantext", "path": "/pantext/quantifier.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ikacper/Willos path: /backend/api/admin.py from django.contrib import admin <|fim_suffix|>@admin.register(Property) class PropertyAdmin(admin.ModelAdmin): list_display = ( "title", "address", "price", "date", "bedrooms", "bathrooms", "c...
code_fim
easy
{ "lang": "python", "repo": "Ikacper/Willos", "path": "/backend/api/admin.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@admin.register(Property) class PropertyAdmin(admin.ModelAdmin): list_display = ( "title", "address", "price", "date", "bedrooms", "bathrooms", "cordinates", )<|fim_prefix|># repo: Ikacper/Willos path: /backend/api/admin.py from django.contr...
code_fim
easy
{ "lang": "python", "repo": "Ikacper/Willos", "path": "/backend/api/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bluemurder/mlfl path: /udacity course code/01-03-numpyarraymaximumquiz.py """Locate maximum value.""" import numpy as np def get_max_index(a): <|fim_suffix|> a = np.array([9, 6, 2, 3, 12, 14, 7, 10], dtype=np.int32) # 32-bit integer array print "Array:", a # Find the maximum a...
code_fim
medium
{ "lang": "python", "repo": "bluemurder/mlfl", "path": "/udacity course code/01-03-numpyarraymaximumquiz.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_run(): a = np.array([9, 6, 2, 3, 12, 14, 7, 10], dtype=np.int32) # 32-bit integer array print "Array:", a # Find the maximum and its index in array print "Maximum value:", a.max() print "Index of max.:", get_max_index(a) if __name__ == "__main__": test_run()<|fim_...
code_fim
medium
{ "lang": "python", "repo": "bluemurder/mlfl", "path": "/udacity course code/01-03-numpyarraymaximumquiz.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: imackerracher/NewsSimilarity path: /newssimilarity/utils/ml_utils.py from sklearn import metrics def evaluate(model, X, y): prediction = model.predict(X) acc = metrics.accuracy_score(y, prediction) print("Accuracy:", acc) return prediction def extract_labels_single_format(...
code_fim
medium
{ "lang": "python", "repo": "imackerracher/NewsSimilarity", "path": "/newssimilarity/utils/ml_utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ [0,1,1,1,0,0...] instead of [[1,0], [1,0], [0,1]...] :param featureset: :return: """ def extract(label): return 1 if label == [1,0] else 0 y = lambda label: extract(label), featureset['Labels'] return y<|fim_prefix|># repo: imackerracher/NewsSimilarity path: /newssimil...
code_fim
medium
{ "lang": "python", "repo": "imackerracher/NewsSimilarity", "path": "/newssimilarity/utils/ml_utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: AbuBakkar32/pythoncode-tutorials path: /ethical-hacking/subdomain-scanner/subdomain_scanner.py import requests # the domain to scan for subdomains domain = "google.com" <|fim_suffix|>for subdomain in subdomains: # construct the url url = f"http://{subdomain}.{domain}" try: #...
code_fim
medium
{ "lang": "python", "repo": "AbuBakkar32/pythoncode-tutorials", "path": "/ethical-hacking/subdomain-scanner/subdomain_scanner.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for subdomain in subdomains: # construct the url url = f"http://{subdomain}.{domain}" try: # if this raises an ERROR, that means the subdomain does not exist requests.get(url) except requests.ConnectionError: # if the subdomain does not exist, just pass, print nothi...
code_fim
medium
{ "lang": "python", "repo": "AbuBakkar32/pythoncode-tutorials", "path": "/ethical-hacking/subdomain-scanner/subdomain_scanner.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: k2sebeom/pyplayscii path: /examples/bounce.py from playscii import GameObject, GameManager from playscii.input import Input BALL = " ** \n" \ " ****\n" \ " **" class Ball(GameObject): def __init__(self): super().__init__(pos=(40, 10), render=BALL) ...
code_fim
medium
{ "lang": "python", "repo": "k2sebeom/pyplayscii", "path": "/examples/bounce.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self): super().__init__((80, 20)) self.ball = Ball() self.set_title("Press q to quit") def setup(self): self.add_object(self.ball) def update(self): if self.ball.x < 0 or self.ball.x > 74: self.ball.vel = (-self.ball.vel[0], se...
code_fim
medium
{ "lang": "python", "repo": "k2sebeom/pyplayscii", "path": "/examples/bounce.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: heyyybingo/sparsifying_regularizers_for_RRNNs path: /language_model/train_lm.py elf).__init__() word2id, id2word = {}, {} if sos not in word2id: word2id[sos] = len(word2id) id2word[word2id[sos]] = sos for w in words: if w not in word2id:...
code_fim
hard
{ "lang": "python", "repo": "heyyybingo/sparsifying_regularizers_for_RRNNs", "path": "/language_model/train_lm.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> else: unchanged += 1 if args.lr_decay_epoch > 0 and epoch >= args.lr_decay_epoch: args.lr *= args.lr_decay if unchanged >= args.patience: print_and_log("Reached " + str(args.patience) + " iterations w...
code_fim
hard
{ "lang": "python", "repo": "heyyybingo/sparsifying_regularizers_for_RRNNs", "path": "/language_model/train_lm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: heyyybingo/sparsifying_regularizers_for_RRNNs path: /language_model/train_lm.py ing == "max_plus": self.semiring = MaxPlusSemiring else: assert False, "Semiring should either be plus_times or max_plus, not {}".format(args.semiring) self.enco...
code_fim
hard
{ "lang": "python", "repo": "heyyybingo/sparsifying_regularizers_for_RRNNs", "path": "/language_model/train_lm.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ricorx7/QRevPy path: /Classes/BoatData.py self.v_processed_mps = np.copy(self.v_mps) self.u_processed_mps[self.valid_data[0, :] == False] = np.nan self.v_processed_mps[self.valid_data[0, :] == False] = np.nan n_invalid = 0 # Process data by ensembles for...
code_fim
hard
{ "lang": "python", "repo": "ricorx7/QRevPy", "path": "/Classes/BoatData.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: ricorx7/QRevPy path: /Classes/BoatData.py o_coord_sys == 'Beam': # Determine frequency index for transformation matrix if len(t_matrix.shape) > 2: idx_freq = np.where(t_matrix_freq == self.frequency_khz[ii]) ...
code_fim
hard
{ "lang": "python", "repo": "ricorx7/QRevPy", "path": "/Classes/BoatData.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> # Compute speed and direction of boat direct, speed = cart2pol(b_vele, b_veln) # Compute residuals from a robust Loess smooth speed_smooth = rloess(ens_time, speed, filter_width) speed_res = speed - speed_smooth # Apply a trimmed st...
code_fim
hard
{ "lang": "python", "repo": "ricorx7/QRevPy", "path": "/Classes/BoatData.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> @commands.command() async def getmyreminders(self, ctx): reminders = Database.getReminders(ctx.author.id) if len(reminders) > 1: embed = discord.Embed(title=f"{ctx.author.name} reminders") for reminder in reminders: embed.add_field(name=remin...
code_fim
hard
{ "lang": "python", "repo": "matttattoli/exceed-discord-bot", "path": "/cogs/Reminders.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: matttattoli/exceed-discord-bot path: /cogs/Reminders.py import discord from discord.ext import commands from cogs.utils.checks import * from cogs.utils.GlobalVars import * from cogs.utils.debug import * from cogs.utils.Database import Database import datetime import asyncio class RemindParser: ...
code_fim
hard
{ "lang": "python", "repo": "matttattoli/exceed-discord-bot", "path": "/cogs/Reminders.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, bot): self.bot = bot @commands.command() async def remindme(self, ctx, *, msg: str): data = RemindParser.parseReminderMsg(msg) if data is None: return await ctx.send("Error parsing your reminder") Database.createReminder(ctx.autho...
code_fim
hard
{ "lang": "python", "repo": "matttattoli/exceed-discord-bot", "path": "/cogs/Reminders.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chapman-cpsc-230/hw2-agust105 path: /sum_powers.py """ File: sum_power.py Copyright (c) 2016 Francis Agustin License: MIT <|fim_suffix|>""" user_input = raw_input ("Enter value for b: ") b = float (user_input) while b == 1: user_input = raw_input ("Value cannot be 1. Enter value for b: "...
code_fim
hard
{ "lang": "python", "repo": "chapman-cpsc-230/hw2-agust105", "path": "/sum_powers.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>user_input = raw_input ("Enter value for b: ") b = float (user_input) while b == 1: user_input = raw_input ("Value cannot be 1. Enter value for b: ") b = float (user_input) user_input2 = raw_input ("Enter value for n: ") n = int (user_input2) i = 0.0 sum_power = 0 while i <= n: sum_power +=...
code_fim
hard
{ "lang": "python", "repo": "chapman-cpsc-230/hw2-agust105", "path": "/sum_powers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>while b == 1: user_input = raw_input ("Value cannot be 1. Enter value for b: ") b = float (user_input) user_input2 = raw_input ("Enter value for n: ") n = int (user_input2) i = 0.0 sum_power = 0 while i <= n: sum_power += b**i i += 1 print sum_power eq = ((b**(n+1)) - 1)/(b-1) print e...
code_fim
medium
{ "lang": "python", "repo": "chapman-cpsc-230/hw2-agust105", "path": "/sum_powers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: WxOutside/software path: /telemetry/functions.py #!/usr/bin/env python import subprocess import json import os import smtplib import time from config import couchdb_baseurl, wxoutside_email_server, wxoutside_email_port from environment_config import wxoutside_sensor_email, wxoutside_sensor_pass...
code_fim
hard
{ "lang": "python", "repo": "WxOutside/software", "path": "/telemetry/functions.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> except: pass doc_name=host_name + '_last_record' output=run_proc('GET', base_url + '/telemetry/' + doc_name) last_record_json_items={} try: if output['_rev']: last_record_json_items=output #print ("We need to update re...
code_fim
hard
{ "lang": "python", "repo": "WxOutside/software", "path": "/telemetry/functions.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>for thisLayer in thisFont.selectedLayers: # create a temporary copy of the current layer originalLayer = thisLayer.copy() # reinterpolate the layer thisLayer.reinterpolate() # put back paths and components as of before reinterpolating the layer try: # Glyphs 3 thisLayer.shapes = originalLayer.shap...
code_fim
medium
{ "lang": "python", "repo": "harbortype/glyphs-scripts", "path": "/Anchors/Re-interpolate Anchors.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: harbortype/glyphs-scripts path: /Anchors/Re-interpolate Anchors.py #MenuTitle: Re-interpolate Anchors # -*- coding: utf-8 -*- from __future__ import division, print_function, unicode_literals __doc__=""" Re-interpolates only the anchors on selected layers. """ <|fim_suffix|>for thisLayer in this...
code_fim
medium
{ "lang": "python", "repo": "harbortype/glyphs-scripts", "path": "/Anchors/Re-interpolate Anchors.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: arthurtucker/Clue-Less path: /clueless/server/app.py from flask import Flask from flask.ext import restful from clueless import log from clueless.server.api import resources _LOG = log.get_logger(__name__) <|fim_suffix|> _LOG.info('Clueless server starting..') app = Flask(__name__) ...
code_fim
medium
{ "lang": "python", "repo": "arthurtucker/Clue-Less", "path": "/clueless/server/app.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def start_server(): _LOG.info('Clueless server starting..') app = Flask(__name__) api = restful.Api(app) api.add_resource(resources.PlayersResource, '/players') api.add_resource(resources.PlayerResource, '/players/<string:username>') api.add_resource(resources.GamesResource, '/...
code_fim
medium
{ "lang": "python", "repo": "arthurtucker/Clue-Less", "path": "/clueless/server/app.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> _LOG.info('Clueless server starting..') app = Flask(__name__) api = restful.Api(app) api.add_resource(resources.PlayersResource, '/players') api.add_resource(resources.PlayerResource, '/players/<string:username>') api.add_resource(resources.GamesResource, '/games') api.add_re...
code_fim
medium
{ "lang": "python", "repo": "arthurtucker/Clue-Less", "path": "/clueless/server/app.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: FNNDSC/pl-gepush path: /gepush/Agent17Upload.py ''' /* * Copyright 2010-2016 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...
code_fim
hard
{ "lang": "python", "repo": "FNNDSC/pl-gepush", "path": "/gepush/Agent17Upload.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>terminate_flag = False device_config = {} with open(config_file, 'r') as f: device_config = json.load(f) logger.debug( "device_config is %s ", json.dumps(device_config)) host = device_config['endpoint'] rootCAPath = device_config['rootCertificate'] certificatePath = device_config['deviceCertificate']...
code_fim
hard
{ "lang": "python", "repo": "FNNDSC/pl-gepush", "path": "/gepush/Agent17Upload.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: FanGeGo/motifwalk path: /research/src/mane/motif.py """Motif object to use with Graph """ # Coding: utf-8 # Filename: motif.py # Created: 2016-07-16 # Description: ## v0.0: File created from __future__ import print_function from __future__ import division from __future__ import absolute_import ...
code_fim
medium
{ "lang": "python", "repo": "FanGeGo/motifwalk", "path": "/research/src/mane/motif.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># >>> BEGIN DEFAULT MOTIF(s) <<< default_directed = Motif(directed=True) # TODO: Implement walk engine here default_undirected = Motif(directed=False) # TODO: Implement walk engine here # >>> END DEFAULT MOTIF(s) <<<<|fim_prefix|># repo: FanGeGo/motifwalk path: /research/src/mane/motif.py """Motif object...
code_fim
medium
{ "lang": "python", "repo": "FanGeGo/motifwalk", "path": "/research/src/mane/motif.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vontell/dynabench path: /api/migrations/20210521_01_xxxx-open_flores.py # Copyright (c) Facebook, Inc. and its affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Hide Flores task until June 4th, 2021. """ fr...
code_fim
medium
{ "lang": "python", "repo": "vontell/dynabench", "path": "/api/migrations/20210521_01_xxxx-open_flores.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>step( f""" UPDATE tasks SET hidden = true, submitable = true WHERE task_code in {tasks} """, f""" UPDATE tasks SET hidden = false, submitable = false WHERE task_code in {tasks} """, )<|fim_prefix|># repo: vontell/dynabench path: /api/migrations/20210521_01_xxxx-open_flores...
code_fim
medium
{ "lang": "python", "repo": "vontell/dynabench", "path": "/api/migrations/20210521_01_xxxx-open_flores.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: IamMayankThakur/test-bigdata path: /adminmgr/media/code/A3/task3/BD_85_130_185_279_S3RkVts.py import findspark findspark.init() from pyspark import SparkConf,SparkContext from pyspark.streaming import StreamingContext from pyspark.sql import Row,SQLContext import sys import requests conf=SparkC...
code_fim
medium
{ "lang": "python", "repo": "IamMayankThakur/test-bigdata", "path": "/adminmgr/media/code/A3/task3/BD_85_130_185_279_S3RkVts.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>dataStream=ssc.socketTextStream("localhost",9009) dataStream.pprint() words = dataStream.flatMap(lambda line: line.split(";")[7].split(",")) pairs = words.map(lambda word: (word, 1)) windowedWordCounts = pairs.reduceByKeyAndWindow(lambda x, y: x + y, int(sys.argv[1]), 1) windowedWordCounts.pprint() ssc.s...
code_fim
medium
{ "lang": "python", "repo": "IamMayankThakur/test-bigdata", "path": "/adminmgr/media/code/A3/task3/BD_85_130_185_279_S3RkVts.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cstlee/RooBench path: /scripts/roobench_config.py #!/usr/bin/env python # Copyright (c) 2020, Stanford University # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this perm...
code_fim
hard
{ "lang": "python", "repo": "cstlee/RooBench", "path": "/scripts/roobench_config.py", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>def main(args): if args["bench"]: with open(args["<server_list>"]) as f: server_list = json.load(f) with open(args["<workload>"]) as f: workload = json.load(f) config = {} node_count = len(server_list['servers']) if args['--nodes'] > 0: ...
code_fim
hard
{ "lang": "python", "repo": "cstlee/RooBench", "path": "/scripts/roobench_config.py", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|># repo: robot-ai-machinelearning/to_share_or_not_to_share path: /main.py import os from argparse import ArgumentParser import torch from torch.utils.data.dataset import Subset from torchvision import datasets from models.graph_comps import GraphComp from models.graph_sampler import GraphSampler from tr...
code_fim
hard
{ "lang": "python", "repo": "robot-ai-machinelearning/to_share_or_not_to_share", "path": "/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # load the architecture dataset dataset_path = "./datasets/sp_{}.pkl".format(search_space) # folder where results are saved model_dir = get_output_folder(os.path.join("./results", exp_params["output_dir"]), search_space) # If training, skipped if only evaluating if not args.eval_...
code_fim
hard
{ "lang": "python", "repo": "robot-ai-machinelearning/to_share_or_not_to_share", "path": "/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # creating the super-net model = GraphComp(**exp_params) print("Number of trainable parameters: {}".format( sum([p.numel() for p in model.parameters()]))) if args.snapshot_path is not None: model.load_state_dict(torch.load(args.snapshot_path, map_location=exp_params["device...
code_fim
hard
{ "lang": "python", "repo": "robot-ai-machinelearning/to_share_or_not_to_share", "path": "/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ :type S: str :rtype: bool """ sign = "abc" while S: if len(S) < 3: return False current = "" index = 0 flag = False while index < len(S): if index < len(S) - 2: ...
code_fim
hard
{ "lang": "python", "repo": "windard/leeeeee", "path": "/1003.check-if-word-is-valid-after-substitutions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: windard/leeeeee path: /1003.check-if-word-is-valid-after-substitutions.py # coding=utf-8 # # @lc app=leetcode id=1003 lang=python # # [1003] Check If Word Is Valid After Substitutions # # https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/description/ # # algorithms # Medium...
code_fim
hard
{ "lang": "python", "repo": "windard/leeeeee", "path": "/1003.check-if-word-is-valid-after-substitutions.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @transition(field='status', source=['prepayment_deposited', 'no_payment_required'], custom=dict(auto=True)) def acknowledge_prepayment(self): """ Acknowledge the payment. This method is invoked automatically. """ self.acknowledge_payment() @tran...
code_fim
hard
{ "lang": "python", "repo": "shivamraj74/django-shop", "path": "/shop/payment/workflows.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: shivamraj74/django-shop path: /shop/payment/workflows.py from django.core.exceptions import ImproperlyConfigured from django.utils.translation import gettext_lazy as _ from django_fsm import transition, RETURN_VALUE from shop.models.order import BaseOrder class ManualPaymentWorkflowMixin: ...
code_fim
hard
{ "lang": "python", "repo": "shivamraj74/django-shop", "path": "/shop/payment/workflows.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def cancelable(self): return super().cancelable() or self.status in self.CANCELABLE_SOURCES @transition(field='status', target=RETURN_VALUE(*TRANSITION_TARGETS.keys()), conditions=[cancelable], custom=dict(admin=True, button_name=_("Cancel Order"))) def cancel_order(se...
code_fim
hard
{ "lang": "python", "repo": "shivamraj74/django-shop", "path": "/shop/payment/workflows.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return self._extract_uplynk_info(url) class UplynkPreplayIE(UplynkIE): IE_NAME = 'uplynk:preplay' _VALID_URL = r'https?://.*?\.uplynk\.com/preplay2?/(?P<path>ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|(?P<id>[0-9a-f]{32}))\.json' _TEST = None def _real_extract(self, url): ...
code_fim
medium
{ "lang": "python", "repo": "firsttris/plugin.video.sendtokodi", "path": "/lib/youtube_dl/extractor/uplynk.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: firsttris/plugin.video.sendtokodi path: /lib/youtube_dl/extractor/uplynk.py # coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( float_or_none, ExtractorError, ) class UplynkIE(InfoExtractor): IE_NAME = 'uplynk' ...
code_fim
hard
{ "lang": "python", "repo": "firsttris/plugin.video.sendtokodi", "path": "/lib/youtube_dl/extractor/uplynk.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class UplynkPreplayIE(UplynkIE): IE_NAME = 'uplynk:preplay' _VALID_URL = r'https?://.*?\.uplynk\.com/preplay2?/(?P<path>ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|(?P<id>[0-9a-f]{32}))\.json' _TEST = None def _real_extract(self, url): path, external_id, video_id = re.match(self._VA...
code_fim
hard
{ "lang": "python", "repo": "firsttris/plugin.video.sendtokodi", "path": "/lib/youtube_dl/extractor/uplynk.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @asyncached def rendered_contents(self): return 'Hello World' # TODO<|fim_prefix|># repo: encukou/galerka path: /galerka/views/index.py from galerka import views from galerka.view import GalerkaView from galerka.util import asyncached <|fim_middle|>class TitlePage(GalerkaView): vie...
code_fim
medium
{ "lang": "python", "repo": "encukou/galerka", "path": "/galerka/views/index.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: encukou/galerka path: /galerka/views/index.py from galerka import views from galerka.view import GalerkaView from galerka.util import asyncached <|fim_suffix|> view_packages = [views] @asyncached def title(self): return self.request.environ['galerka.site-title'] @asynca...
code_fim
easy
{ "lang": "python", "repo": "encukou/galerka", "path": "/galerka/views/index.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># remove default help command client.remove_command("help") # connect all cogs for cog in os.listdir("./cogs"): if cog.endswith(".py"): try: cog = f"cogs.{cog.replace('.py', '')}" client.load_extension(cog) except Exception as e: print(f"{cog} can n...
code_fim
medium
{ "lang": "python", "repo": "denizumuteser/Artificial_Stupidity", "path": "/bot.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: denizumuteser/Artificial_Stupidity path: /bot.py import discord, asyncio, time, os, random, platform from discord.ext import tasks, commands import config intents = discord.Intents.all() <|fim_suffix|># connect all cogs for cog in os.listdir("./cogs"): if cog.endswith(".py"): try: ...
code_fim
hard
{ "lang": "python", "repo": "denizumuteser/Artificial_Stupidity", "path": "/bot.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mitre-cyber-academy/2013-crypto-300 path: /src/decrypt.py import random import argparse def main(): parser = argparse.ArgumentParser( description='Decrypt a file using a key.') parser.add_argument('seed', help='The seed of the PRNG', type=int) parser.add_argument('cryptFile', help='The file...
code_fim
medium
{ "lang": "python", "repo": "mitre-cyber-academy/2013-crypto-300", "path": "/src/decrypt.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while True: currByte = args.cryptFile.read(1) if(currByte == ''): break byteVal = ord(currByte) randVal = random.getrandbits(8) outFile.write(chr(byteVal ^ randVal)) outFile.close() args.cryptFile.close() if __name__ == '__main__': main()<|fim_prefix|># repo: mitre-cyber-academy/2013-cry...
code_fim
medium
{ "lang": "python", "repo": "mitre-cyber-academy/2013-crypto-300", "path": "/src/decrypt.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhuyifan1993/learning_3d_shape_under_self-supervison path: /utils/dataset.py #!/usr/bin/env python # -*- coding:utf-8 -*- # author:Yifan Zhu # datetime:2020/10/1 23:52 # file: dataset.py # software: PyCharm import glob import logging import os import h5py import torch import yaml from torch.util...
code_fim
hard
{ "lang": "python", "repo": "zhuyifan1993/learning_3d_shape_under_self-supervison", "path": "/utils/dataset.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', self.dataset_folder, split) self.dirList = sorted(glob.glob(self.root_dir + '/*/{}/*'.format(category)), key=os.path.getmtime) def __len__(self): return len(self.dirList) def __getitem__(self,...
code_fim
hard
{ "lang": "python", "repo": "zhuyifan1993/learning_3d_shape_under_self-supervison", "path": "/utils/dataset.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return data def get_model_dict(self, idx): return self.shapes[idx] class KITTI360Dataset(data.Dataset): def __init__(self, dataset_folder, split, category, points_batch=200, evaluation=False): self.dataset_folder = dataset_folder self.split = split self.c...
code_fim
hard
{ "lang": "python", "repo": "zhuyifan1993/learning_3d_shape_under_self-supervison", "path": "/utils/dataset.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ plot cars as red points, events as blue points, and lines connecting cars to their targets :param carDict: :param eventDict: :return: image for gif """ fig, ax = plt.subplots() ax.set_title('time: {0}'.format(s.time)) for c in range(nc): ...
code_fim
hard
{ "lang": "python", "repo": "ChanaRoss/Thesis", "path": "/Simulation/Anticipitory/PlotResultsFromSimulationMIO_V1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for pickleName in pickleNames: lg = pickle.load(open('/home/chana/Documents/Thesis/FromGitFiles/Simulation/Anticipitory/PickleFiles/' + pickleName + '.p', 'rb')) simTime = 20 if 'Hungarian' in pickleName: events = lg['events'] gridSize = lg['gs'] ...
code_fim
hard
{ "lang": "python", "repo": "ChanaRoss/Thesis", "path": "/Simulation/Anticipitory/PlotResultsFromSimulationMIO_V1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ChanaRoss/Thesis path: /Simulation/Anticipitory/PlotResultsFromSimulationMIO_V1.py import numpy as np import pickle from matplotlib import pyplot as plt import pandas as pd import seaborn as sns from ipywidgets import interact import imageio # import my file in order to load state class from pick...
code_fim
hard
{ "lang": "python", "repo": "ChanaRoss/Thesis", "path": "/Simulation/Anticipitory/PlotResultsFromSimulationMIO_V1.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> filepath = os.path.join(month_dir, monthstr+".tsv") if os.path.isfile(filepath): result_json["temperatures"] = [] with open(filepath, "r") as f: for line in f: if not line.strip(): continue #ignore empty line datestr, min_temp, max_temp =...
code_fim
hard
{ "lang": "python", "repo": "nixeneko/temperature_website", "path": "/public/api/get_month_temps", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> firstday = datetime.date(date.year, date.month, 1) lastmonth = firstday + datetime.timedelta(days=-1) lastmonth_firstday = datetime.date(lastmonth.year, lastmonth.month, 1) return lastmonth_firstday def get_json(): result_json = {} form = cgi.FieldStorage() monthstr = datetim...
code_fim
hard
{ "lang": "python", "repo": "nixeneko/temperature_website", "path": "/public/api/get_month_temps", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nixeneko/temperature_website path: /public/api/get_month_temps #!/usr/bin/env python3 #coding: utf-8 import sys, json, datetime, os import re import cgi import cgitb #for debug #cgitb.enable() #for debug from settings.settings import TEMP_LOG_DIR #TEMP_LOG_DIR = "/home/pi/temperature/temp_log" ...
code_fim
hard
{ "lang": "python", "repo": "nixeneko/temperature_website", "path": "/public/api/get_month_temps", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kenrumer/scorekeeper path: /golf/migrations/0069_playerplugin_priority.py # -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-12-01 20:09 from __future__ import unicode_literals <|fim_suffix|> class Migration(migrations.Migration): dependencies = [ ('golf', '0068_auto_20171...
code_fim
medium
{ "lang": "python", "repo": "kenrumer/scorekeeper", "path": "/golf/migrations/0069_playerplugin_priority.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AddField( model_name='playerplugin', name='priority', field=models.IntegerField(default=-1, help_text='Highest priority will be listed first in selecting format', verbose_name='Priority'), ), ]<|fim_prefix|># repo: kenru...
code_fim
medium
{ "lang": "python", "repo": "kenrumer/scorekeeper", "path": "/golf/migrations/0069_playerplugin_priority.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: perfsonar/pscheduler path: /python-pscheduler/pscheduler/tests/psselect_test.py #!/usr/bin/env python3 """ test for the select module. """ import unittest from base_test import PschedTestBase from pscheduler.psselect import * class TestPsselect(PschedTestBase): <|fim_suffix|> self.asse...
code_fim
medium
{ "lang": "python", "repo": "perfsonar/pscheduler", "path": "/python-pscheduler/pscheduler/tests/psselect_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_except(self): self.assertEqual( polled_select([], [], [999], 2.0), ([], [], [999]) ) if __name__ == '__main__': unittest.main()<|fim_prefix|># repo: perfsonar/pscheduler path: /python-pscheduler/pscheduler/tests/psselect_test.py #!/usr/bin/env py...
code_fim
hard
{ "lang": "python", "repo": "perfsonar/pscheduler", "path": "/python-pscheduler/pscheduler/tests/psselect_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: yukinarit/pyserde path: /serde/se.py g["serde_custom_class_serializer"] = functools.partial( serde_custom_class_serializer, custom=serializer ) # Collect types used in the generated code. for typ in iter_types(cls): # When we encou...
code_fim
hard
{ "lang": "python", "repo": "yukinarit/pyserde", "path": "/serde/se.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yukinarit/pyserde path: /serde/se.py r): if f.skip_if: g[f.skip_if.name] = f.skip_if if f.serializer: g[f.serializer.name] = f.serializer add_func( scope, TO_ITER, render_to_tuple(cls, serializer, type_check, serialize_c...
code_fim
hard
{ "lang": "python", "repo": "yukinarit/pyserde", "path": "/serde/se.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@dataclass class SeField(Field[T]): """ Field class for serialization. """ @property def varname(self) -> str: """ Get variable name in the generated code e.g. obj.a.b """ var = getattr(self.parent, "varname", None) if self.parent else None if v...
code_fim
hard
{ "lang": "python", "repo": "yukinarit/pyserde", "path": "/serde/se.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: WesGtoX/python-selenium path: /class11/class11_06.py from time import sleep from selenium.webdriver import Firefox from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support.expected_conditions import alert_is_present <|fim_suffix|>sleep(2) browser.find_element_b...
code_fim
medium
{ "lang": "python", "repo": "WesGtoX/python-selenium", "path": "/class11/class11_06.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> url = 'https://selenium.dunossauro.live/aula_11_a.html' browser = Firefox() wdw = WebDriverWait(browser, 30) browser.get(url) sleep(2) browser.find_element_by_id('alertd').click() print('before wait alert...') alert = wdw.until(alert_is_present()) print('after wait alert.') alert.accept() # alerta...
code_fim
medium
{ "lang": "python", "repo": "WesGtoX/python-selenium", "path": "/class11/class11_06.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> with arg_scope([layers.batch_norm], is_training=False): s = preprocess(o) a = actors(s, noise=noise) q = critics(s, a) layers.summarize_tensors([s, *a, *q]) return a self.act = Function(act) def t...
code_fim
hard
{ "lang": "python", "repo": "Digits88/chi", "path": "/chi/rl/bdpg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Digits88/chi path: /chi/rl/bdpg.py """ This script implements the DDPG algorithm """ import tensorflow as tf from tensorflow.python.layers.utils import smart_cond from tensorflow.python.ops.variable_scope import get_local_variable import chi import tensortools as tt from chi import Experiment, e...
code_fim
hard
{ "lang": "python", "repo": "Digits88/chi", "path": "/chi/rl/bdpg.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ob = self.env.reset() done = False R = 0 self.act.initialize_local() idx = np.random.randint(0, self.heads) while not done: a = self.act(ob) a = a[idx] a = a if np.random.rand() > .1 else self.env.action_space.sample() ...
code_fim
hard
{ "lang": "python", "repo": "Digits88/chi", "path": "/chi/rl/bdpg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: robin8a/udemy_raspberry_machine_learning path: /Codes/Image_processing_projects/Project_5-Real_time_Human_Face_Recognition/5.5-Human_Face_Recognition-2.py # Real-time Human Face Recognition - 2 # Training using face images stored in human_faces folder # Testing using images captured from webcam ...
code_fim
hard
{ "lang": "python", "repo": "robin8a/udemy_raspberry_machine_learning", "path": "/Codes/Image_processing_projects/Project_5-Real_time_Human_Face_Recognition/5.5-Human_Face_Recognition-2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if matching[1] < 500: score = int( 100 * (1 - (matching[1])/350) ) string = str(score) + '% Matching Confidence' if score > 70: # Input the text string using cv2.putText #cv2.putText(image, string, orgin, font, fontScale, color, thickness) cv2.putText(image, string, (100, 100),...
code_fim
hard
{ "lang": "python", "repo": "robin8a/udemy_raspberry_machine_learning", "path": "/Codes/Image_processing_projects/Project_5-Real_time_Human_Face_Recognition/5.5-Human_Face_Recognition-2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> diff_bmp.GetPixelColor(0, 0).AssertIsRGB(0, 255, 255) diff_bmp.GetPixelColor(1, 1).AssertIsRGB(255, 0, 255) diff_bmp.GetPixelColor(0, 1).AssertIsRGB(255, 255, 0) diff_bmp.GetPixelColor(1, 0).AssertIsRGB(0, 0, 255) diff_bmp.GetPixelColor(0, 2).AssertIsRGB(255, 255, 255) diff_bmp.Ge...
code_fim
hard
{ "lang": "python", "repo": "PDi-Communication-Systems-Inc/lollipop_external_chromium_org", "path": "/tools/telemetry/telemetry/core/bitmap_unittest.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: PDi-Communication-Systems-Inc/lollipop_external_chromium_org path: /tools/telemetry/telemetry/core/bitmap_unittest.py # Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import tempfile ...
code_fim
hard
{ "lang": "python", "repo": "PDi-Communication-Systems-Inc/lollipop_external_chromium_org", "path": "/tools/telemetry/telemetry/core/bitmap_unittest.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> histogram = bmp.ColorHistogram() for i in xrange(3): self.assertEquals(sum(histogram[i]), bmp.width * bmp.height) self.assertEquals(histogram.r[1], 0) self.assertEquals(histogram.r[5], 2) self.assertEquals(histogram.r[8], 2) self.assertEquals(histogram.g[2], 0) self.asser...
code_fim
hard
{ "lang": "python", "repo": "PDi-Communication-Systems-Inc/lollipop_external_chromium_org", "path": "/tools/telemetry/telemetry/core/bitmap_unittest.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return super(MultiChoiceAnswer, cls).equals(answer, txt) class MultiSelectAnswer(Answer): value = models.ManyToManyField("QuestionOption", ) @classmethod def create(cls, interview, question, answer): raw_answer = answer if isinstance(answer, basestring): ...
code_fim
hard
{ "lang": "python", "repo": "unicefuganda/uSurvey", "path": "/survey/models/interviews.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: unicefuganda/uSurvey path: /survey/models/interviews.py # ignore the initial message if self.has_started and reply is None: return self.last_question.display_text(channel=channel, context=answers_context) # now confirm the question is applicable if next_...
code_fim
hard
{ "lang": "python", "repo": "unicefuganda/uSurvey", "path": "/survey/models/interviews.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: unicefuganda/uSurvey path: /survey/models/interviews.py query_args = [] return {'%s%s__%s' % (namespace, answer_key, validation_queries[cls.less_than.__name__]): test_args[1], '%s%s__%s' % (namespace, answer_key, validation_queri...
code_fim
hard
{ "lang": "python", "repo": "unicefuganda/uSurvey", "path": "/survey/models/interviews.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def minMax(df): """Center dataframe column ranges to [-1, 1]""" max_, min_ = df.max(axis=0), df.min(axis=0) midrange = (max_ + min_) / 2 half_range = (max_ - min_) / 2 return (df - midrange) / half_range @staticmethod def centerMeanAnd...
code_fim
hard
{ "lang": "python", "repo": "meereeum/vANNilla-tf", "path": "/classes/data.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: meereeum/vANNilla-tf path: /classes/data.py from __future__ import division import re import pandas as pd import numpy as np class DataIO: def __init__(self, df, target_label, norm_fn = None, clip_to = None, encode_n_minus_1 = False): """Data class with functions f...
code_fim
hard
{ "lang": "python", "repo": "meereeum/vANNilla-tf", "path": "/classes/data.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }