text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Anurag810/frappe path: /frappe/core/doctype/custom_docperm/custom_docperm.py
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document
<|fim_suffix|> def on_update(self):
frappe.clear... | code_fim | easy | {
"lang": "python",
"repo": "Anurag810/frappe",
"path": "/frappe/core/doctype/custom_docperm/custom_docperm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> frappe.clear_cache(doctype = self.parent)<|fim_prefix|># repo: Anurag810/frappe path: /frappe/core/doctype/custom_docperm/custom_docperm.py
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Doc... | code_fim | easy | {
"lang": "python",
"repo": "Anurag810/frappe",
"path": "/frappe/core/doctype/custom_docperm/custom_docperm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """If a module is already in sys.modules and a reload fails
(e.g. a SyntaxError), the module should be in the state it was before
the reload began."""
pass
@abc.abstractmethod
def test_unloadable(self):
"""Test ImportError is raised when the loader is asked... | code_fim | hard | {
"lang": "python",
"repo": "RustPython/RustPython",
"path": "/Lib/test/test_importlib/abc.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RustPython/RustPython path: /Lib/test/test_importlib/abc.py
import abc
class FinderTests(metaclass=abc.ABCMeta):
"""Basic tests for a finder to pass."""
@abc.abstractmethod
def test_module(self):
# Test importing a top-level module.
pass
@abc.abstractmethod
... | code_fim | hard | {
"lang": "python",
"repo": "RustPython/RustPython",
"path": "/Lib/test/test_importlib/abc.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :return: a new H2ODataWrapper
"""
if spark_session_params is None:
spark_session_params = {}
if h2o_sparkling_params is None:
h2o_sparkling_params = {}
return self.to_spark(spark_session_params).to_h2o_sparkling(factor_columns_list=factor_... | code_fim | hard | {
"lang": "python",
"repo": "Harflo/mercury-ml",
"path": "/mercury_ml/common/data_wrappers/pandas.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def to_h2o_sparkling(self, spark_session_params=None, factor_columns_list=None, h2o_sparkling_params=None):
"""
Creates a new H2ODataWrapper based on this PandasDataWrapper and returns it as a new object
:param list factor_columns_list: The names of the columns that should be ... | code_fim | hard | {
"lang": "python",
"repo": "Harflo/mercury-ml",
"path": "/mercury_ml/common/data_wrappers/pandas.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Harflo/mercury-ml path: /mercury_ml/common/data_wrappers/pandas.py
class PandasDataWrapper():
"""
A DataWrapper with a Pandas DataFrame as its underlying data
"""
def __init__(self, underlying, field_names):
self.underlying = underlying
self.field_names = field_na... | code_fim | hard | {
"lang": "python",
"repo": "Harflo/mercury-ml",
"path": "/mercury_ml/common/data_wrappers/pandas.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 遍历第三行的所有列 保存字段名
for col in range(0, excel_sheet.ncols):
cell = excel_sheet.cell(2, col)
col_name_list.append(str(cell.value))
assert cell.ctype == 1, "found a invalid col name in col [%d] !~" % (col)
# 遍历第四行的所有列 保存数据类型
for col in range(0, excel_sheet.ncols):
... | code_fim | hard | {
"lang": "python",
"repo": "fqkw6/SmartGame01",
"path": "/ConfigData/Excel2Json/excel2json.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fqkw6/SmartGame01 path: /ConfigData/Excel2Json/excel2json.py
#-*- coding:utf-8 -*-
import sys
import os
import xlrd
import re
# 使可以解析中文字符
reload(sys)
sys.setdefaultencoding('utf8')
# 当前脚本路径
curpath = os.path.dirname(os.path.abspath(sys.argv[0]))
# 文件头描述格式化文本
lua_file_head_format_desc = '''/*... | code_fim | hard | {
"lang": "python",
"repo": "fqkw6/SmartGame01",
"path": "/ConfigData/Excel2Json/excel2json.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ew.as_view(), name='join'),
path('<int:pk>/leave/', LeaveView.as_view(), name='leave'),
path('<int:pk>/qr', QrView.as_view(), name='qr'),
path('<int:pk>/members', MembersView.as_view(), name='members'),
path('<int:pk>/members/export_csv', export_csv, name='export_csv'),
]<|fim_prefix|># re... | code_fim | medium | {
"lang": "python",
"repo": "liujordan/QuickRegister",
"path": "/clubs/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,
path('<int:pk>/members', MembersView.as_view(), name='members'),
path('<int:pk>/members/export_csv', export_csv, name='export_csv'),
]<|fim_prefix|># repo: liujordan/QuickRegister path: /clubs/urls.py
from django.urls import path, re_path
from .views import *
app_name = 'clubs'
urlpatterns = [... | code_fim | hard | {
"lang": "python",
"repo": "liujordan/QuickRegister",
"path": "/clubs/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liujordan/QuickRegister path: /clubs/urls.py
from django.urls import path, re_path
from .views import *
app_name = 'clubs'
urlpatterns = [
path('', HomeView.as_view(), name='home'),
path('create', CreateView.as_view(), name='create'),
path('<int:pk>/', ClubView.as_view(), name='club'... | code_fim | medium | {
"lang": "python",
"repo": "liujordan/QuickRegister",
"path": "/clubs/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pshung29/turbocare path: /turbocare/controllers_person_manager.py
, receipt.id)
receipt_link = HRef()
receiptvalues.append((receipt_link.display(link_href='/billing/?receipt_id=%d' % receipt.id, link_text=receipt.id), '%d Items purchased on %s (%s)' % (receipt.CountPurchasedItems(), recei... | code_fim | hard | {
"lang": "python",
"repo": "pshung29/turbocare",
"path": "/turbocare/controllers_person_manager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @expose(html='turbocare.templates.dataentryerror')
def DataEntryError(self, error='', next_link = '', **kw):
if error == '':
error = "Unknown Error"
if next_link == '':
next_link = "/billing/"
return dict(error_message = error, next_link=next_link)
def GetDefaultCustomerLocationID(self)... | code_fim | hard | {
"lang": "python",
"repo": "pshung29/turbocare",
"path": "/turbocare/controllers_person_manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pshung29/turbocare path: /turbocare/controllers_person_manager.py
n create it """
customers = model.InvCustomer.select(model.InvCustomer.q.ExternalID==Person.id)
if customers.count() == 0:
return CreateCustomer(Person)
else:
return customers[0]
# Load any data
# Set our defau... | code_fim | hard | {
"lang": "python",
"repo": "pshung29/turbocare",
"path": "/turbocare/controllers_person_manager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> newauthorid, newhour = data_mapped
try:
newhour = int(newhour)
except ValueError:
continue
if oldauthorid and oldauthorid!=newauthorid:
arr = [0]*24
for i in hour:
arr[i] +=1
arr1 = []
for i,x in enumerate(arr):
if x == max(arr):
arr1.append(i)
print oldauthorid, "\t", arr... | code_fim | medium | {
"lang": "python",
"repo": "LakshayNagpal/Data-Analyst-Nanodegree",
"path": "/P6: Intro to Hadoop and MapReduce/reducer_final_1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> oldauthorid = newauthorid
hour.append(newhour)
#oldhour = max(oldhour,newhour)
if oldauthorid !=None:
print oldauthorid, "\t", oldhour<|fim_prefix|># repo: LakshayNagpal/Data-Analyst-Nanodegree path: /P6: Intro to Hadoop and MapReduce/reducer_final_1.py
#!/usr/bin/python
import sys
import operator
... | code_fim | hard | {
"lang": "python",
"repo": "LakshayNagpal/Data-Analyst-Nanodegree",
"path": "/P6: Intro to Hadoop and MapReduce/reducer_final_1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LakshayNagpal/Data-Analyst-Nanodegree path: /P6: Intro to Hadoop and MapReduce/reducer_final_1.py
#!/usr/bin/python
import sys
import operator
oldauthorid = None
hour = []
oldhour = 0
for line in sys.stdin:
data_mapped = line.strip().split('\t')
<|fim_suffix|> print oldauthorid, "\t", arr1... | code_fim | hard | {
"lang": "python",
"repo": "LakshayNagpal/Data-Analyst-Nanodegree",
"path": "/P6: Intro to Hadoop and MapReduce/reducer_final_1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lb3/CLIP-PyL path: /clippyl/test_build_readid_db.py
'''test the readid db builder'''
import os
import unittest
from clippyl.build_readid_db import main
from clippyl.sample_data.paths import hitsclip_discardUnclipped_fq_dir
class BuildReadidDBTestCase(unittest.TestCase):
<|fim_suffix|>#NOTE... | code_fim | hard | {
"lang": "python",
"repo": "lb3/CLIP-PyL",
"path": "/clippyl/test_build_readid_db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # getting relevant sample data filepaths
fp_l = os.listdir(hitsclip_discardUnclipped_fq_dir())
fp_l = [os.path.join(hitsclip_discardUnclipped_fq_dir(), fp) for fp in fp_l]
fq_fp_l = [fp for fp in fp_l if fp.split('.')[-2:] == ['fq','gz']]
print (fq_fp_l)
# b... | code_fim | hard | {
"lang": "python",
"repo": "lb3/CLIP-PyL",
"path": "/clippyl/test_build_readid_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sujitnoronha/cresendo path: /clientpage/models.py
from django.db import models
from django.contrib.auth.models import User
from django.shortcuts import reverse
loctype = (
('tourist','tourist'),
('resteraunt','resteraunts'),
)
# Create your models here.
class Locations(models.Model):
... | code_fim | medium | {
"lang": "python",
"repo": "sujitnoronha/cresendo",
"path": "/clientpage/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return reverse("profile", kwargs={"id": self.pk})
class CommentsField(models.Model):
location = models.ForeignKey(Locations, on_delete=models.CASCADE, related_name='location')
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='creator')
comment = models.CharField(... | code_fim | medium | {
"lang": "python",
"repo": "sujitnoronha/cresendo",
"path": "/clientpage/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SuperMaltese/PieCentral path: /hibike/hibike_process.py
eue
import random
import threading
import time
import sys
#from PieCentral.runtime.runtimeUtil import *
# from runtimeUtil import *
# pylint: disable=import-error
import hibike_message as hm
import serial
__all__ = ["hibike_process"]
# ... | code_fim | hard | {
"lang": "python",
"repo": "SuperMaltese/PieCentral",
"path": "/hibike/hibike_process.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def remove_disconnected_devices(error_queue, devices, clean_up_queue, state_queue):
"""
Clean up any disconnected devices in ERROR_QUEUE.
"""
next_time_errors = []
while True:
try:
error = error_queue.get(block=False)
pack = devices[error.uid]
... | code_fim | hard | {
"lang": "python",
"repo": "SuperMaltese/PieCentral",
"path": "/hibike/hibike_process.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SuperMaltese/PieCentral path: /hibike/hibike_process.py
f get_working_serial_ports(excludes=()):
"""
Scan for open COM ports, except those in EXCLUDES.
Returns:
A list of serial port objects (`serial.Serial`) and port names.
"""
excludes = set(excludes)
# Last com... | code_fim | hard | {
"lang": "python",
"repo": "SuperMaltese/PieCentral",
"path": "/hibike/hibike_process.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def record_time_info(self):
present_time = datetime.now()
self.rx_timestamps.append(present_time)
self.rx_delays.append((present_time - self.last_packet_time).microseconds)
self.last_packet_time = present_time
def clear_lists(self):
self.rx_data.clear()
... | code_fim | hard | {
"lang": "python",
"repo": "royjara/arduino_ble_sense",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def cleanup(self):
if self.client:
await self.client.stop_notify(read_characteristic)
await self.client.disconnect()
async def manager(self):
print("Starting connection manager.")
while True:
if self.client:
await s... | code_fim | hard | {
"lang": "python",
"repo": "royjara/arduino_ble_sense",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: royjara/arduino_ble_sense path: /app.py
# https://tutorialedge.net/python/concurrency/asyncio-event-loops-tutorial/
import os, sys
import asyncio
import platform
from datetime import datetime
from typing import Callable, Any
from aioconsole import ainput
from bleak import BleakClient, discover
... | code_fim | hard | {
"lang": "python",
"repo": "royjara/arduino_ble_sense",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: disqus/pgshovel path: /src/main/python/pgshovel/administration/__init__.py
ation_value(cluster, cursor, 'version', __version__)
# Ensure that this database has already had an identifier associated with it.
logger.info('Checking for node ID...')
node_id = get_or_set_node_identifier(cl... | code_fim | hard | {
"lang": "python",
"repo": "disqus/pgshovel",
"path": "/src/main/python/pgshovel/administration/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def fetch_sets(cluster, names=None):
if names is None:
names = cluster.zookeeper.get_children(cluster.get_set_path())
sets = map(VersionedSet.expand, names)
paths = map(
cluster.get_set_path,
map(operator.attrgetter('name'), sets),
)
futures = map(cluster.zooke... | code_fim | hard | {
"lang": "python",
"repo": "disqus/pgshovel",
"path": "/src/main/python/pgshovel/administration/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: disqus/pgshovel path: /src/main/python/pgshovel/administration/__init__.py
sion
from pgshovel.database import (
get_configuration_value,
get_node_identifier,
get_or_set_node_identifier,
set_configuration_value,
update_configuration_value,
)
from pgshovel.interfaces.configurati... | code_fim | hard | {
"lang": "python",
"repo": "disqus/pgshovel",
"path": "/src/main/python/pgshovel/administration/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inowas/flopyAdapter path: /flopyAdapter/modflow_package_adapter/sftadapter.py
from flopyAdapter.modflow_package_adapter.adapter_base import ModflowPackageAdapterBase
import flopy.mt3d as mt
class SftAdapter(ModflowPackageAdapterBase):
def __init__(self, *args):
super(SftAdapter, sel... | code_fim | hard | {
"lang": "python",
"repo": "inowas/flopyAdapter",
"path": "/flopyAdapter/modflow_package_adapter/sftadapter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> content = {
"nsfinit": package.nsfinit,
"mxsfbc": package.mxsfbc,
"icbcsf": package.icbcsf,
"ioutobs": package.ioutobs,
"ietsfr": package.ietsfr,
"isfsolv": package.isfsolv,
"wimp": package.wimp,
"wups... | code_fim | hard | {
"lang": "python",
"repo": "inowas/flopyAdapter",
"path": "/flopyAdapter/modflow_package_adapter/sftadapter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> default = {
"nsfinit": 0,
"mxsfbc": 0,
"icbcsf": 0,
"ioutobs": None,
"ietsfr": 0,
"isfsolv": 1,
"wimp": 0.5,
"wups": 1.0,
"cclosesf": 1e-06,
"mxitersf": 10,
"crntsf"... | code_fim | hard | {
"lang": "python",
"repo": "inowas/flopyAdapter",
"path": "/flopyAdapter/modflow_package_adapter/sftadapter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @allure.step
def delete_popup_trial(self):
self.driver.find_element_by_tag_name('body').send_keys(Keys.ESCAPE)
time.sleep(2)<|fim_prefix|># repo: Mikhail-QA/HS path: /POM/delete_popup.py
import allure
import time
from selenium.webdriver.common.keys import Keys
class DeleteModalP... | code_fim | hard | {
"lang": "python",
"repo": "Mikhail-QA/HS",
"path": "/POM/delete_popup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mikhail-QA/HS path: /POM/delete_popup.py
import allure
import time
from selenium.webdriver.common.keys import Keys
class DeleteModalPopup(object):
def __init__(self, driver):
self.driver = driver
<|fim_suffix|> element = self.driver.find_element_by_css_selector(
... | code_fim | medium | {
"lang": "python",
"repo": "Mikhail-QA/HS",
"path": "/POM/delete_popup.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> element = self.driver.find_element_by_css_selector(
'body > div.modal-backdrop.fade.in')
self.driver.execute_script("""
var element = arguments[0];
element.parentNode.removeChild(element);
""", element)
@allure.step
def delete_popup_trial(self):... | code_fim | hard | {
"lang": "python",
"repo": "Mikhail-QA/HS",
"path": "/POM/delete_popup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def has_object_permission(self, request, view, obj) -> bool:
if request.method == "GET":
return super().has_object_permission(request, view, obj)
else:
return request.user.is_staff or request.user == obj.user<|fim_prefix|># repo: sparcs-kaist/new-ara-api path: ... | code_fim | easy | {
"lang": "python",
"repo": "sparcs-kaist/new-ara-api",
"path": "/apps/user/permissions/user_profile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.method == "GET":
return super().has_object_permission(request, view, obj)
else:
return request.user.is_staff or request.user == obj.user<|fim_prefix|># repo: sparcs-kaist/new-ara-api path: /apps/user/permissions/user_profile.py
from rest_framework import... | code_fim | medium | {
"lang": "python",
"repo": "sparcs-kaist/new-ara-api",
"path": "/apps/user/permissions/user_profile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sparcs-kaist/new-ara-api path: /apps/user/permissions/user_profile.py
from rest_framework import permissions
<|fim_suffix|> def has_object_permission(self, request, view, obj) -> bool:
if request.method == "GET":
return super().has_object_permission(request, view, obj)
... | code_fim | easy | {
"lang": "python",
"repo": "sparcs-kaist/new-ara-api",
"path": "/apps/user/permissions/user_profile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Store sample dict
sample = dict()
sample['rgb'] = rgb.float()
sample['uvw'] = uvw.long()
sample['mask'] = mask.long()
sample['latent'] = latent.float()
sample['crop_size'] = crop_size.long()
sample['intrinsics'] = torch.Tensor(intrinsics).f... | code_fim | hard | {
"lang": "python",
"repo": "yumianhuli2/sdflabel",
"path": "/datasets/crops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yumianhuli2/sdflabel path: /datasets/crops.py
import os
import json
import numpy as np
import torch
from PIL import Image
from torch.utils.data.dataset import Dataset
from scipy.spatial.transform import Rotation as R
import torchvision.transforms as transforms
import random
class Crops(Dataset)... | code_fim | hard | {
"lang": "python",
"repo": "yumianhuli2/sdflabel",
"path": "/datasets/crops.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get camera parameters
intrinsics = np.array(gt_sample['intrinsics']).reshape((3, 3))
# Random transformations
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
transformation_rgb = transforms.Compose([
transforms.... | code_fim | hard | {
"lang": "python",
"repo": "yumianhuli2/sdflabel",
"path": "/datasets/crops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>a=shorten("tokens")
b=shorten("parse")
c=shorten("interpreter")
open("build/op.min.js","w").write(a+b+c)<|fim_prefix|># repo: adriank/ObjectPath.JS path: /minimize.py
#!/usr/bin/python
import httplib, urllib, sys
# Define the parameters for the POST request and encode them in
# a URL-safe format.
def... | code_fim | hard | {
"lang": "python",
"repo": "adriank/ObjectPath.JS",
"path": "/minimize.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adriank/ObjectPath.JS path: /minimize.py
#!/usr/bin/python
import httplib, urllib, sys
# Define the parameters for the POST request and encode them in
# a URL-safe format.
<|fim_suffix|>a=shorten("tokens")
b=shorten("parse")
c=shorten("interpreter")
open("build/op.min.js","w").write(a+b+c)<|f... | code_fim | hard | {
"lang": "python",
"repo": "adriank/ObjectPath.JS",
"path": "/minimize.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> length_scale = np.asarray(length_scale)
dists = cdist(query_sample.T/length_scale, other_samples.T/length_scale,
metric='euclidean')
if nu == 3/2:
tmp1 = np.sqrt(3)*dists
tmp2 = (np.tile(
query_sample.T, (other_samples.shape[1], 1))-other_samples.T... | code_fim | hard | {
"lang": "python",
"repo": "samtx/pyapprox",
"path": "/pyapprox/gaussian_process.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samtx/pyapprox path: /pyapprox/gaussian_process.py
# tmp[:, jj] = tau.dot(K_train_grad_all_train_points_jj[:, kk])
# assert np.allclose(tmp[:,jj], tmp1[kk,:,jj])
# assert np.allclose(tmp,tmp1[kk,:,:])
# jac[:, ii*nvars+kk] -= np.sum(tmp*tau, axis=1)... | code_fim | hard | {
"lang": "python",
"repo": "samtx/pyapprox",
"path": "/pyapprox/gaussian_process.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def objective_econ(self, new_sample_index):
if self.L_inv.shape[0] == 0:
val = self.P[new_sample_index, new_sample_index]/self.A[
new_sample_index, new_sample_index]
return -val
A_12 = self.A[self.pivots, new_sample_index:new_sample_index+1]
... | code_fim | hard | {
"lang": "python",
"repo": "samtx/pyapprox",
"path": "/pyapprox/gaussian_process.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iterative/dvc path: /dvc/dagascii.py
"""Draws DAG in ASCII."""
import logging
import math
import os
from grandalf.graphs import Edge, Graph, Vertex
from grandalf.layouts import SugiyamaLayout
from grandalf.routing import EdgeViewer, route_with_lines
logger = logging.getLogger(__name__)
class... | code_fim | hard | {
"lang": "python",
"repo": "iterative/dvc",
"path": "/dvc/dagascii.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> canvas = AsciiCanvas(canvas_cols, canvas_lines)
# NOTE: first draw edges so that node boxes could overwrite them
for edge in sug.g.sE:
# pylint: disable=protected-access
assert len(edge.view._pts) > 1
for index in range(1, len(edge.view._pts)):
start = edge... | code_fim | hard | {
"lang": "python",
"repo": "iterative/dvc",
"path": "/dvc/dagascii.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
x (int): x coordinate. Should be >= 0 and < number of columns in
the canvas.
y (int): y coordinate. Should be >= 0 an < number of lines in the
canvas.
char (str): character to place in the specified point on the
... | code_fim | hard | {
"lang": "python",
"repo": "iterative/dvc",
"path": "/dvc/dagascii.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ofa/everyvoter path: /mailer/filters.py
"""List filters for mailer"""
import django_filters
from mailer.models import MailingTemplate
from election.choices import DEADLINES, ELECTION_TYPES
class MailingTemplateFilter(django_filters.FilterSet):
<|fim_suffix|> class Meta(object):
"""M... | code_fim | hard | {
"lang": "python",
"repo": "ofa/everyvoter",
"path": "/mailer/filters.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Meta options for the filter"""
model = MailingTemplate
fields = ['name', 'election_type', 'deadline_type']<|fim_prefix|># repo: ofa/everyvoter path: /mailer/filters.py
"""List filters for mailer"""
import django_filters
from mailer.models import MailingTemplate
from election.c... | code_fim | hard | {
"lang": "python",
"repo": "ofa/everyvoter",
"path": "/mailer/filters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Heaps:
完全二叉树,最大堆的非叶子节点的值都比孩子大,最小堆的非叶子结点的值都比孩子小
Heap包含两个属性,order property 和 shape property(a complete binary tree),在插入
一个新节点的时候,始终要保持这两个属性
插入操作:保持堆属性和完全二叉树属性, sift-up 操作维持堆属性
extract操作:只获取根节点数据,并把树最底层最右节点copy到根节点后,sift-down操作维持堆属性
用数组实现heap,从根节点开始,从上往下从左到右给每个节点编号,则根据完全二... | code_fim | hard | {
"lang": "python",
"repo": "welch-chu/python_data_structures_and_algorithms",
"path": "/docs/16_优先级队列/priority_queue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: welch-chu/python_data_structures_and_algorithms path: /docs/16_优先级队列/priority_queue.py
# -*- coding:utf-8 -*-
# 第二章拷贝的 Array 代码
class Array(object):
def __init__(self, size=32):
self._size = size
self._items = [None] * size
def __getitem__(self, index):
return... | code_fim | hard | {
"lang": "python",
"repo": "welch-chu/python_data_structures_and_algorithms",
"path": "/docs/16_优先级队列/priority_queue.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class PriorityQueue(object):
def __init__(self, maxsize):
self.maxsize = maxsize
self._maxheap = MaxHeap(maxsize)
def push(self, priority, value):
entry = (priority, value) # 注意这里把这个 tuple push进去,python 比较 tuple 从第一个开始比较
self._maxheap.add(entry)
def pop(se... | code_fim | hard | {
"lang": "python",
"repo": "welch-chu/python_data_structures_and_algorithms",
"path": "/docs/16_优先级队列/priority_queue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EUGINELETHAL/activity path: /indicators/migrations/0010_auto_20200310_1010.py
# Generated by Django 2.2.10 on 2020-03-10 17:10
import datetime
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('indicators', '0009_merge_20200228_0054'),
]
operations ... | code_fim | easy | {
"lang": "python",
"repo": "EUGINELETHAL/activity",
"path": "/indicators/migrations/0010_auto_20200310_1010.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='level',
name='create_date',
field=models.DateTimeField(blank=True, default=datetime.datetime.now, null=True),
),
]<|fim_prefix|># repo: EUGINELETHAL/activity path: /indicators/migrations/0010_aut... | code_fim | medium | {
"lang": "python",
"repo": "EUGINELETHAL/activity",
"path": "/indicators/migrations/0010_auto_20200310_1010.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hashimmm/iiifoo path: /features/steps/utils.py
from time import time
from behave import *
from caching import cached
@given(u'a cached method that returns current time')
def step_impl(context):
@cached(timeout=5)
def curtime():
return time()
context.timefunc = curtime
<|fi... | code_fim | medium | {
"lang": "python",
"repo": "hashimmm/iiifoo",
"path": "/features/steps/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@when(u'it is called twice')
def step_impl(context):
context.time1 = context.timefunc()
context.time2 = context.timefunc()
@then(u'the same time is returned')
def step_impl(context):
assert context.time1 == context.time2<|fim_prefix|># repo: hashimmm/iiifoo path: /features/steps/utils.py
fr... | code_fim | medium | {
"lang": "python",
"repo": "hashimmm/iiifoo",
"path": "/features/steps/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> env = os.environ
args = [
'docker-compose', '-f', os.path.join(HERE, 'compose', 'zk.yaml')
]
subprocess.check_call(args + ["up", "-d"], env=env)
sys.stderr.write("Waiting for ZK to boot")
for _ in xrange(2):
try:
res = requests.get(URL)
res.r... | code_fim | hard | {
"lang": "python",
"repo": "ofek-public/integrations-core",
"path": "/zk/tests/conftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ofek-public/integrations-core path: /zk/tests/conftest.py
# (C) Datadog, Inc. 2010-2017
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
import os
import sys
import time
import subprocess
import requests
import pytest
from datadog_checks.utils.common import get_docker_h... | code_fim | hard | {
"lang": "python",
"repo": "ofek-public/integrations-core",
"path": "/zk/tests/conftest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
'host': HOST,
'port': PORT,
'expected_mode': "follower",
'tags': []
}
@pytest.fixture
def get_conn_failure_config():
return {
'host': HOST,
'port': 2182,
'expected_mode': "down",
'tags': []
}
@pytest.fixture
def a... | code_fim | hard | {
"lang": "python",
"repo": "ofek-public/integrations-core",
"path": "/zk/tests/conftest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def choose_lost():
lost = input('How many unsuccessful choices do you want to allow yourself? ')
lost = int(lost)
return lost
def check_lost(lose, lost, word):
if lose > lost:
print()
print('You lose! The secret word was: {}'.format(list_to_string(word)))
return... | code_fim | hard | {
"lang": "python",
"repo": "mwinslo/21-FunctionalDecomposition-201930",
"path": "/src/m1_hangman.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mwinslo/21-FunctionalDecomposition-201930 path: /src/m1_hangman.py
"""
Hangman.
Authors: Montgomery Winslow and Micah Fletcher.
""" # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE.
# DONE: 2. Implement Hangman using your Iterative Enhancement Plan.
import random
def min_length():
min = int(in... | code_fim | hard | {
"lang": "python",
"repo": "mwinslo/21-FunctionalDecomposition-201930",
"path": "/src/m1_hangman.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: python-kol/libkol path: /test/test_koldate.py
from unittest import TestCase
from libkol.koldate import koldate
class KoldateTestCase(TestCase):
def test_ronald_phase(self):
self.assertEqual(koldate(52, 2, 0).ronald_phase, 0)
self.assertEqual(koldate(52, 2, 1).ronald_phase, 1... | code_fim | hard | {
"lang": "python",
"repo": "python-kol/libkol",
"path": "/test/test_koldate.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(koldate(52, 2, 0).moonlight, 0)
self.assertEqual(koldate(52, 2, 1).moonlight, 2)
self.assertEqual(koldate(52, 2, 2).moonlight, 2)
self.assertEqual(koldate(52, 2, 3).moonlight, 4)
self.assertEqual(koldate(52, 2, 4).moonlight, 7)
self.assertEq... | code_fim | hard | {
"lang": "python",
"repo": "python-kol/libkol",
"path": "/test/test_koldate.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>exHandler),
(r"/log/", LogHandler),
(r"/real/time/", RealTimeHandler),
]<|fim_prefix|># repo: wenmaai/monitor-python path: /app/urls.py
# -*- coding: utf-8 -*-
# 导入系统监控视图
from app.views.views_index import IndexHandler
# 导入日志监控视图
from app.views.views_log import LogHandler
# 导入实时监控视图
from app.vie<|... | code_fim | medium | {
"lang": "python",
"repo": "wenmaai/monitor-python",
"path": "/app/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wenmaai/monitor-python path: /app/urls.py
# -*- coding: utf-8 -*-
# 导入系统监控视图
from app.views.views_index import IndexHandler
# 导入日志监控视图
from app.views.views_log import LogHandler
# 导入实时监控视图
from app.vie<|fim_suffix|>exHandler),
(r"/log/", LogHandler),
(r"/real/time/", RealTimeHandler),
]<|... | code_fim | medium | {
"lang": "python",
"repo": "wenmaai/monitor-python",
"path": "/app/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def search_people_1(search_type, search_value):
"""Reads (searches) person records for the specified search type and equal search value.
:param search_type: Type varies based on search options.
:param search_value: The value to search for.
:return: List of Person()
"""
try:
... | code_fim | hard | {
"lang": "python",
"repo": "yorkadam/addressweb",
"path": "/addressbook/data/read.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yorkadam/addressweb path: /addressbook/data/read.py
A foreign_keys = ON")
c.execute("SELECT * FROM comments WHERE personid=?", (person_id,))
comment_list = []
for row in c:
_comment = Comment()
_comment.person_id = row["personid"]
_comme... | code_fim | hard | {
"lang": "python",
"repo": "yorkadam/addressweb",
"path": "/addressbook/data/read.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yorkadam/addressweb path: /addressbook/data/read.py
return []
def read_comment(person_id):
"""Reads a comment for the specified person identifier (row identifier).
:param person_id: Person identifier (row identifier).
:return: List of Comment()
"""
try:
conn ... | code_fim | hard | {
"lang": "python",
"repo": "yorkadam/addressweb",
"path": "/addressbook/data/read.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># FIND SONGS
song_select = ("""
SELECT s.song_id, s.artist_id
FROM songs AS s
JOIN artists AS a ON s.artist_id = a.artist_id
WHERE s.title = %s AND a.name = %s AND s.duration = %s;
""")
# QUERY LISTS
create_table_queries = [artist_table_create, song_table_create, time_table_create,
... | code_fim | hard | {
"lang": "python",
"repo": "dewith/sparkify_postgres",
"path": "/sql_queries.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dewith/sparkify_postgres path: /sql_queries.py
# DROP TABLES
songplay_table_drop = "DROP TABLE IF EXISTS songplays;"
user_table_drop = "DROP TABLE IF EXISTS users;"
song_table_drop = "DROP TABLE IF EXISTS songs;"
artist_table_drop = "DROP TABLE IF EXISTS artists;"
time_table_drop = "DROP TABLE IF... | code_fim | hard | {
"lang": "python",
"repo": "dewith/sparkify_postgres",
"path": "/sql_queries.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>time_table_create = ("""
CREATE TABLE IF NOT EXISTS time (
start_time TIMESTAMP,
hour INT NOT NULL,
day INT NOT NULL,
week INT NOT NULL,
month INT NOT NULL,
year INT NOT NULL,
weekday INT NOT NULL,
... | code_fim | hard | {
"lang": "python",
"repo": "dewith/sparkify_postgres",
"path": "/sql_queries.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tr_data_dict = {"transaction": {}}
tr_data_dict["transaction"]["type"] = self.fields["transaction__type"]
tr_data_dict["transaction"]["order_id"] = self.fields["transaction__order_id"]
if self.fields.get("transaction__customer_id"):
tr_data_dict["transaction"]["... | code_fim | hard | {
"lang": "python",
"repo": "hayyat/merchant",
"path": "/billing/integrations/braintree_payments_integration.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hayyat/merchant path: /billing/integrations/braintree_payments_integration.py
from billing import Integration
from django.conf import settings
from django.views.decorators.http import require_GET
from billing.signals import transaction_was_successful, transaction_was_unsuccessful
from django.conf... | code_fim | hard | {
"lang": "python",
"repo": "hayyat/merchant",
"path": "/billing/integrations/braintree_payments_integration.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> key_tool = Gtk.EventControllerKey.new()
click_tool = Gtk.GestureClick.new()
key_tool.connect("key-pressed", on_key_pressed, event_manager)
click_tool.connect("released", on_double_click, event_manager)
return key_tool, click_tool
def on_key_pressed(controller, keyval, keycode, state... | code_fim | medium | {
"lang": "python",
"repo": "amolenaar/gaphor",
"path": "/gaphor/diagram/tools/textedit.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amolenaar/gaphor path: /gaphor/diagram/tools/textedit.py
from gi.repository import Gdk, Gtk
from gaphor.core.modeling import Diagram
from gaphor.diagram.event import DiagramOpened
from gaphor.diagram.instanteditors import instant_editor
def text_edit_tools(view, event_manager):
key_tool = ... | code_fim | hard | {
"lang": "python",
"repo": "amolenaar/gaphor",
"path": "/gaphor/diagram/tools/textedit.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tiLayerNetWork.load_net_work(91)
net.cross_validate(test_data, test_label)<|fim_prefix|># repo: YzzC/Backpropagation- path: /validate.py
from multilayernetwork import MultiLayerNetWork
from util import *
from config import *
if __name__ == "__main__":
test_data = load_csv_np(path=TEST_<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "YzzC/Backpropagation-",
"path": "/validate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YzzC/Backpropagation- path: /validate.py
from multilayernetwork import MultiLayerNetWork
from util import *
from confi<|fim_suffix|>tiLayerNetWork.load_net_work(91)
net.cross_validate(test_data, test_label)<|fim_middle|>g import *
if __name__ == "__main__":
test_data = load_csv_np(path=T... | code_fim | medium | {
"lang": "python",
"repo": "YzzC/Backpropagation-",
"path": "/validate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: voghoei/DL-Fundation path: /MH-Term-Project-master/src/basic_models_2class/basic_models.py
import numpy as np
import pickle, pandas, textblob, string, sys, config
from sklearn import model_selection, preprocessing, linear_model, naive_bayes, metrics, svm
from sklearn.feature_extraction.text impor... | code_fim | hard | {
"lang": "python",
"repo": "voghoei/DL-Fundation",
"path": "/MH-Term-Project-master/src/basic_models_2class/basic_models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def train(parameters):
"""
model training and print out the accuracy
@param: parameters: type, an object that contains parsed arguments
return: void
"""
X_train, X_val, X_test, y_train, y_val, y_test = get_data(parameters.feature)
accuracy = -1
if parameters.model == 'nai... | code_fim | hard | {
"lang": "python",
"repo": "voghoei/DL-Fundation",
"path": "/MH-Term-Project-master/src/basic_models_2class/basic_models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lt"
},
"DeleteDataSourceDefinition": {
"timeout_millis": 40000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"GetDataSourceDefinition": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
... | code_fim | hard | {
"lang": "python",
"repo": "cmm08/bq-dts-partner-clients-python",
"path": "/google/cloud/bigquery/datatransfer_v1/gapic/data_source_service_client_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmm08/bq-dts-partner-clients-python path: /google/cloud/bigquery/datatransfer_v1/gapic/data_source_service_client_config.py
config = {
"interfaces": {
"google.cloud.bigquery.datatransfer.v1.DataSourceService": {
"retry_codes": {
"idempotent": [
"DEADLINE_EXCEEDED",
... | code_fim | hard | {
"lang": "python",
"repo": "cmm08/bq-dts-partner-clients-python",
"path": "/google/cloud/bigquery/datatransfer_v1/gapic/data_source_service_client_config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = User
exclude = ['groups',
'user_permissions',
'is_staff',
'is_superuser',
'password']<|fim_prefix|># repo: dev-dpoudel/healthmap path: /user/serializers.py
from django.contrib.auth.models import Group
from... | code_fim | hard | {
"lang": "python",
"repo": "dev-dpoudel/healthmap",
"path": "/user/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dev-dpoudel/healthmap path: /user/serializers.py
from django.contrib.auth.models import Group
from .models import User, Scope
from rest_framework import serializers
class ScopeSerializer(serializers.ModelSerializer):
<|fim_suffix|> # Fetch Age from model property
age = serializers.ReadOn... | code_fim | hard | {
"lang": "python",
"repo": "dev-dpoudel/healthmap",
"path": "/user/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@bot.command(name='notanilist', help='Prints a message on whether or not MyAniList is AniList (spoilers: it\'s not).')
async def are_we_anilist(ctx):
"""
Prints a message on whether or not MyAniList is AniList (spoilers: it's not).
:param ctx: The current context.
:return: A message decla... | code_fim | hard | {
"lang": "python",
"repo": "croberts22/yukibot",
"path": "/bot/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: croberts22/yukibot path: /bot/main.py
import os
from discord.ext import commands
from dotenv import load_dotenv
# - Environment Setup
load_dotenv()
TOKEN = os.getenv('DISCORD_BOT_TOKEN')
bot = commands.Bot(command_prefix='!')
preamble = '📣 **Before posting, please check <#{channel}> for prev... | code_fim | hard | {
"lang": "python",
"repo": "croberts22/yukibot",
"path": "/bot/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kunalgupta777/Neural-Networks path: /Program4.py
## 4) Using Neural Network Implement Perceptron Learning Algorithm
## Using Perceptron Learning Algorithm for classifying 2 letters in a 3x3 matrix
matrix_I = [1,1,1,-1,1,-1,1,1,1]
matrix_F = [1,1,1,1,1,1,1,-1,-1]
# Initialising weights and... | code_fim | hard | {
"lang": "python",
"repo": "kunalgupta777/Neural-Networks",
"path": "/Program4.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ## Training on 1st Matrix
# Calculating yin
for i in range(1,10):
yinI+=matrix_I[i-1]*weights_bias[i]
print "yin for I matrix: ", yin
# Target value
y = f(yinI)
if y!= target[0]:
## weight updation starts
weights_bias[0]+=alp... | code_fim | medium | {
"lang": "python",
"repo": "kunalgupta777/Neural-Networks",
"path": "/Program4.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zp1018/mask2json path: /convertmask/labelme_sub/utils/__init__.py
'''
@lanhuage: python
@Descripttion:
@version: beta
@Author: xiaoshuyui
@Date: 2020-03-03 16:22:57
@LastEditors: xiaoshuyui
@LastEditTime: 2020-07-13 16:41:26
'''
# flake8: noqa
from ._io import lblsave
from .image import apply_... | code_fim | medium | {
"lang": "python",
"repo": "zp1018/mask2json",
"path": "/convertmask/labelme_sub/utils/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .shape import labelme_shapes_to_label
from .shape import masks_to_bboxes
from .shape import polygons_to_mask
from .shape import shape_to_mask
from .shape import shapes_to_label
from .qt import newIcon
from .qt import newButton
from .qt import newAction
from .qt import addActions
from .qt import labe... | code_fim | medium | {
"lang": "python",
"repo": "zp1018/mask2json",
"path": "/convertmask/labelme_sub/utils/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .qt import newIcon
from .qt import newButton
from .qt import newAction
from .qt import addActions
from .qt import labelValidator
from .qt import struct
from .qt import distance
from .qt import distancetoline
from .qt import fmtShortcut
from .draw import label_colormap
from .draw import _validate_col... | code_fim | hard | {
"lang": "python",
"repo": "zp1018/mask2json",
"path": "/convertmask/labelme_sub/utils/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Only run if the build was successful
if self.workflow.build_process_failed:
self.log.info("Not running for failed build")
self.workflow.builder.image_id = None
return []
self.set_manifest_list_expectations()
# Work out the name of the... | code_fim | hard | {
"lang": "python",
"repo": "MartinBasti/atomic-reactor",
"path": "/atomic_reactor/plugins/post_pulp_pull.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MartinBasti/atomic-reactor path: /atomic_reactor/plugins/post_pulp_pull.py
"""Copyright (c) 2016 Red Hat, Inc
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
Pull built image from Crane to discover its imag... | code_fim | hard | {
"lang": "python",
"repo": "MartinBasti/atomic-reactor",
"path": "/atomic_reactor/plugins/post_pulp_pull.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Decide whether we expect v2schema2list based on whether
# group_manifests grouped any manifests
if self.workflow.postbuild_results.get(PLUGIN_GROUP_MANIFESTS_KEY):
self.expect_v2schema2list = True
platforms = get_platforms(self.workflow)
if no... | code_fim | hard | {
"lang": "python",
"repo": "MartinBasti/atomic-reactor",
"path": "/atomic_reactor/plugins/post_pulp_pull.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = np.array([[1, 3, 4], [2, 3, 4]])
y = np.array([[3, 4, 5], [5, 2, 1]])
expect = np.array([6. / 2, 19. / 2]).mean()
np.testing.assert_almost_equal(MSE.batch_mean(x, y), expect)<|fim_prefix|># repo: gvinciguerra/nnweaver path: /test/losses_test.py
from nnweaver.losses import *
def test... | code_fim | hard | {
"lang": "python",
"repo": "gvinciguerra/nnweaver",
"path": "/test/losses_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gvinciguerra/nnweaver path: /test/losses_test.py
from nnweaver.losses import *
def test_mee():
x = np.array(1)
y = np.array(2)
np.testing.assert_almost_equal(MEE.loss(x, y), 1)
x = np.array([[1], [2]])
y = np.array([[3], [5]])
np.testing.assert_almost_equal(MEE.loss(x, ... | code_fim | hard | {
"lang": "python",
"repo": "gvinciguerra/nnweaver",
"path": "/test/losses_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s)):
print(i,model.layers[i].name)<|fim_prefix|># repo: DreamRiverForever/M2det-Keras path: /test.py
from nets.M2det import m2det
model = <|fim_middle|>m2det(21,None, name='m2det')
model.summary()
for i in range(len(model.layer | code_fim | medium | {
"lang": "python",
"repo": "DreamRiverForever/M2det-Keras",
"path": "/test.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.