text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: hzmangel/wp2hugo path: /hugo_printer.py import yaml import os import logging import html2text class HugoPrinter: def __init__(self, *args, **kwargs): accept_attributes = ["meta", "categories", "tags", "posts", "drafts", "basedir"] for attr in accept_attributes: ...
code_fim
hard
{ "lang": "python", "repo": "hzmangel/wp2hugo", "path": "/hugo_printer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> actual = _moving_average(list(data.items()), chunk_size=2) expected = {'2020-01-03': 15, '2020-01-04': 30} self.assertListEqual(actual, list(expected.items())) def test_zero_and_negative_values(self): """ Tests to make sure that negative va...
code_fim
hard
{ "lang": "python", "repo": "IanCostello/tools", "path": "/covid19-dashboard/TestMovingAverage.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: IanCostello/tools path: /covid19-dashboard/TestMovingAverage.py # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.o...
code_fim
hard
{ "lang": "python", "repo": "IanCostello/tools", "path": "/covid19-dashboard/TestMovingAverage.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Tests to make sure that negative values and zeros don't cause any issues. They are valid inputs. """ data = {'2020-01-02': -10, '2020-01-03': 0, '2020-01-04': 0} actual = _moving_average(list(data.items()), chunk_size=2) ...
code_fim
hard
{ "lang": "python", "repo": "IanCostello/tools", "path": "/covid19-dashboard/TestMovingAverage.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>' try: return eval(erg) except ValueError: return 'Invalid calculation'<|fim_prefix|># repo: dskbrd/dascord-py path: /lib_calc.py def calc(erg: str): if erg.islower() or erg<|fim_middle|>.isupper(): return 'Invalid calculation
code_fim
easy
{ "lang": "python", "repo": "dskbrd/dascord-py", "path": "/lib_calc.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>ValueError: return 'Invalid calculation'<|fim_prefix|># repo: dskbrd/dascord-py path: /lib_calc.py def calc(erg: str): if erg.islower() or erg.isupper(): return 'Invalid calculation<|fim_middle|>' try: return eval(erg) except
code_fim
easy
{ "lang": "python", "repo": "dskbrd/dascord-py", "path": "/lib_calc.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: dskbrd/dascord-py path: /lib_calc.py def calc(erg: str): if erg.islower() or erg.isupper(): return 'Invalid calculation<|fim_suffix|>ValueError: return 'Invalid calculation'<|fim_middle|>' try: return eval(erg) except
code_fim
easy
{ "lang": "python", "repo": "dskbrd/dascord-py", "path": "/lib_calc.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> stu1 = { 'id': 1, 'name': 'ping' } print('stu1 =', stu1) msg = msgpack.packb(stu1) print(type(msg)) print(len(msg)) print(msg) stu2 = msgpack.unpackb(msg, use_list=False, encoding='utf-8') print('stu2 =', stu2) def main(): test1() if __name__ =...
code_fim
easy
{ "lang": "python", "repo": "MDGSF/PythonPractice", "path": "/msgpackdemo/1/msgpackdemo.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: MDGSF/PythonPractice path: /msgpackdemo/1/msgpackdemo.py #!/usr/bin/env python # -*- coding: UTF-8 -*- import msgpack def test1(): stu1 = { 'id': 1, 'name': 'ping' } print('stu1 =', stu1) <|fim_suffix|> stu2 = msgpack.unpackb(msg, use_list=False, encoding='utf-8...
code_fim
medium
{ "lang": "python", "repo": "MDGSF/PythonPractice", "path": "/msgpackdemo/1/msgpackdemo.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> test1() if __name__ == "__main__": main()<|fim_prefix|># repo: MDGSF/PythonPractice path: /msgpackdemo/1/msgpackdemo.py #!/usr/bin/env python # -*- coding: UTF-8 -*- <|fim_middle|>import msgpack def test1(): stu1 = { 'id': 1, 'name': 'ping' } print('stu1 =', stu1)...
code_fim
hard
{ "lang": "python", "repo": "MDGSF/PythonPractice", "path": "/msgpackdemo/1/msgpackdemo.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: pmnyc/Data_Engineering_Collections path: /django_flask_samples/tango_with_django-master/made_with_twd_project/showcase/models.py from django.db import models from django.contrib.auth.models import User from django.conf import settings class Category(models.Model): name = models.CharField(max...
code_fim
hard
{ "lang": "python", "repo": "pmnyc/Data_Engineering_Collections", "path": "/django_flask_samples/tango_with_django-master/made_with_twd_project/showcase/models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> name = models.CharField(max_length=64) tagline = models.CharField(max_length=128) description = models.CharField(max_length=512) year = models.IntegerField(default=2014, choices=YEAR_CHOICES) url = models.URLField() live = models.BooleanField(default=True) github_url = models.U...
code_fim
hard
{ "lang": "python", "repo": "pmnyc/Data_Engineering_Collections", "path": "/django_flask_samples/tango_with_django-master/made_with_twd_project/showcase/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># read serial for d in datasets: p = paths[1] df = pandas.read_csv(d+p+'.csv', header=None) df = df.min() read_time = df[0] csr_time = df[1] mem_time = df[2] exec_time = df[3] stats['serial'].append(df[2]) stats['cilk'].append(df[3]) ...
code_fim
hard
{ "lang": "python", "repo": "KonstantinosChatziantoniou/GraphTrianglesCounting", "path": "/scripts/res.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: KonstantinosChatziantoniou/GraphTrianglesCounting path: /scripts/res.py import pandas import matplotlib.pyplot as plt datasets = ['auto.mtx', 'delaunay_n22.mtx', 'great-britain_osm.mtx'] paths = ['cuda', 'serial_cilk'] stats = {} stats['cuda'] = [] stats['serial'] = [] stats['cilk'] = [] stat...
code_fim
hard
{ "lang": "python", "repo": "KonstantinosChatziantoniou/GraphTrianglesCounting", "path": "/scripts/res.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># read cuda for d in datasets: p = paths[0] df = pandas.read_csv(d+p+'.csv', header=None) df = df.min() read_time = df[0] csr_time = df[1] mem_time = df[2] exec_time = df[3] stats['cuda'].append(df[2] + df[3]) # read serial for d in dataset...
code_fim
hard
{ "lang": "python", "repo": "KonstantinosChatziantoniou/GraphTrianglesCounting", "path": "/scripts/res.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhmsg/dms path: /Web/msg_web.py #! /usr/bin/env python # coding: utf-8 import sys sys.path.append("..") from flask import Flask from flask_login import current_user from Web import * from Web.redis_session import RedisSessionInterface __author__ = 'zhouheng' def create_app(): msg_web = Fla...
code_fim
hard
{ "lang": "python", "repo": "zhmsg/dms", "path": "/Web/msg_web.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> env = msg_web.jinja_env env.globals["current_env"] = current_env # env.globals["role_value"] = control.role_value env.globals["menu_url"] = dms_url_prefix + "/portal/" env.globals["short_link_url"] = short_link_prefix env.filters['unix_timestamp'] = unix_timestamp env.filters['...
code_fim
hard
{ "lang": "python", "repo": "zhmsg/dms", "path": "/Web/msg_web.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wsp-sag/gtfs-router path: /src/gtfs_router/utils/misc.py import logging logger = logging.getLogger() def log_stop_information(partridge_feed, stop_id): stops = partridge_feed.stops stop = stops[stops["stop_id"] == stop_id] if stop.empty: logger.waring("No stop_id found for:...
code_fim
hard
{ "lang": "python", "repo": "wsp-sag/gtfs-router", "path": "/src/gtfs_router/utils/misc.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i, p in enumerate(coords): proj_dist = line.project(Point(p)) if proj_dist == distance: return [LineString(coords[: i + 1]), LineString(coords[i:])] if proj_dist > distance: cp = line.interpolate(distance) return [ LineStr...
code_fim
hard
{ "lang": "python", "repo": "wsp-sag/gtfs-router", "path": "/src/gtfs_router/utils/misc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: uonafya/mfl_api path: /common/migrations/0020_auto_20221205_0904.py # -*- coding: utf-8 -*- # Generated by Django 1.11.27 on 2022-12-05 09:04 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): <|fim_suffix|> operations = ...
code_fim
medium
{ "lang": "python", "repo": "uonafya/mfl_api", "path": "/common/migrations/0020_auto_20221205_0904.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('common', '0019_auto_20191021_1227'), ] operations = [ migrations.AlterField( model_name='apiauthentication', name='client_secret', field=models.CharField(default=b'', max_length=255), ), migrations.AlterFi...
code_fim
medium
{ "lang": "python", "repo": "uonafya/mfl_api", "path": "/common/migrations/0020_auto_20221205_0904.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.fname = filename super(FileOutputProcessor, self).__init__(var_list, sample_interval) def pre_run(self): self.h5file = h5py.File(self.fname, 'w') self.h5file.create_dataset('metadata',(),'i') self.h5file['metadata'].attrs['start_time'] = self.start_tim...
code_fim
hard
{ "lang": "python", "repo": "mkturkcan/neurodriver", "path": "/neurokernel/LPU/OutputProcessors/FileOutputProcessor.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: mkturkcan/neurodriver path: /neurokernel/LPU/OutputProcessors/FileOutputProcessor.py import numpy as np import h5py from datetime import datetime from neurokernel.LPU.OutputProcessors.BaseOutputProcessor import BaseOutputProcessor class FileOutputProcessor(BaseOutputProcessor): def __init__(s...
code_fim
hard
{ "lang": "python", "repo": "mkturkcan/neurodriver", "path": "/neurokernel/LPU/OutputProcessors/FileOutputProcessor.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for var, d in self.variables.items(): self.h5file[var+'/data'].resize((self.h5file[var+'/data'].shape[0]+1, len(d['uids']))) self.h5file[var+'/data'][-1,:] = d['output'].reshape((1,-1)) def post_run(self): ...
code_fim
hard
{ "lang": "python", "repo": "mkturkcan/neurodriver", "path": "/neurokernel/LPU/OutputProcessors/FileOutputProcessor.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.topic_vectors = nn.Parameter(topic_vectors) self.n_topics = n_topics def forward(self, doc_weights): """Embed a batch of documents. Arguments: doc_weights: A float tensor of shape [batch_size, n_topics], document distributions (logits)...
code_fim
hard
{ "lang": "python", "repo": "Gwangfilm/Comparative-analysis-of-user-preference-factors-in-parks-using-big-data", "path": "/lda2vec-pytorch-master/utils/lda2vec_loss.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Arguments: pivot_words: A long tensor of shape [batch_size]. target_words: A long tensor of shape [batch_size, window_size]. Windows around pivot words. doc_vectors: A float tensor of shape [batch_size, embedding_dim]. ...
code_fim
hard
{ "lang": "python", "repo": "Gwangfilm/Comparative-analysis-of-user-preference-factors-in-parks-using-big-data", "path": "/lda2vec-pytorch-master/utils/lda2vec_loss.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Gwangfilm/Comparative-analysis-of-user-preference-factors-in-parks-using-big-data path: /lda2vec-pytorch-master/utils/lda2vec_loss.py import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.init as init import torch.nn.functional as F from scipy.stats import ortho_g...
code_fim
hard
{ "lang": "python", "repo": "Gwangfilm/Comparative-analysis-of-user-preference-factors-in-parks-using-big-data", "path": "/lda2vec-pytorch-master/utils/lda2vec_loss.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: paltrickontpb/Adafruit-IO-Control-Center path: /Code_uploader.py from Adafruit_IO import Client KEY = 'ADAFRUIT-IO-KEY' <|fim_suffix|>code = raw_input('Enter the Code : ') print("Input Code : "+str(code)) pyclient.send('data', code) print("Code updated in cloud")<|fim_middle|>pyclient = Client...
code_fim
easy
{ "lang": "python", "repo": "paltrickontpb/Adafruit-IO-Control-Center", "path": "/Code_uploader.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pyclient.send('data', code) print("Code updated in cloud")<|fim_prefix|># repo: paltrickontpb/Adafruit-IO-Control-Center path: /Code_uploader.py from Adafruit_IO import Client KEY = 'ADAFRUIT-IO-KEY' pyclient = Client(KEY) <|fim_middle|>code = raw_input('Enter the Code : ') print("Input Code : "+str(c...
code_fim
medium
{ "lang": "python", "repo": "paltrickontpb/Adafruit-IO-Control-Center", "path": "/Code_uploader.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: Coding-Squad/givabit path: /src/givabit/ui_tests/login_test.py import time from givabit.ui_tests import ui_test_utils from givabit.ui_tests.page_objects.login_page import LoginPage from givabit.backend.user import User from selenium import webdriver from google.appengine.ext import testbed c...
code_fim
medium
{ "lang": "python", "repo": "Coding-Squad/givabit", "path": "/src/givabit/ui_tests/login_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> sessions = self.session_repo.get_sessions(email=user.email) session_ids = set([session.id for session in sessions]) self.assertSetEqual(session_ids, set([session_id])) def get_session_id(self): return self.get_cookie('sessionid')['value']<|fim_prefix|># repo: Coding-Sq...
code_fim
hard
{ "lang": "python", "repo": "Coding-Squad/givabit", "path": "/src/givabit/ui_tests/login_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: EDRN/eke.biomarker path: /eke/biomarker/upgrades.py # encoding: utf-8 # Copyright 2011 California Institute of Technology. ALL RIGHTS # RESERVED. U.S. Government Sponsorship acknowledged. from eke.biomarker import PROFILE_ID from eke.biomarker.interfaces import IBiomarkerFolder from Products.CMF...
code_fim
medium
{ "lang": "python", "repo": "EDRN/eke.biomarker", "path": "/eke/biomarker/upgrades.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> '''Set up faceted navigation and add disclaimers on all Biomarker Folders.''' portal = _getPortal(setupTool) request = portal.REQUEST catalog = getToolByName(portal, 'portal_catalog') results = [i.getObject() for i in catalog(object_provides=IBiomarkerFolder.__identifier__)] if len...
code_fim
hard
{ "lang": "python", "repo": "EDRN/eke.biomarker", "path": "/eke/biomarker/upgrades.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_output_schema(self): # Output of deid should use standard schema (DC-120) o_dataset_ref = self.client.dataset(self.o_dataset) for table_name in CDM_TABLE_NAMES: table_ref = o_dataset_ref.table(table_name) table = self.client.get_table(table_ref)...
code_fim
hard
{ "lang": "python", "repo": "berneskaracay/curation", "path": "/data_steward/deid/test/deid_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: berneskaracay/curation path: /data_steward/deid/test/deid_test.py """ This unit test requires a valid configuration at `deid/test_config.json` and the environment variables below. I_DATASET: Input dataset_id. O_DATASET: Output dataset_id. Note that tests currently assume that this has been popula...
code_fim
hard
{ "lang": "python", "repo": "berneskaracay/curation", "path": "/data_steward/deid/test/deid_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Table fields should have names and types from standard schema # Note: We do not check nullability as deid may entail relaxing constraint actual_items = [(item.name, item.field_type.lower()) for item in table.schema] actual_schema = dict(actual_items) ...
code_fim
hard
{ "lang": "python", "repo": "berneskaracay/curation", "path": "/data_steward/deid/test/deid_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Adding converter for dateobject to schema. AlbumSchema.CONVERTER_MAP[DateObject] = DateConverter def test_validate_df(spark_session): input_data = [ {"title": "valid_1", "release_date": date(2020, 1, 10)}, {"title": "valid_2", "release_date": date(2020, 1, 11)}, {"title": "...
code_fim
hard
{ "lang": "python", "repo": "hammond756/marshmallow-pyspark", "path": "/tests/test_custom_field.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def test_validate_df(spark_session): input_data = [ {"title": "valid_1", "release_date": date(2020, 1, 10)}, {"title": "valid_2", "release_date": date(2020, 1, 11)}, {"title": "valid_3", "release_date": date(2020, 1, 11)}, {"title": "valid_4", "release_date": date(2020,...
code_fim
hard
{ "lang": "python", "repo": "hammond756/marshmallow-pyspark", "path": "/tests/test_custom_field.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hammond756/marshmallow-pyspark path: /tests/test_custom_field.py """ Test custom field """ from datetime import date from marshmallow import fields, ValidationError from marshmallow_pyspark import Schema from marshmallow_pyspark.converters import DateConverter class DateObject(fields.Fie...
code_fim
hard
{ "lang": "python", "repo": "hammond756/marshmallow-pyspark", "path": "/tests/test_custom_field.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return np.sqrt(w1*w2).content<|fim_prefix|># repo: lgray/dazsle-hbb-recipes path: /dazsle_hbb_recipes/kfactors/top_kfactors.py """ kfactors / reweighting for ttbar """ from fnal_column_analysis_tools.util import numpy as np from fnal_column_analysis_tools.util import awkward def calculateTopKFactor...
code_fim
medium
{ "lang": "python", "repo": "lgray/dazsle-hbb-recipes", "path": "/dazsle_hbb_recipes/kfactors/top_kfactors.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def calculateTopKFactor(top_pts,antitop_pts): w1 = np.exp(0.0615 - 0.0005*top_pts); w2 = np.exp(0.0615 - 0.0005*antitop_pts); return np.sqrt(w1*w2).content<|fim_prefix|># repo: lgray/dazsle-hbb-recipes path: /dazsle_hbb_recipes/kfactors/top_kfactors.py """ kfactors / reweighting for ttbar ""...
code_fim
medium
{ "lang": "python", "repo": "lgray/dazsle-hbb-recipes", "path": "/dazsle_hbb_recipes/kfactors/top_kfactors.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: lgray/dazsle-hbb-recipes path: /dazsle_hbb_recipes/kfactors/top_kfactors.py """ kfactors / reweighting for ttbar """ <|fim_suffix|> w1 = np.exp(0.0615 - 0.0005*top_pts); w2 = np.exp(0.0615 - 0.0005*antitop_pts); return np.sqrt(w1*w2).content<|fim_middle|>from fnal_column_analysis_too...
code_fim
medium
{ "lang": "python", "repo": "lgray/dazsle-hbb-recipes", "path": "/dazsle_hbb_recipes/kfactors/top_kfactors.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> module_dir = os.path.join( proj_path, const.DIR_NAME_FILES, const.DIR_NAME_FILES_MODULES, module_name, const.DIR_NAME_GLUECODE, ) # clean old generated src file.remove_dir(os.path.join(module_dir, "generated-src")) file.remove_dir(os.path.join(m...
code_fim
hard
{ "lang": "python", "repo": "rockonedege/ezored", "path": "/files/core/gluecode.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rockonedege/ezored path: /files/core/gluecode.py """Module: Glue code""" import os from files.core import const from files.core import file from files.core import log from files.core import runner from files.core import util # ------------------------------------------------------------------...
code_fim
hard
{ "lang": "python", "repo": "rockonedege/ezored", "path": "/files/core/gluecode.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CalPolyDnD/DnDCapstone path: /dmsite/backend/dmsite/tests/classes.py class TestTable: def __init__(self): self.file = [] self.data = [] def add_data(self, data): self.file = data def query(self, IndexName=None, KeyConditionExpression=None): dict = {} ...
code_fim
hard
{ "lang": "python", "repo": "CalPolyDnD/DnDCapstone", "path": "/dmsite/backend/dmsite/tests/classes.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(0, len(self.data)): if self.data[i]['Item']['name'] == Key['name']: return self.data[i] return {} def response(self, key): for i in range(0, len(self.data)): item = self.data[i]['Item'] if 'name' in key and 'na...
code_fim
hard
{ "lang": "python", "repo": "CalPolyDnD/DnDCapstone", "path": "/dmsite/backend/dmsite/tests/classes.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def update_item(self, Key = None, UpdateExpression=None, ExpressionAttributeNames=None, ExpressionAttributeValues = None): for i in range(0, len(self.data)): if 'name' in self.data[i]['Item'] and self.dat...
code_fim
hard
{ "lang": "python", "repo": "CalPolyDnD/DnDCapstone", "path": "/dmsite/backend/dmsite/tests/classes.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>.models.deletion.CASCADE, to='projectsTestsQuestions.Project')), ], ), migrations.CreateModel( name='testsApply', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ...
code_fim
hard
{ "lang": "python", "repo": "ATOM27/TFF", "path": "/School/apply/migrations/0001_initial.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ATOM27/TFF path: /School/apply/migrations/0001_initial.py # -*- coding: utf-8 -*- # Generated by Django 1.10 on 2017-05-13 13:33 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial...
code_fim
hard
{ "lang": "python", "repo": "ATOM27/TFF", "path": "/School/apply/migrations/0001_initial.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def _conv_dw(inp, oup, stride=1, padding=0, expand_ratio=1): """ Introduction ------------ 采用MobileNet的结构减少参数,压缩模型 Parameters ---------- inp: 输入通道数 oup: 输出通道数 stride: 卷积步长 padding: 卷积padding大小 expand_ratio: 维度扩充比例 Returns: -------...
code_fim
hard
{ "lang": "python", "repo": "aloyschen/SSD-Pytorch", "path": "/models/SSDLite.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aloyschen/SSD-Pytorch path: /models/SSDLite.py import torch import torch.nn as nn import torch.nn.functional as F from models.Modules import L2Norm class SSDLite(nn.Module): def __init__(self, BaseModel, extras, head, feature_layer, num_class): """ Introduction ------...
code_fim
hard
{ "lang": "python", "repo": "aloyschen/SSD-Pytorch", "path": "/models/SSDLite.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def add_extras(base, feature_layer, mbox, num_classes): """ Introduction ------------ 将基础模型特征基础上提取多尺度特征,再使用卷积进行box坐标和类别的回归 Parameters ---------- base: 基础模型 feature_layer: 特征层参数 mbox: 每层特征预测box的数量 num_classes: 数据集类别数量 """ extra_layers = []...
code_fim
hard
{ "lang": "python", "repo": "aloyschen/SSD-Pytorch", "path": "/models/SSDLite.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HassamSheikh/VIP_Protection_Envs path: /policy/interactive.py #!/usr/bin/env python import os,sys sys.path.insert(1, os.path.join(sys.path[0], '..')) import argparse import pandas as pd import gc from collections import defaultdict from multiagent.environment import MultiAgentEnv from multiagent....
code_fim
hard
{ "lang": "python", "repo": "HassamSheikh/VIP_Protection_Envs", "path": "/policy/interactive.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': # parse arguments parser = argparse.ArgumentParser(description=None, allow_abbrev=False) parser.add_argument("--data-path", default='./data/trajectory_data.csv', help="Path for saving trajectories") parser.add_argument("--scenario", type=str, default="simple", he...
code_fim
hard
{ "lang": "python", "repo": "HassamSheikh/VIP_Protection_Envs", "path": "/policy/interactive.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for idx, p_vel in enumerate(agent.state.p_vel): key_name = agent.name + "_p_vel_" + axis[idx] episode_data[key_name].append(p_vel) for idx, agent in enumerate(world.policy_agents): episode_data[agent.name + "_actions"].append([agent.action.u]) episode_d...
code_fim
hard
{ "lang": "python", "repo": "HassamSheikh/VIP_Protection_Envs", "path": "/policy/interactive.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: 0xPrateek/ML-Algorithms path: /Algorithms/Linear Regression/LinearRegression.py ############################################################################################################################ ''' Linear Regression implementation in Python 3 By - Prateek ...
code_fim
hard
{ "lang": "python", "repo": "0xPrateek/ML-Algorithms", "path": "/Algorithms/Linear Regression/LinearRegression.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == '__main__': data = pd.read_csv('../../Datasets/linearRegression_Dataset.txt', header = None) #Loading dataset file and storing in 'data' variable. x = data.iloc[:,0] #sepratly storing the coloumn 0 in x. y = data.iloc[:,1] #sepratly storing the coloumn 1 ...
code_fim
hard
{ "lang": "python", "repo": "0xPrateek/ML-Algorithms", "path": "/Algorithms/Linear Regression/LinearRegression.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': data = pd.read_csv('../../Datasets/linearRegression_Dataset.txt', header = None) #Loading dataset file and storing in 'data' variable. x = data.iloc[:,0] #sepratly storing the coloumn 0 in x. y = data.iloc[:,1] #sepratly storing the coloumn 1 i...
code_fim
hard
{ "lang": "python", "repo": "0xPrateek/ML-Algorithms", "path": "/Algorithms/Linear Regression/LinearRegression.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Spookz0r/Temporal_Insanity path: /Martin/exp2.py from __future__ import print_function import numpy as np #np.random.seed(1337) # for reproducibility from keras.datasets import mnist from keras.layers.core import TimeDistributedDense, Activation, Dropout from keras.models import Sequential f...
code_fim
medium
{ "lang": "python", "repo": "Spookz0r/Temporal_Insanity", "path": "/Martin/exp2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>nr = np.random.randint(0,9999) print("Sample nr ", nr) pic = copy.deepcopy(X_test[nr]) img = X_test[nr] img = img.reshape(1,1,28,28) img = img.astype('float32') img /= 255 model = load_model("muh_model.h5") start = time.time() x = model.predict(img, batch_size = 1, verbose = 1) end = time.time() prin...
code_fim
medium
{ "lang": "python", "repo": "Spookz0r/Temporal_Insanity", "path": "/Martin/exp2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> model = load_model("muh_model.h5") start = time.time() x = model.predict(img, batch_size = 1, verbose = 1) end = time.time() print("Prediction is: ", x[0][0]) print("Answer is: ", y_test[nr]) print("It took: ", end-start, " seconds") plt.imshow(pic) plt.show()<|fim_prefix|># repo: Spookz0r/Temporal_Insan...
code_fim
hard
{ "lang": "python", "repo": "Spookz0r/Temporal_Insanity", "path": "/Martin/exp2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Nico769/HPCA-Project-Code path: /core/algos/monte_carlo_pi.py """Estimate pi using a parallel Monte Carlo simulation. Implements an MPI version of a parallel Monte Carlo simulation for estimating pi. MPI's default channel is used. Usage: python monte_carlo_pi.py [total_nu...
code_fim
hard
{ "lang": "python", "repo": "Nico769/HPCA-Project-Code", "path": "/core/algos/monte_carlo_pi.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ points_fallen_inside_circle = 0 # draw a pair (x,y) from an uniform distribution # between 0 and 1 for each trial # NOTE: each child process has its own seed # since np.random.seed() hasn't been invoked # This is good for randomness but terrible for # reproducibi...
code_fim
hard
{ "lang": "python", "repo": "Nico769/HPCA-Project-Code", "path": "/core/algos/monte_carlo_pi.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># for trail in map_dict: # if "view" in map_dict[trail]: # method_path = map_dict[trail]["model"] # __get_method(method_path=method_path)<|fim_prefix|># repo: conrad-strughold/GamestonkTerminal path: /tests/openbb_terminal/test_sdk.py # pylint: disable=import-outside-t...
code_fim
hard
{ "lang": "python", "repo": "conrad-strughold/GamestonkTerminal", "path": "/tests/openbb_terminal/test_sdk.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: conrad-strughold/GamestonkTerminal path: /tests/openbb_terminal/test_sdk.py # pylint: disable=import-outside-toplevel # def test_openbb(): # """Test the openbb function""" # from openbb_terminal.sdk import openbb # assert "stocks" in dir(openbb) # assert "economy" in dir(openbb...
code_fim
hard
{ "lang": "python", "repo": "conrad-strughold/GamestonkTerminal", "path": "/tests/openbb_terminal/test_sdk.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># def __get_method(method_path: str) -> Callable: # module_path, function_name = method_path.rsplit(".", 1) # module = import_module(module_path) # method = getattr(module, function_name) # return method # def test_load_models(): # map_dict = trail_map.map_dict # for trail in m...
code_fim
medium
{ "lang": "python", "repo": "conrad-strughold/GamestonkTerminal", "path": "/tests/openbb_terminal/test_sdk.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SeyZ/baboon path: /baboon/baboon/plugins/git/monitor_git.py import os import sys import re import fnmatch if sys.version_info < (2, 7): # Python < 2.7 doesn't have the cmp_to_key function. from baboon.common.utils import cmp_to_key else: from functools import cmp_to_key from baboon....
code_fim
hard
{ "lang": "python", "repo": "SeyZ/baboon", "path": "/baboon/baboon/plugins/git/monitor_git.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # First, check if the modified file is the gitignore file. If it's the # case, update include/exclude paths lists. if rel_path == self.gitignore_path: self._populate_gitignore_items() # Return True only if rel_path matches an exclude pattern AND does NOT ...
code_fim
hard
{ "lang": "python", "repo": "SeyZ/baboon", "path": "/baboon/baboon/plugins/git/monitor_git.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: juancprzs/semantic-embeddings path: /learn_classifier.py import numpy as np import argparse import pickle import os import shutil from collections import OrderedDict import keras from keras import backend as K import utils from datasets import get_data_generator def transform_inputs(X, y, n...
code_fim
hard
{ "lang": "python", "repo": "juancprzs/semantic-embeddings", "path": "/learn_classifier.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Configure environment K.set_session(K.tf.Session(config = K.tf.ConfigProto(gpu_options = { 'allow_growth' : True }))) # Load dataset if args.class_list is not None: with open(args.class_list) as class_file: class_list = list(OrderedDict((l.strip().split()[0], None) f...
code_fim
hard
{ "lang": "python", "repo": "juancprzs/semantic-embeddings", "path": "/learn_classifier.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if args.max_decay > 0: decay = (1.0/args.max_decay - 1) / ((data_generator.num_train // args.batch_size) * (args.epochs if args.epochs else num_epochs)) else: decay = 0.0 par_model.compile(optimizer = keras.optimizers.SGD(lr=args.sgd_lr, decay=decay, momentum=0.9, nesterov=args...
code_fim
hard
{ "lang": "python", "repo": "juancprzs/semantic-embeddings", "path": "/learn_classifier.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: starlingx/distcloud path: /distributedcloud/dcorch/engine/initial_sync_manager.py # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licens...
code_fim
hard
{ "lang": "python", "repo": "starlingx/distcloud", "path": "/distributedcloud/dcorch/engine/initial_sync_manager.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Indicate that initial sync has started self.gsm.update_subcloud_state( subcloud_name, initial_sync_state=consts.INITIAL_SYNC_STATE_IN_PROGRESS) # Initial sync. It's synchronous so that identity # get synced before fernet token keys are synced. Thi...
code_fim
hard
{ "lang": "python", "repo": "starlingx/distcloud", "path": "/distributedcloud/dcorch/engine/initial_sync_manager.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def normalize_num_clients_and_default_num_clients( num_clients: Optional[int], default_num_clients: int) -> int: if num_clients is not None: warnings.warn('num_clients is deprecated; please use default_num_clients ' 'instead.') py_typecheck.check_type(num_clients, int) ...
code_fim
hard
{ "lang": "python", "repo": "Saiprasad16/federated", "path": "/tensorflow_federated/python/core/impl/executors/executor_stacks.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Saiprasad16/federated path: /tensorflow_federated/python/core/impl/executors/executor_stacks.py l: return 1 return dtype.size * 8 def _calculate_bit_size(self, history: sizing_executor.SizeAndDTypes) -> int: """Takes a list of 2 element lists and calculates the number of bits rep...
code_fim
hard
{ "lang": "python", "repo": "Saiprasad16/federated", "path": "/tensorflow_federated/python/core/impl/executors/executor_stacks.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> num_clients: Optional[int], default_num_clients: int) -> int: if num_clients is not None: warnings.warn('num_clients is deprecated; please use default_num_clients ' 'instead.') py_typecheck.check_type(num_clients, int) return num_clients return default_num_clients d...
code_fim
hard
{ "lang": "python", "repo": "Saiprasad16/federated", "path": "/tensorflow_federated/python/core/impl/executors/executor_stacks.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.rect.y = y # Sets change x def setChangeX(self, x): self.changex = x # Sets change y def setChangeY(self, y): self.changey = y<|fim_prefix|># repo: Programming-2/Lil-Sheds-Get-Good-In path: /src/Entity.py import pygame # Basic structure for entities class ...
code_fim
hard
{ "lang": "python", "repo": "Programming-2/Lil-Sheds-Get-Good-In", "path": "/src/Entity.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Programming-2/Lil-Sheds-Get-Good-In path: /src/Entity.py import pygame # Basic structure for entities class Entity(pygame.sprite.Sprite): def __init__(self, startx, starty, xchange, ychange, image): super().__init__() self.xchange = xchange self.ychange = ychange ...
code_fim
medium
{ "lang": "python", "repo": "Programming-2/Lil-Sheds-Get-Good-In", "path": "/src/Entity.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: modelica-3rdparty/BuildingSystems path: /BuildingSystems/Resources/Scripts/JModelica/Buildings/Constructions/Examples/Window.py # paths and info import os, sys homeDir = os.environ['HOMEPATH'] jmodDir = os.environ['JMODELICA_HOME'] workDir = "Desktop" # has to be adapted by the user !!! moLiDir =...
code_fim
medium
{ "lang": "python", "repo": "modelica-3rdparty/BuildingSystems", "path": "/BuildingSystems/Resources/Scripts/JModelica/Buildings/Constructions/Examples/Window.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|># plotting of the results import pylab as P fig = P.figure(1) P.clf() # Temperatures y1 = res['ambience.TAirRef'] y2 = res['window.toSurfacePort_1.heatPort.T'] y3 = res['window.heatTransfer.T'] y4 = res['window.toSurfacePort_2.heatPort.T'] t = res['time'] P.subplot(3,1,1) P.plot(t, y1, t, y2, t, y3, t, y4...
code_fim
hard
{ "lang": "python", "repo": "modelica-3rdparty/BuildingSystems", "path": "/BuildingSystems/Resources/Scripts/JModelica/Buildings/Constructions/Examples/Window.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: openshift/openshift-tools path: /scripts/monitoring/cron-send-disk-metrics.py #!/usr/bin/env python ''' Command to send dynamic disk information to Zagg ''' # vim: expandtab:tabstop=4:shiftwidth=4 # # Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "Licen...
code_fim
hard
{ "lang": "python", "repo": "openshift/openshift-tools", "path": "/scripts/monitoring/cron-send-disk-metrics.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> # do TPS checks; use disk.dev.total filtered_disk_totals = clean_up_metric_dict(pcp_metrics_divided[pcp_disk_dev_metrics[0]], pcp_disk_dev_metrics[0] + '.') # Add dynamic items metric_sender.add_dynamic_metric(discovery_key_disk, item_protot...
code_fim
hard
{ "lang": "python", "repo": "openshift/openshift-tools", "path": "/scripts/monitoring/cron-send-disk-metrics.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> """ cli.archive_esnet_snmp with out-of-bounds """ tokiotest.TEMP_FILE.close() # Calculate new bounds that are a subset of the actual data that will be returned orig_start_dt = datetime.datetime.strptime(tokiotest.SAMPLE_ESNET_SNMP_START, ...
code_fim
hard
{ "lang": "python", "repo": "NERSC/pytokio", "path": "/tests/test_cli_archive_esnet_snmp.py", "mode": "spm", "license": "BSD-3-Clause-LBNL", "source": "the-stack-v2" }
<|fim_suffix|> """retain some properties of each dataset in an hdf5 file""" if isinstance(obj_data, h5py.Dataset): summary['shapes'][obj_name] = obj_data.shape # note that this will break if the hdf5 file contains non-numeric datasets summary['sums'][obj_name] = obj_da...
code_fim
hard
{ "lang": "python", "repo": "NERSC/pytokio", "path": "/tests/test_cli_archive_esnet_snmp.py", "mode": "spm", "license": "BSD-3-Clause-LBNL", "source": "the-stack-v2" }
<|fim_prefix|># repo: NERSC/pytokio path: /tests/test_cli_archive_esnet_snmp.py #!/usr/bin/env python """Test the archive_esnet_snmp.py tool """ import os import datetime import warnings import nose import h5py import tokiotest import tokio.connectors.hdf5 import tokio.cli.archive_esnet_snmp def generate_tts(output_...
code_fim
hard
{ "lang": "python", "repo": "NERSC/pytokio", "path": "/tests/test_cli_archive_esnet_snmp.py", "mode": "psm", "license": "BSD-3-Clause-LBNL", "source": "the-stack-v2" }
<|fim_prefix|># repo: Interbotix/interbotix_ros_manipulators path: /interbotix_ros_xsarms/interbotix_xsarm_perception/scripts/pick_place.py import time from interbotix_xs_modules.arm import InterbotixManipulatorXS from interbotix_perception_modules.armtag import InterbotixArmTagInterface from interbotix_perception_mod...
code_fim
hard
{ "lang": "python", "repo": "Interbotix/interbotix_ros_manipulators", "path": "/interbotix_ros_xsarms/interbotix_xsarm_perception/scripts/pick_place.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # pick up all the objects and drop them in a virtual basket in front of the robot for cluster in clusters: x, y, z = cluster["position"] bot.arm.set_ee_pose_components(x=x, y=y, z=z+0.05, pitch=0.5) bot.arm.set_ee_pose_components(x=x, y=y, z=z, pitch=0.5) bot.grippe...
code_fim
hard
{ "lang": "python", "repo": "Interbotix/interbotix_ros_manipulators", "path": "/interbotix_ros_xsarms/interbotix_xsarm_perception/scripts/pick_place.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> max_array_length = 0 for index in range(len(arrays)): length = len(arrays[index]) if length > max_array_length: max_array_length = length #write headers l1 = l2 = '' for index in range(len(headers)): header = '**' + escape_string(headers[index]) + '**' l1 += '|' l1 += ...
code_fim
hard
{ "lang": "python", "repo": "gerald1248/kanban-builder", "path": "/src/main/python/kanban_builder.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gerald1248/kanban-builder path: /src/main/python/kanban_builder.py """ Creates Markdown Kanban boards from Yaml input """ import os import sys import yaml import re import string USAGE = """ Usage: python [relative/path/to/]kanban_builder.py [input.yml] Arguments: --rows=N: display no more tha...
code_fim
hard
{ "lang": "python", "repo": "gerald1248/kanban-builder", "path": "/src/main/python/kanban_builder.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> headers = [] arrays = [] max_string_lengths = [] for column in obj: key = column.keys()[0] headers.append(key) #headers arr = column[key] arrays.append(arr) #arrays max_string_length = len(key) + 4; #leave room for bold markers for s in arr: length = len(s) if ...
code_fim
hard
{ "lang": "python", "repo": "gerald1248/kanban-builder", "path": "/src/main/python/kanban_builder.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: odero/django-pesapal path: /django_pesapal/urls.py # -*- coding: utf-8 -*- from django.conf.urls import url <|fim_suffix|>urlpatterns = [ url( r"^transaction/completed/$", views.TransactionCompletedView.as_view(), name="transaction_completed", ), url( ...
code_fim
easy
{ "lang": "python", "repo": "odero/django-pesapal", "path": "/django_pesapal/urls.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>urlpatterns = [ url( r"^transaction/completed/$", views.TransactionCompletedView.as_view(), name="transaction_completed", ), url( r"^transaction/status/$", views.TransactionStatusView.as_view(), name="transaction_status", ), url(r"^transa...
code_fim
easy
{ "lang": "python", "repo": "odero/django-pesapal", "path": "/django_pesapal/urls.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: GuillaumeCisco/substra-tools path: /tests/test_metrics.py import json import sys from substratools import metrics from substratools.workspace import Workspace from substratools.utils import import_module import pytest @pytest.fixture() def write_pred_file(): workspace = Workspace() da...
code_fim
medium
{ "lang": "python", "repo": "GuillaumeCisco/substra-tools", "path": "/tests/test_metrics.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> DummyMetrics() def test_score(): m = DummyMetrics() wp = metrics.MetricsWrapper(m) s = wp.score() assert s == 15 def test_execute(load_metrics_module): s = metrics.execute() assert s == 15 @pytest.mark.parametrize("dry_run_mode,expected_score", [ (False, 15), (Tru...
code_fim
hard
{ "lang": "python", "repo": "GuillaumeCisco/substra-tools", "path": "/tests/test_metrics.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return sum(y_true) + sum(y_pred) """ import_module('metrics', code) yield del sys.modules['metrics'] @pytest.fixture(autouse=True) def setup(valid_opener, write_pred_file): pass class DummyMetrics(metrics.Metrics): def score(self, y_true, y_pred): return sum(y_true)...
code_fim
medium
{ "lang": "python", "repo": "GuillaumeCisco/substra-tools", "path": "/tests/test_metrics.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while b != 0: carry = a & b a = a ^ b b = carry << 1 return a print(no_plus_sign(1, 4))<|fim_prefix|># repo: samirsaravia/Python_101 path: /BrushingUp/challenge-1.0/1.5.1.py """ Write a function to add two positive integers together without using the '+' operator. https:...
code_fim
easy
{ "lang": "python", "repo": "samirsaravia/Python_101", "path": "/BrushingUp/challenge-1.0/1.5.1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: samirsaravia/Python_101 path: /BrushingUp/challenge-1.0/1.5.1.py """ Write a function to add two positive integers together without using the '+' operator. https://en.wikipedia.org/wiki/Bitwise_operation Explanation: https://stackoverflow.com/questions/17342042/why-this-code-for-additionusing-bit...
code_fim
easy
{ "lang": "python", "repo": "samirsaravia/Python_101", "path": "/BrushingUp/challenge-1.0/1.5.1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def port_is_locked(port): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(("127.0.0.1", port)) s.close() return False except socket.error as e: if e.errno == errno.EADDRINUSE: return True def busy_ports(start, end): busy =...
code_fim
hard
{ "lang": "python", "repo": "kapily/portlock", "path": "/portlock/portlock.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kapily/portlock path: /portlock/portlock.py import socket import sys import logging import errno import time socket_singleton = None def ensure_singleton(port, log_error=True): """After calling this method, you can be assured no other script will be running with this port. Otherwise, s...
code_fim
hard
{ "lang": "python", "repo": "kapily/portlock", "path": "/portlock/portlock.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ykanggit/web2py-appliances path: /RadioScheduleLogs/controllers/default.py # -*- coding: utf-8 -*- ######################################################################### ## This is a samples controller ## - index is the default action of any application ## - user is required for authenticati...
code_fim
hard
{ "lang": "python", "repo": "ykanggit/web2py-appliances", "path": "/RadioScheduleLogs/controllers/default.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }