text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """SMPP Client Connector manager logics"""
managerName = 'smppcc'
def persist(self, arg, opts):
if self.pb['smppcm'].perspective_persist(opts.profile):
self.protocol.sendData(
'%s configuration persisted (profile:%s)' % (self.managerName, opts.profile), pro... | code_fim | hard | {
"lang": "python",
"repo": "jookies/jasmin",
"path": "/jasmin/protocols/cli/smppccm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.startSession(
self.update_session,
annoucement='Updating connector id [%s]: (ok: save, ko: exit)' % opts.update,
completitions=list(SMPPClientConfigKeyMap),
sessionContext={'cid': opts.update})
@ConnectorExist(cid_key='remove')
@... | code_fim | hard | {
"lang": "python",
"repo": "jookies/jasmin",
"path": "/jasmin/protocols/cli/smppccm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jookies/jasmin path: /jasmin/protocols/cli/smppccm.py
import pickle
import logging
from enum import Enum
from twisted.internet import defer, reactor
from jasmin.protocols.cli.managers import PersistableManager, Session
from jasmin.protocols.cli.protocol import str2num
from jasmin.protocols.smpp... | code_fim | hard | {
"lang": "python",
"repo": "jookies/jasmin",
"path": "/jasmin/protocols/cli/smppccm.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiaburroGiuseppe/Hands-On-Simulation-Modeling-with-Python path: /Chapter07/Newton-Raphson.py
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,3,100)
y=x**3 -2*x**2 -x + 2
fig = plt.figure()
axdef = fig.add_subplot(1, 1, 1)
axdef.spines['left'].set_position('center')
... | code_fim | medium | {
"lang": "python",
"repo": "CiaburroGiuseppe/Hands-On-Simulation-Modeling-with-Python",
"path": "/Chapter07/Newton-Raphson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ActualX = 3
PrecisionValue = 0.000001
PreviousStepSize = 1
MaxIteration = 10000
IterationCounter = 0
while PreviousStepSize > PrecisionValue and IterationCounter < MaxIteration:
PreviousX = ActualX
ActualX = ActualX - FirstDerivative(PreviousX)/ SecondDerivative(PreviousX)
Pre... | code_fim | medium | {
"lang": "python",
"repo": "CiaburroGiuseppe/Hands-On-Simulation-Modeling-with-Python",
"path": "/Chapter07/Newton-Raphson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flytian/python_machinelearning path: /Chapter_2_diy/Chapter_2_1_2_diy.py
# coding:utf-8
# 从sklearn.datasets导入波士顿房价数据读取器。
from sklearn.datasets import load_boston
# 导入numpy并重命名为np。
import numpy as np
def get_boston():
boston = load_boston()
# 输出数据描述。
print boston.DESCR
X = bosto... | code_fim | hard | {
"lang": "python",
"repo": "flytian/python_machinelearning",
"path": "/Chapter_2_diy/Chapter_2_1_2_diy.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># 从sklearn.neighbors导入KNeighborRegressor(K近邻回归器)。
from sklearn.neighbors import KNeighborsRegressor
# 使得预测的方式为平均回归:weights='uniform'。
# 使得预测的方式为根据距离加权回归:weights='distance'。
def classfication_KNR(X_train, y_train, X_test, y_test, ss_y, weights):
# 初始化K近邻回归器,并且调整配置
knr = KNeighborsRegressor(weight... | code_fim | hard | {
"lang": "python",
"repo": "flytian/python_machinelearning",
"path": "/Chapter_2_diy/Chapter_2_1_2_diy.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# 从sklearn.ensemble中导入RandomForestRegressor、ExtraTreesGressor以及GradientBoostingRegressor。
from sklearn.ensemble import RandomForestRegressor, ExtraTreesRegressor, GradientBoostingRegressor
def classfication_RFR(X_train, y_train, X_test, y_test, ss_y):
# 使用RandomForestRegressor训练模型,并对测试数据做出预测,结果存储在变... | code_fim | hard | {
"lang": "python",
"repo": "flytian/python_machinelearning",
"path": "/Chapter_2_diy/Chapter_2_1_2_diy.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhengcongreal/meiduo_project path: /meiduo_mall/apps/meiduo_admin/views/specs.py
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from apps.goods.models import SPUSpecification, SpecificationOption
from apps.meiduo_admin.serializers.specs import SP... | code_fim | medium | {
"lang": "python",
"repo": "zhengcongreal/meiduo_project",
"path": "/meiduo_mall/apps/meiduo_admin/views/specs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class SPUSpecListView(ListAPIView):
serializer_class = SPUSpecSerializer
queryset =SPUSpecification.objects.all()<|fim_prefix|># repo: zhengcongreal/meiduo_project path: /meiduo_mall/apps/meiduo_admin/views/specs.py
from rest_framework.generics import ListAPIView
from rest_framework.viewsets impo... | code_fim | hard | {
"lang": "python",
"repo": "zhengcongreal/meiduo_project",
"path": "/meiduo_mall/apps/meiduo_admin/views/specs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: truongnmt/DeepECG path: /predict.py
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import sys
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
from functools import partial
import numpy as np
import tensorflow as tf
import cardio.dataset as ds
from cardio import EcgDataset
from cardio.d... | code_fim | hard | {
"lang": "python",
"repo": "truongnmt/DeepECG",
"path": "/predict.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>predict_eds = EcgDataset(path=signal_path, no_ext=True, sort=True)
predict_ppl = (predict_eds >> template_predict_ppl).run()
print(str(predict_ppl.get_variable("predictions_list")[0]).replace("'", "\""))<|fim_prefix|># repo: truongnmt/DeepECG path: /predict.py
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'... | code_fim | hard | {
"lang": "python",
"repo": "truongnmt/DeepECG",
"path": "/predict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nishitpatel01/Data-Science-Toolbox path: /algorithm/DFS/302_Smallest_Rectangle_Enclosing_Black_Pixels.py
class Solution(object):
def __init__(self):
self.top = None
self.bottom = None
self.left = None
self.right = None
def minArea(self, image, x, y):
<|fi... | code_fim | hard | {
"lang": "python",
"repo": "nishitpatel01/Data-Science-Toolbox",
"path": "/algorithm/DFS/302_Smallest_Rectangle_Enclosing_Black_Pixels.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.top = x
self.bottom = x
self.left = y
self.right = y
def dfs(image, x, y):
if x < 0 or y < 0 or x >= len(image) or y >= len(image[0]) or image[x][y] == '0':
return
image[x][y] = '0'
self.top = min(self.top, ... | code_fim | hard | {
"lang": "python",
"repo": "nishitpatel01/Data-Science-Toolbox",
"path": "/algorithm/DFS/302_Smallest_Rectangle_Enclosing_Black_Pixels.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dfs(image, x + 1, y)
dfs(image, x - 1, y)
dfs(image, x, y - 1)
dfs(image, x, y + 1)
dfs(image, x, y)
return (self.right - self.left) * (self.bottom - self.top)<|fim_prefix|># repo: nishitpatel01/Data-Science-Toolbox path: /algorithm/DFS/30... | code_fim | hard | {
"lang": "python",
"repo": "nishitpatel01/Data-Science-Toolbox",
"path": "/algorithm/DFS/302_Smallest_Rectangle_Enclosing_Black_Pixels.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # *Making a row of the csv
row = {'Class': vert_class, 'ID': id, 'Gene Sequence': geneseq}
# *Appending to the final dataset
dataset.append(row)
# *Creating the csv in the 'interim' folder under 'data'
with open('../../data/interim/dataset.csv', 'w') as csvfile:
write... | code_fim | hard | {
"lang": "python",
"repo": "gourav-saha/gene-to-signal",
"path": "/src/data/make_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gourav-saha/gene-to-signal path: /src/data/make_dataset.py
# !Script to make a csv dataset to feed into the spectrogram from the ML-DSP dataset from DOI: <https://doi.org/10.1186/s12864-019-5571-y>
# *Import packages
import glob
import os
import csv
# *Making a list of the folders
classes = os.... | code_fim | hard | {
"lang": "python",
"repo": "gourav-saha/gene-to-signal",
"path": "/src/data/make_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucaspedroni/stk path: /stk/calculators/energy/macromodel.py
from uuid import uuid4
import os
import subprocess as sp
from ...utilities import move_generated_macromodel_files
from .energy_calculators import EnergyCalculator, EnergyError
class MacroModelEnergy(EnergyCalculator):
"""
Cal... | code_fim | hard | {
"lang": "python",
"repo": "lucaspedroni/stk",
"path": "/stk/calculators/energy/macromodel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output_dir : :class:`str`, optional
The name of the directory into which files generated during
the optimization are written, if ``None`` then
:func:`uuid.uuid4` is used.
force_field : :class:`int`, optional
The number of the force field to ... | code_fim | hard | {
"lang": "python",
"repo": "lucaspedroni/stk",
"path": "/stk/calculators/energy/macromodel.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jometho/crowdsource-reporter-scripts path: /GenerateIds/calculateids.py
# ------------------------------------------------------------------------------
# Name: calculateids.py
# Purpose: generates identifiers for features
# Copyright 2016 Esri
# Licensed under the Apache License, ... | code_fim | hard | {
"lang": "python",
"repo": "jometho/crowdsource-reporter-scripts",
"path": "/GenerateIds/calculateids.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate a new id value from a string and the current id value
row[0] = seq_format.format(sequence_value)
try:
fcrows.updateRow(row)
except RuntimeError:
return 'error: The value type is incompatible with the field type.... | code_fim | hard | {
"lang": "python",
"repo": "jometho/crowdsource-reporter-scripts",
"path": "/GenerateIds/calculateids.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # find and update all features that need ids
sql = """{} is null""".format(fld)
with arcpy.da.UpdateCursor(data_path, fld, where_clause=sql) as fcrows:
for row in fcrows:
# Calculate a new id value from a string and the current id value
row[0] = seq_format.for... | code_fim | hard | {
"lang": "python",
"repo": "jometho/crowdsource-reporter-scripts",
"path": "/GenerateIds/calculateids.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Char.query.delete()
for char in char_list:
new_char = Char(char["char_name"], char["last_update"], char["char_class"], char["item_level"], char["guild"])
db.session.add(new_char)
new_row_count = Char.query.count()
i... | code_fim | hard | {
"lang": "python",
"repo": "pskfry/wowrecruitapi",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if user_verified:
access_token = create_access_token(identity = req["user_name"])
res_body = {"access_token": access_token}
return Response(response=json.dumps(res_body), mimetype="application/json", status=201)
else:
retur... | code_fim | hard | {
"lang": "python",
"repo": "pskfry/wowrecruitapi",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pskfry/wowrecruitapi path: /app.py
import os
import sys
import json
from flask_sqlalchemy import SQLAlchemy
from flask import (jsonify, request, Response, abort, Flask, render_template)
from sqlalchemy import inspect
from flask_jwt_extended import (JWTManager, create_access_token, jwt_requi... | code_fim | hard | {
"lang": "python",
"repo": "pskfry/wowrecruitapi",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # we are ready to create the check
# open the template and perform the conversions
with open("./template_permissions", 'r') as templatefile:
# replace the placeholders within the template with the actual values
filestring = templatefile.read()
filestring = filestring.replace("FILEID", path_id)
... | code_fim | hard | {
"lang": "python",
"repo": "Feehley/apache-webserver",
"path": "/packages/scap-security-guide/scap-security-guide/RHEL6/input/checks/templates/create_permission_checks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Feehley/apache-webserver path: /packages/scap-security-guide/scap-security-guide/RHEL6/input/checks/templates/create_permission_checks.py
#!/usr/bin/python
#
# create_permission_checks.py
# generate template-based checks for file permissions/ownership
#
# NOTE: The file 'template_permissions' sh... | code_fim | hard | {
"lang": "python",
"repo": "Feehley/apache-webserver",
"path": "/packages/scap-security-guide/scap-security-guide/RHEL6/input/checks/templates/create_permission_checks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> config['dimensions'] = list(chart.chartdimension_set.values())
# XXX
for dim in config['dimensions']:
dim['chartId'] = dim.pop('chartId_id')
dim['variableId'] = dim.pop('variableId_id')
chart.config = json.dumps(config)
... | code_fim | hard | {
"lang": "python",
"repo": "owid/owid-importer",
"path": "/grapher_admin/migrations/0022_map_type_standardization_20171128_1432.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: owid/owid-importer path: /grapher_admin/migrations/0022_map_type_standardization_20171128_1432.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-11-28 14:32
from __future__ import unicode_literals
from django.db import migrations, models, transaction, connection
import json
def canFl... | code_fim | hard | {
"lang": "python",
"repo": "owid/owid-importer",
"path": "/grapher_admin/migrations/0022_map_type_standardization_20171128_1432.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
enc = encoders.OrdinalEncoder(verbose=1, return_df=True, impute_missing=True)
enc.fit(X)
out = enc.transform(X_t)
self.assertEqual(len(set(out['extra'].values)), 4)
self.assertIn(0, set(out['extra'].values))
self.assertFalse(enc.mapping is None)
sel... | code_fim | medium | {
"lang": "python",
"repo": "JohnnyC08/categorical-encoding",
"path": "/category_encoders/tests/test_ordinal.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> enc = encoders.OrdinalEncoder()
out = enc.fit_transform(X)
tu.verify_numeric(out)
self.assertEqual(3, out['Categorical'][0])
self.assertEqual(3, out['Categorical'][1])
self.assertEqual(1, out['Categorical'][2])
self.assertEqual(2, out['Categorical']... | code_fim | hard | {
"lang": "python",
"repo": "JohnnyC08/categorical-encoding",
"path": "/category_encoders/tests/test_ordinal.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JohnnyC08/categorical-encoding path: /category_encoders/tests/test_ordinal.py
import pandas as pd
from unittest2 import TestCase # or `from unittest import ...` if on Python 3.4+
import category_encoders.tests.test_utils as tu
import numpy as np
import category_encoders as encoders
np_X = tu.... | code_fim | hard | {
"lang": "python",
"repo": "JohnnyC08/categorical-encoding",
"path": "/category_encoders/tests/test_ordinal.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># @njit
# def set_to_value_in_box(image, min_x, max_x, min_y, max_y, width, height, value=30.0):
# for x in range(width):
# for y in range(height):
# if min_x <= x < max_x and min_y <= y < max_y:
# image[y, x, 0] = value
# image[y, x, 1] = 0.#0.#11116473
# image[y, x, 2] = 0.#0.#02320262... | code_fim | hard | {
"lang": "python",
"repo": "timtyree/care",
"path": "/notebooks/lib/controller/draw.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timtyree/care path: /notebooks/lib/controller/draw.py
from numba import njit
from numba.typed import List
import numpy as np
from ..utils.stack_txt_LR import *
# @njit
def get_semicircle(txt,deg,x0,y0):
#make the initialization mesh
img = 0*txt[...,0].copy()
color_left_of_line(out=im... | code_fim | hard | {
"lang": "python",
"repo": "timtyree/care",
"path": "/notebooks/lib/controller/draw.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def initialize_mesh(width,height,channel_no, value, zero=None):
'''create initialization buffer for the standard.
let the ring propagate out until tissue in the center
is excitable before exploring initial trajectories based
on the width of rectangular perturbations.'''
if zero is None:
zero = np.z... | code_fim | hard | {
"lang": "python",
"repo": "timtyree/care",
"path": "/notebooks/lib/controller/draw.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Aggiunge un bordo bianco in alto e a destra fino a raggiungere
le width e height desiderate
"""
top = max(0, height)
right = max(0, width)
result = np.full((top, right), 255)
result[result.shape[0]-img.shape[0]:result.shape[0],:img.shape[1]] = img
... | code_fim | medium | {
"lang": "python",
"repo": "Kidel/In-Codice-Ratio-OCR-with-CNN",
"path": "/Notebooks/image_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kidel/In-Codice-Ratio-OCR-with-CNN path: /Notebooks/image_utils.py
from PIL import Image
import numpy as np
WIDTH=34
HEIGHT=56
# Simply loads an image without invert, crop or padding
def load_sample(filepath, return_size=False):
im = Image.open(filepath).convert('L')
(width, height) = i... | code_fim | hard | {
"lang": "python",
"repo": "Kidel/In-Codice-Ratio-OCR-with-CNN",
"path": "/Notebooks/image_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: e-kolpakov/study-model path: /model/agents/student/behaviors/student_interaction.py
import random
from model.agents.student.messages import FactMessage, ResourceMessageAsync
__author__ = 'e.kolpakov'
class BaseSendMessagesBehavior:
def __init__(self):
pass
@staticmethod
d... | code_fim | hard | {
"lang": "python",
"repo": "e-kolpakov/study-model",
"path": "/model/agents/student/behaviors/student_interaction.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:param Student from_student: student sending messages
:param Student to_student: recipient student
:param kwargs: keyword arguments
:rtype: itertools.Iterable[BaseMessage]
"""
if from_student.knowledge:
fact = random.sample(from_stude... | code_fim | hard | {
"lang": "python",
"repo": "e-kolpakov/study-model",
"path": "/model/agents/student/behaviors/student_interaction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shycoldii/agario path: /game/menu.py
import pygame
from game.button import *
from game.state import GameState
from game.map import Map
from display import Display
class Menu:
can_quit = None
can_play = None
first_try = None
mouse_pos = None
buttons = None
state = None
... | code_fim | hard | {
"lang": "python",
"repo": "shycoldii/agario",
"path": "/game/menu.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Меню-победы"""
cls.buttons.append(Button(pos=vector(width / 4, height / 5),
size=vector(width / 2, height / 10),
text="Победа !",
display=button_win,
i... | code_fim | hard | {
"lang": "python",
"repo": "shycoldii/agario",
"path": "/game/menu.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ali1rathore/python-object-extractor path: /python_object_extractor/inspection.py
import symtable
from types import ModuleType
from typing import Dict, List
from python_object_extractor.descriptors import ObjectDescriptor
from python_object_extractor.graph import sort_descriptors_topologically
f... | code_fim | hard | {
"lang": "python",
"repo": "ali1rathore/python-object-extractor",
"path": "/python_object_extractor/inspection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _inspect_object_with_children(
object_reference: ObjectReference,
known_objects: Dict[ObjectReference, ObjectDescriptor],
project_path: str,
) -> None:
if object_reference in known_objects:
return
descriptor = inspect_object(
project_path=project_path,
obje... | code_fim | hard | {
"lang": "python",
"repo": "ali1rathore/python-object-extractor",
"path": "/python_object_extractor/inspection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> aliases_to_imports = {
alias: ObjectImport(references[0], alias)
for alias, references in aliases_to_references_groupped.items()
}
object_imports = list()
for symbol in symbols:
key = symbol.get_name()
item = aliases_to_imports.get(key)
is_sibling... | code_fim | hard | {
"lang": "python",
"repo": "ali1rathore/python-object-extractor",
"path": "/python_object_extractor/inspection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
This function is used to gather LLDP data from a Juniper network device.
dev = Juniper device connection
return = Returns the LLDP neighbor table
"""
try:
globals().update(loadyaml('yaml/lldp_neighbor.yml'))
lldp_ni = lldp_neighbor_info(dev).get()
ret... | code_fim | medium | {
"lang": "python",
"repo": "sincere32/junos-pyez-example",
"path": "/lib/jlldp/jlldpneighbor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sincere32/junos-pyez-example path: /lib/jlldp/jlldpneighbor.py
"""
Query LLDP data from a Juniper network device.
"""
import sys
from jnpr.junos import Device
from jnpr.junos.factory import loadyaml
def juniper_lldp_neighbor(dev):
<|fim_suffix|> except Exception as err:
print(err)
... | code_fim | hard | {
"lang": "python",
"repo": "sincere32/junos-pyez-example",
"path": "/lib/jlldp/jlldpneighbor.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> except Exception as err:
print(err)
dev.close()
sys.exit(1)
return
return<|fim_prefix|># repo: sincere32/junos-pyez-example path: /lib/jlldp/jlldpneighbor.py
"""
Query LLDP data from a Juniper network device.
"""
import sys
from jnpr.junos import Device
from jnpr... | code_fim | hard | {
"lang": "python",
"repo": "sincere32/junos-pyez-example",
"path": "/lib/jlldp/jlldpneighbor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smenjas/socratica path: /sorting/planets.py
"""
format := (name, radius, density, distance from sun)
Radius: Radius at equator in kilometers
Density: Average density in g/cm^3
Distance from Sun: Avg. distance to sun in AUs
<|fim_suffix|># The planets sorted by distance from the Sun, ascending.
... | code_fim | medium | {
"lang": "python",
"repo": "smenjas/socratica",
"path": "/sorting/planets.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|># Now let's find the least dense planet.
size = lambda planet: planet[2]
planets.sort(key=size, reverse=False)
#print(planets) # Saturn, Uranus, Jupiter, Neptune, Mars, Venus, Mercury, Earth
# list.sort() changes the list
# Q: Can you create a sorted copy?
# Q: How do you sort a tuple?
# A: Use sorted()
... | code_fim | hard | {
"lang": "python",
"repo": "smenjas/socratica",
"path": "/sorting/planets.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>def signature(timestamp, path, secret):
to_sign = timestamp + '\n' + path
hmac_code = hmac.new(secret.encode(), to_sign.encode(), sha1).digest()
return base64.b64encode(hmac_code).decode()<|fim_prefix|># repo: HandleKun/pyapollo path: /pyapollo/signature.py
import base64
import hmac
from hash... | code_fim | easy | {
"lang": "python",
"repo": "HandleKun/pyapollo",
"path": "/pyapollo/signature.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HandleKun/pyapollo path: /pyapollo/signature.py
import base64
import hmac
from hashlib import sha1
def authorization(appid, sign):
<|fim_suffix|>def signature(timestamp, path, secret):
to_sign = timestamp + '\n' + path
hmac_code = hmac.new(secret.encode(), to_sign.encode(), sha1).digest(... | code_fim | easy | {
"lang": "python",
"repo": "HandleKun/pyapollo",
"path": "/pyapollo/signature.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 'Apollo {}:{}'.format(appid, sign)
def signature(timestamp, path, secret):
to_sign = timestamp + '\n' + path
hmac_code = hmac.new(secret.encode(), to_sign.encode(), sha1).digest()
return base64.b64encode(hmac_code).decode()<|fim_prefix|># repo: HandleKun/pyapollo path: /pyapollo/s... | code_fim | easy | {
"lang": "python",
"repo": "HandleKun/pyapollo",
"path": "/pyapollo/signature.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj = cls(
l1=raritan.rpc.powerlogic.PowerMeter.MinMaxReading.decode(
json["l1"], agent
),
l2=raritan.rpc.powerlogic.PowerMeter.MinMaxReading.decode(
json["l2"], agent
),
l3=... | code_fim | hard | {
"lang": "python",
"repo": "rsp2k/raritan-pdu-json-rpc",
"path": "/raritan/rpc/powerlogic/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rsp2k/raritan-pdu-json-rpc path: /raritan/rpc/powerlogic/__init__.py
ChangedEvent, self).__init__(
actUserName, actIpAddr, source
)
typecheck.is_struct(
oldSettings, raritan.rpc.powerlogic.Config.Settings, AssertionError
)
... | code_fim | hard | {
"lang": "python",
"repo": "rsp2k/raritan-pdu-json-rpc",
"path": "/raritan/rpc/powerlogic/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> json = {}
json["current"] = raritan.rpc.powerlogic.PowerMeter.L2N_N_Avg.encode(
self.current
)
json["voltageL2L"] = raritan.rpc.powerlogic.PowerMeter.L2L_Avg.encode(
self.voltageL2L
)
json["voltageL2N"]... | code_fim | hard | {
"lang": "python",
"repo": "rsp2k/raritan-pdu-json-rpc",
"path": "/raritan/rpc/powerlogic/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AASHE/iss path: /iss/management/commands/upsert_iss_organizations.py
#!/usr/bin/env python
"""Upserts Organization records with data from Salesforce Accounts.
"""
import logging
import os
from django.core.management.base import BaseCommand
import iss.models
import iss.membersuite
import iss.uti... | code_fim | hard | {
"lang": "python",
"repo": "AASHE/iss",
"path": "/iss/management/commands/upsert_iss_organizations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def handle(self, *args, **options):
upsert_organizations_for_recently_modified_accounts(
since=options['m'],
include_aashe_in_website=options['i'],
get_all=options['a'],
)
def upsert_organizations_for_recently_modified_accounts(
since=7, in... | code_fim | hard | {
"lang": "python",
"repo": "AASHE/iss",
"path": "/iss/management/commands/upsert_iss_organizations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--all',
action='store_true',
default=False,
dest='a',
help='upsert all organizations'
)
parser.add_argument(
'-m', '--mod... | code_fim | medium | {
"lang": "python",
"repo": "AASHE/iss",
"path": "/iss/management/commands/upsert_iss_organizations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # page_total_actions : 페이지 행동
# page_views_total : 페이지 조회
# page_fan_adds : 페이지 좋아요
# page_impressions_organic : 게시물 도달
# page_post_engagement : 게시물 참여
# page_video_views : 동영상 조회
'''
if self.fb_metric == 'page_total_actions':
... | code_fim | hard | {
"lang": "python",
"repo": "YooInKeun/Facebook-Page-Insights-Web-Crawler",
"path": "/Web Application(DB Insert)/parsed_data/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YooInKeun/Facebook-Page-Insights-Web-Crawler path: /Web Application(DB Insert)/parsed_data/models.py
from django.db import models
class fb_insight(models.Model):
fb_page = models.CharField(max_length=200)
fb_metric = models.CharField(max_length=100)
fb_value = models.CharField... | code_fim | hard | {
"lang": "python",
"repo": "YooInKeun/Facebook-Page-Insights-Web-Crawler",
"path": "/Web Application(DB Insert)/parsed_data/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> type = 'object'
properties = {
'answer': {
'type': 'string'
}
}<|fim_prefix|># repo: Yogev911/sms-service path: /resources/common_modles.py
from flask_restful_swagger_2 import Schema
class UserModel(Schema):
type = 'object'
properties = {
'user': ... | code_fim | hard | {
"lang": "python",
"repo": "Yogev911/sms-service",
"path": "/resources/common_modles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yogev911/sms-service path: /resources/common_modles.py
from flask_restful_swagger_2 import Schema
class UserModel(Schema):
<|fim_suffix|>class Puzzle(Schema):
type = 'object'
properties = {
'answer': {
'type': 'string'
}
}<|fim_middle|> type = 'object'... | code_fim | hard | {
"lang": "python",
"repo": "Yogev911/sms-service",
"path": "/resources/common_modles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#directory to save weights file
CHECKPOINT_PATH = 'checkpoint'
#total training epoches
EPOCH = 20
MILESTONES = list((np.array(range(6))+1)*5)
#initial learning rate
#INIT_LR = 0.1
#time of we run the script
TIME_NOW = datetime.now().isoformat()
#tensorboard log dir
LOG_DIR = 'runs'
#save weights file... | code_fim | hard | {
"lang": "python",
"repo": "david-villagra/Academic-Faster-RCNN",
"path": "/conf/global_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#save weights file per SAVE_EPOCH epoch
SAVE_EPOCH = 3
DATA_PATH = currentDirectory+'/cifar-100-python'
WEIGHT_PATH = currentDirectory+'/results/weights'
OUTDIR = currentDirectory+'/results'
SAVE_WEIGHTS = False
USE_ZFNET = 0
ACT = 'relu' # set manually to 'lrelu'
OPTIM = 'sgd'
LOSS = 'cel' # cross ... | code_fim | hard | {
"lang": "python",
"repo": "david-villagra/Academic-Faster-RCNN",
"path": "/conf/global_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: david-villagra/Academic-Faster-RCNN path: /conf/global_settings.py
import os
from datetime import datetime
import numpy as np
currentDirectory = os.getcwd()
IMDB_PATH = '/home/tobias/PycharmProjects/Data/images/training' # Kitti data
LABEL_PATH = '/home/tobias/PycharmProjects/Data/label' ... | code_fim | hard | {
"lang": "python",
"repo": "david-villagra/Academic-Faster-RCNN",
"path": "/conf/global_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tmanabe/PairwisePreferenceMultileave path: /utils/datasetcollections.py
# -*- coding: utf-8 -*-
import sys
import os
import random
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from utils.dataset import DataSet
def get_datasets(sim_args):
"""
Function for retrieving da... | code_fim | hard | {
"lang": "python",
"repo": "tmanabe/PairwisePreferenceMultileave",
"path": "/utils/datasetcollections.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DATASET_COLLECTION['MQ2008'] = DataSet('MQ2008', PREFIX + '/MQ2008/Fold*/',
'short', True, 46,
multileave_feat=[
range(11,16), #TF-IDF
... | code_fim | hard | {
"lang": "python",
"repo": "tmanabe/PairwisePreferenceMultileave",
"path": "/utils/datasetcollections.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for f, m in validators:
if not f():
ctx['error'] = m
return False
if required and not value:
ctx['error'] = _('{caption} field is required')
return False
ctx['error'] = ''
return True<|fim_prefix|># repo: TheSpitefulOctopus/pantra path: /com... | code_fim | medium | {
"lang": "python",
"repo": "TheSpitefulOctopus/pantra",
"path": "/components/Forms/inputs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheSpitefulOctopus/pantra path: /components/Forms/inputs.py
from pantra.ctx import *
caption: str = ''
required: bool = False
value: str = ''
error: str = ''
readonly: bool = False
validators = []
def validate(func, message):
<|fim_suffix|> for f, m in validators:
if not f():
... | code_fim | easy | {
"lang": "python",
"repo": "TheSpitefulOctopus/pantra",
"path": "/components/Forms/inputs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GabrielMarquesss/Exercicios-Python path: /ex006.py
#Programa que leia um número e mostre o seu dobro, triplo e raiz quadrada
<|fim_suffix|>print('O dobro de {} é {}, seu triplo é {} e sua raiz quadrada é {}'.format(n,n*2,n*3,n**1/2))<|fim_middle|>n = int(input('Digite um número: '))
| code_fim | easy | {
"lang": "python",
"repo": "GabrielMarquesss/Exercicios-Python",
"path": "/ex006.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('O dobro de {} é {}, seu triplo é {} e sua raiz quadrada é {}'.format(n,n*2,n*3,n**1/2))<|fim_prefix|># repo: GabrielMarquesss/Exercicios-Python path: /ex006.py
#Programa que leia um número e mostre o seu dobro, triplo e raiz quadrada
<|fim_middle|>n = int(input('Digite um número: '))
| code_fim | easy | {
"lang": "python",
"repo": "GabrielMarquesss/Exercicios-Python",
"path": "/ex006.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brentyi/sphinx-autoapi path: /tests/test_objects.py
# coding=utf8
"""Test .NET autoapi objects"""
import os
import unittest
from collections import namedtuple
import mock
from jinja2 import Environment, FileSystemLoader
from autoapi.mappers import dotnet
from autoapi.mappers import python
fro... | code_fim | hard | {
"lang": "python",
"repo": "brentyi/sphinx-autoapi",
"path": "/tests/test_objects.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_rendered_class_escaping(self):
"""Rendered class escaping"""
jinja_env = Environment(loader=FileSystemLoader([TEMPLATE_DIR]))
cls = dotnet.DotNetClass(
{"id": "Foo.Bar`1", "inheritance": ["Foo.Baz`1"]},
jinja_env=jinja_env,
app=mock.... | code_fim | hard | {
"lang": "python",
"repo": "brentyi/sphinx-autoapi",
"path": "/tests/test_objects.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ExtendedLoginForm(LoginForm):
""" Extend the Flask-Security registration form
Makes email optional and adds a Name
"""
name = TextField('Name OR Email', validators=[required()])
def validate(self):
name = self.name.data
self.name.errors = [] #not sure why er... | code_fim | hard | {
"lang": "python",
"repo": "joehand/DataNews",
"path": "/data_news/user/forms.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joehand/DataNews path: /data_news/user/forms.py
from .models import User
from ..utils import NAME_LEN_MIN, NAME_LEN_MAX, ILLEGAL_NAMES
from flask.ext.wtf import Form
from flask.ext.wtf.html5 import URLField, EmailField
from wtforms import TextField
from wtforms.validators import required, email,... | code_fim | hard | {
"lang": "python",
"repo": "joehand/DataNews",
"path": "/data_news/user/forms.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not NAME_LEN_MIN < len(name) + 1 < NAME_LEN_MAX:
self.name.errors.append('Must be between %s and %s characters'% (NAME_LEN_MIN,NAME_LEN_MAX))
return False
user = User.find_user_by_name(name).first()
if user is not None:
name = User.make_uniq... | code_fim | hard | {
"lang": "python",
"repo": "joehand/DataNews",
"path": "/data_news/user/forms.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch path: /57. random numbers/drawingrandomnumbers.py
"""
Drawing RANDOM numbers
random numbers
random() 0 <= x < 1 lub [0,1)
uniform(2.5, 10.0) 2.5 <= x < 10.0 lub [2.5, 10)
randrange(10) from (0,1,2,3,4,5,6,7,8,9)
... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch",
"path": "/57. random numbers/drawingrandomnumbers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def will_weapon_hit(weaponChanceToHitPercentage):
chanceToHit = random.uniform(0, 100)
if (weaponChanceToHitPercentage > chanceToHit):
return "hit"
else:
return "not hit"
hitList = []
while x < 1000:
x = x + 1
hitList.append(random.randint(0, 10))
from collections im... | code_fim | hard | {
"lang": "python",
"repo": "PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch",
"path": "/57. random numbers/drawingrandomnumbers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>hitList = []
while x < 1000:
x = x + 1
hitList.append(random.randint(0, 10))
from collections import Counter
print(Counter(hitList))<|fim_prefix|># repo: PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch path: /57. random numbers/drawingrandomnumbers.py
"""
Drawing RANDOM numbers
... | code_fim | hard | {
"lang": "python",
"repo": "PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch",
"path": "/57. random numbers/drawingrandomnumbers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dic['TIPO DE REGISTRO'] = [int(arq[nlinha][24:26]) for nlinha in range(1, len(arq)-1)]
dic['DATA DO PREGÃO'] = [(arq[nlinha][2:10]) for nlinha in range(1, len(arq)-1)]
dic['CÓDIGO BDI'] = [(arq[nlinha][10:12]) for nlinha in range(1, len(arq)-1)]
dic['CÓDIGO DE NEGOCIAÇÃO DO PAPEL'] = [(arq[nlinha][12:24])... | code_fim | hard | {
"lang": "python",
"repo": "luizctsilva/Python4Finance",
"path": "/script_cotahist_1_0_0.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luizctsilva/Python4Finance path: /script_cotahist_1_0_0.py
#! python3
#1 Importa Bibliotecas
from sys import exit
import time
import pandas as pd
#2 Conecta, lê e fecha o arquivo -- arquivo = open('demo2.txt', 'r', encoding='UTF-8')
print('SCRIPT DESENVOLVIDO POR LUIZ CLAUDIO TAVARES SILVA\nVE... | code_fim | hard | {
"lang": "python",
"repo": "luizctsilva/Python4Finance",
"path": "/script_cotahist_1_0_0.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
turtle.onkeypress(up_2, W)
turtle.onkeypress(down_2, S)
turtle.onkeypress(left_2, A)
turtle.onkeypress(right_2, D)
def move_truck1():
global pos_list_1
my_pos_1 = truck1.pos()
x_pos_1 = my_pos_1[0]
y_pos_1 = my_pos_1[1]
new_pos_1 = truck1.pos()
new_x_pos_1 = new_pos_1[0]
... | code_fim | hard | {
"lang": "python",
"repo": "noor19-meet/meet2017y1final-proj",
"path": "/Yair.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: noor19-meet/meet2017y1final-proj path: /Yair.py
import turtle
SQUARE_SIZE = 20
pos_list_1 = []
pos_list_2 = []
UP = 0
DOWN = 1
LEFT = 2
RIGHT = 3
UP_ARROW = "Up"
LEFT_ARROW = "Left"
DOWN_ARROW = "Down"
RIGHT_ARROW = "Right"
W = "Up"
A = "Left"
S = "Down"
D = "Right"
direction_1 = UP
direc... | code_fim | hard | {
"lang": "python",
"repo": "noor19-meet/meet2017y1final-proj",
"path": "/Yair.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if direction_2 == RIGHT:
track1.goto(x_pos + SQUARE_SIZE, y_pos)
print("You moved right!")
elif direction_2 == LEFT:
track1.goto(x_pos - SQUARE_SIZE, y_pos)
print('You moved left!')
elif direction_2 == UP:
track1.goto(x_pos, y_pos + SQUARE_SIZE)
... | code_fim | hard | {
"lang": "python",
"repo": "noor19-meet/meet2017y1final-proj",
"path": "/Yair.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mapper = self._get_java_mapper(
job_properties={
"userName": "user",
"oozie.wf.application.path": "hdfs:///user/USER/examples/apps/java",
"mapreduce.map.java.opts": "-Dmapreduce1=val1 -Dmapreduce2=val2",
},
config=... | code_fim | hard | {
"lang": "python",
"repo": "GoogleCloudPlatform/oozie-to-airflow",
"path": "/tests/mappers/test_java_mapper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GoogleCloudPlatform/oozie-to-airflow path: /tests/mappers/test_java_mapper.py
# -*- coding: utf-8 -*-
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the L... | code_fim | hard | {
"lang": "python",
"repo": "GoogleCloudPlatform/oozie-to-airflow",
"path": "/tests/mappers/test_java_mapper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if includeEndpoints:
numPoints -= 2
data = PerfectData.discrete_data(net,params,numPoints,timeInterval, \
vars=vars,random=randomX)
if includeEndpoints:
traj = net.integrate(timeInterval)
for var in vars:
for time in timeInterval:... | code_fim | hard | {
"lang": "python",
"repo": "EmoryUniversityTheoreticalBiophysics/SirIsaac",
"path": "/SirIsaac/fakeData.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if noiseSeed is not None: np.random.seed(noiseSeed)
if typValOffsets is None: typValOffsets = np.zeros(len(vars))
for var,offset,trueNoiseFracSize in zip(list(data.keys()),typValOffsets,noiseFracSizeList):
trueNoiseSize = trueNoiseFracSize * ( net.get_var_typical_val(var) - offset )
... | code_fim | hard | {
"lang": "python",
"repo": "EmoryUniversityTheoreticalBiophysics/SirIsaac",
"path": "/SirIsaac/fakeData.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EmoryUniversityTheoreticalBiophysics/SirIsaac path: /SirIsaac/fakeData.py
# fakeData.py
#
# Bryan Daniels
# 7.20.2009
#
# Make fake data compatible with SloppyCell.
from SloppyCell.ReactionNetworks import *
import numpy as np
# (originally from runTranscriptionNetwork.py)
def noisyFakeData(net,... | code_fim | hard | {
"lang": "python",
"repo": "EmoryUniversityTheoreticalBiophysics/SirIsaac",
"path": "/SirIsaac/fakeData.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fornasari12/expedia_web_scraper path: /competition_factor.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import logging
from time import sleep
import pandas as pd
import datetime as dt
from datetime import datetime
from google.cloud import bigquery
from ut... | code_fim | hard | {
"lang": "python",
"repo": "fornasari12/expedia_web_scraper",
"path": "/competition_factor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.driver.quit()
print('driver quited')
return df_rooms
logging.info('Starting scraping')
bot = ExpediaScraper(start_date='2021-03-01', end_date='2021-03-31')
logging.info('Starting with webdriver scraping')
df = bot.iterate_through_date_range().reset_index(drop=True)
logging.i... | code_fim | hard | {
"lang": "python",
"repo": "fornasari12/expedia_web_scraper",
"path": "/competition_factor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arponpes/Animal-Shelter path: /test/test_models.py
import pytest
from core.factories import AdopterFamilyFactory, AnimalFactory
<|fim_suffix|> animal = AnimalFactory(state='AVAILABLE')
AdopterFamilyFactory(animal=animal)
assert animal.state == 'UNAVAILABLE'<|fim_middle|>
@pytest.mark... | code_fim | easy | {
"lang": "python",
"repo": "arponpes/Animal-Shelter",
"path": "/test/test_models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> animal = AnimalFactory(state='AVAILABLE')
AdopterFamilyFactory(animal=animal)
assert animal.state == 'UNAVAILABLE'<|fim_prefix|># repo: arponpes/Animal-Shelter path: /test/test_models.py
import pytest
from core.factories import AdopterFamilyFactory, AnimalFactory
<|fim_middle|>
@pytest.mark... | code_fim | easy | {
"lang": "python",
"repo": "arponpes/Animal-Shelter",
"path": "/test/test_models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_add_leading_dims_numpy() -> None:
x = np.random.random(3)
target = np.random.random((1, 2, 3))
assert add_leading_dims_numpy(x, target).shape == (1, 1, 3)<|fim_prefix|># repo: takuseno/d3rlpy path: /tests/preprocessing/test_base.py
import numpy as np
import torch
from d3rlpy.prepro... | code_fim | medium | {
"lang": "python",
"repo": "takuseno/d3rlpy",
"path": "/tests/preprocessing/test_base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: takuseno/d3rlpy path: /tests/preprocessing/test_base.py
import numpy as np
import torch
from d3rlpy.preprocessing.base import add_leading_dims, add_leading_dims_numpy
def test_add_leading_dims() -> None:
x = torch.rand(3)
target = torch.rand(1, 2, 3)
assert add_leading_dims(x, targ... | code_fim | easy | {
"lang": "python",
"repo": "takuseno/d3rlpy",
"path": "/tests/preprocessing/test_base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hasanmdarif/Advanced-Data-Structures-with-Python path: /genetic.py
import random
from deap import base, creator, tools
def eval_func(individual):
target_sum = 15
return len(individual) - abs(sum(individual) - target_sum),
def create_toolbox(num_bits):
creator.create("FitnessMax", base.... | code_fim | hard | {
"lang": "python",
"repo": "hasanmdarif/Advanced-Data-Structures-with-Python",
"path": "/genetic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> toolbox.mutate(mutant)
del mutant.fitness.values
invalid_ind = [ind for ind in offspring if not ind.fitness.valid]
fitnesses = map(toolbox.evaluate, invalid_ind)
for ind, fit in zip(invalid_ind, fitnesses):
ind.fitness.values = fit
print('Evaluated', len(invalid_ind), 'individuals')
popu... | code_fim | medium | {
"lang": "python",
"repo": "hasanmdarif/Advanced-Data-Structures-with-Python",
"path": "/genetic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>population[:] = offspring
fits = [ind.fitness.values[0] for ind in population]
length = len(population)
mean = sum(fits) / length
sum2 = sum(x*x for x in fits)
std = abs(sum2 / length - mean**2)**0.5
print('Min =', min(fits), ', Max =', max(fits))
print('Average =', round(mean, 2), ', Standard deviation =... | code_fim | hard | {
"lang": "python",
"repo": "hasanmdarif/Advanced-Data-Structures-with-Python",
"path": "/genetic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def receive(self, packet: dict, protocol, transport):
request_type = packet['type']
if request_type in ['register', 'get_instances', 'xsubscribe', 'get_subscribers']:
for_log = {}
params = packet['params']
for_log["caller_name"] = params['service'] +... | code_fim | hard | {
"lang": "python",
"repo": "dedeepyabonthu/vyked",
"path": "/vyked/registry.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup_logging("registry")
self._loop.add_signal_handler(getattr(signal, 'SIGINT'), partial(self._stop, 'SIGINT'))
self._loop.add_signal_handler(getattr(signal, 'SIGTERM'), partial(self._stop, 'SIGTERM'))
app = Application(loop=asyncio.get_event_loop())
fn = getattr... | code_fim | hard | {
"lang": "python",
"repo": "dedeepyabonthu/vyked",
"path": "/vyked/registry.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.