text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: jiasir/playback path: /playback/mysql_manage.py
import sys
from fabric.api import *
from fabric.colors import red
from fabric.tasks import Task
from playback import common
class MysqlManage(common.Common):
"""
Manage Galera Cluster for MySQL
:param user(str): the use... | code_fim | hard | {
"lang": "python",
"repo": "jiasir/playback",
"path": "/playback/mysql_manage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :returns: None
"""
return execute(self._stop_mysql)
def _change_root_password(self, pwd):
sudo('mysqladmin -uroot password %s' % pwd)
def change_root_password(self, *args, **kwargs):
"""
Change the mysql root password
:param pwd... | code_fim | hard | {
"lang": "python",
"repo": "jiasir/playback",
"path": "/playback/mysql_manage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for obj in tree.findall("object"):
cls = obj.find("name").text
# We include "difficult" samples in training.
# Based on limited experiments, they don't hurt accuracy.
# difficult = int(obj.find("difficult").text)
# if difficult == 1:
... | code_fim | hard | {
"lang": "python",
"repo": "SmallMunich/centerX",
"path": "/data/dataset/wider_mafa_face.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SmallMunich/centerX path: /data/dataset/wider_mafa_face.py
import os
import json
import cv2
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.structures import BoxMode
import pickle
import xml.etree.ElementTree as ET
from typing import List, Tuple, Union
from fvcore.com... | code_fim | hard | {
"lang": "python",
"repo": "SmallMunich/centerX",
"path": "/data/dataset/wider_mafa_face.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return dicts
def register_face(name, txt, annotation_dirname, image_root, class_names=CLASS_NAMES):
DatasetCatalog.register(name, lambda: load_face_instances(txt, annotation_dirname, image_root, class_names))
MetadataCatalog.get(name).set(
thing_classes=list(class_names)
)<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "SmallMunich/centerX",
"path": "/data/dataset/wider_mafa_face.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NCBI-Hackathons/PubImproved path: /mesh_extract/stopStem.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 9 21:35:32 2019
@author: nidhi rastogi
"""
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
<|fim_suffix|>def tokenize(text):
output = ... | code_fim | hard | {
"lang": "python",
"repo": "NCBI-Hackathons/PubImproved",
"path": "/mesh_extract/stopStem.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def testFuncNew(text):
stopwords.append(('newWord','and','I','A','And','So','arnt','This','When','It','many','Many','so','cant','Yes','yes','No','no','These','these','also','want','please','show','me'))
output = ' '.join([word for word in text.split() if word not in stopwords])
return output
... | code_fim | medium | {
"lang": "python",
"repo": "NCBI-Hackathons/PubImproved",
"path": "/mesh_extract/stopStem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output = []
output = [word_tokenize(i) for i in text]
return output
if __name__ == "__main__":
text = 'bemethyl and isinglass'
#print(testFuncOld(text))
#print(testFuncNew(text))
#print((testFuncNew(text)).split())<|fim_prefix|># repo: NCBI-Hackathons/PubImproved path: /m... | code_fim | hard | {
"lang": "python",
"repo": "NCBI-Hackathons/PubImproved",
"path": "/mesh_extract/stopStem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ss=="rock":
print("computer won")
elif ch==computer_guess:
print("draw!")
else:
print("you won")<|fim_prefix|># repo: Code-Abhi/Basic-games path: /Rock paper scissors/rock paer scissors.py
#game of rock,paper scissors
import random
ch=input("enter rock,paper or scissors ")
compute... | code_fim | hard | {
"lang": "python",
"repo": "Code-Abhi/Basic-games",
"path": "/Rock paper scissors/rock paer scissors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Code-Abhi/Basic-games path: /Rock paper scissors/rock paer scissors.py
#game of rock,paper scissors
import random
ch=input("enter rock,paper or scissors ")
computer_guess=rando<|fim_suffix|>lif ch=="paper" and computer_guess=="scissors":
print("computer won")
elif ch=="scissors" and ... | code_fim | medium | {
"lang": "python",
"repo": "Code-Abhi/Basic-games",
"path": "/Rock paper scissors/rock paer scissors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def run_field_scan(ModelClass, model_kwargs, t_output_every, t_upto, field,
vals, force_resume=True, parallel=False):
"""Run many models with a range of parameter sets.
Parameters
----------
ModelClass: callable
A class or factory function that returns a model o... | code_fim | hard | {
"lang": "python",
"repo": "eddiejessup/agaro",
"path": "/agaro/run_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eddiejessup/agaro path: /agaro/run_utils.py
from __future__ import print_function, division
from functools import partial
from ciabatta.parallel import run_func
from agaro import runner
def run_model(t_output_every, output_dir=None, m=None, force_resume=True,
**iterate_args):
... | code_fim | hard | {
"lang": "python",
"repo": "eddiejessup/agaro",
"path": "/agaro/run_utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: intel/webml-polyfill path: /test/cts/tool/CTSConverter/src/nn/specs/V1_2/detection_postprocess.mod.py
#
# Copyright (C) 2019 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You... | code_fim | hard | {
"lang": "python",
"repo": "intel/webml-polyfill",
"path": "/test/cts/tool/CTSConverter/src/nn/specs/V1_2/detection_postprocess.mod.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>output0 = {
o1: [0.95, 0.9, 0.3],
o2: [
0.0, 10.0, 1.0, 11.0,
0.0, 0.0, 1.0, 1.0,
0.0, 100.0, 1.0, 101.0
],
o3: [1, 0, 0],
o4: [3],
}
Example((input0, output0)).AddVariations("relaxed", "float16")
# TEST 4: DETECTION_POSTPROCESSING
i1 = Input("scores", "TENSOR... | code_fim | hard | {
"lang": "python",
"repo": "intel/webml-polyfill",
"path": "/test/cts/tool/CTSConverter/src/nn/specs/V1_2/detection_postprocess.mod.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>o1 = Output("scoresOut", "TENSOR_FLOAT32", "{1, 3}") # scores out
o2 = Output("roiOut", "TENSOR_FLOAT32", "{1, 3, 4}") # roi out
o3 = Output("classesOut", "TENSOR_INT32", "{1, 3}") # classes out
o4 = Output("detectionOut", "TENSOR_INT32", "{1}") # num detections out
Model().Operation("DETECTION_POSTPROCES... | code_fim | hard | {
"lang": "python",
"repo": "intel/webml-polyfill",
"path": "/test/cts/tool/CTSConverter/src/nn/specs/V1_2/detection_postprocess.mod.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ############################################################################
@classmethod
def _add_arguments(cls, parser):
guiopt = GUIOpt(parser)
parser.add_argument(
"-t", "--schema",
metavar="FILE",
required=True,
help="schem... | code_fim | hard | {
"lang": "python",
"repo": "Shura1oplot/dufi",
"path": "/dufi/commands/cmd_xml2db_scripts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shura1oplot/dufi path: /dufi/commands/cmd_xml2db_scripts.py
# [SublimeLinter @python:3]
import os
import win32console
from .base import Command
from .xml2db import XML2DB
from .sqlhelpers import get_sql_name
from .arghelpers import GUIOpt
class XML2DBScripts(XML2DB):
BCP = 'bcp "%DATABAS... | code_fim | hard | {
"lang": "python",
"repo": "Shura1oplot/dufi",
"path": "/dufi/commands/cmd_xml2db_scripts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>kwds = run.indent(options.option_help('list'))
with open('keyword_list.rst', 'w') as fout:
fout.write(kwds)<|fim_prefix|># repo: MikeDacre/fyrd path: /docs/sphinx/print_list.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Print a table of keyword options.
<|fim_middle|>Last modified: 2016-11-11... | code_fim | medium | {
"lang": "python",
"repo": "MikeDacre/fyrd",
"path": "/docs/sphinx/print_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MikeDacre/fyrd path: /docs/sphinx/print_list.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Print a table of keyword options.
<|fim_suffix|>kwds = run.indent(options.option_help('list'))
with open('keyword_list.rst', 'w') as fout:
fout.write(kwds)<|fim_middle|>Last modified: 2016-11-11... | code_fim | medium | {
"lang": "python",
"repo": "MikeDacre/fyrd",
"path": "/docs/sphinx/print_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> w:
w.write(tflite_quant_model)
print("Weight Quantization complete! - mobilebert_english_weight_quant.tflite")<|fim_prefix|># repo: ann2183/PINTO_model_zoo path: /048_mobile_bert/01_float32/01_weight_quantization.py
### tensorflow==2.3.0
import tensorflow as tf
import numpy as np
# Weight Quantiza... | code_fim | hard | {
"lang": "python",
"repo": "ann2183/PINTO_model_zoo",
"path": "/048_mobile_bert/01_float32/01_weight_quantization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ann2183/PINTO_model_zoo path: /048_mobile_bert/01_float32/01_weight_quantization.py
### tensorflow==2.3.0
import tensorflow as tf
import numpy as np
# Weight Quantization
converter = tf.lite.TFLiteConverter.from_saved_model('experiment/saved_model/1596242469')
converter.optimizations = [tf.lite... | code_fim | medium | {
"lang": "python",
"repo": "ann2183/PINTO_model_zoo",
"path": "/048_mobile_bert/01_float32/01_weight_quantization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ZE_FOR_SIZE]
tflite_quant_model = converter.convert()
with open('mobilebert_english_weight_quant.tflite', 'wb') as w:
w.write(tflite_quant_model)
print("Weight Quantization complete! - mobilebert_english_weight_quant.tflite")<|fim_prefix|># repo: ann2183/PINTO_model_zoo path: /048_mobile_bert/01_floa... | code_fim | medium | {
"lang": "python",
"repo": "ann2183/PINTO_model_zoo",
"path": "/048_mobile_bert/01_float32/01_weight_quantization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # XXX properly handle string overlapping >1 siz sized buffers
siz = kernel.get_buffer_size()
lim = beg + rem - 1
l = []
while True:
if buf:
relpos = pos - beg
b = buf[relpos:relpos + siz]
else:
b = fo.read(pos, siz)
assert b,... | code_fim | hard | {
"lang": "python",
"repo": "kusumi/fileobj",
"path": "/src/ext/strings.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kusumi/fileobj path: /src/ext/strings.py
# Copyright (c) 2010, Tomohiro Kusumi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must ret... | code_fim | hard | {
"lang": "python",
"repo": "kusumi/fileobj",
"path": "/src/ext/strings.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crataegustess/github_rename_utils path: /github_rename_utils/github_rest_api.py
from github3 import GitHub
from github3.session import GitHubSession
from datetime import datetime
class GithubSessionWrapper:
def __init__(self, session, rate_limit_store=None):
self._wrapped = session
... | code_fim | hard | {
"lang": "python",
"repo": "crataegustess/github_rename_utils",
"path": "/github_rename_utils/github_rest_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.request('patch', url, data=data, **kwargs)
def delete(self, url, **kwargs):
return self.request('delete', url, **kwargs)
class GithubRestClient(GitHub):
def __init__(self, token, session=GitHubSession(), rate_limit_store=None):
wrapped_session = GithubSessionW... | code_fim | hard | {
"lang": "python",
"repo": "crataegustess/github_rename_utils",
"path": "/github_rename_utils/github_rest_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='orderoption',
name='service',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='options', to='calc.Service', verbose_name='Option'),
),
migrations.AlterField(
... | code_fim | medium | {
"lang": "python",
"repo": "crowmurk/locker",
"path": "/locker/calc/migrations/0014_change_order_option_verbose_names.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crowmurk/locker path: /locker/calc/migrations/0014_change_order_option_verbose_names.py
# Generated by Django 2.2.2 on 2019-08-24 09:11
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> dependencies = [
('calc', '0013_add_service_price_and_pric... | code_fim | medium | {
"lang": "python",
"repo": "crowmurk/locker",
"path": "/locker/calc/migrations/0014_change_order_option_verbose_names.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('calc', '0013_add_service_price_and_price_to_orderoption'),
]
operations = [
migrations.AlterField(
model_name='orderoption',
name='service',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_nam... | code_fim | medium | {
"lang": "python",
"repo": "crowmurk/locker",
"path": "/locker/calc/migrations/0014_change_order_option_verbose_names.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: meloncookie/JsMeetsStarlette path: /setup.py
import setuptools
SHORT_DISCRIPTION = 'This is a library that bridges '\
'server-side python and browser-side javascript.'
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(
name='JsMeetsStarlette... | code_fim | hard | {
"lang": "python",
"repo": "meloncookie/JsMeetsStarlette",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "jinja2",
"python-multipart",
"pyyaml",
"requests",
"ujson",
"starlette"
]
},
packages=setuptools.find_packages(),
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
... | code_fim | hard | {
"lang": "python",
"repo": "meloncookie/JsMeetsStarlette",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KevinBacas/FuzzeyPot path: /FuzzeyPot/Blog/views.py
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils import timezone
from django.core.urlresolvers import reverse
from .models import BlogPost
<|fim_suffix|> new_post_text = r... | code_fim | hard | {
"lang": "python",
"repo": "KevinBacas/FuzzeyPot",
"path": "/FuzzeyPot/Blog/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_post_text = request.GET.get('post_text', '')
if new_post_text == '':
return render(request, 'Blog/new.html')
else:
new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone.now())
new_blog_post.save()
return HttpResponseRedirect(reverse('blog:detai... | code_fim | medium | {
"lang": "python",
"repo": "KevinBacas/FuzzeyPot",
"path": "/FuzzeyPot/Blog/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChillyBwoy/gears-eco path: /gears_eco/compiler.py
import os
from gears.compilers import ExecCompiler
SOURCE = """(function() { %(namespace)s || (%(namespace)s = {});
%(namespace)s["%(name)s"] = %(source)s;
}).call(this);"""
<|fim_suffix|> def __call__(self, asset):
super(EcoCom... | code_fim | medium | {
"lang": "python",
"repo": "ChillyBwoy/gears-eco",
"path": "/gears_eco/compiler.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> result_mimetype = 'application/javascript'
executable = 'node'
params = [os.path.join(os.path.dirname(__file__), 'compiler.js')]
def __call__(self, asset):
super(EcoCompiler, self).__call__(asset)
asset.processed_source = SOURCE % {
'name': asset.attributes.pat... | code_fim | medium | {
"lang": "python",
"repo": "ChillyBwoy/gears-eco",
"path": "/gears_eco/compiler.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> # with open(log_file, 'rb', 0) as read_null:
# os.dup2(read_null.fileno(), sys.stdin.fileno())
with open(log_file, 'a') as write_null:
# Redirect to 1 which means stdout
os.dup2(write_null.fileno(), 1)
with open(log_file, 'a') as error_null:
# Redirect to 2 which me... | code_fim | hard | {
"lang": "python",
"repo": "FrederichRiver/neutrino2",
"path": "/dev_global/dev_global/basic.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FrederichRiver/neutrino2 path: /dev_global/dev_global/basic.py
#!/usr/bin/python38
import atexit
import os
import signal
import sys
__version__ = '1.0.1'
PROG_NAME = 'Neutrino'
def deamon(pid_file: str, log_file: str, prog_name: str):
<|fim_suffix|> os.chdir('/')
os.umask(0)
os.s... | code_fim | hard | {
"lang": "python",
"repo": "FrederichRiver/neutrino2",
"path": "/dev_global/dev_global/basic.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Initialize binary matrix
binary_matrix = numpy.zeros((len(self.label_list), length_frames))
for label in label_list:
if label in self.label_list:
# Find correct row
pos = self.label_list.index(label)
# Mark row to be h... | code_fim | hard | {
"lang": "python",
"repo": "DCASE-REPO/dcase_util",
"path": "/dcase_util/data/encoders.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif not self.allow_unknown_labels:
# Unknown label given
message = '{name}: Unknown label [{label}]'.format(name=self.__class__.__name__, label=label)
self.logger.exception(message)
raise ValueError(message)
self.data = ... | code_fim | hard | {
"lang": "python",
"repo": "DCASE-REPO/dcase_util",
"path": "/dcase_util/data/encoders.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DCASE-REPO/dcase_util path: /dcase_util/data/encoders.py
a', indent=indent) + '\n'
output += ui.data(indent=indent + 2, field='data', value=self.data) + '\n'
output += ui.line(indent=indent + 2, field='Dimensions') + '\n'
output += ui.data(indent=indent + 4, field='time_a... | code_fim | hard | {
"lang": "python",
"repo": "DCASE-REPO/dcase_util",
"path": "/dcase_util/data/encoders.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # STEP 2: eliminate rhs with more than 2 nonterminals
for i in range(len(rules)):
rule = rules[i]
lhs, rhs, log_prob = rule
if len(rhs) > 2:
assert all(x in nonterm for x in rhs), rule
current_lhs = lhs
for... | code_fim | hard | {
"lang": "python",
"repo": "positivevaib/nyu-archive",
"path": "/grad/natural-language-processing/constituent-parsing/submission.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: positivevaib/nyu-archive path: /grad/natural-language-processing/constituent-parsing/submission.py
import sys
import math
from collections import namedtuple, defaultdict
from itertools import chain, product
START_SYM = 'ROOT'
class GrammarRule(namedtuple('Rule', ['lhs', 'rhs', 'log_prob'])):
... | code_fim | hard | {
"lang": "python",
"repo": "positivevaib/nyu-archive",
"path": "/grad/natural-language-processing/constituent-parsing/submission.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if new_nonterm not in nonterm:
nonterm.add(new_nonterm)
cnf.add(new_nonterm_rule)
else:
assert new_nonterm_rule in cnf
rhs_list[j] = new_nonterm
... | code_fim | hard | {
"lang": "python",
"repo": "positivevaib/nyu-archive",
"path": "/grad/natural-language-processing/constituent-parsing/submission.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: petershan1119/semantic-progressiveness path: /modules/semshift/measures.py
import numpy as np
import gensim
class HamiltonMeasures (object):
@staticmethod
def linguistic_drift (before, after, word):
""" Hamilton et al. (2016) proposed a measure for linguistic drift,
which is simply the c... | code_fim | hard | {
"lang": "python",
"repo": "petershan1119/semantic-progressiveness",
"path": "/modules/semshift/measures.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> nn1 = before.wv.most_similar (word, topn=k)
nn2 = after.wv.most_similar (word, topn=k)
common = set ([w for w,_ in nn1]) | set ([w for w,_ in nn2])
sim1 = np.array ([before.wv.similarity (w, word) for w in common])
sim2 = np.array ([after.wv.similarity (w, word) for w in common])
sim = np.do... | code_fim | medium | {
"lang": "python",
"repo": "petershan1119/semantic-progressiveness",
"path": "/modules/semshift/measures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rkm/bluebird path: /tests/integration/machcoll/conftest.py
"""
Configuration for MachColl integration tests
"""
import pytest
<|fim_suffix|> integration_sim = request.config.getoption("--integration-sim")
if integration_sim.lower() != "machcoll":
pytest.skip()<|fim_middle|>
@pytes... | code_fim | medium | {
"lang": "python",
"repo": "rkm/bluebird",
"path": "/tests/integration/machcoll/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> integration_sim = request.config.getoption("--integration-sim")
if integration_sim.lower() != "machcoll":
pytest.skip()<|fim_prefix|># repo: rkm/bluebird path: /tests/integration/machcoll/conftest.py
"""
Configuration for MachColl integration tests
"""
import pytest
<|fim_middle|>
@pytes... | code_fim | medium | {
"lang": "python",
"repo": "rkm/bluebird",
"path": "/tests/integration/machcoll/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: parrisma/AI-Intuition path: /lib/reflrn/stochastic/StochasticAgent.py
import logging
import random
from lib.reflrn.interface.Agent import Agent
from lib.reflrn.interface.State import State
from lib.reflrn.stochastic.StochasticActorCriticPolicy import StochasticActorCriticPolicy
class Stochast... | code_fim | hard | {
"lang": "python",
"repo": "parrisma/AI-Intuition",
"path": "/lib/reflrn/stochastic/StochasticAgent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.lg.debug(self.agent_name + " reward : " + str(reward_for_play) + " for action " + str(action))
self.policy.remember(state=state,
action=action,
r=reward_for_play,
next_state=next_state)
if ... | code_fim | hard | {
"lang": "python",
"repo": "parrisma/AI-Intuition",
"path": "/lib/reflrn/stochastic/StochasticAgent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdur4373/ROS_depth_pred path: /pytorch/camera_msg.py
from sensor_msgs.msg import CameraInfo, Image
def make_camera_msg(cam, rgb_time_sec, rgb_time_nsec, test_image):
camera_info_msg = CameraInfo()
camera_info_msg.header.seq = test_image
if rgb_time_nsec + 20000000 > 999999999:
... | code_fim | medium | {
"lang": "python",
"repo": "abdur4373/ROS_depth_pred",
"path": "/pytorch/camera_msg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> depth_msg = Image()
depth_msg.header.seq = test_image
depth_msg.header.frame_id = "/openni_rgb_optical_frame"
depth_msg.header.stamp.secs = rgb_time_sec
depth_msg.header.stamp.nsecs = rgb_time_nsec - 20000000
depth_msg.step = 2560
depth_msg.is_bigendian = 0
depth_msg.enco... | code_fim | medium | {
"lang": "python",
"repo": "abdur4373/ROS_depth_pred",
"path": "/pytorch/camera_msg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xuefeicao/scdn path: /examples/DCM_sim/dcm_scdn.py
"""
An example with 100 subjects fMRI signals with same stimuli. was generated from DCM model.
Data are included in the folder data/
"""
import sys
#sys.path.append('../..')
#import scdn
from scdn.scdn_analysis import scdn_multi_sub
from scdn.e... | code_fim | hard | {
"lang": "python",
"repo": "xuefeicao/scdn",
"path": "/examples/DCM_sim/dcm_scdn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>real para
stimuli_folder = ['data/stimuli/']*100 # This folder only contains evt files, two subjects share same stimuli
dt = 3 #TR of fMRI
scdn_multi_sub(folder_name, data_file, stimuli_folder, val_pair=(0,1), dt=dt, lam=[0.1,0.01,1], mu=[0.1, 1, 5, 10, 100], mu_1=[1], mu_2=[1e-4, 1e-2, 1], lam_1=[0], tol... | code_fim | hard | {
"lang": "python",
"repo": "xuefeicao/scdn",
"path": "/examples/DCM_sim/dcm_scdn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mish3albaiz/Robotics_ECE579 path: /inmoov/scripts/json_parsing.py
import json
def read_json(filename):
# types of what it returns are json standard
# lists, dicts, strings, bools, ints, floats are unclear
with open(filename) as f:
data = json.load(f)
return data
def add_... | code_fim | hard | {
"lang": "python",
"repo": "mish3albaiz/Robotics_ECE579",
"path": "/inmoov/scripts/json_parsing.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # assumes json top-level is dict structure
# deletes item with key=gesture_name
data = read_json(filename)
del data[gesture_name]
with open(filename, 'w') as json_file:
json.dump(data, json_file, indent=4)
def pretty_print(filename):
# just print
print(json.dumps(read_... | code_fim | hard | {
"lang": "python",
"repo": "mish3albaiz/Robotics_ECE579",
"path": "/inmoov/scripts/json_parsing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>3, 15, 19, 0, 0))
# inactive on fourth thursday
assert not doorbell_is_active(datetime(2018, 3, 22, 19, 0, 0))
# inactive on fifth thursday
assert not doorbell_is_active(datetime(2018, 3, 29, 19, 0, 0))<|fim_prefix|># repo: freecodecamp-greenville/meetup-doorbell path: /test_app.py
from d... | code_fim | hard | {
"lang": "python",
"repo": "freecodecamp-greenville/meetup-doorbell",
"path": "/test_app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: freecodecamp-greenville/meetup-doorbell path: /test_app.py
from datetime import datetime
from utils import doorbell_is_active
def test_doorbell_is_active():
# inactive before 6PM
assert not doorbell_is_active(datetime(2018, 3, 1, 17, 59, 59))
# active starting <|fim_suffix|>3, 15, ... | code_fim | hard | {
"lang": "python",
"repo": "freecodecamp-greenville/meetup-doorbell",
"path": "/test_app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rberrelleza/dagster path: /python_modules/libraries/dagster-airflow/dagster_airflow_tests/marks.py
import pytest
nettest = pytest.mark.nettest
requires_k8s = pytest.mark.requires_k8s # requires k8s (and opt<|fim_suffix|>equires_airflow_db # requires airflow db (but not k8s)<|fim_middle|>ionall... | code_fim | easy | {
"lang": "python",
"repo": "rberrelleza/dagster",
"path": "/python_modules/libraries/dagster-airflow/dagster_airflow_tests/marks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>equires_airflow_db # requires airflow db (but not k8s)<|fim_prefix|># repo: rberrelleza/dagster path: /python_modules/libraries/dagster-airflow/dagster_airflow_tests/marks.py
import pytest
nettest = pytest.mark.nettest
requires_<|fim_middle|>k8s = pytest.mark.requires_k8s # requires k8s (and optionall... | code_fim | medium | {
"lang": "python",
"repo": "rberrelleza/dagster",
"path": "/python_modules/libraries/dagster-airflow/dagster_airflow_tests/marks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> file: Optional[IFile]
@router.post("/file/select")
def server_file_select(request: Request, props: Props) -> Result:
project: Project = request.app.get_project(props.session)
file = project.select_file(props.path)
return Result(file=file)<|fim_prefix|># repo: fjuniorr/goodtables-py path... | code_fim | medium | {
"lang": "python",
"repo": "fjuniorr/goodtables-py",
"path": "/frictionless/server/file/select.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Result(BaseModel):
file: Optional[IFile]
@router.post("/file/select")
def server_file_select(request: Request, props: Props) -> Result:
project: Project = request.app.get_project(props.session)
file = project.select_file(props.path)
return Result(file=file)<|fim_prefix|># repo: fju... | code_fim | medium | {
"lang": "python",
"repo": "fjuniorr/goodtables-py",
"path": "/frictionless/server/file/select.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fjuniorr/goodtables-py path: /frictionless/server/file/select.py
from typing import Optional
from pydantic import BaseModel
from fastapi import Request
from ...project import Project, IFile
from ..router import router
<|fim_suffix|> project: Project = request.app.get_project(props.session)
... | code_fim | hard | {
"lang": "python",
"repo": "fjuniorr/goodtables-py",
"path": "/frictionless/server/file/select.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codedesk/flask-gae-boilerplate path: /src/application/__init__.py
from flask import Flask
import os
__author__ = "vasanth"
<|fim_suffix|>app.config.from_object('application.settings.Development')
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
import urls<|fim_middle|>app = Flask(__name... | code_fim | easy | {
"lang": "python",
"repo": "codedesk/flask-gae-boilerplate",
"path": "/src/application/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>app = Flask(__name__)
app.config.from_object('application.settings.Development')
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
import urls<|fim_prefix|># repo: codedesk/flask-gae-boilerplate path: /src/application/__init__.py
from flask import Flask
import os
<|fim_middle|>__author__ = "vasan... | code_fim | easy | {
"lang": "python",
"repo": "codedesk/flask-gae-boilerplate",
"path": "/src/application/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
('datacombine', '0003_auto_20170826_1452'),
]
operations = [
migrations.AlterField(
model_name='address',
name='cc_id',
field=models.CharField(max_length=36, unique=True),
),
... | code_fim | hard | {
"lang": "python",
"repo": "Crimson-Star-Software/data-combine",
"path": "/datacombine/datacombine/migrations/0004_auto_20170828_0145.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Crimson-Star-Software/data-combine path: /datacombine/datacombine/migrations/0004_auto_20170828_0145.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-28 01:45
from __future__ import unicode_literals
<|fim_suffix|> operations = [
migrations.AlterField(
mod... | code_fim | hard | {
"lang": "python",
"repo": "Crimson-Star-Software/data-combine",
"path": "/datacombine/datacombine/migrations/0004_auto_20170828_0145.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#THIS CODE RUNS A RANGE OF DEGREES FOR A GIVEN DIMENSION
dim = 9
start = time.time()
for j in range(2,30):
deg = j
print("dim: ", end = '')
print(dim,end='')
print(" deg: ", end = '')
print(deg)
intervals = np.vstack([-np.ones(dim),np.ones(dim)]).T
errs =... | code_fim | hard | {
"lang": "python",
"repo": "tylerjarvis/RootFinding",
"path": "/yroots/Tester.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#THIS CODE PRINTS THE RESIDUALS OF ANY ROOTS THAT WERE FOUND
# residuals = np.abs(np.hstack([[MultiCheb(M)(point) for M in ms] for point in roots]))
# print(residuals)
#THIS CODE RUNS A RANGE OF DEGREES FOR A GIVEN DIMENSION
dim = 9
start = time.time()
for j in range(2,30):
... | code_fim | hard | {
"lang": "python",
"repo": "tylerjarvis/RootFinding",
"path": "/yroots/Tester.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tylerjarvis/RootFinding path: /yroots/Tester.py
#imports
import time
import numpy as np
import yroots as yr
from ChebyshevSubdivisionSolver import solveChebyshevSubdivision
from yroots.polynomial import MultiCheb
#This chunk of the code produces a funciton that looks kind of like a Chebys... | code_fim | hard | {
"lang": "python",
"repo": "tylerjarvis/RootFinding",
"path": "/yroots/Tester.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zYeoman/wechat-bot path: /plugins/tuling.py
#!/usr/bin/env python
# -*- coding=utf-8 -*-
# {
# "name":"tuling",
# "description":"Tuling bot",
# "type":"response",
# "regex":"^.*\.$"
# }
<|fim_suffix|> msg = [u'天气', u'你好', 'askldjf']
for m in msg:
n = {'Text': m, '... | code_fim | hard | {
"lang": "python",
"repo": "zYeoman/wechat-bot",
"path": "/plugins/tuling.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg = [u'天气', u'你好', 'askldjf']
for m in msg:
n = {'Text': m, 'FromUserName': '@abcd1234'}
print(u'test plugin tuling:msg={}'.format(m))
if get_response(n):
print("OK!")
if __name__ == '__main__':
import sys
while True:
msg = raw_input('>>>').de... | code_fim | medium | {
"lang": "python",
"repo": "zYeoman/wechat-bot",
"path": "/plugins/tuling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andrewleech/python-elm path: /elm327/connection.py
################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2014 Francisco Ruiz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and... | code_fim | hard | {
"lang": "python",
"repo": "andrewleech/python-elm",
"path": "/elm327/connection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def connect(self, device_name):
port = self._open_port(device_name)
self._LOGGER.info("Connected to %r", device_name)
connection = SerialConnection(port)
return connection
def _open_port(self, device_name):
try:
port = self._port_class(device_na... | code_fim | hard | {
"lang": "python",
"repo": "andrewleech/python-elm",
"path": "/elm327/connection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def send_command(self, data, read_delay=1):
"""Write "data" to the port and return the response form it"""
self._write(data)
if read_delay:
time.sleep(read_delay)
return self._read()
def close(self):
self._port.close()
self._port = None
... | code_fim | hard | {
"lang": "python",
"repo": "andrewleech/python-elm",
"path": "/elm327/connection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hsulab/DailyScripts path: /deepmd/evaluate_and_train.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
<|fim_suffix|>if __name__ == '__main__':
calc = EMT()
evaluated_datfile = './evaluated.xyz'
frames = read('./basic_strus.xyz', ':')
for atoms in frames:
calc.reset()
... | code_fim | medium | {
"lang": "python",
"repo": "hsulab/DailyScripts",
"path": "/deepmd/evaluate_and_train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
calc = EMT()
evaluated_datfile = './evaluated.xyz'
frames = read('./basic_strus.xyz', ':')
for atoms in frames:
calc.reset()
atoms.calc = calc
dummy = atoms.get_forces() # single-point calculation
write(evaluated_datfile, atom... | code_fim | medium | {
"lang": "python",
"repo": "hsulab/DailyScripts",
"path": "/deepmd/evaluate_and_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> frames = read('./basic_strus.xyz', ':')
for atoms in frames:
calc.reset()
atoms.calc = calc
dummy = atoms.get_forces() # single-point calculation
write(evaluated_datfile, atoms, append=True)
pass<|fim_prefix|># repo: hsulab/DailyScripts path: /deepmd/evalu... | code_fim | medium | {
"lang": "python",
"repo": "hsulab/DailyScripts",
"path": "/deepmd/evaluate_and_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NescobarAlopLop/miscellaneous path: /mini_programs/csv_streamer.py
import socket
from time import sleep
import sys
PATH = '/home/ge/k-segment/datasets/KO.csv'
HOST = 'localhost'
PORT = 9990
def infinite_stream_txt_file_over_socket(file_path: str, soc: socket) -> None:
"""
This functio... | code_fim | medium | {
"lang": "python",
"repo": "NescobarAlopLop/miscellaneous",
"path": "/mini_programs/csv_streamer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def destroy_socket(conn: socket, soc: socket) -> None:
conn.close()
conn.shutdown(socket.SHUT_RDWR)
soc.shutdown(socket.SHUT_RDWR)
soc.close()
if __name__ == '__main__':
if len(sys.argv) == 4:
path = sys.argv[1]
host = sys.argv[2]
port = int(sys.argv[3])
e... | code_fim | hard | {
"lang": "python",
"repo": "NescobarAlopLop/miscellaneous",
"path": "/mini_programs/csv_streamer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out = line.encode('utf-8')
print('Sending line', line)
conn.send(out)
def setup_socket(host_address: str, host_port: int) -> socket:
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soc.bind((host_address, host_port))
soc.listen(1)
return soc
def destroy_socket(conn:... | code_fim | medium | {
"lang": "python",
"repo": "NescobarAlopLop/miscellaneous",
"path": "/mini_programs/csv_streamer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def bit_and_i_i_i(a : 'int', b : 'int', c : 'int'):
return a & b & c
def bit_and_b_b_i(a : 'bool', b : 'bool', c : 'int'):
return a & b & c
def invert_b(a : 'bool'):
return ~a
def invert_i(a : 'int'):
return ~a
def or_ints(n : int):
if n & 1 or n < 128:
return 1
e... | code_fim | hard | {
"lang": "python",
"repo": "pyccel/pyccel",
"path": "/tests/epyccel/modules/bitwise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyccel/pyccel path: /tests/epyccel/modules/bitwise.py
# pylint: disable=missing-function-docstring, missing-module-docstring
def right_shift_b_b(a : 'bool', b : 'bool'):
return a >> b
def right_shift_i_i(a : 'int', b : 'int'):
return a >> b
def right_shift_b_i(a : 'bool', b : 'int'):
... | code_fim | hard | {
"lang": "python",
"repo": "pyccel/pyccel",
"path": "/tests/epyccel/modules/bitwise.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return a >> b
def left_shift_i_i(a : 'int', b : 'int'):
return a >> b
def left_shift_b_b(a : 'bool', b : 'bool'):
return a >> b
def bit_xor_b_b(a : 'bool', b : 'bool'):
return a ^ b
def bit_xor_b_b_b(a : 'bool', b : 'bool', c : 'bool'):
return a ^ b ^ c
def bit_xor_i_i(a : 'int', b... | code_fim | medium | {
"lang": "python",
"repo": "pyccel/pyccel",
"path": "/tests/epyccel/modules/bitwise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: XiaotaoChen/resnet.mxnet path: /symbol/simple.py
import mxnet as mx
def conv_bn_relu(data, name, stride=(1,1)):
sym = mx.sym.Convolution(data=data, num_filter=8, kernel=(3, 3), stride=stride, pad=(1, 1),
no_bias=True, name=name + "_conv")
bn1 = mx.sym.Batch... | code_fim | medium | {
"lang": "python",
"repo": "XiaotaoChen/resnet.mxnet",
"path": "/symbol/simple.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = mx.sym.Variable(name='data')
sym = conv_bn_relu(data, name = "stage1", stride=(2,2))
sym = conv_bn_relu(sym, name = "stage2", stride=(2,2))
pool1 = mx.symbol.Pooling(data=sym, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1')
flat = mx.symbol.Flatten(data=pool1)
... | code_fim | medium | {
"lang": "python",
"repo": "XiaotaoChen/resnet.mxnet",
"path": "/symbol/simple.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gkovaig/i2FHIRb2 path: /i2fhirb2/i2b2model/metadata/i2b2ontologyvisualattributes.py
# Copyright (c) 2017, Mayo Clinic
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# Red... | code_fim | medium | {
"lang": "python",
"repo": "gkovaig/i2FHIRb2",
"path": "/i2fhirb2/i2b2model/metadata/i2b2ontologyvisualattributes.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> char3 = string_value[2] if len(cast(Sized, string_value)) == 3 else ' '
assert (char3 in " E")
self.editable = char3 == 'E'
else:
self.leaf = False # C
self.approximate = False # Leaf only - multiple targets
self.... | code_fim | hard | {
"lang": "python",
"repo": "gkovaig/i2FHIRb2",
"path": "/i2fhirb2/i2b2model/metadata/i2b2ontologyvisualattributes.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># x = [1, 2, 3, 4, 5]
# y = iter(x)
#
# print(y.__next__())
# print(y.__next__())
# print(y.__next__())
# class MyRange:
#
# def __init__(self, *args):
# if len(args) == 3:
# self.start = args[0]
# self.end = args[1]
# self.step = args[2]
# elif len... | code_fim | hard | {
"lang": "python",
"repo": "pavanmaradia/202102-Python-Django-Training",
"path": "/sessions/session_13.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pavanmaradia/202102-Python-Django-Training path: /sessions/session_13.py
"""
Create class Property
Override default class methods
Iterators
"""
# class Employee(object):
#
# def __init__(self, **kwargs):
# self.first_name = kwargs.get('first_name', "")
# self.last_name = kwa... | code_fim | hard | {
"lang": "python",
"repo": "pavanmaradia/202102-Python-Django-Training",
"path": "/sessions/session_13.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Joseamica/Easily-written-Django path: /day4/articles/urls.py
from django.conf.urls import patterns, include, url
from articles.views import HelloTemplate
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'day4.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
... | code_fim | medium | {
"lang": "python",
"repo": "Joseamica/Easily-written-Django",
"path": "/day4/articles/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> url(r'^$', 'articles.views.articles'),
url(r'^all/$', 'articles.views.articles', name='all'),
url(r'^get/(?P<article_id>\d+)/$', 'articles.views.article', name='get'),
url(r'^language/(?P<language>[a-z\-]+)/$', 'articles.views.language', name='language'),
url(r'^hello/', 'articles.vi... | code_fim | medium | {
"lang": "python",
"repo": "Joseamica/Easily-written-Django",
"path": "/day4/articles/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
new_list = [i.strip() for i in text.splitlines() if i.strip() != ""]
new_dict = {}
col_name = new_list[0].strip().split()
index_name = new_list[1].strip()
for item in new_list[2:]:
index, *others = item.split()
others = [float(i) for i in others]
new_dic... | code_fim | hard | {
"lang": "python",
"repo": "rayjustinhuang/DataAnalysisandMachineLearning",
"path": "/RJ's Toolbox/Custom_Functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
new_df : DataFrame
A pandas DataFrame object.
"""
new_list = [i.strip() for i in text.splitlines() if i.strip() != ""]
new_dict = {}
col_name = new_list[0].strip().split()
index_name = new_list[1].strip()
for item in new_list[2:]:
index,... | code_fim | hard | {
"lang": "python",
"repo": "rayjustinhuang/DataAnalysisandMachineLearning",
"path": "/RJ's Toolbox/Custom_Functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rayjustinhuang/DataAnalysisandMachineLearning path: /RJ's Toolbox/Custom_Functions.py
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 2 12:11:41 2021
@author: rjlo_
"""
# Custom Functions
import pandas as pd
# convert_text_to_df
# Used to convert printed DataFrame output text to an actual Data... | code_fim | medium | {
"lang": "python",
"repo": "rayjustinhuang/DataAnalysisandMachineLearning",
"path": "/RJ's Toolbox/Custom_Functions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_random():
n_observations = 60
n_features = 5
data = np.random.uniform(size=(n_observations, n_features))
print(data.shape)
forest = RCForest(random_state=42)
scores = forest.insert_batch(data)
assert scores.shape == (n_observations,)
assert scores[0] == 0.
ass... | code_fim | hard | {
"lang": "python",
"repo": "josteinbf/rrcforest",
"path": "/tests/test_rcforest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josteinbf/rrcforest path: /tests/test_rcforest.py
import numpy as np
from rrcforest import RCForest
def test_constants():
n_observations = 300
n_features = 4
data = np.ones(shape=(n_observations, n_features), dtype=float)
data *= 3.1415
<|fim_suffix|> assert scores.shape ==... | code_fim | hard | {
"lang": "python",
"repo": "josteinbf/rrcforest",
"path": "/tests/test_rcforest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # launch the experiments on the local machine
processes = []
for seed in range(num_seeds):
seed_variant = deepcopy(variant)
seed_variant["logging_dir"] += "{}/".format(seed)
processes.append(
m.Process(
target=baseline,
args=(... | code_fim | hard | {
"lang": "python",
"repo": "brandontrabucco/playground",
"path": "/playground/launch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brandontrabucco/playground path: /playground/launch.py
"""Author: Brandon Trabucco, Copyright 2019, MIT License"""
from playground import maybe_initialize_process
from copy import deepcopy
import multiprocessing as m
<|fim_suffix|> baseline,
variant,
env_class,
env_kwargs=None,
... | code_fim | medium | {
"lang": "python",
"repo": "brandontrabucco/playground",
"path": "/playground/launch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jonatas-Soares-Alves/Exercicios-do-Curso-de-Python path: /MUNDO 2/Exercícios/Exercício 71 (vi15).py
print('=' * 40)
print('{:^40}'.format('BANCO CEV'))
print('=' * 40)
dinheiro = float(input('Quanto quer sacar? R$'))
n50 = 0
n20 = 0
n10 = 0
n1 = 0
while True:
if dinheiro >= 50:
n50 +=... | code_fim | medium | {
"lang": "python",
"repo": "Jonatas-Soares-Alves/Exercicios-do-Curso-de-Python",
"path": "/MUNDO 2/Exercícios/Exercício 71 (vi15).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif 20 > dinheiro >= 10:
n10 += 1
dinheiro -= 10
elif 10 > dinheiro >= 1:
n1 += 1
dinheiro -= 1
else:
break
if n50 > 0:
print(f'Total de {n50} cédulas de R$50')
if n20 > 0:
print(f'Total de {n20} cédulas de R$20')
if n10 > 0:
print(f'Tota... | code_fim | medium | {
"lang": "python",
"repo": "Jonatas-Soares-Alves/Exercicios-do-Curso-de-Python",
"path": "/MUNDO 2/Exercícios/Exercício 71 (vi15).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.