text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> statistics = {} rankList = {} # status == 1 mean Accepted for submission in submissionList: status = submission.status if status != 1: status = 0 user_pid = (submission.user, submission.pid) if statistics.has_key(user_pid): statistics[user_pid] =...
code_fim
hard
{ "lang": "python", "repo": "haihua-sysu/onlinejudge", "path": "/web/contest/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> context = {'contest': contest, 'submissionList': submissionList} return render_to_response('contest_submission.html', context, context_instance = RequestContext(request)) def solvedCount(val): return val[1] def SCORE(val): return val[1] def showOIStanding(request, cid): res = canSho...
code_fim
hard
{ "lang": "python", "repo": "haihua-sysu/onlinejudge", "path": "/web/contest/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tensorflow/datasets path: /tensorflow_datasets/translate/mtnt/mtnt.py # coding=utf-8 # Copyright 2023 The TensorFlow Datasets 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 ...
code_fim
hard
{ "lang": "python", "repo": "tensorflow/datasets", "path": "/tensorflow_datasets/translate/mtnt/mtnt.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pair = f'{self.builder_config.src_lang}-{self.builder_config.dst_lang}' return { 'train': self._generate_examples(path / f'MTNT/train/train.{pair}.tsv'), 'test': self._generate_examples(path / f'MTNT/test/test.{pair}.tsv'), 'valid': self._generate_examples(path / f'MTNT/val...
code_fim
hard
{ "lang": "python", "repo": "tensorflow/datasets", "path": "/tensorflow_datasets/translate/mtnt/mtnt.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """Yields examples.""" with epath.Path(path).open() as f: reader = csv.reader(f, delimiter='\t') for row in reader: if len(row) < 3: logging.info('skipped row %s', row) continue key = hashlib.md5(','.join(row[0:3]).encode('utf-8')).hexdigest() ...
code_fim
hard
{ "lang": "python", "repo": "tensorflow/datasets", "path": "/tensorflow_datasets/translate/mtnt/mtnt.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __lt__(self, other): if not isinstance(other, self.__class__): return NotImplemented return self.sort_key < other.sort_key @property def sort_key(self): return (self.controller_num, self.channel, self.enclosure_id, self.target_id) @property ...
code_fim
hard
{ "lang": "python", "repo": "asciiphil/perc-status", "path": "/perc-status", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: asciiphil/perc-status path: /perc-status """ Returns a string containing the binary representation of the given integer. COUNT represents the number of digits that should be in the output. If omitted, as few digits will be used as possible.""" if count == 0: count = int(math...
code_fim
hard
{ "lang": "python", "repo": "asciiphil/perc-status", "path": "/perc-status", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: asciiphil/perc-status path: /perc-status '--omreport', default='omreport', help='Location of the omreport program, if not in $PATH.') option_parser.add_option('-c', '--controller', type='int', help='Specific controller number to query. Default is...
code_fim
hard
{ "lang": "python", "repo": "asciiphil/perc-status", "path": "/perc-status", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>rec = musicbrainzngs.get_recording_by_id('9abfbf0b-ef05-4dfc-9177-17cc42dd3feb',includes=['artists','releases']) track = rec['recording'] album = track['release-list'][0]['title'] artist = track['artist-credit-phrase']<|fim_prefix|># repo: rawdlite/mopidy-remote path: /tests/library_test.py from __future...
code_fim
hard
{ "lang": "python", "repo": "rawdlite/mopidy-remote", "path": "/tests/library_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: rawdlite/mopidy-remote path: /tests/library_test.py from __future__ import unicode_literals import datetime import sys sys.path.append('../mopidy_remote') from library import RemoteLibrary import musicbrainzngs <|fim_suffix|>lib = RemoteplayLibrary(config) musicbrainzngs.set_useragent('mopidy-he...
code_fim
medium
{ "lang": "python", "repo": "rawdlite/mopidy-remote", "path": "/tests/library_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> data = get_only_updated_values(instance, data) if len(data) == 0: return None res = update_in_db(instance, data) if res != 'updated': set_session_var('errors', str(res)) return None else: set_session_var('success', ...
code_fim
hard
{ "lang": "python", "repo": "ai-transparent/transparentai-ui", "path": "/transparentai_ui/app/controllers/controller_class.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ai-transparent/transparentai-ui path: /transparentai_ui/app/controllers/controller_class.py from flask import render_template, request, redirect, url_for, session from flask_babel import _ from ..utils import set_session_var, check_if_session_var_exists from ..utils.db import add_in_db, update_i...
code_fim
hard
{ "lang": "python", "repo": "ai-transparent/transparentai-ui", "path": "/transparentai_ui/app/controllers/controller_class.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yhz61010/jquery path: /build/downloadapi_for_exist_file.py #!/usr/bin/python # -*- coding: UTF-8 -*- import codecs import os,sys,re,time; filename = r"../jQueryAPI.en_US.xml" fileread = o<|fim_suffix|>Query Object Instances",filer,0); #替换stra 为 strb sub = re.sub(r'(<entry.*?)(>)',r'\1 filename...
code_fim
medium
{ "lang": "python", "repo": "yhz61010/jquery", "path": "/build/downloadapi_for_exist_file.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ead.close(); fileok = open(filename,'w', encoding='utf-8'); fileok.write(sub); fileok.close(); print(filename,'Replace successful.')<|fim_prefix|># repo: yhz61010/jquery path: /build/downloadapi_for_exist_file.py #!/usr/bin/python # -*- coding: UTF-8 -*- import codecs import os,sys,re,time; filename = ...
code_fim
medium
{ "lang": "python", "repo": "yhz61010/jquery", "path": "/build/downloadapi_for_exist_file.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AlterField( model_name="study", name="coi_reported", field=models.PositiveSmallIntegerField( choices=[ (4, "---"), (0, "Authors report they have no COI"), (...
code_fim
hard
{ "lang": "python", "repo": "shapiromatron/hawc", "path": "/hawc/apps/study/migrations/0011_auto_20190416_2035.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shapiromatron/hawc path: /hawc/apps/study/migrations/0011_auto_20190416_2035.py # Generated by Django 1.11.15 on 2019-04-17 01:35 from django.conf import settings from django.db import migrations, models def update_choices(apps, schema_editor): if settings.HAWC_FLAVOR == "EPA": app...
code_fim
hard
{ "lang": "python", "repo": "shapiromatron/hawc", "path": "/hawc/apps/study/migrations/0011_auto_20190416_2035.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hisahi/Nanibgal path: /application/view/feed.py MSGS_PER_PAGE = 25 # (request.args, msgs_func, *func_args) -> (msgs, offset, next_page, prev_page) def compute_pages(args, msgs_func, *func_args): try: before = max(0, int(args.get("b", None))) except: before = None try...
code_fim
hard
{ "lang": "python", "repo": "hisahi/Nanibgal", "path": "/application/view/feed.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>f newest_id <= prev_page: prev_page = None else: prev_page = None if len(msgs) > MSGS_PER_PAGE: next_page = msgs[MSGS_PER_PAGE]["id"] msgs = msgs[:MSGS_PER_PAGE] return msgs, next_page, prev_page<|fim_prefix|># repo: hisahi/Nanibgal path: /applicati...
code_fim
hard
{ "lang": "python", "repo": "hisahi/Nanibgal", "path": "/application/view/feed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: airbus-cert/regrippy path: /regrippy/plugins/mndmru.py from regrippy import BasePlugin, PluginResult, mactime class Plugin(BasePlugin): """Reads 'Map Network Drive MRU' key (Most Recently Used remote drives)""" __REGHIVE__ = "NTUSER.DAT" def run(self): <|fim_suffix|> order ...
code_fim
medium
{ "lang": "python", "repo": "airbus-cert/regrippy", "path": "/regrippy/plugins/mndmru.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> print( mactime( name=f"{self.guess_username()}\t{result.value_data}", mtime=result.mtime ) )<|fim_prefix|># repo: airbus-cert/regrippy path: /regrippy/plugins/mndmru.py from regrippy import BasePlugin, PluginResult, mactime class Plugin(BasePlugin...
code_fim
medium
{ "lang": "python", "repo": "airbus-cert/regrippy", "path": "/regrippy/plugins/mndmru.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for letter in order.value(): res = PluginResult(key=key, value=values[letter]) yield res def display_human(self, result): print(result.value_data) def display_machine(self, result): print( mactime( name=f"{self.guess_use...
code_fim
hard
{ "lang": "python", "repo": "airbus-cert/regrippy", "path": "/regrippy/plugins/mndmru.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bzaczynski/ogre path: /tests/pdf/test_canvas.py m ipsum', 10, 10), places=2) def test_should_return_cursor_position_of_longest_line_of_text(self): canvas = Canvas() canvas.font.size_pts = 6 self.assertAlmostEqual(76.24, canvas.text(self.TEXT, 10, 10), places=2) d...
code_fim
hard
{ "lang": "python", "repo": "bzaczynski/ogre", "path": "/tests/pdf/test_canvas.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertAlmostEqual(34.58, x, places=2) mock_obj.assert_called_once_with(28.34645669291339, 805.543307086614) mock_obj.return_value.textLine.assert_has_calls([ mock.call('Lorem'), mock.call('ipsum'), mock.call('dolor sit'), mock.c...
code_fim
hard
{ "lang": "python", "repo": "bzaczynski/ogre", "path": "/tests/pdf/test_canvas.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bzaczynski/ogre path: /tests/pdf/test_canvas.py nvas.Canvas.setTitle') def test_should_update_metadata(self, mock_set_title, mock_set_subject, mock_set_keywords, ...
code_fim
hard
{ "lang": "python", "repo": "bzaczynski/ogre", "path": "/tests/pdf/test_canvas.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> eps = guess_epsilon.epsilon() ret = eps.to_log10(10, 0.1) assert_almost_equal(ret[0], 1.0, 0.01) assert_almost_equal(ret[1], 0.01, 0.001) def test_obs_to_log(): eps = guess_epsilon.epsilon() obs = {'dnu': [10.0, 0.1], 'numax': [100.0, 1.0], 'teff': [4000.0, 1...
code_fim
hard
{ "lang": "python", "repo": "darthoctopus/PBjam", "path": "/pbjam/tests/test_epsilon_guess.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: darthoctopus/PBjam path: /pbjam/tests/test_epsilon_guess.py from __future__ import division, print_function import pytest import numpy as np from numpy.testing import (assert_almost_equal, assert_array_equal, assert_allclose) from pbjam import guess_epsilon def test_...
code_fim
hard
{ "lang": "python", "repo": "darthoctopus/PBjam", "path": "/pbjam/tests/test_epsilon_guess.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @property def name(self): return self._name @property def dtype(self): return dtypes.int64 @property def is_reparameterized(self): return False def batch_shape(self, name="batch_shape"): with ops.name_scope(self.name): return array_ops.identity(self._batch_shape, nam...
code_fim
hard
{ "lang": "python", "repo": "agrawalnishant/tensorflow", "path": "/tensorflow/contrib/distributions/python/ops/categorical.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: agrawalnishant/tensorflow path: /tensorflow/contrib/distributions/python/ops/categorical.py # Copyright 2016 Google Inc. 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 c...
code_fim
hard
{ "lang": "python", "repo": "agrawalnishant/tensorflow", "path": "/tensorflow/contrib/distributions/python/ops/categorical.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """Sample `n` observations from the Categorical distribution. Args: n: 0-D. Number of independent samples to draw for each distribution. seed: Random seed (optional). name: A name for this operation (optional). Returns: An `int64` `Tensor` with shape `[n, batch_shape...
code_fim
hard
{ "lang": "python", "repo": "agrawalnishant/tensorflow", "path": "/tensorflow/contrib/distributions/python/ops/categorical.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Cap-n-Proud/Bailey_2 path: /units/easy_driver_test.py # 31 dir # 33 steps import time import random import Easy_Driver as es import RPi.GPIO as GPIO en = 19 step = 21 dir = 23 en = 26 step = 24 dir = 22 <|fim_suffix|>motor_A.set_speed(speed) # while i < 1000: # # motor_A.step() # # ...
code_fim
hard
{ "lang": "python", "repo": "Cap-n-Proud/Bailey_2", "path": "/units/easy_driver_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>motor_A.set_speed(speed) # while i < 1000: # # motor_A.step() # # i += 1 # # motor_A.disable() print("all finished") motor_A.print_info() motor_A.set_target(90) i = 0 while i < 1000: motor_A.step_to_target() # print(round(motor_A.steps_to_go(), 2), motor_A.current_pos) i += 1<|fim_...
code_fim
hard
{ "lang": "python", "repo": "Cap-n-Proud/Bailey_2", "path": "/units/easy_driver_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cate = [path + x for x in os.listdir(path) if os.path.isdir(path + x)] cate.sort() record = getrecord(record_path) label = getlabel(label_path) for idx, folder in enumerate(cate): L = len([name for name in os.listdir(folder) if os.path.isfile(os.path.join(folder, name))]) ...
code_fim
hard
{ "lang": "python", "repo": "githubhjx/Deep-Learning", "path": "/pythonFilep/pain_cut.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: githubhjx/Deep-Learning path: /pythonFilep/pain_cut.py # This is a Pain Dataset cut program # Created by JiaxuHan at 2018/11/19 import os import glob import shutil record_path = '/home/s2/data/Pain/records.txt' label_path = '/home/s2/data/Pain/label.txt' img_path = '/home/s2/data/Pain/79/' o...
code_fim
hard
{ "lang": "python", "repo": "githubhjx/Deep-Learning", "path": "/pythonFilep/pain_cut.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for idx, folder in enumerate(cate): L = len([name for name in os.listdir(folder) if os.path.isfile(os.path.join(folder, name))]) temp = glob.glob(folder + '/*.png') temp.sort() for i, j in zip(range(0, len(record[idx]), 2), range(1, len(record[idx]), 2)): l...
code_fim
hard
{ "lang": "python", "repo": "githubhjx/Deep-Learning", "path": "/pythonFilep/pain_cut.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>result = nfa.match(args.regex, args.text) if args.verbose: if result == False: print("The text " + args.text + \ " does not match the regular expression " + args.regex) else: print("The text " + args.text + \ " matches the regular expression " + args.re...
code_fim
hard
{ "lang": "python", "repo": "charlieconneely/regex_nfa", "path": "/runner.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if args.verbose: if result == False: print("The text " + args.text + \ " does not match the regular expression " + args.regex) else: print("The text " + args.text + \ " matches the regular expression " + args.regex) elif args.quiet: print(str(result)...
code_fim
medium
{ "lang": "python", "repo": "charlieconneely/regex_nfa", "path": "/runner.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: charlieconneely/regex_nfa path: /runner.py # Charlie Conneely # Runner program import argparse import nfa parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() <|fim_suffix|>if args.verbose: if result == False: print("The text " + args.text + \ ...
code_fim
hard
{ "lang": "python", "repo": "charlieconneely/regex_nfa", "path": "/runner.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self): super(refinement, self).__init__() self.conv1 = nn.Sequential( nn.Conv2d(4, 64, 3, stride=1, padding=1), nn.ReLU() ) self.conv2 = nn.Sequential( nn.Conv2d(64, 64, 3, stride=1, padding=1), nn.ReLU() ...
code_fim
hard
{ "lang": "python", "repo": "wyk0517/image-matting-experiment", "path": "/model/part_model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wyk0517/image-matting-experiment path: /model/part_model.py # -*- coding: utf-8 -*- import torch.nn as nn import torch import torch.nn.functional as F from base import BaseModel import torchvision.models as models def architecture_transform(model, backbone=models.vgg16(pretrained=True)): # ...
code_fim
hard
{ "lang": "python", "repo": "wyk0517/image-matting-experiment", "path": "/model/part_model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class refinement(nn.Module): def __init__(self): super(refinement, self).__init__() self.conv1 = nn.Sequential( nn.Conv2d(4, 64, 3, stride=1, padding=1), nn.ReLU() ) self.conv2 = nn.Sequential( nn.Conv2d(64, 64, 3, stride=1, padding=...
code_fim
hard
{ "lang": "python", "repo": "wyk0517/image-matting-experiment", "path": "/model/part_model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ggirlk/python-bigO-calculator path: /tests/test_compare.py from bigO import bigO from bigO import algorithm def test_run(): lib = bigO() result = lib.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 5000) result = lib.compare( algorithm.insertSort, algorithm....
code_fim
hard
{ "lang": "python", "repo": "ggirlk/python-bigO-calculator", "path": "/tests/test_compare.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_all(): lib = bigO() result = lib.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "all", 50000 ) result = lib.compare(algorithm.insertSort, algorithm.bubbleSort, "all", 5000) print(result) result = lib.compare(algorithm.quickSortHoare, algorithm.inser...
code_fim
hard
{ "lang": "python", "repo": "ggirlk/python-bigO-calculator", "path": "/tests/test_compare.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> lib.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 16) lib.compare(algorithm.insertSort, algorithm.selectionSort, "reversed", 16) lib.compare(algorithm.bubbleSort, algorithm.selectionSort, "reversed", 16) def test_all(): lib = bigO() result = lib.compare( alg...
code_fim
hard
{ "lang": "python", "repo": "ggirlk/python-bigO-calculator", "path": "/tests/test_compare.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: STAR-TIDES/kb path: /star_tides/core/actions/create_project_action.py '''star_tides.core.actions.create_project_action ''' from marshmallow.exceptions import ValidationError from star_tides.services.databases.mongo.schemas.project_schema import ProjectSchema from star_tides.services.databases.mo...
code_fim
hard
{ "lang": "python", "repo": "STAR-TIDES/kb", "path": "/star_tides/core/actions/create_project_action.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.project = project def run(self): if self.project.id is not None: raise InvalidParamError('Expected project not to have ID.') schema = {} try: schema = ProjectSchema().load(self.project._asdict()) except ValidationError as e: ...
code_fim
medium
{ "lang": "python", "repo": "STAR-TIDES/kb", "path": "/star_tides/core/actions/create_project_action.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return operator def taper_clifford(self, operator: PauliSumOp) -> OperatorBase: """This method operates the second part of the tapering. This function assumes that the input operators have already been transformed using :meth:`convert_clifford`. The redundant qubits du...
code_fim
hard
{ "lang": "python", "repo": "1ucian0/qiskit-terra", "path": "/qiskit/opflow/primitive_ops/tapered_pauli_sum_op.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 1ucian0/qiskit-terra path: /qiskit/opflow/primitive_ops/tapered_pauli_sum_op.py t], tapering_values: Optional[List[int]] = None, tol: float = 1e-14, ): """ Args: symmetries: the list of Pauli objects representing the Z_2 symmetries sq_pa...
code_fim
hard
{ "lang": "python", "repo": "1ucian0/qiskit-terra", "path": "/qiskit/opflow/primitive_ops/tapered_pauli_sum_op.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 1ucian0/qiskit-terra path: /qiskit/opflow/primitive_ops/tapered_pauli_sum_op.py class TaperedPauliSumOp(PauliSumOp): """Deprecated: Class for PauliSumOp after tapering""" @deprecate_func( since="0.24.0", additional_msg="For code migration guidelines, visit https://qisk...
code_fim
hard
{ "lang": "python", "repo": "1ucian0/qiskit-terra", "path": "/qiskit/opflow/primitive_ops/tapered_pauli_sum_op.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ArthurGorgonio/suggestclasses path: /core/tests/test_sugestao.py import django django.setup() from django.contrib.auth.models import User from core.bo.sevices import get_estrutura_by_id from core.bo.turma import get_sugestao_turmas, carrega_turmas_horario, carrega_sugestao_turmas, \ converte...
code_fim
hard
{ "lang": "python", "repo": "ArthurGorgonio/suggestclasses", "path": "/core/tests/test_sugestao.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> super().setUpClass() print('\nSugestaoTests') criar_dados() @classmethod def tearDownClass(cls): super().tearDownClass() remover_dados() def test_get_sugestao(self): estrutura = get_estrutura_by_id(999999999) sugestao1 = SugestaoTurma.o...
code_fim
hard
{ "lang": "python", "repo": "ArthurGorgonio/suggestclasses", "path": "/core/tests/test_sugestao.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cdeil/astrometric_checks path: /test_pointing.py """Checks of the pointing table from HESS. """ from gammapy.data import PointingInfo def check_pointing_info(): pointing_info = PointingInfo.read('hess_event_list.fits') print(pointing_info) # Check altaz coordinates from HESS softwa...
code_fim
medium
{ "lang": "python", "repo": "cdeil/astrometric_checks", "path": "/test_pointing.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>START: Time: 2004-01-21T19:50:02.184(TT) Time: 53025.826414166666 MJD (TT) RADEC: 83.6333 24.5144 deg ALTAZ: 11.2043 41.3792 deg END: Time: 2004-01-21T20:16:28.184(TT) Time: 53025.844770648146 MJD (TT) RADEC: 83.6333 24.5144 deg ALTAZ: 3.18474 42.1431 deg sky_diff: 697.907arcsec 697.909arcsec a...
code_fim
hard
{ "lang": "python", "repo": "cdeil/astrometric_checks", "path": "/test_pointing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> END: Time: 2004-01-21T20:16:28.184(TT) Time: 53025.844770648146 MJD (TT) RADEC: 83.6333 24.5144 deg ALTAZ: 3.18474 42.1431 deg sky_diff: 697.907arcsec 697.909arcsec az_diff: 911.484arcsec 939.596arcsec alt_diff: -137.97arcsec -40.2693arcsec time diff: 0h01m00.7656s 0h01m02.6397s """ if __na...
code_fim
hard
{ "lang": "python", "repo": "cdeil/astrometric_checks", "path": "/test_pointing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HelloKuki/autoupdateServer path: /apkinfo/urls.py from django.conf.urls import url from django.contrib import admin <|fim_suffix|>urlpatterns = [ url(r'^createAppInfo', views.createAppInfo.as_view()), url(r'^uploadAppIcon', views.uploadAppIcon.as_view()), url(r'^uploadApkFile', views...
code_fim
easy
{ "lang": "python", "repo": "HelloKuki/autoupdateServer", "path": "/apkinfo/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>urlpatterns = [ url(r'^createAppInfo', views.createAppInfo.as_view()), url(r'^uploadAppIcon', views.uploadAppIcon.as_view()), url(r'^uploadApkFile', views.uploadApkFile.as_view()), url(r'^explainApk', views.explainApk.as_view()), url(r'^releaseVersion', views.releaseVersion.as_view()),...
code_fim
easy
{ "lang": "python", "repo": "HelloKuki/autoupdateServer", "path": "/apkinfo/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.CreateModel( name='Leave', fields=[ ('id',models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')), ], ), migrations.CreateModel( name='...
code_fim
hard
{ "lang": "python", "repo": "Iamdavidonuh/REQAP", "path": "/activities/migrations/0001_initial.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Iamdavidonuh/REQAP path: /activities/migrations/0001_initial.py # Generated by Django 3.0.4 on 2020-04-15 21:39 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone import uuid class Migration(migrations.Migrati...
code_fim
hard
{ "lang": "python", "repo": "Iamdavidonuh/REQAP", "path": "/activities/migrations/0001_initial.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: googleapis/python-bigtable path: /tests/unit/test_row_merger.py import os from itertools import zip_longest from typing import List import proto import pytest from google.cloud.bigtable.row_data import PartialRowsData, PartialRowData, InvalidChunk from google.cloud.bigtable_v2.types.bigtable im...
code_fim
hard
{ "lang": "python", "repo": "googleapis/python-bigtable", "path": "/tests/unit/test_row_merger.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with pytest.raises(InvalidChunk): _process_chunks( ReadRowsResponse.CellChunk( row_key=b"a", family_name="f", qualifier=b"q", timestamp_micros=1000, value_size=2, value=b"v", ...
code_fim
hard
{ "lang": "python", "repo": "googleapis/python-bigtable", "path": "/tests/unit/test_row_merger.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ccr5/BlackJack path: /tests/review.py import unittest import bot import cards import dealer import deck import players class TestBlackJack(unittest.TestCase): # Bot unittests def bot_play_game(self): npc = bot.Bot('test', 100) npc.hand.append(["Aces", [1, 11], "A"], ["T...
code_fim
medium
{ "lang": "python", "repo": "ccr5/BlackJack", "path": "/tests/review.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> npc = deck.Deck() result = npc.create_deck() self.assertEqual(len(result), 52) def deck_shuffle_deck(self): npc = deck.Deck() result1 = npc.create_deck() result2 = npc.shuffle_deck() self.assertEqual(len(result1), len(result2)) if __name__ == ...
code_fim
hard
{ "lang": "python", "repo": "ccr5/BlackJack", "path": "/tests/review.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # build dic2 l1=random.sample(nameObj, n2) l2=random.sample(nameNonObj, n2) if (verbose >= 2): print 'dic2: ', l1, l2 dic2[name] = l1 for i in l1: nameObj.remove(i) for (k, i) in l2: if not (dic2.has_key(k)): dic2[k]=[] dic2[k].append...
code_fim
hard
{ "lang": "python", "repo": "baaslaawe/speaker-recognition-2", "path": "/split.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: baaslaawe/speaker-recognition-2 path: /split.py # -*- coding: utf-8 -*- from __future__ import division #division en flottants par défaut import random #Split the dictionary into 3 disjoint dictionaries #A dictionary is balanced if the number of name's objects is roughly equal to the number of n...
code_fim
hard
{ "lang": "python", "repo": "baaslaawe/speaker-recognition-2", "path": "/split.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if(t == 0): loop = False else: pt = p loop1 = True print(f'Progressão finalizada com {counter} termos mostrados')<|fim_prefix|># repo: henriquekirchheck/Curso-em-Video-Python path: /desafio/desafio062.py print('=====================') print(' 10 Termos de um PA') pr...
code_fim
medium
{ "lang": "python", "repo": "henriquekirchheck/Curso-em-Video-Python", "path": "/desafio/desafio062.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: henriquekirchheck/Curso-em-Video-Python path: /desafio/desafio062.py print('=====================') print(' 10 Termos de um PA') print('=====================') loop = True loop1 = True p = int(input('Primeiro Termo: ')) pt = p r = int(input('Razão: ')) t = 10 counter = 0 while(loop == True): ...
code_fim
medium
{ "lang": "python", "repo": "henriquekirchheck/Curso-em-Video-Python", "path": "/desafio/desafio062.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#erorr error = 0 for i in range(0, len(reproducedAnalog)): error += int(math.fabs(reproducedAnalog[i] - samples[i])) print("Level, Analog, Digital: ",levelsOfSamples) print("Digital Form: ",digitalForm) print("Reproduced Analog: ",reproducedAnalog) print("Total Error: ",error)<|fim_prefix|># repo: ol...
code_fim
hard
{ "lang": "python", "repo": "olagalal/multimedia-tasks", "path": "/quantization.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: olagalal/multimedia-tasks path: /quantization.py import math # samples = [550, 600, -100, 150, -300, 900, 0, 850] # bitLevel = 2 samples = [] bitLevel = 0 userInput = input("Enter samples: ") temp = "" for i in range(0, len(userInput)): if userInput[i] == " ": samples += [int(temp...
code_fim
hard
{ "lang": "python", "repo": "olagalal/multimedia-tasks", "path": "/quantization.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: atniptw/shiny-robot path: /Sportz/killersports/killersportsteam.py from datetime import date import requests BASE_URL = "http://api.sportsdatabase.com/nfl/query.json" class KillerSportsTeam: def __init__(self, team, season): self.team = team self.season = season def ge...
code_fim
medium
{ "lang": "python", "repo": "atniptw/shiny-robot", "path": "/Sportz/killersports/killersportsteam.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> query = "division@team={0} and season={1}".format(self.team, self.season) payload = {"output": "json", "api_key": "guest", "sdql": query} result = requests.get(BASE_URL, params=payload) jsonResult = self._format_string_to_JSON(result.text) return jsonResult['groups...
code_fim
hard
{ "lang": "python", "repo": "atniptw/shiny-robot", "path": "/Sportz/killersports/killersportsteam.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return jsonResult['groups'][0]['columns'][0][0] def get_team_opponent(self, week): return self._get_game_parameter("o:team", week) def _get_game_parameter(self, parameter, week): query = "{0}@team={1} and season={2} and week={3}".format(parameter, self.team, self.season, ...
code_fim
hard
{ "lang": "python", "repo": "atniptw/shiny-robot", "path": "/Sportz/killersports/killersportsteam.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>m from .pso import ParticleSwarmOptimization from .sa import SimulatedAnnealing from .two_opt import TwoOpt<|fim_prefix|># repo: shubhampachori12110095/tsp-solvers path: /tsp_solvers/methods/__init__.py from .aco import AntColonyOptimization from .ga impor<|fim_middle|>t GeneticAlgorithm from .lp import ...
code_fim
easy
{ "lang": "python", "repo": "shubhampachori12110095/tsp-solvers", "path": "/tsp_solvers/methods/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shubhampachori12110095/tsp-solvers path: /tsp_solvers/methods/__init__.py from .aco import AntColonyOptimization from .ga impor<|fim_suffix|> import SimulatedAnnealing from .two_opt import TwoOpt<|fim_middle|>t GeneticAlgorithm from .lp import LinearIntegerProgram from .pso import ParticleSwarmOp...
code_fim
medium
{ "lang": "python", "repo": "shubhampachori12110095/tsp-solvers", "path": "/tsp_solvers/methods/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data['supervisors'] = data['supervisors'].apply(split_entry) data['keywords'] = data['keywords'].apply(split_entry) data['skills'] = data.apply( lambda row: { 'required': split_entry(row['required_skills']), 'preferred': split_entry(row['preferred_skills']) }, ...
code_fim
hard
{ "lang": "python", "repo": "guillep/pharo-project-proposals", "path": "/converter/XLS2JSON/convert.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: guillep/pharo-project-proposals path: /converter/XLS2JSON/convert.py import pandas as pd DIR = '../../website/data/' FILE_IN = DIR + 'ideas.xlsx' FILE_OUT = 'ideas.json' def split_entry(string): return [each.strip() for each in string.split(',')] <|fim_suffix|> data['skills'] = data.a...
code_fim
hard
{ "lang": "python", "repo": "guillep/pharo-project-proposals", "path": "/converter/XLS2JSON/convert.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data['skills'] = data.apply( lambda row: { 'required': split_entry(row['required_skills']), 'preferred': split_entry(row['preferred_skills']) }, axis=1) data['size'] = data['size'].apply(lambda x: x.split()[0]) data['difficulty'] = data['difficulty'].apply(lamb...
code_fim
hard
{ "lang": "python", "repo": "guillep/pharo-project-proposals", "path": "/converter/XLS2JSON/convert.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: OPI-PIB/jupyter-edx-grader-xblock path: /xblock_jupyter_graded/config.py """Application config""" # Root directory where nbgrader data will be stored in EdX EDX_ROOT = "/var/www/nbgrader/courses/" <|fim_suffix|># nbgrader directory names - these are the default names nbgrader expects # but coul...
code_fim
medium
{ "lang": "python", "repo": "OPI-PIB/jupyter-edx-grader-xblock", "path": "/xblock_jupyter_graded/config.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|># nbgrader directory names - these are the default names nbgrader expects # but could be mofied in nbgrader config and those reflected here if so desired RELEASE = "release" SOURCE = "source" SUBMITTED = "submitted" AUTOGRADED = "autograded" FEEDBACK = "feedback"<|fim_prefix|># repo: OPI-PIB/jupyter-edx-g...
code_fim
medium
{ "lang": "python", "repo": "OPI-PIB/jupyter-edx-grader-xblock", "path": "/xblock_jupyter_graded/config.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: aio-libs/aiopg path: /tests/test_pool.py import asyncio from unittest import mock import pytest from psycopg2.extensions import TRANSACTION_STATUS_INTRANS import aiopg from aiopg.connection import TIMEOUT, Connection from aiopg.pool import Pool async def test_create_pool(create_pool): poo...
code_fim
hard
{ "lang": "python", "repo": "aio-libs/aiopg", "path": "/tests/test_pool.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> conn1, conn2, conn3 = await asyncio.gather(fut1, fut2, fut3) assert 3 == pool.size assert 0 == pool.freesize assert {conn1, conn2, conn3} == pool._used pool.release(conn1) assert 3 == pool.size assert 1 == pool.freesize assert {conn2, conn3} == pool._used pool.release...
code_fim
hard
{ "lang": "python", "repo": "aio-libs/aiopg", "path": "/tests/test_pool.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> res = CommandBlock() res += self res += arg return res def __iadd__(self, arg): if arg is None: return self if isinstance(arg, str): self.__commands.extend(arg.split('\n')) return self try: self.__...
code_fim
hard
{ "lang": "python", "repo": "serl/topoblocktest", "path": "/lib/bash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: serl/topoblocktest path: /lib/bash.py import os import re import subprocess from tempfile import NamedTemporaryFile class CommandBlock: __timeout_re = re.compile(r"\s+timeout\s+.*?(\d+)") @classmethod def root_check(cls): return cls() + 'if [ $EUID -ne 0 ]; then echo "root ...
code_fim
hard
{ "lang": "python", "repo": "serl/topoblocktest", "path": "/lib/bash.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: idkwim/CryptoAttacks path: /CryptoAttacks/tests/test_Hash.py #!/usr/bin/env python from __future__ import print_function from CryptoAttacks.Hash import * import hashlib def test_sha1(): print("Test: sha1") for x in range(30): tmp = random_str(random.randint(0, 256)) as...
code_fim
hard
{ "lang": "python", "repo": "idkwim/CryptoAttacks", "path": "/CryptoAttacks/tests/test_Hash.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_length_extension(): print("Test length extension sha1") for x in range(30): secret = random_str(random.randint(0, 130)) new_message = random_str(random.randint(0, 130)) old_hash = sha1(secret) new_hash, new_data = length_extension(old_hash, len(secret), ne...
code_fim
hard
{ "lang": "python", "repo": "idkwim/CryptoAttacks", "path": "/CryptoAttacks/tests/test_Hash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print("Test length extension md4") for x in range(30): secret = random_str(random.randint(0, 130)) new_message = random_str(random.randint(0, 130)) old_hash = md4(secret) new_hash, new_data = length_extension(old_hash, len(secret), new_message, type='md4') a...
code_fim
hard
{ "lang": "python", "repo": "idkwim/CryptoAttacks", "path": "/CryptoAttacks/tests/test_Hash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> secret_type = "Azure SAS Token" denylist = [ re.compile(r"(?=.*sv=*)(?=.*&se=*)(?=.*&sig=[\%0-9a-zA-Z]{20})"), ]<|fim_prefix|># repo: flecoqui/azure-detect-secrets path: /pipelines/detect-secrets/plugins/azuresas.py # ------------------------------------------------------------------...
code_fim
medium
{ "lang": "python", "repo": "flecoqui/azure-detect-secrets", "path": "/pipelines/detect-secrets/plugins/azuresas.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: flecoqui/azure-detect-secrets path: /pipelines/detect-secrets/plugins/azuresas.py # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # lic...
code_fim
medium
{ "lang": "python", "repo": "flecoqui/azure-detect-secrets", "path": "/pipelines/detect-secrets/plugins/azuresas.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tuetschek/GEM-metrics path: /gem_metrics/bleu.py #!/usr/bin/env python3 from .metric import ReferencedMetric import sacrebleu from itertools import zip_longest <|fim_suffix|> ref_streams = list(zip_longest(*references.untokenized)) bleu = sacrebleu.corpus_bleu(predictions.untoken...
code_fim
medium
{ "lang": "python", "repo": "tuetschek/GEM-metrics", "path": "/gem_metrics/bleu.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def compute(self, predictions, references): ref_streams = list(zip_longest(*references.untokenized)) bleu = sacrebleu.corpus_bleu(predictions.untokenized, ref_streams, lowercase=True) return {'bleu': bleu.score}<|fim_prefix|># repo: tuetschek/GEM-metrics path: /gem_metrics/ble...
code_fim
medium
{ "lang": "python", "repo": "tuetschek/GEM-metrics", "path": "/gem_metrics/bleu.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aladshaw3/cats path: /scripts/python/labview_processing/specific_data_scripts/PureFuels_data_processing.py out (C)', 'P tup in (bar)', 'P top out (bar)', 'NH3 (3000,300)', 'CO (500,10000)', 'Ethanol (1000,10000)', 'CH4 (250,3000)'] # methylisobutylketone if base_folder == "MIBK": ...
code_fim
hard
{ "lang": "python", "repo": "aladshaw3/cats", "path": "/scripts/python/labview_processing/specific_data_scripts/PureFuels_data_processing.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run.append(readCoOptimaFile(folder+"/"+run_name, folder+"/"+bypass_name)) avg_run = readCoOptimaFile(folder+"/"+run_name, folder+"/"+bypass_name) bypass_name = "20170804-CPTMA-MalibuTWC-SGDI-30k-2Pentaone-5Cramp-lambda0_999-bp-2" run_name = "20170804-CPTMA-MalibuTWC-SGD...
code_fim
hard
{ "lang": "python", "repo": "aladshaw3/cats", "path": "/scripts/python/labview_processing/specific_data_scripts/PureFuels_data_processing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nihirsingh29/HCRSimPY path: /HCRSimPY/light_schedules/__init__.py #This will load in some functions to the nam<|fim_suffix|>ghtSchedule import * from ..plots import * from ..utils import * from ..models import *<|fim_middle|>espace when the #package is loaded from .Li
code_fim
easy
{ "lang": "python", "repo": "nihirsingh29/HCRSimPY", "path": "/HCRSimPY/light_schedules/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rom ..utils import * from ..models import *<|fim_prefix|># repo: nihirsingh29/HCRSimPY path: /HCRSimPY/light_schedules/__init__.py #This will load in some functions to the namespace when the #package is loaded from .Li<|fim_middle|>ghtSchedule import * from ..plots import * f
code_fim
easy
{ "lang": "python", "repo": "nihirsingh29/HCRSimPY", "path": "/HCRSimPY/light_schedules/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def parse_variable(parsed_tokens): return Variable(parsed_tokens[0])<|fim_prefix|># repo: SeerZero/synet path: /synet/translation/variable.py class Variable: def __init__(self, name): self.name = name self.is_variable = True self.is_constant = False if self.name == '_': self.wil...
code_fim
hard
{ "lang": "python", "repo": "SeerZero/synet", "path": "/synet/translation/variable.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: SeerZero/synet path: /synet/translation/variable.py class Variable: def __init__(self, name): self.name = name self.is_variable = True self.is_constant = False if self.name == '_': self.wildcard = True else: self.wildcard = False def __str__(self): r...
code_fim
medium
{ "lang": "python", "repo": "SeerZero/synet", "path": "/synet/translation/variable.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> comments_map = {} root_header = None root_comment = None for comment in self.comments(): dot() if root_header is None or root_header.object_id != comment.nid: root_comment = Comment.objects.get_or_create_root_comment(self.node_ctype, comment.nid)[0] update_comments_header(Comment, in...
code_fim
hard
{ "lang": "python", "repo": "LinuxOSsk/Shakal-NG", "path": "/blackhole/management/commands/import_blackhole.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def sync_comment(self): comments_map = {} root_header = None root_comment = None for comment in self.comments(): dot() if root_header is None or root_header.object_id != comment.nid: root_comment = Comment.objects.get_or_create_root_comment(self.node_ctype, comment.nid)[0] update_co...
code_fim
hard
{ "lang": "python", "repo": "LinuxOSsk/Shakal-NG", "path": "/blackhole/management/commands/import_blackhole.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LinuxOSsk/Shakal-NG path: /blackhole/management/commands/import_blackhole.py # -*- coding: utf-8 -*- import subprocess import sys from collections import namedtuple from datetime import datetime from os import path import pytz from django.conf import settings from django.contrib.contenttypes.mod...
code_fim
hard
{ "lang": "python", "repo": "LinuxOSsk/Shakal-NG", "path": "/blackhole/management/commands/import_blackhole.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def stem(word): """ stemming = tìm dạng gốc của từ ví dụ: từ = ["tổ chức", "tổ chức", "tổ chức"] words = [gốc (w) cho w trong từ] -> ["organ", "organ", "organ"] """ return stemmer.stem(word.lower()) def bag_of_words(tokenized_sentence, words): """ trả về mảng các...
code_fim
medium
{ "lang": "python", "repo": "Lanh2208/android", "path": "/python_fun/chatbot-gui/nltk_utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ trả về mảng các từ: 1 cho mỗi từ đã biết tồn tại trong câu, 0 nếu không thí dụ: câu = ["xin chào", "như thế nào", "là", "bạn"] words = ["xin chào", "xin chào", "tôi", "bạn", "tạm biệt", "cảm ơn", "tuyệt"] bog = [0, 1, 0, 1, 0, 0, 0] """ # ngắt từng từ sentence_w...
code_fim
hard
{ "lang": "python", "repo": "Lanh2208/android", "path": "/python_fun/chatbot-gui/nltk_utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Lanh2208/android path: /python_fun/chatbot-gui/nltk_utils.py import numpy as np #NLTK là gì? NLTK là một thư viện python tiêu chuẩn với các chức năng và tiện ích được tạo sẵn để dễ sử dụng và triển khai. Nó là một trong những thư viện được sử dụng nhiều nhất để xử lý ngôn ngữ tự nhiên và ngôn ngữ...
code_fim
hard
{ "lang": "python", "repo": "Lanh2208/android", "path": "/python_fun/chatbot-gui/nltk_utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }