text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> def getEvent(self, index): event = self._events[index] if event[0] == "status": return StatusEvent(*event)<|fim_prefix|># repo: freeekanayaka/testlogging path: /testlogging/testing.py from collections import namedtuple from testtools.testresult.doubles import StreamResul...
code_fim
easy
{ "lang": "python", "repo": "freeekanayaka/testlogging", "path": "/testlogging/testing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DavidNjoroge/idea-pitch path: /app/main/request.py from ..models import Comment,User,Pitch,Category <|fim_suffix|> cats=Category.query.all() categories=[] for cat in cats: tem=str(cat) temp=tem.split(' ')[1] result=(temp,temp) categories.append(result) ...
code_fim
easy
{ "lang": "python", "repo": "DavidNjoroge/idea-pitch", "path": "/app/main/request.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cats=Category.query.all() categories=[] for cat in cats: tem=str(cat) temp=tem.split(' ')[1] result=(temp,temp) categories.append(result) # print (result) return id<|fim_prefix|># repo: DavidNjoroge/idea-pitch path: /app/main/request.py from ..model...
code_fim
easy
{ "lang": "python", "repo": "DavidNjoroge/idea-pitch", "path": "/app/main/request.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: blueyed/pytest path: /testing/deprecated_test.py import inspect import pytest from _pytest import deprecated from _pytest import nodes @pytest.mark.parametrize( "attribute", ( "Collector", "Module", "Function", "Instance", "Session", "Ite...
code_fim
hard
{ "lang": "python", "repo": "blueyed/pytest", "path": "/testing/deprecated_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> testdir.makepyfile( """ def test_foo(): pass """ ) assert_no_print_logs(testdir, ("--no-print-logs",)) @pytest.mark.filterwarnings("default") def test_noprintlogs_is_deprecated_ini(testdir): testdir.makeini( """ [pytest] log_pr...
code_fim
hard
{ "lang": "python", "repo": "blueyed/pytest", "path": "/testing/deprecated_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@pytest.mark.parametrize("junit_family", [None, "legacy", "xunit2"]) def test_warn_about_imminent_junit_family_default_change(testdir, junit_family): """Show a warning if junit_family is not defined and --junitxml is used (#6179)""" testdir.makepyfile( """ def test_foo(): ...
code_fim
hard
{ "lang": "python", "repo": "blueyed/pytest", "path": "/testing/deprecated_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def char2num(ch): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'.':-1}[ch] nums = map(char2num,s) point = 0 def toFloat(x,y): nonlocal point if y== -1: point = 1 return x if point==0: return x*10+y; else: point = point*10 return x+y/point return reduce(...
code_fim
hard
{ "lang": "python", "repo": "tuhongwei/python-exercise", "path": "/function/exercise1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># 利用map和reduce编写一个str2float函数,把字符串'123.456'转换成浮点数123.456 from functools import reduce def str2float(s): def char2num(ch): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[ch] def str2int(s): return reduce(lambda x,y: x*10+y,map(char2num,s)) try: n = s.index('.') s = s[:n] + ...
code_fim
medium
{ "lang": "python", "repo": "tuhongwei/python-exercise", "path": "/function/exercise1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tuhongwei/python-exercise path: /function/exercise1.py #!/user/bin/env python3 # -*- coding: utf-8 -*- # L1 = ['adam', 'LISA', 'barT']变成首字母大写 def normalize(name): return str.capitalize(name) L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize,L1)) print(L2) # 用lambda改写 L3 = list(map(lambda nam...
code_fim
hard
{ "lang": "python", "repo": "tuhongwei/python-exercise", "path": "/function/exercise1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: BeryJu/supervisr path: /supervisr/mail/apps.py """Supervisr Mail app config""" from supervisr.core.apps import SupervisrAppConfig <|fim_suffix|> """Supervisr Mail app config""" name = 'supervisr.mail' label = 'supervisr_mail' verbose_name = 'Supervisr Mail' navbar_enabled = ...
code_fim
easy
{ "lang": "python", "repo": "BeryJu/supervisr", "path": "/supervisr/mail/apps.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Supervisr Mail app config""" name = 'supervisr.mail' label = 'supervisr_mail' verbose_name = 'Supervisr Mail' navbar_enabled = lambda self, request: True title_modifier = lambda self, request: 'Mail'<|fim_prefix|># repo: BeryJu/supervisr path: /supervisr/mail/apps.py """Superv...
code_fim
easy
{ "lang": "python", "repo": "BeryJu/supervisr", "path": "/supervisr/mail/apps.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> name = 'supervisr.mail' label = 'supervisr_mail' verbose_name = 'Supervisr Mail' navbar_enabled = lambda self, request: True title_modifier = lambda self, request: 'Mail'<|fim_prefix|># repo: BeryJu/supervisr path: /supervisr/mail/apps.py """Supervisr Mail app config""" from supervis...
code_fim
medium
{ "lang": "python", "repo": "BeryJu/supervisr", "path": "/supervisr/mail/apps.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: UCLA-StarAI/LearnSDD path: /code/movieExperiments.py import sys, threading, time, math, random, os, re import acQueryMaker, sddQueryMaker from timeout_subprocess import run_with_timeout pos_words = [69,87,88,105,80,282,283,285,300,357,358,378,392,413,439,447,451,589,614,631,632,847,875,864,9...
code_fim
hard
{ "lang": "python", "repo": "UCLA-StarAI/LearnSDD", "path": "/code/movieExperiments.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> queries ={"pos":lambda param: to_count_ac_query(param,pos_words,threshold), "neg":lambda param: to_count_ac_query(param,neg_words,threshold), "group":lambda param: to_group_ac_query(param,pos_words,neg_words), "parity":lambda param: to_parity_ac_query(param), "conj":lambda ...
code_fim
hard
{ "lang": "python", "repo": "UCLA-StarAI/LearnSDD", "path": "/code/movieExperiments.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> from ACquery import queryAC start = time.time() query = queryfun(param) mid = time.time() probability, nbClauses , makefile_time, ac_time = run_with_timeout(queryAC, (modelpath, query, nbvars, fname,evidence), timeout, (float('nan'),float('nan'),float('nan'),float('nan'))) end = time.time() ...
code_fim
hard
{ "lang": "python", "repo": "UCLA-StarAI/LearnSDD", "path": "/code/movieExperiments.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>code('utf8') #for line in sys.stdin: # sys.stdout.write(urllib.unquote(line)) decoding uri<|fim_prefix|># repo: zendannyy/Test_Scripts path: /freq/uri_decode.py #!/usr/bin/python import urllib, sys, time #import urllib.parse #def urldecode(url): # return urllib.parse.unquote(url) url = input("Ente...
code_fim
medium
{ "lang": "python", "repo": "zendannyy/Test_Scripts", "path": "/freq/uri_decode.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>urllib.unquote(url).decode('utf8') print("Here is your output") print urllib.unquote(url).decode('utf8') #for line in sys.stdin: # sys.stdout.write(urllib.unquote(line)) decoding uri<|fim_prefix|># repo: zendannyy/Test_Scripts path: /freq/uri_decode.py #!/usr/bin/python import urllib, sys, time #impo...
code_fim
medium
{ "lang": "python", "repo": "zendannyy/Test_Scripts", "path": "/freq/uri_decode.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zendannyy/Test_Scripts path: /freq/uri_decode.py #!/usr/bin/python import urllib, sys, time #import urllib.parse #def urldecode(url): # r<|fim_suffix|>code('utf8') #for line in sys.stdin: # sys.stdout.write(urllib.unquote(line)) decoding uri<|fim_middle|>eturn urllib.parse.unquote(url) url...
code_fim
medium
{ "lang": "python", "repo": "zendannyy/Test_Scripts", "path": "/freq/uri_decode.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: masaomi/intro-machine-learning-training path: /python_notebooks/utils2.py )/wei[i][1]], color=dico_color[i],ls='--') idx = (y_pred == k) if idx.any(): ax[k].scatter(X[idx, 0], X[idx, 1], marker='o', c=[dico_color[h] for h in y[idx]], edgecolor='k'...
code_fim
hard
{ "lang": "python", "repo": "masaomi/intro-machine-learning-training", "path": "/python_notebooks/utils2.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: masaomi/intro-machine-learning-training path: /python_notebooks/utils2.py dth=4) plt.plot(fpr["macro"], tpr["macro"], label='macro-average ROC curve (area = {0:0.2f})' ''.format(roc_auc["macro"]), color='navy', linestyle=':', linew...
code_fim
hard
{ "lang": "python", "repo": "masaomi/intro-machine-learning-training", "path": "/python_notebooks/utils2.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> plot_contours(ax1, models, xx, yy,cmap=plt.cm.coolwarm, alpha=0.8) ax1.scatter(X0, X1, c=y, cmap=plt.cm.coolwarm, s=20, edgecolors='k') interc=models.intercept_ wei=models.coef_ for i in range(len(interc)): ax1.plot([xx.min(),xx.max()],[-(interc[i]+wei[i][0]*xx.min())/wei[i][1]...
code_fim
hard
{ "lang": "python", "repo": "masaomi/intro-machine-learning-training", "path": "/python_notebooks/utils2.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> """Builds a Servient with both the TD catalogue and the DNS-SD service enabled.""" servient = Servient( catalogue_port=find_free_port(), dnssd_enabled=True, dnssd_instance_name=Faker().pystr()) yield servient @tornado.gen.coroutine def shutdown(): yie...
code_fim
hard
{ "lang": "python", "repo": "agmangas/wot-py", "path": "/tests/wot/discovery/dnssd/conftest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: agmangas/wot-py path: /tests/wot/discovery/dnssd/conftest.py #!/usr/bin/env python # -*- coding: utf-8 -*- import collections import logging import socket import pytest import tornado.gen import tornado.ioloop from faker import Faker from tests.utils import find_free_port from wotpy.support im...
code_fim
hard
{ "lang": "python", "repo": "agmangas/wot-py", "path": "/tests/wot/discovery/dnssd/conftest.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> from test_rospy.srv import TransitiveSrvRequest m = TransitiveSrvRequest() # invoking serialize should be enough to expose issue. The bug # was that genmsg_py was failing to include the imports of # embedded messages. Because messages are flattened, this # c...
code_fim
hard
{ "lang": "python", "repo": "minxuanjun/basalt_class", "path": "/thirdparty/ros/ros_comm/test/test_rospy/test/unit/test_gensrv_py.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: minxuanjun/basalt_class path: /thirdparty/ros/ros_comm/test/test_rospy/test/unit/test_gensrv_py.py #!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or wit...
code_fim
hard
{ "lang": "python", "repo": "minxuanjun/basalt_class", "path": "/thirdparty/ros/ros_comm/test/test_rospy/test/unit/test_gensrv_py.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> ## #2133/2139 def test_test_rospy_TransitiveImport(self): from test_rospy.srv import TransitiveSrvRequest m = TransitiveSrvRequest() # invoking serialize should be enough to expose issue. The bug # was that genmsg_py was failing to include the imports of # e...
code_fim
hard
{ "lang": "python", "repo": "minxuanjun/basalt_class", "path": "/thirdparty/ros/ros_comm/test/test_rospy/test/unit/test_gensrv_py.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: jeffbass/imagezmq path: /examples/t2_recv_images_via_sub.py """t2_recv_images_via_sub.py -- receive images using PUB/SUB messaging pattern. This example program uses imagezmq to receive images from a matching program that is sending images. This test pair uses the PUB/SUB messaging pattern. 1....
code_fim
hard
{ "lang": "python", "repo": "jeffbass/imagezmq", "path": "/examples/t2_recv_images_via_sub.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>To end the programs, press Ctrl-C in the terminal window of each program. It is normal to get error messages when pressing Ctrl-C. There is no error trapping in this simple example program. """ import cv2 import imagezmq # Instantiate and provide the first publisher address image_hub = imagezmq.ImageHub...
code_fim
hard
{ "lang": "python", "repo": "jeffbass/imagezmq", "path": "/examples/t2_recv_images_via_sub.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> image properly. K3b, CDRecord and Burn 2.4.1u are reported to burn the anyboot image properly, without even needing to rename the file to *.iso. </p>""", 'cd' :"""<h1>Below are ISO CD Images</h1> <p>They are designed for installing Haiku from a compact disc.</p>"""}<|fim_prefix|># repo: jrabbit/haiku-fil...
code_fim
hard
{ "lang": "python", "repo": "jrabbit/haiku-files-redesign", "path": "/paragraphs.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jrabbit/haiku-files-redesign path: /paragraphs.py instructions = {'raw': """<h1>Below are Raw Images</h1> <p>They can be used with Qemu, written directly to a USB flash device, or mounted within Haiku.</p>""", 'vmware' : """<h1>Below are VMWare Images</h1> <p>These images can be used with either...
code_fim
hard
{ "lang": "python", "repo": "jrabbit/haiku-files-redesign", "path": "/paragraphs.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lcoghill/phyloboost path: /pipeline/purge-outliers.py from Bio import SeqIO import glob handle = open('outlier-results.txt', 'r') outliers = {} out_dir = '' <|fim_suffix|>## open the flagged alignment, remove any sequences that have the ## suspected misidentified TI values for key, val in out...
code_fim
hard
{ "lang": "python", "repo": "lcoghill/phyloboost", "path": "/pipeline/purge-outliers.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>## open the flagged alignment, remove any sequences that have the ## suspected misidentified TI values for key, val in outliers.items() : sequences = list(SeqIO.parse(open(key), 'fasta')) good_seqs = [] for s in sequences : ti = s.id.split("|")[1][2:] if ti not in val : ...
code_fim
hard
{ "lang": "python", "repo": "lcoghill/phyloboost", "path": "/pipeline/purge-outliers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: longfeide2008/anchore-engine path: /anchore_engine/services/policy_engine/engine/policy/formatting.py import datetime import uuid policy_line_format='{gate}:{trigger}:{action}' param_format='{name}={value} ' whitelist_format='{gate} {trigger}' def policy_json_to_txt(policy_json): """ Ta...
code_fim
hard
{ "lang": "python", "repo": "longfeide2008/anchore-engine", "path": "/anchore_engine/services/policy_engine/engine/policy/formatting.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return ret def policy_txt_to_json(policy_txt): """ Convert a newline delimited string (e.g. read from a file) to a policy json in v1_0 format :param policy_txt: single string of all lines with \n intact :return: json object of 1_0 version policy object """ gen_date = datetime...
code_fim
hard
{ "lang": "python", "repo": "longfeide2008/anchore-engine", "path": "/anchore_engine/services/policy_engine/engine/policy/formatting.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ret = [] if whitelist_json.get('version',None) == '1_0': for item in whitelist_json['items']: ret.append(whitelist_format.format(gate=item['gate'], trigger=item['trigger_id'])) return ret def policy_txt_to_json(policy_txt): """ Convert a newline delimited string ...
code_fim
hard
{ "lang": "python", "repo": "longfeide2008/anchore-engine", "path": "/anchore_engine/services/policy_engine/engine/policy/formatting.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> now = datetime.now() if self._start_time + timedelta(seconds=30) > now: return timedelta() return datetime.now() - self._start_time def _reset_start_time(self) -> None: self._start_time = datetime.now()<|fim_prefix|># repo: grapl-security/grapl path: /src/...
code_fim
hard
{ "lang": "python", "repo": "grapl-security/grapl", "path": "/src/python/grapl-plugin-sdk/grapl_plugin_sdk/analyzer/analyzer_context.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> @final @dataclass(slots=True) class AnalyzerContext: _analyzer_name: AnalyzerName _graph_client: GraphQueryProxyClient _start_time: datetime _allowed: dict[Uid, timedelta | None] def get_graph_client(self) -> GraphQueryProxyClient: return self._graph_client def get_remai...
code_fim
hard
{ "lang": "python", "repo": "grapl-security/grapl", "path": "/src/python/grapl-plugin-sdk/grapl_plugin_sdk/analyzer/analyzer_context.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: grapl-security/grapl path: /src/python/grapl-plugin-sdk/grapl_plugin_sdk/analyzer/analyzer_context.py from __future__ import annotations from dataclasses import dataclass from datetime import datetime, timedelta from typing import final <|fim_suffix|> return self._graph_client def g...
code_fim
hard
{ "lang": "python", "repo": "grapl-security/grapl", "path": "/src/python/grapl-plugin-sdk/grapl_plugin_sdk/analyzer/analyzer_context.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: igorcmag/tp_sim path: /tp_sim/envs/tp_sim_env.py import gym from collections import OrderedDict from gym.spaces import Discrete, Box, Dict, MultiBinary import pandas as pd import numpy as np import random import tp_sim.envs.naive # Auxiliary functions # Convert permit number to permit tuple def ...
code_fim
hard
{ "lang": "python", "repo": "igorcmag/tp_sim", "path": "/tp_sim/envs/tp_sim_env.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Update state self.state = update_state(self.book, self.last_trans, self.in_poss[0], self.credits[0], self.t + 1) # Increase timestamp by 1 self.t += 1 # Calculate reward reward = reward_eval(self.state) # Check if episode is done if self...
code_fim
hard
{ "lang": "python", "repo": "igorcmag/tp_sim", "path": "/tp_sim/envs/tp_sim_env.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>on__ = "2.0.3" __all__ = ["FfmpegQualityMetrics", "FfmpegQualityMetricsError", "__version__"]<|fim_prefix|># repo: morphline/ffmpeg-quality-metrics path: /ffmpeg_quality_metrics/__init__.py from .ffmpeg_quality_metrics import FfmpegQual<|fim_middle|>ityMetrics, FfmpegQualityMetricsError __versi
code_fim
easy
{ "lang": "python", "repo": "morphline/ffmpeg-quality-metrics", "path": "/ffmpeg_quality_metrics/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: morphline/ffmpeg-quality-metrics path: /ffmpeg_quality_metrics/__init__.py from .ffmpeg_quality_metrics import FfmpegQual<|fim_suffix|>s", "FfmpegQualityMetricsError", "__version__"]<|fim_middle|>ityMetrics, FfmpegQualityMetricsError __version__ = "2.0.3" __all__ = ["FfmpegQualityMetric
code_fim
medium
{ "lang": "python", "repo": "morphline/ffmpeg-quality-metrics", "path": "/ffmpeg_quality_metrics/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def temporary_file_path(self): return self.filepath class TestScoutSuiteParser(TestCase): def setup(self, testfile): file = MockFileObject(testfile) product_type = Product_Type(critical_product=True, key_product=False) product_type.save() test_type = Test...
code_fim
medium
{ "lang": "python", "repo": "TarlogicSecurity/django-DefectDojo", "path": "/dojo/unittests/tools/test_scoutsuite_parser.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>class TestScoutSuiteParser(TestCase): def setup(self, testfile): file = MockFileObject(testfile) product_type = Product_Type(critical_product=True, key_product=False) product_type.save() test_type = Test_Type(static_tool=True, dynamic_tool=False) test_type.save...
code_fim
medium
{ "lang": "python", "repo": "TarlogicSecurity/django-DefectDojo", "path": "/dojo/unittests/tools/test_scoutsuite_parser.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: TarlogicSecurity/django-DefectDojo path: /dojo/unittests/tools/test_scoutsuite_parser.py from django.test import TestCase from dojo.tools.scout_suite.parser import ScoutSuiteParser from django.utils import timezone from dojo.models import Test, Engagement, Product, Product_Type, Test_Type class...
code_fim
medium
{ "lang": "python", "repo": "TarlogicSecurity/django-DefectDojo", "path": "/dojo/unittests/tools/test_scoutsuite_parser.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> while queue != []: n = queue.pop(0) # for k in S[n]: for k in sorted(S[n]): if k not in postOrder and S[n][k] == 'green': postOrder.insert(postOrder.index(n), k) queue.append(k) return {n:(i + 1) for i, n in enumerate(postOrd...
code_fim
hard
{ "lang": "python", "repo": "Camiloasc1/AlgorithmsUNAL", "path": "/Udacity/Bridges.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def descendantsList(G, root): bfs = BFS(G, root) parent = bfs['parent'] # deep = bfs['deep'] descendants = {} for k in G: descendants[k] = [k] for k in parent: n = k # for _ in xrange(deep[n]): while parent[n] != None: n = paren...
code_fim
hard
{ "lang": "python", "repo": "Camiloasc1/AlgorithmsUNAL", "path": "/Udacity/Bridges.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Camiloasc1/AlgorithmsUNAL path: /Udacity/Bridges.py # Bridge Edges v4 # # Find the bridge edges in a graph given the # algorithm in lecture. # Complete the intermediate steps # - create_rooted_spanning_tree # - post_order # - number_of_descendants # - lowest_post_order # - highest_post_order...
code_fim
hard
{ "lang": "python", "repo": "Camiloasc1/AlgorithmsUNAL", "path": "/Udacity/Bridges.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def open(self, file_name, **keywords): BookReader.open(self, file_name, **keywords) self._load_from_file() def open_stream(self, file_stream, **keywords): if not hasattr(file_stream, "seek"): # python 2 # Hei zipfile in odfpy would do a seek ...
code_fim
hard
{ "lang": "python", "repo": "mobanbot/pyexcel-xlsxr", "path": "/pyexcel_xlsxr/xlsxr.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: mobanbot/pyexcel-xlsxr path: /pyexcel_xlsxr/xlsxr.py """ pyexcel_xlsxr.xlsxr ~~~~~~~~~~~~~~~~~~~ The lower level xlsx file format handler :copyright: (c) 2017 by Onni Software Ltd & its contributors :license: New BSD License """ from datetime import datetime, date, time from ...
code_fim
hard
{ "lang": "python", "repo": "mobanbot/pyexcel-xlsxr", "path": "/pyexcel_xlsxr/xlsxr.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return result def read_sheet(self, native_sheet): """read one native sheet""" sheet = XLSXSheet(native_sheet, **self._keywords) return {sheet.name: sheet.to_array()} def _load_from_memory(self): self._native_book = XLSXBookSet(self._file_stream) def _...
code_fim
hard
{ "lang": "python", "repo": "mobanbot/pyexcel-xlsxr", "path": "/pyexcel_xlsxr/xlsxr.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: wayne009007/sdcflows path: /sdcflows/workflows/fit/syn.py # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """ Estimating the susceptibility distortions without fieldmaps. .. testsetup:: >>> tmpdir = getfixture('tmpdir') >...
code_fim
hard
{ "lang": "python", "repo": "wayne009007/sdcflows", "path": "/sdcflows/workflows/fit/syn.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def _fixed_masks_arg(mask): """ Prepare the ``fixed_image_masks`` argument of SyN. Example ------- >>> _fixed_masks_arg("atlas_mask.nii.gz") ['NULL', 'atlas_mask.nii.gz'] """ return ["NULL", mask] def _extract_field(in_file, epi_meta): """ Extract the nonzero c...
code_fim
hard
{ "lang": "python", "repo": "wayne009007/sdcflows", "path": "/sdcflows/workflows/fit/syn.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # fmt: off workflow.connect([ (inputnode, transform_list, [("anat2epi_xfm", "in1"), ("std2anat_xfm", "in2")]), (inputnode, invert_t1w, [("anat_brain", "in_file"), (("epi_ref", _pop), "ref_file")]), (input...
code_fim
hard
{ "lang": "python", "repo": "wayne009007/sdcflows", "path": "/sdcflows/workflows/fit/syn.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: tpdn/python-winscard path: /winscard/__init__.py __author__ = 'tpdn' from ctypes import * <|fim_suffix|>from types import * from error import * from const import * from utils import * from reader import * from scard import *<|fim_middle|>scard_dll = WinDLL('winscard.dll')
code_fim
easy
{ "lang": "python", "repo": "tpdn/python-winscard", "path": "/winscard/__init__.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>from types import * from error import * from const import * from utils import * from reader import * from scard import *<|fim_prefix|># repo: tpdn/python-winscard path: /winscard/__init__.py __author__ = 'tpdn' from ctypes import * <|fim_middle|>scard_dll = WinDLL('winscard.dll')
code_fim
easy
{ "lang": "python", "repo": "tpdn/python-winscard", "path": "/winscard/__init__.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> class SQLDebugPanel(DebugPanel): ''' Panel that displays information about the SQL queries run while processing the request. ''' name = 'SQL' template = 'debug_toolbar/panels/sql.html' has_content = True def __init__(self, *args, **kwargs): super(SQLDebugPanel, se...
code_fim
hard
{ "lang": "python", "repo": "tschellenbach/django-debug-toolbar", "path": "/debug_toolbar/panels/sql.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: tschellenbach/django-debug-toolbar path: /debug_toolbar/panels/sql.py import re import uuid from django.db.backends import BaseDatabaseWrapper from django.utils.html import escape from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _, ungettext_laz...
code_fim
hard
{ "lang": "python", "repo": "tschellenbach/django-debug-toolbar", "path": "/debug_toolbar/panels/sql.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if trans_id: self._queries[i-1][1]['ends_trans'] = True # Should we check for duplicate queries? dupe_queries = None if _get_setting('SQL_DUPLICATES'): dupe_queries = self._get_dupe_queries() self.record_stats({ 'databas...
code_fim
hard
{ "lang": "python", "repo": "tschellenbach/django-debug-toolbar", "path": "/debug_toolbar/panels/sql.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ahmad31/Web_Flask_Cassandra path: /flask/lib/python2.7/site-packages/whoosh/lang/snowball/english.py f the algorithm. :type __step1a_suffixes: tuple :cvar __step1b_suffixes: Suffixes to be deleted in step 1b of the algorithm. :type __step1b_suffixes: tuple :cvar __step2_suffixes: ...
code_fim
hard
{ "lang": "python", "repo": "Ahmad31/Web_Flask_Cassandra", "path": "/flask/lib/python2.7/site-packages/whoosh/lang/snowball/english.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if len(r2) >= 1: r2 = "".join((r2[:-1], "e")) else: r2 = "" elif suffix == "entli": word = word[:-2] r1 = r1[:-2] ...
code_fim
hard
{ "lang": "python", "repo": "Ahmad31/Web_Flask_Cassandra", "path": "/flask/lib/python2.7/site-packages/whoosh/lang/snowball/english.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def is_addr_open(url, default_port=None): o = urlparse(url) return _is_service_open(o.hostname, o.port or default_port, socket.SOCK_STREAM) def check_tcp_service(name, addr, port): attempt = 1 trace = "checking TCP service %s on %s:%d..." % (name, addr, port) print("%s %d." % (trace...
code_fim
hard
{ "lang": "python", "repo": "GeneralCommission/kraken", "path": "/server/kraken/server/srvcheck.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> attempt = 1 trace = "checking TCP service %s on %s:%d..." % (name, addr, port) print("%s %d." % (trace, attempt)) while not _is_service_open(addr, port, socket.SOCK_STREAM): if attempt < 3: time.sleep(2) elif attempt < 10: time.sleep(5) else:...
code_fim
hard
{ "lang": "python", "repo": "GeneralCommission/kraken", "path": "/server/kraken/server/srvcheck.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: GeneralCommission/kraken path: /server/kraken/server/srvcheck.py # Copyright 2020 The Kraken Authors # # 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....
code_fim
hard
{ "lang": "python", "repo": "GeneralCommission/kraken", "path": "/server/kraken/server/srvcheck.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class NER_Dataset_for_Adapter(Dataset): def __init__(self, tokenizer, df, label_name): self.label_name = label_name self.mode = "train" self.positive_label, self.sentences, self.tags \ = get_training_label_ane_data_by_df_according_to_label_name_and_alias(df...
code_fim
hard
{ "lang": "python", "repo": "EasonC13/labs-cicero-classify-api", "path": "/utils/trainer/NER.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: EasonC13/labs-cicero-classify-api path: /utils/trainer/NER.py import pandas as pd import pymongo import numpy as np from core.config import ( MONGODB_URL,DATABASE_NAME, NER_LABEL_COLLECTION, LABEL_COLLECTION, LABEL_TRAIN_JOB_COLLECTION, CONFIG_COLLECTION, NER_TRAINER_DATA...
code_fim
hard
{ "lang": "python", "repo": "EasonC13/labs-cicero-classify-api", "path": "/utils/trainer/NER.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>for q, sg in result: print(str(q) + ":\t" + str(sg.subgroup_description)) # print WRAccQF().evaluate_from_dataset(data, Subgroup(target, []))<|fim_prefix|># repo: flemmerich/pysubgroup path: /tests/t_simple_dfs.py from timeit import default_timer as timer import pysubgroup as ps from pysubgroup.dat...
code_fim
medium
{ "lang": "python", "repo": "flemmerich/pysubgroup", "path": "/tests/t_simple_dfs.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: flemmerich/pysubgroup path: /tests/t_simple_dfs.py from timeit import default_timer as timer import pysubgroup as ps from pysubgroup.datasets import get_credit_data <|fim_suffix|>for q, sg in result: print(str(q) + ":\t" + str(sg.subgroup_description)) # print WRAccQF().evaluate_from_datas...
code_fim
hard
{ "lang": "python", "repo": "flemmerich/pysubgroup", "path": "/tests/t_simple_dfs.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tag, name = TextUtils.tag_and_namespace_from_text("{}") self.assertIsNotNone(tag) self.assertEqual("{}", tag) self.assertIsNone(name) tag, name = TextUtils.tag_and_namespace_from_text("{http://alicebot.org/2001/AIML}") self.assertIsNotNone(tag) self...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/test/programytest/utils/text/test_text.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: keiffster/program-y path: /test/programytest/utils/text/test_text.py import os import unittest from programy.utils.text.text import TextUtils ############################################################################# # class TextUtilsTests(unittest.TestCase): def test_get_tabs(self): ...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/test/programytest/utils/text/test_text.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tag, name = TextUtils.tag_and_namespace_from_text("text") self.assertIsNotNone(tag) self.assertEqual("text", tag) self.assertIsNone(name) tag, name = TextUtils.tag_and_namespace_from_text("{}") self.assertIsNotNone(tag) self.assertEqual("{}", tag) ...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/test/programytest/utils/text/test_text.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sx14/open-relation.pytorch path: /open_relation/dataset/lib/to_pascal_format.py import os import shutil import xml.dom.minidom def output_pascal_format(mid_data, output_path): # mid_data: # filename # width # height # depth # objects # -- xmin # -- ymin #...
code_fim
hard
{ "lang": "python", "repo": "sx14/open-relation.pytorch", "path": "/open_relation/dataset/lib/to_pascal_format.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s_truncated_node = des_xml_dom.createElement('truncated') des_truncated_node.appendChild(des_truncated) des_object_node.appendChild(des_truncated_node) # difficult des_object_difficult = des_xml_dom.createTextNode(str(org_object['difficult'])) des_object_difficult_n...
code_fim
hard
{ "lang": "python", "repo": "sx14/open-relation.pytorch", "path": "/open_relation/dataset/lib/to_pascal_format.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def _return_package_url(project_root, package): # See if there is a different index set. config_file = os.path.join(project_root, CONFIG_DIR, CONFIG_FILE) if os.path.exists(config_file): kwargs = load_yaml_file(config_file) index_url = kwargs['package_index'] logging.in...
code_fim
hard
{ "lang": "python", "repo": "CarmeLabs/carme", "path": "/src/cli/commands/package.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CarmeLabs/carme path: /src/cli/commands/package.py ''' Manage project packages ''' import os import sys import ruamel import logging import click from ...modules.packager import Packager from ...modules.gitwrapper import Git from ...modules.base import setup_logger, get_project_root, CONFIG_DIR...
code_fim
hard
{ "lang": "python", "repo": "CarmeLabs/carme", "path": "/src/cli/commands/package.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Some packages can be install multiple packages. if isinstance(package, ruamel.yaml.comments.CommentedSeq): # Loop through packages for x in package: logging.info('Multiple packages, installing: '+x) x_url = _return_package_url(project_root, str(x)) ...
code_fim
hard
{ "lang": "python", "repo": "CarmeLabs/carme", "path": "/src/cli/commands/package.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ghicheon/CVND---Image-Captioning-Project path: /model.py import torch import torch.nn as nn import torchvision.models as models import numpy as np class EncoderCNN(nn.Module): def __init__(self, embed_size): super(EncoderCNN, self).__init__() resnet = models.resne...
code_fim
hard
{ "lang": "python", "repo": "ghicheon/CVND---Image-Captioning-Project", "path": "/model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def forward(self, images): features = self.resnet(images) features = features.view(features.size(0), -1) features = self.embed(features) return features class DecoderRNN(nn.Module): def __init__(self, embed_size, hidden_size, vocab_size, num_layers=1):...
code_fim
medium
{ "lang": "python", "repo": "ghicheon/CVND---Image-Captioning-Project", "path": "/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def sample(self, inputs, states=None, max_len=20): " accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len) " #print("input.shape ", inputs.shape) # 1 1 512 ret=[] for i in range(max_len): ...
code_fim
hard
{ "lang": "python", "repo": "ghicheon/CVND---Image-Captioning-Project", "path": "/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: opnfv/fds path: /networking-odl/networking_odl/db/models.py # Copyright (c) 2015 OpenStack Foundation # 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. You may obtain # a copy of t...
code_fim
medium
{ "lang": "python", "repo": "opnfv/fds", "path": "/networking-odl/networking_odl/db/models.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> object_type = sa.Column(sa.String(36), nullable=False) object_uuid = sa.Column(sa.String(36), nullable=False) operation = sa.Column(sa.String(36), nullable=False) data = sa.Column(sa.PickleType, nullable=True) state = sa.Column(sa.Enum(odl_const.PENDING, odl_const.FAILED, ...
code_fim
medium
{ "lang": "python", "repo": "opnfv/fds", "path": "/networking-odl/networking_odl/db/models.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> __tablename__ = 'opendaylightjournal' object_type = sa.Column(sa.String(36), nullable=False) object_uuid = sa.Column(sa.String(36), nullable=False) operation = sa.Column(sa.String(36), nullable=False) data = sa.Column(sa.PickleType, nullable=True) state = sa.Column(sa.Enum(odl_con...
code_fim
hard
{ "lang": "python", "repo": "opnfv/fds", "path": "/networking-odl/networking_odl/db/models.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: leonardorccosta/Machine-Learning-Repo path: /Hidden Markov Model.py import pandas as pd import numpy as np #loads datasets X = pd.read_csv(path_X) # X is composed of 16 numerical and categorical features and 40 categorical sequential answers to questions # either A, B, C, D, E #Label ...
code_fim
hard
{ "lang": "python", "repo": "leonardorccosta/Machine-Learning-Repo", "path": "/Hidden Markov Model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#second approach remodel = hmm.GaussianHMM(n_components=5, covariance_type="full", n_iter=100) X_markov = entireData3.reshape(entireData3.shape[0], entireData3.shape[1]) X_markov2 = pd.DataFrame(X_markov) X_markov2 = X_markov2.values.flatten() lengths =[] #for j in range(np.size(X_markov,0)) for i ...
code_fim
hard
{ "lang": "python", "repo": "leonardorccosta/Machine-Learning-Repo", "path": "/Hidden Markov Model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>np.random.seed(9) #initializing the model modelmm = hmm.GaussianHMM(n_components=7, covariance_type="full") # transition weights, assuming they are known modelmm.startprob_ = np.array([0.001, 0.049, 0.19, 0.19, 0.19, 0.19, 0.19]) modelmm.transmat_ = np.array([[0.001, 0.049, 0.19, 0.19, 0.19, 0.19, ...
code_fim
hard
{ "lang": "python", "repo": "leonardorccosta/Machine-Learning-Repo", "path": "/Hidden Markov Model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: openstack/neutron path: /neutron/agent/dhcp_agent.py # Copyright 2015 OpenStack Foundation # # 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. You may obtain # a copy of the Licens...
code_fim
hard
{ "lang": "python", "repo": "openstack/neutron", "path": "/neutron/agent/dhcp_agent.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def main(): register_options(cfg.CONF) common_config.init(sys.argv[1:]) config.setup_logging() config.setup_privsep() server = neutron_service.Service.create( binary=constants.AGENT_PROCESS_DHCP, topic=topics.DHCP_AGENT, report_interval=cfg.CONF.AGENT.report_in...
code_fim
hard
{ "lang": "python", "repo": "openstack/neutron", "path": "/neutron/agent/dhcp_agent.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mobilityhouse/resin-release-tool path: /tests/integration/test_info.py from balena.exceptions import ApplicationNotFound from click.testing import CliRunner from resin_release_tool.cli import cli <|fim_suffix|> result = runner.invoke(cli, ["info"]) assert result.exit_code == 1 assert...
code_fim
hard
{ "lang": "python", "repo": "mobilityhouse/resin-release-tool", "path": "/tests/integration/test_info.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> monkeypatch.setenv("RESIN_TOKEN", "fake") monkeypatch.setenv("RESIN_APP", "123") monkeypatch.setenv("TEST", "true") assert os.getenv("RESIN_TOKEN") == "fake" assert os.getenv("RESIN_APP") == "123" runner = CliRunner() result = runner.invoke(cli, ["info"]) assert result.e...
code_fim
hard
{ "lang": "python", "repo": "mobilityhouse/resin-release-tool", "path": "/tests/integration/test_info.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rc14193/leetCodeSolns path: /DesignHashSet.py # https://leetcode.com/explore/learn/card/hash-table/182/practical-applications/1139/ # According to trial 160ms and 18.6mb # 78.74 % time and 92.01% space class MyHashSet: def __init__(self): """ Initialize your data structure h...
code_fim
medium
{ "lang": "python", "repo": "rc14193/leetCodeSolns", "path": "/DesignHashSet.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Returns true if this set contains the specified element """ y = key % 80 return key in self.arr[y] # Your MyHashSet object will be instantiated and called as such: # obj = MyHashSet() # obj.add(key) # obj.remove(key) # param_3 = obj.contains(key)<|fim_prefix|...
code_fim
hard
{ "lang": "python", "repo": "rc14193/leetCodeSolns", "path": "/DesignHashSet.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def item_outcomes(i): if i == 0: return "ERROR" elif i == 1: return "Extremely cursed item" elif i < 4: return "Cursed item" elif i < 8: return "Mostly useless item" elif i < 12: return "Mediocre item" elif i < 15: return "Good item" ...
code_fim
hard
{ "lang": "python", "repo": "moose705/moosebot", "path": "/outcome_tables.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: moose705/moosebot path: /outcome_tables.py def action_outcomes(i): if i == 0: return "ERROR" elif i == 1: return "Overwhelming failure" elif i < 4: return "Failure" elif i < 8: return "Failure, but not completely" elif i < 12: return "Ne...
code_fim
medium
{ "lang": "python", "repo": "moose705/moosebot", "path": "/outcome_tables.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> def testNotify(self): db=DataBuffer(2,9,1) mat=np.array([[1,1,1],[2,2,2]]).transpose() chunk=DataChunk(mat.shape[1],mat.shape[0],mat) db.notify(chunk) self.assertTrue((db.getBuff()==self.step1).all()) #step 2 mat=np.array([[3,3,3],[4,4,4]]).transpose() chunk=DataChunk(mat.shape[1],mat....
code_fim
hard
{ "lang": "python", "repo": "capitancambio/brainz", "path": "/brainz/data/DataBufferTest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def testNotify(self): db=DataBuffer(2,9,1) mat=np.array([[1,1,1],[2,2,2]]).transpose() chunk=DataChunk(mat.shape[1],mat.shape[0],mat) db.notify(chunk) self.assertTrue((db.getBuff()==self.step1).all()) #step 2 mat=np.array([[3,3,3],[4,4,4]]).transpose() chunk=DataChunk(mat.shape[1],mat.sha...
code_fim
hard
{ "lang": "python", "repo": "capitancambio/brainz", "path": "/brainz/data/DataBufferTest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: capitancambio/brainz path: /brainz/data/DataBufferTest.py import unittest from data.bus import DataBuffer,DataChunk import numpy as np class DataBufferTest(unittest.TestCase): """unit tests""" def __init__(self, name): super(DataBufferTest, self).__init__(name) self.name = name <|fim_suf...
code_fim
hard
{ "lang": "python", "repo": "capitancambio/brainz", "path": "/brainz/data/DataBufferTest.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zagaran/instant-census path: /app.py import sys import traceback import jinja2 from bson import ObjectId from flask import Flask, render_template, redirect, session, request, flash from flaskext.markdown import Markdown from mongolia import ID_KEY from raven.contrib.flask import Sentry from rave...
code_fim
hard
{ "lang": "python", "repo": "zagaran/instant-census", "path": "/app.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@app.route('/broken') def broken_page(): [][0] return {} @app.context_processor def inject_unhandled_users_count(): # hacky fix for when user is not logged in, do not inject unhandled users count if not NEEDS_REVIEW_COUNTS or not session or "admin_id" not in session: return {"unha...
code_fim
hard
{ "lang": "python", "repo": "zagaran/instant-census", "path": "/app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> [][0] return {} @app.context_processor def inject_unhandled_users_count(): # hacky fix for when user is not logged in, do not inject unhandled users count if not NEEDS_REVIEW_COUNTS or not session or "admin_id" not in session: return {"unhandled_user_count": ""} users_filter_k...
code_fim
hard
{ "lang": "python", "repo": "zagaran/instant-census", "path": "/app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: qfizik/tket path: /pytket/pytket/backends/status.py # Copyright 2019-2021 Cambridge Quantum Computing # # 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...
code_fim
hard
{ "lang": "python", "repo": "qfizik/tket", "path": "/pytket/pytket/backends/status.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }