text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: kohnakagawa/ghidra_scripts path: /ghidra9.2.1_pyi/ghidra/app/util/datatype/microsoft/MSDataTypeUtils.pyi
from typing import List
import ghidra.program.model.address
import ghidra.program.model.data
import ghidra.program.model.listing
import ghidra.program.model.mem
import java.lang
class MSData... | code_fim | hard | {
"lang": "python",
"repo": "kohnakagawa/ghidra_scripts",
"path": "/ghidra9.2.1_pyi/ghidra/app/util/datatype/microsoft/MSDataTypeUtils.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Gets a pointer displacement data type.
@param program the program for the data type.
@return the pointer displacement data type.
"""
...
@staticmethod
def getReferenceDataType(program: ghidra.program.model.listing.Program, referredToDataType: gh... | code_fim | hard | {
"lang": "python",
"repo": "kohnakagawa/ghidra_scripts",
"path": "/ghidra9.2.1_pyi/ghidra/app/util/datatype/microsoft/MSDataTypeUtils.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def getReferencedAddress(program: ghidra.program.model.listing.Program, address: ghidra.program.model.address.Address) -> ghidra.program.model.address.Address:
"""
Gets the referred to address from the bytes in the program at the indicated address.
If the pro... | code_fim | hard | {
"lang": "python",
"repo": "kohnakagawa/ghidra_scripts",
"path": "/ghidra9.2.1_pyi/ghidra/app/util/datatype/microsoft/MSDataTypeUtils.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Start a search.
engine.position(board)
engine.go(movetime=100)
if board.turn == chess.WHITE:
counts["scores"].append((info_handler.info["score"][1][0]) / 100)
else:
counts["scores"].append((-info_handler.info["score"][1][0]) / 100)
... | code_fim | hard | {
"lang": "python",
"repo": "CoderAryanAnand/fun_projects",
"path": "/Chess_analysis/analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CoderAryanAnand/fun_projects path: /Chess_analysis/analysis.py
import matplotlib
import matplotlib.pyplot as plt
import chess
import chess.svg
import chess.pgn
#from IPython.display import SVG
pgn = open("C:/Users/Aryan Anand/Documents/12323.pgn")
# n = 1
# print(n)
for i in range(1, 3):
... | code_fim | hard | {
"lang": "python",
"repo": "CoderAryanAnand/fun_projects",
"path": "/Chess_analysis/analysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ctlee/bccgc4 path: /Docking_Schrodinger_Glide_templates/Glide_SP_core_templates/Glide_SP_core_ensemble_template/grids/gen_grids.py
#Code to write bash script that generates grids based off of the input files made by grid_in.py
<|fim_suffix|>with open('gen_grids.sh','w') as newfile:
for num ... | code_fim | medium | {
"lang": "python",
"repo": "ctlee/bccgc4",
"path": "/Docking_Schrodinger_Glide_templates/Glide_SP_core_templates/Glide_SP_core_ensemble_template/grids/gen_grids.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open('gen_grids.sh','w') as newfile:
for num in range(10):
newfile.write('$SCHRODINGER/glide /scratch/jegan/GLIDE_'+dock+'_core_docking/'+method+'_docking/grids/'+method+'_grid_'+str(num)+'.in\n')<|fim_prefix|># repo: ctlee/bccgc4 path: /Docking_Schrodinger_Glide_templates/Glide_SP_core_... | code_fim | medium | {
"lang": "python",
"repo": "ctlee/bccgc4",
"path": "/Docking_Schrodinger_Glide_templates/Glide_SP_core_templates/Glide_SP_core_ensemble_template/grids/gen_grids.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vshalt/flask-reddit path: /app/community/views.py
from app.community import community_blueprint
from app.community.forms import NewCommunityForm, UpdateCommunityForm
from app import db
from app.models import Community, CommunityParticipant
from flask import render_template, redirect, url_for, fla... | code_fim | hard | {
"lang": "python",
"repo": "vshalt/flask-reddit",
"path": "/app/community/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@community_blueprint.route('/community/join/<string:name>')
@login_required
def join_community(name):
community = Community.query.filter_by(name=name).first()
if community:
community_participant = CommunityParticipant.query.filter_by(user_id=current_user.id, community_id=community.id).firs... | code_fim | hard | {
"lang": "python",
"repo": "vshalt/flask-reddit",
"path": "/app/community/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> environ['repoze.debug.canary'] = Canary()
return self.app(environ, start_response)
class Canary(object):
pass
def make_middleware(app, global_conf):
""" Paste filter-app converter """
return CanaryMiddleware(app)<|fim_prefix|># repo: repoze/repoze.debug path: /repoze/debug/c... | code_fim | medium | {
"lang": "python",
"repo": "repoze/repoze.debug",
"path": "/repoze/debug/canary.py",
"mode": "spm",
"license": "BSD-3-Clause-Modification",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: repoze/repoze.debug path: /repoze/debug/canary.py
class CanaryMiddleware:
def __init__(self, app):
<|fim_suffix|> """ Paste filter-app converter """
return CanaryMiddleware(app)<|fim_middle|> self.app = app
def __call__(self, environ, start_response):
environ['repoz... | code_fim | hard | {
"lang": "python",
"repo": "repoze/repoze.debug",
"path": "/repoze/debug/canary.py",
"mode": "psm",
"license": "BSD-3-Clause-Modification",
"source": "the-stack-v2"
} |
<|fim_suffix|>def make_middleware(app, global_conf):
""" Paste filter-app converter """
return CanaryMiddleware(app)<|fim_prefix|># repo: repoze/repoze.debug path: /repoze/debug/canary.py
class CanaryMiddleware:
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response... | code_fim | easy | {
"lang": "python",
"repo": "repoze/repoze.debug",
"path": "/repoze/debug/canary.py",
"mode": "spm",
"license": "BSD-3-Clause-Modification",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kondratyev-nv/training path: /python/test/disjoint_set_tests.py
import unittest
import os
from src.disjoint_set import DisjointSet
class disjoint_set_tests(unittest.TestCase):
def test_not_connected_when_set_is_empty(self):
s = DisjointSet()
self.assertFalse(s.is_connected(... | code_fim | hard | {
"lang": "python",
"repo": "kondratyev-nv/training",
"path": "/python/test/disjoint_set_tests.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = DisjointSet()
self.assertEqual(2, s.union(1, 2))
self.assertTrue(s.is_connected(1, 2))
self.assertTrue(s.is_connected(2, 1))
def test_can_connect_two_sets(self):
s = DisjointSet()
self.assertEqual(2, s.union(1, 2))
self.assertTrue(s.is_conne... | code_fim | hard | {
"lang": "python",
"repo": "kondratyev-nv/training",
"path": "/python/test/disjoint_set_tests.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = DisjointSet()
self.assertEqual(2, s.union(1, 2))
self.assertEqual(3, s.union(2, 3))
self.assertEqual(4, s.union(3, 4))
self.assertEqual(4, s.union(4, 1))
def test_can_process_large_input_from_file(self):
s = DisjointSet()
pairs = self.__read... | code_fim | hard | {
"lang": "python",
"repo": "kondratyev-nv/training",
"path": "/python/test/disjoint_set_tests.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NESS-Network/WEB_TAGS path: /webtags.py
from flask import Flask, render_template, request, Response, redirect
import json
from classes.Updater import Updater
from classes.DI import DI
from classes.Config import Config
app = Flask(__name__)
# pip install requests
# pip install json-rpc
@app.rou... | code_fim | hard | {
"lang": "python",
"repo": "NESS-Network/WEB_TAGS",
"path": "/webtags.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route('/show/<int:network_id>/<int:lang_id>/<int:type_id>/<int:tags_id>/<int:resource_id>')
def show_resource(network_id, lang_id, type_id, tags_id, resource_id):
rep = DI.get_repository()
network = rep.get_network_name_by_id(network_id)
lang = rep.get_lang_name_by_id(lang_id)
type =... | code_fim | hard | {
"lang": "python",
"repo": "NESS-Network/WEB_TAGS",
"path": "/webtags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route('/langs/<int:network_id>')
def show_langs(network_id):
rep = DI.get_repository()
langs = rep.read_langs(network_id)
network = rep.get_network_name_by_id(network_id)
return render_template('list/langs.html', title='Main', nav='tags', langs=langs,
netwo... | code_fim | hard | {
"lang": "python",
"repo": "NESS-Network/WEB_TAGS",
"path": "/webtags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tox-dev/tox path: /tests/config/loader/test_loader.py
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from tox.config.cli.parse import get_options
from tox.config.loader.api import Override
if TYPE_CHECKING:
from tox.pytest import CaptureFixture
<|fim_su... | code_fim | medium | {
"lang": "python",
"repo": "tox-dev/tox",
"path": "/tests/config/loader/test_loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parsed, _, __, ___, ____ = get_options(flag, "magic=true")
assert len(parsed.override) == 1
value = parsed.override[0]
assert value.key == "magic"
assert value.value == "true"
assert not value.namespace
assert value.append is False
@pytest.mark.parametrize("flag", ["-x", "--o... | code_fim | medium | {
"lang": "python",
"repo": "tox-dev/tox",
"path": "/tests/config/loader/test_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
"""Command line execution of this building block. Please check the command line documentation."""
parser = argparse.ArgumentParser(description="Wrapper for the GROMACS make_ndx module.",
formatter_class=lambda prog: argparse.RawTextHelpFormatter(pro... | code_fim | hard | {
"lang": "python",
"repo": "bioexcel/biobb_md",
"path": "/biobb_md/gromacs/make_ndx.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bioexcel/biobb_md path: /biobb_md/gromacs/make_ndx.py
#!/usr/bin/env python3
"""Module containing the MakeNdx class and the command line interface."""
import os
import argparse
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration impo... | code_fim | hard | {
"lang": "python",
"repo": "bioexcel/biobb_md",
"path": "/biobb_md/gromacs/make_ndx.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Input/Output files
self.io_dict = {
"in": {"input_structure_path": input_structure_path, "input_ndx_path": input_ndx_path},
"out": {"output_ndx_path": output_ndx_path}
}
# Properties specific for BB
self.selection = properties.get('selecti... | code_fim | hard | {
"lang": "python",
"repo": "bioexcel/biobb_md",
"path": "/biobb_md/gromacs/make_ndx.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maximebenoitgagne/wintertime path: /utils/python/python/tiles/variable.py
les) > 0:
self.tiled = True
else:
globpatt = base + '.meta'
if debug: print 'looking for metafiles:', globpatt
metafiles = glob(base + '.meta')
... | code_fim | hard | {
"lang": "python",
"repo": "maximebenoitgagne/wintertime",
"path": "/utils/python/python/tiles/variable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if trunc.endswith('/'):
dvs = unknowndimvals(trunc)
dimvals.update(dvs)
first = dict((k,v[0]) for k,v in dvs.items())
else:
dvs = unknowndimvals(trunc,sufs)
dimvals.update(dv... | code_fim | hard | {
"lang": "python",
"repo": "maximebenoitgagne/wintertime",
"path": "/utils/python/python/tiles/variable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ndims = i
i = 0
vardimnames = []
while re.search(r'{v%d[}:]' % i, tmpl):
vardimnames.append('v%d' % i)
i += 1
nvardims = i
dimvals = dict( (k,kwargs.get(k, [])) for k in dimnames+vardimnames )
first = dict( (k,kwargs.get(k, ['*'])[0]) for k in dimnames+vardim... | code_fim | hard | {
"lang": "python",
"repo": "maximebenoitgagne/wintertime",
"path": "/utils/python/python/tiles/variable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Inverts y => x.
"""
# During training, keep smoothed average of sample mean and variance
if self.training:
mean, var = y.mean(0), y.var(0)
# NOTE: The momentum variable agrees with the definition in e.g. `torch.nn.BatchNorm1d`
self.movin... | code_fim | hard | {
"lang": "python",
"repo": "ae-foster/pyro",
"path": "/pyro/distributions/transforms/batch_norm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ae-foster/pyro path: /pyro/distributions/transforms/batch_norm.py
import torch
import torch.nn as nn
from torch.distributions import constraints
import torch.nn.functional as F
from pyro.distributions.torch_transform import TransformModule
from pyro.distributions.util import copy_docs_from
@co... | code_fim | hard | {
"lang": "python",
"repo": "ae-foster/pyro",
"path": "/pyro/distributions/transforms/batch_norm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_balance_tags(self):
for test, texturize, expected in BALANCE_TESTS:
result = content.balance_tags(test, texturize)
if result != expected:
raise ValueError(Differ(expected=expected, result=result))
def test_texturize_block(self):
... | code_fim | hard | {
"lang": "python",
"repo": "ludoo/wpkit",
"path": "/wpkit/tests/wp/test_content.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ludoo/wpkit path: /wpkit/tests/wp/test_content.py
# encoding: utf-8
from django.test import TestCase
from django_nose.tools import *
from wpkit.wp import content
from .. import Differ
BALANCE_TESTS = (
(
'<p> <p>Test 0</p>',
False,
'<p> </p><p>Test 0</p>'
),
... | code_fim | hard | {
"lang": "python",
"repo": "ludoo/wpkit",
"path": "/wpkit/tests/wp/test_content.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ybyangjing/Faster_RCNN_SUNRGBD path: /examples/faster_rcnn/train_SUNRGBD.py
"""
faster_rcnn_chainercv
train_SUNRGBD
created by Kazunari on 2018/06/26
"""
from __future__ import division
import argparse
import numpy as np
import os.path as osp
import datetime
import matplotlib
matplotlib.use(... | code_fim | hard | {
"lang": "python",
"repo": "ybyangjing/Faster_RCNN_SUNRGBD",
"path": "/examples/faster_rcnn/train_SUNRGBD.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> train_data = SUNRGBDDataset(args.dataset_path,mode="train")
test_data = SUNRGBDDataset(args.dataset_path, mode="test")
sunrgbd_bbox_label_names = train_data.get_dataset_label()
faster_rcnn = FasterRCNNVGG16(n_fg_class=len(sunrgbd_bbox_label_names),
pretr... | code_fim | hard | {
"lang": "python",
"repo": "ybyangjing/Faster_RCNN_SUNRGBD",
"path": "/examples/faster_rcnn/train_SUNRGBD.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b+=1
if i=='x':
break
total=max(0,a-b)
outfile=open('acadout.txt','w')
outfile.write(str(total))
outfile.close()<|fim_prefix|># repo: eddiegz/Personal-C path: /AIO/academic/academic espionage.py
infile=open('acadin.txt','r').readlines()
a,b=0,0
for e in infile:<|fim_middle|>
... | code_fim | medium | {
"lang": "python",
"repo": "eddiegz/Personal-C",
"path": "/AIO/academic/academic espionage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eddiegz/Personal-C path: /AIO/academic/academic espionage.py
infile=open('acadin.txt','r').readlines()
a,b=0,0
for e in infile:<|fim_suffix|>e=open('acadout.txt','w')
outfile.write(str(total))
outfile.close()<|fim_middle|>
i=e.strip()
if i=='i':
a+=1
elif i=='o':
... | code_fim | medium | {
"lang": "python",
"repo": "eddiegz/Personal-C",
"path": "/AIO/academic/academic espionage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, cluster, bind_address=None):
super(FrontendStanza, self).__init__("frontend")
self.header = "frontend %s" % cluster.name
if not bind_address:
bind_address = ""
self.add_lines(cluster.haproxy.get("frontend", []))
self.add_line("bi... | code_fim | medium | {
"lang": "python",
"repo": "wglass/lighthouse",
"path": "/lighthouse/haproxy/stanzas/frontend.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.add_lines(cluster.haproxy.get("frontend", []))
self.add_line("bind %s:%s" % (bind_address, cluster.haproxy["port"]))
self.add_line("default_backend %s" % cluster.name)<|fim_prefix|># repo: wglass/lighthouse path: /lighthouse/haproxy/stanzas/frontend.py
from .stanza import Sta... | code_fim | hard | {
"lang": "python",
"repo": "wglass/lighthouse",
"path": "/lighthouse/haproxy/stanzas/frontend.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wglass/lighthouse path: /lighthouse/haproxy/stanzas/frontend.py
from .stanza import Stanza
class FrontendStanza(Stanza):
"""
Stanza subclass representing a "frontend" stanza.
A frontend stanza defines an address to bind to an a backend to route
traffic to. A cluster can define... | code_fim | medium | {
"lang": "python",
"repo": "wglass/lighthouse",
"path": "/lighthouse/haproxy/stanzas/frontend.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> profiles=Profile.objects.all()
followers=Following.objects.filter(username=request.user.username)
# print(followers)
followings=Following.objects.filter(followed=request.user.username)
return render(request,"profile.html", {'profiles':profiles,'followers':followers, 'following':f... | code_fim | hard | {
"lang": "python",
"repo": "Koech-code/Instagram",
"path": "/instagram/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Koech-code/Instagram path: /instagram/views.py
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render, redirect
from .models import Following, Image, Profile
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
fr... | code_fim | hard | {
"lang": "python",
"repo": "Koech-code/Instagram",
"path": "/instagram/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def to_csv(self, data, label):
with open(f"{label}.csv", 'w', newline="") as myfile:
wr = csv.writer(myfile)
for item in data:
wr.writerow([item[0], item[1]])
def show(self):
plt.show()<|fim_prefix|># repo: swifmaneum/ContainerPacking path:... | code_fim | medium | {
"lang": "python",
"repo": "swifmaneum/ContainerPacking",
"path": "/src/Plotter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Add a list of tuples (x, y) as a line plot, see https://stackoverflow.com/a/18458953/5730444"""
plt.figure(figure_number)
plt.plot(*zip(*data), label=label, marker='.', linestyle="")
plt.legend(loc="upper left")
def to_csv(self, data, label):
with open(f"{... | code_fim | hard | {
"lang": "python",
"repo": "swifmaneum/ContainerPacking",
"path": "/src/Plotter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swifmaneum/ContainerPacking path: /src/Plotter.py
import csv
import matplotlib.pyplot as plt
class Plotter(object):
def add_figure(self, title, x_label, y_label):
figure = plt.figure()
plt.grid()
plt.title(title)
plt.xlabel(x_label)
plt.ylabel(y_labe... | code_fim | medium | {
"lang": "python",
"repo": "swifmaneum/ContainerPacking",
"path": "/src/Plotter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dev_type = data.get("dev_type")
devices = []
if dev_type == "light":
devices.append(TuyaLight(data, api))
elif dev_type == "climate":
devices.append(TuyaClimate(data, api))
elif dev_type == "scene":
devices.append(TuyaScene(data, api))
elif dev_type == "fan... | code_fim | medium | {
"lang": "python",
"repo": "ollo69/tuyaha",
"path": "/tuyaha/devices/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ollo69/tuyaha path: /tuyaha/devices/factory.py
from tuyaha.devices.climate import TuyaClimate
from tuyaha.devices.cover import TuyaCover
from tuyaha.devices.fan import TuyaFanDevice
from tuyaha.devices.light import TuyaLight
from tuyaha.devices.lock import TuyaLock
from tuyaha.devices.scene impor... | code_fim | medium | {
"lang": "python",
"repo": "ollo69/tuyaha",
"path": "/tuyaha/devices/factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if dev_type == "light":
devices.append(TuyaLight(data, api))
elif dev_type == "climate":
devices.append(TuyaClimate(data, api))
elif dev_type == "scene":
devices.append(TuyaScene(data, api))
elif dev_type == "fan":
devices.append(TuyaFanDevice(data, api))
... | code_fim | medium | {
"lang": "python",
"repo": "ollo69/tuyaha",
"path": "/tuyaha/devices/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if ('POLVO' in x) == True and ('POLVO' in y) == False: #Peixe ODEIA polvos
points = points - 1000
if ('POLVO' in y) == True and ('POLVO' in x) == False:
points = points + 1000
if ('POLVO' in x) == True and ('POLVO' in y) == True:
points = 5000
print('\033[33m—'*32)
if points != 5000:
... | code_fim | hard | {
"lang": "python",
"repo": "LuckyCards/Curso-Python3",
"path": "/Aleatorios/PeixeBurro.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LuckyCards/Curso-Python3 path: /Aleatorios/PeixeBurro.py
from time import sleep
print('\n')
print('\033[33m—'*32)
print('\033[36m PERGUNTE AO PEIXE v0.2Alpha')
print('\033[33m—'*32, '\033[m\n')
x = str(input('Digite uma palavra: ')).strip().upper()
y = str(input('Digite outra palavra: ')).strip(... | code_fim | medium | {
"lang": "python",
"repo": "LuckyCards/Curso-Python3",
"path": "/Aleatorios/PeixeBurro.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def remove_vm_hdd(vmuuid, vminfo, hdduuid):
cmd = ' '.join([
'VBoxManage',
'storageattach {vm}',
'--storagectl {sctl}',
'--medium {med}',
'--device {dev}',
'--port {port}',
'--type hdd',
])
command = ShellCommand(
cmd,
vm=... | code_fim | hard | {
"lang": "python",
"repo": "neuroticnerd/boxbox",
"path": "/boxbox/virtualbox.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neuroticnerd/boxbox path: /boxbox/virtualbox.py
"""
need to check out
https://github.com/VRGhost/vbox
"""
import re
import os
from subprocess import CalledProcessError
from .shellcommand import ShellCommand
from . import utils
re_sctl = r'(?P<sctl>.{0,}?)\s*\((?P<device>\d+),\s*(?P<port>\d+)\)... | code_fim | hard | {
"lang": "python",
"repo": "neuroticnerd/boxbox",
"path": "/boxbox/virtualbox.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_vm_info(vmname):
showvm = 'VBoxManage showvminfo {vmname}'
command = ShellCommand(showvm, vmname=vmname).grep(vmname).grep('vmdk')
utils.debug(command.prompt)
utils.debug(command)
vminfomatch = re_vm.match(command.out)
if vminfomatch is None:
utils.error('ERROR: can... | code_fim | hard | {
"lang": "python",
"repo": "neuroticnerd/boxbox",
"path": "/boxbox/virtualbox.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jlgarridol/sslearn path: /sslearn/utils.py
import numpy as np
import os
import math
import pandas as pd
from statsmodels.stats.proportion import proportion_confint
from sklearn.tree import DecisionTreeClassifier
from sklearn.base import ClassifierMixin
def safe_division(dividend, divisor, eps... | code_fim | hard | {
"lang": "python",
"repo": "jlgarridol/sslearn",
"path": "/sslearn/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if base_classifier is None:
return DecisionTreeClassifier()
elif can_be_list and (type(base_classifier) == list or type(base_classifier) == tuple):
if collection_size is not None:
if len(base_classifier) != collection_size:
raise AttributeError(f"base_c... | code_fim | hard | {
"lang": "python",
"repo": "jlgarridol/sslearn",
"path": "/sslearn/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> classes = np.unique(y_label)
proportion = calculate_prior_probability(y_label)
factor = 1/min(proportion.values())
number_per_class = dict()
for c in classes:
number_per_class[c] = math.ceil(proportion[c] * factor)
return number_per_class
def check_classifier(base_classi... | code_fim | hard | {
"lang": "python",
"repo": "jlgarridol/sslearn",
"path": "/sslearn/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inesp/blog-structuring-old-python path: /main.py
from city import City
from zoo import Zoo
<|fim_suffix|>assert vienna.zoo
assert isinstance(vienna.zoo, Zoo)
assert vienna.zoo.size == 130
assert vienna.zoo._owner_name == "Mrs Zoo Keeper"
print(
f"City: {vienna.name}\n"
f"Zoo owner: {vi... | code_fim | easy | {
"lang": "python",
"repo": "inesp/blog-structuring-old-python",
"path": "/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(
f"City: {vienna.name}\n"
f"Zoo owner: {vienna.zoo._owner_name}\n"
f"Zoo's size: {vienna.zoo.size}\n"
f"Zoo's animals: {', '.join([animal.name for animal in vienna.zoo.animals])}"
)<|fim_prefix|># repo: inesp/blog-structuring-old-python path: /main.py
from city import City
from zoo ... | code_fim | medium | {
"lang": "python",
"repo": "inesp/blog-structuring-old-python",
"path": "/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
From platform.py:
_supported_dists = (
'SuSE', 'debian', 'fedora', 'redhat', 'centos',
'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo',
'UnitedLinux', 'turbolinux', 'arch', 'mageia')
"""
return distro.linux_distribution(full_distribution_... | code_fim | hard | {
"lang": "python",
"repo": "AbnormalSec/darkbox",
"path": "/darkbox/util/osutil.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AbnormalSec/darkbox path: /darkbox/util/osutil.py
"""darkbox.util.osutil"""
import distro
import platform
def get_platform():
<|fim_suffix|>def get_distro():
"""
From platform.py:
_supported_dists = (
'SuSE', 'debian', 'fedora', 'redhat', 'centos',
'mandrake', 'mand... | code_fim | hard | {
"lang": "python",
"repo": "AbnormalSec/darkbox",
"path": "/darkbox/util/osutil.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(txt, str):
txt = txt.lower()
if txt in ["maxy", "mxy", "n", "⊤"]:
return Edge.MaxY
elif txt in ["maxx", "mxx", "e", "⊣"]:
return Edge.MaxX
elif txt in ["miny", "mny", "s", "⊥"]:
return Edge.MinY
elif txt in ["min... | code_fim | hard | {
"lang": "python",
"repo": "rohernandezz/coldtype",
"path": "/coldtype/geometry/edge.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rohernandezz/coldtype path: /coldtype/geometry/edge.py
from enum import Enum
class Edge(Enum):
MaxY = 1
MaxX = 2
MinY = 3
MinX = 4
CenterY = 5
CenterX = 6
def PairFromCompass(cmp):
if isinstance(cmp, Edge):
return None
if isinstance(cmp, ... | code_fim | hard | {
"lang": "python",
"repo": "rohernandezz/coldtype",
"path": "/coldtype/geometry/edge.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BonsaiAI/ray path: /python/ray/util/serialization.py
import ray
def register_serializer(cls, *, serializer, deserializer):
"""Use the given serializer to serialize instances of type ``cls``,
and use the deserializer to deserialize the serialized object.
<|fim_suffix|> Args:
... | code_fim | hard | {
"lang": "python",
"repo": "BonsaiAI/ray",
"path": "/python/ray/util/serialization.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
cls: A Python class/type.
"""
context = ray.worker.global_worker.get_serialization_context()
context._unregister_cloudpickle_reducer(cls)<|fim_prefix|># repo: BonsaiAI/ray path: /python/ray/util/serialization.py
import ray
def register_serializer(cls, *, serializer, deseri... | code_fim | medium | {
"lang": "python",
"repo": "BonsaiAI/ray",
"path": "/python/ray/util/serialization.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if filter(event):
return handler(event, context)
return handle<|fim_prefix|># repo: linuxbasic/async_event_bus path: /async_event_bus/event_handler.py
from async_event_bus.types import EventHandler, FilterFunction, EventHandlerFunction, Context, EventGenerator, Event
def define_... | code_fim | easy | {
"lang": "python",
"repo": "linuxbasic/async_event_bus",
"path": "/async_event_bus/event_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linuxbasic/async_event_bus path: /async_event_bus/event_handler.py
from async_event_bus.types import EventHandler, FilterFunction, EventHandlerFunction, Context, EventGenerator, Event
<|fim_suffix|> def handle(event: Event) -> EventGenerator:
if filter(event):
return handl... | code_fim | medium | {
"lang": "python",
"repo": "linuxbasic/async_event_bus",
"path": "/async_event_bus/event_handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vaexio/vaex path: /packages/vaex-astro/vaex/astro/votable.py
import astropy.io.votable
import vaex
from vaex.dataset import DatasetFile
from vaex.dataset_misc import _try_unit
class VOTable(DatasetFile):
snake_name = "votable"
def __init__(self, filename, fs_options={}, fs=None):
<|fim_suffix... | code_fim | hard | {
"lang": "python",
"repo": "vaexio/vaex",
"path": "/packages/vaex-astro/vaex/astro/votable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for field in self.first_table.fields:
name = field.name
data = self.first_table.array[name]
type = self.first_table.array[name].dtype
clean_name = name
if field.ucd:
self.ucds[clean_name] = field.ucd
if field.unit:
unit = _try_unit(field.unit)
if unit:
self.units[clean... | code_fim | hard | {
"lang": "python",
"repo": "vaexio/vaex",
"path": "/packages/vaex-astro/vaex/astro/votable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ['csat-collect', self.key, model.example, ]
def build_parser(self, base):
from . import graphs
parser = super(ExampleGraphsCollector, self).build_parser(base)
parser.add_argument('graph_name')
parser.add_argument('-l', '--list', action=ListAction,
... | code_fim | hard | {
"lang": "python",
"repo": "GaretJax/csat",
"path": "/csat/collectors/examples/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_model(self):
from . import models
return models.ExamplesConfig
def get_command(self, model):
return ['csat-collect', self.key, model.example, ]
def build_parser(self, base):
from . import graphs
parser = super(ExampleGraphsCollector, self).buil... | code_fim | hard | {
"lang": "python",
"repo": "GaretJax/csat",
"path": "/csat/collectors/examples/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GaretJax/csat path: /csat/collectors/examples/__init__.py
import argparse
from csat.acquisition import base
__version__ = '0.1.0'
class ListAction(argparse.Action):
def __init__(self, option_strings, dest, const, default=None,
required=False, help=None, metavar=None):
... | code_fim | hard | {
"lang": "python",
"repo": "GaretJax/csat",
"path": "/csat/collectors/examples/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@Client.on_message(filters.command('stats'))
async def give_sysinfo(client, message):
splatform = platform.system()
platform_release = platform.release()
platform_version = platform.version()
architecture = platform.machine()
hostname = socket.gethostname()
ip_address = socket.geth... | code_fim | medium | {
"lang": "python",
"repo": "decentboyy/PatriciaVideoPlayer",
"path": "/player/modules/stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>**PlatForm :** `{splatform}`
**PlatForm - Release :** `{platform_release}`
**PlatFork - Version :** `{platform_version}`
**Architecture :** `{architecture}`
**Hostname :** `{hostname}`
**IP :** `{ip_address}`
**Mac :** `{mac_address}`
**Processor :** `{processor}`
**Ram : ** `{ram}`
**CPU :** `{cpu_len}`
... | code_fim | hard | {
"lang": "python",
"repo": "decentboyy/PatriciaVideoPlayer",
"path": "/player/modules/stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: decentboyy/PatriciaVideoPlayer path: /player/modules/stats.py
import platform
import re
import socket
import sys
import time
import uuid
from datetime import datetime
from os import environ, execle, path, remove
from player.helpers.decorators import humanbytes
import psutil
from pyrogram import ... | code_fim | hard | {
"lang": "python",
"repo": "decentboyy/PatriciaVideoPlayer",
"path": "/player/modules/stats.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sql = """INSERT INTO lagou_it\
SET position_name=%s,company_name=%s,company_size=%s,city=%s,industry=%s,salary=%s,jobnature=%s,education=%s,workyear=%s"""
for x in range(0, len(result)):
cursor.execute(sql,(result[x][0],result[x][1],result[x][2],result[x][3],result[x][4],resu... | code_fim | hard | {
"lang": "python",
"repo": "lfthwjx/DataManipulation",
"path": "/Project/Recruit/lagou_it.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lfthwjx/DataManipulation path: /Project/Recruit/lagou_it.py
__author__ = 'Jun Wang'
# -*- coding:utf-8 -*-
import json,urllib2,sys, MySQLdb
# import pandas as pd
reload(sys)
sys.setdefaultencoding('utf8')
# from pandas import DataFrame,Series
db = MySQLdb.connect(host="localhost",user="r... | code_fim | hard | {
"lang": "python",
"repo": "lfthwjx/DataManipulation",
"path": "/Project/Recruit/lagou_it.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> condition = eval(FILTER_CODE.format(data['condition']))
try:
action_strings = data['actions']
except KeyError:
action_strings = []
actions = []
for action_string in action_strings:
_LOG.debug('parsing action: %s', action_string)... | code_fim | hard | {
"lang": "python",
"repo": "mbdevpl/maildaemon",
"path": "/maildaemon/message_filter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbdevpl/maildaemon path: /maildaemon/message_filter.py
"""Filter that is applied on e-mail messages."""
import functools
import logging
import operator
import re
import typing as t
from .message import Message
from .connection import Connection
from .filter_actions import mark, move
_LOG = log... | code_fim | hard | {
"lang": "python",
"repo": "mbdevpl/maildaemon",
"path": "/maildaemon/message_filter.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(
self, connections: t.List[Connection],
condition: t.List[t.List[t.Tuple[str, t.Callable[[str], bool]]]],
actions: t.List[t.Tuple[t.Callable[[t.Any], None], t.Sequence[t.Any]]]):
self._connections = connections
self._condition = conditio... | code_fim | hard | {
"lang": "python",
"repo": "mbdevpl/maildaemon",
"path": "/maildaemon/message_filter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def NMI(A, B, explation=False):
if explation:
print("the more the better")
total = len(A)
A_ids = set(A)
B_ids = set(B)
A_index_map = index_hash_map(A)
B_index_map = index_hash_map(B)
# 互信息计算
MI = 0
for idA in A_ids:
for idB in B_ids:
idAOcc... | code_fim | hard | {
"lang": "python",
"repo": "luluyao9494/PyTls",
"path": "/PyTls/matht.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def JSD(prob1, prob2):
'''
:desc 衡量prob1 和 prob2两个分布的相似程度
:param prob1:
:param prob2:
:return:
'''
if len(prob1) != len(prob2):
raise ValueError("input should be the same length")
prob1_norm = sum(abs(p) for p in prob1)
prob2_norm = sum(abs(p) for p in prob2)
... | code_fim | hard | {
"lang": "python",
"repo": "luluyao9494/PyTls",
"path": "/PyTls/matht.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luluyao9494/PyTls path: /PyTls/matht.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File : matht.py
@Author: sladesha
@Date : 2019/7/22 0:15
@Desc :
'''
import math
from .typet import is_type
import sys
from .listt import index_hash_map, Pi
from math import log
from math import e
__E... | code_fim | hard | {
"lang": "python",
"repo": "luluyao9494/PyTls",
"path": "/PyTls/matht.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> link = '{{' + link + '}}'
return link
def delinktemp(link):
import re
link = re.compile(r'\{\{(.*?)\}\}', re.IGNORECASE).sub(r'\1', str(link))
return link
def addsection(page, content, summary):
site = wikipedia.getSite()
wppage = wikipedia.Page(site, page)
text = wppage.get()
text = text + conte... | code_fim | hard | {
"lang": "python",
"repo": "edgarskos/legobot-old",
"path": "/legoktm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edgarskos/legobot-old path: /legoktm.py
#!usr/bin/python
#
# (C) Legoktm 2008-2011, MIT License
#
import wikipedia, pagegenerators, catlib
import re, sys
from wikipedia import *
#status updater
#syntax: legoktm.newstatus("Status", "User:Username/Status", "[y]es/[n]o prompt)
site = wikipedia.getSi... | code_fim | hard | {
"lang": "python",
"repo": "edgarskos/legobot-old",
"path": "/legoktm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> site = wikipedia.getSite()
wppage = wikipedia.Page(site, page)
text = wppage.get()
text = text + content
wikipedia.showDiff(wppage.get(), text)
try:
page.put(text, summary, minorEdit=False)
except wikipedia.NoPage:
page.put(text, summary, minorEdit=False)
except wikipedia.IsRedirectPage:
ret... | code_fim | hard | {
"lang": "python",
"repo": "edgarskos/legobot-old",
"path": "/legoktm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gbip/Geotrek-admin path: /geotrek/core/tests/test_filters.py
from unittest import skipIf
from django.conf import settings
from django.contrib.gis.geos import LineString, Point
from django.test import TestCase
from geotrek.land.tests.test_filters import LandFiltersTest
from geotrek.core.factori... | code_fim | hard | {
"lang": "python",
"repo": "gbip/Geotrek-admin",
"path": "/geotrek/core/tests/test_filters.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {'is_valid': True}
qs = TrekFilterSet(data=data).qs
self.assertIn(self.trek, qs)
self.assertEqual(qs.count(), 2)
data = {'is_valid': False}
qs = TrekFilterSet(data=data).qs
self.assertEqual(qs.count(), 1)
geom = LineString(Point(7001... | code_fim | hard | {
"lang": "python",
"repo": "gbip/Geotrek-admin",
"path": "/geotrek/core/tests/test_filters.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jdraiv/lock path: /decorators/auth_decorators.py
from functools import wraps
from sanic.response import redirect
<|fim_suffix|> if json_token != None and refresh_token != None:
response = await f(request, *args, **kwargs)
return response
... | code_fim | hard | {
"lang": "python",
"repo": "jdraiv/lock",
"path": "/decorators/auth_decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if json_token != None and refresh_token != None:
response = await f(request, *args, **kwargs)
return response
return redirect('/')
return decorated_function
return decorator<|fim_prefix|># repo: jdraiv/lock path: /decorators/auth_decor... | code_fim | hard | {
"lang": "python",
"repo": "jdraiv/lock",
"path": "/decorators/auth_decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bigrepedge/labpipestest path: /app/api/am_machine/machine_systems_simulation/filesystem.py
import os
from opcua import ua
from .base import BasicSystem
class FileSystem(BasicSystem):
ua_dir_type = 13353
ua_file_type = 11575
def __init__(self, data_handler, inputs=None, outputs=No... | code_fim | hard | {
"lang": "python",
"repo": "bigrepedge/labpipestest",
"path": "/app/api/am_machine/machine_systems_simulation/filesystem.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def recursive_file_list(self, parent_path, parent_node):
for ent in os.listdir(parent_path):
ent_path = os.path.join(self.mnt_dir, ent)
print(ent_path)
rel_path = '/{}'.format(os.path.relpath(ent_path, os.path.abspath('.')))
if os.path.isfile(ent... | code_fim | hard | {
"lang": "python",
"repo": "bigrepedge/labpipestest",
"path": "/app/api/am_machine/machine_systems_simulation/filesystem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.mnt_node = base_node.add_object(ua.NodeId('/mnt', 26), 'mnt', objecttype=self.ua_dir_type)
self.recursive_file_list(self.mnt_dir, self.mnt_node)
def recursive_file_list(self, parent_path, parent_node):
for ent in os.listdir(parent_path):
ent_path = os.path.joi... | code_fim | hard | {
"lang": "python",
"repo": "bigrepedge/labpipestest",
"path": "/app/api/am_machine/machine_systems_simulation/filesystem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># lets do imputing
print("confusion matrix")
print(metrics.confusion_matrix(y_test,predicted))
print(metrics.classification_report(y_test, predicted))
# try random forest model to improve accuracy
from sklearn.ensemble import RandomForestClassifier
rf_model = RandomForestClassifier(random_state=42)
rf_m... | code_fim | hard | {
"lang": "python",
"repo": "sudeep0901/python",
"path": "/src/ML Algorithms/1.ml_diabetes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>import matplotlib.pyplot as plt
plt.plot(C_values,recall_scores)
plt.xlabel("C value")
plt.ylabel("recall score")
plt.show()
# still 61% may be due to imb alance in dataset
# 65% DIABETICS AND 35% non diabetic and is imbalance of classes
# enabeld wieght hyperparameter to handle unbalance
#balanced we... | code_fim | hard | {
"lang": "python",
"repo": "sudeep0901/python",
"path": "/src/ML Algorithms/1.ml_diabetes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sudeep0901/python path: /src/ML Algorithms/1.ml_diabetes.py
import numpy as np
import pandas as pd
import matplotlib as mlp
import matplotlib.pyplot as plt
# https://github.com/JerryKurata/MachineLearningWithPython/
diabetes_data = pd.read_csv(r'src/ML Algorithms/1.ml.pima-data.csv')
# ticket_d... | code_fim | hard | {
"lang": "python",
"repo": "sudeep0901/python",
"path": "/src/ML Algorithms/1.ml_diabetes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: okffi/tietopyynto path: /froide/publicbody/views.py
from django.shortcuts import render, redirect, get_object_or_404
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext_lazy as _, ungettext
from django.contrib import messages
from django.conf import... | code_fim | hard | {
"lang": "python",
"repo": "okffi/tietopyynto",
"path": "/froide/publicbody/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def show_publicbody(request, slug):
obj = get_object_or_404(PublicBody, slug=slug)
context = {
'object': obj,
'foirequests': FoiRequest.published.filter(
public_body=obj).order_by('-last_message')[:10],
'resolutions': FoiRequest.published.get_resolution_count_by... | code_fim | hard | {
"lang": "python",
"repo": "okffi/tietopyynto",
"path": "/froide/publicbody/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> add_arg = self.add_argument
add_arg('--dir', type=str,
help='set project path where is the database. Default to '
'current directory')
def execute(self, args):
persistence.connect_existing(args.dir or os.getcwd())
print_msg('trials ... | code_fim | medium | {
"lang": "python",
"repo": "paopao74cn/noworkflow",
"path": "/capture/noworkflow/now/cmd/cmd_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> persistence.connect_existing(args.dir or os.getcwd())
print_msg('trials available in the provenance store:', True)
for trial in persistence.load('trial'):
text = ' Trial {id}: {script} {arguments}'.format(**trial)
indent = text.index(': ') + 2
p... | code_fim | hard | {
"lang": "python",
"repo": "paopao74cn/noworkflow",
"path": "/capture/noworkflow/now/cmd/cmd_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paopao74cn/noworkflow path: /capture/noworkflow/now/cmd/cmd_list.py
# Copyright (c) 2014 Universidade Federal Fluminense (UFF)
# Copyright (c) 2014 Polytechnic Institute of New York University.
# This file is part of noWorkflow.
# Please, consult the license terms in the LICENSE file.
from __fut... | code_fim | hard | {
"lang": "python",
"repo": "paopao74cn/noworkflow",
"path": "/capture/noworkflow/now/cmd/cmd_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bozzzzo/quark path: /quarkc/test/emit/expected/py/use-class-before-def/pkg/__init__.py
from quark_runtime import *
import quark.reflect
import use_class_before_def_md
class Bar(object):
def _init(self):
pass
def __init__(self): self._init()
<|fim_suffix|> return u"pkg.B... | code_fim | medium | {
"lang": "python",
"repo": "bozzzzo/quark",
"path": "/quarkc/test/emit/expected/py/use-class-before-def/pkg/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _init(self):
self.name = None
def __init__(self): self._init()
def _getClass(self):
return u"pkg.Foo"
def _getField(self, name):
if ((name) == (u"name")):
return (self).name
return None
def _setField(self, name, value):
if ((... | code_fim | hard | {
"lang": "python",
"repo": "bozzzzo/quark",
"path": "/quarkc/test/emit/expected/py/use-class-before-def/pkg/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _getField(self, name):
return None
def _setField(self, name, value):
pass
Bar.pkg_Bar_ref = use_class_before_def_md.Root.pkg_Bar_md
class Foo(object):
def _init(self):
self.name = None
def __init__(self): self._init()
def _getClass(self):
return u... | code_fim | medium | {
"lang": "python",
"repo": "bozzzzo/quark",
"path": "/quarkc/test/emit/expected/py/use-class-before-def/pkg/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.