text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: dieg0varela/holbertonschool-higher_level_programming path: /0x0F-python-object_relational_mapping/2-my_filter_states.py
#!/usr/bin/python3
'''List all states in the DB'''
import MySQLdb
import sys
argv = sys.argv
<|fim_suffix|> db = MySQLdb.connect(host="localhost", port=3306, user=user,
... | code_fim | medium | {
"lang": "python",
"repo": "dieg0varela/holbertonschool-higher_level_programming",
"path": "/0x0F-python-object_relational_mapping/2-my_filter_states.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> db = MySQLdb.connect(host="localhost", port=3306, user=user,
passwd=passwd, db=db_name, charset="utf8")
cursor = db.cursor()
querry = ("SELECT * FROM states WHERE name LIKE BINARY '" +
"{}".format(state) + "' ORDER BY id")
cursor.execute(querry)
r... | code_fim | medium | {
"lang": "python",
"repo": "dieg0varela/holbertonschool-higher_level_programming",
"path": "/0x0F-python-object_relational_mapping/2-my_filter_states.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = x+y
x = x+1
x = x+3
# x = x * 2
# x = x * 0.5
return x
model = SampleModel()
x = torch.randn(1, 3, 24, 24, device='cpu')
torch.onnx.export(model,
x,
"model.onnx",
verbose=False,)
graph = taso.load_onnx("./model.onnx")
print("\n cost = {}".f... | code_fim | medium | {
"lang": "python",
"repo": "aghinsa/taso_demo",
"path": "/0/taso_sample_model2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>model = SampleModel()
x = torch.randn(1, 3, 24, 24, device='cpu')
torch.onnx.export(model,
x,
"model.onnx",
verbose=False,)
graph = taso.load_onnx("./model.onnx")
print("\n cost = {}".format(graph.cost()))
new_graph = taso.optimize(graph, alpha = 1.0, budget = 1000, print_subst=True)
print("\n... | code_fim | medium | {
"lang": "python",
"repo": "aghinsa/taso_demo",
"path": "/0/taso_sample_model2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aghinsa/taso_demo path: /0/taso_sample_model2.py
import taso
import onnx
import torch
import torch.nn as nn
import torchvision.models as models
class SampleModel(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3,3,3,padding=1)
self.conv2 = n... | code_fim | medium | {
"lang": "python",
"repo": "aghinsa/taso_demo",
"path": "/0/taso_sample_model2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hirico/supic path: /pycalc/api.py
# This python file need to be run on the zerorpc server. Call the member method through zerorpc
from __future__ import print_function
from enhance import supic_process as real_predict_sr
import sys
import zerorpc
import argument_sr
from monodepth_inference import... | code_fim | hard | {
"lang": "python",
"repo": "Hirico/supic",
"path": "/pycalc/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ render and store temp depth image in output_dir """
try:
result = real_predict_depth(input_path, output_dir)
reset_default_graph()
return result
except Exception as e:
return '!ERROR' + str(e)
def save_file(self, input_path, ... | code_fim | medium | {
"lang": "python",
"repo": "Hirico/supic",
"path": "/pycalc/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jonathankamau/my-dsa-snippets path: /sorting_algorithms/heap_sort/heap_sort.py
'''
This is a sorting technique that involves building a binary heap from a given
array and then using the heap to sort the array.
A binary heap is a complete binary tree where the parent node is either
greater or sm... | code_fim | hard | {
"lang": "python",
"repo": "jonathankamau/my-dsa-snippets",
"path": "/sorting_algorithms/heap_sort/heap_sort.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if largest != index:
list_of_values[index], list_of_values[largest] = (
list_of_values[largest], list_of_values[index])
make_heap(list_of_values, n, largest)
def heap_sort(list_of_values):
n = len(list_of_values)
for index in range(n, -1, -1):
make_heap(... | code_fim | medium | {
"lang": "python",
"repo": "jonathankamau/my-dsa-snippets",
"path": "/sorting_algorithms/heap_sort/heap_sort.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> nodes = []
collect_nodes(data, nodes)
nodes_dict = {n.name: n for n in nodes}
while any(n.angles is None for n in nodes):
for n in nodes:
parent_name, parent_side_idx = find_parent(nodes, n.name)
if parent_name is None:
# This is a root node... | code_fim | hard | {
"lang": "python",
"repo": "mp4096/tikzor",
"path": "/tikzor",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mp4096/tikzor path: /tikzor
#!/usr/bin/env python3
import sys
import yaml
STICK_LENGTH = 0.6
NODE_DIAMETER = 0.8
class Node():
def __init__(self, name):
self.name = name
self.parent_idx = None
self.children_nodes = {}
self.num_modes = 0
self.angles... | code_fim | hard | {
"lang": "python",
"repo": "mp4096/tikzor",
"path": "/tikzor",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openGDA/gda-diamond path: /configurations/i06-shared/scripts/i06shared/commands/beamline.py
from gda.jython.commands.GeneralCommands import alias
from Diamond.Utility.BeamlineFunctions import BeamlineFunctionClass
from gda.configuration.properties import LocalProperties
print("-"*100)
print("cre... | code_fim | medium | {
"lang": "python",
"repo": "openGDA/gda-diamond",
"path": "/configurations/i06-shared/scripts/i06shared/commands/beamline.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def setDir(newSubDir):
beamlinefunction.setSubDir(newSubDir);
def setdir(newSubDir):
beamlinefunction.setSubDir(newSubDir);
alias("lastscan")
alias("getTitle"); alias("gettitle")
alias("setTitle"); alias("settitle")
alias("getVisit"); alias("getvisit")
alias("setVisit"); alias("setvisit")
alias("... | code_fim | hard | {
"lang": "python",
"repo": "openGDA/gda-diamond",
"path": "/configurations/i06-shared/scripts/i06shared/commands/beamline.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cesaralba/jimenezIntelligence path: /fixers/AddTraducJugadores.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from configargparse import ArgumentParser
# from SMACB.MercadoPage import MercadoPageContent
from SMACB.TemporadaACB import TemporadaACB
# from Utils.Misc import ReadFile
if __name... | code_fim | hard | {
"lang": "python",
"repo": "cesaralba/jimenezIntelligence",
"path": "/fixers/AddTraducJugadores.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for trad in args.trads:
try:
newCod, newNombre = trad.split(':', maxsplit=1)
except ValueError:
print("AddTraducJugadores: Traducción '%s' incorrecta. Formato debe ser codigo:nombre. Ignorando" % trad)
continue
print("AddTraducJugadores: aña... | code_fim | medium | {
"lang": "python",
"repo": "cesaralba/jimenezIntelligence",
"path": "/fixers/AddTraducJugadores.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
parser = ArgumentParser()
parser.add('-i', dest='tempin', type=str, env_var='SM_TEMPIN', required=False)
parser.add('-o', dest='tempout', type=str, env_var='SM_TEMPOUT', required=False)
parser.add_argument(dest='trads', type=str, nargs='*')
args = parser.pa... | code_fim | medium | {
"lang": "python",
"repo": "cesaralba/jimenezIntelligence",
"path": "/fixers/AddTraducJugadores.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vipinksaini/ChatBot path: /Rasa_Foodie_ChatBoat/run_app.py
from rasa_core.channels import HttpInputChannel
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_slack_connector import SlackInput
import ruamel.yaml as yaml
import warnings
<|fim_suffix|>... | code_fim | hard | {
"lang": "python",
"repo": "vipinksaini/ChatBot",
"path": "/Rasa_Foodie_ChatBoat/run_app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/restaurantnlu')
agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter)
input_channel = SlackInput('xoxp-Verf.Key', #app verification token
'xoxb-bot.key', # bot verification token
'slack.key', # slack verification to... | code_fim | medium | {
"lang": "python",
"repo": "vipinksaini/ChatBot",
"path": "/Rasa_Foodie_ChatBoat/run_app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class SexualOrientationSerializer(serializers.ModelSerializer):
class Meta:
model = SexualOrientation
fields = '__all__'
class DatesProfilesListSerializer(serializers.ModelSerializer):
age = serializers.SerializerMethodField("get_age_name")
photos = PhotoListSerializer(many=T... | code_fim | hard | {
"lang": "python",
"repo": "AristokratM/vooko_DRF",
"path": "/profiles/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AristokratM/vooko_DRF path: /profiles/serializers.py
from django.contrib.auth import get_user_model
from rest_framework import serializers
from .models import (
FriendsProfile,
Photo,
Nationality,
AcquaintanceRequest,
DatesProfile,
Match,
SexualOrientation,
Interes... | code_fim | hard | {
"lang": "python",
"repo": "AristokratM/vooko_DRF",
"path": "/profiles/serializers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mpaisner/projects path: /modules/3d.py
import math
class Vector3d:
def __init__(self, xyz):
self.x, self.y, self.z = xyx
class Point3d:
def __init__(self, xyz):
self.x, self.y, self.z = xyz
def add_vect(self, vect):
return Point3d((self.x + vect.x, self.y + vect.y, self.z + v... | code_fim | medium | {
"lang": "python",
"repo": "mpaisner/projects",
"path": "/modules/3d.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Point3d((self.x * xyz[0], self.y * xyz[1], self.z * xyz[2]))
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ", " + str(self.z) + ")"
def calc_distance(triangle,
point = Point3d((1, 2, 1))
print point.rotate_y(math.radians(45))
print point.rotate_y(math.radians(60)).r... | code_fim | hard | {
"lang": "python",
"repo": "mpaisner/projects",
"path": "/modules/3d.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def translate(self, xyz):
return Point3d((self.x + xyz[0], self.y + xyz[1], self.z + xyz[2]))
def rotate_x(self, theta):
cos = math.cos(theta)
sin = math.sin(theta)
return Point3d((self.x, self.y * cos - self.z * sin, self.y * sin + self.z * cos))
def rotate_z(self, theta):
cos = math.cos... | code_fim | medium | {
"lang": "python",
"repo": "mpaisner/projects",
"path": "/modules/3d.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcvenkat/Python-Programs path: /02-Flask-Basics/05-Routing_Exercise.py
# Set up your imports here!
# import ...
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
<|fim_suffix|>def puppylatin(name):
pupname = ' '
if name[ -1] == 'y':
pupnam... | code_fim | medium | {
"lang": "python",
"repo": "mcvenkat/Python-Programs",
"path": "/02-Flask-Basics/05-Routing_Exercise.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '<h1> Your puppylatin name is :{}'.format(pupname)
if __name__ == '__main__':
app.run()<|fim_prefix|># repo: mcvenkat/Python-Programs path: /02-Flask-Basics/05-Routing_Exercise.py
# Set up your imports here!
# import ...
from flask import Flask
from flask import request
app = Flask(__nam... | code_fim | hard | {
"lang": "python",
"repo": "mcvenkat/Python-Programs",
"path": "/02-Flask-Basics/05-Routing_Exercise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ivan985/learning path: /homework_10/mysite/mycourse/management/commands/factory_mixer.py
from mixer.backend.django import mixer
from django.core.management import BaseCommand
from mycourse.models import Course, Teacher, Lesson
<|fim_suffix|> courses = mixer.cycle(20).blend(Course)
... | code_fim | easy | {
"lang": "python",
"repo": "ivan985/learning",
"path": "/homework_10/mysite/mycourse/management/commands/factory_mixer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Command(BaseCommand):
def handle(self, *args, **options):
create_all()<|fim_prefix|># repo: ivan985/learning path: /homework_10/mysite/mycourse/management/commands/factory_mixer.py
from mixer.backend.django import mixer
from django.core.management import BaseCommand
from mycou... | code_fim | medium | {
"lang": "python",
"repo": "ivan985/learning",
"path": "/homework_10/mysite/mycourse/management/commands/factory_mixer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def rewrite_mesh(config, array_width):
# honestly, the structure is kinda unnatural...
pe_subtree = config['architecture']['subtree'][0]['subtree'][0] # FIXME: this is not generic enough
pe_name = pe_subtree['name']
num_pe_prev = re.findall(r'\d+', pe_name)[-1]
num_pe_new = array_widt... | code_fim | hard | {
"lang": "python",
"repo": "617707897/procrustes-timeloop-model",
"path": "/scripts/timeloop.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 617707897/procrustes-timeloop-model path: /scripts/timeloop.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions... | code_fim | hard | {
"lang": "python",
"repo": "617707897/procrustes-timeloop-model",
"path": "/scripts/timeloop.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> web_simulator = web_simulators.get(num_sample)
if not web_simulator:
web_simulator = create_simulator(default_web_simulator.data_feeder,
default_web_simulator.model_path,
num_sample)
... | code_fim | hard | {
"lang": "python",
"repo": "mokemokechicken/event_simulator",
"path": "/src/event_simulator/web/server.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> simulator_config = SmallConfig()
simulator_config.batch_size = num_sample
with tf.Graph().as_default():
web_simulator = WebSimulator()
web_simulator.setup(data_feeder, tf.Session(), simulator_config, model_path)
return web_simulator
######
import tensorflow as tf
impor... | code_fim | hard | {
"lang": "python",
"repo": "mokemokechicken/event_simulator",
"path": "/src/event_simulator/web/server.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mokemokechicken/event_simulator path: /src/event_simulator/web/server.py
# coding: utf8
import sys
from pandas import json
from bottle import route, run, static_file, get, post, request
from event_simulator.lib.data_feeder import DataFeeder
from event_simulator.lib.ptb_model import SmallConfig
... | code_fim | hard | {
"lang": "python",
"repo": "mokemokechicken/event_simulator",
"path": "/src/event_simulator/web/server.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: staryash/qa-instance path: /filtered_files.py
# -*- coding: utf-8 -*-
import shutil
import os
<|fim_suffix|>lines = open(URL_LIST_FILE).readlines()
for src_file in lines:
dest_file = dest_base_dir + src_file.rstrip()
print('src_file:', src_file, ', dest_file:', dest_file)
os.makedirs(os.p... | code_fim | medium | {
"lang": "python",
"repo": "staryash/qa-instance",
"path": "/filtered_files.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lines = open(URL_LIST_FILE).readlines()
for src_file in lines:
dest_file = dest_base_dir + src_file.rstrip()
print('src_file:', src_file, ', dest_file:', dest_file)
os.makedirs(os.path.dirname(dest_file), exist_ok=True)
shutil.copy(src_file.rstrip(), dest_file)<|fim_prefix|># repo: staryash/qa-in... | code_fim | medium | {
"lang": "python",
"repo": "staryash/qa-instance",
"path": "/filtered_files.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: staryash/qa-instance path: /filtered_files.py
# -*- coding: utf-8 -*-
import shutil
import os
URL_LIST_FILE = './noisy2hin2.txt'
<|fim_suffix|>lines = open(URL_LIST_FILE).readlines()
for src_file in lines:
dest_file = dest_base_dir + src_file.rstrip()
print('src_file:', src_file, ', dest_f... | code_fim | medium | {
"lang": "python",
"repo": "staryash/qa-instance",
"path": "/filtered_files.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Exercise(models.Model):
name = models.CharField(max_length=50)
classification = models.ForeignKey(Classification, on_delete=models.CASCADE)
target_muscle = models.CharField(max_length=50)
apparatus = models.CharField(max_length=50)
instructions = models.ForeignKey(Instruction, on... | code_fim | hard | {
"lang": "python",
"repo": "d-rolfe/exrx-django-react",
"path": "/exrx_backend/exrx/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: d-rolfe/exrx-django-react path: /exrx_backend/exrx/models.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
<|fim_suffix|> utility = models.CharField(max_length=50)
mechanics = models.CharField(max_length=50)
force = models.CharField(max_... | code_fim | medium | {
"lang": "python",
"repo": "d-rolfe/exrx-django-react",
"path": "/exrx_backend/exrx/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = models.CharField(max_length=50)
classification = models.ForeignKey(Classification, on_delete=models.CASCADE)
target_muscle = models.CharField(max_length=50)
apparatus = models.CharField(max_length=50)
instructions = models.ForeignKey(Instruction, on_delete=models.CASCADE)<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "d-rolfe/exrx-django-react",
"path": "/exrx_backend/exrx/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexforster/inparallel path: /inparallel/task.py
# -*- coding: UTF-8 -*-
#
# Copyright © 2016 Alex Forster. All rights reserved.
# This software is licensed under the 3-Clause ("New") BSD license.
# See the LICENSE file for details.
#
import sys
import os
import time
import functools
import thre... | code_fim | hard | {
"lang": "python",
"repo": "alexforster/inparallel",
"path": "/inparallel/task.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@util.decorator
def task(fn):
@six.wraps(fn)
def wrapper(*args, **kwargs):
global _pid, _thread, _tasks
parent, child = multiprocessing.Pipe()
parent_ex, child_ex = multiprocessing.Pipe()
child_pid = os.fork()
if child_pid == 0:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "alexforster/inparallel",
"path": "/inparallel/task.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ :type parent: multiprocessing.Connection
:type parent_ex: multiprocessing.Connection
:rtype future: concurrent.futures.Future
"""
global _pid, _thread, _tasks
if _pid != os.getpid():
_tasks = {}
_pid = os.getpid()
_thread = threading.Thread(t... | code_fim | hard | {
"lang": "python",
"repo": "alexforster/inparallel",
"path": "/inparallel/task.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (dirpath, _, filenames) in os.walk(path):
for filename in filenames:
yield os.path.join(dirpath, filename)
def main():
args = handle_args()
input_path = args.i[0]
n_of_frames = args.n[0]
counter = 0
list_files = get_files(input_path)
with os.fdopen(sys.stdout.fileno(), 'wb') as output... | code_fim | hard | {
"lang": "python",
"repo": "pepebecker/opencv-work",
"path": "/src/frames.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pepebecker/opencv-work path: /src/frames.py
#!/usr/bin/env python
import os
import io
import sys
import numpy as np
import argparse
from PIL import Image
def handle_args():
parser = argparse.ArgumentParser()
parser.add_argument('-i', nargs=1, type=str, metavar='input-dir', required=True, hel... | code_fim | hard | {
"lang": "python",
"repo": "pepebecker/opencv-work",
"path": "/src/frames.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> model=Imageupload
fields = '__all__'
class Postadd(forms.ModelForm):
class Meta:
model=Addpost
fields='__all__'<|fim_prefix|># repo: avi527/Blog-Using-Django path: /tech_first/tech1/techapp/form.py
from django import forms
from .models import Register,Imageuplo... | code_fim | medium | {
"lang": "python",
"repo": "avi527/Blog-Using-Django",
"path": "/tech_first/tech1/techapp/form.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avi527/Blog-Using-Django path: /tech_first/tech1/techapp/form.py
from django import forms
from .models import Register,Imageupload,Addpost
class Signupfrom(forms.ModelForm):
class Meta:
<|fim_suffix|> model=Addpost
fields='__all__'<|fim_middle|> model=Register
... | code_fim | hard | {
"lang": "python",
"repo": "avi527/Blog-Using-Django",
"path": "/tech_first/tech1/techapp/form.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: godotengine/godot path: /drivers/png/SCsub
#!/usr/bin/env python
Import("env")
env_png = env.Clone()
# Thirdparty source files
thirdparty_obj = []
if env["builtin_libpng"]:
thirdparty_dir = "#thirdparty/libpng/"
thirdparty_sources = [
"png.c",
"pngerror.c",
"p... | code_fim | hard | {
"lang": "python",
"repo": "godotengine/godot",
"path": "/drivers/png/SCsub",
"mode": "psm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if env["arch"].startswith("arm"):
if env.msvc: # Can't compile assembly files with MSVC.
env_thirdparty.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT"), 0])
else:
env_neon = env_thirdparty.Clone()
if "S_compiler" in env:
env_neon["CC"] = env... | code_fim | hard | {
"lang": "python",
"repo": "godotengine/godot",
"path": "/drivers/png/SCsub",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AP-MI-2021/lab-567-AlecsandraMuha path: /UserInterface/fisiernou.py
from Domain.librarie import creeazaVanzare
from Logic.CRUD import stergeVanzare, modificaVanzare, adaugaVanzare
from UserInterface.console import showAll
def comenzi(lista):
while True:
try:
print("help"... | code_fim | hard | {
"lang": "python",
"repo": "AP-MI-2021/lab-567-AlecsandraMuha",
"path": "/UserInterface/fisiernou.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> titlucarte = comanda[2]
gencarte = comanda[3]
pret = float(comanda[4])
tipreducere = comanda[5]
lista = modificaVanzare(id, titlucarte, gencarte, pret, tipreducere, lista)
... | code_fim | hard | {
"lang": "python",
"repo": "AP-MI-2021/lab-567-AlecsandraMuha",
"path": "/UserInterface/fisiernou.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>loss = loss(h_fc3, label_holder)
train = tf.train.AdamOptimizer(1e-4).minimize(loss)
top_k_op = tf.nn.in_top_k(h_fc3, label_holder, 1)
sess = tf.InteractiveSession()
tf.global_variables_initializer().run()
tf.train.start_queue_runners()
for step in range(max_steps):
strat_time = time.time()
image... | code_fim | hard | {
"lang": "python",
"repo": "spinoooo/deeplearning_test",
"path": "/cifar10/cifair.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spinoooo/deeplearning_test path: /cifar10/cifair.py
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 12 10:28:54 2017
@author: kb202
"""
import tensorflow as tf
import numpy as np
import time
import sys
#sys.path.append('/home/kb202/code/python/tensorflow/cifar10/')
sys.path.append('cifar10')
imp... | code_fim | hard | {
"lang": "python",
"repo": "spinoooo/deeplearning_test",
"path": "/cifar10/cifair.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ab.sort(key=lambda x: sum(x)+x[0], reverse=True)
ans = 0
for a, b in ab:
aoki -= a
taka += a + b
ans += 1
if taka > aoki:
break
print(ans)<|fim_prefix|># repo: arakoma/competitive_programming path: /contest/abc/abc187/d.py
N = int(input())
ab = [list(map(int, input().... | code_fim | easy | {
"lang": "python",
"repo": "arakoma/competitive_programming",
"path": "/contest/abc/abc187/d.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arakoma/competitive_programming path: /contest/abc/abc187/d.py
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
<|fim_suffix|>ab.sort(key=lambda x: sum(x)+x[0], reverse=True)
ans = 0
for a, b in ab:
aoki -= a
taka += a + b
ans += 1
if taka > ao... | code_fim | easy | {
"lang": "python",
"repo": "arakoma/competitive_programming",
"path": "/contest/abc/abc187/d.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> blog.delete()
self.redirect('/blog/?')<|fim_prefix|># repo: runnphoenix/udacity_fullstack_proj3 path: /handlers/deleteBlog.py
#!/usr/bin/python
from handler import Handler
import accessControl
<|fim_middle|>
class DeleteBlog(Handler):
@accessControl.user_logged_in
@accessContro... | code_fim | medium | {
"lang": "python",
"repo": "runnphoenix/udacity_fullstack_proj3",
"path": "/handlers/deleteBlog.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@accessControl.user_logged_in
@accessControl.post_exist
@accessControl.user_owns_blog
def get(self, blog_id, blog):
blog.delete()
self.redirect('/blog/?')<|fim_prefix|># repo: runnphoenix/udacity_fullstack_proj3 path: /handlers/deleteBlog.py
#!/usr/bin/python
from handle... | code_fim | easy | {
"lang": "python",
"repo": "runnphoenix/udacity_fullstack_proj3",
"path": "/handlers/deleteBlog.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: runnphoenix/udacity_fullstack_proj3 path: /handlers/deleteBlog.py
#!/usr/bin/python
from handler import Handler
import accessControl
class DeleteBlog(Handler):
<|fim_suffix|> blog.delete()
self.redirect('/blog/?')<|fim_middle|> @accessControl.user_logged_in
@accessContro... | code_fim | medium | {
"lang": "python",
"repo": "runnphoenix/udacity_fullstack_proj3",
"path": "/handlers/deleteBlog.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> batch_preds = self.model.predict(X_minibatch.float().to(self.device))
acc.append(np.sum(batch_preds == y_minibatch.cpu().data.numpy()) / y_minibatch.shape[0])
optimizer.step()
def main(device, args):
# Load the reddit train, dev, and test data
data_... | code_fim | hard | {
"lang": "python",
"repo": "dylan-slack/Finetuning-DP-Language-Models",
"path": "/finetune_brown_on_reddit_with_dp.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dylan-slack/Finetuning-DP-Language-Models path: /finetune_brown_on_reddit_with_dp.py
import torch
from torch import nn
from torch.utils.data import TensorDataset
import numpy as np
from pyvacy import optim, analysis, sampling
import argparse
import os
from train_brown_model import Model, get_... | code_fim | hard | {
"lang": "python",
"repo": "dylan-slack/Finetuning-DP-Language-Models",
"path": "/finetune_brown_on_reddit_with_dp.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> l = loss.to('cpu').data.numpy()
losses.append(l)
# if l < best_model['loss']:
# best_model['loss'] = l
# best_model['epoch'] = E + 1
# best_model['it'] = it
# best_model['model_s... | code_fim | hard | {
"lang": "python",
"repo": "dylan-slack/Finetuning-DP-Language-Models",
"path": "/finetune_brown_on_reddit_with_dp.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> playblast_btn = cmds.button(label="PLAYBLAST",
bgc=cls.BUTTON_COLOR_01,
c="MayaToKeyframePro.playblast()",
parent=playblast_form_layout)
open_temp_dir_btn = cmds.button(label="Open ... | code_fim | hard | {
"lang": "python",
"repo": "JingXuyang/PLMG",
"path": "/packages/maya/2016.5/scripts/keyframe_pro_maya/maya_to_keyframe_pro.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmds.optionVar(clearArray=cls.COLLAPSE_STATE_OPTION_VAR)
layouts = [cls.sync_layout, cls.viewer_layout, cls.playblast_layout]
for layout in layouts:
collapse = cmds.frameLayout(layout, q=True, cl=True)
cmds.optionVar(iva=[cls.COLLAPSE_STATE_OPTION_VAR, colla... | code_fim | hard | {
"lang": "python",
"repo": "JingXuyang/PLMG",
"path": "/packages/maya/2016.5/scripts/keyframe_pro_maya/maya_to_keyframe_pro.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JingXuyang/PLMG path: /packages/maya/2016.5/scripts/keyframe_pro_maya/maya_to_keyframe_pro.py
# Open in viewer
viewer_index = cmds.radioButtonGrp(cls.playblast_viewer_rbg, query=True, select=True) - 1
if viewer_index <= 1:
if not cls.is_initialized(False):
... | code_fim | hard | {
"lang": "python",
"repo": "JingXuyang/PLMG",
"path": "/packages/maya/2016.5/scripts/keyframe_pro_maya/maya_to_keyframe_pro.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> valid_err = float((os.path.split(p_filename)[1])[-13:-9]) / 100
test_err = float((os.path.split(p_filename)[1])[-8:-4]) / 100
f = open(p_filename)
p_data = pickle.load(f)
f.close()
plt.figure(figsize=(10, 8))
plt.bar(list(range(1, len(p_data) + 1)), p_data)
plt.xticks(size=... | code_fim | medium | {
"lang": "python",
"repo": "tomrunia/HyperSphere",
"path": "/HyperSphere/dummy/paper_scripts/stochastic_depth_resnet_result.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomrunia/HyperSphere path: /HyperSphere/dummy/paper_scripts/stochastic_depth_resnet_result.py
import os
import pickle
import matplotlib.pyplot as plt
import numpy as np
p_2490_2536_filename = os.path.join('/home/coh1/Experiments/StochasticDepthP', 'stochastic_depth_death_rate_cifar100+_20180125-... | code_fim | medium | {
"lang": "python",
"repo": "tomrunia/HyperSphere",
"path": "/HyperSphere/dummy/paper_scripts/stochastic_depth_resnet_result.py",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|>c1 = ano % 4
c2 = ano % 100
c3 = ano % 400
if (c1 == 0) and (c2 != 0):
print('Este ano é bissexto')
else:
if c3 == 0:
print('Este ano é bissexto')
else:
print('Este ano NÃO é bissexto')
print('\n---FIM---')<|fim_prefix|># repo: brenuvida/cursoemvideo path: /Aula10/exercicio_3... | code_fim | medium | {
"lang": "python",
"repo": "brenuvida/cursoemvideo",
"path": "/Aula10/exercicio_32.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def delete(self, commit=False):
"""
删除对象,从数据库中删除记录
:param commit: 是否提交,默认提交
:return self or False: 若commit为False, 则返回false;反之且提交成功,则返回self
"""
db.session.delete(self)
commit and db_session_commit()
return self
@classmethod
def up... | code_fim | hard | {
"lang": "python",
"repo": "liuzemeeting/python_script",
"path": "/flask_test/apps/utils/db.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def upsert(cls, where, commit=False, **kwargs):
record = cls.query.filter_by(**where).first()
print('record', record, where)
if record:
record.update(commit=commit, **kwargs)
else:
record = cls(**kwargs).save(commit=commit)
... | code_fim | hard | {
"lang": "python",
"repo": "liuzemeeting/python_script",
"path": "/flask_test/apps/utils/db.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liuzemeeting/python_script path: /flask_test/apps/utils/db.py
# coding=utf-8
# @Time : 2018/10/22 下午3:24
from sqlalchemy.orm import class_mapper
from application import db
def db_session_commit():
try:
db.session.commit()
except Exception:
print('db_session_commitdb... | code_fim | hard | {
"lang": "python",
"repo": "liuzemeeting/python_script",
"path": "/flask_test/apps/utils/db.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>es import *
from .graphs import *
from .regexps import *
from .grammars import *<|fim_prefix|># repo: ND-CSE-30151/tock path: /tock/__init__.py
from .machines import *
from .operations<|fim_middle|> import *
from .runs import *
from .tabl | code_fim | easy | {
"lang": "python",
"repo": "ND-CSE-30151/tock",
"path": "/tock/__init__.py",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>regexps import *
from .grammars import *<|fim_prefix|># repo: ND-CSE-30151/tock path: /tock/__init__.py
from .machines import *
from .operations<|fim_middle|> import *
from .runs import *
from .tables import *
from .graphs import *
from . | code_fim | medium | {
"lang": "python",
"repo": "ND-CSE-30151/tock",
"path": "/tock/__init__.py",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ND-CSE-30151/tock path: /tock/__init__.py
from .machines import *
from .operations import *
from .runs import *
from .tabl<|fim_suffix|>regexps import *
from .grammars import *<|fim_middle|>es import *
from .graphs import *
from . | code_fim | easy | {
"lang": "python",
"repo": "ND-CSE-30151/tock",
"path": "/tock/__init__.py",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> # start pwm
p.start(dc)
# brighten/dim demo
for i in range(1,50):
time.sleep(0.1)
dc = i
p.ChangeDutyCycle(dc)
# exit
input('Press return to stop:') # use raw_input for Python 2
p.stop()
GPIO.cleanup()
#simple_gpio_usage_output()
pwm_gpio_usa... | code_fim | hard | {
"lang": "python",
"repo": "BxNxM/rpitools",
"path": "/gpio/gpio_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BxNxM/rpitools path: /gpio/gpio_demo.py
#!/usr/bin/python3
#GPIO USAGE: §https://sourceforge.net/p/raspberry-gpio-python/wiki/BasicUsage/
#GPIO PINOUT: https://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
try:
import RPi.GPIO as GPIO
except RuntimeError:
... | code_fim | medium | {
"lang": "python",
"repo": "BxNxM/rpitools",
"path": "/gpio/gpio_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # exit
input('Press return to stop:') # use raw_input for Python 2
p.stop()
GPIO.cleanup()
#simple_gpio_usage_output()
pwm_gpio_usage_output()<|fim_prefix|># repo: BxNxM/rpitools path: /gpio/gpio_demo.py
#!/usr/bin/python3
#GPIO USAGE: §https://sourceforge.net/p/raspberry-gpio-pytho... | code_fim | hard | {
"lang": "python",
"repo": "BxNxM/rpitools",
"path": "/gpio/gpio_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mukundneharkar/TestSDK path: /lmingest/models/__init__.py
# coding: utf-8
# flake8: noqa
"""
LogicMonitor API-Ingest Rest API
LogicMonitor is a SaaS-based performance monitoring platform that provides full visibility into complex, hybrid infrastructures, offering granular performance mo... | code_fim | medium | {
"lang": "python",
"repo": "mukundneharkar/TestSDK",
"path": "/lmingest/models/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""
from __future__ import absolute_import
# import models into model package
from lmingest.models.list_rest_data_point_v1 import ListRestDataPointV1
from lmingest.models.list_rest_data_source_instance_v1 import \
ListRestDataSourceInstanceV1
from lmingest.models.map_string_string import MapStringStri... | code_fim | medium | {
"lang": "python",
"repo": "mukundneharkar/TestSDK",
"path": "/lmingest/models/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amineabdelmoumen/ebook-API path: /Blog/account/urls.py
from django.urls import path
from . import views
from rest_framework.authtoken.views import obtain_auth_token
urlpatterns = [
path('register', <|fim_suffix|>rs_and_theirBooks, name="users_all_inf"),
path('Mybooks', views.get_My_books,... | code_fim | medium | {
"lang": "python",
"repo": "amineabdelmoumen/ebook-API",
"path": "/Blog/account/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>te_book"),
path('find_poster/<str:pk>', views.find_poster, name="find_poster"),
path('update/<str:pk>', views.update_book, name="update")
]<|fim_prefix|># repo: amineabdelmoumen/ebook-API path: /Blog/account/urls.py
from django.urls import path
from . import views
from rest_framework.authtoken.v... | code_fim | medium | {
"lang": "python",
"repo": "amineabdelmoumen/ebook-API",
"path": "/Blog/account/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kbrgl/quinine path: /quinine/common/utils.py
"""
Some common utilities.
"""
import yaml
from funcy import *
from munch import Munch
import cytoolz as tz
def difference(*colls):
"""
Find the keys that have different values in an arbitrary number of (nested) collections. Any key
that... | code_fim | hard | {
"lang": "python",
"repo": "kbrgl/quinine",
"path": "/quinine/common/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return postfix(prefix(s, pre), post)
def nested_map(f, *args):
""" Recursively transpose a nested structure of tuples, lists, and dicts """
assert len(args) > 0, 'Must have at least one argument.'
arg = args[0]
if isinstance(arg, tuple) or isinstance(arg, list):
return [nest... | code_fim | hard | {
"lang": "python",
"repo": "kbrgl/quinine",
"path": "/quinine/common/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@autocurry
def walk_values_rec(f, coll):
"""
Similar to funcy's walk_values, but does so recursively, including mapping f over lists.
"""
if is_mapping(coll):
return f(walk_values(walk_values_rec(f), coll))
elif is_list(coll):
return f(list(map(walk_values_rec(f), coll)... | code_fim | hard | {
"lang": "python",
"repo": "kbrgl/quinine",
"path": "/quinine/common/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DavidLee1216/django-edu path: /MxOnline/storage_backends.py
from storages.backends.s3boto3 import S3Boto3Storage
from MxOnline.settings import MEDIAFILES_LOCATION
<|fim_suffix|> location = MEDIAFILES_LOCATION
file_overwrite = False<|fim_middle|>class MediaStorage(S3Boto3Storage):
| code_fim | easy | {
"lang": "python",
"repo": "DavidLee1216/django-edu",
"path": "/MxOnline/storage_backends.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> location = MEDIAFILES_LOCATION
file_overwrite = False<|fim_prefix|># repo: DavidLee1216/django-edu path: /MxOnline/storage_backends.py
from storages.backends.s3boto3 import S3Boto3Storage
from MxOnline.settings import MEDIAFILES_LOCATION
<|fim_middle|>class MediaStorage(S3Boto3Storage):
| code_fim | easy | {
"lang": "python",
"repo": "DavidLee1216/django-edu",
"path": "/MxOnline/storage_backends.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlanFermat/leetcode path: /Facebook/mergeInterval.py
# class Interval(object):
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
<|fim_suffix|> def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
... | code_fim | hard | {
"lang": "python",
"repo": "AlanFermat/leetcode",
"path": "/Facebook/mergeInterval.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
if intervals:
sort_list = sorted(intervals, key = self.getKey)
i = 0
n = len(sort_list)
print sort_list
while ... | code_fim | hard | {
"lang": "python",
"repo": "AlanFermat/leetcode",
"path": "/Facebook/mergeInterval.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hackdeath/dictionary path: /dictionary/migrations/0002_auto_20160708_1504.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-08 18:04
from __future__ import unicode_literals
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('dictionary', '0001_in... | code_fim | medium | {
"lang": "python",
"repo": "hackdeath/dictionary",
"path": "/dictionary/migrations/0002_auto_20160708_1504.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('dictionary', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Language',
fields=[
('language', models.CharField(max_length=5, primary_key=True, serialize=False)),
('alphabet', models.Cha... | code_fim | medium | {
"lang": "python",
"repo": "hackdeath/dictionary",
"path": "/dictionary/migrations/0002_auto_20160708_1504.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod # metoda klasowa jest swiadoma bycia czescia klasy i widzi inne metody w klasie
def dodaj_i_pomnoz(cls,a,b): # wymaga slowa kluczowego cls (zamiast self) bo operuje na klasie a nie na jej obiekcie/instancji
return cls.dodaj(a,b) * 2
m = Matematyka()
prin... | code_fim | hard | {
"lang": "python",
"repo": "plelewski/50_python_Q_and_A",
"path": "/38_class_static_methods.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: plelewski/50_python_Q_and_A path: /38_class_static_methods.py
# Pytane 38 - do czego służą dekoratory @staticmethod i @classmethod?
class Matematyka:
def __init__(self):
self.pi = 3.14
<|fim_suffix|> @classmethod # metoda klasowa jest swiadoma bycia czescia klas... | code_fim | hard | {
"lang": "python",
"repo": "plelewski/50_python_Q_and_A",
"path": "/38_class_static_methods.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''(number, number) -> number
Calculate the variable_maintenance for a flat by inputting flat_sqft and charge_per_sqft.
A sqft_surcharge is calculated based on the flat_sqft.
Examples:
>>>(1600, 20)
33200.0
>>>(1000, 40)
40750.0
'''
if (flat_sqft <= 0):
... | code_fim | medium | {
"lang": "python",
"repo": "AshaTampa/learning-to-code",
"path": "/maintenance_functions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AshaTampa/learning-to-code path: /maintenance_functions.py
def fixed_maintenance(flat_sqft):
'''(number) -> number
Calculate the fixed_maintenance cost for a flat by inputting flat_sqft against a fixed maintenance charge per sqft of 50
Examples:
>>>(1200)
60000
>>>(1... | code_fim | medium | {
"lang": "python",
"repo": "AshaTampa/learning-to-code",
"path": "/maintenance_functions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: legend-xu/FruitShop path: /FruitShop/FruitGP2/tasks.py
from time import sleep
from celery import shared_task, app
<|fim_suffix|> send_active_email(username,to_email)<|fim_middle|>from FruitGP2.utils import send_active_email
@shared_task
def send_activate_email_async(username,to_email):
| code_fim | medium | {
"lang": "python",
"repo": "legend-xu/FruitShop",
"path": "/FruitShop/FruitGP2/tasks.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> send_active_email(username,to_email)<|fim_prefix|># repo: legend-xu/FruitShop path: /FruitShop/FruitGP2/tasks.py
from time import sleep
from celery import shared_task, app
from FruitGP2.utils import send_active_email
<|fim_middle|>
@shared_task
def send_activate_email_async(username,to_email):
| code_fim | medium | {
"lang": "python",
"repo": "legend-xu/FruitShop",
"path": "/FruitShop/FruitGP2/tasks.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@shared_task
def send_activate_email_async(username,to_email):
send_active_email(username,to_email)<|fim_prefix|># repo: legend-xu/FruitShop path: /FruitShop/FruitGP2/tasks.py
from time import sleep
from celery import shared_task, app
<|fim_middle|>from FruitGP2.utils import send_active_email
| code_fim | easy | {
"lang": "python",
"repo": "legend-xu/FruitShop",
"path": "/FruitShop/FruitGP2/tasks.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kgreenek/bazel_timestamp_server path: /client.py
import argparse
import grpc
import timestamp_service_pb2
import timestamp_service_pb2_grpc
<|fim_suffix|> arg_parser = create_arg_parser()
args = arg_parser.parse_args()
print("Connecting to Timestamp server:")
print(args.server)
... | code_fim | hard | {
"lang": "python",
"repo": "kgreenek/bazel_timestamp_server",
"path": "/client.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> arg_parser = create_arg_parser()
args = arg_parser.parse_args()
print("Connecting to Timestamp server:")
print(args.server)
print("")
channel = grpc.insecure_channel(args.server)
stub = timestamp_service_pb2_grpc.TimestampServiceStub(channel)
request = timestamp_service_pb2... | code_fim | medium | {
"lang": "python",
"repo": "kgreenek/bazel_timestamp_server",
"path": "/client.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ck-china/pythonjc path: /zuoye/danli.py
class DogCk(object):
__flg = None
def __init__(self,name):
<|fim_suffix|> if DogCk.__flg == None:
DogCk.__flg = object.__new__(cls)
return DogCk.__flg
a=DogCk('ck')
b=DogCk('ck')
print(id(a))
print(id(b))<|fim_middle|> ... | code_fim | easy | {
"lang": "python",
"repo": "ck-china/pythonjc",
"path": "/zuoye/danli.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if DogCk.__flg == None:
DogCk.__flg = object.__new__(cls)
return DogCk.__flg
a=DogCk('ck')
b=DogCk('ck')
print(id(a))
print(id(b))<|fim_prefix|># repo: ck-china/pythonjc path: /zuoye/danli.py
class DogCk(object):
__flg = None
def __init__(self,name):
<|fim_middle|> ... | code_fim | easy | {
"lang": "python",
"repo": "ck-china/pythonjc",
"path": "/zuoye/danli.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Args:
control_dist_km: number, the control distance in kilometers
brevet_dist_km: number, the nominal distance of the brevet
in kilometers, which must be one of 200, 300, 400, 600, or 1000
(the only official ACP brevet distances)
brevet_start_time: ... | code_fim | hard | {
"lang": "python",
"repo": "tcolb/proj4-brevets",
"path": "/brevets/acp_times.py",
"mode": "spm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def open_time(control_dist_km, brevet_dist_km, brevet_start_time):
"""
Args:
control_dist_km: number, the control distance in kilometers
brevet_dist_km: number, the nominal distance of the brevet
in kilometers, which must be one of 200, 300, 400, 600,
or 1000 (... | code_fim | medium | {
"lang": "python",
"repo": "tcolb/proj4-brevets",
"path": "/brevets/acp_times.py",
"mode": "spm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.