text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: henrysky/milkyway_plot path: /mw_plot/mw_plot_masters.py import os import numpy as np import pylab as plt from abc import ABC, abstractmethod import astropy.units as u import astropy.coordinates as coord import warnings def rgb2gray(rgb): """ Change RGB color image into grayscale in RGB...
code_fim
hard
{ "lang": "python", "repo": "henrysky/milkyway_plot", "path": "/mw_plot/mw_plot_masters.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, grayscale, projection, center, radius, figsize, dpi, grid=False): if projection in [ "equirectangular", "aitoff", "hammer", "lambert", "mollweide", ]: self._projection = projection else: ...
code_fim
hard
{ "lang": "python", "repo": "henrysky/milkyway_plot", "path": "/mw_plot/mw_plot_masters.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': rospy.init_node('rapp_manager') manager = rocon_app_manager.RappManager() manager.spin()<|fim_prefix|># repo: Playfish/cafe_demo path: /rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py #!/usr/bin/env python # # License: BSD # https://raw.github.com/robotics...
code_fim
hard
{ "lang": "python", "repo": "Playfish/cafe_demo", "path": "/rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> rospy.init_node('rapp_manager') manager = rocon_app_manager.RappManager() manager.spin()<|fim_prefix|># repo: Playfish/cafe_demo path: /rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py #!/usr/bin/env python # # License: BSD # https://raw.github.com/robotics-in-concert/rocon_app_platfo...
code_fim
medium
{ "lang": "python", "repo": "Playfish/cafe_demo", "path": "/rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Playfish/cafe_demo path: /rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py #!/usr/bin/env python # # License: BSD # https://raw.github.com/robotics-in-concert/rocon_app_platform/master/rocon_app_manager/LICENSE # ######################################################################...
code_fim
hard
{ "lang": "python", "repo": "Playfish/cafe_demo", "path": "/rocon_app_platform/rocon_app_manager/scripts/rapp_manager.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: RWTH-EBC/pyCity path: /pycity_base/examples/example_absorption_chiller.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ Example of the absorption chiller class. """ from __future__ import division import numpy as np import pycity_base.classes.timer import pycity_base.classes.weather import...
code_fim
medium
{ "lang": "python", "repo": "RWTH-EBC/pyCity", "path": "/pycity_base/examples/example_absorption_chiller.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> np.random.seed(0) result_q = np.random.rand(timer.timesteps_used_horizon) * q_nominal result_schedule = np.random.randint(2, size=timer.timesteps_used_horizon) achiller.set_results(result_q, result_schedule) results = achiller.get_results(True) print() print("Cooling output: "...
code_fim
hard
{ "lang": "python", "repo": "RWTH-EBC/pyCity", "path": "/pycity_base/examples/example_absorption_chiller.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def process_tables(f): html = " ".join([x.strip() for x in f]) date = get_date(html) print(date) dfs = pandas.read_html(html) for i, df in enumerate(dfs, 1): print(f"Processing {date} - Table {i}") unnamed = df.columns.str.contains('^Unnamed') unnamed_exists = ...
code_fim
hard
{ "lang": "python", "repo": "c2-d2/covid-ma-cases", "path": "/scripts/ma_html_to_tsv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: c2-d2/covid-ma-cases path: /scripts/ma_html_to_tsv.py #! /usr/bin/env python3 import argparse import csv import datetime import pandas import re def get_date(s): re_date = re.compile(r".*As of (.*?)<") m = re_date.match(s) assert m is not None, "Parsing date failed" dstr = m.gr...
code_fim
hard
{ "lang": "python", "repo": "c2-d2/covid-ma-cases", "path": "/scripts/ma_html_to_tsv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def main(): parser = argparse.ArgumentParser(description="") parser.add_argument( 'file', type=argparse.FileType('r'), metavar='str', help='input html file', ) args = parser.parse_args() process_tables(args.file) if __name__ == "__main__": main...
code_fim
hard
{ "lang": "python", "repo": "c2-d2/covid-ma-cases", "path": "/scripts/ma_html_to_tsv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<|fim_prefix|># repo: Mugala/neighbourhood-watch- path: /hood/urls.py from django.conf.urls import url from . import views from django.conf import settings from django.conf.urls.st...
code_fim
hard
{ "lang": "python", "repo": "Mugala/neighbourhood-watch-", "path": "/hood/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Mugala/neighbourhood-watch- path: /hood/urls.py from django.conf.urls import url from . import views from django.conf import settings from django.conf.urls.static import static <|fim_suffix|>if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=...
code_fim
hard
{ "lang": "python", "repo": "Mugala/neighbourhood-watch-", "path": "/hood/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try: os.chdir("dirty") except OSError: print("Test Error: Couldn't cd into 'dirty' test directory.") raise self.assertTrue(self.cmake_build_info["build_dir"].is_dir()) self.assertTrue(self.cmake_build_info["comp_data_cmake"].is_file()) ...
code_fim
hard
{ "lang": "python", "repo": "phillipbonhomme/cmake.nvim", "path": "/tests/rplugin/python3/test_cmake.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: phillipbonhomme/cmake.nvim path: /tests/rplugin/python3/test_cmake.py import rplugin.python3.cmake import rplugin.python3.rtags import unittest import pathlib import neovim import subprocess import os # 1. Determine if Clean or Dirty # a. Clean - Goto Step #2 # b. Dirty - Delete all Old Bu...
code_fim
hard
{ "lang": "python", "repo": "phillipbonhomme/cmake.nvim", "path": "/tests/rplugin/python3/test_cmake.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> normpath = os.path.normpath(path) normpath_split = normpath.split(os.sep) return len(ignored_dir_names.intersection(normpath_split)) > 0<|fim_prefix|># repo: fxnn/musicdir path: /scanner.py #!/bin/env python import os import musicdir ignored_dir_names={'@eaDir'} <|fim_middle|>def scan_dir...
code_fim
hard
{ "lang": "python", "repo": "fxnn/musicdir", "path": "/scanner.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: fxnn/musicdir path: /scanner.py #!/bin/env python import os import musicdir ignored_dir_names={'@eaDir'} <|fim_suffix|> normpath = os.path.normpath(path) normpath_split = normpath.split(os.sep) return len(ignored_dir_names.intersection(normpath_split)) > 0<|fim_middle|>def scan_dir...
code_fim
hard
{ "lang": "python", "repo": "fxnn/musicdir", "path": "/scanner.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: genomicsengland/gel-coverage path: /gelcoverage/test/output_verifier.py , constants.STATISTICS, dict) self._verify_dict_field(json["results"]["whole_genome"], constants.CHROMOSOMES, list) self._verify_wg_stats(json["results"]["whole_genome"][constants.STATISTICS]) ...
code_fim
hard
{ "lang": "python", "repo": "genomicsengland/gel-coverage", "path": "/gelcoverage/test/output_verifier.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: genomicsengland/gel-coverage path: /gelcoverage/test/output_verifier.py in self.expected_gene_list, msg="Unexpected gene found in results '%s'" % gene[constants.GENE_NAME]) self._verify_dict_field(gene, constants.CHROMOSOME, str) # Checks t...
code_fim
hard
{ "lang": "python", "repo": "genomicsengland/gel-coverage", "path": "/gelcoverage/test/output_verifier.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __verify_exon(self, exon, gene_name, transcript_id, has_gc = True): try: self.assertEqual(type(exon), dict) self._verify_dict_field(exon, constants.EXON_START, int) self.assertTrue(exon[constants.EXON_START] >= 0) self._verify_dict_field(exon...
code_fim
hard
{ "lang": "python", "repo": "genomicsengland/gel-coverage", "path": "/gelcoverage/test/output_verifier.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: trickeydan/ctff path: /ctff/ctff.py """The main CTFF script.""" from importlib import resources from typing import List, Optional import mistune from flask import Flask, current_app, render_template from .challenge_group import ChallengeGroup class CTFF(Flask): """CTFFramework main class....
code_fim
hard
{ "lang": "python", "repo": "trickeydan/ctff", "path": "/ctff/ctff.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.before_first_request(self._setup) def _setup(self) -> None: self.add_url_rule("/", view_func=self.index_view) def index_view(self) -> str: """Render the index view for the CTF.""" return render_template( "index.html", challenge_groups=...
code_fim
hard
{ "lang": "python", "repo": "trickeydan/ctff", "path": "/ctff/ctff.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ The HTML for the CTF introduction. If introduction_md is set, this will be rendered from it. """ if self._introduction_md is None: return self._introduction_html else: return mistune.markdown(self._introduction_md) @property...
code_fim
hard
{ "lang": "python", "repo": "trickeydan/ctff", "path": "/ctff/ctff.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class UNet_G(nn.Module): def __init__(self, ic, oc, sz, use_f = True, use_bn = True, use_sn = False, norm_type = 'batchnorm', dropout_num = 3): super(UNet_G, self).__init__() self.ic = ic self.oc = oc self.use_f = use_f self.sz = sz self.dims = { '16' : [64, 128, 256, 512], '32' : [64, ...
code_fim
hard
{ "lang": "python", "repo": "ericlearning/generative-pix2pix", "path": "/architectures/architecture_pix2pix.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ericlearning/generative-pix2pix path: /architectures/architecture_pix2pix.py t torch.nn.utils.spectral_norm as SpectralNorm class Nothing(nn.Module): def __init__(self): super(Nothing, self).__init__() def forward(self, x): return x def get_norm(norm_type, size): if(norm_type == 'batc...
code_fim
hard
{ "lang": "python", "repo": "ericlearning/generative-pix2pix", "path": "/architectures/architecture_pix2pix.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Residual Block class ResBlock(nn.Module): def __init__(self, ic, oc, use_bn = True, use_sn = False, norm_type = 'instancenorm'): super(ResBlock, self).__init__() self.ic = ic self.oc = oc self.norm_type = norm_type self.relu = nn.ReLU(inplace = True) self.reflection_pad1 = nn.ReflectionPad...
code_fim
hard
{ "lang": "python", "repo": "ericlearning/generative-pix2pix", "path": "/architectures/architecture_pix2pix.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># if ombar_m < 0 or ombar_de < 0 or ombar_r < 0 or ombar_a < 0: # print('stepfall') # print('z = %s, Hz = %s, in_terms = %s'% (z, Hz, in_terms)) # print('ombar_m = ',ombar_m,'ombar_r = ',ombar_r, # 'ombar_a = ',ombar_a,'ombar_de = ',ombar_de) if math.isnan(Hz): ...
code_fim
hard
{ "lang": "python", "repo": "lefthandedroo/Cosmodels", "path": "/Models/firstderivs_cython.pyx", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lefthandedroo/Cosmodels path: /Models/firstderivs_cython.pyx if ombar_m < 0 or ombar_de < 0 or math.isnan(Hz): # print('gamma_over_z') # print('z = %s, Hz = %s, gamma = %s, ombar_m = %s, ombar_de = %s' # %(z, Hz, gamma, ombar_m, ombar_de)) if math.isnan(Hz): ...
code_fim
hard
{ "lang": "python", "repo": "lefthandedroo/Cosmodels", "path": "/Models/firstderivs_cython.pyx", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># if ombar_m < 0 or ombar_de < 0 or math.isnan(Hz): # print('rdecay_mxde') # print('z = %s, Hz = %s, gamma = %s, ombar_m = %s, ombar_de = %s' # %(z, Hz, gamma, ombar_m, ombar_de)) if math.isnan(Hz): print('rdecay_mxde') print('z = %s, Hz = %s, gam...
code_fim
hard
{ "lang": "python", "repo": "lefthandedroo/Cosmodels", "path": "/Models/firstderivs_cython.pyx", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: leohemsted/mandayclock path: /src/patch/exchange.py from . import Patch import pyexchange.exchange2010 as pyexchange2010 class PyExchangePatch(Patch): """ Class to patch pyexchange """ @classmethod def patch(cls): <|fim_suffix|> return '<%s: %s (%s->%s)>' % (self...
code_fim
easy
{ "lang": "python", "repo": "leohemsted/mandayclock", "path": "/src/patch/exchange.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __BaseExchangeCalendarEvent__repr__(self): return '<%s: %s (%s->%s)>' % (self.__class__.__name__, self.subject, self.start, self.end) pyexchange2010.BaseExchangeCalendarEvent.__repr__ = __BaseExchangeCalendarEvent__repr__<|fim_prefix|># repo: leohemsted/mandayclock path: ...
code_fim
medium
{ "lang": "python", "repo": "leohemsted/mandayclock", "path": "/src/patch/exchange.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jmrichardson/pycaret path: /pycaret/tests/test_time_series_setup.py rategy""" from sktime.forecasting.model_selection._split import ExpandingWindowSplitter from pycaret.time_series import setup fold = 3 fh = np.arange(1, 13) # regular horizon of 12 months fh_extended = np....
code_fim
hard
{ "lang": "python", "repo": "jmrichardson/pycaret", "path": "/pycaret/tests/test_time_series_setup.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jmrichardson/pycaret path: /pycaret/tests/test_time_series_setup.py Irrespective of the enforce_exogenous flag, all models are enabled when # the data does not contain exogenous variables. assert num_models1 == num_models2 def test_enforce_exogenous_exo_data(load_uni_exo_data_target): ...
code_fim
hard
{ "lang": "python", "repo": "jmrichardson/pycaret", "path": "/pycaret/tests/test_time_series_setup.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> seasonal_period = prefix + seasonal_period prefix = int(prefix) lcm = abs(seasonal_value * prefix) // math.gcd(seasonal_value, prefix) expected_seasonal_value = int(lcm / prefix) exp = TSForecastingExperiment() fh = np.arange(1, 13) fold = 2 data = load_pos_and_neg_data ...
code_fim
hard
{ "lang": "python", "repo": "jmrichardson/pycaret", "path": "/pycaret/tests/test_time_series_setup.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return "contact-" + Base.get_homie_device_id(self) def property_change(self, property_, value): if property_ == "contact": self.update_contact(value.upper()) Base.property_change(self, property_, value)<|fim_prefix|># repo: mjcumming/ISY-Homie-Bridge path: /isy_h...
code_fim
hard
{ "lang": "python", "repo": "mjcumming/ISY-Homie-Bridge", "path": "/isy_homie/devices/contact.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mjcumming/ISY-Homie-Bridge path: /isy_homie/devices/contact.py #! /usr/bin/env python from homie.device_contact import Device_Contact from .base import Base class Contact(Base, Device_Contact): def __init__(self, isy_device=None, homie_settings=None, mqtt_settings=None): <|fim_suffix|> ...
code_fim
hard
{ "lang": "python", "repo": "mjcumming/ISY-Homie-Bridge", "path": "/isy_homie/devices/contact.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def property_change(self, property_, value): if property_ == "contact": self.update_contact(value.upper()) Base.property_change(self, property_, value)<|fim_prefix|># repo: mjcumming/ISY-Homie-Bridge path: /isy_homie/devices/contact.py #! /usr/bin/env python from homie.d...
code_fim
hard
{ "lang": "python", "repo": "mjcumming/ISY-Homie-Bridge", "path": "/isy_homie/devices/contact.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.training and self.embed_p != 0: size = (self.emb.weight.size(0),1) mask = dropout_mask(self.emb.weight.data, size, self.embed_p) masked_embed = self.emb.weight * mask else: masked_embed = self.emb.weight if scale: ...
code_fim
hard
{ "lang": "python", "repo": "namanphy/Controllable-Image-Captioning-App", "path": "/src/dropouts.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for layer in self.layer_names: raw_w = getattr(self, f'{layer}_raw') setattr(self.module, layer, F.dropout(raw_w.data, p = self.weight_p, training = False)) if hasattr(self.module, 'reset'): self.module.reset() def forward(self, *args, reset_mask = True): ...
code_fim
hard
{ "lang": "python", "repo": "namanphy/Controllable-Image-Captioning-App", "path": "/src/dropouts.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: namanphy/Controllable-Image-Captioning-App path: /src/dropouts.py """ different kinds of dropouts for AWD-LSTM model mainly reference from https://github.com/fastai/fastai2/blob/master/fastai2/text/models/awdlstm.py with minor change """ import warnings import torch import torch.nn as nn import ...
code_fim
hard
{ "lang": "python", "repo": "namanphy/Controllable-Image-Captioning-App", "path": "/src/dropouts.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> map = MapModel.query.filter_by(map_id=map_id).first() for k, v in input.items(): setattr(map, k, v) sa.session.commit() ok = True return UpdateMap(map=map, ok=ok) class DeleteMap(graphene.Mutation): class Arguments: map_id = graphene.Int() ...
code_fim
hard
{ "lang": "python", "repo": "TaiSakuma/acondbs", "path": "/acondbs/schema/map_.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: TaiSakuma/acondbs path: /acondbs/schema/map_.py import graphene from graphene import relay from graphene_sqlalchemy import SQLAlchemyObjectType from ..models import Map as MapModel from ..db.sa import sa ##__________________________________________________________________|| class Map(SQLAlchem...
code_fim
hard
{ "lang": "python", "repo": "TaiSakuma/acondbs", "path": "/acondbs/schema/map_.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Collineli/genetic-minesweeper path: /minesweepergenetic.py #sorry to anyone who has to work with this code, including myself from random import sample, uniform, randint, seed #direction map used for gen_board function direction_map = [ (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1...
code_fim
hard
{ "lang": "python", "repo": "Collineli/genetic-minesweeper", "path": "/minesweepergenetic.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #next 2 functions are me being lazy. #theyre almost the same #first one starts the main part of genetic algorithm from scratch #i.e. it generate a new random population #the second one can be used as function that will let you continue on old generation def new_generations(n, w, h, num): gener...
code_fim
hard
{ "lang": "python", "repo": "Collineli/genetic-minesweeper", "path": "/minesweepergenetic.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def generate_population(size, w, h, N): """ generates a population with given size of population, board's w(idth) and h(eight) N is used for the number that we want to optimize. Entity is stored as a tuple (list of indexes of mines, amount of N on the board). """ population =...
code_fim
hard
{ "lang": "python", "repo": "Collineli/genetic-minesweeper", "path": "/minesweepergenetic.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jdavisclark/JsFormat path: /libs/merge_utils.py """ Copyright (c) 2012 The GoSublime Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including w...
code_fim
hard
{ "lang": "python", "repo": "jdavisclark/JsFormat", "path": "/libs/merge_utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vs = view.settings() ttts = vs.get("translate_tabs_to_spaces") if not code.strip(): return (False, '') vs.set("translate_tabs_to_spaces", False) dirty = False err = '' try: dirty = _merge_code(view, edit, code, formatted_code) except MergeException as exc: ...
code_fim
hard
{ "lang": "python", "repo": "jdavisclark/JsFormat", "path": "/libs/merge_utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: eye3/nkit4py path: /test/sandbox.py import nkit4py, json import tornado, tornado.ioloop from tornado.web import RequestHandler, Application from tornado.httpclient import HTTPRequest, AsyncHTTPClient <|fim_suffix|> self.http = AsyncHTTPClient() @tornado.gen.coroutine def run(sel...
code_fim
hard
{ "lang": "python", "repo": "eye3/nkit4py", "path": "/test/sandbox.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> downloader = XmlDownloader() result = yield downloader.run( "http://www.naprostore.ru/foto/RBC/naprostore_rbc.xml", SPEC) self.set_header("Content-Type", "application/json; charset=utf-8") self.write(json.dumps(result, indent=2, ensure_ascii=False))...
code_fim
hard
{ "lang": "python", "repo": "eye3/nkit4py", "path": "/test/sandbox.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ElPala/Urban_Lab_App path: /src/app/dash.py # Setup import dash from dash.dependencies import Input, Output, State import dash_core_components as dcc import dash_html_components as html import dash_bootstrap_components as dbc from config import config, about from model.data import Data from model...
code_fim
hard
{ "lang": "python", "repo": "ElPala/Urban_Lab_App", "path": "/src/app/dash.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @app.callback(output=Output("plot-active", "figure"), inputs=[Input("country", "value")]) def plot_active_cases(country): data.process_data(country) model = Model(data.dtf) model.forecast() model.add_deaths(data.mortality) result = Result(model.dtf) # Python function to render out...
code_fim
hard
{ "lang": "python", "repo": "ElPala/Urban_Lab_App", "path": "/src/app/dash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data.process_data(country) model = Model(data.dtf) model.forecast() model.add_deaths(data.mortality) result = Result(model.dtf) peak_day, num_max, total_cases_until_today, total_cases_in_30days, active_cases_today, active_cases_in_30days = result.get_panel() peak_color = "white...
code_fim
hard
{ "lang": "python", "repo": "ElPala/Urban_Lab_App", "path": "/src/app/dash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: TheCyberViking/Insider_Threat_Bait path: /insiderthreat.py import time import webbrowser import requests import sys def main(): print("CVE-2020-1350 Vulnerablity Scanner by @TheCyberViking, @ZepherFish, @TJ_Null, @ZoomerX") print("This is in attempt to scan and open the link to ...
code_fim
hard
{ "lang": "python", "repo": "TheCyberViking/Insider_Threat_Bait", "path": "/insiderthreat.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if response.status_code == 200: sys.stdout.write("\033[1;31m") print("CAUGHT See HR Soon") elif response.status_code == 404: sys.stdout.write("\033[0;32m") print("CAUGHT See HR Soon") main()<|fim_prefix|># repo: TheCyberViking/Insi...
code_fim
hard
{ "lang": "python", "repo": "TheCyberViking/Insider_Threat_Bait", "path": "/insiderthreat.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": main()<|fim_prefix|># repo: viniciusdc/conda-store path: /conda-store-server/conda_store_server/__main__.py from conda_store_server import cli, logging <|fim_middle|>def main(): logging.initialize_logging() cli.cli_conda_store()
code_fim
medium
{ "lang": "python", "repo": "viniciusdc/conda-store", "path": "/conda-store-server/conda_store_server/__main__.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: viniciusdc/conda-store path: /conda-store-server/conda_store_server/__main__.py from conda_store_server import cli, logging <|fim_suffix|> logging.initialize_logging() cli.cli_conda_store() if __name__ == "__main__": main()<|fim_middle|> def main():
code_fim
easy
{ "lang": "python", "repo": "viniciusdc/conda-store", "path": "/conda-store-server/conda_store_server/__main__.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> __tablename__ = 'user' id = db.Column(db.Integer,primary_key=True) name = db.Column(db.String(25),nullable=False) email = db.Column(db.String(200),nullable=False,unique=True)<|fim_prefix|># repo: FranciscoCarbonell/Flask-base-rest path: /models/user.py from databases.dbs import db <|fim_...
code_fim
easy
{ "lang": "python", "repo": "FranciscoCarbonell/Flask-base-rest", "path": "/models/user.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: FranciscoCarbonell/Flask-base-rest path: /models/user.py from databases.dbs import db <|fim_suffix|> __tablename__ = 'user' id = db.Column(db.Integer,primary_key=True) name = db.Column(db.String(25),nullable=False) email = db.Column(db.String(200),nullable=False,unique=True)<|fim_...
code_fim
easy
{ "lang": "python", "repo": "FranciscoCarbonell/Flask-base-rest", "path": "/models/user.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: smtylmzx/RouteOptimizer-FlaskWebService path: /__init__.py from flask import Flask, request from flask_cors import cross_origin import routewebservice app = Flask(__name__) <|fim_suffix|>if __name__ == "__main__": app.run()<|fim_middle|>@app.route("/post", methods=['POST']) @cross_origin() ...
code_fim
medium
{ "lang": "python", "repo": "smtylmzx/RouteOptimizer-FlaskWebService", "path": "/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data = request.form['data'] demands = request.form['demands'] return routewebservice.main(data, demands) if __name__ == "__main__": app.run()<|fim_prefix|># repo: smtylmzx/RouteOptimizer-FlaskWebService path: /__init__.py from flask import Flask, request from flask_cors import cross_orig...
code_fim
medium
{ "lang": "python", "repo": "smtylmzx/RouteOptimizer-FlaskWebService", "path": "/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": app.run()<|fim_prefix|># repo: smtylmzx/RouteOptimizer-FlaskWebService path: /__init__.py from flask import Flask, request from flask_cors import cross_origin import routewebservice app = Flask(__name__) @app.route("/post", methods=['POST']) @cross_origin() def postData()...
code_fim
medium
{ "lang": "python", "repo": "smtylmzx/RouteOptimizer-FlaskWebService", "path": "/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return urlresolvers.reverse( "comment_tests.custom_comments.views.custom_approve_comment", args=(c.id,) )<|fim_prefix|># repo: Albertsss/hue path: /desktop/core/ext-py/Django-1.6.10/tests/comment_tests/custom_comments/__init__.py from django.core import urlresolvers from comment_t...
code_fim
hard
{ "lang": "python", "repo": "Albertsss/hue", "path": "/desktop/core/ext-py/Django-1.6.10/tests/comment_tests/custom_comments/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Albertsss/hue path: /desktop/core/ext-py/Django-1.6.10/tests/comment_tests/custom_comments/__init__.py from django.core import urlresolvers from comment_tests.custom_comments.models import CustomComment from comment_tests.custom_comments.forms import CustomCommentForm def get_model(): return...
code_fim
medium
{ "lang": "python", "repo": "Albertsss/hue", "path": "/desktop/core/ext-py/Django-1.6.10/tests/comment_tests/custom_comments/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def get_form_target(): return urlresolvers.reverse( "comment_tests.custom_comments.views.custom_submit_comment" ) def get_flag_url(c): return urlresolvers.reverse( "comment_tests.custom_comments.views.custom_flag_comment", args=(c.id,) ) def get_delete_url(c): ...
code_fim
medium
{ "lang": "python", "repo": "Albertsss/hue", "path": "/desktop/core/ext-py/Django-1.6.10/tests/comment_tests/custom_comments/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: fraufelder-frau/zalzibab_public_suite path: /risk_management/risk_calculator.py #!/usr/bin/env python # coding: utf-8 import MyBitmex as bm import MyBybit as bb from MyFunctions import * import sys print('Begin Risk Manager') while True: exchanges = ['Bitmex', 'Bybit', 'Exit'] exchange...
code_fim
hard
{ "lang": "python", "repo": "fraufelder-frau/zalzibab_public_suite", "path": "/risk_management/risk_calculator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif step1 == 'Plan New Trade': order_type = list_user_prompt('Choose Order Type for Entry', order_types) stop = input_price(client, 'Enter Stop Price', valid_ticks) target = input_price(client, 'Enter Target Price', valid_ticks) ...
code_fim
hard
{ "lang": "python", "repo": "fraufelder-frau/zalzibab_public_suite", "path": "/risk_management/risk_calculator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif exchange == 'Bybit': contract = 'BTCUSD' while True: step1_options = ['View/Manage Open Positions', 'Plan New Trade', 'Change Exchange'] step1 = list_user_prompt('Choose Starting Option', step1_options) if step1 == 'Change Exchange': ...
code_fim
hard
{ "lang": "python", "repo": "fraufelder-frau/zalzibab_public_suite", "path": "/risk_management/risk_calculator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>print("------- ACCURACY ASSESSMENT -------") print("RMSE: {:.4f}" .format(rmse)) print("R^2 score: {:.4f}" .format(r2_score)) print("CV Scores: {:.2f} (+/- {:.2f})" .format(cv_scores.mean(),\ cv_scores.std() * 2)) ##### PLOT ##### # Plot outputs, using scatt...
code_fim
hard
{ "lang": "python", "repo": "voaneves/LearningML", "path": "/Regression/Boston Housing/LR_BostonHousing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>##### PLOT ##### # Plot outputs, using scatter and tableau n. 4. Ticks are diabled and everything # else is the cleanest that I could plt.style.use('ggplot') plt.scatter(Y_test, Y_pred, alpha=0.75, label='Comparative Prices') plt.tick_params( axis='both', # changes apply to the x-axis which=...
code_fim
hard
{ "lang": "python", "repo": "voaneves/LearningML", "path": "/Regression/Boston Housing/LR_BostonHousing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: voaneves/LearningML path: /Regression/Boston Housing/LR_BostonHousing.py #!/usr/bin/env python # Title : LR_BostonHousing.py # Description : With Linear Regression, we hope to accurately predict the Bos- # ton Housing prices using ScikitLearn techniques and datasets. # ...
code_fim
hard
{ "lang": "python", "repo": "voaneves/LearningML", "path": "/Regression/Boston Housing/LR_BostonHousing.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Zenterio/opensourcelib path: /k2/addons/k2-gude/gudepowercontrol/test/test_gudepowermeterextension.py from unittest import TestCase from unittest.mock import patch from zaf.config import MissingConditionalConfigOption from powermeter import POWER_METER_POWER from ..gudepowermeter import GUDE_I...
code_fim
hard
{ "lang": "python", "repo": "Zenterio/opensourcelib", "path": "/k2/addons/k2-gude/gudepowercontrol/test/test_gudepowermeterextension.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> json = create_valid_power_json_response(port=1, value=42) json['sensor_values'][0]['type'] = GUDE_INDIVIDUAL_PORT_MEASUREMENTS + 1 with self.assertRaises(GudePowerMeterError): with patch('requests.get', return_value=success_response(json=json)): with cre...
code_fim
hard
{ "lang": "python", "repo": "Zenterio/opensourcelib", "path": "/k2/addons/k2-gude/gudepowercontrol/test/test_gudepowermeterextension.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_correct_power_value(self): port = 1 valid_json = create_valid_power_json_response(port=port, value=42) with patch('requests.get', return_value=success_response(json=valid_json)): with create_powermeter_harness(gude_port=port) as h: futures =...
code_fim
hard
{ "lang": "python", "repo": "Zenterio/opensourcelib", "path": "/k2/addons/k2-gude/gudepowercontrol/test/test_gudepowermeterextension.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mechaturtles/The-Deleter path: /deleter.py import os import sys # needed functions: prefix, zero result handling # File delete function with fault exception def delete(file): try: print("Deleting " + file) bsize = os.path.getsize(addpath + file) #Size in bytes ...
code_fim
hard
{ "lang": "python", "repo": "mechaturtles/The-Deleter", "path": "/deleter.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while True: ans = input("\nRestart? (y/n)\n") if ans == "n" or ans == "y" or ans == "": break else: print("Invalid input.\n") sess_size = filesize(sess_total) ans = input("\nProgram finished. {} {} worth of files deleted during this session. P...
code_fim
hard
{ "lang": "python", "repo": "mechaturtles/The-Deleter", "path": "/deleter.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HackUTA-Solar/SmarterGroceries path: /config.conf.py # These values are for TESTING! Please override with real val<|fim_suffix|>ASE_PORT=3306 MYSQL_DATABASE_USER='root' MYSQL_DATABASE_DB='g'<|fim_middle|>ues when deploying! SECRET_KEY=b'\xca\xd3\x14\xbe>\x18\xb22&\xd4B>E\xf5\x04\xb3' MYSQL_DATABA...
code_fim
medium
{ "lang": "python", "repo": "HackUTA-Solar/SmarterGroceries", "path": "/config.conf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ASE_PORT=3306 MYSQL_DATABASE_USER='root' MYSQL_DATABASE_DB='g'<|fim_prefix|># repo: HackUTA-Solar/SmarterGroceries path: /config.conf.py # These values are for TESTING! Please override with real values when deploying! SECRET_KEY=b'\xca\xd3\x14\xbe>\x18\xb22&\x<|fim_middle|>d4B>E\xf5\x04\xb3' MYSQL_DATABA...
code_fim
medium
{ "lang": "python", "repo": "HackUTA-Solar/SmarterGroceries", "path": "/config.conf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Step 1: Assignment # Compute distance from each point to each centroid # use tf.argmin https://www.tensorflow.org/versions/0.6.0/api_docs/python/math_ops.html#argmin # to get centroid assignments # To compute distance, use something like: # euclid_dist = tf.sqrt(tf.reduce_sum(tf.pow(tf.sub(v1, v2), 2)...
code_fim
medium
{ "lang": "python", "repo": "jrubin01/learningtensorflow", "path": "/solutions/L06/kmeans_plan.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Can also use tf.segment_sum to do this https://www.tensorflow.org/versions/0.6.0/api_docs/python/math_ops.html#segment_sum # However that is what the reference uses<|fim_prefix|># repo: jrubin01/learningtensorflow path: /solutions/L06/kmeans_plan.py # Create random dataset of blogs # Use "tf.gather...
code_fim
hard
{ "lang": "python", "repo": "jrubin01/learningtensorflow", "path": "/solutions/L06/kmeans_plan.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jrubin01/learningtensorflow path: /solutions/L06/kmeans_plan.py # Create random dataset of blogs # Use "tf.gather" with a randomly generated index to initialise starting centroids # Loop until convergence <<< TODO convergence test # Start with just 100 iterations, then consider a convergence...
code_fim
hard
{ "lang": "python", "repo": "jrubin01/learningtensorflow", "path": "/solutions/L06/kmeans_plan.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_simple(): mock_api = Mock() jobstep_id = uuid4() mock_api.get_jobstep.return_value = { 'status': {'id': 'in_progress'} } heartbeater = Heartbeater(mock_api, jobstep_id) heartbeat_thread = Thread(target=heartbeater.wait) heartbeat_thread.start() sleep(0.0...
code_fim
medium
{ "lang": "python", "repo": "isabella232/changes-lxc-wrapper", "path": "/tests/test_heartbeat.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # XXX(dcramer): we really shouldnt call this internal API with heartbeater.cv: heartbeater.cv.notifyAll() sleep(0.001) assert mock_api.mock_calls == [ call.get_jobstep(jobstep_id), call.get_jobstep(jobstep_id), ] assert not heartbeat_thread.is_alive() ...
code_fim
medium
{ "lang": "python", "repo": "isabella232/changes-lxc-wrapper", "path": "/tests/test_heartbeat.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: isabella232/changes-lxc-wrapper path: /tests/test_heartbeat.py from mock import call, Mock from time import sleep from threading import Thread from uuid import uuid4 <|fim_suffix|> mock_api = Mock() jobstep_id = uuid4() mock_api.get_jobstep.return_value = { 'status': {'id': '...
code_fim
medium
{ "lang": "python", "repo": "isabella232/changes-lxc-wrapper", "path": "/tests/test_heartbeat.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_errors( """ type Known extend scalar Unknown @dummy extend type Unknown @dummy extend interface Unknown @dummy extend union Unknown @dummy extend enum Unknown @dummy extend input Unknown @dummy ...
code_fim
hard
{ "lang": "python", "repo": "nudjur/graphql-core", "path": "/tests/validation/test_possible_type_extensions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def extending_with_different_kinds(): assert_errors( """ scalar FooScalar type FooObject interface FooInterface union FooUnion enum FooEnum input FooInputObject extend type FooScalar @dummy ...
code_fim
hard
{ "lang": "python", "repo": "nudjur/graphql-core", "path": "/tests/validation/test_possible_type_extensions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nudjur/graphql-core path: /tests/validation/test_possible_type_extensions.py from functools import partial from graphql.utilities import build_schema from graphql.validation.rules.possible_type_extensions import ( PossibleTypeExtensionsRule, extending_unknown_type_message, extending_...
code_fim
hard
{ "lang": "python", "repo": "nudjur/graphql-core", "path": "/tests/validation/test_possible_type_extensions.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CESEL/BatchBuilderResearch path: /RQ1and2/code/test.py from batching import BatchBisect # y_proba = [0.1, 0.2, 0.0, 0.8, 0.3, 0.0, 0.0, 0.2, 0.1, 0.6, # 0.0, 0.7, 0.0, 0.2, 0.3, 0.0, 0.6, 0.9, 0.1, 0.3, # 0.0, 0.8, 0.7, 0.2, 0.3, 0.0, 0.9, 0.3, 0.1, 0.2, # 0.2, 0...
code_fim
medium
{ "lang": "python", "repo": "CESEL/BatchBuilderResearch", "path": "/RQ1and2/code/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>assert x == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] assert y == [0.0, 0.09999999999999998, 0.19999999999999996, 0.15000000000000002, -0.125, 0.09999999999999998, -0.10000000000000009, 0.025000000000000022, 0.025000000000000022, -0.2250000000000001, -0.125, 0.025000000000000...
code_fim
medium
{ "lang": "python", "repo": "CESEL/BatchBuilderResearch", "path": "/RQ1and2/code/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> config = configparser.ConfigParser() config.read(config_file) try: object.__setattr__(self, "email_folder", config.get("Email", "Folder")) except configparser.NoOptionError: object.__setattr__(self, "email_folder", "INBOX") try: ...
code_fim
medium
{ "lang": "python", "repo": "bweissinger/steam-reporter", "path": "/steam_reporter/config.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: bweissinger/steam-reporter path: /steam_reporter/config.py from dataclasses import dataclass import configparser @dataclass(frozen=True) class Config: """ConfigParser wrapper""" email_folder: str threads: int database: str email_address: str email_server: str local_...
code_fim
medium
{ "lang": "python", "repo": "bweissinger/steam-reporter", "path": "/steam_reporter/config.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: openstack/keystoneauth path: /keystoneauth1/exceptions/discovery.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/licenses/LICENSE-2.0 # ...
code_fim
medium
{ "lang": "python", "repo": "openstack/keystoneauth", "path": "/keystoneauth1/exceptions/discovery.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> message = "Discovery of client versions failed." class VersionNotAvailable(DiscoveryFailure): message = "Discovery failed. Requested version is not available." class ImpliedVersionMismatch(ValueError): label = 'version' def __init__(self, service_type, implied, given): super(I...
code_fim
hard
{ "lang": "python", "repo": "openstack/keystoneauth", "path": "/keystoneauth1/exceptions/discovery.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # This pipeline can also be trained to make predictions, using # the embedded features. text_clf_pipeline = make_pipeline( text_emb_pipeline, LogisticRegression() ) # Prediction example text_clf_pipeline.fit(dataf, dataf['label_col']).predict(dataf) ``` """...
code_fim
hard
{ "lang": "python", "repo": "koaning/embetter", "path": "/embetter/external/_openai.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: koaning/embetter path: /embetter/external/_openai.py import os import numpy as np import openai from embetter.base import EmbetterBase def _batch(iterable, n=1): len_iter = len(iterable) for ndx in range(0, len_iter, n): yield iterable[ndx : min(ndx + n, len_iter)] class Open...
code_fim
hard
{ "lang": "python", "repo": "koaning/embetter", "path": "/embetter/external/_openai.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, model="text-embedding-ada-002", batch_size=25): # You must run this first! openai.organization = os.getenv("OPENAI_ORG") openai.api_key = os.getenv("OPENAI_KEY") self.model = model self.batch_size = batch_size def transform(self, X, y=Non...
code_fim
hard
{ "lang": "python", "repo": "koaning/embetter", "path": "/embetter/external/_openai.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def show_balance(self): print("Balance on account {} is {:.2f}".format(self.name, self._balance / 100)) if __name__ == '__main__': john = Account("John") john.deposit(1010) john.deposit(10) john.deposit(10) john.withdraw(30) john.withdraw(0) john.show_balance() ...
code_fim
hard
{ "lang": "python", "repo": "Scottie-Richardson/python-masterclass", "path": "/Databases in Python/rollback.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if amount > 0.0: # new_balance = self._balance + amount # deposit_time = Account._current_time() # db.execute("UPDATE accounts SET balance = ? WHERE (name = ?)", (new_balance, self.name)) # db.execute("INSERT INTO history VALUES(?, ?, ?)", (deposit_t...
code_fim
hard
{ "lang": "python", "repo": "Scottie-Richardson/python-masterclass", "path": "/Databases in Python/rollback.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Scottie-Richardson/python-masterclass path: /Databases in Python/rollback.py import sqlite3 import datetime import pytz db = sqlite3.connect("accounts.sqlite", detect_types=sqlite3.PARSE_DECLTYPES) db.execute("CREATE TABLE IF NOT EXISTS accounts (name TEXT PRIMARY KEY NOT NULL, balance INTEGER N...
code_fim
hard
{ "lang": "python", "repo": "Scottie-Richardson/python-masterclass", "path": "/Databases in Python/rollback.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: david-caro/gaffer path: /gaffer/cli/commands/dev_start.py # -*- coding: utf-8 - # # This file is part of gaffer. See the NOTICE for more information. from .base import Command from ...manager import Manager from ...console_output import ConsoleOutput from ...process import ProcessConfig from .....
code_fim
hard
{ "lang": "python", "repo": "david-caro/gaffer", "path": "/gaffer/cli/commands/dev_start.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # add processes for name, cmd_str in config.procfile.processes(): cmd, cmd_args = config.procfile.parse_cmd(cmd_str) params = dict(args=cmd_args, env=config.procfile.env, numprocesses=concurrency.get(name, 1), ...
code_fim
hard
{ "lang": "python", "repo": "david-caro/gaffer", "path": "/gaffer/cli/commands/dev_start.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for group in old_groups: new_groups.update(group) if group['gid'] == group_id: new_groups.update({'gid': group_id, 'step': step_up}) heosobj.save_groups(new_groups, datetime.now()) def volume_down(heosobj, command, data): """CLI 4.3....
code_fim
hard
{ "lang": "python", "repo": "WebSpider/pyheos", "path": "/pyheos/group.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }