text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>class AddSubtractionMatrixError(Exception): ''' Exception raised for errors when the matrices to be added or subracted do not have the same dimensions ''' def __init__(self, message='The matrices needs to have the same dimension'): self.message = messa...
code_fim
hard
{ "lang": "python", "repo": "jairNeto/basic_matrix_algebra", "path": "/jair_matrices/exceptions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: adamlerer/droidlet path: /droidlet/dialog/craftassist/tests/test_dialogue_manager.py """ Copyright (c) Facebook, Inc. and its affiliates. """ import os import unittest import logging from droidlet.dialog.dialogue_manager import DialogueManager from droidlet.memory.dialogue_stack import DialogueS...
code_fim
hard
{ "lang": "python", "repo": "adamlerer/droidlet", "path": "/droidlet/dialog/craftassist/tests/test_dialogue_manager.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> action_dict = { "dialogue_type": "HUMAN_GIVE_COMMAND", "action_sequence": [ { "action_type": "DANCE", "dance_type": { "look_turn": { "location": { ...
code_fim
hard
{ "lang": "python", "repo": "adamlerer/droidlet", "path": "/droidlet/dialog/craftassist/tests/test_dialogue_manager.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ZeoZagart/TF_QA path: /train_distributed.py from Model.NQModel import NQModel from Model.LossFn import LossFn import torch import time import sklearn import datetime import Model.datasetutils as datasetutils import Model.tensorboardutils as boardutils import torch.utils.tensorboard as tensorboard...
code_fim
hard
{ "lang": "python", "repo": "ZeoZagart/TF_QA", "path": "/train_distributed.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> startcm = sklearn.metrics.confusion_matrix(target[1].flatten().detach().numpy(), start01) endcm = sklearn.metrics.confusion_matrix(target[2].flatten().detach().numpy(), end01) StartM += torch.from_numpy(startcm) EndM += torch.from_numpy(endcm) def log_confusion_matrix(matrix, labels, name, ...
code_fim
hard
{ "lang": "python", "repo": "ZeoZagart/TF_QA", "path": "/train_distributed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> start = time.time() model.train() steps = -1 for inp_id, inp_type, inp_mask, ans_type, start, end, yes_no in tqdm(traingen) : steps += 1 output = model(inp_id.squeeze(), inp_mask.squeeze(), inp_type.squeeze()) ## Calculate Confusion Matrix update_confusion_matrix(AnswerTypeMatrix, YesNoMatr...
code_fim
hard
{ "lang": "python", "repo": "ZeoZagart/TF_QA", "path": "/train_distributed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: disorn-inc/Project_Structure path: /core_program/yolo_part/yolo-camera/open_pic.py import numpy as np import cv2 import time camera = cv2.imread('/home/disor<|fim_suffix|>ow('j',frame) print(camera[:,:,0:3]) cv2.waitKey(0) cv2.destroyAllWindows()<|fim_middle|>n/code_save/Project_Structure/core_p...
code_fim
medium
{ "lang": "python", "repo": "disorn-inc/Project_Structure", "path": "/core_program/yolo_part/yolo-camera/open_pic.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ow('j',frame) print(camera[:,:,0:3]) cv2.waitKey(0) cv2.destroyAllWindows()<|fim_prefix|># repo: disorn-inc/Project_Structure path: /core_program/yolo_part/yolo-camera/open_pic.py import numpy as np import cv2 import time camera = cv2.imread('/home/disorn/code_save/Project_Structure/core_program/yolo_pa...
code_fim
medium
{ "lang": "python", "repo": "disorn-inc/Project_Structure", "path": "/core_program/yolo_part/yolo-camera/open_pic.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Azure/WALinuxAgent path: /tests/utils/test_crypt_util.py # Copyright 2018 Microsoft Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
code_fim
hard
{ "lang": "python", "repo": "Azure/WALinuxAgent", "path": "/tests/utils/test_crypt_util.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_get_pubkey_from_crt(self): crypto = CryptUtil(conf.get_openssl_cmd()) prv_key = os.path.join(data_dir, "wire", "trans_prv") expected_pub_key = os.path.join(data_dir, "wire", "trans_pub") with open(expected_pub_key) as fh: self.assertEqual(fh.read()...
code_fim
hard
{ "lang": "python", "repo": "Azure/WALinuxAgent", "path": "/tests/utils/test_crypt_util.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hiimim/rrNotifications path: /rrNotifications.py #!/usr/bin/python # -*- coding: utf-8 -*- # encoding: utf-8 # Configuration: Radarr radarrHost = '192.168.1.5' radarrPort = '7878' radarrApiKey = 'xxxxx' # Configuration: Telegram telegramToken = 'xxxxx' telegramChatId = 00000 import os import ...
code_fim
hard
{ "lang": "python", "repo": "hiimim/rrNotifications", "path": "/rrNotifications.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Send notification if (radarr_eventtype == 'Download') and (radarr_isupgrade == 'False'): movie = rrSearchMovie(radarr_movie_imdbid, 'imdb') movie = rrSearchMovie(movie['tmdbId'], 'tmdb') msg = '<b>' + movie['title'] + '</b> (' + str(movie['year']) + ') downloaded!\n' + excerpt(movie['overview'])...
code_fim
hard
{ "lang": "python", "repo": "hiimim/rrNotifications", "path": "/rrNotifications.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pandas-dev/pandas path: /pandas/tests/frame/methods/test_set_index.py x.map(lambda indx: indx >= 1)] result = df2.set_index("key") tm.assert_frame_equal(result, expected) # MultiIndex constructor does not work directly on Series -> lambda # Add list-of-list constructor be...
code_fim
hard
{ "lang": "python", "repo": "pandas-dev/pandas", "path": "/pandas/tests/frame/methods/test_set_index.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pandas-dev/pandas path: /pandas/tests/frame/methods/test_set_index.py rays( df[["A", "B", "A", "B"]].T.values, names=["A", "B", "C", "D"] ) df = df.set_index(["A", "B"]) assert df.set_index(df.index).index.names == ["A", "B"] # Check that set_index i...
code_fim
hard
{ "lang": "python", "repo": "pandas-dev/pandas", "path": "/pandas/tests/frame/methods/test_set_index.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> values = np.random.default_rng(2).integers(0, 10, (length,)) msg = "Length mismatch: Expected 5 rows, received array of length.*" # wrong length directly with pytest.raises(ValueError, match=msg): df.set_index(box(values), drop=drop, append=append) # ...
code_fim
hard
{ "lang": "python", "repo": "pandas-dev/pandas", "path": "/pandas/tests/frame/methods/test_set_index.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: isabella232/pulumi-kubernetes-crds path: /operators/api-operator/python/pulumi_pulumi_kubernetes_crds_operators_api_operator/_tables.py # coding=utf-8 # *** WARNING: this file was generated by crd2pulumi. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** SNAKE_...
code_fim
hard
{ "lang": "python", "repo": "isabella232/pulumi-kubernetes-crds", "path": "/operators/api-operator/python/pulumi_pulumi_kubernetes_crds_operators_api_operator/_tables.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>": "max_replicas", "memoryLimit": "memory_limit", "minReplicas": "min_replicas", "reqMemory": "req_memory", "requestCount": "request_count", "requestCPU": "request_cpu", "securityConfig": "security_config", "specificIp": "specific_ip", "startIp": "start_ip", "stopOnQuot...
code_fim
hard
{ "lang": "python", "repo": "isabella232/pulumi-kubernetes-crds", "path": "/operators/api-operator/python/pulumi_pulumi_kubernetes_crds_operators_api_operator/_tables.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cloudmesh/cloudmesh-robot path: /cloudmesh/pi/command/pi.py from __future__ import print_function from cloudmesh.shell.command import command from cloudmesh.shell.command import PluginCommand from cloudmesh.common.Shell import Shell, Brew, Pip from cloudmesh.common.console import Console from clo...
code_fim
hard
{ "lang": "python", "repo": "cloudmesh/cloudmesh-robot", "path": "/cloudmesh/pi/command/pi.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> elif arguments.reboot: pass elif arguments.image and arguments.fetch: url = "https://downloads.raspberrypi.org/NOOBS_latest" if os.path.isfile("NOOBS_latest"): print("... image already downloaded") else: os...
code_fim
hard
{ "lang": "python", "repo": "cloudmesh/cloudmesh-robot", "path": "/cloudmesh/pi/command/pi.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> arguments.dryrun = arguments["--dryrun"] def _run(command): print(command) if arguments.dryrun: print(command) else: os.system(command) def _continue(msg): if not arguments.dryrun: c =...
code_fim
hard
{ "lang": "python", "repo": "cloudmesh/cloudmesh-robot", "path": "/cloudmesh/pi/command/pi.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: a-martynovich/api path: /backend/device_registry/migrations/0025_auto_20190512_1934.py # Generated by Django 2.1.7 on 2019-05-12 19:34 from django.db import migrations, models from django.contrib.postgres.fields import JSONField <|fim_suffix|> dependencies = [ ('device_registry', '0...
code_fim
medium
{ "lang": "python", "repo": "a-martynovich/api", "path": "/backend/device_registry/migrations/0025_auto_20190512_1934.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('device_registry', '0024_fix_scan_info_content'), ] operations = [ migrations.AddField( model_name='deviceinfo', name='app_armor_enabled', field=models.BooleanField(blank=True, null=True), ), migrations.AddF...
code_fim
medium
{ "lang": "python", "repo": "a-martynovich/api", "path": "/backend/device_registry/migrations/0025_auto_20190512_1934.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AddField( model_name='deviceinfo', name='app_armor_enabled', field=models.BooleanField(blank=True, null=True), ), migrations.AddField( model_name='deviceinfo', name='selinux_state', ...
code_fim
medium
{ "lang": "python", "repo": "a-martynovich/api", "path": "/backend/device_registry/migrations/0025_auto_20190512_1934.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if n == 0: return 1 else: partial = power(x, n // 2) result = partial * partial # eqaul to x^n for even if n % 2 == 1: #odd # multiply prefix by x to get x^n result *= x return result if __name__ == "__main__":...
code_fim
easy
{ "lang": "python", "repo": "gauravssnl/Data-Structures-and-Algorithms", "path": "/python/Data Structures and Algorithms in Python Book/recursion/power_better.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gauravssnl/Data-Structures-and-Algorithms path: /python/Data Structures and Algorithms in Python Book/recursion/power_better.py # complexity : O(log n ) as in Binary search # the number of times that we can divide n in half before getting to one or less is O(logn). <|fim_suffix|>if __name__ == "...
code_fim
hard
{ "lang": "python", "repo": "gauravssnl/Data-Structures-and-Algorithms", "path": "/python/Data Structures and Algorithms in Python Book/recursion/power_better.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.value = value def __str__(self): return str(self.value)<|fim_prefix|># repo: rca32/cesium path: /cesium/custom_exceptions.py class DataFormatError(Exception): <|fim_middle|> """TS data file or header file does not improperly formatted. Attributes ---------- valu...
code_fim
medium
{ "lang": "python", "repo": "rca32/cesium", "path": "/cesium/custom_exceptions.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: rca32/cesium path: /cesium/custom_exceptions.py class DataFormatError(Exception): """TS data file or header file does not improperly formatted. <|fim_suffix|> """ def __init__(self, value): self.value = value def __str__(self): return str(self.value)<|fim_middle...
code_fim
medium
{ "lang": "python", "repo": "rca32/cesium", "path": "/cesium/custom_exceptions.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhaochl/python-utils path: /utils/pinyin_util.py #!/usr/bin/env python # coding=utf-8 #pip install pypinyin from pypinyin import pinyin, lazy_pinyin import pypinyin if __name__=="__main__": t=pinyin(u'中心') #[[u'zh\u014dng'], [u'x\u012bn']] print t for pinyin_list in t : ...
code_fim
medium
{ "lang": "python", "repo": "zhaochl/python-utils", "path": "/utils/pinyin_util.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> t=lazy_pinyin(u'中心') # 不考虑多音字的情况 #['zhong', 'xin'] print t<|fim_prefix|># repo: zhaochl/python-utils path: /utils/pinyin_util.py #!/usr/bin/env python # coding=utf-8 #pip install pypinyin from pypinyin import pinyin, lazy_pinyin import pypinyin if __name__=="__main__": t=pinyin(u'中心') ...
code_fim
medium
{ "lang": "python", "repo": "zhaochl/python-utils", "path": "/utils/pinyin_util.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: exercism/python path: /exercises/practice/circular-buffer/.meta/example.py class BufferFullException(BufferError): """Exception raised when CircularBuffer is full. message: explanation of the error. """ def __init__(self, message): self.message = message <|fim_suffix|> ...
code_fim
hard
{ "lang": "python", "repo": "exercism/python", "path": "/exercises/practice/circular-buffer/.meta/example.py", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> class CircularBuffer: def __init__(self, capacity): self.buffer = bytearray(capacity) self.read_point = 0 self.write_point = 0 # (protected) helper method def _update_buffer(self, data): try: self.buffer[self.write_point] = data except Typ...
code_fim
medium
{ "lang": "python", "repo": "exercism/python", "path": "/exercises/practice/circular-buffer/.meta/example.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: yuhangwang/craftr path: /craftr/logging.py # Copyright (C) 2015 Niklas Rosenstein # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including witho...
code_fim
hard
{ "lang": "python", "repo": "yuhangwang/craftr", "path": "/craftr/logging.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class Logger(object): ''' Simple logger class. ''' def __init__(self, prefix=None, level=0): super().__init__() self.prefix = prefix or '' self.level = level def emit(self, level, *args, **kwargs): frame = kwargs.pop('frame', None) if level >= self.level: message = print...
code_fim
hard
{ "lang": "python", "repo": "yuhangwang/craftr", "path": "/craftr/logging.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SegmentationBLWX/sssegmentation path: /ssseg/modules/models/segmentors/memorynetv2/memorynetv2.py ''' Function: Implementation of MemoryNetV2 - "MCIBI++: Soft Mining Contextual Information Beyond Image for Semantic Segmentation" Author: Zhenchao Jin ''' import copy import torch import tor...
code_fim
hard
{ "lang": "python", "repo": "SegmentationBLWX/sssegmentation", "path": "/ssseg/modules/models/segmentors/memorynetv2/memorynetv2.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>_cwi_before_fpn', True): lateral_outputs.append(torch.cat([memory_output, feats_cwi], dim=1)) else: lateral_outputs.append(feats_cwi) for i in range(len(lateral_outputs) - 1, 0, -1): prev_shape = lateral_outputs[i ...
code_fim
hard
{ "lang": "python", "repo": "SegmentationBLWX/sssegmentation", "path": "/ssseg/modules/models/segmentors/memorynetv2/memorynetv2.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def test_deep(player): log(player.deep.enter(0)) #print player.deep.auto() #sleep(100) #log(player.deep.fight(1)) #log(player.deep.enter(1)) #log(player.deep.box()) #log(player.deep.enter(0)) from corelib import sleep sleep(200)<|fim_prefix|># repo: hw233/twist...
code_fim
easy
{ "lang": "python", "repo": "hw233/twisted_zdzl", "path": "/server/code/client/scripts/deep.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hw233/twisted_zdzl path: /server/code/client/scripts/deep.py #!/usr/bin/env python # -*- coding:utf-8 -*- DEBUG = 1 def log(msg): if DEBUG: print(msg) <|fim_suffix|> log(player.deep.enter(0)) #print player.deep.auto() #sleep(100) #log(player.deep.fight(1)) ...
code_fim
easy
{ "lang": "python", "repo": "hw233/twisted_zdzl", "path": "/server/code/client/scripts/deep.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> log(player.deep.enter(0)) #print player.deep.auto() #sleep(100) #log(player.deep.fight(1)) #log(player.deep.enter(1)) #log(player.deep.box()) #log(player.deep.enter(0)) from corelib import sleep sleep(200)<|fim_prefix|># repo: hw233/twisted_zdzl path: /server/c...
code_fim
medium
{ "lang": "python", "repo": "hw233/twisted_zdzl", "path": "/server/code/client/scripts/deep.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ardyflora/telegram-ipl-cricket-score-bot path: /database.py import sqlite3 def create_iplPoints(c): c.execute('''CREATE TABLE iplPoints (Rank integer, Teams text, MAT integer, WON integer, Lost integer, TIED integer, NR integer , PTS integer, NETRR text, FOR text, AGAINST text...
code_fim
medium
{ "lang": "python", "repo": "ardyflora/telegram-ipl-cricket-score-bot", "path": "/database.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def init_database(): conn = sqlite3.connect('iplPoints.db') c = conn.cursor() create_iplPoints(c) create_fixtures(c) conn.commit() conn.close() if __name__ == '__main__': init_database()<|fim_prefix|># repo: ardyflora/telegram-ipl-cricket-score-bot path: /database.py import...
code_fim
hard
{ "lang": "python", "repo": "ardyflora/telegram-ipl-cricket-score-bot", "path": "/database.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: webis-de/authorship-threetrain path: /tira-prepare-documents.py #!/usr/bin/env python3 #Usage: tira-prepare-documents `inputDataset` `run` `outdir` `which` #prepares the documents for the databases. First three arguments are from the PAN interface, last must be "training", "unknown" or "both".<|...
code_fim
hard
{ "lang": "python", "repo": "webis-de/authorship-threetrain", "path": "/tira-prepare-documents.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ra.stanford_db,tira.tokens_db,tira.pos_db,tira.c_syntax_tree_db,training_dataset) if which == 'both' or which == 'unknown': prepare_documents.prepareDocumentsChunked(tira.stanford_db,tira.tokens_db,tira.pos_db,tira.c_syntax_tree_db,unknown_dataset) if __name__ == '__main__': import sys interf=tira.ti...
code_fim
hard
{ "lang": "python", "repo": "webis-de/authorship-threetrain", "path": "/tira-prepare-documents.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: disillusionment/emulator101-disassembler path: /disassembler.py import binascii import sys from helpers import get_registers, opcodes8080 #File Reading source_file = str(sys.argv[1]) output_file_name = source_file.split('.')[0] + "_disassembled.txt" with open(source_file, 'rb') as f: source...
code_fim
hard
{ "lang": "python", "repo": "disillusionment/emulator101-disassembler", "path": "/disassembler.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if data_address_bytes > 0: data_address_bytes -= 1 opcode += 1 continue position = (x * 2) byte = hex_dump[position] + hex_dump[position + 1] opcode_tuple = opcodes8080[byte] instruction = opcode_tuple[0] if not instruction: opcode += 1 ...
code_fim
medium
{ "lang": "python", "repo": "disillusionment/emulator101-disassembler", "path": "/disassembler.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># definations def dot_prod(t1: torch.Tensor, t2: torch.Tensor, verbose: bool = False): """simple function with fully built doc string and wrapper for Cpp-object :param t1: tensor 1 :param t2: tensor 2 :param verbose: bool whether to allow C++ code to print """ assert t1.size() == t...
code_fim
hard
{ "lang": "python", "repo": "yashbonde/mask_attention_transformer", "path": "/mask_attention/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yashbonde/mask_attention_transformer path: /mask_attention/__init__.py """ MIT License Copyright (c) 2020 Yash Bonde Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without...
code_fim
hard
{ "lang": "python", "repo": "yashbonde/mask_attention_transformer", "path": "/mask_attention/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> out = conv(x1, edge_index) assert out.tolist() == [0, 1, 1, 0] assert torch.equal(conv(x2, edge_index), out) assert torch.equal(conv(x1, adj1.t()), out) assert torch.equal(conv(x1, adj2.t()), out) assert torch.equal(conv(x2, adj1.t()), out) assert torch.equal(conv(x2, adj2.t())...
code_fim
hard
{ "lang": "python", "repo": "suntaochun/pytorch_geometric", "path": "/test/nn/conv/test_wl_conv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: suntaochun/pytorch_geometric path: /test/nn/conv/test_wl_conv.py import torch import torch.nn.functional as F from torch_sparse import SparseTensor from torch_geometric.nn import WLConv <|fim_suffix|> x1 = torch.tensor([1, 0, 0, 1]) x2 = F.one_hot(x1).to(torch.float) edge_index = to...
code_fim
medium
{ "lang": "python", "repo": "suntaochun/pytorch_geometric", "path": "/test/nn/conv/test_wl_conv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertNoDiff(util.diff(util.run_mock('control/if_3.sieve'), 'control/if_3.out')) if __name__ == '__main__': unittest.main()<|fim_prefix|># repo: dburkart/check-sieve path: /test/AST/control_test.py import unittest import checksieve from . import util class TestControlAST(util.DiffTest...
code_fim
hard
{ "lang": "python", "repo": "dburkart/check-sieve", "path": "/test/AST/control_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dburkart/check-sieve path: /test/AST/control_test.py import unittest import checksieve from . import util class TestControlAST(util.DiffTestCase): def test_simple_if(self): self.assertNoDiff(util.diff(util.run_mock('control/if_1.sieve'), 'control/if_1.out')) <|fim_suffix|> ...
code_fim
medium
{ "lang": "python", "repo": "dburkart/check-sieve", "path": "/test/AST/control_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_if_else(self): self.assertNoDiff(util.diff(util.run_mock('control/if_2.sieve'), 'control/if_2.out')) def test_if_elsif_else(self): self.assertNoDiff(util.diff(util.run_mock('control/if_3.sieve'), 'control/if_3.out')) if __name__ == '__main__': unittest.main()<|f...
code_fim
medium
{ "lang": "python", "repo": "dburkart/check-sieve", "path": "/test/AST/control_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """takes method and wraps it in a timer""" log = LogMixin() def timed(*args, **kw): ts = time.time() result = method(*args, **kw) te = time.time() log.logger.info(f'''{method.__qualname__} took {round(te - ts, 3)}s seconds''') return result ...
code_fim
hard
{ "lang": "python", "repo": "pplonski/scitime", "path": "/scitime/_log.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pplonski/scitime path: /scitime/_log.py import time import logging import warnings warnings.simplefilter("ignore") class LogMixin(object): @property def logger(self): <|fim_suffix|> """takes method and wraps it in a timer""" log = LogMixin() def timed(*args, **kw): ...
code_fim
hard
{ "lang": "python", "repo": "pplonski/scitime", "path": "/scitime/_log.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>cePulseFlagMC=cms.bool(False), usePulseFlag = cms.bool(True), correctionType = cms.int32(1) )<|fim_prefix|># repo: cms-sw/cmssw path: /RecoEgamma/EgammaHFProducers/python/hfClusterShapes_cfi.py import FWCore.Paramet...
code_fim
hard
{ "lang": "python", "repo": "cms-sw/cmssw", "path": "/RecoEgamma/EgammaHFProducers/python/hfClusterShapes_cfi.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cms-sw/cmssw path: /RecoEgamma/EgammaHFProducers/python/hfClusterShapes_cfi.py import FWCore.ParameterSet.Config as cms # HFEMClusterShape producer hfEMClusters = cms.EDProducer("HFEMClusterProducer", hits = cms.InputTag("hfreco")<|fim_suffix|>cePulseFlagMC=cms.bool...
code_fim
hard
{ "lang": "python", "repo": "cms-sw/cmssw", "path": "/RecoEgamma/EgammaHFProducers/python/hfClusterShapes_cfi.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: lanxinplus/lanxinplus-openapi-python-sdk path: /lanxinplus_openapi/api/org_api.py """ LanXin+ OpenAPI LanXin+ OpenAPI Platform # noqa: E501 Generated by: https://openapi.lanxin.cn """ import re # noqa: F401 import sys # noqa: F401 from lanxinplus_openapi.api_client import ApiC...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/org_api.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Returns: V1OrgFetchResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( ...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/org_api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Args: app_token (str): app_token orgid (str): orgid Keyword Args: user_token (str): user_token. [optional] Returns: V1OrgFetchResponse If the method is called asynchronously, returns the request threa...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/org_api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> get_ipython().kernel.comm_manager.register_target(self.target_name + '/' + str(channel), handle_open) def run(self): # TODO wait until JS ready while not self.opened: time.sleep(self.sleep) while self.opened: messages = queue_get_all(self.q) ...
code_fim
hard
{ "lang": "python", "repo": "silky/tributary", "path": "/tributary/_depr/hosts/comm.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.comm.send(data=messages_to_json(messages)) time.sleep(self.sleep) def runComm(q, channel, sleep=1): # print('adding handler %s%s' % ('lantern.live/', channel)) comm = CommHandler(q, channel, sleep) comm.run()<|fim_prefix|># repo: silky/tributary path: /tribu...
code_fim
hard
{ "lang": "python", "repo": "silky/tributary", "path": "/tributary/_depr/hosts/comm.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: silky/tributary path: /tributary/_depr/hosts/comm.py import time from IPython import get_ipython from ..utils import queue_get_all, messages_to_json class CommHandler(object): def __init__(self, q, channel, sleep=1, replay=True, replay_count=1000): self.closed = False self.q...
code_fim
hard
{ "lang": "python", "repo": "silky/tributary", "path": "/tributary/_depr/hosts/comm.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bernardobranco/ucl-search-engine path: /engine/tasks.py import time import requests from celery import shared_task #from pymongo import MongoClient from django.conf import settings from engine.models import WebPage from engine.crawler import get_page from engine.forms import WebPageForm import...
code_fim
hard
{ "lang": "python", "repo": "bernardobranco/ucl-search-engine", "path": "/engine/tasks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># i = 0 # print('SAVING STEP 1') # out_pages_ids = list() # for out_link in resp['out_links']: # print(i) # # Create new page if outlink does not exist # # Adds to crawler after save # #try: # ...
code_fim
hard
{ "lang": "python", "repo": "bernardobranco/ucl-search-engine", "path": "/engine/tasks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># out_pages_ids.append(out_page.id) # # add out links as in link to current page # #out_page.in_links.add(page) # i +=1 # print('SAVING OUTLINKS') # page.out_links.add(*out_pages_ids) # print('SAVING STEP ...
code_fim
hard
{ "lang": "python", "repo": "bernardobranco/ucl-search-engine", "path": "/engine/tasks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 4. After the parameter processing from steps 1-3 the request is made using the calling function returned by the module attribute ``retrieve_caller_fn`` and the reponse formatters are applied to the output. """ def __init__( self, json_rpc_method=None, ...
code_fim
hard
{ "lang": "python", "repo": "sanchaymittal/FarmEasy", "path": "/WhatsApp_FarmEasy/env/lib/python3.6/site-packages/web3/method.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sanchaymittal/FarmEasy path: /WhatsApp_FarmEasy/env/lib/python3.6/site-packages/web3/method.py import functools import warnings from eth_utils import ( to_tuple, ) from eth_utils.toolz import ( identity, pipe, ) def _munger_star_apply(fn): @functools.wraps(fn) def inner(arg...
code_fim
hard
{ "lang": "python", "repo": "sanchaymittal/FarmEasy", "path": "/WhatsApp_FarmEasy/env/lib/python3.6/site-packages/web3/method.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if block_identifier is None: block_identifier = DEFAULT_BLOCK return module, [account, block_identifier] ``` all mungers should return an argument list. if no munger is provided, a default munger expecting no method arguments will b...
code_fim
hard
{ "lang": "python", "repo": "sanchaymittal/FarmEasy", "path": "/WhatsApp_FarmEasy/env/lib/python3.6/site-packages/web3/method.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sourcepirate/capsule path: /capsule/download.py import os import six import shutil import wget import traceback import zipfile def trim_repo_url(url): """Replace the .git in url""" return url.replace(".git", "") def get_archive_url(url, branch='master', release=None): """ get ...
code_fim
hard
{ "lang": "python", "repo": "sourcepirate/capsule", "path": "/capsule/download.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def rupture(url, outpath=None, branch='master', dirname=None, release=None): """ Downloads the archive, unzips it and deletes the archive file Args: url: url to be downloaded outpath: path of the output folder dirname: name of the directory branc...
code_fim
hard
{ "lang": "python", "repo": "sourcepirate/capsule", "path": "/capsule/download.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>+= 95*95 c = 95 d = 95 a += 1 d -= 1 while d != 0 c -= 1 while c != 0<|fim_prefix|># repo: tbjoern/adventofcode path: /Twentythree/reverse.py # a = 7 or a = 12 b = a b -= 1 d = a a = 0 # a += b*d c = b a += 1 c -= 1 while c != 0 d -= 1 while d !=0 b -= 1 c = ...
code_fim
medium
{ "lang": "python", "repo": "tbjoern/adventofcode", "path": "/Twentythree/reverse.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tbjoern/adventofcode path: /Twentythree/reverse.py # a = 7 or a = 12 b = a b -= 1 d = a a = 0 # a += b*d c = b a += 1<|fim_suffix|>+= 95*95 c = 95 d = 95 a += 1 d -= 1 while d != 0 c -= 1 while c != 0<|fim_middle|> c -= 1 while c != 0 d -= 1 while d !=0 ...
code_fim
medium
{ "lang": "python", "repo": "tbjoern/adventofcode", "path": "/Twentythree/reverse.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_Size2i(): cmp(size.return_Size2i(), (203, 17)) size.receive_Size2i(size.Size2i(250, 128)) def test_Size2d(): cmp(size.return_Size2d(), (0.039, 0.377)) size.receive_Size2d(size.Size2d(0.637, 0.256)) def test_Size2f(): cmp(size.return_Size2f(), (0.460, 0.339)) size.rece...
code_fim
medium
{ "lang": "python", "repo": "renatoGarcia/opencv-swig", "path": "/test/test_size.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def test_Vec_constructor(): cmp(size.Size2i(size.Point2i(23, 58)), (23, 58))<|fim_prefix|># repo: renatoGarcia/opencv-swig path: /test/test_size.py #! /usr/bin/python3 import sys sys.path.insert(0, ".") import size def cmp(r, t): epsilon = 0.0001 for p in zip(r, t): assert(abs(p[...
code_fim
hard
{ "lang": "python", "repo": "renatoGarcia/opencv-swig", "path": "/test/test_size.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: renatoGarcia/opencv-swig path: /test/test_size.py #! /usr/bin/python3 import sys sys.path.insert(0, ".") import size def cmp(r, t): epsilon = 0.0001 for p in zip(r, t): assert(abs(p[0] - p[1]) < epsilon) def test_Size(): cmp(size.return_Size(), (14, 55)) size.receive...
code_fim
hard
{ "lang": "python", "repo": "renatoGarcia/opencv-swig", "path": "/test/test_size.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: austincmatteson/pyramid-stocks path: /pyramid_scaffold/tests/test_model_stock.py def test_constructed_stock_added_to_database(db_session): from ..models import Stock assert len(db_session.query(Stock).all()) == 0 stock = Stock( symbol="AM", companyName="ayymang", ...
code_fim
medium
{ "lang": "python", "repo": "austincmatteson/pyramid-stocks", "path": "/pyramid_scaffold/tests/test_model_stock.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert len(db_session.query(Stock).all()) == 0 stock = Stock( companyName="ayymang", exchange="NYC", industry="dusty", website="google.com", description="test", CEO="me", issueType="huh", sector="tc" ) with pytest.raises(Integ...
code_fim
hard
{ "lang": "python", "repo": "austincmatteson/pyramid-stocks", "path": "/pyramid_scaffold/tests/test_model_stock.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: castelao/CoTeDe path: /cotede/utils/utils.py # -*- coding: utf-8 -*- """Utilities for CoTeDe Miscelaneous resources to support CoTeDe. """ from datetime import date, datetime import json import logging import numpy as np import os from os.path import expanduser import re import pkg_resources ...
code_fim
hard
{ "lang": "python", "repo": "castelao/CoTeDe", "path": "/cotede/utils/utils.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # tar = tarfile.open("%s.tar.bz2" % filename, "w:bz2") tar = tarfile.open(filename, "w:bz2") tmpdir = tempfile.mkdtemp() try: # Data f = "%s/data.hdf" % (tmpdir) db.data.to_hdf(f, "df") tar.add(f, arcname="data.hdf") # hashlib.md5(open(f, 'rb').read...
code_fim
hard
{ "lang": "python", "repo": "castelao/CoTeDe", "path": "/cotede/utils/utils.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> db = shelve.open(self.filename) db[key] = obj db.close() def restore(self, key): db = shelve.open(self.filename) if db.has_key(key): obj = db[key] logger.info("Successful load data by key '%s' info from file %s" % (key, self.filename)) ...
code_fim
medium
{ "lang": "python", "repo": "spitty/strelka_telegram_bot", "path": "/storer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: spitty/strelka_telegram_bot path: /storer.py #!/usr/bin/python import logging import shelve logger = logging.getLogger(__name__) <|fim_suffix|> db = shelve.open(self.filename) db[key] = obj db.close() def restore(self, key): db = shelve.open(self.filename) ...
code_fim
medium
{ "lang": "python", "repo": "spitty/strelka_telegram_bot", "path": "/storer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: manikandtan-ck/RecurrentGaze path: /images_data_augmenter_seqaware.py e data augmenter class and related methods # author :Cristina Palmero # date :30092018 # version :2.0 # usage : - # notes : - # python_version :3.5.5 # ==========================...
code_fim
hard
{ "lang": "python", "repo": "manikandtan-ck/RecurrentGaze", "path": "/images_data_augmenter_seqaware.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ ImageDataAugmenter class. Prepared to apply the same augmentation to a list of images/data. Sequence-aware: the current augmentation state can be returned to the calling class, so that all frames of a sequence are augmented in the same way. """ def __init__(self, ...
code_fim
hard
{ "lang": "python", "repo": "manikandtan-ck/RecurrentGaze", "path": "/images_data_augmenter_seqaware.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if transform_matrix is not None: face_img = apply_transform_matrix(self, face_img, transform_matrix) nface_img = apply_transform_matrix(self, nface_img, transform_matrix) leye_img = apply_transform_matrix(self, leye_img, transform_matrix) reye_img = ...
code_fim
hard
{ "lang": "python", "repo": "manikandtan-ck/RecurrentGaze", "path": "/images_data_augmenter_seqaware.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for ch in kanji_numbers: print ctype % (ch, 'M') for ch in hiragana: print ctype % (ch, 'I') for ch in katakana: print ctype % (ch, 'K') for ch in alphabets: print ctype % (ch, 'A') for ch in numbers: print ctype % (ch, 'N')<|fim_prefix|># repo: ktty1220/TinySegmenterMaker path: /...
code_fim
medium
{ "lang": "python", "repo": "ktty1220/TinySegmenterMaker", "path": "/templates/tex-ctypes.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ktty1220/TinySegmenterMaker path: /templates/tex-ctypes.py #!/usr/bin/env python # -*- coding:utf-8 -*- import sys import codecs sys.stdin = codecs.getreader('utf-8')(sys.stdin) sys.stdout = codecs.getwriter('utf-8')(sys.stdout) kanji_numbers = u"一二三四五六七八九十百千万億兆" hiragana = u"あいうえおかきくけこがぎぐげご...
code_fim
medium
{ "lang": "python", "repo": "ktty1220/TinySegmenterMaker", "path": "/templates/tex-ctypes.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tmpdir, top_level_deps, spec_deps): top_level_file = tmpdir.join('elm-native-package.json') spec_file = tmpdir.join('spec-elm-native-package.json') top_level = OrderedDict(top_level_deps) top_level_file.write(json.dumps(top_level)) spec = OrderedDict(spec_deps...
code_fim
medium
{ "lang": "python", "repo": "NoRedInk/elm-ops-tooling", "path": "/tests/test_native_deps_sync.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>@given(top_level_deps=st.permutations(top_level_deps), spec_deps=st.permutations(spec_deps)) def test_spec_order_is_preserved( tmpdir, top_level_deps, spec_deps): top_level_file = tmpdir.join('elm-native-package.json') spec_file = tmpdir.join('spec-elm-native-package...
code_fim
hard
{ "lang": "python", "repo": "NoRedInk/elm-ops-tooling", "path": "/tests/test_native_deps_sync.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: NoRedInk/elm-ops-tooling path: /tests/test_native_deps_sync.py from collections import OrderedDict import json from hypothesis import given import hypothesis.strategies as st import native_deps_sync top_level_deps = [ ('NoRedInk/top-1', '1.0.0 <= v <= 1.0.0'), ('NoRedInk/top-2', '1.0....
code_fim
medium
{ "lang": "python", "repo": "NoRedInk/elm-ops-tooling", "path": "/tests/test_native_deps_sync.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>name = "Тициано Вечеллио" print("Герой нашей сегоднящней программы - " + name) name2 = input("Под каким же именем мы знаем этого человека? Ваш ответ: ") print("Все верно: " + name + " - " + name2) input("Нажмите Enter для выхода")<|fim_prefix|># repo: stasvorosh/pythonintask path: /INBa/2014/Mamedov_R_A/...
code_fim
easy
{ "lang": "python", "repo": "stasvorosh/pythonintask", "path": "/INBa/2014/Mamedov_R_A/Mamedov 3_12.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: stasvorosh/pythonintask path: /INBa/2014/Mamedov_R_A/Mamedov 3_12.py # Задача 3, Вариант 12 # Напишите программу, которая выводит имя "Тициано Вечеллио", и запрашивает его псевдоним. Программа должна сцеплять две эти строки и выводить полученную строку, разделяя имя и псевдоним с помощью тире. ...
code_fim
easy
{ "lang": "python", "repo": "stasvorosh/pythonintask", "path": "/INBa/2014/Mamedov_R_A/Mamedov 3_12.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ An audio processing pipeline that computes a frequency domain representation of the sound that follows a geometric scale """ bark = zounds.ArrayWithUnitsFeature( zounds.BarkBands, samplerate=samplerate, stop_freq_hz=samplerate.nyquist, needs=BaseMode...
code_fim
hard
{ "lang": "python", "repo": "JohnVinyard/zounds", "path": "/examples/pytorch_autoencoder.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # get references to all the sounds. features are lazily # loaded/evaluated, so this is a cheap operation snds = list(Sound) # create a synthesizer that can invert the frequency adaptive representation synth = zounds.FrequencyAdaptiveFFTSynthesizer(scale, samplerate) def random_...
code_fim
hard
{ "lang": "python", "repo": "JohnVinyard/zounds", "path": "/examples/pytorch_autoencoder.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: JohnVinyard/zounds path: /examples/pytorch_autoencoder.py import featureflow as ff import zounds import numpy as np from torch import nn, optim from random import choice import argparse class Layer(nn.Module): """ A single layer of our simple autoencoder """ def __init__(self, ...
code_fim
hard
{ "lang": "python", "repo": "JohnVinyard/zounds", "path": "/examples/pytorch_autoencoder.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sdgdsffdsfff/qchat_supplier_robot path: /utils/send_message_util.py #!/usr/bin/env python # -*- encoding: utf8 -*- import sys sys.path.append("././") import json import requests import uuid from db.get_database_data import SupplierQaHistory from xml.sax.saxutils import escape from get_config imp...
code_fim
hard
{ "lang": "python", "repo": "sdgdsffdsfff/qchat_supplier_robot", "path": "/utils/send_message_util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif is_worked == '0': answer = "感谢你的反馈,我会好好学习的~" message = "<message from='{m_from}' to='{m_to}' type='{mtype}' realfrom='{real_from}' " \ "realto='{real_to}' channelid='{channelid}' qchatid='5'>" \ "<body id='{uuid}' msgType='{msg_type}' ex...
code_fim
hard
{ "lang": "python", "repo": "sdgdsffdsfff/qchat_supplier_robot", "path": "/utils/send_message_util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>with open(file_path, "rb") as f: f_data = f.read() print(charset_normalizer.detect(f_data)) # print(chardet.detect(f_data)) # returns 'ascii' even if the file is saved in UTF8 format if it does not contain any unicode characters.<|fim_prefix|># repo: jgstew/tools path: /Python/file_get_encod...
code_fim
easy
{ "lang": "python", "repo": "jgstew/tools", "path": "/Python/file_get_encoding.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jgstew/tools path: /Python/file_get_encoding.py # pip install chardet # import chardet <|fim_suffix|>file_path = "Python/file_get_encoding.py" with open(file_path, "rb") as f: f_data = f.read() print(charset_normalizer.detect(f_data)) # print(chardet.detect(f_data)) # returns 'asci...
code_fim
medium
{ "lang": "python", "repo": "jgstew/tools", "path": "/Python/file_get_encoding.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gruen/redash path: /redash/worker.py from celery import Celery from datetime import timedelta from redash import settings <|fim_suffix|>celery.conf.update(CELERY_RESULT_BACKEND=settings.CELERY_BACKEND, CELERYBEAT_SCHEDULE={ 'refresh_queries': { ...
code_fim
hard
{ "lang": "python", "repo": "gruen/redash", "path": "/redash/worker.py", "mode": "psm", "license": "BSD-2-Clause-Views", "source": "the-stack-v2" }
<|fim_suffix|>celery.conf.update(CELERY_RESULT_BACKEND=settings.CELERY_BACKEND, CELERYBEAT_SCHEDULE={ 'refresh_queries': { 'task': 'redash.tasks.refresh_queries', 'schedule': timedelta(seconds=30) }, ...
code_fim
hard
{ "lang": "python", "repo": "gruen/redash", "path": "/redash/worker.py", "mode": "spm", "license": "BSD-2-Clause-Views", "source": "the-stack-v2" }
<|fim_prefix|># repo: xmanatee/mipt.digger.project path: /nmakeenkov_dev.py import cv2 import rectangle_builder cap = cv2.VideoCapture(u'data/CH0P0389.MPG') r_b = rectangle_builder.RectangleBuilder() while(cap.isOpened()): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) edges = cv2.Canny...
code_fim
hard
{ "lang": "python", "repo": "xmanatee/mipt.digger.project", "path": "/nmakeenkov_dev.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }