text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: dedeepyabonthu/vyked path: /vyked/registry.py
e: Service):
service_name = self._get_full_service_name(service.name, service.version)
service_entry = (service.host, service.port, service.node_id, service.type)
self._registered_services[service.name][service.version].append(... | code_fim | hard | {
"lang": "python",
"repo": "dedeepyabonthu/vyked",
"path": "/vyked/registry.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Based on https://github.com/Sato-Kunihiko/audio-SNR/blob/8d2c933b6c0afe6f1203251f4877e7a1068a6130/create_mixed_audio_file.py#L20
:param clean_rms: Root Mean Square (RMS) - a value between 0.0 and 1.0
:param snr: Signal-to-Noise (SNR) Ratio in dB - typically somewhere between -20 and 60
:re... | code_fim | hard | {
"lang": "python",
"repo": "anitalp/audiomentations",
"path": "/audiomentations/core/utils.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anitalp/audiomentations path: /audiomentations/core/utils.py
import math
import os
def read_dir(path):
ir_list = os.listdir(path)
return [os.path.join(path, ir) for ir in ir_list]
<|fim_suffix|>def calculate_desired_noise_rms(clean_rms, snr):
"""
Given the Root Mean Square (RM... | code_fim | medium | {
"lang": "python",
"repo": "anitalp/audiomentations",
"path": "/audiomentations/core/utils.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>lst = tkinter.Listbox(eventsbox, height=10, width=50)
lst.pack(side=tkinter.LEFT)
scrollbx = tkinter.Scrollbar(eventsbox)
scrollbx.pack(side=tkinter.RIGHT, fill=tkinter.Y)
lst.config(yscrollcommand=scrollbx.set)
scrollbx.config(command=lst.yview)
events_func = tkinter.Entry(root, width=50)
events_func.... | code_fim | medium | {
"lang": "python",
"repo": "sarincr/Intermediate-Python-Projects",
"path": "/10.ToDoAPP/11.ToDoAPP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sarincr/Intermediate-Python-Projects path: /10.ToDoAPP/11.ToDoAPP.py
import tkinter
import tkinter.messagebox
import pickle
root = tkinter.Tk()
root.title("To-Do List by @TokyoEdtech")
def add_events():
events = events_func.get()
if events != "":
lst.insert(tkinter.END, events)
... | code_fim | hard | {
"lang": "python",
"repo": "sarincr/Intermediate-Python-Projects",
"path": "/10.ToDoAPP/11.ToDoAPP.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if cap.isOpened():
success, frame = cap.read()
while success:
dets, scores, orientations = _detector.run(frame, False)
for i, d in enumerate(dets):
x1 = d.left()
y1 = d.top()
x2 = d.right()
y2 = d.bottom()
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 25... | code_fim | medium | {
"lang": "python",
"repo": "rootadminWalker/Face-app",
"path": "/Face_recognition/original.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rootadminWalker/Face-app path: /Face_recognition/original.py
import dlib
import cv2
import pandas as pd
import numpy as np
import os
path = "./Users"
_shape_dat = "shape_predictor_68_face_landmarks.dat"
_face_dat = "dlib_face_recognition_resnet_model_v1.dat"
_detector = dlib.get_frontal_face_de... | code_fim | hard | {
"lang": "python",
"repo": "rootadminWalker/Face-app",
"path": "/Face_recognition/original.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
print("Nobody is here")
cv2.imshow("frame", frame)
if cv2.waitKey(1) == ord('q'):
break
success, frame = cap.read()
cap.release()
cv2.destroyAllWindows()
print("OK")<|fim_prefix|># repo: rootadminWalker/Face-app path: /Face_recognition/original.py
import dlib
imp... | code_fim | hard | {
"lang": "python",
"repo": "rootadminWalker/Face-app",
"path": "/Face_recognition/original.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = url.split("/")[-1]
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(f"{DATA_PATH}/{name}", "wb") as f:
f.write(response.raw.read())
else:
logging.info(f"Failed {url} download")
if __name__ == "__main__":
fetch_pwc(... | code_fim | hard | {
"lang": "python",
"repo": "Juan-Mateos/ai_papers_with_code",
"path": "/ai_papers_with_code/pipeline/data/fetch_pwc_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Juan-Mateos/ai_papers_with_code path: /ai_papers_with_code/pipeline/data/fetch_pwc_data.py
import logging
import requests
from ai_papers_with_code import PROJECT_DIR
DATA_PATH = f"{PROJECT_DIR}/inputs/data"
def fetch_pwc():
"""
Fetches the pwc data
"""
for url in [
"h... | code_fim | medium | {
"lang": "python",
"repo": "Juan-Mateos/ai_papers_with_code",
"path": "/ai_papers_with_code/pipeline/data/fetch_pwc_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
'user_id': 'admin',
'inputs': inputs,
'outputs': {
'error': 'Inputs incorrect',
'model': model
},
'exp_out': None,
'_id': jobId,
'run_type': "single"
}<|fim_prefix|># repo: quanted/pram_flask path: /REST_UBER... | code_fim | medium | {
"lang": "python",
"repo": "quanted/pram_flask",
"path": "/REST_UBER/rest_model_caller.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quanted/pram_flask path: /REST_UBER/rest_model_caller.py
import logging
import pandas as pd
def model_run(model, jobId, inputs, module):
boolog = True
if boolog:
print('ubertool_ecorest start ================================')
print('REST_UBER.rest_model_caller.model_ru... | code_fim | medium | {
"lang": "python",
"repo": "quanted/pram_flask",
"path": "/REST_UBER/rest_model_caller.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> except Exception as e:
self.logger.info("[-] copy() error: %s" % ( str(e)))
pass
# 再尝试一次
count -= 1
return False
def next_page(self, pagenum):
try:
# 下一页
#<a href="?stype=1&page=2">2</a>
... | code_fim | hard | {
"lang": "python",
"repo": "maerson/daili",
"path": "/plugin/provider.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maerson/daili path: /plugin/provider.py
dapters.DEFAULT_RETRIES = 3
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) "
"Chrome/21.0.1180.89 Safari/537... | code_fim | hard | {
"lang": "python",
"repo": "maerson/daili",
"path": "/plugin/provider.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maerson/daili path: /plugin/provider.py
://ipinfo.io/ip',
# 'http://ipv4.icanhazip.com/',
# 'http://myexternalip.com/raw',
# 'http://ipinfo.io/ip',
# 'http://ifconfig.io/ip',
def update_geoip_db():
print('The update in progress, please waite for a while...')
filename = 'GeoLite2-City.tar... | code_fim | hard | {
"lang": "python",
"repo": "maerson/daili",
"path": "/plugin/provider.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SeisSol/Matrices path: /src/quad_rules/quadrature.py
import numpy as np
from . import WitherdenVincentTet
from . import WitherdenVincentTri
from . import GaussJacobi
def quad(nodes, weights, f):
"""
Compute the integral with a given quadrature rule
Parameters
----------
nod... | code_fim | hard | {
"lang": "python",
"repo": "SeisSol/Matrices",
"path": "/src/quad_rules/quadrature.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def visualize(nodes, weights, new_corners):
"""
Visualize a quadratur rule on a given element.
Parameters
----------
nodes : np.array of shape (n, d)
The nodes of the quadrature rule
weights : np.array of shape (n,)
The weights of the quadrature rule
new_corner... | code_fim | hard | {
"lang": "python",
"repo": "SeisSol/Matrices",
"path": "/src/quad_rules/quadrature.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bmoretz/Python-Playground path: /src/Classes/MSDS400/Module 2/minimize.py
# Minimize x1*x4( x1 + x2 + x3 ) + x3
# s.t.
# x1 * x2 * x3 * x4 >= 25
# x1**2 + x2**2 + x3**2 + x4**2 = 40
# 1 <= x1, x2, x3, x4 <= 5
# x0 = ( 1, 5, 5, 1 )
import numpy as np
from scipy.optimize import minimize
def objec... | code_fim | hard | {
"lang": "python",
"repo": "bmoretz/Python-Playground",
"path": "/src/Classes/MSDS400/Module 2/minimize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def constraint2( x ):
sum_sq = 40
for i in range( 4 ):
sum_sq = sum_sq - x[ i ] ** 2
return sum_sq
x0 = [ 1, 5, 5, 1 ]
print( objective( x0 ) )
b = ( 1.0, 10.0 )
bnds = ( b, b, b, b )
con1 = { 'type' : 'ineq', 'fun': constraint1 }
con2 = { 'type' : 'eq', 'fun': constraint2 }
cons = [ con1, con2 ]... | code_fim | medium | {
"lang": "python",
"repo": "bmoretz/Python-Playground",
"path": "/src/Classes/MSDS400/Module 2/minimize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, parent = None):
Frame.__init__(self, parent)
self.pack()
widget = Button(self, text = 'Quit', command = self.quit)
widget.pack(side = LEFT, expand = YES, fill = BOTH)
def quit(self):
answer = askokcancel('Verify exit', "Really quit?")
... | code_fim | medium | {
"lang": "python",
"repo": "ordinary-developer/education",
"path": "/py/m_lutz-programming_python-4_ed/code/ch_08/07-a_smart_and_reusable_quit_button/quitter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ordinary-developer/education path: /py/m_lutz-programming_python-4_ed/code/ch_08/07-a_smart_and_reusable_quit_button/quitter.py
"""
a Quit button that verifies exit requests;
to reuse, attach an instance to other GUIs, and re-pack as desired
"""
<|fim_suffix|> def quit(self):
answer =... | code_fim | hard | {
"lang": "python",
"repo": "ordinary-developer/education",
"path": "/py/m_lutz-programming_python-4_ed/code/ch_08/07-a_smart_and_reusable_quit_button/quitter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/horizon path: /openstack_dashboard/dashboards/admin/floating_ips/tables.py
# Copyright 2016 Letv Cloud Computing
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may ob... | code_fim | hard | {
"lang": "python",
"repo": "openstack/horizon",
"path": "/openstack_dashboard/dashboards/admin/floating_ips/tables.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class AdminReleaseFloatingIP(project_tables.ReleaseIPs):
pass
class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
def single(self, table, request, obj_id):
try:
fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
api.neutron.floating_ip_disa... | code_fim | hard | {
"lang": "python",
"repo": "openstack/horizon",
"path": "/openstack_dashboard/dashboards/admin/floating_ips/tables.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
api.neutron.floating_ip_disassociate(request, fip.id)
LOG.info('Disassociating Floating IP "%s".', obj_id)
messages.success(request,
_('Successfully disas... | code_fim | hard | {
"lang": "python",
"repo": "openstack/horizon",
"path": "/openstack_dashboard/dashboards/admin/floating_ips/tables.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_reduced_eda(prob_ids) -> list[tuple[np.ndarray, np.ndarray]]:
"""Reduzierte Datenpunkte.
Für jeden Probanden, `times, data`.
"""
filenames = [_vhdr_filename(p) for p in prob_ids]
points_per_sec = 5000
return compute_reduced_eda(points_per_sec, filenames)
def eda_long(b... | code_fim | medium | {
"lang": "python",
"repo": "C0C0AN/MD_thesis_JanOttoHeiland",
"path": "/script/eda/eda_collect.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: C0C0AN/MD_thesis_JanOttoHeiland path: /script/eda/eda_collect.py
"""Sammel EDA Daten und schreibe es in CSV Datei."""
import numpy as np
import pandas as pd
from blocks import load_blocks
from show_eda import DATEN, compute_reduced_eda
def index_prob_id(blocks):
"""Set prob_id in index."""... | code_fim | hard | {
"lang": "python",
"repo": "C0C0AN/MD_thesis_JanOttoHeiland",
"path": "/script/eda/eda_collect.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> duration = pd.DataFrame(index=bs.index)
for i in range(6):
duration[i] = bs[i + 1] - bs[i]
duration.to_csv("duration.tsv", sep="\t", float_format="%.2f")
blocks = index_prob_id(bs)
lf = eda_long(blocks)
lf.eda *= 1e6
lf.to_csv("eda_long.tsv", sep="\t", float_format="%7... | code_fim | hard | {
"lang": "python",
"repo": "C0C0AN/MD_thesis_JanOttoHeiland",
"path": "/script/eda/eda_collect.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gongtian1234/easy_leetcode path: /easyleetcode/leetcodes/Leetcode_021_Merge_Two_Sorted_Lists.py
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def make_list(arr):
head_node = None
p_node = None
for a in arr:
new_node = ListNode(a)
... | code_fim | hard | {
"lang": "python",
"repo": "gongtian1234/easy_leetcode",
"path": "/easyleetcode/leetcodes/Leetcode_021_Merge_Two_Sorted_Lists.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Solution(object):
def mergeTwoLists(self, l1, l2):
pos = dummyHead = ListNode(0)
while l1 is not None and l2 is not None:
if l1.val <= l2.val:
pos.next = l1
l1 = l1.next
else:
pos.next = l2
l... | code_fim | medium | {
"lang": "python",
"repo": "gongtian1234/easy_leetcode",
"path": "/easyleetcode/leetcodes/Leetcode_021_Merge_Two_Sorted_Lists.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_connection_manager_connect_as_master_successful():
hci_thread = MagicMock()
cb_thread = CallbackThread()
mgr = ConnectionManager(hci_thread, cb_thread)
address = Address("c9:ea:a5:b8:c8:10", AddressType.random)
assert mgr.find_connection_by_address(address) is None
conne... | code_fim | hard | {
"lang": "python",
"repo": "notmikeb/pybluetooth",
"path": "/tests/test_connection_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert connection.state == State.initiating
assert not connection.connected_event.is_set()
assert connection.disconnected_event.is_set()
with pytest.raises(TimeoutException):
connection.wait_until_connected(0)
connection.wait_until_disconnected(0)
cb_thread.dispatch_packet... | code_fim | hard | {
"lang": "python",
"repo": "notmikeb/pybluetooth",
"path": "/tests/test_connection_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: notmikeb/pybluetooth path: /tests/test_connection_manager.py
import binascii
import pytest
from pybluetooth.address import *
from pybluetooth.connection import ConnectionManager, Role, State
from pybluetooth.exceptions import *
from pybluetooth import CallbackThread
from scapy.layers.bluetooth i... | code_fim | hard | {
"lang": "python",
"repo": "notmikeb/pybluetooth",
"path": "/tests/test_connection_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Turn a pygments token list into a list of prompt_toolkit text fragments
(``(style_str, text)`` tuples).
"""
result = []
for token, text in token_list:
result.append(('class:' + _pygments_token_to_classname(token), text))
return result<|fim_prefix|># repo: Arrendi/... | code_fim | hard | {
"lang": "python",
"repo": "Arrendi/rice",
"path": "/rice/deps/prompt_toolkit/styles/pygments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Arrendi/rice path: /rice/deps/prompt_toolkit/styles/pygments.py
"""
Adaptor for building prompt_toolkit styles, starting from a Pygments style.
Usage::
from pygments.styles.tango import TangoStyle
style = style_from_pygments(pygments_style_cls=TangoStyle)
"""
from __future__ import unic... | code_fim | hard | {
"lang": "python",
"repo": "Arrendi/rice",
"path": "/rice/deps/prompt_toolkit/styles/pygments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def token_list_to_formatted_text(token_list):
"""
Turn a pygments token list into a list of prompt_toolkit text fragments
(``(style_str, text)`` tuples).
"""
result = []
for token, text in token_list:
result.append(('class:' + _pygments_token_to_classname(token), text))
... | code_fim | hard | {
"lang": "python",
"repo": "Arrendi/rice",
"path": "/rice/deps/prompt_toolkit/styles/pygments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def pre_set_grid(self):
set_grid = copy.copy(self.grid)
for yindex, row in enumerate(self.grid):
for xindex, cell in enumerate(row):
#object 1 IDK how to loop without breaking! *crying on the inside*
set_grid[5][0].alive = True
... | code_fim | hard | {
"lang": "python",
"repo": "Elisa-Alvarez/Conways-Game-Of-Life",
"path": "/src/game_window_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Elisa-Alvarez/Conways-Game-Of-Life path: /src/game_window_class.py
import pygame
import copy
import random
from cell_class import *
vec = pygame.math.Vector2
class Game_window:
def __init__(self, screen, x,y,):
self.screen = screen
self.pos = vec(x,y)
self.width, self... | code_fim | hard | {
"lang": "python",
"repo": "Elisa-Alvarez/Conways-Game-Of-Life",
"path": "/src/game_window_class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> color_grid = copy.copy(self.grid)
for yindex, row in enumerate(self.grid):
for xindex, cell in enumerate(row):
if cell.alive:
color_grid[yindex][xindex].set_color()
self.grid = color_grid
def pre... | code_fim | hard | {
"lang": "python",
"repo": "Elisa-Alvarez/Conways-Game-Of-Life",
"path": "/src/game_window_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: satra/nibabel path: /nibabel/tests/test_spatialimages.py
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along w... | code_fim | hard | {
"lang": "python",
"repo": "satra/nibabel",
"path": "/nibabel/tests/test_spatialimages.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@parametric
def test_data_dtype():
hdr = Header()
yield assert_equal(hdr.get_data_dtype(), np.dtype(np.float32))
hdr.set_data_dtype(np.float64)
yield assert_equal(hdr.get_data_dtype(), np.dtype(np.float64))
hdr.set_data_dtype('u2')
yield assert_equal(hdr.get_data_dtype(), np.dtype... | code_fim | hard | {
"lang": "python",
"repo": "satra/nibabel",
"path": "/nibabel/tests/test_spatialimages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@parametric
def test_read_data():
hdr = Header(np.int32, shape=(1,2,3), zooms=(3.0, 2.0, 1.0))
fobj = StringIO()
data = np.arange(6).reshape((1,2,3))
hdr.data_to_fileobj(data, fobj)
yield assert_equal(fobj.getvalue(),
data.astype(np.int32).tostring(order='F'))
... | code_fim | hard | {
"lang": "python",
"repo": "satra/nibabel",
"path": "/nibabel/tests/test_spatialimages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Marcelixoo/trip-planner path: /app/user/forms.py
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import ValidationError, DataRequired
from app.user.models import User
class DestinationForm(FlaskForm):
<|fim_suffix|> if user is not None... | code_fim | hard | {
"lang": "python",
"repo": "Marcelixoo/trip-planner",
"path": "/app/user/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = User.query.filter_by(email=email.data).first()
if user is not None:
raise ValidationError(
'Email already taken! Please use a different email address.'
)<|fim_prefix|># repo: Marcelixoo/trip-planner path: /app/user/forms.py
from flask_wtf im... | code_fim | hard | {
"lang": "python",
"repo": "Marcelixoo/trip-planner",
"path": "/app/user/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def NAND(x1, x2):
x = np.array([x1, x2])
w = np.array([-0.5, -0.5])
b = 0.7
tmp = np.sum(x*w) + b
if tmp <= 0:
return 0
else:
return 1
def XOR(x1, x2):
s1 = NAND(x1, x2)
s2 = OR(x1, x2)
return AND(s1, s2)
print(XOR(0,0))
print(XOR(1,0))
print(XOR(0,1))... | code_fim | hard | {
"lang": "python",
"repo": "Adrian123K/dl",
"path": "/01-2.perceptron1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adrian123K/dl path: /01-2.perceptron1.py
# 15
import numpy as np
def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1 * w1 + x2 * w2
if tmp <= theta:
return 0
else:
return 1
inputs = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
target = np.array([0, 0, 0, 1]).re... | code_fim | medium | {
"lang": "python",
"repo": "Adrian123K/dl",
"path": "/01-2.perceptron1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 18
import numpy as np
def AND(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5, 0.5])
b = -0.7
tmp = np.sum(x*w) + b
if tmp <= 0:
return 0
else:
return 1
def OR(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5, 0.5])
b = -0.4
tmp = np.sum(x*w) +... | code_fim | hard | {
"lang": "python",
"repo": "Adrian123K/dl",
"path": "/01-2.perceptron1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ch21yyds/vgtr path: /work/utils/utils.py
# -*- coding: utf-8 -*-
import os
import cv2
import random
import shutil
import numpy as np
import torch
import torch.backends.cudnn as cudnn
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __... | code_fim | hard | {
"lang": "python",
"repo": "ch21yyds/vgtr",
"path": "/work/utils/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def lr_poly(base_lr, iter, max_iter, power):
return base_lr * ((1 - float(iter) / max_iter) ** (power))
def adjust_learning_rate(optimizer, epoch, lr, drop_list=(70, 100)):
if epoch in drop_list:
lr = lr * 0.1
optimizer.param_groups[0]['lr'] = lr
if len(optimize... | code_fim | hard | {
"lang": "python",
"repo": "ch21yyds/vgtr",
"path": "/work/utils/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rudolfbyker/venus6 path: /input_messages.py
from common import byteorder
from messages import Message
class InputMessage(Message):
"""
A Message from the host to the GPS unit.
"""
def __str__(self):
s = "GPS < Host: {}".format(type(self).name)
for v in self.valu... | code_fim | hard | {
"lang": "python",
"repo": "rudolfbyker/venus6",
"path": "/input_messages.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__()
# from fields import
# self.values = [
#
# ]
class ConfigurePositionPinningMessage(InputMessage):
"""
>>> bytes(ConfigurePositionPinningMessage(True)).hex()
'a0a100023901380d0a'
>>> bytes(ConfigurePositionPinningMessage(False))... | code_fim | hard | {
"lang": "python",
"repo": "rudolfbyker/venus6",
"path": "/input_messages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)<|fim_prefix|># repo: Rodgersouko/insta path: /instagram/urls.py
from django.urls import path, include, re_path
from . im... | code_fim | hard | {
"lang": "python",
"repo": "Rodgersouko/insta",
"path": "/instagram/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rodgersouko/insta path: /instagram/urls.py
from django.urls import path, include, re_path
from . import views
from django.conf import settings
from django.conf.urls.static import static
<|fim_suffix|>]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA... | code_fim | hard | {
"lang": "python",
"repo": "Rodgersouko/insta",
"path": "/instagram/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dvejmz/meetup-notifier path: /email_compose.py
def composeEmail(groupName, eventStartDateTime, answers):
messageAnswers = '\n'.join(answers)
return f'<|fim_suffix|> on {str(eventStartDateTime)} (UTC)\n\n{messageAnswers}'<|fim_middle|>RSVP answers for the {groupName} MeetUp event scheduled | code_fim | easy | {
"lang": "python",
"repo": "dvejmz/meetup-notifier",
"path": "/email_compose.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> on {str(eventStartDateTime)} (UTC)\n\n{messageAnswers}'<|fim_prefix|># repo: dvejmz/meetup-notifier path: /email_compose.py
def composeEmail(groupName, eventStartDateTime, answers):
messageAnswers = '\n'.join(answers)
return f'<|fim_middle|>RSVP answers for the {groupName} MeetUp event scheduled | code_fim | easy | {
"lang": "python",
"repo": "dvejmz/meetup-notifier",
"path": "/email_compose.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tchlux/VarSys path: /Code_[2017-07-11]_Data_Comparison_Check/Resources/plotly_interface.py
max(max(diff), greatest_diff)
return greatest_diff
# Class for building a plotly plot
# ==========================================
class Plot:
def __init__(self, title="", x_title="x",... | code_fim | hard | {
"lang": "python",
"repo": "tchlux/VarSys",
"path": "/Code_[2017-07-11]_Data_Comparison_Check/Resources/plotly_interface.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> start = end = None
# Cycle through the elements of data
for i,tr in enumerate(self.to_reverse):
if (tr and start==None):
start = i
if (not tr and start!=None):
end = i+1
# Reverse that group of plot series
... | code_fim | hard | {
"lang": "python",
"repo": "tchlux/VarSys",
"path": "/Code_[2017-07-11]_Data_Comparison_Check/Resources/plotly_interface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Manage plotly reverse order bug (only happens with "tonext_")
self.reorder_data()
# Generate the figure
fig = plotly.graph_objs.Figure(data=data, layout=plot_layout)
# Create the html file and show in browser if appropriate
if html: create_html(fig, file_... | code_fim | hard | {
"lang": "python",
"repo": "tchlux/VarSys",
"path": "/Code_[2017-07-11]_Data_Comparison_Check/Resources/plotly_interface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bartekpacia/python-training path: /project_euler/0022.py
names = []
with open("0022.txt") as file:
for line in file:
names_in_line = map(lambda s: s[1:-1], line.split(","))
names.extend(names_in_line)
names.sort()
<|fim_suffix|> score = 0
for char in name:
sc... | code_fim | easy | {
"lang": "python",
"repo": "bartekpacia/python-training",
"path": "/project_euler/0022.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> score *= index
return score
total_name_score = 0
for index, name in enumerate(names):
total_name_score += name_score(name, index + 1)
print(total_name_score)<|fim_prefix|># repo: bartekpacia/python-training path: /project_euler/0022.py
names = []
with open("0022.txt") as file:
for li... | code_fim | medium | {
"lang": "python",
"repo": "bartekpacia/python-training",
"path": "/project_euler/0022.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qcoumes/dgeq path: /dgeq/joins.py
import operator
from functools import reduce
from typing import Any, Dict, Iterable, List, Optional, Set, Type, Union
from django.db import models
from . import utils
from .censor import Censor
from .exceptions import InvalidCommandError, NotARelatedFieldError
... | code_fim | hard | {
"lang": "python",
"repo": "qcoumes/dgeq",
"path": "/dgeq/joins.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for item in subquery:
row = utils.serialize_row(
item, self.fields, self._one_fields, self._many_fields, self.joins
)
rows.append(row)
return rows
def _fetch_unique(self, obj: models.Model) -> Optional[Dict[str, Any]]:
... | code_fim | hard | {
"lang": "python",
"repo": "qcoumes/dgeq",
"path": "/dgeq/joins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ROUTER_TYPES = [ROUTER_TYPE_TIER0, ROUTER_TYPE_TIER1]
LROUTERPORT_UPLINK = "LogicalRouterUplinkPort"
LROUTERPORT_DOWNLINK = "LogicalRouterDownLinkPort"
LROUTERPORT_LINKONTIER0 = "LogicalRouterLinkPortOnTIER0"
LROUTERPORT_LINKONTIER1 = "LogicalRouterLinkPortOnTIER1"
LROUTER_TYPES = [LROUTERPORT_UPLINK,
... | code_fim | hard | {
"lang": "python",
"repo": "yfauser/vmware-nsx",
"path": "/vmware_nsx/common/nsx_constants.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ATTACHMENT_TYPES = [ATTACHMENT_VIF, ATTACHMENT_LR]
# Replication modes
MTEP = "MTEP"
SOURCE = "SOURCE"
REPLICATION_MODES = [MTEP, SOURCE]
# Router type
ROUTER_TYPE_TIER0 = "TIER0"
ROUTER_TYPE_TIER1 = "TIER1"
ROUTER_TYPES = [ROUTER_TYPE_TIER0, ROUTER_TYPE_TIER1]
LROUTERPORT_UPLINK = "LogicalRouterUpli... | code_fim | hard | {
"lang": "python",
"repo": "yfauser/vmware-nsx",
"path": "/vmware_nsx/common/nsx_constants.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yfauser/vmware-nsx path: /vmware_nsx/common/nsx_constants.py
# Copyright 2015 VMware, Inc.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#... | code_fim | hard | {
"lang": "python",
"repo": "yfauser/vmware-nsx",
"path": "/vmware_nsx/common/nsx_constants.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update(self, instance, validated_data):
instance.temp_export_details = validated_data.pop("temp_export_details", instance.temp_export_details)
instance.proposed_return_date = validated_data.pop("proposed_return_date", instance.proposed_return_date)
instance.temp_direct_cont... | code_fim | hard | {
"lang": "python",
"repo": "uktrade/lite-api",
"path": "/api/applications/serializers/temporary_export_details.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uktrade/lite-api path: /api/applications/serializers/temporary_export_details.py
from django.utils import timezone
from rest_framework import serializers
from api.applications.models import BaseApplication
from api.applications.serializers.serializer_helper import validate_field
from lite_conten... | code_fim | hard | {
"lang": "python",
"repo": "uktrade/lite-api",
"path": "/api/applications/serializers/temporary_export_details.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = BaseApplication
fields = (
"temp_export_details",
"is_temp_direct_control",
"temp_direct_control_details",
"proposed_return_date",
)
def validate(self, data):
validated_data = super().validate(data)
valid... | code_fim | hard | {
"lang": "python",
"repo": "uktrade/lite-api",
"path": "/api/applications/serializers/temporary_export_details.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nahuelhds/diffengine path: /diffengine/utils.py
import os
import yaml
def generate_config(home, content):
<|fim_suffix|> yaml.dump(content, open(config_file, "w"), default_flow_style=False)<|fim_middle|> config_file = os.path.join(home, "config.yaml")
if not os.path.isdir(home):
... | code_fim | medium | {
"lang": "python",
"repo": "nahuelhds/diffengine",
"path": "/diffengine/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> yaml.dump(content, open(config_file, "w"), default_flow_style=False)<|fim_prefix|># repo: nahuelhds/diffengine path: /diffengine/utils.py
import os
import yaml
def generate_config(home, content):
<|fim_middle|> config_file = os.path.join(home, "config.yaml")
if not os.path.isdir(home):
... | code_fim | medium | {
"lang": "python",
"repo": "nahuelhds/diffengine",
"path": "/diffengine/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amisha-w/PackTravel path: /publish/models.py
from django.db import models
# declare a new model with a name "GeeksModel"
class Ride(models.Model):
# fields of the model
destination = models.TextField()
rideDate = models.TextField()
class Meta:
<|fim_suffix|> # renames the in... | code_fim | easy | {
"lang": "python",
"repo": "amisha-w/PackTravel",
"path": "/publish/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # renames the instances of the model
# with their title name
def __str__(self):
return self.title<|fim_prefix|># repo: amisha-w/PackTravel path: /publish/models.py
from django.db import models
# declare a new model with a name "GeeksModel"
class Ride(models.Model):
# fields of t... | code_fim | easy | {
"lang": "python",
"repo": "amisha-w/PackTravel",
"path": "/publish/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sec-Fork/SiteScan path: /Third/wafw00f/entrance.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2020, WAFW00F Developers.
See the LICENSE file for copying permission.
'''
# For keeping python2 support for now
from __future__ import print_function
import csv
import io
import js... | code_fim | hard | {
"lang": "python",
"repo": "Sec-Fork/SiteScan",
"path": "/Third/wafw00f/entrance.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> wafdetections = dict()
plugin_dict = load_plugins()
result_dict = {}
for plugin_module in plugin_dict.values():
wafdetections[plugin_module.NAME] = plugin_module.is_waf
# Check for prioritized ones first, then check those added externally
checklist = wafdetectionsprio
... | code_fim | hard | {
"lang": "python",
"repo": "Sec-Fork/SiteScan",
"path": "/Third/wafw00f/entrance.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gistable/gistable path: /all-gists/2635832/snippet.py
from types import FunctionType
def percol_specialkey_replace(fn):
def decofn(self, key):
if len(key) > 2 and key[0] == "<" and key[-1] == ">":
key = key[1:-1]
return fn(self, key)
return decofn
class Chain... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/2635832/snippet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @percol_add_command
def toggle_mark_and_previous(self):
self.toggle_mark()
self.select_previous()
@percol_add_command
def toggle_mark_select_under(self):
index = self.model.index
mark = not self.model.get_mark(index)
for mark_index in range(index, s... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/2635832/snippet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ao in pull("http://schoolido.lu/api/cards/"):
DB.ingest_api_object(ao)
DB.disconnect()
if __name__ == '__main__':
import plac; plac.call(main)<|fim_prefix|># repo: summertriangle-dev/more-ll-tools path: /snowcone/seed_from_live.py
import requests
import json
import syncstate
fro... | code_fim | easy | {
"lang": "python",
"repo": "summertriangle-dev/more-ll-tools",
"path": "/snowcone/seed_from_live.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: summertriangle-dev/more-ll-tools path: /snowcone/seed_from_live.py
import requests
import json
import syncstate
from sukutomo import pull
<|fim_suffix|>if __name__ == '__main__':
import plac; plac.call(main)<|fim_middle|>def main(out):
DB = syncstate.State(out)
for ao in pull("http:... | code_fim | medium | {
"lang": "python",
"repo": "summertriangle-dev/more-ll-tools",
"path": "/snowcone/seed_from_live.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not viewer_policy:
severity = 3
message = 'No viewer policy found for this distribution'
elif viewer_policy == 'allow-all':
severity = 2
message = 'Distribution should only allow HTTPS traffic'
elif view... | code_fim | hard | {
"lang": "python",
"repo": "coolfriends/oil",
"path": "/oil/plugins/aws/cloudfront/https/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.results.append({
'resource': resource_arn,
'region': 'aws-global',
'severity': severity,
'message': message
})
return self.results<|fim_prefix|># repo: coolfriends/oil path: /oil/plugins/aws/cloudfront/h... | code_fim | hard | {
"lang": "python",
"repo": "coolfriends/oil",
"path": "/oil/plugins/aws/cloudfront/https/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: coolfriends/oil path: /oil/plugins/aws/cloudfront/https/__init__.py
from oil.plugins import Plugin
class HTTPSPlugin(Plugin):
name = 'https'
provider = 'aws'
service = 'cloudfront'
requirements = {
'distributions': ['aws', 'cloudfront', 'list_distributions']
}
... | code_fim | hard | {
"lang": "python",
"repo": "coolfriends/oil",
"path": "/oil/plugins/aws/cloudfront/https/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> jinad_client = JinaDClient(host=HOST, port=JINAD_PORT)
assert jinad_client.alive, 'cannot reach jinad'
storage_flow_id, query_flow_id, workspace_id = create_flows()
# start rolling update in the background
Thread(target=dump_and_roll_update, args=(storage_flow_id, ... | code_fim | medium | {
"lang": "python",
"repo": "nikosNalmpantis/examples",
"path": "/wikipedia-sentences-query-while-indexing/tests/test_query_while_indexing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nikosNalmpantis/examples path: /wikipedia-sentences-query-while-indexing/tests/test_query_while_indexing.py
import time
from threading import Thread
from jina import Document, __default_host__, Client
from daemon.clients import JinaDClient
from jina.logging.logger import JinaLogger
HOST = __def... | code_fim | medium | {
"lang": "python",
"repo": "nikosNalmpantis/examples",
"path": "/wikipedia-sentences-query-while-indexing/tests/test_query_while_indexing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>a=(b*h)/2
#Datos de Salida
print("El área es: ", area)<|fim_prefix|># repo: WilliamGabCh/FP_Group-2_WGCH path: /AreaTriangulo.py
#declarar variables
print("Ejercicios 01: Area del Triangulo")
#Datos de entrada)
b=int(input("ingrese Ba<|fim_middle|>se: "))
h=int(input("Ingrese Altura: "))
#Proceso
are | code_fim | easy | {
"lang": "python",
"repo": "WilliamGabCh/FP_Group-2_WGCH",
"path": "/AreaTriangulo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WilliamGabCh/FP_Group-2_WGCH path: /AreaTriangulo.py
#declarar variables
print("Ejercicios 01: Area del Triangulo")
#Datos de entrada)
b=int(input("ingrese Ba<|fim_suffix|>a=(b*h)/2
#Datos de Salida
print("El área es: ", area)<|fim_middle|>se: "))
h=int(input("Ingrese Altura: "))
#Proceso
are | code_fim | easy | {
"lang": "python",
"repo": "WilliamGabCh/FP_Group-2_WGCH",
"path": "/AreaTriangulo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args:
(av_name, av_type) = args
av_name = os.path.splitext(os.path.basename(av_name))[0]
# If the config file states the exercise should be removed, remove it
if av_name in exercises and 'remove' in exercises[av_name] and exercises[av_name]['remove']:
... | code_fim | hard | {
"lang": "python",
"repo": "fionacsukcl/OpenDSA-stable",
"path": "/tools/ODSA_RST_Module.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fionacsukcl/OpenDSA-stable path: /tools/ODSA_RST_Module.py
import os
import datetime
import re
from string import whitespace as ws
from config_templates import *
# Parses the arguments from a Sphinx directive, prints error messages if the directive doesn't match the expected format
def parse_dir... | code_fim | hard | {
"lang": "python",
"repo": "fionacsukcl/OpenDSA-stable",
"path": "/tools/ODSA_RST_Module.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If the config file states the exercise should be removed, remove it
if av_name in exercises and 'remove' in exercises[av_name] and exercises[av_name]['remove']:
print console_msg_prefix + 'Removing: ' + av_name
# Config file states exercise should be removed,... | code_fim | hard | {
"lang": "python",
"repo": "fionacsukcl/OpenDSA-stable",
"path": "/tools/ODSA_RST_Module.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RoosDaniel/Fadderjobb path: /fadderanmalan/utils/misc.py
from django.db.models import Q
from django.contrib.auth import get_user_model
<|fim_suffix|>
# Removes all jobs that the user cannot view due to insufficient permissions
def filter_jobs_for_user(user: User, jobs):
if not user.is_superu... | code_fim | easy | {
"lang": "python",
"repo": "RoosDaniel/Fadderjobb",
"path": "/fadderanmalan/utils/misc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not user.is_superuser:
jobs = jobs.filter(Q(only_visible_to__in=user.groups.all()) | Q(only_visible_to__isnull=True))
return jobs<|fim_prefix|># repo: RoosDaniel/Fadderjobb path: /fadderanmalan/utils/misc.py
from django.db.models import Q
from django.contrib.auth import get_user_model... | code_fim | medium | {
"lang": "python",
"repo": "RoosDaniel/Fadderjobb",
"path": "/fadderanmalan/utils/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Removes all jobs that the user cannot view due to insufficient permissions
def filter_jobs_for_user(user: User, jobs):
if not user.is_superuser:
jobs = jobs.filter(Q(only_visible_to__in=user.groups.all()) | Q(only_visible_to__isnull=True))
return jobs<|fim_prefix|># repo: RoosDaniel/Fa... | code_fim | easy | {
"lang": "python",
"repo": "RoosDaniel/Fadderjobb",
"path": "/fadderanmalan/utils/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert (224, 224, 3) == deduce_input_shape()
assert (256, 256, 3) == deduce_input_shape(default_size=256)
assert (128, 128, 1) == deduce_input_shape((128, 128, 1))
assert (128, 128, 3) == deduce_input_shape((128, 128, 3), weights="imagenet")
assert (3, 128, 128) == deduce_input_shape((... | code_fim | hard | {
"lang": "python",
"repo": "carnotresearch/cr-vision",
"path": "/tests/cnn/test_default_input_shape.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carnotresearch/cr-vision path: /tests/cnn/test_default_input_shape.py
from cr.vision.dl.nets.cnn.utils import *
import pytest
def test_data_format():
check_data_format("channels_first")
check_data_format("channels_last")
with pytest.raises(ValueError):
check_data_format("cha... | code_fim | hard | {
"lang": "python",
"repo": "carnotresearch/cr-vision",
"path": "/tests/cnn/test_default_input_shape.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert 1 == get_num_channels((224, 224))
assert 3 == get_num_channels((224, 224, 3))
assert 3 == get_num_channels((3, 224, 224), 'channels_first')
assert 3 == get_num_channels((224, 224, 3), 'channels_last')
def test_check_min_size():
check_min_size((None, None), 32)
check_min_si... | code_fim | hard | {
"lang": "python",
"repo": "carnotresearch/cr-vision",
"path": "/tests/cnn/test_default_input_shape.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liuc1601/ansible-role-nginx path: /molecule/common/test_default/test_default.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_nginx_is_installed(host):
<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "liuc1601/ansible-role-nginx",
"path": "/molecule/common/test_default/test_default.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ngx = host.service("nginx")
assert ngx.is_running
assert ngx.is_enabled
def test_hosts_file(host):
ngx = host.file('/etc/hosts')
assert ngx.exists
assert ngx.user == 'root'
assert ngx.group == 'root'
def test_endpoint(host):
command = """curl -I http://localhost/"""
... | code_fim | medium | {
"lang": "python",
"repo": "liuc1601/ansible-role-nginx",
"path": "/molecule/common/test_default/test_default.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_endpoint(host):
command = """curl -I http://localhost/"""
cmd = host.run(command)
assert '200 OK' in cmd.stdout<|fim_prefix|># repo: liuc1601/ansible-role-nginx path: /molecule/common/test_default/test_default.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = tes... | code_fim | hard | {
"lang": "python",
"repo": "liuc1601/ansible-role-nginx",
"path": "/molecule/common/test_default/test_default.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @params.setter
def params(self, value):
self._params = value
@property
def service_code(self):
return self._service_code
@service_code.setter
def service_code(self, value):
self._service_code = value
@property
def uri(self):
return self._uri... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/AnttechAiCvUaIdentifyModel.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not d:
return None
o = AnttechAiCvUaIdentifyModel()
if 'attributes' in d:
o.attributes = d['attributes']
if 'm_app_id' in d:
o.m_app_id = d['m_app_id']
if 'params' in d:
o.params = d['params']
if 'service_co... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/AnttechAiCvUaIdentifyModel.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alipay/alipay-sdk-python-all path: /alipay/aop/api/domain/AnttechAiCvUaIdentifyModel.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
class AnttechAiCvUaIdentifyModel(object):
def __init__(self):
self._attributes = N... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/AnttechAiCvUaIdentifyModel.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jdrew1303/pyBusylight path: /pybusylight/color_constants.py
"""Provide RGB color constants and a colors dictionary with
elements formatted: colors[colorname] = CONSTANT"""
from collections import namedtuple, OrderedDict
Color = namedtuple('RGB','red, green, blue')
colors = {} #dict of colors
c... | code_fim | hard | {
"lang": "python",
"repo": "jdrew1303/pyBusylight",
"path": "/pybusylight/color_constants.py",
"mode": "psm",
"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.