text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>if __name__ == '__main__': # conn = MongoClient('192.168.100.232',27017) conn = MongoClient('node01',27017) analysisDict = readLogAnalysis(conn) updateLogRuleAccuracy(conn, analysisDict) conn.close()<|fim_prefix|># repo: zhujunyong/python3-utils path: /plog/logrulesupdater.py #!/...
code_fim
hard
{ "lang": "python", "repo": "zhujunyong/python3-utils", "path": "/plog/logrulesupdater.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhujunyong/python3-utils path: /plog/logrulesupdater.py #!/usr/bin/env python3 # -*- coding: utf8 -*- ''' Created on 2017年5月9日 @author: zhujunyong ''' from pymongo import MongoClient from bson import ObjectId # find in logAnalysis ,condition: result is not null, ruleId is not null # return di...
code_fim
hard
{ "lang": "python", "repo": "zhujunyong/python3-utils", "path": "/plog/logrulesupdater.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, num_objects: int): super().__init__() self.num_objects = num_objects def forward(self, objects: torch.Tensor) -> torch.Tensor: batch_size, num_objects, object_size = objects.size() return torch.cat([ objects.unsqueeze(1).repeat(1, num...
code_fim
hard
{ "lang": "python", "repo": "mikomel/wild-relation-network", "path": "/wild_relation_network/layers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mikomel/wild-relation-network path: /wild_relation_network/layers.py from typing import List import torch from torch import nn class Identity(nn.Module): def forward(self, x: torch.Tensor) -> torch.Tensor: return x class LinearBNReLU(nn.Module): def __init__(self, in_dim: int...
code_fim
hard
{ "lang": "python", "repo": "mikomel/wild-relation-network", "path": "/wild_relation_network/layers.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return self.num_objects ** 3 class GroupObjectsIntoTriplesWith(nn.Module): def forward(self, objects: torch.Tensor, object: torch.Tensor) -> torch.Tensor: batch_size, num_objects, object_size = objects.size() return torch.cat([ objects.unsqueeze(1).repeat(1, num_o...
code_fim
hard
{ "lang": "python", "repo": "mikomel/wild-relation-network", "path": "/wild_relation_network/layers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Generate k-node sample graph (self.sample_vertex_matrix, self.sample_edge_matrix) partitioned_sample_graph = SampleGraph(args, partitioning_keys=partitioning_keys) partition_eval = partition_evaluation_model(args) # compute the embedding for the partitioned_sample_graph embeddin...
code_fim
hard
{ "lang": "python", "repo": "TsinghuaDatabaseGroup/AI4DBCode", "path": "/DatabasePartition/test_partition_key_evaluation.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: TsinghuaDatabaseGroup/AI4DBCode path: /DatabasePartition/test_partition_key_evaluation.py import itertools import random import numpy as np from scipy.optimize import minimize import sys import os import networkx as nx import torch import torch.nn as nn import torch.nn.functional as F import pa...
code_fim
hard
{ "lang": "python", "repo": "TsinghuaDatabaseGroup/AI4DBCode", "path": "/DatabasePartition/test_partition_key_evaluation.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># evaluate the query latency under the selected partitioning keys if __name__ == "__main__": # 生成参数 args = PartitionConfig() # 生成路径 success, msg = args.generate_paths() if not success: raise ValueError(msg) partitioning_keys = {'lineitem': ['l_orderkey', 'l_quantity'], 'o...
code_fim
hard
{ "lang": "python", "repo": "TsinghuaDatabaseGroup/AI4DBCode", "path": "/DatabasePartition/test_partition_key_evaluation.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Azure/azureml-examples path: /.devcontainer/jupyter_server_config.py ## Whether to allow the user to run the notebook as root<|fim_suffix|>erverApp.port = 8888 c.ServerApp.token = "" c.ServerApp.disable_check_xsrf = True c.ServerApp.allow_origin = "*"<|fim_middle|>. c.ServerApp.allow_root = True ...
code_fim
easy
{ "lang": "python", "repo": "Azure/azureml-examples", "path": "/.devcontainer/jupyter_server_config.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>erverApp.port = 8888 c.ServerApp.token = "" c.ServerApp.disable_check_xsrf = True c.ServerApp.allow_origin = "*"<|fim_prefix|># repo: Azure/azureml-examples path: /.devcontainer/jupyter_server_config.py ## Whether to allow the user to run the notebook as root<|fim_middle|>. c.ServerApp.allow_root = True ...
code_fim
easy
{ "lang": "python", "repo": "Azure/azureml-examples", "path": "/.devcontainer/jupyter_server_config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>disable_check_xsrf = True c.ServerApp.allow_origin = "*"<|fim_prefix|># repo: Azure/azureml-examples path: /.devcontainer/jupyter_server_config.py ## Whether to allow the user to run the notebook as root. c.ServerApp.allow_root = True c.ServerApp.ip = "*" c.S<|fim_middle|>erverApp.port = 8888 c.ServerApp...
code_fim
easy
{ "lang": "python", "repo": "Azure/azureml-examples", "path": "/.devcontainer/jupyter_server_config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>video = (tuple((adc(f, noise_model = noise_model[i], saturation = SATURATION, readout_noise = READOUT_NOISE, bit_depth = BIT_DEPTH) for i,f in enumerate(frames))) for frames in video) #video = load(video, NFRAMES_DUAL) if __name__ == "__main__": #: no need to load video, but th...
code_fim
hard
{ "lang": "python", "repo": "IJSComplexMatter/cddm", "path": "/examples/paper/simple_video/dual_video.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: IJSComplexMatter/cddm path: /examples/paper/simple_video/dual_video.py """ Dual-camera random triggered simple brownian motion video. This script also creates sample frames from both cameras (Fig 1 in the paper). """ from cddm.sim import simple_brownian_video, create_random_times1, adc from cdd...
code_fim
hard
{ "lang": "python", "repo": "IJSComplexMatter/cddm", "path": "/examples/paper/simple_video/dual_video.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: santosfamilyfoundation/SantosCloud path: /app/handlers/makeReport.py #!/usr/bin/env python import os import tornado.web from traffic_cloud_utils.pdf_generate import makePdf from traffic_cloud_utils.app_config import get_project_path from baseHandler import BaseHandler class MakeReportHandler(B...
code_fim
hard
{ "lang": "python", "repo": "santosfamilyfoundation/SantosCloud", "path": "/app/handlers/makeReport.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> status_code, reason = MakeReportHandler.handler(self.identifier) if status_code == 200: report_path = os.path.join(project_dir,\ 'santosreport.pdf') self.set_header('Content-Disposition',\ 'attachment;...
code_fim
hard
{ "lang": "python", "repo": "santosfamilyfoundation/SantosCloud", "path": "/app/handlers/makeReport.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sanjayts/codewars-py path: /kyu5/factorial_trailing_zeroes.py # https://www.codewars.com/kata/number-of-trailing-zeros-of-n/train/python from math import floor, log <|fim_suffix|> kmax = floor(log(n, 5)) num = sum(floor(n / 5 ** k) for k in range(1, kmax + 1)) return num assert ze...
code_fim
hard
{ "lang": "python", "repo": "sanjayts/codewars-py", "path": "/kyu5/factorial_trailing_zeroes.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> kmax = floor(log(n, 5)) num = sum(floor(n / 5 ** k) for k in range(1, kmax + 1)) return num assert zeros(30) == 7<|fim_prefix|># repo: sanjayts/codewars-py path: /kyu5/factorial_trailing_zeroes.py # https://www.codewars.com/kata/number-of-trailing-zeros-of-n/train/python from math import f...
code_fim
hard
{ "lang": "python", "repo": "sanjayts/codewars-py", "path": "/kyu5/factorial_trailing_zeroes.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: uw-it-aca/msca-provisioner path: /provisioner/management/commands/monitor_licenses.py from django.core.management.base import CommandError from provisioner.management.commands import ProvisionerCommand from provisioner.monitor import Monitor <|fim_suffix|> def handle(self, *args, **options):...
code_fim
medium
{ "lang": "python", "repo": "uw-it-aca/msca-provisioner", "path": "/provisioner/management/commands/monitor_licenses.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> try: monitor = Monitor() monitor.confirm_activation(); monitor.confirm_deactivation(); self.update_job() except Exception as err: raise CommandError('FAIL: %s' % (err))<|fim_prefix|># repo: uw-it-aca/msca-provisioner path: /provi...
code_fim
medium
{ "lang": "python", "repo": "uw-it-aca/msca-provisioner", "path": "/provisioner/management/commands/monitor_licenses.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Stops the pricing threads. """ pass @abc.abstractmethod def subscribe(self, subject): """ Subscribes to real-time price publications on a given `Subject` representing an instrument. :param subject: The price subject to subscribe to. ...
code_fim
hard
{ "lang": "python", "repo": "bidfx/bidfx-api-py", "path": "/bidfx/pricing/provider.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Un-subscribes from a previously subscribed price `Subject`. :param subject: The price subject to unsubscribe from. :type subject: Subject """ pass<|fim_prefix|># repo: bidfx/bidfx-api-py path: /bidfx/pricing/provider.py __all__ = ["PriceProvider"] imp...
code_fim
hard
{ "lang": "python", "repo": "bidfx/bidfx-api-py", "path": "/bidfx/pricing/provider.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bidfx/bidfx-api-py path: /bidfx/pricing/provider.py __all__ = ["PriceProvider"] import abc from .subject import Subject class PriceProvider(abc.ABC): """ A PriceProvider is an interface that encapsulates the operations of an underlying price provider implementation. """ <|fim_suf...
code_fim
hard
{ "lang": "python", "repo": "bidfx/bidfx-api-py", "path": "/bidfx/pricing/provider.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: simon-saliba/degiro-connector path: /degiro_connector/quotecast/models/session_storage.py import logging import requests import threading # FIX #61631955 # Degiro's server has a low level of security # Which is not compatible with OpenSSL 1.1.1 # https://stackoverflow.com/questions/61631955/pyth...
code_fim
hard
{ "lang": "python", "repo": "simon-saliba/degiro-connector", "path": "/degiro_connector/quotecast/models/session_storage.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self, headers: dict = None, hooks: dict = None, ) -> requests.Session: """ Args: headers (dict, optional): Headers to used for the Session. Defaults to None. hooks (dict, optional): Hooks fo...
code_fim
hard
{ "lang": "python", "repo": "simon-saliba/degiro-connector", "path": "/degiro_connector/quotecast/models/session_storage.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return session def reset_session(self, headers: dict = None, hooks: dict = None): self.__local_storage.session = self.build_session(headers=headers, hooks=hooks) def __init__(self, headers: dict = None, hooks: dict = None): self.__logger = logging.getLogger(self.__module_...
code_fim
hard
{ "lang": "python", "repo": "simon-saliba/degiro-connector", "path": "/degiro_connector/quotecast/models/session_storage.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> 'cflags_cc': [ '-fexceptions' ], 'libraries': [ '/path/to/libexiv2.a', '/path/to/libexpat.a' ], } ] }<|fim_prefix|># repo: jonathanlurie/exiv2node path: /binding.gyp { 'targets': [ { 'target_name': 'exiv2', 'sources': [ 'exiv2nod...
code_fim
medium
{ "lang": "python", "repo": "jonathanlurie/exiv2node", "path": "/binding.gyp", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jonathanlurie/exiv2node path: /binding.gyp { 'targets': [ { 'target_name': 'exiv2', 'sources': [ 'exiv2node.cc' ], 'include_dirs' : [ '/path/exiv2/include', '/path/to/expat/include', "<!(node -e \"require('nan')\")" ], 'xco...
code_fim
medium
{ "lang": "python", "repo": "jonathanlurie/exiv2node", "path": "/binding.gyp", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ChemGen/HackOutCode path: /rename.py #!/usr/bin/python """rename.py: Renames the output files of convert.sh""" import os <|fim_suffix|>j = 1 for i in range(1, len(content)): if content[i - 1] == "> <Key>\n": print(j) oldFileName = "out" + str(j) + ".png" newFileName...
code_fim
easy
{ "lang": "python", "repo": "ChemGen/HackOutCode", "path": "/rename.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>j = 1 for i in range(1, len(content)): if content[i - 1] == "> <Key>\n": print(j) oldFileName = "out" + str(j) + ".png" newFileName = content[i][:-1] + ".png" os.rename(oldFileName, newFileName) j = j + 1<|fim_prefix|># repo: ChemGen/HackOutCode path: /rename.p...
code_fim
easy
{ "lang": "python", "repo": "ChemGen/HackOutCode", "path": "/rename.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: swipswaps/sdr path: /somfy/epy_block_1.py """ Embedded Python Blocks: Each time this file is saved, GRC will instantiate the first class it finds to get ports and parameters of your block. The arguments to __init__ will be the parameters. All of them are required to have default values! """ im...
code_fim
hard
{ "lang": "python", "repo": "swipswaps/sdr", "path": "/somfy/epy_block_1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """arguments to this function show up as parameters in GRC""" gr.sync_block.__init__( self, name='Embedded Python Block', # will show up in GRC in_sig=[np.byte], out_sig=[np.byte] ) # if an attribute with the same name as a ...
code_fim
hard
{ "lang": "python", "repo": "swipswaps/sdr", "path": "/somfy/epy_block_1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: trojsten/web path: /trojsten/special/plugin_prask_7_2_1/migrations/0001_initial.py # Generated by Django 2.2.18 on 2021-04-06 12:53 import django.db.models.deletion from django.conf import settings from django.db import migrations, models <|fim_suffix|> dependencies = [ migrations.sw...
code_fim
hard
{ "lang": "python", "repo": "trojsten/web", "path": "/trojsten/special/plugin_prask_7_2_1/migrations/0001_initial.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.CreateModel( name="UserLevel", fields=[ ( "id", models.AutoField( auto_created=True, primary_key=True, serialize=False, verbose_name="ID" ), ...
code_fim
hard
{ "lang": "python", "repo": "trojsten/web", "path": "/trojsten/special/plugin_prask_7_2_1/migrations/0001_initial.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # ### commands auto generated by Alembic - please adjust! ### op.add_column('car', sa.Column('image_file_name', sa.String(length=140), nullable=True)) op.drop_column('car', 'image_path') # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please...
code_fim
medium
{ "lang": "python", "repo": "MarkusWET/ey-mann-wo-ist-mein-autoverleih", "path": "/ws1_restful_autoverleih/migrations/versions/05a0fb418234_.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MarkusWET/ey-mann-wo-ist-mein-autoverleih path: /ws1_restful_autoverleih/migrations/versions/05a0fb418234_.py """empty message Revision ID: 05a0fb418234 Revises: 50985ada54fb Create Date: 2018-04-01 14:27:30.440304 """ from alembic import op import sqlalchemy as sa <|fim_suffix|>def upgrade()...
code_fim
medium
{ "lang": "python", "repo": "MarkusWET/ey-mann-wo-ist-mein-autoverleih", "path": "/ws1_restful_autoverleih/migrations/versions/05a0fb418234_.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>CAMEL_TO_SNAKE_CASE_TABLE = { "apiVersion": "api_version", "lastTransitionTime": "last_transition_time", "nodeSelector": "node_selector", "routerIDs": "router_i_ds", "verbatimConfig": "verbatim_config", }<|fim_prefix|># repo: isabella232/pulumi-kubernetes-crds path: /operators/keepali...
code_fim
hard
{ "lang": "python", "repo": "isabella232/pulumi-kubernetes-crds", "path": "/operators/keepalived-operator/python/pulumi_pulumi_kubernetes_crds_operators_keepalived_operator/_tables.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: isabella232/pulumi-kubernetes-crds path: /operators/keepalived-operator/python/pulumi_pulumi_kubernetes_crds_operators_keepalived_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 doin...
code_fim
hard
{ "lang": "python", "repo": "isabella232/pulumi-kubernetes-crds", "path": "/operators/keepalived-operator/python/pulumi_pulumi_kubernetes_crds_operators_keepalived_operator/_tables.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if buffer_args.get('buffer_size', 0) <= 0: logger.info('This algorithm does not need sepecify a data buffer outside the model.') return None _buffer_type = buffer_args.get('type', 'None') logger.info(_buffer_type) if _buffer_type in BufferDict.keys(): Buffer = get...
code_fim
hard
{ "lang": "python", "repo": "123world/RLs", "path": "/rls/parse/parse_buffer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> _buffer_type = buffer_args.get('type', 'None') logger.info(_buffer_type) if _buffer_type in BufferDict.keys(): Buffer = getattr(importlib.import_module(f'rls.memories.replay_buffer'), BufferDict[_buffer_type]) return Buffer(batch_size=buffer_args['batc...
code_fim
hard
{ "lang": "python", "repo": "123world/RLs", "path": "/rls/parse/parse_buffer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 123world/RLs path: /rls/parse/parse_buffer.py #!/usr/bin/env python3 # encoding: utf-8 import importlib from typing import Optional from rls.common.config import Config from rls.memories.replay_buffer import ReplayBuffer from rls.utils.logging_utils import get_logger logger = get_logger(__nam...
code_fim
hard
{ "lang": "python", "repo": "123world/RLs", "path": "/rls/parse/parse_buffer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: EPFL-LCSB/rekindle path: /sampling/flux_parameter_function.py # -*- coding: utf-8 -*- """ .. module:: skimpy :platform: Unix, Windows :synopsis: Simple Kinetic Models in Python .. moduleauthor:: SKiMPy team [---------] Copyright 2017 Laboratory of Computational Systems Biotechnology (LCS...
code_fim
hard
{ "lang": "python", "repo": "EPFL-LCSB/rekindle", "path": "/sampling/flux_parameter_function.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.function(input,flux_parameter_values) _fluxes = np.array([flux_dict[rxn.name] for rxn in model.reactions.values() ]) flux_parameter_values = _fluxes / flux_parameter_values if np.any(flux_parameter_values < 0): ixs = np.where(flux_parameter_values < 0)[0]...
code_fim
hard
{ "lang": "python", "repo": "EPFL-LCSB/rekindle", "path": "/sampling/flux_parameter_function.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if np.any(flux_parameter_values < 0): ixs = np.where(flux_parameter_values < 0)[0] model.logger.info("Fluxes {} are not aligned with deltaG values!".format([model.reactions.iloc(i)[0] for i in ixs])) raise ValueError for rxn,v in zip(model.reactions.val...
code_fim
hard
{ "lang": "python", "repo": "EPFL-LCSB/rekindle", "path": "/sampling/flux_parameter_function.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: trungphansg/ddlf path: /examples/task-run.py # Distributed DL Client runs on the master node # @author: Trung Phan # @created date: 2021-06-28 # @last modified date: # @note: from ddlf.cluster import * code1 = ''' def f(self): self.data['total'] = 1000 setattr(Worker, 'f...
code_fim
medium
{ "lang": "python", "repo": "trungphansg/ddlf", "path": "/examples/task-run.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>async def main(): cluster = Cluster() await cluster.connect() await cluster.run_code(code1) await cluster.run_code(code2) res = await cluster.run_method(g, a=4000, b=2000 ) print(f"result: {res}") res = await cluster.show_data() print(f"result: {res}") # await cluster.c...
code_fim
medium
{ "lang": "python", "repo": "trungphansg/ddlf", "path": "/examples/task-run.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> bbb: int one: One @dataclass class Three(Interface): bbb: int two: Two @dataclass class All(Interface): bbb: int one: One two: Two three: Three """ @pytest.mark.filterwarnings("ignore::UserWarning") @pytest.mark.parametriz...
code_fim
hard
{ "lang": "python", "repo": "cs-cordero/py-ts-interfaces", "path": "/py_ts_interfaces/tests/tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bbb: int """ TEST_NINE = """ from dataclasses import dataclass from py_ts_interfaces import Interface @dataclass class Foo(Interface): aaa: str @dataclass class Bar(Interface): bbb: int foo: Foo """ TEST_TEN = """ from dataclasses import data...
code_fim
hard
{ "lang": "python", "repo": "cs-cordero/py-ts-interfaces", "path": "/py_ts_interfaces/tests/tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cs-cordero/py-ts-interfaces path: /py_ts_interfaces/tests/tests.py from copy import deepcopy from itertools import count from typing import Any from unittest.mock import patch import pytest from astroid import AnnAssign, ClassDef, extract_node from py_ts_interfaces import Interface, Parser from...
code_fim
hard
{ "lang": "python", "repo": "cs-cordero/py-ts-interfaces", "path": "/py_ts_interfaces/tests/tests.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@app.route('/manager/complete/<pce_id>/') def routeCompleteProject(pce_id): """ Input: pce_id<str> Output: HTML from template Sends a request to crud.py to update the status of a project to "Completed" and assign a date of completion. """ return completeProject(pce_id) @app.route('/manager/view/...
code_fim
hard
{ "lang": "python", "repo": "tiffanystallings/project-manager", "path": "/app/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>@app.route('/manager/edit/<pce_id>', methods=['GET', 'POST']) def editProject(pce_id): project = getProjectById(pce_id) if request.method == 'POST': return updateProject(project, request) return render_template('edit_project.html', project=project) @app.route('/manager/delete/<pce_id>') def deleteP...
code_fim
hard
{ "lang": "python", "repo": "tiffanystallings/project-manager", "path": "/app/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: tiffanystallings/project-manager path: /app/views.py from flask import Flask from flask import render_template from flask import request import os from crud import * from models import app #app = Flask(__name__) @app.route('/') @app.route('/home/<int:page>/') def showMain(page=1): """ Inp...
code_fim
hard
{ "lang": "python", "repo": "tiffanystallings/project-manager", "path": "/app/views.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_amours.py #calss header class _AMOURS(): def __init__(self,): <|fim_suffix|> self.basic = ['amour']<|fim_middle|> self.name = "AMOURS" self.definitions = amour self.parents = [] self.childen = [] self.properties = [] self.jsondat...
code_fim
medium
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/otherforms/_amours.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.basic = ['amour']<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_amours.py #calss header class _AMOURS(): def __init__(self,): self.name = "AMOURS" self.definitions = amour <|fim_middle|> self.parents = [] self.childen = [] self.properties = [] self.jsonda...
code_fim
medium
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/otherforms/_amours.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: virtualdvid/NLP path: /gapnlp/syntax.py 4: tele = "1" if toks[0] != '1': return None, 0, 0 for i in range(1,4): if not toks[i].isdigit(): return None, 0, 0 tele += t...
code_fim
hard
{ "lang": "python", "repo": "virtualdvid/NLP", "path": "/gapnlp/syntax.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Check if this word is a gender reference w, n, t = self._isGender(self._words, i) if w is not None: skip = n if self._gender is True: words.append( {'word': w, 'tag': t } ) ...
code_fim
hard
{ "lang": "python", "repo": "virtualdvid/NLP", "path": "/gapnlp/syntax.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: virtualdvid/NLP path: /gapnlp/syntax.py x]['word'] in ['fax']: tag = Vocabulary.TELEPHONE_FAX index += 1 if index == length: return None, 0, 0 if words[index]['word'] in ['number', 'no', 'num', ]: index += 1 ...
code_fim
hard
{ "lang": "python", "repo": "virtualdvid/NLP", "path": "/gapnlp/syntax.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def next_knight_moves(self, position): col = position.col row = position.row return [ ChessBoardPosition(col-2,row-1), ChessBoardPosition(col-2,row+1), ChessBoardPosition(col+2,row-1), ChessBoardPosition(col+2,row+1), ...
code_fim
medium
{ "lang": "python", "repo": "virajs/codeeval", "path": "/0-easy/knight-moves/main.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: virajs/codeeval path: /0-easy/knight-moves/main.py import sys CHESS_BOARD_SIZE = 8 class ChessBoardPosition(object): def __init__(self, col, row): self.col = col self.row = row @staticmethod def position_string_to_ints(position_string): col = ord(position_st...
code_fim
hard
{ "lang": "python", "repo": "virajs/codeeval", "path": "/0-easy/knight-moves/main.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> tebd = qtn.TEBD(psi0, H, dt=dt, tol=tol, imag=True) assert tebd.cyclic == cyclic tebd.split_opts['cutoff'] = 1e-10 if (dt is None and tol is None): with pytest.raises(ValueError): tebd.update_to(tf, order=order) return tebd....
code_fim
hard
{ "lang": "python", "repo": "jcmgray/quimb", "path": "/tests/test_tensor/test_tensor_tebd.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jcmgray/quimb path: /tests/test_tensor/test_tensor_tebd.py import pytest from pytest import approx import numpy as np import quimb as qu import quimb.tensor as qtn from quimb.tensor.tensor_1d_tebd import OTOC_local class TestTEBD: def test_setup_and_sweep(self): n = 10 H_i...
code_fim
hard
{ "lang": "python", "repo": "jcmgray/quimb", "path": "/tests/test_tensor/test_tensor_tebd.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """test the type equality function""" for seq, exp in [ ((1, ), True), ((1, 1.0, 1+0j), False), ((1, 10, 100), True), ((True, False, 10), False), (['abc', 'def', 'ghi'], True), (np.linspace(0, 1, 100), True), ]: assert same_type(*seq) ==...
code_fim
medium
{ "lang": "python", "repo": "jaredg2/labcore", "path": "/test/pytest/test_utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jaredg2/labcore path: /test/pytest/test_utils.py import pytest import numpy as np from labcore.utils import same_type <|fim_suffix|> assert not same_type( True, False, True, False, target_type=int, ) with pytest.raises(ValueError): same_type()<|fim_middle|>def test_...
code_fim
hard
{ "lang": "python", "repo": "jaredg2/labcore", "path": "/test/pytest/test_utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def metrics(self): metrics = { "weight_loss": self.l2_loss.item(), } # you can print them to command line here. with Torch models its somehow not reportet to the logger print(metrics) return metrics<|fim_prefix|># repo: mg64ve/ray_custom_loss path: /...
code_fim
hard
{ "lang": "python", "repo": "mg64ve/ray_custom_loss", "path": "/custom_loss_l2_model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mg64ve/ray_custom_loss path: /custom_loss_l2_model.py import numpy as np from ray.rllib.models.modelv2 import ModelV2, restore_original_dimensions from ray.rllib.models.tf.tf_action_dist import Categorical from ray.rllib.models.tf.tf_modelv2 import TFModelV2 from ray.rllib.models.tf.fcnet import...
code_fim
hard
{ "lang": "python", "repo": "mg64ve/ray_custom_loss", "path": "/custom_loss_l2_model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># rank most similar items movies=recommendations.transformPrefs(recommendations.critics) print(recommendations.topMatches(movies,'Superman Returns')) # recommend items to user print(recommendations.getRecommendations(recommendations.critics,'Toby')) print(recommendations.getRecommendations(recommendation...
code_fim
medium
{ "lang": "python", "repo": "nishitpatel01/Data-Science-Toolbox", "path": "/models/collaborative_filtering/workbench.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>itemsim = recommendations.calculateSimilarItems(recommendations.critics) print(itemsim) print(recommendations.getRecommendedItems(recommendations.critics,itemsim,'Toby'))<|fim_prefix|># repo: nishitpatel01/Data-Science-Toolbox path: /models/collaborative_filtering/workbench.py from recommendations import...
code_fim
hard
{ "lang": "python", "repo": "nishitpatel01/Data-Science-Toolbox", "path": "/models/collaborative_filtering/workbench.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nishitpatel01/Data-Science-Toolbox path: /models/collaborative_filtering/workbench.py from recommendations import critics print(critics['Lisa Rose']) # check two types of similarity metrics import recommendations print(recommendations.sim_distance(recommendations.critics, 'Lisa Rose','Gene Seymo...
code_fim
medium
{ "lang": "python", "repo": "nishitpatel01/Data-Science-Toolbox", "path": "/models/collaborative_filtering/workbench.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Test cost center permissions """ self.data['company'] = User.objects.get( username='c2e1').profile.company.pk response = self.client.post(self.url, self.data, format='json') #cost center is created, but provided company is ignored. se...
code_fim
hard
{ "lang": "python", "repo": "dajeffri/RESTParcel", "path": "/data/tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Test cost center update permissions """ costCenterPK = CostCenter.objects.get(name='c2c1').pk url = reverse('CostCenter-detail', kwargs={'pk': costCenterPK}) response = self.client.put(url, self.data, format='json') #This is 404 instead of 403 be...
code_fim
hard
{ "lang": "python", "repo": "dajeffri/RESTParcel", "path": "/data/tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dajeffri/RESTParcel path: /data/tests.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase from data.models import Address, Company, Profile, CostCenter, MailPiece from dja...
code_fim
hard
{ "lang": "python", "repo": "dajeffri/RESTParcel", "path": "/data/tests.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: maduhu/marvin path: /marvin/cloudstackAPI/removeCertFromLoadBalancer.py """Removes a certificate from a load balancer rule""" from baseCmd import * from baseResponse import * <|fim_suffix|> def __init__(self): self.isAsync = "true" """the ID of the load balancer rule""" ...
code_fim
medium
{ "lang": "python", "repo": "maduhu/marvin", "path": "/marvin/cloudstackAPI/removeCertFromLoadBalancer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self): self.isAsync = "true" """the ID of the load balancer rule""" """Required""" self.lbruleid = None self.typeInfo['lbruleid'] = 'uuid' self.required = ["lbruleid", ] class removeCertFromLoadBalancerResponse (baseResponse): typeInfo...
code_fim
medium
{ "lang": "python", "repo": "maduhu/marvin", "path": "/marvin/cloudstackAPI/removeCertFromLoadBalancer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """any text associated with the success or failure""" self.displaytext = None self.typeInfo['displaytext'] = 'string' """true if operation is executed successfully""" self.success = None self.typeInfo['success'] = 'boolean'<|fim_prefix|># repo: maduhu/marvin...
code_fim
hard
{ "lang": "python", "repo": "maduhu/marvin", "path": "/marvin/cloudstackAPI/removeCertFromLoadBalancer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self, data: Any, services: Services, datastore: DatastoreService, logging: LoggingModule, user_id: int, ): super().__init__(services, datastore, logging) self.data = data self.logger = logging.getLogger(__name__) self.user...
code_fim
hard
{ "lang": "python", "repo": "OpenSlides/openslides-backend", "path": "/openslides_backend/presenter/base.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: OpenSlides/openslides-backend path: /openslides_backend/presenter/base.py from abc import abstractmethod from typing import Any, Callable, Optional from fastjsonschema import JsonSchemaException from openslides_backend.shared.base_service_provider import BaseServiceProvider from ..services.dat...
code_fim
medium
{ "lang": "python", "repo": "OpenSlides/openslides-backend", "path": "/openslides_backend/presenter/base.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> request = requests.get( 'https://viacep.com.br/ws/{}/json/'.format(cep_input)) address_data = request.json() if 'erro' not in address_data: print('######################') print('==> CEP ENCONTRADO <==') print('######################') print() ...
code_fim
hard
{ "lang": "python", "repo": "CleiberReis/python-api-cep", "path": "/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CleiberReis/python-api-cep path: /main.py import requests def main(): print() print('#####################') print('### Consulta CEP ####') print('#####################') print() cep_input = input('Digite um cep para a consulta: ') print() if len(cep_input) !=...
code_fim
hard
{ "lang": "python", "repo": "CleiberReis/python-api-cep", "path": "/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> face_color = kwargs.get('face_color') self._face_color = _get_hex_color(face_color) if face_color is not None else None self._face_alpha = kwargs.get('face_alpha') def write(self, w): ''' Write the polygon. Args: w (_Writer): Writer used t...
code_fim
hard
{ "lang": "python", "repo": "fishke22/gmplot", "path": "/gmplot/drawables/polygon.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ''' Write the polygon. Args: w (_Writer): Writer used to write the polygon. ''' w.write('new google.maps.Polygon({') w.indent() w.write('clickable: false,') w.write('geodesic: true,') if self._edge_color is not None: w.wr...
code_fim
hard
{ "lang": "python", "repo": "fishke22/gmplot", "path": "/gmplot/drawables/polygon.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: fishke22/gmplot path: /gmplot/drawables/polygon.py from gmplot.color import _get_hex_color from gmplot.utility import _format_LatLng class _Polygon(object): def __init__(self, lats, lngs, precision, **kwargs): ''' Args: lats ([float]): Latitudes. lngs ...
code_fim
hard
{ "lang": "python", "repo": "fishke22/gmplot", "path": "/gmplot/drawables/polygon.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> row=0 while row<7: col=0 while col<7: if (col==3 or row==6) or (row<3 and row+col==2): print("*",end="") else: print(end=" ") col+=1 row+=1 print()<|fim_prefix|># repo: Ashokkommi0001/patt...
code_fim
hard
{ "lang": "python", "repo": "Ashokkommi0001/patterns", "path": "/Num/one.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ashokkommi0001/patterns path: /Num/one.py def for_one(): for row in range(7): for col in range(7): if (col==3 or row==6) or (row<3 and row+col==2): print("*",end="") else: print(end=" ") print() <|fim_suffix|> ...
code_fim
hard
{ "lang": "python", "repo": "Ashokkommi0001/patterns", "path": "/Num/one.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wikiteams/linda-nlp path: /scream.py import sys import logging import logging.handlers import logging.config import datetime DISABLE__STD = False logging.config.fileConfig('logging.conf') logger = logging.getLogger(__name__) intelliTag_verbose = False def log(s): if intell...
code_fim
medium
{ "lang": "python", "repo": "wikiteams/linda-nlp", "path": "/scream.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def log_error(s): if intelliTag_verbose: print str(datetime.datetime.now()) + ': ' + str(s) logger.error(s) def log_warning(s): if intelliTag_verbose: print str(datetime.datetime.now()) + ': ' + str(s) logger.warning(s) def log_debug(s): if inte...
code_fim
hard
{ "lang": "python", "repo": "wikiteams/linda-nlp", "path": "/scream.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if (intelliTag_verbose) and (not DISABLE__STD): sys.stdout.write(str(s)) sys.stdout.flush()<|fim_prefix|># repo: wikiteams/linda-nlp path: /scream.py import sys import logging import logging.handlers import logging.config import datetime DISABLE__STD = False logging.config...
code_fim
hard
{ "lang": "python", "repo": "wikiteams/linda-nlp", "path": "/scream.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return new_codes def __sub_operation(line, key=None): ''' Helper for _apply_mutation(). The key defines which mutations will be made as a list, so multiple mutations can be made for each operation. ''' if not key: key = {"+": ["-"], "-": ["+"], ">": ["<"], "<": ["<"], "/": ["*"], ...
code_fim
hard
{ "lang": "python", "repo": "YangVincent/SmartContractTester", "path": "/Flask/app/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: YangVincent/SmartContractTester path: /Flask/app/views.py from wtforms import SelectField, TextField, TextAreaField, validators, StringField, SubmitField from flask import render_template, flash, jsonify, Flask, request, Response from werkzeug import secure_filename from app import app, csrf from...
code_fim
hard
{ "lang": "python", "repo": "YangVincent/SmartContractTester", "path": "/Flask/app/views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Run the Mythril test suite on a provided script """ is_request = False if not test_subject: test_subject = request.form.get('data') is_request = True m = Mythril(test_subject) result = m.mythril(test_subject) output = result[1].decode('utf-8') decoder = json.decoder.JSONDecoder() ou...
code_fim
hard
{ "lang": "python", "repo": "YangVincent/SmartContractTester", "path": "/Flask/app/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: M1koto/sc-backend path: /flask_utils/password_enforcer.py from password_strength import PasswordPolicy class PasswordEnforcer: # A convenience constructor for initializing the password strength enforcer def __init__(self): self.pass_policy = PasswordPolicy.from_names( ...
code_fim
medium
{ "lang": "python", "repo": "M1koto/sc-backend", "path": "/flask_utils/password_enforcer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Check if the password is strong enough or not def check(self, password): errors = self.pass_policy.test(password) return len(errors) == 0<|fim_prefix|># repo: M1koto/sc-backend path: /flask_utils/password_enforcer.py from password_strength import PasswordPolicy class PasswordEn...
code_fim
hard
{ "lang": "python", "repo": "M1koto/sc-backend", "path": "/flask_utils/password_enforcer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yerihyo/foxylib path: /foxylib/tools/sendgrid/sendgrid_tool.py import logging import os from functools import lru_cache from foxylib.singleton.env.foxylib_env import FoxylibEnv from sendgrid import SendGridAPIClient from foxylib.tools.log.foxylib_logger import FoxylibLogger # class MailConfig...
code_fim
hard
{ "lang": "python", "repo": "yerihyo/foxylib", "path": "/foxylib/tools/sendgrid/sendgrid_tool.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # @classmethod # def SendDynamic(cls): # """ Send a dynamic email to a list of email addresses # # :returns API response code # :raises Exception e: raises an exception """ # # create Mail object and populate # message = Mail( # from_email=F...
code_fim
hard
{ "lang": "python", "repo": "yerihyo/foxylib", "path": "/foxylib/tools/sendgrid/sendgrid_tool.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: faierbol/VK_marketplace path: /backend/app/tests/utils/user.py import random from base64 import b64encode from hashlib import sha256 from hmac import HMAC from typing import Optional from urllib.parse import urlencode from sqlalchemy.orm import Session from app import crud from app.core.config ...
code_fim
hard
{ "lang": "python", "repo": "faierbol/VK_marketplace", "path": "/backend/app/tests/utils/user.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def user_auth_header(id: int) -> str: vk_params = { "vk_user_id": str(id), "vk_app_id": "1", "vk_is_app_user": "1", "vk_language": "ru", } ordered = {k: vk_params[k] for k in sorted(vk_params)} secret = settings.MINI_APP_SECRET_KEY sign = b64encode( ...
code_fim
medium
{ "lang": "python", "repo": "faierbol/VK_marketplace", "path": "/backend/app/tests/utils/user.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> user_in = UserCreate(id=id or random.randint(1, 1000)) user = crud.user.create(db=db, obj_in=user_in) return user<|fim_prefix|># repo: faierbol/VK_marketplace path: /backend/app/tests/utils/user.py import random from base64 import b64encode from hashlib import sha256 from hmac import HMAC fro...
code_fim
hard
{ "lang": "python", "repo": "faierbol/VK_marketplace", "path": "/backend/app/tests/utils/user.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Xiaoyu-Xing/algorithms path: /amazon/python/find_all_anagrams_in_a_string_438.py # Reference: # https://leetcode.com/problems/find-all-anagrams-in-a-string/discuss/92007/Sliding-Window-algorithm-template-to-solve-all-the-Leetcode-substring-search-problem. # https://leetcode.com/problems/find-all-...
code_fim
medium
{ "lang": "python", "repo": "Xiaoyu-Xing/algorithms", "path": "/amazon/python/find_all_anagrams_in_a_string_438.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> res = [] if len(s) < len(p): return [] s_dict = {} p_dict = {} for letter in p: p_dict[letter] = p_dict.get(letter, 0) + 1 for letter in s[:len(p) - 1]: s_dict[letter] = s_dict.get(letter, 0) + 1 for i in range(len(p) - 1, len(s)): s_dict[s[i]] =...
code_fim
medium
{ "lang": "python", "repo": "Xiaoyu-Xing/algorithms", "path": "/amazon/python/find_all_anagrams_in_a_string_438.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def setPosition(self, position): self.__position = position def getColour(self): return self.__colour def setColour(self, colour): self.__colour = colour<|fim_prefix|># repo: mccolm-robotics/Claver-AI-Assistant path: /Claver/assistant/avatar/entities/Light.py from py...
code_fim
medium
{ "lang": "python", "repo": "mccolm-robotics/Claver-AI-Assistant", "path": "/Claver/assistant/avatar/entities/Light.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mccolm-robotics/Claver-AI-Assistant path: /Claver/assistant/avatar/entities/Light.py from pyrr import Vector3 class Light: def __init__(self, position, colour, attenuation=Vector3((1, 0, 0))): self.__position = position self.__colour = colour self.__attenuation = at...
code_fim
medium
{ "lang": "python", "repo": "mccolm-robotics/Claver-AI-Assistant", "path": "/Claver/assistant/avatar/entities/Light.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: KenN7/PyTiltWebsite path: /pytilt-api/influxmodels.py #!/usr/bin/python3 from influxdb import InfluxDBClient class Influxdb: def __init__(self, host, port): self.host = host #8086 self.port = port def connect(self, db): <|fim_suffix|> def write(self, json): ...
code_fim
hard
{ "lang": "python", "repo": "KenN7/PyTiltWebsite", "path": "/pytilt-api/influxmodels.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }