text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: couchbase/perfrunner path: /perfrunner/utils/debug.py import glob import os import re import shutil import zipfile from argparse import ArgumentParser from collections import defaultdict from multiprocessing import set_start_method from pathlib import Path from typing import List from logger imp...
code_fim
hard
{ "lang": "python", "repo": "couchbase/perfrunner", "path": "/perfrunner/utils/debug.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def create_bucket_hostname(node_name: str) -> str: node_name = node_name.split('@')[1].split('.') hostname = '{}.{}'.format(node_name[0], node_name[1]) return hostname def check_if_log_file_exists(bucket_name: str, file_key: str): cmd = 'aws s3api wait object-exists \ --bucket {} \ ...
code_fim
hard
{ "lang": "python", "repo": "couchbase/perfrunner", "path": "/perfrunner/utils/debug.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: emedvedev/pre-commit-hook-yamlfmt path: /pre_commit_hooks/yamlfmt #!/usr/bin/env python3 """Format YAML files.""" import argparse import sys from ruamel.yaml import YAML # pylint: disable=import-error DEFAULT_INDENT = { "mapping": 4, "sequence": 6, "offset": 4, } class Cli: ...
code_fim
hard
{ "lang": "python", "repo": "emedvedev/pre-commit-hook-yamlfmt", "path": "/pre_commit_hooks/yamlfmt", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Abort """ sys.stderr.write(msg) sys.exit(1) if __name__ == "__main__": ARGS = Cli().parser.parse_args() FORMATTER = Formatter( mapping=ARGS.mapping, sequence=ARGS.sequence, offset=ARGS.offset, colons=ARGS.colons, width=ARGS.widt...
code_fim
hard
{ "lang": "python", "repo": "emedvedev/pre-commit-hook-yamlfmt", "path": "/pre_commit_hooks/yamlfmt", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def load_monitoring_capabilities(): """ Loads the monitoring capabilities in terms of list of monitorable metrics and collector API """ config = ConfigParser.ConfigParser() for metric_name, metric_infos in METRICS.iteritems(): if 'monitoring' in metric_infos.keys():...
code_fim
hard
{ "lang": "python", "repo": "IntelLabsEurope/OCCI-SLAs", "path": "/api/create_monitoring_records.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: IntelLabsEurope/OCCI-SLAs path: /api/create_monitoring_records.py #!/usr/bin/env python # # Copyright (c) 2015 Intel Innovation and Research Ireland Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You ma...
code_fim
hard
{ "lang": "python", "repo": "IntelLabsEurope/OCCI-SLAs", "path": "/api/create_monitoring_records.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> monitoring_records = DB.monitoring.find({'name': monitoring_sys}) if monitoring_records.count() > 0: mon_record = monitoring_records[0] try: mon_metrics = mon_record['metrics'] if metric_name not in mon_metric...
code_fim
hard
{ "lang": "python", "repo": "IntelLabsEurope/OCCI-SLAs", "path": "/api/create_monitoring_records.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert FLAGS.field != '' (study, rev_study) = ProcessModel(file(FLAGS.in_model)) Report(study) print Report(rev_study) if __name__ == '__main__': main(sys.argv)<|fim_prefix|># repo: rozim/KaggleFindingElo path: /study-field-...
code_fim
medium
{ "lang": "python", "repo": "rozim/KaggleFindingElo", "path": "/study-field-buckets.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rozim/KaggleFindingElo path: /study-field-buckets.py #!/usr/bin/python import sys import cjson import gflags import collections import numpy import random FLAGS = gflags.FLAGS gflags.DEFINE_string('in_model', 'model.xjson', 'Output of generate-model.py') gflags.DEFINE_string('field', '', '') gf...
code_fim
medium
{ "lang": "python", "repo": "rozim/KaggleFindingElo", "path": "/study-field-buckets.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try: argv = FLAGS(argv) # parse flags except gflags.FlagsError, e: print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) assert FLAGS.field != '' (study, rev_study) = ProcessModel(file(FLAGS.in_model)) Report(study) print Report(rev_study) ...
code_fim
hard
{ "lang": "python", "repo": "rozim/KaggleFindingElo", "path": "/study-field-buckets.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Tencent/bk-base path: /src/datamgr/metadata/metadata_biz/types/entities/preference.py # -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making BK-BASE 蓝鲸基础平台 available. Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. BK-BASE 蓝鲸基础平台...
code_fim
hard
{ "lang": "python", "repo": "Tencent/bk-base", "path": "/src/datamgr/metadata/metadata_biz/types/entities/preference.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@as_metadata @attr.s class DatamonitorAlertConfig(Preference): id = attr.ib(type=int, metadata={'identifier': True, 'dgraph': {'index': ['int']}}) monitor_target = attr.ib(type=str) monitor_config = attr.ib(type=str) notify_config = attr.ib(type=str) trigger_config = attr.ib(type=str) ...
code_fim
medium
{ "lang": "python", "repo": "Tencent/bk-base", "path": "/src/datamgr/metadata/metadata_biz/types/entities/preference.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def try_request(url, headers=None, proxies=None, times=3, interval=10, timeout=3): """尝试执行HTTP请求:尝试请求times次,每次请求之间间隔interval秒,如果最终请求失败则返回None""" for _ in range(times): if response := do_request(url=url, headers=headers, proxies=proxies, timeout=timeout): return response ...
code_fim
hard
{ "lang": "python", "repo": "ChangxingJiang/Utils4R", "path": "/Utils4R/request.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ChangxingJiang/Utils4R path: /Utils4R/request.py import time import requests def do_request(url, headers=None, proxies=None, timeout=3): """执行HTTP请求:如果请求成功则返回请求结果;如果请求失败则返回None""" try: if response := requests.get(url=url, headers=headers, proxies=proxies, timeout=timeout): ...
code_fim
medium
{ "lang": "python", "repo": "ChangxingJiang/Utils4R", "path": "/Utils4R/request.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: wf-hahaha/Cognitive-Map path: /Network/navigation_network/params.py ''' Navigation Network, Written by Xiao For robot localization in a dynamic environment. ''' import numpy as np from lib.params import ADJACENT_NODES_SHIFT_GRID ACTION_ENCODING = dict(left=np.array([1,0,0]), right=np.array([0,1,...
code_fim
hard
{ "lang": "python", "repo": "wf-hahaha/Cognitive-Map", "path": "/Network/navigation_network/params.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>.1, SG=0.01} # ------------------------------------------------------------------------------ TRAIN_FRACTION = 0.7 VAL_FRACTION = 0.15 TEST_FRACTION = 0.15 # ------------------------------------------------------------------------------ DATA_DIR = './Network/datasets' # Training and validation data direct...
code_fim
hard
{ "lang": "python", "repo": "wf-hahaha/Cognitive-Map", "path": "/Network/navigation_network/params.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> state = env.reset() done = False while not done: action = agent(state) state, reward, done, _ = env.step(action) episode_result['path'].append(env.controller.last_event.metadata['agent']['position']) if done: break ...
code_fim
hard
{ "lang": "python", "repo": "GELIELEO/attention_on_midlevel", "path": "/alg_thor/utils/eval.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> agent = policy episode_result['path'].append(env.controller.last_event.metadata['agent']['position']) state = env.reset() done = False while not done: action = agent(state) state, reward, done, _ = env.step(action) episo...
code_fim
hard
{ "lang": "python", "repo": "GELIELEO/attention_on_midlevel", "path": "/alg_thor/utils/eval.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: GELIELEO/attention_on_midlevel path: /alg_thor/utils/eval.py import numpy as np import torch from torch.autograd import Variable from gym_robothor.envs import env_generator import ai2thor.util.metrics def evaluate_with_spl(env, policy, cuda, task_config_file): episode_results = [] for ...
code_fim
medium
{ "lang": "python", "repo": "GELIELEO/attention_on_midlevel", "path": "/alg_thor/utils/eval.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Conradwangt/watchmen-matryoshka-doll path: /watchmen/common/storage/storage_template.py from enum import Enum from typing import List from pydantic.main import BaseModel from watchmen.common.storage.engine_adaptor import find_template template = find_template() class OrderType(Enum): """...
code_fim
hard
{ "lang": "python", "repo": "Conradwangt/watchmen-matryoshka-doll", "path": "/watchmen/common/storage/storage_template.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def list_all_select(select: dict, model: BaseModel, name: str) -> list: pass # need to do def list_(where: dict, model: BaseModel, name: str) -> list: return template.list_(where, model, name) def list_select(select: dict, where: dict, model: BaseModel, name: str) -> list: pass # need to...
code_fim
hard
{ "lang": "python", "repo": "Conradwangt/watchmen-matryoshka-doll", "path": "/watchmen/common/storage/storage_template.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def insert_all(data: list, model: BaseModel, name: str): return template.insert_all(data, model, name) def update_one(one: any, model: BaseModel, name: str) -> any: return template.update_one(one, model, name) def update_one_first(where: dict, updates: dict, model: BaseModel, name: str) -> Ba...
code_fim
hard
{ "lang": "python", "repo": "Conradwangt/watchmen-matryoshka-doll", "path": "/watchmen/common/storage/storage_template.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bcgov/mds path: /services/core-api/tests/mines/mine/resources/test_mine_incident_resource.py import pytest import json from datetime import datetime, timedelta from app.extensions import db from app.api.incidents.models.mine_incident import MineIncident from tests.factories import MineFactory fro...
code_fim
hard
{ "lang": "python", "repo": "bcgov/mds", "path": "/services/core-api/tests/mines/mine/resources/test_mine_incident_resource.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> post_resp = test_client.post( f'/mines/{test_mine_guid}/incidents', json=data, headers=auth_headers['full_auth_header']) assert post_resp.status_code == 201, post_resp.response post_data = json.loads(post_resp.data.decode()) assert post_data['mine_guid'] == str(test_mine_guid) ...
code_fim
hard
{ "lang": "python", "repo": "bcgov/mds", "path": "/services/core-api/tests/mines/mine/resources/test_mine_incident_resource.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: onnx/onnx path: /onnx/reference/ops/op_lp_pool.py # Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0221,R0913,R0914 import numpy as np from onnx.reference.ops.op_pool_common import CommonPool <|fim_suffix|> def _run( # type: ign...
code_fim
medium
{ "lang": "python", "repo": "onnx/onnx", "path": "/onnx/reference/ops/op_lp_pool.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> kernel_element_count = np.prod(kernel_shape) return (np.power(kernel_element_count * power_average[0], 1.0 / p),)<|fim_prefix|># repo: onnx/onnx path: /onnx/reference/ops/op_lp_pool.py # Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W...
code_fim
hard
{ "lang": "python", "repo": "onnx/onnx", "path": "/onnx/reference/ops/op_lp_pool.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: gusdelact/pySearchML path: /kubeflow/components/prepare_env/run.py import sys import argparse import pathlib import gzip import json import requests from typing import Dict, Any, NamedTuple from urllib.parse import urljoin from google.cloud import storage, bigquery PATH = pathlib.Path(__file__...
code_fim
hard
{ "lang": "python", "repo": "gusdelact/pySearchML", "path": "/kubeflow/components/prepare_env/run.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bucket_obj = storage_client.bucket(bucket) if not bucket_obj.exists(): bucket_obj.create() # Query GA data query_path = PATH / f'{args.model_name}' / 'ga_data.sql' query = open(str(query_path)).read() print(query) job_config = bigquery.Q...
code_fim
hard
{ "lang": "python", "repo": "gusdelact/pySearchML", "path": "/kubeflow/components/prepare_env/run.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bugout-dev/infestor path: /python/infestor/manager.py from typing import Tuple, List, Optional import os from pathlib import Path import libcst as cst from . import visitors from . import transformers from .errors import * from .config import ( default_config_file, load_config, Infe...
code_fim
hard
{ "lang": "python", "repo": "bugout-dev/infestor", "path": "/python/infestor/manager.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if not self.is_reporter_imported(): self.add_reporter_import() def add_reporter_import(self) -> None: if self.is_reporter_imported(): return transformer = transformers.ImportReporterTransformer( self.reporter_module_path, self.reporter_objec...
code_fim
hard
{ "lang": "python", "repo": "bugout-dev/infestor", "path": "/python/infestor/manager.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: henrikgruner/Programvareutvikling path: /backend/auction/auctions/factories.py from datetime import datetime, timedelta from random import randint import factory import factory.fuzzy import pytz from django.contrib.auth.models import User <|fim_suffix|>class AuctionFactory(factory.DjangoModelFa...
code_fim
medium
{ "lang": "python", "repo": "henrikgruner/Programvareutvikling", "path": "/backend/auction/auctions/factories.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class AuctionFactory(factory.DjangoModelFactory): class Meta: model = Auction created = datetime.now(pytz.utc) title = factory.Faker("sentence", nb_words=4) author = factory.Iterator(User.objects.all()) description = factory.Faker("text", max_nb_chars=200, ext_word_list=None) ...
code_fim
medium
{ "lang": "python", "repo": "henrikgruner/Programvareutvikling", "path": "/backend/auction/auctions/factories.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> coords = [ nextPos[0]*wratio-1.5, nextPos[1]*hratio-1.5, 3, 3 ] pygame.draw.rect( screen, BLACK, coords) carts[nextPos] = (dirs, interDir) if crashed: coords = [ crashed[0]*wratio-1.5, crashed[1]*hratio-1.5, 3, 3 ...
code_fim
hard
{ "lang": "python", "repo": "Vanojx1/AdventOfCode2018", "path": "/D13/part1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Vanojx1/AdventOfCode2018 path: /D13/part1.py import pygame import numpy as np from collections import deque BLACK = (0,0,0) WHITE = (255, 255, 255) RED = (255,0,0) GRAY = (221,221,221) puzzleInput = open('input.txt', 'r').read().split('\n') mineGrid = map(lambda x: list(x), puzzleInput) def ge...
code_fim
hard
{ "lang": "python", "repo": "Vanojx1/AdventOfCode2018", "path": "/D13/part1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aws/aws-encryption-sdk-python path: /src/aws_encryption_sdk/internal/utils/__init__.py # Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A...
code_fim
hard
{ "lang": "python", "repo": "aws/aws-encryption-sdk-python", "path": "/src/aws_encryption_sdk/internal/utils/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def message_id(size): """Generates a new message ID. :param size: The size of the message id to generate, in bytes :type size: int :returns: Message ID :rtype: bytes """ return os.urandom(size) def get_aad_content_string(content_type, is_final_frame): """Prepares the ap...
code_fim
hard
{ "lang": "python", "repo": "aws/aws-encryption-sdk-python", "path": "/src/aws_encryption_sdk/internal/utils/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: moldyn/msmhelper path: /src/msmhelper/msm/utils/linalg.py # -*- coding: utf-8 -*- """Basic linear algebra method. BSD 3-Clause License Copyright (c) 2019-2020, Daniel Nagel All rights reserved. """ import decorit import numpy as np from msmhelper.utils import tests @decorit.alias('eigl') def...
code_fim
hard
{ "lang": "python", "repo": "moldyn/msmhelper", "path": "/src/msmhelper/msm/utils/linalg.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def _eigenvectors(matrix, nvals): """Estimate eigenvectors.""" if not tests.is_quadratic(matrix): raise TypeError('Matrix needs to be quadratic {0}'.format(matrix)) if nvals is None: nvals = len(matrix) elif nvals > len(matrix): raise TypeError( '{nval...
code_fim
hard
{ "lang": "python", "repo": "moldyn/msmhelper", "path": "/src/msmhelper/msm/utils/linalg.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Estimates the right eigenvalues of a quadratic matrix. Parameters ---------- matrix : ndarray Quadratic 2d matrix eigenvalues or determined of. nvals : int, optional Number of returned eigenvalues and -vectors. Using ensures probability of real valued matrices....
code_fim
hard
{ "lang": "python", "repo": "moldyn/msmhelper", "path": "/src/msmhelper/msm/utils/linalg.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: ungarj/mapchete path: /mapchete/formats/tools.py """ Functions handling output formats. This module deserves a cleaner rewrite some day. """ import datetime import logging import warnings from pprint import pformat from typing import Dict import dateutil.parser from rasterio.crs import CRS fro...
code_fim
hard
{ "lang": "python", "repo": "ungarj/mapchete", "path": "/mapchete/formats/tools.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Verify that both mappings of output metadata parameters are compatible. Parameters ---------- params1 : dict Output metadata parameters. params2 : dict Output metadata parameters. """ def _buffered_pyramid(pyramid): if isinstance(pyramid, dict)...
code_fim
hard
{ "lang": "python", "repo": "ungarj/mapchete", "path": "/mapchete/formats/tools.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Iterate through dictionary and try to parse values according to strategies.""" def _parse_val(val): for func, allowed_exception in strategies: try: return func(val) except allowed_exception: pass else: return v...
code_fim
hard
{ "lang": "python", "repo": "ungarj/mapchete", "path": "/mapchete/formats/tools.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class Meta: model = Post fields = ('id', 'title', 'created_on', 'author') author = fields.Str(attribute='author.username')<|fim_prefix|># repo: dmitriyvek/flask-blog path: /flask_blog/blog/api/serializers.py from marshmallow import fields, validate from flask_blog import ma from...
code_fim
hard
{ "lang": "python", "repo": "dmitriyvek/flask-blog", "path": "/flask_blog/blog/api/serializers.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dmitriyvek/flask-blog path: /flask_blog/blog/api/serializers.py from marshmallow import fields, validate from flask_blog import ma from flask_blog.blog.models import Post class PostDetailSerializer(ma.SQLAlchemySchema): <|fim_suffix|> '''Schema for Post list api''' class Meta: ...
code_fim
hard
{ "lang": "python", "repo": "dmitriyvek/flask-blog", "path": "/flask_blog/blog/api/serializers.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bridgecrewio/checkov path: /checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsCacheEnabled.py from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck from checkov.common.models.enums import CheckCategories class APIGatewayMethodSettingCacheEnab...
code_fim
hard
{ "lang": "python", "repo": "bridgecrewio/checkov", "path": "/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsCacheEnabled.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> name = "Ensure API Gateway method setting caching is enabled" id = "CKV_AWS_225" supported_resources = ['aws_api_gateway_method_settings'] categories = [CheckCategories.BACKUP_AND_RECOVERY] super().__init__(name=name, id=id, categories=categories, supported_resource...
code_fim
medium
{ "lang": "python", "repo": "bridgecrewio/checkov", "path": "/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsCacheEnabled.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def get_inspected_key(self): return "settings/[0]/caching_enabled" check = APIGatewayMethodSettingCacheEnabled()<|fim_prefix|># repo: bridgecrewio/checkov path: /checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsCacheEnabled.py from checkov.terraform.checks.resource.base_resourc...
code_fim
hard
{ "lang": "python", "repo": "bridgecrewio/checkov", "path": "/checkov/terraform/checks/resource/aws/APIGatewayMethodSettingsCacheEnabled.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: michalnand/reinforcement_learning_im path: /experiments/autoencoder_test/models/model_ae.py import torch import torch.nn as nn class Model(torch.nn.Module): def __init__(self, input_shape): super(Model, self).__init__() self.device = torch.device("cuda" if torch.cuda.is_avai...
code_fim
hard
{ "lang": "python", "repo": "michalnand/reinforcement_learning_im", "path": "/experiments/autoencoder_test/models/model_ae.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> torch.save(self.model_encoder.state_dict(), path + "model_ae_encoder.pt") torch.save(self.model_decoder.state_dict(), path + "model_ae_decoder.pt") def load(self, path): print("loading ", path) self.model_encoder.load_state_dict(torch.load(path + "model_ae_encoder.pt...
code_fim
hard
{ "lang": "python", "repo": "michalnand/reinforcement_learning_im", "path": "/experiments/autoencoder_test/models/model_ae.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x_ax_subvol, x_ax_subvol_ix = \ _find_boxcar_subvolume(x_ax, self.center, self.radius) return x_ax_subvol_ix def overlap_potential(self, c): """Determine the overlap potential of object self and object c. Overlap criterion based on the overlap potential val...
code_fim
hard
{ "lang": "python", "repo": "aluchies/particle_packing", "path": "/particle_packing/boxcar/Boxcar.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: aluchies/particle_packing path: /particle_packing/boxcar/Boxcar.py import numpy as np class Boxcar(object): """ """ def __init__(self, center, radius): """ """ center = float(center) self.center = center radius = float(radius) sel...
code_fim
hard
{ "lang": "python", "repo": "aluchies/particle_packing", "path": "/particle_packing/boxcar/Boxcar.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: ReiiSky/flowpipe path: /flowpipe/graph.py """A Graph of Nodes.""" from __future__ import print_function from __future__ import absolute_import from ascii_canvas.canvas import Canvas from ascii_canvas.item import Item from ascii_canvas.item import Line from .node import INode __all__ = ['Graph']...
code_fim
hard
{ "lang": "python", "repo": "ReiiSky/flowpipe", "path": "/flowpipe/graph.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Evaluate all sub nodes.""" for node in self.evaluation_sequence: node.evaluate() def serialize(self): """Serialize the graph in it's grid form.""" data = super(Graph, self).serialize() data['nodes'] = [node.serialize() for node in self.nodes] ...
code_fim
hard
{ "lang": "python", "repo": "ReiiSky/flowpipe", "path": "/flowpipe/graph.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> df_new = url2pandas(data_url, product, num_31day_blocks) # Get dataframe for block df = df.append(df_new) # Append to existing dataframe # Rename output dataframe columns based on requested product # and convert to useable data types if product == 'water_...
code_fim
hard
{ "lang": "python", "repo": "delgadom/py_noaa", "path": "/py_noaa/coops.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: delgadom/py_noaa path: /py_noaa/coops.py # If the data product is water levels, check that a datum is specified if product == 'water_level': if datum is None: raise ValueError('No datum specified for water level data.See' ' https://tidesand...
code_fim
hard
{ "lang": "python", "repo": "delgadom/py_noaa", "path": "/py_noaa/coops.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> df_L = df[df['high_low'].str.contains("L ")].copy() df_L.rename(columns={'date_time': 'date_time_L', 'water_level': 'L_water_level'}, inplace=True) df_LL = df[df['high_low'].str.contains("LL")].copy() df_LL.rename(columns={'...
code_fim
hard
{ "lang": "python", "repo": "delgadom/py_noaa", "path": "/py_noaa/coops.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ruisunyc/leetcode_Solution path: /leetcode/0051.N皇后/0051-N皇后.py class Solution: def solveNQueens(self, n: int) -> List[List[str]]: <|fim_suffix|> if row==n: ans.append(tmp) return for j in range(n): if j not in cols and r...
code_fim
easy
{ "lang": "python", "repo": "ruisunyc/leetcode_Solution", "path": "/leetcode/0051.N皇后/0051-N皇后.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if row==n: ans.append(tmp) return for j in range(n): if j not in cols and row+j not in sums and row-j not in subs: dfs(row+1,tmp+[j],cols|{j},sums|{row+j},subs|{row-j}) dfs(0,[],set(),set(),set()) r...
code_fim
easy
{ "lang": "python", "repo": "ruisunyc/leetcode_Solution", "path": "/leetcode/0051.N皇后/0051-N皇后.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Josepe75/pvlab path: /src/pvlab/__init__.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- # License: bsd-3-clause # Copyright (C) 2021 J. P. Silva. All rights reserved. """ <|fim_suffix|>PVLAB is a project devoted to the development and improvement of scientific software for the measurement, ...
code_fim
medium
{ "lang": "python", "repo": "Josepe75/pvlab", "path": "/src/pvlab/__init__.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>PVLAB is a project devoted to the development and improvement of scientific software for the measurement, calibration and modeling of the performance of photovoltaic devices and solar sensors. PVLAB package born from the efforts in data treatment for the calibration of pyranometers at the Laboratory of Ph...
code_fim
medium
{ "lang": "python", "repo": "Josepe75/pvlab", "path": "/src/pvlab/__init__.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhangx1923/-QuQ- path: /baseClass/Gate.py #!/usr/bin/python3 from baseGate import * #the dict will be used in SplitGate of Gate.py elementGate = { "X":"CNOT cq-0,tq-0;", "Y":"Sd tq-0;CNOT cq-0,tq-0;S tq-0;", "Z":"H tq-0;CNOT cq-0,tq-0;H tq-0;", "H":"H tq-0;Sd tq-0;CNOT cq-0,tq-0;H tq-0;T tq-...
code_fim
hard
{ "lang": "python", "repo": "zhangx1923/-QuQ-", "path": "/baseClass/Gate.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Z = [[1,0],[0,-1]] gate = Gate([q],Z,"Z") return gate.singleOperator(record,forceQuit = forceQuit) def I(q:Qubit,record = True,forceQuit = False): I = [[1,0],[0,1]] gate = Gate([q],I,"I") return gate.singleOperator(record,forceQuit = forceQuit) def H(q:Qubit,record = True,forceQuit = False): H =...
code_fim
hard
{ "lang": "python", "repo": "zhangx1923/-QuQ-", "path": "/baseClass/Gate.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>array[0][2] = 9 array[1][0] = 7 array[2][2] = 3 print(array)<|fim_prefix|># repo: jlcatonjr/Learn-Python-for-Stats-and-Econ path: /In Class Projects/In Class Examples Spring 2019/Section 5/numpyzeros.py #numpyzeros.py import numpy as np <|fim_middle|>array = np.zeros((3,3)) empty_array = np.empty((5,3))...
code_fim
medium
{ "lang": "python", "repo": "jlcatonjr/Learn-Python-for-Stats-and-Econ", "path": "/In Class Projects/In Class Examples Spring 2019/Section 5/numpyzeros.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jlcatonjr/Learn-Python-for-Stats-and-Econ path: /In Class Projects/In Class Examples Spring 2019/Section 5/numpyzeros.py #numpyzeros.py import numpy as np <|fim_suffix|>array[0][2] = 9 array[1][0] = 7 array[2][2] = 3 print(array)<|fim_middle|>array = np.zeros((3,3)) empty_array = np.empty((5,3))...
code_fim
medium
{ "lang": "python", "repo": "jlcatonjr/Learn-Python-for-Stats-and-Econ", "path": "/In Class Projects/In Class Examples Spring 2019/Section 5/numpyzeros.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ct1799/clicks-to-hitler path: /clickstohitler.py import bs4 as bs import urllib.request import re def game_setup(): """begins the clicks-to-hitler game """ article_setup = '' current_article = '' counter_setup = -1 current_counter = 0 foundHitler = False #list tha...
code_fim
hard
{ "lang": "python", "repo": "ct1799/clicks-to-hitler", "path": "/clickstohitler.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """returns a list of wiki article urls from a single wiki url Parameters ---------- sourceURL : str the wiki url that you are extracting article links from """ sourceURL = sourceURL.encode().decode() articleList = [] soup = bs.BeautifulSoup(urllib.request.urlopen(s...
code_fim
hard
{ "lang": "python", "repo": "ct1799/clicks-to-hitler", "path": "/clickstohitler.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>r = requests.get(url) if not r: print('download failed, try again or download %s manually' % url) exit() open('temp.zip', 'wb').write(r.content) zipfile.ZipFile('temp.zip').extractall() os.rename(zipfile.ZipFile('temp.zip').namelist()[0], folder) os.remove('temp.zip')<|fim_prefix|># repo: jarekt/...
code_fim
medium
{ "lang": "python", "repo": "jarekt/SDLchip", "path": "/getSDL.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: jarekt/SDLchip path: /getSDL.py #simple script for downloading github repos(zip files) easily import requests import zipfile import os url = 'https://www.libsdl.org/release/SDL2-2.0.9.zip' folder = 'SDL' #zip contents into this ^ folder <|fim_suffix|>zipfile.ZipFile('temp.zip').extractall() os....
code_fim
medium
{ "lang": "python", "repo": "jarekt/SDLchip", "path": "/getSDL.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>zipfile.ZipFile('temp.zip').extractall() os.rename(zipfile.ZipFile('temp.zip').namelist()[0], folder) os.remove('temp.zip')<|fim_prefix|># repo: jarekt/SDLchip path: /getSDL.py #simple script for downloading github repos(zip files) easily import requests import zipfile import os <|fim_middle|>url = 'htt...
code_fim
hard
{ "lang": "python", "repo": "jarekt/SDLchip", "path": "/getSDL.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: wenkairen/RoboND-Rover-Project path: /RoboND-Rover-Project/code/perception.py import numpy as np import cv2 # Identify pixels above the threshold # Threshold of RGB > 160 does a nice job of identifying ground pixels only def color_thresh(img, rgb_thresh=(160, 160, 160),rock_thresh = (20,100,100)...
code_fim
hard
{ "lang": "python", "repo": "wenkairen/RoboND-Rover-Project", "path": "/RoboND-Rover-Project/code/perception.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x_world, y_world = pix_to_world(xpix, ypix, Rover.pos[0], Rover.pos[1],Rover.yaw, Rover.worldmap.shape[0],scale) obs_x_world, obs_y_world = pix_to_world(obsxpix, obsypix, ...
code_fim
hard
{ "lang": "python", "repo": "wenkairen/RoboND-Rover-Project", "path": "/RoboND-Rover-Project/code/perception.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: syllamacedo/exercicios_python path: /curso_em_video/ex104_validando_entrada_dados_com_funcao.py # Exercício Python 104: Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante # ‘a função input() do Python, só que fazendo a validação para aceitar apenas um valor numér...
code_fim
medium
{ "lang": "python", "repo": "syllamacedo/exercicios_python", "path": "/curso_em_video/ex104_validando_entrada_dados_com_funcao.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> n = leiaint(input('Digite um número inteiro: ')) print(f'Você acabou de digitar o número {n}.')<|fim_prefix|># repo: syllamacedo/exercicios_python path: /curso_em_video/ex104_validando_entrada_dados_com_funcao.py # Exercício Python 104: Crie um programa que tenha a função leiaInt(), que vai funcionar de...
code_fim
medium
{ "lang": "python", "repo": "syllamacedo/exercicios_python", "path": "/curso_em_video/ex104_validando_entrada_dados_com_funcao.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>print ("MAC - IP") macs = [] for snd, rcv in ans: macs.append(rcv.sprintf(r"%Ether.src%")) print (rcv.sprintf(r"%Ether.src% - %ARP.psrc%")) #print macs stop_time = datetime.now() total_time = stop_time - start_time print ("\n[*] Done in %s" %(total_time))<|fim_prefix|># repo: kodefish/pyarp path...
code_fim
medium
{ "lang": "python", "repo": "kodefish/pyarp", "path": "/arp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kodefish/pyarp path: /arp.py import sys from datetime import datetime from scapy.all import srp, Ether, ARP, conf try: interface = raw_input("[*] Enter Desired interface: ") #Get interface to scan ips = raw_input("[*] Enter Range of IPs to Scan for : ") #Get IP or IP range to scan except...
code_fim
medium
{ "lang": "python", "repo": "kodefish/pyarp", "path": "/arp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result.append(random.choice(all[i])) #choice of one of all elements and append to list. i=i+1 print(*result) #print result list's elements.<|fim_prefix|># repo: ozturkemre/programming-challanges path: /10-RandomSentenceGenerator/RandomSentenceGenerator.py import random nouns=("John","Plato"...
code_fim
medium
{ "lang": "python", "repo": "ozturkemre/programming-challanges", "path": "/10-RandomSentenceGenerator/RandomSentenceGenerator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ozturkemre/programming-challanges path: /10-RandomSentenceGenerator/RandomSentenceGenerator.py import random nouns=("John","Plato","Sharon","Grandfather","Dog","Cat","Money","Horse","Tree") verbs=("runs","hear","know","believe","is","call","drives","jumps") adv=("financially","willfully","abrupt...
code_fim
medium
{ "lang": "python", "repo": "ozturkemre/programming-challanges", "path": "/10-RandomSentenceGenerator/RandomSentenceGenerator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Setting path and files session_path = "session_data/" + session_folder + "/" test_folder = session_path + "test_" + type_of_cal + "/" config_filename = session_path + "config.csv" cal_filename = test_folder + "training_fixation.csv" analyzer = gda.GazeDataAnalyzer() print("\nSETUP TRANSFORMATION") an...
code_fim
hard
{ "lang": "python", "repo": "Toonwire/infancy_eye_tracking", "path": "/sim_visual_angle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Toonwire/infancy_eye_tracking path: /sim_visual_angle.py # -*- coding: utf-8 -*- """ Created on Wed Jun 12 11:21:04 2019 @author: Toonw """ import numpy as np import gaze_data_analyzer as gda import matplotlib.pyplot as plt import math # Run analyse on type_of_cal = "default" #type_of_cal ...
code_fim
hard
{ "lang": "python", "repo": "Toonwire/infancy_eye_tracking", "path": "/sim_visual_angle.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># X行/(Y+1) - W列 for i in range(Y+1, W+1): if S[X][i] == '#': break ans += 1 print(ans)<|fim_prefix|># repo: FGtatsuro/myatcoder path: /beginner_contest/197/B.py import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) <|fim_middle|>H, W, X, Y = map(int, input().split()) S = ...
code_fim
hard
{ "lang": "python", "repo": "FGtatsuro/myatcoder", "path": "/beginner_contest/197/B.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># 1 - (X-1)行/Y列 for i in range(X-1, 0, -1): if S[i][Y] == '#': break ans += 1 # (X+1) - H行/Y列 for i in range(X+1, H+1): if S[i][Y] == '#': break ans += 1 # X行/1 - (Y-1)列 for i in range(Y-1, 0, -1): if S[X][i] == '#': break ans += 1 # X行/(Y+1) - W列 for...
code_fim
medium
{ "lang": "python", "repo": "FGtatsuro/myatcoder", "path": "/beginner_contest/197/B.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: FGtatsuro/myatcoder path: /beginner_contest/197/B.py import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) H, W, X, Y = map(int, input().split()) S = [0] * (H+1) for i in range(H): S[i+1] = [0] + list(input().strip()) ans = 0 # X行/y列 ans += 1 <|fim_suffix|># X行/1 - (Y-1)列 f...
code_fim
medium
{ "lang": "python", "repo": "FGtatsuro/myatcoder", "path": "/beginner_contest/197/B.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: marcortiz11/FastComposedModels path: /Source/pytorch/classifier_metadata.py import torch from Source.io_util import read_pickle from Source.pytorch.component import Component from Data.datasets import Split class ClassifierMetadata(Component): def __init__(self, path_to_pickle: str, split=...
code_fim
hard
{ "lang": "python", "repo": "marcortiz11/FastComposedModels", "path": "/Source/pytorch/classifier_metadata.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> precomputed_pred = torch.from_numpy(precomputed_pred) self.update_processing_time(ids.numel() * time_batch_128/128.0) self.predictions = precomputed_pred[ids].to(ids.device) return self.predictions def set_evaluation_split(self, split: Split): self.split = spli...
code_fim
hard
{ "lang": "python", "repo": "marcortiz11/FastComposedModels", "path": "/Source/pytorch/classifier_metadata.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Call component's class constructor self.path = path_to_pickle self.split = split metadata = read_pickle(self.path) parameters = metadata['metrics']['params'] super().__init__(p=parameters) # This way predictions can be manipulated on GPU se...
code_fim
medium
{ "lang": "python", "repo": "marcortiz11/FastComposedModels", "path": "/Source/pytorch/classifier_metadata.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ picks false color bands from the 12 Sentinel bands (for visual interpretation of vegetation) :param input: 12-band image tensor :return: 3-band NIR-RED-GREEN tensor """ rgb_band_idxs = [bands.index(b) for b in ["S2B8", "S2B4", "S2B3"]] return input[rgb_band_idxs] def equa...
code_fim
hard
{ "lang": "python", "repo": "MarcCoru/dino", "path": "/sen12ms/transforms.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: MarcCoru/dino path: /sen12ms/transforms.py import skimage.exposure import numpy as np import albumentations as A from albumentations.pytorch import ToTensorV2 #import torchvision.transforms as T bands = ["S2B1", "S2B2", "S2B3", "S2B4", "S2B5", "S2B6", "S2B7", "S2B8", "S2B8A", "S2B9", "S2B10", "S...
code_fim
hard
{ "lang": "python", "repo": "MarcCoru/dino", "path": "/sen12ms/transforms.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># http://121.0.0.0:5000/message?question=what @app.route('/message') def return_message_response(): message = request.args.get('question') # Add content to conversation bot.update_conversation(message) bot.threaded_call() print message response = bot.dummy_answer(message) retur...
code_fim
hard
{ "lang": "python", "repo": "educriado/junction-2016", "path": "/src/app.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: educriado/junction-2016 path: /src/app.py #!flask/bin/python from flask import Flask from flask import jsonify from flask import request from bot import Bot <|fim_suffix|> return "Hello, World!" topics_count = {'cats': 1, 'sports': 1, 'music': 1} topic_files = [i + '.aiml' for i in topics_c...
code_fim
medium
{ "lang": "python", "repo": "educriado/junction-2016", "path": "/src/app.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: yeonan/TopDownNvidia path: /src/errors/metric_measure_errors.py """ Mistakes launched by MetricMeasure class and its subclasses in the hierarchy. @date: Jan 2021 @version: 1.0 """ class DataStructuresOfEventError(Exception): """Exception raised when an event is defined in a data str...
code_fim
medium
{ "lang": "python", "repo": "yeonan/TopDownNvidia", "path": "/src/errors/metric_measure_errors.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Exception raised when a metric is defined in a data structure, but not in another that should be.""" C_ERROR_MESSAGE : str = ("Following metric is defined in a data" + " structure, but not in another that should be: ") def __init__(self, metric_name : str): ""...
code_fim
medium
{ "lang": "python", "repo": "yeonan/TopDownNvidia", "path": "/src/errors/metric_measure_errors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Attributes: metric_name : str ; name of the metric that produced the error """ super().__init__(self.C_ERROR_MESSAGE + metric_name) pass<|fim_prefix|># repo: yeonan/TopDownNvidia path: /src/errors/metric_measure_errors.py """ Mistakes launched by Metr...
code_fim
hard
{ "lang": "python", "repo": "yeonan/TopDownNvidia", "path": "/src/errors/metric_measure_errors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for file_name in os.listdir(path): noun_list_negative = "" with open(path+file_name, 'r') as file: #month = file_name.rsplit("_") my_file = file_name.rsplit(".txt") for line in file: blob = TextBlob(line) for sentence in blob.sentences: # if sentence.sentiment.polarity < 0: for nwo...
code_fim
medium
{ "lang": "python", "repo": "sagarkrkv/Yelp-Dataset-Challenge", "path": "/Other Trials/noun_phrase_extraction.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if not os.path.exists(output_path): os.makedirs(output_path) noun_list_positive = "" for file_name in os.listdir(path): noun_list_negative = "" with open(path+file_name, 'r') as file: #month = file_name.rsplit("_") my_file = file_name.rsplit(".txt") for line in file: blob = TextBlob(li...
code_fim
medium
{ "lang": "python", "repo": "sagarkrkv/Yelp-Dataset-Challenge", "path": "/Other Trials/noun_phrase_extraction.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sagarkrkv/Yelp-Dataset-Challenge path: /Other Trials/noun_phrase_extraction.py import nltk from nltk.tag import pos_tag from nltk.tokenize import word_tokenize import os from textblob import TextBlob from nltk.stem.snowball import EnglishStemmer stemmer = EnglishStemmer() <|fim_suffix|> if not ...
code_fim
medium
{ "lang": "python", "repo": "sagarkrkv/Yelp-Dataset-Challenge", "path": "/Other Trials/noun_phrase_extraction.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: SelvorWhim/competitive path: /Codewars/HowOldWillIBeIn2099.py def calculate_age(year_of_birth, current_year): delta = current_year - year_of_birth <|fim_suffix|>bs(delta) == 1 else "years" if delta > 0: return "You are {} {} old.".format(delta, year_s) else: retu...
code_fim
medium
{ "lang": "python", "repo": "SelvorWhim/competitive", "path": "/Codewars/HowOldWillIBeIn2099.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>bs(delta) == 1 else "years" if delta > 0: return "You are {} {} old.".format(delta, year_s) else: return "You will be born in {} {}.".format(-delta, year_s)<|fim_prefix|># repo: SelvorWhim/competitive path: /Codewars/HowOldWillIBeIn2099.py def calculate_age(year_of_birth, curr...
code_fim
medium
{ "lang": "python", "repo": "SelvorWhim/competitive", "path": "/Codewars/HowOldWillIBeIn2099.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> context = super(JiraConfigView, self).get_context() context['body_class'] = 'aui-page-focused aui-page-size-medium' return context def get(self, request, *args, **kwargs): try: jira_auth = self.get_jira_auth() except (ApiError, JiraTenant.DoesNotExi...
code_fim
hard
{ "lang": "python", "repo": "craigmichaelmartin/sentry-plugins", "path": "/src/sentry_plugins/jira_ac/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: craigmichaelmartin/sentry-plugins path: /src/sentry_plugins/jira_ac/views.py from __future__ import absolute_import import json from six.moves.urllib.parse import urlparse from django.forms.util import ErrorList from django.http import HttpResponse from django.views.decorators.csrf import csrf...
code_fim
hard
{ "lang": "python", "repo": "craigmichaelmartin/sentry-plugins", "path": "/src/sentry_plugins/jira_ac/views.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with open('dog_names.txt', 'r') as f: dog_names = f.read().splitlines() f.close() breed = dog_names[np.argmax(predicted_vector)] return breed def classify_dog_breed(img_path): ''' Input: img_path: string-valued file path to a color image Output: ...
code_fim
hard
{ "lang": "python", "repo": "cmeng94/dog-breed-classifier", "path": "/app/dog_classifier.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }