text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def baja(self, folio):
del self.pacientes[folio]
return "Paciente eliminado"<|fim_prefix|># repo: nahumsin/finalProyect path: /app/AltasBajas.py
from Paciente import Paciente
class AltasBajas:
pacientes = {}
folio = 100
def alta(self, nombre, apellido, edad, email, dire... | code_fim | hard | {
"lang": "python",
"repo": "nahumsin/finalProyect",
"path": "/app/AltasBajas.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 引数
各種設定値(辞書型)
戻り値
min_funtionの戻り値
"""
print("{}th calculation starts.".format(1+len(min_function.summary_list)))
hidden_list = [int(args["l1_out"]), int(args["l2_out"])]
drop_list = [args["l1_drop"], args["l2_drop"]]
epochs ... | code_fim | hard | {
"lang": "python",
"repo": "ytgw/ml_tips",
"path": "/tuning/hyperopt_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 最適解探索
print("-------------------- Search Start --------------------")
best = fmin(calc_object_value,
tune_parameter,
algo=tpe.suggest,
max_evals=15)
# 結果表示
print("-------------------- Search End --------------------")
min_function.... | code_fim | hard | {
"lang": "python",
"repo": "ytgw/ml_tips",
"path": "/tuning/hyperopt_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ytgw/ml_tips path: /tuning/hyperopt_test.py
# -*- coding: utf-8 -*-
"""
hyperopt sample
"""
# --------------------------------------------------
# Initial Setting
# --------------------------------------------------
import numpy as np
import tensorflow as tf
import random as rn
import os
# GPUの無... | code_fim | hard | {
"lang": "python",
"repo": "ytgw/ml_tips",
"path": "/tuning/hyperopt_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whsqkaak/CodingTrainingStudy path: /sort/sort.py
def solution(array, commands):
answer = []
for i, j, k in commands:
t<|fim_suffix|> answer.append(tmp[k-1])
return answer<|fim_middle|>mp = array[i-1:j]
tmp.sort()
| code_fim | easy | {
"lang": "python",
"repo": "whsqkaak/CodingTrainingStudy",
"path": "/sort/sort.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mp = array[i-1:j]
tmp.sort()
answer.append(tmp[k-1])
return answer<|fim_prefix|># repo: whsqkaak/CodingTrainingStudy path: /sort/sort.py
def solution(array, commands):
answer <|fim_middle|>= []
for i, j, k in commands:
t | code_fim | easy | {
"lang": "python",
"repo": "whsqkaak/CodingTrainingStudy",
"path": "/sort/sort.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbark/messaging-service path: /tests/test_integration.py
import json
import pytest
pytestmark = pytest.mark.integration
def post_msg(client, msg={'foo': 'bar'}):
endpoint = '/messages/1'
result = client.simulate_post(endpoint, body=json.dumps(msg))
return endpoint, json.loads(resul... | code_fim | hard | {
"lang": "python",
"repo": "mbark/messaging-service",
"path": "/tests/test_integration.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_post_delete_get(client):
endpoint, msg = post_msg(client)
client.simulate_delete(endpoint, body=json.dumps([msg]))
result = client.simulate_get(endpoint)
assert result.status_code == 200
response = json.loads(result.text)
assert len(response) == 0
def test_get_get_unre... | code_fim | hard | {
"lang": "python",
"repo": "mbark/messaging-service",
"path": "/tests/test_integration.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> plt.xlabel("RA")
plt.ylabel("Dec")
else:
centerPixel = (header["xCenterPixel"], header["yCenterPixel"])
pixelDimension = image.shape
degreesToArcseconds = 3600
pixelScale = header["degreesPixelScale"] * degreesToArcseconds
extent = [(-centerPi... | code_fim | hard | {
"lang": "python",
"repo": "MichaelStroet/BachelorProject",
"path": "/code/fitsFiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MichaelStroet/BachelorProject path: /code/fitsFiles.py
# Michael Stroet 11293284
import os, sys
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
from matplotlib.colors import LogNorm
root_directory = os.path.dirname(os.path.dirname(os.... | code_fim | hard | {
"lang": "python",
"repo": "MichaelStroet/BachelorProject",
"path": "/code/fitsFiles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eecs-395-senior-project-team/voda path: /webscraper/vodadata/leadInfoScraper.py
import scrapy
import psycopg2
import traceback
class LeadInfoScraper(scrapy.Spider):
name = "LeadInfoScraper"
counter = 0
def __init__(self, connection):
self.connection = connection
def wr... | code_fim | hard | {
"lang": "python",
"repo": "eecs-395-senior-project-team/voda",
"path": "/webscraper/vodadata/leadInfoScraper.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # check if this source-contaminant relationship exists
cursor.execute('SELECT * FROM "vodaMainApp_sourcelevels" WHERE source_id = %s '
'AND contaminant_id = %s', (src_id, cont_id))
results = cursor.fetchall()
# if there is not alr... | code_fim | hard | {
"lang": "python",
"repo": "eecs-395-senior-project-team/voda",
"path": "/webscraper/vodadata/leadInfoScraper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shafaypro/shafayworkspace path: /Tkinter_Beginner/frame.py
from tkinter import * # imports the tkinter header file
class Window(Frame): # Starts a windows instance
def __init__(self, master=None): # the constructor of the Windows Class
<|fim_suffix|>
root = Tk() # creates an object of the ... | code_fim | medium | {
"lang": "python",
"repo": "shafaypro/shafayworkspace",
"path": "/Tkinter_Beginner/frame.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Frame.__init__(self, master) # a self frame is created using this
self.master = master # intialize the master with the current frame master (variable)
root = Tk() # creates an object of the tkinter class
app = Window(root) # to pass the root of tkinter to the class created
root.mainloop() # to ... | code_fim | medium | {
"lang": "python",
"repo": "shafaypro/shafayworkspace",
"path": "/Tkinter_Beginner/frame.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = User<|fim_prefix|># repo: danielziro/SistemaGranja-master path: /SistemaGranja-master/InicioSesion/forms.py
# -*- coding: utf-8 -*-
from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import User
from django.uti... | code_fim | easy | {
"lang": "python",
"repo": "danielziro/SistemaGranja-master",
"path": "/SistemaGranja-master/InicioSesion/forms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danielziro/SistemaGranja-master path: /SistemaGranja-master/InicioSesion/forms.py
# -*- coding: utf-8 -*-
from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
#from dja... | code_fim | easy | {
"lang": "python",
"repo": "danielziro/SistemaGranja-master",
"path": "/SistemaGranja-master/InicioSesion/forms.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert response.status_code == 200
self.assertContains(response, accepted_class.teacher.name)
self.assertContains(response, accepted_class.b_title)
def test_bios_teachers_profile_skipped(self):
first_context = ClassContext()
first_context.people.class_id = firs... | code_fim | hard | {
"lang": "python",
"repo": "bethlakshmi/gbe-divio-djangocms-python2.7",
"path": "/tests/gbe/test_bios_teachers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> first_context = ClassContext()
link = first_context.set_social_media("Facebook")
other_context = ClassContext()
login_as(ProfileFactory(), self)
response = self.client.get(
self.url,
data={'conference': first_context.conference.conference_slu... | code_fim | hard | {
"lang": "python",
"repo": "bethlakshmi/gbe-divio-djangocms-python2.7",
"path": "/tests/gbe/test_bios_teachers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gmoreiraa/Web-Service path: /Server/server.py
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
import re
with open("db.json") as data_file:
data = json.load(data_file)
with open("login.json") as data_file:
login = json.load(data_file)
class ServiceHandler(BaseHTT... | code_fim | hard | {
"lang": "python",
"repo": "gmoreiraa/Web-Service",
"path": "/Server/server.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(data) > 0:
index = int(data[len(data) - 1]["id"]) + 1
else:
index = 1
req["id"] = str(index)
data.append(req)
with open("db.json", 'w+') as file_data:
json.dump(data, file_data)
self.send_response(201)
sel... | code_fim | hard | {
"lang": "python",
"repo": "gmoreiraa/Web-Service",
"path": "/Server/server.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jang93/exercism path: /python/error-handling/error_handling.py
def handle_error_by_throwing_exception():
raise Exception("Error")
<|fim_suffix|>
def filelike_objects_are_closed_on_exception(filelike_object):
with filelike_object as f:
f.do_something()<|fim_middle|>def handle_err... | code_fim | hard | {
"lang": "python",
"repo": "jang93/exercism",
"path": "/python/error-handling/error_handling.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def filelike_objects_are_closed_on_exception(filelike_object):
with filelike_object as f:
f.do_something()<|fim_prefix|># repo: jang93/exercism path: /python/error-handling/error_handling.py
def handle_error_by_throwing_exception():
raise Exception("Error")
def handle_error_by_returning... | code_fim | medium | {
"lang": "python",
"repo": "jang93/exercism",
"path": "/python/error-handling/error_handling.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @mock.patch('client_of_redundant_servers.client_of_redundant_radius_servers.Client')
def test_client_radius_auth_packet_error_exception(self, mock_pyrad_client):
a_client = ClientOfRedundantRadiusServers(self.fake_server_dict, "test")
mock_pyrad_client.side_effect = pyrad.packet.Pa... | code_fim | hard | {
"lang": "python",
"repo": "rbricheno/client_of_redundant_servers",
"path": "/tests/test_client_of_redundant_radius_servers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ok/backend/')
sys.path.insert(1, '/home/terzeron/.pyenv/versions/flask/lib/python3.9/site-packages')
from index import app as application<|fim_prefix|># repo: terzeron/FlaskVueTest path: /backend/index.wsgi
#!/usr/bin/env python
import logging
import sys
logging.basicConfig<|fim_middle|>(stream=sys.std... | code_fim | medium | {
"lang": "python",
"repo": "terzeron/FlaskVueTest",
"path": "/backend/index.wsgi",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: terzeron/FlaskVueTest path: /backend/index.wsgi
#!/usr/bin/env python
import logging
import sys
logging.basicConfig<|fim_suffix|>k/lib/python3.9/site-packages')
from index import app as application<|fim_middle|>(stream=sys.stderr)
sys.path.insert(0, '/home/terzeron/public_html/book/backend/')
s... | code_fim | medium | {
"lang": "python",
"repo": "terzeron/FlaskVueTest",
"path": "/backend/index.wsgi",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PiperProject/quest path: /src/unittest_driver.py
#!/usr/bin/env python
import copy, os, pickledb, string, sys, unittest
#####################
# UNITTEST DRIVER #
#####################
def unittest_driver() :
print
print "************************************"
print "* RUNNING TEST SUI... | code_fim | hard | {
"lang": "python",
"repo": "PiperProject/quest",
"path": "/src/unittest_driver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>t.test_example9" )
os.system( "python -m unittest Test_quest.Test_quest.test_example10" )
os.system( "python -m unittest Test_quest.Test_quest.test_example11" )
os.system( "python -m unittest Test_quest.Test_quest.test_example12" )
os.system( "python -m unittest Test_quest.Test_quest.test_example1... | code_fim | hard | {
"lang": "python",
"repo": "PiperProject/quest",
"path": "/src/unittest_driver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ethangela/multimedia path: /src/data_extraction/permutate_data.py
import ast
import copy
import glob
import h5py
import logging
import numpy as np
import os
import pandas as pd
from editing.writer import DatasetWriter
from numpy import random
FEATURES_FILE = os.environ["FEATURES_FILE"]
SEGME... | code_fim | hard | {
"lang": "python",
"repo": "ethangela/multimedia",
"path": "/src/data_extraction/permutate_data.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> logging.info("Gittering videos")
for indx, row in df.iterrows():
video_name = row["segmented_video_id"].replace('.mp4', '')
if video_name not in shift_mappings:
shift_val = get_shift()
video_feature = video_features_all[video_name]
video_feature_shifted = shift_video(video_feature = video... | code_fim | hard | {
"lang": "python",
"repo": "ethangela/multimedia",
"path": "/src/data_extraction/permutate_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
T = int(input())
for j in range(T):
N, L = list(map(int,input().split()))
prime,numbers = findprime(N)
A = list(map(int,input().split()))
fact = []
print(prime)
# for i in numbers:
# if A[0] % i == 0:
# if A[1] % i ==0:
# fact.append(int(A[0] /... | code_fim | hard | {
"lang": "python",
"repo": "Alferdize/Data-Structure-and-Algorithms",
"path": "/kickstarter/crypto.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>T = int(input())
for j in range(T):
N, L = list(map(int,input().split()))
prime,numbers = findprime(N)
A = list(map(int,input().split()))
fact = []
print(prime)
# for i in numbers:
# if A[0] % i == 0:
# if A[1] % i ==0:
# fact.append(int(A[0] / ... | code_fim | hard | {
"lang": "python",
"repo": "Alferdize/Data-Structure-and-Algorithms",
"path": "/kickstarter/crypto.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Alferdize/Data-Structure-and-Algorithms path: /kickstarter/crypto.py
def findprime(n):
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p*p,n+1,p):
prime[i] = False
p += 1
<|fim_suffix|>... | code_fim | hard | {
"lang": "python",
"repo": "Alferdize/Data-Structure-and-Algorithms",
"path": "/kickstarter/crypto.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 120*E2*lx*ly**2*nu12**2) - (2*((15*E1**2*h**3*ly)/32 - (15*E1*E2*h**3*ly)/32))/(120*E1*ly**2 - 120*E2*ly**2*nu12**2) + (2*((9*E1**2*h**3*ly**2)/32 + (9*E1*E2*h**3*ly**2)/32 - (5*E1*G12*h**3*ly**2)/16 + (5*E2*G12*h**3*ly**2*nu12**2)/16 + (E1*E2*h**3*ly**2*nu12)/16))/(120*E1*lx*ly**2 - 120*E2*lx*ly**2*nu12... | code_fim | hard | {
"lang": "python",
"repo": "stutipathak5/Machine-Learning-Assisted-System-Identification-of-a-Composite-Plate",
"path": "/finite_element_analysis.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stutipathak5/Machine-Learning-Assisted-System-Identification-of-a-Composite-Plate path: /finite_element_analysis.py
(2*((5*E1**2*h**3*lx**2)/32 - (E1**2*h**3*ly**2)/8 + (5*E1*E2*h**3*lx**2)/32 - (E1*E2*h**3*ly**2)/8 + (5*E1*G1... | code_fim | hard | {
"lang": "python",
"repo": "stutipathak5/Machine-Learning-Assisted-System-Identification-of-a-Composite-Plate",
"path": "/finite_element_analysis.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwmatthews/pulp_rpm path: /pulp_rpm/test/unit/server/test_distributions.py
# -*- coding: utf-8 -*-
#
# Copyright © 2011 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2)... | code_fim | hard | {
"lang": "python",
"repo": "jwmatthews/pulp_rpm",
"path": "/pulp_rpm/test/unit/server/test_distributions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(TestDistribution, self).tearDown()
shutil.rmtree(self.temp_dir)
def test_metadata(self):
metadata = YumImporter.metadata()
self.assertEquals(metadata["id"], TYPE_ID_IMPORTER_YUM)
self.assertTrue(TYPE_ID_DISTRO in metadata["types"])
def test_distribut... | code_fim | hard | {
"lang": "python",
"repo": "jwmatthews/pulp_rpm",
"path": "/pulp_rpm/test/unit/server/test_distributions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('main', '0011_auto_20210613_1150'),
]
operations = [
migrations.AddField(
model_name='producto',
name='fecha_alta',
field=models.DateTimeField(null=True),
),
]<|fim_prefix|># repo: Diegodelias/TPFINAL-DESWEB-PY... | code_fim | easy | {
"lang": "python",
"repo": "Diegodelias/TPFINAL-DESWEB-PYTHON-JS-polotic-2021-TPFINAL",
"path": "/main/migrations/0012_producto_fecha_alta.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Diegodelias/TPFINAL-DESWEB-PYTHON-JS-polotic-2021-TPFINAL path: /main/migrations/0012_producto_fecha_alta.py
# Generated by Django 3.2.4 on 2021-06-13 18:39
<|fim_suffix|> dependencies = [
('main', '0011_auto_20210613_1150'),
]
operations = [
migrations.AddField(
... | code_fim | medium | {
"lang": "python",
"repo": "Diegodelias/TPFINAL-DESWEB-PYTHON-JS-polotic-2021-TPFINAL",
"path": "/main/migrations/0012_producto_fecha_alta.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cornex-Inc/Coffee path: /Doctor/migrations/0010_bundle.py
# Generated by Django 2.1.15 on 2020-01-09 17:20
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('Doctor', '0009_auto_20200105_2317'),
]
operations = [
migrations.CreateModel(
... | code_fim | hard | {
"lang": "python",
"repo": "Cornex-Inc/Coffee",
"path": "/Doctor/migrations/0010_bundle.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('Doctor', '0009_auto_20200105_2317'),
]
operations = [
migrations.CreateModel(
name='bundle',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
(... | code_fim | hard | {
"lang": "python",
"repo": "Cornex-Inc/Coffee",
"path": "/Doctor/migrations/0010_bundle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='bundle',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('upper', models.CharField(max_length=64)),
('group_code', m... | code_fim | hard | {
"lang": "python",
"repo": "Cornex-Inc/Coffee",
"path": "/Doctor/migrations/0010_bundle.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'w')
f2.write(new)
f1.close()
f2.close()<|fim_prefix|># repo: zhanlaoban/Python_tools path: /01-去掉文本中的空行.py
import re
f1 = open('finance.txt')
content = f1.read()
new = re.sub('\n\n', '\n'<|fim_middle|>, content)
f2 = open('finance_new.txt', | code_fim | easy | {
"lang": "python",
"repo": "zhanlaoban/Python_tools",
"path": "/01-去掉文本中的空行.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhanlaoban/Python_tools path: /01-去掉文本中的空行.py
import re
f1 = open('finance.txt')
cont<|fim_suffix|>, content)
f2 = open('finance_new.txt', 'w')
f2.write(new)
f1.close()
f2.close()<|fim_middle|>ent = f1.read()
new = re.sub('\n\n', '\n' | code_fim | easy | {
"lang": "python",
"repo": "zhanlaoban/Python_tools",
"path": "/01-去掉文本中的空行.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def put_on_multi_gpus(model, opt):
if opt.gpu_ids != "-1":
gpus = list(map(int, opt.gpu_ids.split(",")))
model = DataParallelWithCallback(model, device_ids=gpus).cuda()
else:
model.module = model
assert len(opt.gpu_ids.split(",")) == 0 or opt.batch_size % len(opt.gpu_id... | code_fim | hard | {
"lang": "python",
"repo": "ftll574/Simulator2Real",
"path": "/Our_GAN/models/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ftll574/Simulator2Real path: /Our_GAN/models/models.py
from models.sync_batchnorm import DataParallelWithCallback
import models.generator as generators
import models.discriminator as discriminators
from models.diffaugment import DiffAugment
import os
import torch
import torch.nn as nn
from torch.... | code_fim | hard | {
"lang": "python",
"repo": "ftll574/Simulator2Real",
"path": "/Our_GAN/models/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pretrained_dict = torch.load(path)
model_dict = model.state_dict()
pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}
model_dict.update(pretrained_dict)
model.load_state_dict(model_dict)
if self.opt.phase == ... | code_fim | hard | {
"lang": "python",
"repo": "ftll574/Simulator2Real",
"path": "/Our_GAN/models/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: techappg/meat_fun_backend path: /product/api/Subcategory_like_api.py
from rest_framework.permissions import AllowAny, IsAuthenticated
from product.models.Subcategory import Subcategory_like
from rest_framework import viewsets
from product.serializer.Subcategory_like_serializer import Subcate... | code_fim | easy | {
"lang": "python",
"repo": "techappg/meat_fun_backend",
"path": "/product/api/Subcategory_like_api.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Subcategory_like_ViewSet(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated, ]
serializer_class = Subcategory_like_Serializer
queryset = Subcategory_like.objects.all()<|fim_prefix|># repo: techappg/meat_fun_backend path: /product/api/Subcategory_like_api.py
from rest_frame... | code_fim | medium | {
"lang": "python",
"repo": "techappg/meat_fun_backend",
"path": "/product/api/Subcategory_like_api.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, key, val, next, pre, freq):
self.key = key
self.val = val
self.next = next
self.pre = pre
self.freq = freq
def __init__(self, capacity: int):
self.d = {}
self.capacity = capacity
self.size =... | code_fim | medium | {
"lang": "python",
"repo": "zhaoyu20150930/leetcode-test",
"path": "/LeetCode/l460.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhaoyu20150930/leetcode-test path: /LeetCode/l460.py
"""
设计并实现最不经常使用(LFU)缓存的数据结构。它应该支持以下操作:get 和 put。
get(key) - 如果键存在于缓存中,则获取键的值(总是正数),否则返回 -1。
put(key, value) - 如果键不存在,请设置或插入值。当缓存达到其容量时,它应该在插入新项目之前,使 最不经常使用的项目无效。在此问题中,当存在平局(即两个或更多个键具有相同使用频率)时,最近最少使用的键将被去除。
进阶:
你是否可以在 O(1) 时间复杂度内执行两项操作?
示例:
... | code_fim | hard | {
"lang": "python",
"repo": "zhaoyu20150930/leetcode-test",
"path": "/LeetCode/l460.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lihongjie-123/calligraphy-study path: /src/main/user_model.py
Widgets.QFrame.StyledPanel)
self.loose_color_change_frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.loose_color_change_frame.setObjectName("loose_color_change_frame")
self.loose_color_change_frame.setFrameSty... | code_fim | hard | {
"lang": "python",
"repo": "Lihongjie-123/calligraphy-study",
"path": "/src/main/user_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lihongjie-123/calligraphy-study path: /src/main/user_model.py
"practise_loose_point_map": {},
}
self.format_all_point_list = []
self.practise_count = 1
self.step = 0
self.practise_status = ""
self.timer = QBasicTimer()
self.timer.stop()
... | code_fim | hard | {
"lang": "python",
"repo": "Lihongjie-123/calligraphy-study",
"path": "/src/main/user_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
self.suspend_time = time.time()
self.timer.stop()
self.painting = False
self.start_write = False
tmp_last_point = self.loose_point_list[0]
self.painter.begin(self.__board)
self.painter.setPen(
... | code_fim | hard | {
"lang": "python",
"repo": "Lihongjie-123/calligraphy-study",
"path": "/src/main/user_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
lookahead = int(0.2/self.dt)
lookahead = 0
if len(self.Xvel)==0:
terminate_index = 0
if self.robot_poly_index < terminate_index :
#polynomial traj followining
self.... | code_fim | hard | {
"lang": "python",
"repo": "shihyunlo/side_walking",
"path": "/nodes/side_walking_old.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shihyunlo/side_walking path: /nodes/side_walking_old.py
self.subgoal_ind = 1 # to be set, input by arg
# general parameters
self.x_ref = []
self.v = 1.0 #desired group velocity
self.sm = 0.8 #safety margin
self.dt = 0.1
# self.ped_helmet_i... | code_fim | hard | {
"lang": "python",
"repo": "shihyunlo/side_walking",
"path": "/nodes/side_walking_old.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> start_yaw = 0.0
#initialization: system level
cmd_pub_rate = 100
rate = rospy.Rate(cmd_pub_rate)
rate_count = int(cmd_pub_rate/(1/self.dt))
vel_msg_ = Twist()
plot_count = 0
vel_count = 0
vel_n = 5
... | code_fim | hard | {
"lang": "python",
"repo": "shihyunlo/side_walking",
"path": "/nodes/side_walking_old.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> zeros = (np.zeros(missing_data * 100))
ones = (np.ones((1 - missing_data) * 100))
one_zero = np.concatenate([zeros, ones])
mv = []
for p in patients:
mv.append(np.random.choice(one_zero, len(p[:-1])))
return mv
def classify(X, y, dAs):
methods = {'rfc': rfc, 'fullrfc... | code_fim | hard | {
"lang": "python",
"repo": "greenelab/DAPS",
"path": "/classify_patients.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: greenelab/DAPS path: /classify_patients.py
import os
import pickle as pkl
import gc
import time
import numpy as np
import random
import argparse
import theano
import theano.tensor as T
import train_dAs as trainer
from sklearn.cross_validation import StratifiedKFold
from sklearn.metrics import ... | code_fim | hard | {
"lang": "python",
"repo": "greenelab/DAPS",
"path": "/classify_patients.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__()
self.pe_enable = False # Ture | False
self.cfg = cfg
# reduce the parameters to 3 quarters
#filter = [64 // 2, 128 // 2, 256 // 2, 512 // 2, 512 // 2]
filter = [int(64 * 0.75), int(128 * 0.75), int(256 * 0.75), int(512 * 0.75), int(512 * ... | code_fim | hard | {
"lang": "python",
"repo": "saraalrawi/EIN-SELD",
"path": "/seld/methods/ein_seld/models/seld.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saraalrawi/EIN-SELD path: /seld/methods/ein_seld/models/seld.py
ing=(1, 1), dilation=1, bias=False),
nn.BatchNorm2d(256),
nn.ReLU(inplace=True),nn.AvgPool2d(kernel_size=(1, 2)) )
self.shared_co... | code_fim | hard | {
"lang": "python",
"repo": "saraalrawi/EIN-SELD",
"path": "/seld/methods/ein_seld/models/seld.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saraalrawi/EIN-SELD path: /seld/methods/ein_seld/models/seld.py
tten_encoder[i][j][1] = self.dropout(atten_encoder[i][j][1])
atten_encoder[i][j][2] = self.encoder_block_att[j](atten_encoder[i][j][1])
#atten_encoder[i][j][2] = self.dropout(atten_enco... | code_fim | hard | {
"lang": "python",
"repo": "saraalrawi/EIN-SELD",
"path": "/seld/methods/ein_seld/models/seld.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liangan1/news path: /phs/university/shandong_university.py
# -*- coding: UTF-8 -*-:
from phs import spider, newsBase
import re
import datetime
import bs4
class ShandongUniversityNews(newsBase.NewsParserBase):
def __init__(self):
super().__init__()
def parse_html(se... | code_fim | hard | {
"lang": "python",
"repo": "liangan1/news",
"path": "/phs/university/shandong_university.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
return self.news_list
if __name__ == '__main__':
news_instance = ShandongUniversityNews()
news_list = news_instance.parse_html()
print("All news:")
for news in news_list:
print(news.get_university(), news.school, news.title, news.date, news.href)
today_news =... | code_fim | hard | {
"lang": "python",
"repo": "liangan1/news",
"path": "/phs/university/shandong_university.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #three
self.set_target_url("http://www.cs.sdu.edu.cn/index/xygg.htm")
target_tags = self.get_tag_by_attr(tag="div", attr="class", value="sub_text")
self.parse_target_tags(target_tags, self.url, "山东大学", "计算机科学与技术学院", is_deeper = False)
#four
self.set_... | code_fim | hard | {
"lang": "python",
"repo": "liangan1/news",
"path": "/phs/university/shandong_university.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for t in threads:
t.join()
finally:
# write to DATA_FILE even when process is interrupted
with open(DATA_FILE, 'w') as data_file:
print ("Rewriting %s with %s entries" %
(DATA_FILE, len(classify_data)))
... | code_fim | hard | {
"lang": "python",
"repo": "ymittal/fb-drive",
"path": "/drive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param file_id file id
:param filename file name
:return boolean denoting whether file was downloaded successfully
"""
# httplib2 library is not thread-safe, need a new http for each thread
drive_service = discovery.build('drive', 'v3', http=get_http())
request = drive... | code_fim | hard | {
"lang": "python",
"repo": "ymittal/fb-drive",
"path": "/drive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ymittal/fb-drive path: /drive.py
from __future__ import print_function
import httplib2
import json
import os
import io
from Queue import Queue
from threading import Thread
from fbrecog import recognize
from apiclient import discovery
from apiclient import errors
from apiclient.http import HttpR... | code_fim | hard | {
"lang": "python",
"repo": "ymittal/fb-drive",
"path": "/drive.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> king_position = self.findKing(self.board,color)
check_board = self.computeCheckBoard(self.board,color)
return check_board[king_position[0]][king_position[1]]
def pawnMoves(self,pawn,board):
moves = []
position = (pawn.i,pawn.j)
for destinat... | code_fim | hard | {
"lang": "python",
"repo": "Amadeus23/Simple-chess-game",
"path": "/board_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Amadeus23/Simple-chess-game path: /board_model.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 17 01:42:42 2018
@author: amadej
"""
#This will be the "model" which has the information of the state of the board
from helper import *
from pieces import *
from copy import ... | code_fim | hard | {
"lang": "python",
"repo": "Amadeus23/Simple-chess-game",
"path": "/board_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> path('createproject/', views.create_project),
path('editproject/', views.edit_project),
path('deleteproject/', views.delete_project),
]<|fim_prefix|># repo: iMaks99/OdooProjectsServer path: /odoo_db/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('getproject... | code_fim | medium | {
"lang": "python",
"repo": "iMaks99/OdooProjectsServer",
"path": "/odoo_db/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iMaks99/OdooProjectsServer path: /odoo_db/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('getprojectsall/', views.get_projects_all),
path('login/', views.login_user),
path('getprojecttasks/', views.get_project_tasks),
path('getprojecttasktype/', vie... | code_fim | medium | {
"lang": "python",
"repo": "iMaks99/OdooProjectsServer",
"path": "/odoo_db/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print BOT_ID in command line
slack_client = slackclient.SlackClient(BOT_TOKEN)
print slack_client
client_connect = slack_client.api_call("users.list").get('ok')
print client_connect
for user in slack_client.api_call("users.list").get('members'):
if user.get('name') == BOT_NAME:
print user.get... | code_fim | medium | {
"lang": "python",
"repo": "joemoded/slack",
"path": "/slack/sf_giants_bot/get_rtm_bot_id.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joemoded/slack path: /slack/sf_giants_bot/get_rtm_bot_id.py
import os, slackclient
# to run, "python get_rtm_bot.py
# after running, export BOT_ID to virtualenv using command line
# before running, export BOT_NAME and BOT_TOKEN to virtualenv using command line
BOT_NAME = os.environ.get('BOT_NAM... | code_fim | medium | {
"lang": "python",
"repo": "joemoded/slack",
"path": "/slack/sf_giants_bot/get_rtm_bot_id.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'ok')
print client_connect
for user in slack_client.api_call("users.list").get('members'):
if user.get('name') == BOT_NAME:
print user.get('id')<|fim_prefix|># repo: joemoded/slack path: /slack/sf_giants_bot/get_rtm_bot_id.py
import os, slackclient
# to run, "python get_rtm_bot.py
# after r... | code_fim | medium | {
"lang": "python",
"repo": "joemoded/slack",
"path": "/slack/sf_giants_bot/get_rtm_bot_id.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Starting web server
print("Starting web server")
processThread = threading.Thread(target=thread_second) # <- note extra ','
processThread.start()
#Getting env variables
apiKey = os.environ["api_key"]
apiSecret = os.environ["api_secret"]
organizationId = os.environ["organization_id"]
print("Apikey :" +a... | code_fim | hard | {
"lang": "python",
"repo": "Antheor0/nicehash-api",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Antheor0/nicehash-api path: /main.py
#!/bin/python3
import nicehash
import json
import os
import sys
import threading
import time
from subprocess import call
def write_file(path,file,message):
pathsys=os.getcwd()
os.chdir(path)
file = open(file, "w")
file.write(message)
file.... | code_fim | hard | {
"lang": "python",
"repo": "Antheor0/nicehash-api",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jeaven/PyTSI path: /testing/mobotix/mobotix.py
import os as os
from tqdm import tqdm
from pysolar.solar import *
import datetime as datetime
import pathlib
import matplotlib.pyplot as plt
import numpy as np
import cv2 as cv2
import matplotlib.gridspec as gridspec
from sklearn import preprocessing... | code_fim | hard | {
"lang": "python",
"repo": "Jeaven/PyTSI",
"path": "/testing/mobotix/mobotix.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cv2.line(masked, (828,457), (693,96), black, 35)
R = masked[:,:,0]
G = masked[:,:,1]
B = masked[:,:,2]
B[B==0]=1
RBRatio = np.zeros((xres,yres),dtype=float)
RBRatio = np.where(B>0, R/B, 0)
sunPixels = cloudPixels = 0
skycoverimage = np.zeros((xres,yres,n_colors),dtype='uint8')
#1 i... | code_fim | hard | {
"lang": "python",
"repo": "Jeaven/PyTSI",
"path": "/testing/mobotix/mobotix.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def getIndexes():
Indexes = []
for x in range(EnvSize):
for y in range(EnvSize):
Indexes.append((x, y))
return Indexes<|fim_prefix|># repo: YeonJae-Choi/WumpusWorld-project path: /constants.py
# 행동 설정
from collections import namedtuple
Agent = 1
Pit = 2
Wumpus = 3
Gold =... | code_fim | medium | {
"lang": "python",
"repo": "YeonJae-Choi/WumpusWorld-project",
"path": "/constants.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def getMatrix(item):
matrix = []
try:
copy = getattr(item, 'copy')
except AttributeError:
copy = None
for i in range(EnvSize):
matrix.append([])
for j in range(EnvSize):
if copy:
matrix[i].append(copy())
else:
... | code_fim | medium | {
"lang": "python",
"repo": "YeonJae-Choi/WumpusWorld-project",
"path": "/constants.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YeonJae-Choi/WumpusWorld-project path: /constants.py
# 행동 설정
from collections import namedtuple
Agent = 1
Pit = 2
Wumpus = 3
Gold = 4
Wind = 5
Stench = 6
EnvSize = 4
def getMatrix(item):
matrix = []
try:
copy = getattr(item, 'copy')
except AttributeError:
copy = N... | code_fim | hard | {
"lang": "python",
"repo": "YeonJae-Choi/WumpusWorld-project",
"path": "/constants.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PratikBali/python-learning path: /automation/windows/run_sp12.py
import os
def main():
sp12 = r'C:\private\perforce_branches\TEF-Peru-mobile-app\PROD_2930_sp12\mobile_app\app'
<|fim_suffix|>if __name__ == "__main__":
main()<|fim_middle|> os.chdir(sp12)
print(sp12 + '\grunt dev')
os.s... | code_fim | medium | {
"lang": "python",
"repo": "PratikBali/python-learning",
"path": "/automation/windows/run_sp12.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
main()<|fim_prefix|># repo: PratikBali/python-learning path: /automation/windows/run_sp12.py
import os
def main():
<|fim_middle|> sp12 = r'C:\private\perforce_branches\TEF-Peru-mobile-app\PROD_2930_sp12\mobile_app\app'
os.chdir(sp12)
print(sp12 + '\grunt dev')
os.s... | code_fim | medium | {
"lang": "python",
"repo": "PratikBali/python-learning",
"path": "/automation/windows/run_sp12.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LotusEcho/AdventOfCode2018 path: /src/day14/day14.py
from datetime import datetime
def find_good_recipes(improvement_num, count):
"""
>>> find_good_recipes(9, 10)
'5158916779'
>>> find_good_recipes(5, 10)
'0124515891'
>>> find_good_recipes(18, 10)
'9251071085'
>>... | code_fim | hard | {
"lang": "python",
"repo": "LotusEcho/AdventOfCode2018",
"path": "/src/day14/day14.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pattern_to_find in ''.join(map(str, recipes[-(len(keys) + 2):])):
not_found = False
if recipes[-1] == keys[-1]:
return len(recipes) - len(keys)
else:
return len(recipes) - len(keys) - 1
if __name__ == "__main__":
start_time = datetime.now()
... | code_fim | hard | {
"lang": "python",
"repo": "LotusEcho/AdventOfCode2018",
"path": "/src/day14/day14.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def measure_the_work(pattern_to_find):
"""
>>> measure_the_work('51589')
9
>>> measure_the_work('01245')
5
>>> measure_the_work('92510')
18
>>> measure_the_work('59414')
2018
:param pattern_to_find: The pattern to look for.
:return: The number of recipes before... | code_fim | hard | {
"lang": "python",
"repo": "LotusEcho/AdventOfCode2018",
"path": "/src/day14/day14.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>>\d+)/$',GroupDetailView.as_view(),name="detail_group"),
re_path(r'^follow_group/(?P<pk>\d+)/$',FollowGroupView.as_view(),name="follow_group"),
re_path(r'^delete_group/(?P<pk>\d+)/$',GroupDeleteView.as_view(),name="delete_group"),
re_path(r'^update_group/(?P<pk>\d+)/$',GroupUpdateView.as_view(... | code_fim | medium | {
"lang": "python",
"repo": "amirbaba316/nerdvana",
"path": "/group/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amirbaba316/nerdvana path: /group/urls.py
from django.urls import path,re_path
from .views import CreateGroup,GroupListView,GroupDetailView,GroupDeleteView,GroupUpdateView,FollowGroupView
urlpatterns=[
<|fim_suffix|>>\d+)/$',GroupDetailView.as_view(),name="detail_group"),
re_path(r'^foll... | code_fim | medium | {
"lang": "python",
"repo": "amirbaba316/nerdvana",
"path": "/group/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.name<|fim_prefix|># repo: ActoSoft/DjangoCourse-FirstDjangoProject path: /groups/models.py
from django.db import models
from django.contrib.auth.models import User
<|fim_middle|>class GroupModel(models.Model):
users = models.ManyToManyField(User, related_na... | code_fim | hard | {
"lang": "python",
"repo": "ActoSoft/DjangoCourse-FirstDjangoProject",
"path": "/groups/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ActoSoft/DjangoCourse-FirstDjangoProject path: /groups/models.py
from django.db import models
from django.contrib.auth.models import User
class GroupModel(models.Model):
<|fim_suffix|> def __str__(self):
return self.name<|fim_middle|> users = models.ManyToManyField(User, related_na... | code_fim | hard | {
"lang": "python",
"repo": "ActoSoft/DjangoCourse-FirstDjangoProject",
"path": "/groups/models.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rint("1",end=" ")
else:
print("0",end=" ")
print()<|fim_prefix|># repo: sub7ata/Pattern-Programs-in-Python path: /pattern97.py
"""
Example
Enter a number: 5
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
"""
num = in<|fim_middle|>t(input("Enter a number: "))
for i in range(1,num+1):
for j in ... | code_fim | medium | {
"lang": "python",
"repo": "sub7ata/Pattern-Programs-in-Python",
"path": "/pattern97.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sub7ata/Pattern-Programs-in-Python path: /pattern97.py
"""
Example
Enter a number: 5
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
"""
num = in<|fim_suffix|>,i+1):
if(i%2!=0 and j%2!=0) or (i%2==0 and j%2==0):
print("1",end=" ")
else:
print("0",end=" ")
print()<|fim_m... | code_fim | medium | {
"lang": "python",
"repo": "sub7ata/Pattern-Programs-in-Python",
"path": "/pattern97.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_python/Problem_155/172.py
import sys
in_file = open(sys.argv[1], "r")
out_file = open("output.out", "w")
t = int(in_file.readline())
<|fim_suffix|> c_max = int(params[0])
c_rest = params[1]
ans = 0
inte = 0
pos = 0
for m i... | code_fim | medium | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_155/172.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> out_file.write("Case #" + str(i + 1) + ": " + str(ans))
out_file.write("\n")
in_file.close()
out_file.close()<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_python/Problem_155/172.py
import sys
in_file = open(sys.argv[1], "r")
out_file = open("output.out", "w")
t = int(i... | code_fim | hard | {
"lang": "python",
"repo": "dr-dos-ok/Code_Jam_Webscraper",
"path": "/solutions_python/Problem_155/172.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Liam-F/rts path: /z_nameddictionaryfiltered.py
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 23 00:17:18 2014
@author: jmalinchak
"""
import nameddictionary #
class filter(nameddictionary):
def __init__(self,directorylocal,Symbol,ExpirationDate,OptionType,Strike,QuoteDatetime):
nd =... | code_fim | hard | {
"lang": "python",
"repo": "Liam-F/rts",
"path": "/z_nameddictionaryfiltered.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute_filtering(self,Symbol,ExpirationDate,OptionType,Strike,QuoteDatetime):
dNamedDictionary = self.MainDictionariesObject.NamedDictionary
#from datetime import datetime
dResult = {}
for KeyOfSymbols in dNamedDictionary.keys():
if KeyOfSymbols == Symb... | code_fim | hard | {
"lang": "python",
"repo": "Liam-F/rts",
"path": "/z_nameddictionaryfiltered.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """If a listlist_op returns something besides a list as output, raise a ValueError."""
@ops.listlist_op
def f(x):
return iter([4, 5, 6]) # Returning an iterator instead of an list
with pytest.raises(ValueError):
result = f([1, 2, 3])
##############################
# Te... | code_fim | hard | {
"lang": "python",
"repo": "msmerlak/LEAP",
"path": "/tests/test_ops.py",
"mode": "spm",
"license": "AFL-2.1",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Constant evaluation should ignore the existing fitness function and
set the fitness of all individuals to the same value."""
pop = test_population
pop = ops.const_evaluate(pop, value=123456789.0)
for ind in pop:
assert(pytest.approx(123456789.0) == ind.fitness)
######... | code_fim | hard | {
"lang": "python",
"repo": "msmerlak/LEAP",
"path": "/tests/test_ops.py",
"mode": "spm",
"license": "AFL-2.1",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msmerlak/LEAP path: /tests/test_ops.py
import collections
import pytest
import leap_ec.ops as ops
from leap_ec.data import test_population
##############################
# Test iteriter_op
##############################
def test_iteriter_op_1():
"""If an iteriter_op is given an iterator a... | code_fim | hard | {
"lang": "python",
"repo": "msmerlak/LEAP",
"path": "/tests/test_ops.py",
"mode": "psm",
"license": "AFL-2.1",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adlenafane/ML path: /Code/Data representation/plot_shorthands.py
# Useful functions for plotting & exporting the graph
import matplotlib.pyplot as pyplot # to plot
#==============================================================================
# Set the fontsize for a legend
def set_legend_font... | code_fim | hard | {
"lang": "python",
"repo": "adlenafane/ML",
"path": "/Code/Data representation/plot_shorthands.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.