text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> # Bit of a hack, parse the working directory to get the name name = os.path.basename(options.working_dir).split(".")[0].split("-")[-1] ini_filename = os.path.join(options.working_dir,options.ini_filename) with open(ini_filename,"w") as ifh: print>>ifh, "[feature]" print>>ifh,"BilingualNPL...
code_fim
medium
{ "lang": "python", "repo": "Pangeamt/nectm", "path": "/tools/mosesdecoder-master/scripts/training/bilingual-lm/create_blm_ini.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> parser.set_defaults( working_dir="working", n = "5", m = "4", ini_filename = "blm.ini", name = "comb", epochs = "10" ) options = parser.parse_args() if not os.path.exists(options.working_dir): os.makedirs(options.working_dir) # Bit of a hack, parse the working d...
code_fim
hard
{ "lang": "python", "repo": "Pangeamt/nectm", "path": "/tools/mosesdecoder-master/scripts/training/bilingual-lm/create_blm_ini.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: mike10004/smatterscripts path: /shelltools/makepairslist.py #!/usr/bin/env python # -*- coding: utf-8 -*- # # makepairslist.py # # (c) 2015 Mike Chaberski # # MIT License from __future__ import print_function import sys import csv from argparse import ArgumentParser import os.path def ma...
code_fim
hard
{ "lang": "python", "repo": "mike10004/smatterscripts", "path": "/shelltools/makepairslist.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def _convert_input(inputpath, args): if args.convert == 'mates': with open(inputpath, 'r') as ifile: reader = csv.reader(ifile) for row in reader: print(row[0]) print(row[1]) return 0 elif args.convert == 'csv': with o...
code_fim
hard
{ "lang": "python", "repo": "mike10004/smatterscripts", "path": "/shelltools/makepairslist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: quoth/zine path: /zine/parsers.py # -*- coding: utf-8 -*- """ zine.parsers ~~~~~~~~~~~~ This module holds the base parser information and the dict of default parsers. :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details. :license: BSD, see LICENSE for more...
code_fim
hard
{ "lang": "python", "repo": "quoth/zine", "path": "/zine/parsers.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def parse(self, input_data, reason): """Return a ZEML tree.""" raise NotImplementedError() class ZEMLParser(BaseParser): """The parser for the ZEML Markup language.""" name = lazy_gettext('Zine-Markup') def parse(self, input_data, reason): rv = parse_zeml(input_...
code_fim
hard
{ "lang": "python", "repo": "quoth/zine", "path": "/zine/parsers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.app = app def process(self, attributes, content, reason): """Called each time the element is encountered.""" raise NotImplementedError() class BaseParser(object): """Baseclass for all kinds of parsers.""" #: the localized name of the parser. name = None ...
code_fim
hard
{ "lang": "python", "repo": "quoth/zine", "path": "/zine/parsers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: MattHartshorn/otp-encryption path: /src/otp.py import otpcypher import keygenerator import helper import argparse import sys import actions # Run execution def main(args = None): parser = getParser() run(parser, parser.parse_args()) def run(parser, args): if (args.cmd == "enc" or ar...
code_fim
hard
{ "lang": "python", "repo": "MattHartshorn/otp-encryption", "path": "/src/otp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> parser = argparse.ArgumentParser(add_help=False) parser.add_argument("-h", "--help", help="Shows this help message or command help and exit", nargs="?", const="", default="", action=actions.HelpAction, metavar="CMD") subparsers = parser.add_subparsers(help="Commands", dest="cmd") setupCyph...
code_fim
hard
{ "lang": "python", "repo": "MattHartshorn/otp-encryption", "path": "/src/otp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print("error: {0}".format(content)) sys.exit(1) # Create parser def getParser(): parser = argparse.ArgumentParser(add_help=False) parser.add_argument("-h", "--help", help="Shows this help message or command help and exit", nargs="?", const="", default="", action=actions.HelpAction, metava...
code_fim
hard
{ "lang": "python", "repo": "MattHartshorn/otp-encryption", "path": "/src/otp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async def _async_set_unique_id(self, unique_id: str) -> None: """Set the unique ID of the config flow and abort if it already exists.""" await self.async_set_unique_id(unique_id) self._abort_if_unique_id_configured() @staticmethod @callback def async_get_options_fl...
code_fim
hard
{ "lang": "python", "repo": "home-assistant/core", "path": "/homeassistant/components/airvisual/config_flow.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async def async_step_geography_by_name( self, user_input: dict[str, str] | None = None ) -> FlowResult: """Handle the initialization of the cloud API based on city/state/country.""" if not user_input: return self.async_show_form( step_id="geograp...
code_fim
hard
{ "lang": "python", "repo": "home-assistant/core", "path": "/homeassistant/components/airvisual/config_flow.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: home-assistant/core path: /homeassistant/components/airvisual/config_flow.py """Define a config flow manager for AirVisual.""" from __future__ import annotations import asyncio from collections.abc import Mapping from typing import Any from pyairvisual.cloud_api import ( CloudAPI, Inval...
code_fim
hard
{ "lang": "python", "repo": "home-assistant/core", "path": "/homeassistant/components/airvisual/config_flow.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>talLayout_12.addWidget(self.label_11) self.txtTask = QtWidgets.QComboBox(self.tab) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeig...
code_fim
hard
{ "lang": "python", "repo": "Pual1003/easyfmri", "path": "/GUI/frmTAIntersecGUI.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ts.QCheckBox(self.tab) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.cbCond.sizePolicy().hasHeightForWidth()) sel...
code_fim
hard
{ "lang": "python", "repo": "Pual1003/easyfmri", "path": "/GUI/frmTAIntersecGUI.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Pual1003/easyfmri path: /GUI/frmTAIntersecGUI.py Width()) self.label_3.setSizePolicy(sizePolicy) self.label_3.setObjectName("label_3") self.horizontalLayout_7.addWidget(self.label_3) self.txtLabel = QtWidgets.QComboBox(self.tab) sizePolicy = QtWidgets.QSize...
code_fim
hard
{ "lang": "python", "repo": "Pual1003/easyfmri", "path": "/GUI/frmTAIntersecGUI.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: willjgit/Python-Driver-Communication path: /Usermode/x86UsermodeExample.py #CSGO Example (x86) from ctypes import * from sys import platform import os import keyboard dwEntityList = (0x4DBC5B4) dwForceAttack = (0x31ECB34) dwLocalPlayer = (0xDA244C) m_fFlags = (0x104) m_iCrosshairId = (0x11438) m...
code_fim
hard
{ "lang": "python", "repo": "willjgit/Python-Driver-Communication", "path": "/Usermode/x86UsermodeExample.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if entity_id > 0 and entity_id <= 64 and player_team != entity_team: Driver.WriteInt(modBase + dwForceAttack, 6) if keyboard.is_pressed('end'): exit(0)<|fim_prefix|># repo: willjgit/Python-Driver-Communication path: /Usermode/x86UsermodeExample.py #CSGO Example (x86) from cty...
code_fim
hard
{ "lang": "python", "repo": "willjgit/Python-Driver-Communication", "path": "/Usermode/x86UsermodeExample.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # main dirs fastmri_tmp_data_dir = tmpdir_factory.mktemp( "fastmri_test_tmp_data", numbered=False, ) logs_tmp_dir = tmpdir_factory.mktemp( "logs", numbered=False, ) checkpoints_tmp_dir = tmpdir_factory.mktemp( "checkpoints", numbered=...
code_fim
hard
{ "lang": "python", "repo": "nitindang/fastmri-reproducible-benchmark", "path": "/fastmri_recon/tests/conftest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return { 'fastmri_tmp_data_dir': str(fastmri_tmp_data_dir) + '/', 'logs_tmp_dir': str(tmpdir_factory.getbasetemp()) + '/', 'checkpoints_tmp_dir': str(tmpdir_factory.getbasetemp()) + '/', 'fastmri_tmp_singlecoil_train': str(fastmri_tmp_singlecoil_train) + '/', 'f...
code_fim
hard
{ "lang": "python", "repo": "nitindang/fastmri-reproducible-benchmark", "path": "/fastmri_recon/tests/conftest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nitindang/fastmri-reproducible-benchmark path: /fastmri_recon/tests/conftest.py import h5py import numpy as np import pytest from tqdm import tqdm K_shape_single_coil = (2, 640, 322) K_shape_multi_coil = (2, 15, 640, 322) I_shape = (2, 320, 320) contrast = 'CORPD_FBK' def create_data(filename,...
code_fim
hard
{ "lang": "python", "repo": "nitindang/fastmri-reproducible-benchmark", "path": "/fastmri_recon/tests/conftest.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Eadon999/bert path: /test.py import csv import pandas as pd import tensorflow as tf f = './data/domainc/train.tsv' <|fim_suffix|> """读取 tsv 的工具方法""" fw = open('./test.tsv', 'w', encoding='utf-8') with open(input_file, "r", encoding='utf-8') as f: reader = csv.reader(f, delim...
code_fim
medium
{ "lang": "python", "repo": "Eadon999/bert", "path": "/test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """读取 tsv 的工具方法""" fw = open('./test.tsv', 'w', encoding='utf-8') with open(input_file, "r", encoding='utf-8') as f: reader = csv.reader(f, delimiter="\t", quotechar=quotechar) lines = [] for line in reader: new = line[0].replace(' ', '\t') fw....
code_fim
medium
{ "lang": "python", "repo": "Eadon999/bert", "path": "/test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: SMHendryx/measureExtremums path: /tests_measureExtremums.py #code from http://stackoverflow.com/questions/31667070/max-distance-between-2-points-in-a-data-set-and-identifying-the-points from itertools import combinations from numpy import random from scipy.spatial.distance import pdist from sci...
code_fim
medium
{ "lang": "python", "repo": "SMHendryx/measureExtremums", "path": "/tests_measureExtremums.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#compute number of combinations: import functools from operator import mul # or mul=lambda x,y:x*y from fractions import Fraction def nCk(n,k): return int( functools.reduce(mul, (Fraction(n-i, i+1) for i in range(k)), 1) )<|fim_prefix|># repo: SMHendryx/measureExtremums path: /tests_measureExtremu...
code_fim
hard
{ "lang": "python", "repo": "SMHendryx/measureExtremums", "path": "/tests_measureExtremums.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def num_free_slots() -> int: return sum( 0 if slot["container"] else 1 for agent_slots in cluster_slots().values() for slot in agent_slots ) def run_command_set_priority(sleep: int = 30, slots: int = 1, priority: int = 0) -> str: command = [ "det", "-m...
code_fim
hard
{ "lang": "python", "repo": "determined-ai/determined", "path": "/e2e_tests/tests/cluster/utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: determined-ai/determined path: /e2e_tests/tests/cluster/utils.py import json import subprocess import time from datetime import datetime, timezone from typing import Any, Dict import pytest import requests from typing_extensions import Literal from determined.common import api from determined.c...
code_fim
hard
{ "lang": "python", "repo": "determined-ai/determined", "path": "/e2e_tests/tests/cluster/utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with temp_dir() as tmp_dir: injection_path = os.path.join(tmp_dir, "injection") with open(injection_path, "w", encoding="utf-8") as out: out.write("Hey there!") # Prepare file:// URL valid for both linux and windows injection_url = "f...
code_fim
hard
{ "lang": "python", "repo": "lorien/grab", "path": "/tests/test_xml_security.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lorien/grab path: /tests/test_xml_security.py # Reference: # https://lxml.de/FAQ.html#how-do-i-use-lxml-safely-as-a-web-service-endpoint import os import typing from io import BytesIO from typing import cast from lxml.etree import parse from tests.util import BaseTestCase, temp_dir <|fim_suff...
code_fim
hard
{ "lang": "python", "repo": "lorien/grab", "path": "/tests/test_xml_security.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ifyokoh/calculator path: /calculator/calculator.py import numbers class CalculatorError(Exception): """An exception class for Calculator, for errors""" class Calculator(): def __init__(self, value=0) -> None: <|fim_suffix|> self._check_operand(a) self.memory -= a ...
code_fim
hard
{ "lang": "python", "repo": "Ifyokoh/calculator", "path": "/calculator/calculator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Resets memory to zero.""" self.memory = 0 return self.memory def add(self, a: float) -> float: self._check_operand(a) self.memory += a return self.memory def subtract(self, a: float) -> float: self._check_operand(a) self.memory -...
code_fim
medium
{ "lang": "python", "repo": "Ifyokoh/calculator", "path": "/calculator/calculator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if a == 0: if b == 0: if c == 0: x.set_to(0) elif c == 1: x.set_to(0) elif b == 1: if c == 0: x.set_to(0) elif c == 1: if d == 0: x.set_to(0) elif d == 1: x.set_to(0) y.s...
code_fim
medium
{ "lang": "python", "repo": "briancabbott/GitHub-Repository-Downloader", "path": "/TypeScript/codeql-processor/code/Microsoft-DPU/TerpreT/models/test4.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: briancabbott/GitHub-Repository-Downloader path: /TypeScript/codeql-processor/code/Microsoft-DPU/TerpreT/models/test4.py @Runtime([2], 2) def Increment(x): return (x + 1) % 2 a = Param(2) b = Param(2) c = Param(2) d = Param(2)[2] <|fim_suffix|>if a == 0: if b == 0: if c == 0: ...
code_fim
medium
{ "lang": "python", "repo": "briancabbott/GitHub-Repository-Downloader", "path": "/TypeScript/codeql-processor/code/Microsoft-DPU/TerpreT/models/test4.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e conditioned by the existence of these # resources with proper matching structure. # # Nevertheless, this mechanism has been implemented so as to get easily adapted # to local configurations, by editing/adding this very same folder. # # Adding a custom function can be done simply as follows. # # In this ...
code_fim
hard
{ "lang": "python", "repo": "jhuguetn/pyxnat", "path": "/pyxnat/core/derivatives/__init__.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: jhuguetn/pyxnat path: /pyxnat/core/derivatives/__init__.py # Since pyxnat v1.2.1.0.post3, we introduced a mechanism to tune these objects # and allow adding custom functions for specific types of resources. # # For instance, one could now directly write: # # resource = experiment.resource('FREESU...
code_fim
hard
{ "lang": "python", "repo": "jhuguetn/pyxnat", "path": "/pyxnat/core/derivatives/__init__.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: dmbavkar/Sarcasm-Detection path: /src/visualize_hidden_units.py import keras.backend as K import numpy as np import matplotlib.pyplot as plt import os path = os.getcwd()[:os.getcwd().rfind('/')] def visualize_dense_units(activations, doc_index): with open(path + "/plots/html_visualizations/...
code_fim
hard
{ "lang": "python", "repo": "dmbavkar/Sarcasm-Detection", "path": "/src/visualize_hidden_units.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for unit in range(activations.shape[0]): this_max = max(activations[unit][:]) this_min = min(activations[unit][:]) for timestep in range(activations.shape[1]): activation = activations[unit][timestep] if activation < 0.0: ...
code_fim
hard
{ "lang": "python", "repo": "dmbavkar/Sarcasm-Detection", "path": "/src/visualize_hidden_units.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Get the name of the layers names = [layer.name for layer in model.layers] # Get a list of model inputs inp = model.input multiple_inputs = True # Wrap single inputs in a list if not isinstance(inp, list): inp = [inp] multiple_inputs = False # Get the la...
code_fim
hard
{ "lang": "python", "repo": "dmbavkar/Sarcasm-Detection", "path": "/src/visualize_hidden_units.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mikekeda/tools path: /gunicorn.conf.py """ Gunicorn config. """ bind = "unix:/u<|fim_suffix|>0 max_requests = 100 daemon = False umask = "91" user = "nginx" loglevel = "info"<|fim_middle|>wsgi/tools.sock" workers = 2 timeout = 3
code_fim
easy
{ "lang": "python", "repo": "mikekeda/tools", "path": "/gunicorn.conf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>k = "91" user = "nginx" loglevel = "info"<|fim_prefix|># repo: mikekeda/tools path: /gunicorn.conf.py """ Gunicorn config. """ bind = "unix:/uwsgi/tools.sock" workers = 2 timeout = 3<|fim_middle|>0 max_requests = 100 daemon = False umas
code_fim
easy
{ "lang": "python", "repo": "mikekeda/tools", "path": "/gunicorn.conf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>0 max_requests = 100 daemon = False umask = "91" user = "nginx" loglevel = "info"<|fim_prefix|># repo: mikekeda/tools path: /gunicorn.conf.py """ Gunicorn config. """ bind = "unix:/u<|fim_middle|>wsgi/tools.sock" workers = 2 timeout = 3
code_fim
easy
{ "lang": "python", "repo": "mikekeda/tools", "path": "/gunicorn.conf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: praekelt/vumi-freeswitch-esl path: /vxfreeswitch/originate.py # -*- test-case-name: vxfreeswitch.tests.test_originate -*- """ Utilities for creating originate FreeSwitch API calls. """ class OriginateMissingParameter(Exception): """ Raised if required originate parameters are missing. """ ...
code_fim
hard
{ "lang": "python", "repo": "praekelt/vumi-freeswitch-esl", "path": "/vxfreeswitch/originate.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.template = self.format_template(**kw) def format_call(self, from_addr, to_addr, uuid): """ Return a formatted originate call. :param str from_addr: The address the call is from. :param str to_addr: The address the call is to. :pa...
code_fim
hard
{ "lang": "python", "repo": "praekelt/vumi-freeswitch-esl", "path": "/vxfreeswitch/originate.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> :param str from_addr: The address the call is from. :param str to_addr: The address the call is to. :param str uuid: The UUID that the originated call should have. :returns str: A formatted originate call for passing to Fre...
code_fim
hard
{ "lang": "python", "repo": "praekelt/vumi-freeswitch-esl", "path": "/vxfreeswitch/originate.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: quic/aimet path: /TrainingExtensions/tensorflow/src/python/aimet_tensorflow/utils/op/embedding.py # /usr/bin/env python3.5 # -*- mode: python -*- # ============================================================================= # @@-COPYRIGHT-START-@@ # # Copyright (c) 2022, Qualcomm Innovation C...
code_fim
hard
{ "lang": "python", "repo": "quic/aimet", "path": "/TrainingExtensions/tensorflow/src/python/aimet_tensorflow/utils/op/embedding.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def _get_word_tensor(embedding_op: tf.Operation) -> tf.Tensor: """ Get word embedding op from embedding op :param embedding_op: associated op of embedding layer :return: word embedding tensor """ assert embedding_op.type == 'AddV2' ...
code_fim
hard
{ "lang": "python", "repo": "quic/aimet", "path": "/TrainingExtensions/tensorflow/src/python/aimet_tensorflow/utils/op/embedding.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: bgoonz/UsefulResourceRepo2.0 path: /GIT-USERS/amitness/ML-From-Scratch/mlfromscratch/examples/linear_discriminant_analysis.py from __future__ import print_function from sklearn import datasets import matplotlib.pyplot as plt import numpy as np from mlfromscratch.supervised_learning import LDA fr...
code_fim
hard
{ "lang": "python", "repo": "bgoonz/UsefulResourceRepo2.0", "path": "/GIT-USERS/amitness/ML-From-Scratch/mlfromscratch/examples/linear_discriminant_analysis.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> accuracy = accuracy_score(y_test, y_pred) print("Accuracy:", accuracy) Plot().plot_in_2d(X_test, y_pred, title="LDA", accuracy=accuracy) if __name__ == "__main__": main()<|fim_prefix|># repo: bgoonz/UsefulResourceRepo2.0 path: /GIT-USERS/amitness/ML-From-Scratch/mlfromscratch/examples...
code_fim
hard
{ "lang": "python", "repo": "bgoonz/UsefulResourceRepo2.0", "path": "/GIT-USERS/amitness/ML-From-Scratch/mlfromscratch/examples/linear_discriminant_analysis.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: isawzz/vid path: /pylibs/humpack/code/tests/test_packing.py from humpack import pack, unpack, json_unpack, json_pack from _util_test import get_tdict def test_pack_tdict(): <|fim_suffix|>def test_json_pack_transactionable(): data = get_tdict() s = json_pack(data) assert repr(json_unpack(s...
code_fim
medium
{ "lang": "python", "repo": "isawzz/vid", "path": "/pylibs/humpack/code/tests/test_packing.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data = get_tdict() rec = unpack(pack(data)) assert repr(data) == repr(rec) def test_json_pack_transactionable(): data = get_tdict() s = json_pack(data) assert repr(json_unpack(s)) == repr(data) data.begin() data[1234] = 'element' assert 1234 in data assert 'element' == data[1234] da...
code_fim
medium
{ "lang": "python", "repo": "isawzz/vid", "path": "/pylibs/humpack/code/tests/test_packing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print(xml_str) handler = DefaultSaxHandler() parser = ParserCreate() parser.StartElementHandler = handler.start_element parser.EndElementHandler = handler.end_element parser.CharacterDataHandler = handler.char_data parser.Parse(xml_str) return {'city':handler.city,'forecast...
code_fim
hard
{ "lang": "python", "repo": "bujige/Python-practice", "path": "/first/urllib-practice.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def parseXml(xml_str): print(xml_str) handler = DefaultSaxHandler() parser = ParserCreate() parser.StartElementHandler = handler.start_element parser.EndElementHandler = handler.end_element parser.CharacterDataHandler = handler.char_data parser.Parse(xml_str) return {'city'...
code_fim
hard
{ "lang": "python", "repo": "bujige/Python-practice", "path": "/first/urllib-practice.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bujige/Python-practice path: /first/urllib-practice.py from urllib import request, parse import json # with request.urlopen('https://api.douban.com/v2/book/2129650') as f: # data = f.read() # print('Status:', f.status, f.reason) # for k, v in f.getheaders(): # print('%s: %s'...
code_fim
hard
{ "lang": "python", "repo": "bujige/Python-practice", "path": "/first/urllib-practice.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> url_file = file(url.split('/')[-1],'wb+') threadLock = threading.Lock() threads = [] for tName in range(1, threadnum + 1): if tName < threadnum: scope = "%d-%d" %(current,len * tName - 1) current = len * tName elif tName == threadnum: ...
code_fim
hard
{ "lang": "python", "repo": "ywang412/homework-arch-4", "path": "/3/liquanzhou/downloader.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if tName < threadnum: scope = "%d-%d" %(current,len * tName - 1) current = len * tName elif tName == threadnum: if current != size: scope = "%d-%d" %(current,size) else: scope = "%d-" %(current - 1) pri...
code_fim
hard
{ "lang": "python", "repo": "ywang412/homework-arch-4", "path": "/3/liquanzhou/downloader.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ywang412/homework-arch-4 path: /3/liquanzhou/downloader.py #!/usr/bin/env python #encoding:utf8 import urllib2 import threading class myThread(threading.Thread): def __init__(self, url_file, scope, url): threading.Thread.__init__(self) self.url_file = url_file self....
code_fim
medium
{ "lang": "python", "repo": "ywang412/homework-arch-4", "path": "/3/liquanzhou/downloader.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Shirshakk-P/ControlSystems path: /Design Study Assignment 1/systemSim.py import simpy import random import statistics import numpy as np import matplotlib matplotlib.use('TKAgg') import matplotlib.pyplot as plt import import_ipynb import massSpringParam as P #from systemDynamics import s...
code_fim
medium
{ "lang": "python", "repo": "Shirshakk-P/ControlSystems", "path": "/Design Study Assignment 1/systemSim.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#instantiate the simulation plots and ainmation #dataPlot = dataPlotter() animation = massSpringAnimation() t = P.t_start #y = system.h() while t < P.t_end: r = reference.square(t) d = disturbance.step(t) n = noise.random(t) u = reference.sawtooth(t) states = np.array([[d],...
code_fim
hard
{ "lang": "python", "repo": "Shirshakk-P/ControlSystems", "path": "/Design Study Assignment 1/systemSim.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> app.add_template_filter(minify_filter, name="minify")<|fim_prefix|># repo: daboross/dabo.guru path: /content/util/htmlmin_filter.py from markupsafe import Markup <|fim_middle|>import htmlmin def minify_filter(s): return Markup(htmlmin.minify(str(s), remove_comments=True, remove_empty_space=Tru...
code_fim
medium
{ "lang": "python", "repo": "daboross/dabo.guru", "path": "/content/util/htmlmin_filter.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: daboross/dabo.guru path: /content/util/htmlmin_filter.py from markupsafe import Markup import htmlmin def minify_filter(s): return Markup(htmlmin.minify(str(s), remove_comments=True, remove_empty_space=True)) <|fim_suffix|> app.add_template_filter(minify_filter, name="minify")<|fim_mi...
code_fim
easy
{ "lang": "python", "repo": "daboross/dabo.guru", "path": "/content/util/htmlmin_filter.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hanouticelina/sub-clus path: /code/fuzzy_cmeans.py import numpy as np import pandas as pd from scipy.spatial.distance import cdist import math import time from datetime import datetime as dt import matplotlib.pyplot as plt from iads_a import kmoyennes as km def _memberships(dist,data,fuzz): ...
code_fim
hard
{ "lang": "python", "repo": "hanouticelina/sub-clus", "path": "/code/fuzzy_cmeans.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def _compute_loss(data, memberships, centroids, fuzz): dist_data_centroids = cdist(data, centroids, metric="euclidean") ** 2 return ((memberships ** fuzz) * dist_data_centroids).sum() def memberships(data, centroids, f): distances = cdist(data.values, centroids.values, metric="euclidean") ...
code_fim
hard
{ "lang": "python", "repo": "hanouticelina/sub-clus", "path": "/code/fuzzy_cmeans.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ITISFoundation/osparc-simcore path: /packages/postgres-database/src/simcore_postgres_database/sidecar_models.py """ Facade for sidecar service Facade to direct access to models in the database by the sidecar service <|fim_suffix|>__all__ = ( "comp_tasks", "comp_pipeline", "...
code_fim
medium
{ "lang": "python", "repo": "ITISFoundation/osparc-simcore", "path": "/packages/postgres-database/src/simcore_postgres_database/sidecar_models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>__all__ = ( "comp_tasks", "comp_pipeline", "comp_pipeline", "StateType", ) # nopycln: file<|fim_prefix|># repo: ITISFoundation/osparc-simcore path: /packages/postgres-database/src/simcore_postgres_database/sidecar_models.py """ Facade for sidecar service Facade to direct access to mo...
code_fim
medium
{ "lang": "python", "repo": "ITISFoundation/osparc-simcore", "path": "/packages/postgres-database/src/simcore_postgres_database/sidecar_models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gstearmit/django-crm.20 path: /crm/wsgi.py import os import sys from django.core.wsgi import get_wsgi_application <|fim_suffix|>application = get_wsgi_application()<|fim_middle|>PROJECT_DIR = os.path.abspath(__file__) sys.path.append(PROJECT_DIR) os.environ.setdefault("DJANGO_SETTINGS_MODULE"...
code_fim
medium
{ "lang": "python", "repo": "gstearmit/django-crm.20", "path": "/crm/wsgi.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crm.settings") application = get_wsgi_application()<|fim_prefix|># repo: gstearmit/django-crm.20 path: /crm/wsgi.py import os import sys from django.core.wsgi import get_wsgi_application <|fim_middle|> PROJECT_DIR = os.path.abspath(__file__) sys.path.app...
code_fim
medium
{ "lang": "python", "repo": "gstearmit/django-crm.20", "path": "/crm/wsgi.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crm.settings") application = get_wsgi_application()<|fim_prefix|># repo: gstearmit/django-crm.20 path: /crm/wsgi.py import os import sys from django.core.wsgi import get_wsgi_application <|fim_middle|> PROJECT_DIR = os.path.abspath(__file__) sys.path.ap...
code_fim
medium
{ "lang": "python", "repo": "gstearmit/django-crm.20", "path": "/crm/wsgi.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: euirim/clone-wars-gan path: /preprocess.py from tqdm import tqdm import ffmpeg import os from fractions import Fraction import uuid INPUT_DIR = "/home/euirim/Downloads/SWTCW" # Input directory to read episodes from OUTPUT_DIR = "./data/full" # Output directory to write frames to START_CUT = 20...
code_fim
hard
{ "lang": "python", "repo": "euirim/clone-wars-gan", "path": "/preprocess.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Generate the `VideoData` object for the file name and the file name template for the output frames. tag = os.path.splitext(os.path.basename(file_name))[0] tag = tag.replace(" ", "_") vd = VideoData.get(file_name) start_cut_frames = int(vd.fps * start) end_cut_frames = int(vd.fps ...
code_fim
hard
{ "lang": "python", "repo": "euirim/clone-wars-gan", "path": "/preprocess.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HenShalom/neo4j-table-to-graph path: /modelLoader/intilizer.py import os, json from modelLoader.vertex import Vertex from modelLoader.edge import Edge def data_loader(models_path): <|fim_suffix|> def extract_data(model): vertices = [] edges = [] for vertex in model['vertices']: ...
code_fim
hard
{ "lang": "python", "repo": "HenShalom/neo4j-table-to-graph", "path": "/modelLoader/intilizer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def extract_data(model): vertices = [] edges = [] for vertex in model['vertices']: vertices.append(Vertex(vertex)) for edge in vertex['edges']: edges.append(Edge(edge)) if edge['label'] == "identifies": vertices.append(Vertex(edge['verte...
code_fim
hard
{ "lang": "python", "repo": "HenShalom/neo4j-table-to-graph", "path": "/modelLoader/intilizer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert os.path.exists('./input/x.txt') is True assert f.full_path in result.output def test_check_with_rm(mocker): f = File("./x.txt", 'x.txt') i = mocker.MagicMock() i.fetch_indexed_file.return_value = f mocked_indexer = mocker.patch('hashdex.cli.Indexer') mocked_in...
code_fim
hard
{ "lang": "python", "repo": "jeff-99/hashdex", "path": "/tests/test_cli.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jeff-99/hashdex path: /tests/test_cli.py #!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `hashdex` package.""" import os import re from click.testing import CliRunner from hashdex.cli import cli from hashdex.files import File, DuplicateFileResult def test_main_command_shows_help()...
code_fim
hard
{ "lang": "python", "repo": "jeff-99/hashdex", "path": "/tests/test_cli.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_duplicates_with_non_equal_duplicates(mocker): runner = CliRunner() r1 = DuplicateFileResult() r1.add_diff("x") i = mocker.MagicMock() i.get_duplicates.return_value = [r1] mocked_indexer = mocker.patch('hashdex.cli.Indexer') mocked_indexer.return_value = i with...
code_fim
hard
{ "lang": "python", "repo": "jeff-99/hashdex", "path": "/tests/test_cli.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> f_lab = [] if alpha.shape[1] == 1: f_lab = ['$k_d$'] else: f_lab = ['$K_f^p$', '$S$'] labels = ['$x$', '$a_x$'] plot_cross_data(0, x, [dist[:,insertion_dir], d_act[:,insertion_dir]], ax, labels, ylim=[-1,1],ls = ['-', '-', '--', ':']) alpha *= -1 labels = [...
code_fim
hard
{ "lang": "python", "repo": "cambel/ur3-tools", "path": "/plot/sac_plot_detail_p14.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cambel/ur3-tools path: /plot/sac_plot_detail_p14.py from plotter_utils import smooth, reformat_large_tick_values import matplotlib.ticker as tick import matplotlib.cm as cm import matplotlib.pyplot as plt import numpy as np import matplotlib matplotlib.use('TkAgg') filename = '/home/cambel/dev/...
code_fim
hard
{ "lang": "python", "repo": "cambel/ur3-tools", "path": "/plot/sac_plot_detail_p14.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tazjel/comparable-text-miner path: /split_processed_wikipedia_file.py # coding: utf-8 # Author: Motaz Saad import sys, os from os.path import basename import logging logging.basicConfig(format='%(levelname)s : %(asctime)s : %(message)s', level=logging.INFO) x_seperator = '\nXXXXXXX\n' # defin...
code_fim
hard
{ "lang": "python", "repo": "tazjel/comparable-text-miner", "path": "/split_processed_wikipedia_file.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def usage(): print 'Usage: ', sys.argv[0], '<corpus file> <number of parts> <output path>' ################################################################## if len(sys.argv) < 3: usage(); sys.exit(2) import imp tp = imp.load_source('textpro', 'textpro.py') def main(argv): corpus_file = sys.argv[...
code_fim
medium
{ "lang": "python", "repo": "tazjel/comparable-text-miner", "path": "/split_processed_wikipedia_file.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: pgmpy/pgmpy path: /pgmpy/utils/sets.py from collections.abc import Iterable from itertools import combinations, chain def _variable_or_iterable_to_set(x): """ Convert variable, set, or iterable x to a frozenset. If x is None, returns the empty set. Parameters --------- ...
code_fim
medium
{ "lang": "python", "repo": "pgmpy/pgmpy", "path": "/pgmpy/utils/sets.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def _powerset(iterable): """ https://docs.python.org/3/library/itertools.html#recipes powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) Parameters ---------- iterable: any iterable Returns ------- chain: a generator of the powerset of the input """...
code_fim
hard
{ "lang": "python", "repo": "pgmpy/pgmpy", "path": "/pgmpy/utils/sets.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>CURRENCY_PAIRS = ["CADJPY", "EURUSD", "GBPUSD", "USDJPY", "USDCHF"] for currency_pair in CURRENCY_PAIRS: ticks = MT5.copy_rates_from_pos(currency_pair, MT5.TIMEFRAME_M5, 0, 99999) df = pd.DataFrame(ticks) df = df.drop(columns=["real_volume", "spread", "tick_volume"]) df["time"] = pd.to_datetime(df["ti...
code_fim
hard
{ "lang": "python", "repo": "joegeto/ForEx-1", "path": "/core/data_gathering.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: joegeto/ForEx-1 path: /core/data_gathering.py import MetaTrader5 as MT5 from tqdm import tqdm import pandas as pd from pathlib import Path from datetime import datetime import numpy as np import os <|fim_suffix|>if not MT5.initialize(): print("initialize() failed") MT5.shutdown() CURRENCY_PA...
code_fim
hard
{ "lang": "python", "repo": "joegeto/ForEx-1", "path": "/core/data_gathering.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if not MT5.initialize(): print("initialize() failed") MT5.shutdown() CURRENCY_PAIRS = ["CADJPY", "EURUSD", "GBPUSD", "USDJPY", "USDCHF"] for currency_pair in CURRENCY_PAIRS: ticks = MT5.copy_rates_from_pos(currency_pair, MT5.TIMEFRAME_M5, 0, 99999) df = pd.DataFrame(ticks) df = df.drop(columns=["rea...
code_fim
medium
{ "lang": "python", "repo": "joegeto/ForEx-1", "path": "/core/data_gathering.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Eastwu5788/heron path: /app/modules/user/follow_share_list.py from flask import g from . import user from app.modules.base.base_handler import BaseHandler from app.modules.vendor.pre_request.flask import filter_params from app.modules.vendor.pre_request.filter_rules import Rule from app.models....
code_fim
medium
{ "lang": "python", "repo": "Eastwu5788/heron", "path": "/app/modules/user/follow_share_list.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> user_id = g.account["user_id"] follow_user_id_list = FollowModel.query_follow_user_list(user_id) follow_user_id_list = list(set(follow_user_id_list)) share_model_list = ShareModel.query_user_share_list(follow_user_id_list, user_id, 20, params["last_id"], 0) share_...
code_fim
hard
{ "lang": "python", "repo": "Eastwu5788/heron", "path": "/app/modules/user/follow_share_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ht = Hashtable() ht.add("abd", 10) actual = ht.contains("abd") excepted = True assert actual == excepted def test_contains2(): ht = Hashtable() ht.add("abd", 10) actual = ht.contains("s") excepted = False assert actual == excepted<|fim_prefix|># repo: abdu-zeyad/d...
code_fim
medium
{ "lang": "python", "repo": "abdu-zeyad/data-structures-and-algorithms", "path": "/python/tests/test_hashtable.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abdu-zeyad/data-structures-and-algorithms path: /python/tests/test_hashtable.py from python.code_challenges.hashtable.hashtable.hash_table import Hashtable <|fim_suffix|>def test_add(): ht = Hashtable() actual = ht.add("abd", 10).head.value excepted = ["abd", 10] assert actual =...
code_fim
medium
{ "lang": "python", "repo": "abdu-zeyad/data-structures-and-algorithms", "path": "/python/tests/test_hashtable.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_get(): ht = Hashtable() ht.add("abd", 10) actual = ht.get("abd") excepted = 10 assert actual == excepted def test_contains(): ht = Hashtable() ht.add("abd", 10) actual = ht.contains("abd") excepted = True assert actual == excepted def test_contains2(): ...
code_fim
hard
{ "lang": "python", "repo": "abdu-zeyad/data-structures-and-algorithms", "path": "/python/tests/test_hashtable.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pass class ExampleClassForOrder: async def d_asyncmethod(self): pass def a_syncmethod(self): pass async def c_asyncmethod(self): pass def b_syncmethod(self): pass class ExampleInheritedSubclass(ExampleClassForOrder): def a_syncmethod(self)...
code_fim
medium
{ "lang": "python", "repo": "python-trio/sphinxcontrib-trio", "path": "/tests/test-docs-source/autodoc_examples.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: python-trio/sphinxcontrib-trio path: /tests/test-docs-source/autodoc_examples.py import abc def basic(): pass async def asyncfn(x): pass def gen(): yield # Classes are a bit complicated for autodoc, because: # - there's the :members: option # - how you access the attributes mat...
code_fim
hard
{ "lang": "python", "repo": "python-trio/sphinxcontrib-trio", "path": "/tests/test-docs-source/autodoc_examples.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class ExampleInheritedSubclass(ExampleClassForOrder): def a_syncmethod(self): pass async def c_asyncmethod(self): pass async def autosummary_me(): pass<|fim_prefix|># repo: python-trio/sphinxcontrib-trio path: /tests/test-docs-source/autodoc_examples.py import abc def bas...
code_fim
hard
{ "lang": "python", "repo": "python-trio/sphinxcontrib-trio", "path": "/tests/test-docs-source/autodoc_examples.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: llnw/salt-eventsd path: /salteventsd/timer.py ''' A timer class that starts with an initial value and fires an event to the reference given every time the timer-interval is reached. While running, the timer-counter be be reset to start from the beginning. ''' import threading import time import ...
code_fim
hard
{ "lang": "python", "repo": "llnw/salt-eventsd", "path": "/salteventsd/timer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ''' stop the timer ''' self.running = False def is_running(self): ''' check if the timer is still running ''' return self.running<|fim_prefix|># repo: llnw/salt-eventsd path: /salteventsd/timer.py ''' A timer class that starts with an i...
code_fim
hard
{ "lang": "python", "repo": "llnw/salt-eventsd", "path": "/salteventsd/timer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: doccano/doccano path: /backend/api/migrations/0020_auto_20211221_1415.py # Generated by Django 3.2.8 on 2021-12-21 14:15 import django.db.models.deletion from django.db import migrations, models from label_types.models import generate_random_hex_color class Migration(migrations.Migration): ...
code_fim
hard
{ "lang": "python", "repo": "doccano/doccano", "path": "/backend/api/migrations/0020_auto_20211221_1415.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ("y", "y"), ("z", "z"), ], max_length=1, null=True, ), ), ("background_color", models.CharField(default=generate_random_hex_color, max_length=7)), ...
code_fim
hard
{ "lang": "python", "repo": "doccano/doccano", "path": "/backend/api/migrations/0020_auto_20211221_1415.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>blank=True, choices=[("ctrl", "ctrl"), ("shift", "shift"), ("ctrl shift", "ctrl shift")], max_length=10, null=True, ), ), ( "suffix_key", mode...
code_fim
hard
{ "lang": "python", "repo": "doccano/doccano", "path": "/backend/api/migrations/0020_auto_20211221_1415.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chengziyi/chatbot_with_bm25 path: /handle.py import hashlib import web import reply import receive from chatbot import bot import time agent=bot() class Handle(object): def POST(self): try: webData = web.data() print ("Handle Post webdata is :", webData) ...
code_fim
hard
{ "lang": "python", "repo": "chengziyi/chatbot_with_bm25", "path": "/handle.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> token_list = [token, timestamp, nonce] token_list.sort() sha1 = hashlib.sha1() #map(sha1.update, token_list) [sha1.update(i.encode('utf-8')) for i in token_list] hashcode = sha1.hexdigest() print("handle/GET func: hashcode...
code_fim
hard
{ "lang": "python", "repo": "chengziyi/chatbot_with_bm25", "path": "/handle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Criticism Z_pred = q_Z.mean().eval().argmax(axis=1) print("Result (label flip,can happen):") print("Predicted") print(Z_pred) print("True") print(Z_true) print("Adjusted Rand Index =", adjusted_rand_score(Z_pred, Z_true)) # Visualization G = nx.from_numpy_matrix(A_observed) nx.draw(G, pos=nx.spring_lay...
code_fim
hard
{ "lang": "python", "repo": "aladinD/SBMCommunityDetection", "path": "/code/SBM/edward1/SBM_karateClub.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: aladinD/SBMCommunityDetection path: /code/SBM/edward1/SBM_karateClub.py """ Stochastic Block Model (SBM) Realization for Zachary's Karate Club Example The Karate Club consists of 34 members, where two explicit groups (Mr. Hi vs. Officer) are formed during a dispute: a) Members which support ...
code_fim
hard
{ "lang": "python", "repo": "aladinD/SBMCommunityDetection", "path": "/code/SBM/edward1/SBM_karateClub.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }