text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: honnibal/legacy_thesis_code path: /code/scripts/.svn/text-base/analyseLex.py.svn-base
#!/usr/bin/python
"""
Gather several descriptive systems about a CCGbank instance:
- Number of categories vs n, where n is a frequency threshold
- Avg. category ambiguiy vs n
- Expected category entropy
"""
fro... | code_fim | hard | {
"lang": "python",
"repo": "honnibal/legacy_thesis_code",
"path": "/code/scripts/.svn/text-base/analyseLex.py.svn-base",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def plotLines(lines, title, xLabel, yLabel, fName):
g = Gnuplot.Gnuplot(debug=1)
g('set data style lines')
g.title(title)
data = []
for line, lineTitle in lines:
data.append(Gnuplot.PlotItems.Data(line, title=lineTitle))
g.plot(*data)
g.xlabel(xLabel)
g.yla... | code_fim | hard | {
"lang": "python",
"repo": "honnibal/legacy_thesis_code",
"path": "/code/scripts/.svn/text-base/analyseLex.py.svn-base",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> errors_hogwild_sum_two = [e_sum + e for (e_sum,e) in zip(errors_hogwild_sum_two,errors_hogwild_two)]
times_hogwild_sum_two = [t_sum + t for (t_sum,t) in zip(times_hogwild_sum_two,times_hogwild_two)]
errors_hogwild_sum_four = [e_sum + e for (e_sum,e) in zip(errors_hogwild_sum_four,errors_hogwi... | code_fim | hard | {
"lang": "python",
"repo": "tmarino2/parOja",
"path": "/oja_hogwild.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[samples,covariance,truth] = getSyntheticData(n,d,k)
total_samples = []
for i in range(epochs):
total_samples.extend(samples)
errors_oja_sum = [0]*n
times_oja_sum = [0]*n
errors_hogwild_sum_one = [0]*n
times_hogwild_sum_one = [0]*n
errors_hogwild_sum_two = [0]*n
times_hogwild_sum_two = [0]*n
err... | code_fim | hard | {
"lang": "python",
"repo": "tmarino2/parOja",
"path": "/oja_hogwild.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tmarino2/parOja path: /oja_hogwild.py
import scipy.sparse
from multiprocessing.sharedctypes import Array
from ctypes import c_double
import numpy as np
from multiprocessing import Pool
import matplotlib.pyplot as plt
from time import time
import scipy.io as sio
import sys
# np.random.seed(1)
d... | code_fim | hard | {
"lang": "python",
"repo": "tmarino2/parOja",
"path": "/oja_hogwild.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> MOCK_SRC = 'dummy.jpg'
MOCK_TITLE = 'title'
MOCK_ALT_TEXT = 'alt_text'
def setUp(self):
file1 = File(name='file1.jpg', file=BytesIO(b'abcdef'))
attachment1 = G(Attachment, original_filename='user_friendly_filename1.jpg', file=file1)
self.mock_image_mapper = Mock()... | code_fim | medium | {
"lang": "python",
"repo": "f1nnix/magplan",
"path": "/src/magplan/xmd/tests/test_renderer.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> html = self.renderer.image(self.MOCK_SRC, self.MOCK_TITLE, self.MOCK_ALT_TEXT)
self.mock_image_mapper.assert_called_with(self.MOCK_SRC, self.renderer.attachments)
assert html == self.expected_html<|fim_prefix|># repo: f1nnix/magplan path: /src/magplan/xmd/tests/test_renderer.py
"... | code_fim | hard | {
"lang": "python",
"repo": "f1nnix/magplan",
"path": "/src/magplan/xmd/tests/test_renderer.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: f1nnix/magplan path: /src/magplan/xmd/tests/test_renderer.py
"""
Every block element test will be automatically
wrapped inside `<p></p>\n`. Thats why every block
test should include this wrapper tag.
"""
from io import BytesIO
from unittest import TestCase
from unittest.mock import patch, Mock
... | code_fim | hard | {
"lang": "python",
"repo": "f1nnix/magplan",
"path": "/src/magplan/xmd/tests/test_renderer.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thraxil/gtreed path: /working-env/lib/python2.5/CherryPy-2.2.1-py2.5.egg/cherrypy/test/test_custom_filters.py
"""Test the various means of instantiating and invoking filters."""
import types
import test
test.prefer_parent_path()
import cherrypy
from cherrypy import filters
from cherrypy.filters... | code_fim | hard | {
"lang": "python",
"repo": "thraxil/gtreed",
"path": "/working-env/lib/python2.5/CherryPy-2.2.1-py2.5.egg/cherrypy/test/test_custom_filters.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def err_in_onstart(self):
return "success!"
cherrypy.config.update({
'global': {
# METHOD TWO:
# Declare a classname in server.input_filters.
'server.input_filters': ["cherrypy.test.test_custom_filters.AccessFilter"],
'serve... | code_fim | hard | {
"lang": "python",
"repo": "thraxil/gtreed",
"path": "/working-env/lib/python2.5/CherryPy-2.2.1-py2.5.egg/cherrypy/test/test_custom_filters.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def transform(self, source):
for old, new in self.REPLACEMENTS.items():
source = re.sub("(?m)"+old, new, source)
return source
def run(self, dryrun=True):
self.backup()
self.restore()
for filename in self.filenames:
if not filename.... | code_fim | hard | {
"lang": "python",
"repo": "betty29/code-1",
"path": "/recipes/Python/577788_Simple_Class_Transforming_PythSource/recipe-577788.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FRCTeam279/2018PowerUp path: /commands/tankdrivereseencoders.py
import time
import math
from wpilib import SmartDashboard
from wpilib.command import Command
import robotmap
import subsystems
class TankDriveResetEncoders(Command):
<|fim_suffix|> subsystems.driveline.resetEncoders()
... | code_fim | hard | {
"lang": "python",
"repo": "FRCTeam279/2018PowerUp",
"path": "/commands/tankdrivereseencoders.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__('TankDriveTurnToHeading')
self.requires(subsystems.driveline)
self.setInterruptible(True)
self.setRunWhenDisabled(False)
def execute(self):
subsystems.driveline.resetEncoders()
print("CMD TankDriveResetEncoders: Reset Completed")
d... | code_fim | medium | {
"lang": "python",
"repo": "FRCTeam279/2018PowerUp",
"path": "/commands/tankdrivereseencoders.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>adeResult
from wexapi.models.cancel_order_result import CancelOrderResult
from wexapi.models.order_info import OrderInfo<|fim_prefix|># repo: madmis/wexapi path: /wexapi/models/__init__.py
from wexapi.models.pair_info import PairInfo
from wexapi.models.ticker import Ticker
from wexapi.models.trade import... | code_fim | medium | {
"lang": "python",
"repo": "madmis/wexapi",
"path": "/wexapi/models/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: madmis/wexapi path: /wexapi/models/__init__.py
from wexapi.models.pair_info import PairInfo
from wexapi.models.ticker import Ticker
from wexapi.models.trade import Tr<|fim_suffix|>adeResult
from wexapi.models.cancel_order_result import CancelOrderResult
from wexapi.models.order_info import OrderI... | code_fim | hard | {
"lang": "python",
"repo": "madmis/wexapi",
"path": "/wexapi/models/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>('.fls') or filename.endswith('.fls') or filename.endswith('.bbl') or filename.endswith('.blg') or filename.endswith('.pdf') or filename.endswith('.aux'):
print 'remove log file ' + filepath
os.remove(filepath)<|fim_prefix|># repo: paulklemm/latex-tools path: /cleanLaTeXFolder.py
# Credit: http://r... | code_fim | hard | {
"lang": "python",
"repo": "paulklemm/latex-tools",
"path": "/cleanLaTeXFolder.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paulklemm/latex-tools path: /cleanLaTeXFolder.py
# Credit: http://realiseyourdreams.wordpress.com/latex-scripts/
#Script to clean up a directory tree!
import os,subprocess
#browse the directory
for dirname, dirnames, filenames in os.walk('.'):
for filename in fil<|fim_suffix|>ame.endswith('~'):... | code_fim | hard | {
"lang": "python",
"repo": "paulklemm/latex-tools",
"path": "/cleanLaTeXFolder.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='lwdevice',
name='dev_eui',
field=models.CharField(max_length=16, unique=True, validators=[django.core.validators.RegexValidator('^[0-9a-fA-F]+$', 'Should match the ^[0-9a-fA-F]+$ pattern'), django.core.validato... | code_fim | medium | {
"lang": "python",
"repo": "richhall/tfc_web",
"path": "/tfc_web/csn/migrations/0002_auto_20170509_2118.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: richhall/tfc_web path: /tfc_web/csn/migrations/0002_auto_20170509_2118.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-05-09 21:18
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
from django.utils.timezone import now
... | code_fim | medium | {
"lang": "python",
"repo": "richhall/tfc_web",
"path": "/tfc_web/csn/migrations/0002_auto_20170509_2118.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('csn', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='lwdevice',
name='dev_eui',
field=models.CharField(max_length=16, unique=True, validators=[django.core.validators.RegexValidator('^[0-9a-fA-F]+$', 'Sh... | code_fim | medium | {
"lang": "python",
"repo": "richhall/tfc_web",
"path": "/tfc_web/csn/migrations/0002_auto_20170509_2118.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SheyMouse/caesar-cipher path: /caesarcipher_06.py
#
# CAESAR CIPHER - PART 6
# Add a GUI
# - by JeffGames
#
#
#
# ToDo:
# 1. Add JeffGames icon
# 2. Handle spaces in the string
# Import tkinter, our GUI framework
from tkinter import * # Import tkinter, our GUI framework
root = Tk()
... | code_fim | hard | {
"lang": "python",
"repo": "SheyMouse/caesar-cipher",
"path": "/caesarcipher_06.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Caesar shift slider
caesarFrame = LabelFrame(choicesFrame, padx=2, pady=2)
lblCaesar = Label(caesarFrame, text="Set your Caesar Shift")
sldrCaesar = Scale(caesarFrame, from_=0, to=80, variable=cesar, orient=VERTICAL, command=moveCaesar)
# Encrypt / Decrypt user choices
cryptFrame = LabelFrame(root, pad... | code_fim | hard | {
"lang": "python",
"repo": "SheyMouse/caesar-cipher",
"path": "/caesarcipher_06.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RoggerLuo/biLSTM path: /getBatch.py
import argparse
import tensorflow as tf
import pickle
import math
import numpy as np
from getData import getData
<|fim_suffix|> dev_dataset = tf.data.Dataset.from_tensor_slices((dev_x, dev_y))
dev_dataset = dev_dataset.batch(FLAGS.dev_batch_size)
... | code_fim | hard | {
"lang": "python",
"repo": "RoggerLuo/biLSTM",
"path": "/getBatch.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_dataset = tf.data.Dataset.from_tensor_slices((test_x, test_y))
test_dataset = test_dataset.batch(FLAGS.test_batch_size)
return train_dataset,dev_dataset,test_dataset<|fim_prefix|># repo: RoggerLuo/biLSTM path: /getBatch.py
import argparse
import tensorflow as tf
import pickle
import ma... | code_fim | hard | {
"lang": "python",
"repo": "RoggerLuo/biLSTM",
"path": "/getBatch.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cgosmeyer/learning_statistics path: /stats/tables/load_table.py
"""
Author:
C.M. Gosmeyer
Date:
Mar 2018
References:
"Introduction to Statistical Problem Solving in Geography",
J.C. McGrew, Jr., A.J. Lembo, Jr., C.B. Monroe
To Do:
Should tables interpolate?
... | code_fim | hard | {
"lang": "python",
"repo": "cgosmeyer/learning_statistics",
"path": "/stats/tables/load_table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
prob : float
The probability, i.e., the area under section of probability
distriubtion curve.
"""
normal_table = self.normal_table
if z > 4:
prob = 0.5
else:
z0 = round(z, 1)
... | code_fim | hard | {
"lang": "python",
"repo": "cgosmeyer/learning_statistics",
"path": "/stats/tables/load_table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
df : int
Degrees of freedom (size of sample).
confidence : float
The confidence level (area under distriubtion curve within
interval).
Returns
-------
t_score : float
The test st... | code_fim | hard | {
"lang": "python",
"repo": "cgosmeyer/learning_statistics",
"path": "/stats/tables/load_table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render_template('output.html', sentence=st, sent=sent, emoji=emoji, address=address)
@app.route('/fu.html')
def result():
return render_template('fu.html')
@app.route('/new.html')
def new():
return render_template('new.html')
if __name__ == '__main__':
app.run(debug=True)<|f... | code_fim | hard | {
"lang": "python",
"repo": "rahulpro2001/sentiment-analysis",
"path": "/app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rahulpro2001/sentiment-analysis path: /app.py
import spacy
from vaderSentiment import vaderSentiment
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def hello():
return render_template('index.html')
@app.route('/',methods=['POST'])
def func():
... | code_fim | hard | {
"lang": "python",
"repo": "rahulpro2001/sentiment-analysis",
"path": "/app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for dict in list:
response = requests.post(url, json=dict)
if(response.status_code == 200):
forDEBUG("SEND_SUCC", dict["title"])
else:
forDEBUG("SEND_FAIL", dict["title"])
def forDEBUG(p1, p2):
print("DEBUG:: {}, {}".format(p1, p2))
def action():... | code_fim | hard | {
"lang": "python",
"repo": "zhengsihan/scripts",
"path": "/Coursera/lab2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhengsihan/scripts path: /Coursera/lab2.py
#! /usr/bin/env python3
import os
import requests
# import json
external_ip = "xx"
data_path = "/data/feedback/"
url = "http://{}/feedback/".format(external_ip)
def read():
<|fim_suffix|>def send(list):
for dict in list:
response = request... | code_fim | hard | {
"lang": "python",
"repo": "zhengsihan/scripts",
"path": "/Coursera/lab2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JaeGyu/PythonEx_1 path: /py200_049-1.py
class MyClass:
name = "alice"
def set_name(self, name):
self.name = name
def get_name(self):
return self.name
<|fim_suffix|>
p1 = MyClass()
p2 = MyClass()
print(p1.name)
p1.set_name("bob")
print(p1.name)
print(p... | code_fim | medium | {
"lang": "python",
"repo": "JaeGyu/PythonEx_1",
"path": "/py200_049-1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(p2.name)
# 인스턴스 멤버를 적용한후에 그 인스턴스 멤버에 접근 할 수 있다
p1.say_hello()
print(p1.greet)
#클래스 메서드를 클래스. 으로 호출 했기 떄문에 self 파라미터를 하나 넘겨 줘야 한다
MyClass.say_hi("gg")<|fim_prefix|># repo: JaeGyu/PythonEx_1 path: /py200_049-1.py
class MyClass:
name = "alice"
def set_name(self, name):
self.nam... | code_fim | hard | {
"lang": "python",
"repo": "JaeGyu/PythonEx_1",
"path": "/py200_049-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(p1.name)
p1.set_name("bob")
print(p1.name)
print(p2.name)
# 인스턴스 멤버를 적용한후에 그 인스턴스 멤버에 접근 할 수 있다
p1.say_hello()
print(p1.greet)
#클래스 메서드를 클래스. 으로 호출 했기 떄문에 self 파라미터를 하나 넘겨 줘야 한다
MyClass.say_hi("gg")<|fim_prefix|># repo: JaeGyu/PythonEx_1 path: /py200_049-1.py
class MyClass:
name = "alice"
... | code_fim | hard | {
"lang": "python",
"repo": "JaeGyu/PythonEx_1",
"path": "/py200_049-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vprusso/toqito path: /tests/test_perms/test_antisymmetric_projection.py
"""Test antisymmetric_projection."""
import numpy as np
from toqito.perms import antisymmetric_projection
def test_antisymmetric_projection_d_2_p_1():
"""Dimension is 2 and p is equal to 1."""
res = antisymmetric_p... | code_fim | medium | {
"lang": "python",
"repo": "vprusso/toqito",
"path": "/tests/test_perms/test_antisymmetric_projection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_antisymmetric_projection_3_3_true():
"""The `dim` is 3, the `p` is 3, and `partial` is True."""
res = antisymmetric_projection(3, 3, True).todense()
np.testing.assert_equal(np.isclose(res[5].item(), -0.40824829), True)
if __name__ == "__main__":
np.testing.run_module_suite()<|fi... | code_fim | hard | {
"lang": "python",
"repo": "vprusso/toqito",
"path": "/tests/test_perms/test_antisymmetric_projection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>numero = int(input("Insira um número: "))
if numero % 2 == 0:
p = numero
print (p, "é um número par")
else:
i = numero
print (i, "é um número ímpar")<|fim_prefix|># repo: joaocjn/def-par-impar-python path: /def-par-impar-python.py
#função: Definir se o número inserido é ímpar ou par
#autor: João Cân... | code_fim | easy | {
"lang": "python",
"repo": "joaocjn/def-par-impar-python",
"path": "/def-par-impar-python.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joaocjn/def-par-impar-python path: /def-par-impar-python.py
#função: Definir se o número inserido é ímpar ou par
#autor: João Cândido
<|fim_suffix|>numero = int(input("Insira um número: "))
if numero % 2 == 0:
p = numero
print (p, "é um número par")
else:
i = numero
print (i, "é um número í... | code_fim | easy | {
"lang": "python",
"repo": "joaocjn/def-par-impar-python",
"path": "/def-par-impar-python.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if numero % 2 == 0:
p = numero
print (p, "é um número par")
else:
i = numero
print (i, "é um número ímpar")<|fim_prefix|># repo: joaocjn/def-par-impar-python path: /def-par-impar-python.py
#função: Definir se o número inserido é ímpar ou par
#autor: João Cândido
p = 0
i = 0
<|fim_middle|>numero = i... | code_fim | easy | {
"lang": "python",
"repo": "joaocjn/def-par-impar-python",
"path": "/def-par-impar-python.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liqingxuan/ECS165 path: /3g.py
import psycopg2
#open databse connection
db = psycopg2.connect(database = "postgres")
###################------------3g------------####################
#####Question 3g##### What percent of students transfer into one of the ABC majors?
cursor3g1 = db.cursor()
#... | code_fim | hard | {
"lang": "python",
"repo": "liqingxuan/ECS165",
"path": "/3g.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#for loop, while i=0, i<array.length, i++
for index in range(len(preABC)):
#print preABC[index]
cursor3g3.execute("SELECT COUNT(SID) FROM Student WHERE PRE_ABC_MAJOR = %s",[preABC[index]])
cntTrans = cursor3g3.fetchone()
sumTrans = sumTrans + cntTrans[0]
preABC[index] = preABC[index] +... | code_fim | medium | {
"lang": "python",
"repo": "liqingxuan/ECS165",
"path": "/3g.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: C-CCM-TC1028-111-2113/homework-4-Guillermofdz27 path: /assignments/17NCuadradoMayor/src/exercise.py
def main():
#Escribe tu código debajo de esta líne<|fim_suffix|>))
y= math.sqrt(x)
z= round(y)
u= z+1
print(str(u))
pass
if __name__=='__main__':
main()<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "C-CCM-TC1028-111-2113/homework-4-Guillermofdz27",
"path": "/assignments/17NCuadradoMayor/src/exercise.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>int(str(u))
pass
if __name__=='__main__':
main()<|fim_prefix|># repo: C-CCM-TC1028-111-2113/homework-4-Guillermofdz27 path: /assignments/17NCuadradoMayor/src/exercise.py
def main():
#Escribe tu código debajo de esta línea
import math
x= int(input("Escribe un numero: "<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "C-CCM-TC1028-111-2113/homework-4-Guillermofdz27",
"path": "/assignments/17NCuadradoMayor/src/exercise.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PyRPy/algorithms_books path: /leetcode/longest_palindrome2.py
# longest_palindrome2.py
class Solution:
def longestPalindrome(self, s):
<|fim_suffix|> result = result * 2 + 1 if mark > 0 else result * 2
return result if result > 0 else (1 if mark > 0 else 0)
s = "abccccdd"
sol... | code_fim | hard | {
"lang": "python",
"repo": "PyRPy/algorithms_books",
"path": "/leetcode/longest_palindrome2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = result * 2 + 1 if mark > 0 else result * 2
return result if result > 0 else (1 if mark > 0 else 0)
s = "abccccdd"
sol = Solution()
print(s)
print(sol.longestPalindrome(s))<|fim_prefix|># repo: PyRPy/algorithms_books path: /leetcode/longest_palindrome2.py
# longest_palindrome2.p... | code_fim | medium | {
"lang": "python",
"repo": "PyRPy/algorithms_books",
"path": "/leetcode/longest_palindrome2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fzh14/Add_LSTM path: /SST_LSTM.py
import tensorflow as tf
import gensim
import string
import numpy as np
import random
##### prepare data
path = 'stanfordSentimentTreebank/output_50d.txt'
# model_path = 'stanfordSentimentTreebank/output'
# model = gensim.models.Word2Vec.load(model_path)
model = ... | code_fim | hard | {
"lang": "python",
"repo": "fzh14/Add_LSTM",
"path": "/SST_LSTM.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Unstack to get a list of 'n_steps' tensors of shape (batch_size, n_input)
x = tf.unstack(x, sentence_max, 1)
# Define a lstm cell with tensorflow
lstm_cell = tf.contrib.rnn.BasicLSTMCell(n_hidden)
# Get lstm cell output, providing 'sequence_length' will perform dynamic
# calcul... | code_fim | hard | {
"lang": "python",
"repo": "fzh14/Add_LSTM",
"path": "/SST_LSTM.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Network Parameters
n_input = 50 # data input (shape: 50*56)
n_steps = 56 # timesteps
n_hidden = 128 # hidden layer num of features
n_classes = 5 # total classes
x = tf.placeholder(tf.float32, [None, n_steps, n_input])
y = tf.placeholder(tf.float32, [None, n_classes])
z = tf.placeholder(tf.int32, [b... | code_fim | hard | {
"lang": "python",
"repo": "fzh14/Add_LSTM",
"path": "/SST_LSTM.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def indel_recalibrate_gatk(self, genotype_vcf_in, outputs):
'''INDEL recalibration using GATK'''
recal_indel_out, tranches_indel_out, indel_plots_r_out = outputs
cores = self.get_stage_options('indel_recalibrate_gatk', 'cores')
gatk_args = "-T VariantRecalibrator --disa... | code_fim | hard | {
"lang": "python",
"repo": "khalidm/thepipeline",
"path": "/src/stages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: khalidm/thepipeline path: /src/stages.py
' \
'| samtools view -b -h -o {bam} -' \
.format(cores=cores,
read_group=read_group,
fastq_read1=fastq_read1_in,
fastq_read2=fastq_read2_in,
... | code_fim | hard | {
"lang": "python",
"repo": "khalidm/thepipeline",
"path": "/src/stages.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Apply SNP recalibration using GATK'''
genotype_vcf_in, [recal_snp, tranches_snp] = inputs
cores = self.get_stage_options('apply_snp_recalibrate_gatk', 'cores')
gatk_args = "-T ApplyRecalibration --disable_auto_index_creation_and_locking_when_reading_rods " \
... | code_fim | hard | {
"lang": "python",
"repo": "khalidm/thepipeline",
"path": "/src/stages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Andrewme/GrammarAnalyse path: /GrammarAnalyse/algorithms.py
import re
class Algorithms():
def UnNTerminals(self, inputData):
print "Unproductive not terminals"
t_out = []
t_in = []
unproductive = []
productive = []
'''split by rows'''
... | code_fim | hard | {
"lang": "python",
"repo": "Andrewme/GrammarAnalyse",
"path": "/GrammarAnalyse/algorithms.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _productive = []
for i in range(len(t_out)):
if self._CharCase(t_out[i]):
if t_in[i][0] not in _productive:
_productive.append(t_in[i][0])
for i in range(len(t_out)):
if self._CharCaseProductiv(t_out[i], _productive):
... | code_fim | hard | {
"lang": "python",
"repo": "Andrewme/GrammarAnalyse",
"path": "/GrammarAnalyse/algorithms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _t_in = []
s_nter = re.compile(r"[^\w+ -> ]")
[_t_in.append(s_nter.split(inputData[i][0]))
for i in range(0, len(inputData))]
return _t_in
'''# is Epsilon'''
def _CharCase(self, data):
if data.islower() or da... | code_fim | hard | {
"lang": "python",
"repo": "Andrewme/GrammarAnalyse",
"path": "/GrammarAnalyse/algorithms.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: exueyuanAlgorithm/AlgorithmDemo path: /LeetCode算法题/1252_奇数值单元格的数目/奇数值单元格的数目.py
class Solution(object):
def oddCells(self, m, n, indices):
"""
:type m: int
:type n: int
:type indices: List[List[int]]
:rtype: <|fim_suffix|> x_num += 1
for key, ite... | code_fim | hard | {
"lang": "python",
"repo": "exueyuanAlgorithm/AlgorithmDemo",
"path": "/LeetCode算法题/1252_奇数值单元格的数目/奇数值单元格的数目.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x_num += 1
for key, item in indice_y_dict.items():
if item % 2 == 1:
y_num += 1
return x_num * n + y_num * m - x_num * y_num * 2<|fim_prefix|># repo: exueyuanAlgorithm/AlgorithmDemo path: /LeetCode算法题/1252_奇数值单元格的数目/奇数值单元格的数目.py
class Solution(object):
def... | code_fim | hard | {
"lang": "python",
"repo": "exueyuanAlgorithm/AlgorithmDemo",
"path": "/LeetCode算法题/1252_奇数值单元格的数目/奇数值单元格的数目.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SalzPUG/json path: /test_json.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from nose.tools import *
from json import json
def test_json_basestring():
assert_equals(json("Hello World"), '"Hello World"')
def test_json_integer():
assert_equals(json(9), "9")
def test_json_float():
... | code_fim | hard | {
"lang": "python",
"repo": "SalzPUG/json",
"path": "/test_json.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = []
assert_equals(json(data), "[]")
def test_empty_dict():
data = {}
assert_equals(json(data), "{}")
def test_list_with_empty_dict():
data = [{}]
assert_equals(json(data), "[{}]")
def test_rangie2():
data = {"": 0}
assert_equals(json(data), '{"":0}')
... | code_fim | hard | {
"lang": "python",
"repo": "SalzPUG/json",
"path": "/test_json.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WooWooNursat/DjangoEndTermProject path: /project/main/serializers.py
from rest_framework import serializers
from main.models import Category, Product, Wear, Food, Order, Cart
from auth_.serializers import ClientSerializer, CourierSerializer, StaffSerializer
class CategorySerializer(serializers.... | code_fim | hard | {
"lang": "python",
"repo": "WooWooNursat/DjangoEndTermProject",
"path": "/project/main/serializers.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class GetCartSerializer(serializers.ModelSerializer):
client = ClientSerializer()
products = ProductSerializer(many=True)
class Meta:
model = Cart
fields = ('products', 'client')<|fim_prefix|># repo: WooWooNursat/DjangoEndTermProject path: /project/main/serializers.py
from r... | code_fim | hard | {
"lang": "python",
"repo": "WooWooNursat/DjangoEndTermProject",
"path": "/project/main/serializers.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afatka/Pabuito path: /cat_class.py
text = grade_to_set['comment_text'])
self.update_subcategory('comments_text')
if grade_to_set['default_comments_text'] is not '':
cmds.scrollField(self.default_comments, edit = True, text = grade_to_set['default_comments_text'])
self.update_subcateg... | code_fim | hard | {
"lang": "python",
"repo": "afatka/Pabuito",
"path": "/cat_class.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update_is_complete(self, reset = False):
self.log('updating "is_complete"')
if reset:
self.is_complete = False
self.log('is_complete: reset')
elif self.current_grade_value is 0 and self.current_default_comment_text is '':
self.is_complete = False
self.log('not complete')
else:
... | code_fim | hard | {
"lang": "python",
"repo": "afatka/Pabuito",
"path": "/cat_class.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afatka/Pabuito path: /cat_class.py
ow to cancel.')
self.add_comment_to_comments(comment)
def reorder_comments(*args):
self.log('reorder comments')
comment_items = cmds.popupMenu(self.rmb_menu, query = True, itemArray = True)
comment_items[-1], comment_items[-2] = comment_items[-2],... | code_fim | hard | {
"lang": "python",
"repo": "afatka/Pabuito",
"path": "/cat_class.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gregorioospina/NidooSprint4 path: /NIDOO/usuarios/urls.py
from django.urls import path
from django.conf.urls import url, include
<|fim_suffix|>urlpatterns = [
url('^$', views.index),
url(r'^usuarios/', views.UsuarioList),
url(r'^capacidades/', views.CapacidadList, name='capacid... | code_fim | easy | {
"lang": "python",
"repo": "gregorioospina/NidooSprint4",
"path": "/NIDOO/usuarios/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
url('^$', views.index),
url(r'^usuarios/', views.UsuarioList),
url(r'^capacidades/', views.CapacidadList, name='capacidadList'),
url(r'^capacidad/(?P<id_capacidad>\d+)/$', views.CapacidadEdit, name='capacidadList'),
url(r'^', include('django.contrib.auth.urls')),
... | code_fim | easy | {
"lang": "python",
"repo": "gregorioospina/NidooSprint4",
"path": "/NIDOO/usuarios/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> count == count + 1
print<|fim_prefix|># repo: JRBenson01/Python path: /Names.py
count = 0
names = ["Adam","Alex","Mariah","Martine","Columbus"]
for name in<|fim_middle|> names:
if name == "Adam":
| code_fim | easy | {
"lang": "python",
"repo": "JRBenson01/Python",
"path": "/Names.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JRBenson01/Python path: /Names.py
count = 0
names = ["Adam","Alex","Mar<|fim_suffix|> names:
if name == "Adam":
count == count + 1
print<|fim_middle|>iah","Martine","Columbus"]
for name in | code_fim | easy | {
"lang": "python",
"repo": "JRBenson01/Python",
"path": "/Names.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(Spacer, self).__init__(**kwargs)
self.width_hint = width<|fim_prefix|># repo: chipaca/caw path: /caw/widgets/spacer.py
import caw.widget
<|fim_middle|>class Spacer(caw.widget.Widget):
def __init__(self, width=5, **kwargs):
| code_fim | medium | {
"lang": "python",
"repo": "chipaca/caw",
"path": "/caw/widgets/spacer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chipaca/caw path: /caw/widgets/spacer.py
import caw.widget
class Spacer(caw.widget.Widget):
<|fim_suffix|> super(Spacer, self).__init__(**kwargs)
self.width_hint = width<|fim_middle|> def __init__(self, width=5, **kwargs):
| code_fim | easy | {
"lang": "python",
"repo": "chipaca/caw",
"path": "/caw/widgets/spacer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fmdaboville/flask-discord-interactions path: /examples/components.py
import os
import sys
from flask import Flask
# This is just here for the sake of examples testing
# to make sure that the imports work
# (you don't actually need it in your code)
sys.path.insert(1, ".")
from flask_discord_int... | code_fim | hard | {
"lang": "python",
"repo": "fmdaboville/flask-discord-interactions",
"path": "/examples/components.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Link buttons don't need a handler
@discord.command()
def google(ctx):
return Response(
content="search engine",
components=[
ActionRow(components=[
Button(
style=ButtonStyles.LINK,
url="https://www.google.com/",
... | code_fim | hard | {
"lang": "python",
"repo": "fmdaboville/flask-discord-interactions",
"path": "/examples/components.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Return nothing for no action
@discord.custom_handler()
def handle_do_nothing(ctx):
print("Doing nothing...")
@discord.command()
def do_nothing(ctx):
return Response(
content="Do nothing",
components=[
ActionRow(components=[
Button(
... | code_fim | hard | {
"lang": "python",
"repo": "fmdaboville/flask-discord-interactions",
"path": "/examples/components.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Choitae/AnotherPy path: /ex2_4.py
#동일한 물건을 A매장에서는 20%, B매장에서는 10% 할인 후 11% 할인(중복할인)한다. 물건이 10,000원일 때 어던 쇼핑몰에서 싸게 살 수 있을까?
<|fim_suffix|>#마켓 B에서의 할인율과 물품 가격
sale_percent_M_B_1 = float(input("B 마켓 1차 할인율 : ")) /100
sale_percent_M_B_2 = float(input("B 마켓 2차 할인율 : ")) /100
market_b = item_price*(1-... | code_fim | hard | {
"lang": "python",
"repo": "Choitae/AnotherPy",
"path": "/ex2_4.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("B 매장에서의 할인된 물품 가격은", market_b, "원 이다")
if market_b > market_a :
print("마켓 A에서 물품을 구입하는 것이 더 낫다")
elif market_a == market_b:
print("마켓 A와 마켓 B에서의 물품 가격은 동일하다")
else :
print("마켓 B에서의 물품 가격이 더 싸다")<|fim_prefix|># repo: Choitae/AnotherPy path: /ex2_4.py
#동일한 물건을 A매장에서는 20%, B매장에서는 10% 할... | code_fim | hard | {
"lang": "python",
"repo": "Choitae/AnotherPy",
"path": "/ex2_4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mconlon17/vivo-foundation path: /test_get_webpage.py
"""
test_get_webpage.py -- Given a URI of a webpage, return a python
structure representing the attributes of the webpage
Version 0.1 MC 2013-12-27
-- Initial version
Version 0.2 MC 2014-09-21
-- Update for PEP 8, Too... | code_fim | medium | {
"lang": "python",
"repo": "mconlon17/vivo-foundation",
"path": "/test_get_webpage.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>__author__ = "Michael Conlon"
__copyright__ = "Copyright 2014, University of Florida"
__license__ = "BSD 3-Clause license"
__version__ = "0.2"
from vivofoundation import get_webpage
from datetime import datetime
print datetime.now(), "Start"
webpages = \
[
"http://vivo.ufl.edu/individual/n35... | code_fim | medium | {
"lang": "python",
"repo": "mconlon17/vivo-foundation",
"path": "/test_get_webpage.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @commands.command(brief='Shows you my ping', help="Using this command i'll tell you my latency")
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.client.latency * 1000, 2)} ms')
@commands.command(brief='A link so you can invite me to other servers')
async def invi... | code_fim | medium | {
"lang": "python",
"repo": "javidelrojoo/Richard-Feynman-bot",
"path": "/cogs/others.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: javidelrojoo/Richard-Feynman-bot path: /cogs/others.py
import discord
from discord.ext import commands
import asyncio
import os
class Others(commands.Cog):
<|fim_suffix|> self.client = client
@commands.command(brief='Shows you my ping', help="Using this command i'll tell you my l... | code_fim | medium | {
"lang": "python",
"repo": "javidelrojoo/Richard-Feynman-bot",
"path": "/cogs/others.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = patterns('',
('^test/',test),
('^welcome/',welcome),
('^books/',books),
(r'^admin/',include(admin.site.urls)),
)<|fim_prefix|># repo: JimDuggan/CT216 path: /Django Examples/mysitev2/mysite/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import... | code_fim | easy | {
"lang": "python",
"repo": "JimDuggan/CT216",
"path": "/Django Examples/mysitev2/mysite/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JimDuggan/CT216 path: /Django Examples/mysitev2/mysite/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
<|fim_suffix|>urlpatterns = patterns('',
('^test/',test),
('^welcome/',welcome),
('^books/',books),
(r'^admin/',include(admin.site.u... | code_fim | medium | {
"lang": "python",
"repo": "JimDuggan/CT216",
"path": "/Django Examples/mysitev2/mysite/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c = NeuronRecordingCreator('test_binary_recording.h5')
self.register_recording_creator(c)
c.add_binary_recording(os.path.abspath('neuron_recordings/binary/voltage.dat'), variable_name='v', variable_unit='mV')
c.add_binary_recording(os.path.abspath('neuron_recordings/binary/... | code_fim | hard | {
"lang": "python",
"repo": "openworm/org.geppetto.recording",
"path": "/org/geppetto/recording/creators/tests/test_neuron.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openworm/org.geppetto.recording path: /org/geppetto/recording/creators/tests/test_neuron.py
import unittest
import os
from org.geppetto.recording.creators import NeuronRecordingCreator
from org.geppetto.recording.creators.tests.abstest import AbstractTestCase
class NeuronRecordingCreatorTestCas... | code_fim | hard | {
"lang": "python",
"repo": "openworm/org.geppetto.recording",
"path": "/org/geppetto/recording/creators/tests/test_neuron.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_py_model(self):
c = NeuronRecordingCreator('test_py_model.h5')
self.register_recording_creator(c)
c.record_model(os.path.abspath('neuron_models/sthB.py'))
# TODO: Make test model shorter and run assertEquals.
c.create()
if __name__ == '__main__':
... | code_fim | hard | {
"lang": "python",
"repo": "openworm/org.geppetto.recording",
"path": "/org/geppetto/recording/creators/tests/test_neuron.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
with open(inputfile) as f:
content = f.readlines()
except:
print('File could not be opened.')
sys.exit(3)
content = [line.strip() for line in content]
invitecount = 0
for email in content:
if (email!=""):
r = requests.post('https://api.github.com/orgs/' + org + '/invi... | code_fim | hard | {
"lang": "python",
"repo": "prasadad99/github_batch_organisation_invite",
"path": "/github_batchadd.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prasadad99/github_batch_organisation_invite path: /github_batchadd.py
# An OAuth access token is needed, see: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token
# Rate limit is 500 per day or 50 if you do not meet certain requirements.... | code_fim | hard | {
"lang": "python",
"repo": "prasadad99/github_batch_organisation_invite",
"path": "/github_batchadd.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lorilew/readit path: /util.py
import time
from django_rq.decorators import job
import django_rq
import rq
import logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
<|fim_suffix|># def my_handler(job, exc_type, exc_value, traceback):
# job.meta... | code_fim | medium | {
"lang": "python",
"repo": "lorilew/readit",
"path": "/util.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> time.sleep(2)
print("Look at me I'm printing something!...{}".format(the_thing))
1 / 0
# def my_handler(job, exc_type, exc_value, traceback):
# job.meta.setdefault('failures', 0)
# job.meta['failures'] += 1
#
# if job.meta['failures'] >= 3:
# logger.warn('job:{} has faile... | code_fim | medium | {
"lang": "python",
"repo": "lorilew/readit",
"path": "/util.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# 找规律,如果输入a输出b,则输入2a输出2*(a-b+1)
class Solution(object):
def lastRemaining(self, n):
if n == 1:
return 1
return 2 * (n/2 - self.lastRemaining(n/2) + 1)<|fim_prefix|># repo: linwt/nowcoder-leetcode path: /leetcode_Python/390.消除游戏.py
# 按题目说明解法
class Solution(object):
def... | code_fim | hard | {
"lang": "python",
"repo": "linwt/nowcoder-leetcode",
"path": "/leetcode_Python/390.消除游戏.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linwt/nowcoder-leetcode path: /leetcode_Python/390.消除游戏.py
# 按题目说明解法
class Solution(object):
def lastRemaining(self, n):
<|fim_suffix|># 找规律,如果输入a输出b,则输入2a输出2*(a-b+1)
class Solution(object):
def lastRemaining(self, n):
if n == 1:
return 1
return 2 * (n/2 - self... | code_fim | hard | {
"lang": "python",
"repo": "linwt/nowcoder-leetcode",
"path": "/leetcode_Python/390.消除游戏.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print "From: " + str(fromdt)
print "Until: " + str(untildt)
# Pack arguments for search API call
API_request = (args.query, formatForDB)
API_dates = (fromdt, untildt, step)
API_output = (args.outputFile, 1, 1)
API_credentials = (args.accountFqdn, args.username, args.password)
# launch search
getSearch(... | code_fim | hard | {
"lang": "python",
"repo": "mostlyjason/LogglyExportTools",
"path": "/DownloadJSON.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>untildt = datetime.datetime.today() - datetime.timedelta(days=0)
untildt = untildt.replace(hour=0, minute=0, second=0, microsecond=0)
fromdt = datetime.datetime.today() - datetime.timedelta(days=1)
fromdt = fromdt.replace(hour=0, minute=0, second=0, microsecond=0)
step = 86400
print "From: " + str(fromdt... | code_fim | hard | {
"lang": "python",
"repo": "mostlyjason/LogglyExportTools",
"path": "/DownloadJSON.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mostlyjason/LogglyExportTools path: /DownloadJSON.py
import sys, requests, json, datetime, argparse
from queryAPI import getSearch, getUTCtime
from FormatForDB import formatForDB
parser = argparse.ArgumentParser()
parser.add_argument("username")
parser.add_argument("password")
parser.add_argumen... | code_fim | hard | {
"lang": "python",
"repo": "mostlyjason/LogglyExportTools",
"path": "/DownloadJSON.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 20jna/jayna-projects path: /intro-CS/ngrams.py
# ngrams.py
# A program that tallies n-gram counts in given text files
# Eric Alexander
# CS 111
def getOneGrams(filename):
''' Function takes in a given text filename and counts one-grams in the file '''
oneGramCounts = {}
w... | code_fim | hard | {
"lang": "python",
"repo": "20jna/jayna-projects",
"path": "/intro-CS/ngrams.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ''' Function takes a dictionary mapping n-grams to counts and prints top n n-grams by count. '''
dictItems = list(countDict.items())
dictItems.sort()
dictItems.sort(key=lambda pair: pair[1], reverse=True)
for i in range(n):
word, count = dictItems[i]
print('{}... | code_fim | hard | {
"lang": "python",
"repo": "20jna/jayna-projects",
"path": "/intro-CS/ngrams.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(n):
word, count = dictItems[i]
print('{} {}'.format(word, count))
def main():
filename = 'Shakespeare/Hamlet.txt'
oneGramDict = getOneGrams(filename)
printTopN(oneGramDict, 50)
if __name__ == '__main__':
main()<|fim_prefix|># repo: 20jna/jayna... | code_fim | hard | {
"lang": "python",
"repo": "20jna/jayna-projects",
"path": "/intro-CS/ngrams.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edutilos6666/PythonSciStudentProject path: /gui/StudentSaveWindow.py
import sys
from PyQt5.QtWidgets import QApplication , QWidget, QPushButton, QTableWidgetItem
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QHBoxLayout, QGroupBox , QDialog, QVBoxLayo... | code_fim | hard | {
"lang": "python",
"repo": "edutilos6666/PythonSciStudentProject",
"path": "/gui/StudentSaveWindow.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
rowPosition = self.tableWidget.rowCount()
self.tableWidget.insertRow(rowPosition)
self.tableWidget.setItem(rowPosition, 0, QTableWidgetItem(enrolmentNumber))
self.tableWidget.setItem(rowPosition, 1, QTableWidgetItem(firstName))
self.tableWidget.... | code_fim | hard | {
"lang": "python",
"repo": "edutilos6666/PythonSciStudentProject",
"path": "/gui/StudentSaveWindow.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cbs-iiith/volttron path: /services/core/MongodbAggregateHistorian/aggregator/aggregator.py
# -*- coding: utf-8 -*- {{{
# vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
#
# Copyright 2017, Battelle Memorial Institute.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may... | code_fim | hard | {
"lang": "python",
"repo": "cbs-iiith/volttron",
"path": "/services/core/MongodbAggregateHistorian/aggregator/aggregator.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_agg_topic_map(self):
return mongoutils.get_agg_topic_map(self.dbclient,
self._agg_topic_collection)
def get_aggregation_list(self):
return ['SUM', 'COUNT', 'AVG', 'MIN', 'MAX', 'STDDEVPOP',
'STDDEVSAMP']
d... | code_fim | hard | {
"lang": "python",
"repo": "cbs-iiith/volttron",
"path": "/services/core/MongodbAggregateHistorian/aggregator/aggregator.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ A method which returns values for a parameter name for a given date"""
result =[]
query_params = {'parameter_name':params[1],'et_log_date':params[0]}
logging.debug("Query params : parameter_name {} and date {}".format(params[1],params[0]))
query = """select a.ke... | code_fim | hard | {
"lang": "python",
"repo": "nachiketgalande/UIHome",
"path": "/stg-nrtviewer.web.att.com/htdocs/vertica_getter.py",
"mode": "spm",
"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.