text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> for word in gen1():
yield word
for word in gen2():
yield word
def full_gen_with_itertools():
import itertools
for word in itertools.chain(gen1(), gen2()):
yield word
fg = full_gen()
print next(fg)
print "--------"
fgi = full_gen_with_itertools()
print next(fgi)
... | code_fim | medium | {
"lang": "python",
"repo": "manojkumar-github/books",
"path": "/professional-python/part-1/Generators/generators-within-generators.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def full_gen():
yield from gen1()
yield from gen2()
"""
Use of the syntax "yield from" is referred to generator delegation
This implementation is different from first two implementations because former implementation
discards any value sent to the generator using "send".
Where as "yield from" syn... | code_fim | hard | {
"lang": "python",
"repo": "manojkumar-github/books",
"path": "/professional-python/part-1/Generators/generators-within-generators.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gokayozcoban/3.b.-Data-Types---Strings-Veri-tipleri---Dizinler- path: /3.b. Data Types - Strings (Veri tipleri - Dizinler).py
# DATA TYPES (DATA TİPLERİ)
# STRİNGS (KARAKTER DİZİNLERİ)
# Bir karakter dizinini tanımlamak için tırnaklar kullanılır. birkaç satır ka-
# rakter dizini yazıyorsak... | code_fim | hard | {
"lang": "python",
"repo": "gokayozcoban/3.b.-Data-Types---Strings-Veri-tipleri---Dizinler-",
"path": "/3.b. Data Types - Strings (Veri tipleri - Dizinler).py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Farklı tırnakların olmasının nedeni, tek tırnakla ayrılan özel isimlerin ayrım
# işaretinin çıktıyı string olarak kabul etmesini önlemek:
print("Türkiye'nin başkenti Ankara'dır.")
Türkiye'nin başkenti Ankara'dır.
# Yukarıdaki gibi bir çıktı almak için çift tırnak ("") kullandım. Çünkü tek
# tırnak ... | code_fim | hard | {
"lang": "python",
"repo": "gokayozcoban/3.b.-Data-Types---Strings-Veri-tipleri---Dizinler-",
"path": "/3.b. Data Types - Strings (Veri tipleri - Dizinler).py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Track the HP of the bunker"""
if self.bunker_health == 0:
self.kill()
def blitme(self):
"""Draw the ship at its current location"""
self.screen.blit(self.image, self.rect)<|fim_prefix|># repo: john-shelton789/AlienInvasion path: /venv/bunker.py
import p... | code_fim | hard | {
"lang": "python",
"repo": "john-shelton789/AlienInvasion",
"path": "/venv/bunker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: john-shelton789/AlienInvasion path: /venv/bunker.py
import pygame
from pygame.sprite import Sprite
import spritesheet
class Bunker(Sprite):
def __init__(self, ai_settings, bunker_x, bunker_y, screen, images):
"""Initialize the ship and set its starting position"""
super(Bunk... | code_fim | hard | {
"lang": "python",
"repo": "john-shelton789/AlienInvasion",
"path": "/venv/bunker.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.load("FWCore.MessageService.MessageLogger_cfi")
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) # -1 means run on all events
#default is HcalTBSource but you can change to PoolSource if you like
#process.source = cms.Source("HcalTBSource",
process.source = cms.Source("Po... | code_fim | medium | {
"lang": "python",
"repo": "oviazlo/RawAnalyzer",
"path": "/cmsrun.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oviazlo/RawAnalyzer path: /cmsrun.py
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
options = VarParsing.VarParsing()
options.register(
'file','',VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
'File path for sto... | code_fim | medium | {
"lang": "python",
"repo": "oviazlo/RawAnalyzer",
"path": "/cmsrun.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mailmevijayakarthik/Python_Skills path: /com/filehandling/FilesandFolders.py
import os
from test.test_unicode_file_functions import filenames
def writeUniquerecords(dirpath,filenames):
<|fim_suffix|> for dirpath,dirnames,filenames in os.walk('/Users/vijayakarthikeyanarul/git/python_Skills/co... | code_fim | hard | {
"lang": "python",
"repo": "mailmevijayakarthik/Python_Skills",
"path": "/com/filehandling/FilesandFolders.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for dirpath,dirnames,filenames in os.walk('/Users/vijayakarthikeyanarul/git/python_Skills/com/filehandling/locators'):
print('Current Path',dirpath)
print('Current Folder names',dirnames)
print('Current Files names ',filenames)
for file in filenames:
writeUn... | code_fim | medium | {
"lang": "python",
"repo": "mailmevijayakarthik/Python_Skills",
"path": "/com/filehandling/FilesandFolders.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EverydayQA/prima path: /pytools/tests/test_nested_dict.py
import unittest
import json
import os
import copy
from nested.nested_dict import NestedDict
from pprint import pprint
class TestNestedDict(unittest.TestCase):
@classmethod
def setUpClass(cls):
path = os.path.dirname(__fi... | code_fim | hard | {
"lang": "python",
"repo": "EverydayQA/prima",
"path": "/pytools/tests/test_nested_dict.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_update(self):
d_original = {'hello1': 1}
dup = {'hello2': 2}
d = self.nd.update(dchg=dup, dnow=d_original)
self.assertEqual(d, {'hello1': 1, 'hello2': 2})
# d_original did not change
self.assertEqual(set(d.keys()), set(['hello1', 'hello2']))
... | code_fim | hard | {
"lang": "python",
"repo": "EverydayQA/prima",
"path": "/pytools/tests/test_nested_dict.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return dict(
map(
lambda path_links: (path_links[0], [link.decode("windows-1251") for link in path_links[1].values()] if isinstance(path_links[1], dict) else path_links[1]),
phpserialize.loads(
urllib2.urlopen(urllib2.Request(
"http:/... | code_fim | hard | {
"lang": "python",
"repo": "themylogin/thelogin.ru",
"path": "/block/sape.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return None
def load_links():
return dict(
map(
lambda path_links: (path_links[0], [link.decode("windows-1251") for link in path_links[1].values()] if isinstance(path_links[1], dict) else path_links[1]),
phpserialize.loads(
urllib2.urlopen(urllib2.R... | code_fim | hard | {
"lang": "python",
"repo": "themylogin/thelogin.ru",
"path": "/block/sape.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: themylogin/thelogin.ru path: /block/sape.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import phpserialize
import urllib2
from cache import cache
from config import config
def block(request, limit=None):
<|fim_suffix|> if slc:
return {
"class" : "sape",
... | code_fim | hard | {
"lang": "python",
"repo": "themylogin/thelogin.ru",
"path": "/block/sape.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> api.unlockAll();
def testProcess(jsonData):
utility.start()
testPageAgvControl(jsonData)
utility.finish()
def test1():
Init()
durabilityTestTask1= threading.Thread(target=func3,args=[20,"stockA_row1_col3",["stockA_row1_col2","stockA_row1_col4"]])
durabilityTestTask1.start()
durabilityTestTa... | code_fim | hard | {
"lang": "python",
"repo": "MOZIJANE/jingxin",
"path": "/hucais/trunk/driver/antAgv/agvCtrl.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MOZIJANE/jingxin path: /hucais/trunk/driver/antAgv/agvCtrl.py
#coding=utf-8
# ycat 2017-10-20 create
# AGV的控制
import sys,os
import json
import setup
if __name__ == '__main__':
setup.setCurPath(__file__)
import utility
import enhance
import threading
import time
import log
import re
import... | code_fim | hard | {
"lang": "python",
"repo": "MOZIJANE/jingxin",
"path": "/hucais/trunk/driver/antAgv/agvCtrl.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def callback2(obj):
if obj["result"] == -1:
print("error, system exit")
obj["finish"] = True
sys.exit(-1)
else:
log.warning(obj["agv"],"arrived",obj["loc2"])
obj["finish"] = True
obj = {}
obj["loc1"] = srcLoc
obj["loc2"] = destLoc
obj["cart"] = cartId
print("call ",srcLoc)
i... | code_fim | hard | {
"lang": "python",
"repo": "MOZIJANE/jingxin",
"path": "/hucais/trunk/driver/antAgv/agvCtrl.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTR... | code_fim | hard | {
"lang": "python",
"repo": "getsentry/sentry-python",
"path": "/sentry_sdk/_werkzeug.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#
# `get_host` comes from `werkzeug.wsgi.get_host`
# https://github.com/pallets/werkzeug/blob/1.0.1/src/werkzeug/wsgi.py#L145
#
def get_host(environ, use_x_forwarded_for=False):
# type: (Dict[str, str], bool) -> str
"""
Return the host for the given WSGI environment.
"""
if use_x_forwa... | code_fim | hard | {
"lang": "python",
"repo": "getsentry/sentry-python",
"path": "/sentry_sdk/_werkzeug.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: getsentry/sentry-python path: /sentry_sdk/_werkzeug.py
"""
Copyright (c) 2007 by the Pallets team.
Some rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source co... | code_fim | hard | {
"lang": "python",
"repo": "getsentry/sentry-python",
"path": "/sentry_sdk/_werkzeug.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ex
from subprocess import check_output
import pathlib<|fim_prefix|># repo: XseniaP/PepSeed path: /Cluster_extend.py
from tkinter import *
from tkinter import filedialog
from tkinter import scrolledtext
import tkinter as <|fim_middle|>tk
import os
import sys
import subprocess
import shl | code_fim | easy | {
"lang": "python",
"repo": "XseniaP/PepSeed",
"path": "/Cluster_extend.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: XseniaP/PepSeed path: /Cluster_extend.py
from tkinter import *
from tkinter import filedialog<|fim_suffix|>tk
import os
import sys
import subprocess
import shlex
from subprocess import check_output
import pathlib<|fim_middle|>
from tkinter import scrolledtext
import tkinter as | code_fim | easy | {
"lang": "python",
"repo": "XseniaP/PepSeed",
"path": "/Cluster_extend.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbjallow6/swarmlib path: /swarmlib/cuckoosearch/nest.py
# ------------------------------------------------------------------------------------------------------
# Copyright (c) Leo Hanisch. All rights reserved.
# Licensed under the BSD 3-Clause License. See LICENSE.txt in the project root for l... | code_fim | medium | {
"lang": "python",
"repo": "mbjallow6/swarmlib",
"path": "/swarmlib/cuckoosearch/nest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Nest:
def __init__(self, function, lower_boundary, upper_boundary):
self.__function = function
self.__lower_boundary = lower_boundary
self.__upper_boundary = upper_boundary
# Randomly create a new nest position
self.__position = np.random.uniform(self.__... | code_fim | medium | {
"lang": "python",
"repo": "mbjallow6/swarmlib",
"path": "/swarmlib/cuckoosearch/nest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
If the new position's value is better than the old one, update the nests position and value.
Arguments:
new_position {Tuple[float, float]} -- The new position
"""
new_value = self.__function(new_position)
if new_value < self.__value:
... | code_fim | hard | {
"lang": "python",
"repo": "mbjallow6/swarmlib",
"path": "/swarmlib/cuckoosearch/nest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _apply(name2: Lstr, score2: int, showpoints2: bool,
color2: Tuple[float, float, float, float], scale2: float,
sound2: Optional[ba.Sound]) -> None:
from bastd.actor.popuptext import PopupText
# Only award this if they're still alive... | code_fim | hard | {
"lang": "python",
"repo": "kakekakeka/ballistica",
"path": "/assets/src/ba_data/python/ba/_stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kakekakeka/ballistica path: /assets/src/ba_data/python/ba/_stats.py
ric Froemling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including witho... | code_fim | hard | {
"lang": "python",
"repo": "kakekakeka/ballistica",
"path": "/assets/src/ba_data/python/ba/_stats.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._activity = None if activity is None else weakref.ref(activity)
# Load our media into this activity's context.
if activity is not None:
if activity.expired:
print_error('unexpected finalized activity')
else:
with _ba.Con... | code_fim | hard | {
"lang": "python",
"repo": "kakekakeka/ballistica",
"path": "/assets/src/ba_data/python/ba/_stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return model
@tf.function
def train(model, images, labels):
with tf.GradientTape() as tape:
y_pred = model(images, training=True)
loss = tf.reduce_mean(cost_fn(labels, y_pred))
grads = tape.gradient(loss, model.trainable_variables)
optimizer.apply_gradients(grads_and_... | code_fim | hard | {
"lang": "python",
"repo": "pervin0527/pervinco",
"path": "/source/classification/ResNet50_augmentation.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_images, total_labels, CLASSES = get_dataset('/home/v100/tf_workspace/datasets/natural_images/natural_images')
n_classes = len(CLASSES)
train_images, valid_images, train_labels, valid_labels = train_test_split(total_images, total_labels, test_size=.3, shuffle=True, random_state=777)
... | code_fim | hard | {
"lang": "python",
"repo": "pervin0527/pervinco",
"path": "/source/classification/ResNet50_augmentation.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pervin0527/pervinco path: /source/classification/ResNet50_augmentation.py
import pathlib, random, cv2
import tensorflow as tf
import numpy as np
import tensorflow.keras.backend as K
import albumentations as A
from matplotlib import pyplot as plt
from functools import partial
from sklearn.model_se... | code_fim | hard | {
"lang": "python",
"repo": "pervin0527/pervinco",
"path": "/source/classification/ResNet50_augmentation.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@admin.register(OrderModel)
class OrderAdmin(admin.ModelAdmin):
list_display = ['first_name', 'phone']<|fim_prefix|># repo: Colibri7/felix_shop path: /orders/admin.py
from django.contrib import admin
<|fim_middle|>from orders.models import OrderModel
| code_fim | easy | {
"lang": "python",
"repo": "Colibri7/felix_shop",
"path": "/orders/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> list_display = ['first_name', 'phone']<|fim_prefix|># repo: Colibri7/felix_shop path: /orders/admin.py
from django.contrib import admin
<|fim_middle|>from orders.models import OrderModel
@admin.register(OrderModel)
class OrderAdmin(admin.ModelAdmin):
| code_fim | medium | {
"lang": "python",
"repo": "Colibri7/felix_shop",
"path": "/orders/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Colibri7/felix_shop path: /orders/admin.py
from django.contrib import admin
<|fim_suffix|> list_display = ['first_name', 'phone']<|fim_middle|>from orders.models import OrderModel
@admin.register(OrderModel)
class OrderAdmin(admin.ModelAdmin):
| code_fim | medium | {
"lang": "python",
"repo": "Colibri7/felix_shop",
"path": "/orders/admin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2692/60749/236088.py
def minvalue(weight,Day):
maximum = 0
res = 0
for x in range(0, len(weight)):
if weight[x] > maximum:
maximum = weight[x]
res += <|fim_suffix|>else:
Capitivity+=1
a=input()
a... | code_fim | hard | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2692/60749/236088.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tivity:
sum+=weight[t]
else:
sum=weight[t]
day+=1
if day<=Day:
return Capitivity
else:
Capitivity+=1
a=input()
a=a[1:len(a)-1]
store=[]
store.append(list(map(int, a.split(","))))
weight=store[0]
Day=int(inp... | code_fim | medium | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2692/60749/236088.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>else:
Capitivity+=1
a=input()
a=a[1:len(a)-1]
store=[]
store.append(list(map(int, a.split(","))))
weight=store[0]
Day=int(input())
print(minvalue(weight,Day))<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2692/60749/236088.py
def minvalue(weight,Day):
maximum = 0
... | code_fim | hard | {
"lang": "python",
"repo": "AdamZhouSE/pythonHomework",
"path": "/Code/CodeRecords/2692/60749/236088.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adityapant1286/Scheduler path: /Scheduler/auditlogging/agents/APIAuditAgent.py
import requests
from requests import Response
from auditlogging.Trail import Trail
from utils.Utils import is_empty
from auditlogging.agents.AuditAgent import AuditAgent
class APIAuditAgent(AuditAgent):
"""
C... | code_fim | hard | {
"lang": "python",
"repo": "adityapant1286/Scheduler",
"path": "/Scheduler/auditlogging/agents/APIAuditAgent.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
--------
Response
Http response
"""
return self._resp
def _set_response(self, resp: Response):
self._resp = resp
def _call_endpoint(self, trail: Trail):
_resp = requests.post(self._url, json=trail.build_trail())
... | code_fim | hard | {
"lang": "python",
"repo": "adityapant1286/Scheduler",
"path": "/Scheduler/auditlogging/agents/APIAuditAgent.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
trail : Trail
a trail object to be used for POST
"""
self._call_endpoint(trail)
def capture_custom(self, jsontrail: str):
"""
Capture custom JSON trail to endpoint
Parameters
----------
... | code_fim | hard | {
"lang": "python",
"repo": "adityapant1286/Scheduler",
"path": "/Scheduler/auditlogging/agents/APIAuditAgent.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>vf.train(x_train = train_x, y_train = train_y, x_test=test_x, y_test = test_y, epochs=100000, alpha=0.001, mini_batch_size=100)<|fim_prefix|># repo: tristandb/VectorFlux path: /main.py
"""
Implements a Neural Network
"""
from vectorflux import VectorFlux
from mnist import read, show, normalize
from vec... | code_fim | hard | {
"lang": "python",
"repo": "tristandb/VectorFlux",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>vf = VectorFlux()
vf.add(Dense(800, activation='sigmoid', input_shape=784, optimizer='Momentum'))
vf.add(Dropout(0.5, input_shape=800))
vf.add(Dense(800, activation='sigmoid', input_shape=800, optimizer='ADAM'))
vf.add(Dense(10, activation='sigmoid', input_shape=800))
vf.train(x_train = train_x, y_train ... | code_fim | hard | {
"lang": "python",
"repo": "tristandb/VectorFlux",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tristandb/VectorFlux path: /main.py
"""
Implements a Neural Network
"""
from vectorflux import VectorFlux
from mnist import read, show, normalize
from vectorflux.layers import Dense
from vectorflux.layers.Dropout import Dropout
<|fim_suffix|>vf.train(x_train = train_x, y_train = train_y, x_tes... | code_fim | hard | {
"lang": "python",
"repo": "tristandb/VectorFlux",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BrandonBlanchard/allen-styleguide-2018 path: /styleguide/migrations/0003_auto_20180627_2149.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-27 21:49
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "BrandonBlanchard/allen-styleguide-2018",
"path": "/styleguide/migrations/0003_auto_20180627_2149.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='ContentSection',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='styleguide_contentsection', se... | code_fim | medium | {
"lang": "python",
"repo": "BrandonBlanchard/allen-styleguide-2018",
"path": "/styleguide/migrations/0003_auto_20180627_2149.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('cms', '0020_old_tree_cleanup'),
('styleguide', '0002_flexcontainer'),
]
operations = [
migrations.CreateModel(
name='ContentSection',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete... | code_fim | medium | {
"lang": "python",
"repo": "BrandonBlanchard/allen-styleguide-2018",
"path": "/styleguide/migrations/0003_auto_20180627_2149.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'X' in item and found == 0:
found = 1
x_start = item.find('X')
d_start = item.find('D')
x_temp = item[x_start+1:d_start]
self.x = self.__format_number(x_temp)
if 'Y' in item and found == 0:
found = 1
... | code_fim | hard | {
"lang": "python",
"repo": "lookme2/PartsPlacement",
"path": "/src/gerber_canvas.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lookme2/PartsPlacement path: /src/gerber_canvas.py
= value
if item[0:1] == 'D': # set the current aperture
item = item[0:item.find('*')]
if DEBUG:
print('I found a ', item)
for key, value in self.AD_commands.item... | code_fim | hard | {
"lang": "python",
"repo": "lookme2/PartsPlacement",
"path": "/src/gerber_canvas.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lookme2/PartsPlacement path: /src/gerber_canvas.py
elf.file_commands)
temp_list = commands
for item in temp_list:
if DEBUG:
print(item)
if '%FSLA' in item:
self.x_format = item[6:8]
self.y_format = item[9:11]
... | code_fim | hard | {
"lang": "python",
"repo": "lookme2/PartsPlacement",
"path": "/src/gerber_canvas.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sethc23/BD_Scripts path: /test.py
import pyximport
pyximport.install(build_in_temp=False,inplace=True)
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
import numpy as np
from test1 import c_test,c_test_result_workaround
<|fim_suffix|>
y = c_test_result_workaround(a,b)
pr... | code_fim | hard | {
"lang": "python",
"repo": "sethc23/BD_Scripts",
"path": "/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
y = c_test_result_workaround(a,b)
print '\nWork-Around Result:\n',np.asarray(y)<|fim_prefix|># repo: sethc23/BD_Scripts path: /test.py
import pyximport
pyximport.install(build_in_temp=False,inplace=True)
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
import numpy as np
from tes... | code_fim | hard | {
"lang": "python",
"repo": "sethc23/BD_Scripts",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>y = c_test_result_workaround(a,b)
print '\nWork-Around Result:\n',np.asarray(y)<|fim_prefix|># repo: sethc23/BD_Scripts path: /test.py
import pyximport
pyximport.install(build_in_temp=False,inplace=True)
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
import numpy as np
from test... | code_fim | hard | {
"lang": "python",
"repo": "sethc23/BD_Scripts",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stephenYan/StrategyAI path: /Engine/regulators/velocity_regulators.py
from math import sqrt
from Engine.regulators.PID import PID
from Engine.regulators.regulator_base_class import RegulatorBaseClass
from Engine.robot import Robot, MAX_LINEAR_ACCELERATION, MAX_ANGULAR_SPEED
from Util import Pose... | code_fim | hard | {
"lang": "python",
"repo": "stephenYan/StrategyAI",
"path": "/Engine/regulators/velocity_regulators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def is_distance_for_break(robot, acc, offset=1) -> bool:
distance = 0.5 * abs(robot.current_speed ** 2 - robot.target_speed ** 2) / acc
return robot.position_error.norm > (distance * offset)
def reset(self):
self.orientation_controller.reset()
class GrS... | code_fim | hard | {
"lang": "python",
"repo": "stephenYan/StrategyAI",
"path": "/Engine/regulators/velocity_regulators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def is_time_to_break(robot, destination, cruise_speed, acceleration, target_speed):
# formule physique: v_finale ** 2 = v_init ** 2 - 2 * acceleration * distance_deplacement
offset = 1.2 # petite marge pour break avant le point vue qu'il y a du délais
dist_to_target = (destination - robot.po... | code_fim | hard | {
"lang": "python",
"repo": "stephenYan/StrategyAI",
"path": "/Engine/regulators/velocity_regulators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhuguangfei/ReadBookAi path: /translate/test.py
# -*- coding:utf-8 -*-
import os
import numpy as np
import tensorflow as tf
from translate import datautil
import seq2seq_model
_buckets = []
convo_hist_limit = 1
max_source_length = 1
max_target_length = 2
flags = tf.app.flags
FLAGS = flags.FLA... | code_fim | hard | {
"lang": "python",
"repo": "zhuguangfei/ReadBookAi",
"path": "/translate/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = seq2seq_model.Seq2SeqModel(from_vocab_size, to_vocab_size, _buckets, hidden_size, num_layers, dropout,
grad_clip, batch_size, learning_rate, lr_decay_factor, forward_only=forward_only, dtype=tf.float32)
ckpt = tf.train.latest_checkpoint(checkpoint_dir... | code_fim | hard | {
"lang": "python",
"repo": "zhuguangfei/ReadBookAi",
"path": "/translate/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emrekndl/pythonPatterns path: /FactoryExmpl.py
import json
import requests
import time
class TRY():
rates = list()
def __init__(self, r):
# if(TRY.rates[-1] != r):
TRY.rates.append(r)
def ls(self):
# print("TRY: "+TRY.rates[e] for e in range(1, len(TRY.rate... | code_fim | hard | {
"lang": "python",
"repo": "emrekndl/pythonPatterns",
"path": "/FactoryExmpl.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print("TRY: "+TRY.rates[e] for e in range(1, len(TRY.rates)))
print(f"USD: {USD.rates}")
class RUB():
rates = list()
def __init__(self, r):
# if(RUB.rates[-1] != r):
RUB.rates.append(r)
def ls(self):
# print("TRY: "+TRY.rates[e] for e in range(1, l... | code_fim | hard | {
"lang": "python",
"repo": "emrekndl/pythonPatterns",
"path": "/FactoryExmpl.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aravindsairam/Pytorch_classification-CatsvsDogs path: /cross_validation.py
import numpy as np
from sklearn import model_selection
from iterstrat.ml_stratifiers import MultilabelStratifiedKFold
"""
- binary cross-validate
- multi-class cross-validate
- multi-label cross-validate
- holdout
- regre... | code_fim | hard | {
"lang": "python",
"repo": "aravindsairam/Pytorch_classification-CatsvsDogs",
"path": "/cross_validation.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if unique_values == 1:
raise Exception("Only one unique value found! \
Must be two for Binary and Multiclass cross validation")
elif unique_values > 1:
kf = model_selection.StratifiedKFold(n_splits=self.num_folds,
... | code_fim | hard | {
"lang": "python",
"repo": "aravindsairam/Pytorch_classification-CatsvsDogs",
"path": "/cross_validation.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> aliveNeighbours = 0
neighbours = ((-1, -1), (0, -1), ( 1, -1),
(-1, 0), ( 1, 0),
(-1, 1), (0, 1), ( 1, 1))
for (ix, iy) in neighbours:
neighbour = self.cell(x + ix, y + iy)
if neighbour == Cells.ALIVE... | code_fim | hard | {
"lang": "python",
"repo": "circulene/lifegame",
"path": "/lifegame_core.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if x < 0 or x >= self.nx or y < 0 or y >= self.ny:
return Cells.DEAD
return self._cells[x][y]
# return self._cells[x % self.nx][y % self.ny]
def gen(self, x, y):
if x < 0 or x >= self.nx or y < 0 or y >= self.ny:
return 0
return self._gen... | code_fim | hard | {
"lang": "python",
"repo": "circulene/lifegame",
"path": "/lifegame_core.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: circulene/lifegame path: /lifegame_core.py
import random
import time
class Cells:
UNDEFINED = 0
DEAD = 1
ALIVE = 2
def __init__(self, nx, ny, density = 5):
self.nx = nx
self.ny = ny
self._cells = [[Cells.UNDEFINED for y in range(ny)] for x in range(nx)]
... | code_fim | hard | {
"lang": "python",
"repo": "circulene/lifegame",
"path": "/lifegame_core.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pathname in glob.glob(files):
basename= os.path.basename(pathname)
new_filename= re.sub(pattern, replacement, basename)
if new_filename != basename:
os.rename(
pathname,
os.path.join(os.path.dirname(pathname), new_filename))
rename(... | code_fim | hard | {
"lang": "python",
"repo": "novedevo/misc_python",
"path": "/zaba renamer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def renamer(files, pattern, replacement):
for pathname in glob.glob(files):
basename= os.path.basename(pathname)
new_filename= re.sub(pattern, replacement, basename)
if new_filename != basename:
os.rename(
pathname,
os.path.join(os.path.d... | code_fim | medium | {
"lang": "python",
"repo": "novedevo/misc_python",
"path": "/zaba renamer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: novedevo/misc_python path: /zaba renamer.py
import re, glob, os
lst = []
def rename(dir, pattern, titlePattern):
for pathAndFilename in glob.iglob(os.path.join(dir, pattern)):
title, ext = os.path.splitext(os.path.basename(pathAndFilename))
#title = title[22:]
#hexa = ... | code_fim | hard | {
"lang": "python",
"repo": "novedevo/misc_python",
"path": "/zaba renamer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spacetelescope/PASTIS path: /pastis/simulators/webbpsf_imaging.py
"""
This is a module containing convenience functions to create the JWST aperture and coronagraphic images with WebbPSF.
"""
import os
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
import logging
impo... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/PASTIS",
"path": "/pastis/simulators/webbpsf_imaging.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return psf_webbpsf
def nircam_nocoro(filter, Aber_WSS):
"""-- Deprecated function still used in analytical PASTIS and some notebooks. --
Parameters
----------
filter : string
Filter name
Aber_WSS : list or array
list of Zernike coefficients ordered in WSS convent... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/PASTIS",
"path": "/pastis/simulators/webbpsf_imaging.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thelegend831/ControlApp---EyeReader path: /cLineGraph.py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox
from matplotlib.path import Path
import json
def cLineGraph(j_file):
data = []
with open(j_file) as f:
for line in f:
dat... | code_fim | hard | {
"lang": "python",
"repo": "thelegend831/ControlApp---EyeReader",
"path": "/cLineGraph.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pic = []
text = []
p = 1
t0 = 0
first = 0
for i in range(0, len(data)):
if data[i].get('type') == 'Picture':
pic = data[i]
#print(pic, i)
if data[i].get('type') == 'Text':
text = data[i]
if first == 0:
... | code_fim | hard | {
"lang": "python",
"repo": "thelegend831/ControlApp---EyeReader",
"path": "/cLineGraph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(0, len(data)):
if data[i].get('type') == 'Picture':
pic = data[i]
#print(pic, i)
if data[i].get('type') == 'Text':
text = data[i]
if first == 0:
page_turns.append(0)
else:
page_tu... | code_fim | hard | {
"lang": "python",
"repo": "thelegend831/ControlApp---EyeReader",
"path": "/cLineGraph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nd_var.dtype.name
raise ValueError(('Trying to share variable %s, but specified dtype %s and found dtype %s.' % (name, dtype_str, found_type_str)))
return found_var
if (should_check and reuse):
raise ValueError(('Variable %s does not exist, or was not created with tf.get_va... | code_fim | hard | {
"lang": "python",
"repo": "wsgan001/PyFPattern",
"path": "/Data Set/bug-fixing-5/83cd3fd279037c242017cd0ab8c825f30c375564-<_get_single_variable>-fix.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wsgan001/PyFPattern path: /Data Set/bug-fixing-5/83cd3fd279037c242017cd0ab8c825f30c375564-<_get_single_variable>-fix.py
def _get_single_variable(self, name, shape=None, dtype=dtypes.float32, initializer=None, regularizer=None, partition_info=None, reuse=None, trainable=True, collections=None, cac... | code_fim | hard | {
"lang": "python",
"repo": "wsgan001/PyFPattern",
"path": "/Data Set/bug-fixing-5/83cd3fd279037c242017cd0ab8c825f30c375564-<_get_single_variable>-fix.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mokasini/cbm path: /cbm/ipycbm/ipy_get/get_settings.py
Research Centre
# License : 3-Clause BSD
from ipywidgets import (Text, VBox, HBox, Label, Password, RadioButtons,
Button, Layout, Box, Tab, Output, Dropdown,
FloatText, BoundedIntText, Comb... | code_fim | hard | {
"lang": "python",
"repo": "mokasini/cbm",
"path": "/cbm/ipycbm/ipy_get/get_settings.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @wb_save.on_click
def wb_save_on_click(b):
progress.clear_output()
dscode = ds_code.value
config.update(['ds_conf', dscode, 'years', str(ds_year.value),
'tables', 'dias_catalog'], str(tb_dc.value))
config.update(['d... | code_fim | hard | {
"lang": "python",
"repo": "mokasini/cbm",
"path": "/cbm/ipycbm/ipy_get/get_settings.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mokasini/cbm path: /cbm/ipycbm/ipy_get/get_settings.py
art of CbM (https://github.com/ec-jrc/cbm).
# Author : Konstantinos Anastasakis
# Credits : GTCAP Team
# Copyright : 2021 European Commission, Joint Research Centre
# License : 3-Clause BSD
from ipywidgets import (Text, VBox, HBox, L... | code_fim | hard | {
"lang": "python",
"repo": "mokasini/cbm",
"path": "/cbm/ipycbm/ipy_get/get_settings.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: valer-whylabs/whylogs path: /tests/unit/core/test_rect.py
from whylogs.core.annotation_profiling import Rectangle
def test_rect():
<|fim_suffix|> rect = Rectangle([[0, 0], [0, 0]])
test = Rectangle([[0, 0], [5, 5]])
assert rect.area == 0
assert rect.intersection(test) == 0
as... | code_fim | hard | {
"lang": "python",
"repo": "valer-whylabs/whylogs",
"path": "/tests/unit/core/test_rect.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
rect = Rectangle([[0, 0], [0, 0]])
test = Rectangle([[0, 0], [5, 5]])
assert rect.area == 0
assert rect.intersection(test) == 0
assert rect.iou(test) == 0<|fim_prefix|># repo: valer-whylabs/whylogs path: /tests/unit/core/test_rect.py
from whylogs.core.annotation_profiling import Rect... | code_fim | hard | {
"lang": "python",
"repo": "valer-whylabs/whylogs",
"path": "/tests/unit/core/test_rect.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: steven112163/DLP-project path: /argument_parser.py
from argparse import ArgumentParser, Namespace
def parse_arguments() -> Namespace:
"""
Parse arguments
:return: Arguments
"""
parser = ArgumentParser(description='DLP project: Stock Prediction using Transformer')
parser... | code_fim | hard | {
"lang": "python",
"repo": "steven112163/DLP-project",
"path": "/argument_parser.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tion', default='l2', type=str, choices=['l1', 'l2'], help='Loss function')
parser.add_argument('-i', '--inference_only', action='store_true', help='Inference only or not')
parser.add_argument('-r', '--root_dir', default='archive', type=str,
help='Directory containing the do... | code_fim | hard | {
"lang": "python",
"repo": "steven112163/DLP-project",
"path": "/argument_parser.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: supmagc/script.artwork.beef path: /lib/libs/webhelper.py
import requests
from requests.adapters import HTTPAdapter
from requests.exceptions import ConnectionError, Timeout, RequestException
# import from `requests` because Jarvis / some platforms still have old urllib3
from requests.packages.urll... | code_fim | hard | {
"lang": "python",
"repo": "supmagc/script.artwork.beef",
"path": "/lib/libs/webhelper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.session = session or retryable_session()
self.login = login
if contenttype:
self.session.headers['Accept'] = contenttype
def __call__(self, url, **kwargs):
try:
return self._inner_call(url, **kwargs)
except (Timeout, ConnectionError... | code_fim | hard | {
"lang": "python",
"repo": "supmagc/script.artwork.beef",
"path": "/lib/libs/webhelper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Convenience Functions:
connect:
Create a database connection, returning a PgNumpy object. If conninfo
is None or "" then the "default" connection based on the PGUSER and
PGDATABASE environment variables is used.
array2table:
Write array with fields (a structure) t... | code_fim | hard | {
"lang": "python",
"repo": "esheldon/espy",
"path": "/old/pgnumpy/pgnumpy/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: esheldon/espy path: /old/pgnumpy/pgnumpy/__init__.py
"""
Package:
pgnumpy
Description
A class and a set of functions for interacting with a PostgreSql database.
A C++ extension module allows returning results as a NumPy array. Numpy
arrays can also be written to tables.
... | code_fim | hard | {
"lang": "python",
"repo": "esheldon/espy",
"path": "/old/pgnumpy/pgnumpy/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#from pgnumpy import tables
#from pgnumpy import table_exists
#from pgnumpy import describe
from pgnumpy import test
from pgnumpy import test_simple
#from pgnumpy import obliterate
#from pgnumpy import compare_arrays
# attempt to import the connect method from psycopg2
try:
from psycopg2 import conne... | code_fim | hard | {
"lang": "python",
"repo": "esheldon/espy",
"path": "/old/pgnumpy/pgnumpy/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 相关的weights,json的文件
weights_file = os.path.join(WEIGHTS_DIR, 'prednet_facebook_segmpred_weights.hdf5')
json_file = os.path.join(WEIGHTS_DIR, 'prednet_facebook_segmpred_model.json')
# weights_file = os.path.join(WEIGHTS_DIR, 'prednet_kitti_weights.hdf5')
# json_file = os.path.join(WEIGHTS_DIR, 'prednet_ki... | code_fim | hard | {
"lang": "python",
"repo": "bopjesvla/videopred",
"path": "/ext/prednet/facebook_cityscapes_evaluate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Reda-BELHAJ/SnakeImproved path: /Classes/GAME.py
import pygame
from .Coin import Coin
from .Snake import Snake, Block
from .Bomb import Bomb
from .Rocket import Rocket
from pygame.math import Vector2
cell_size = 16
cell_number = 30
sprite_cell = pygame.image.load("Assets/Cell.png")
bg = pygame.... | code_fim | hard | {
"lang": "python",
"repo": "Reda-BELHAJ/SnakeImproved",
"path": "/Classes/GAME.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.snake.move_snake()
self.check_collision()
self.check_fail()
self.rem_rockets()
def rem_rockets(self):
for rocket in self.rockets:
if not rocket.out_of_frame():
self.rockets.remove(rocket)
def check_timer(self):
... | code_fim | hard | {
"lang": "python",
"repo": "Reda-BELHAJ/SnakeImproved",
"path": "/Classes/GAME.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for block in self.snake.body[1:] :
if block == self.snake.body[0]:
self.game_over = 1
for rocket in self.rockets:
if rocket.rocket_rect.colliderect(Block(self.snake.body[0].x, self.snake.body[0].y).rect):
self.game_over = 1
... | code_fim | hard | {
"lang": "python",
"repo": "Reda-BELHAJ/SnakeImproved",
"path": "/Classes/GAME.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afwanwh/x0x path: /hi.py
#this apps is open
#Let's start with introduction
print "Hi, I am x0x. Could we introduce ourselves? (yes/no)"
answer = raw_input()
if answer.lower() == 'yes':
print "Okay, what is you<|fim_suffix|>er = raw_input()
if answer == '1':
print 'Well, good bye... | code_fim | medium | {
"lang": "python",
"repo": "afwanwh/x0x",
"path": "/hi.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>terminated.'
print 'bye'
elif answer.lower() == 'no':
print "thank you"
else:
print "your answer is wrong"
print "Please come back later. Thank you!"
print "yoyoi oke"<|fim_prefix|># repo: afwanwh/x0x path: /hi.py
#this apps is open
#Let's start with introduction
print "Hi, I am... | code_fim | medium | {
"lang": "python",
"repo": "afwanwh/x0x",
"path": "/hi.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
logging.log(INFO, "============== NOUN ROOT - No Direct SUBJ and OBJ ================")
if subj is not None: # Mostly likely noun with possessive or nested
if (subj["link"] == Relations.PASSIVE_NOM_SUBJECT): # Necessarily assume this since noun subj is possessive, el... | code_fim | hard | {
"lang": "python",
"repo": "shitian-taiger/relational-extraction",
"path": "/generation/dependency_parse/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shitian-taiger/relational-extraction path: /generation/dependency_parse/main.py
import logging
from logging import INFO
from typing import Dict, List
from .constants import Relations, POS
from .evaluator import *
from .general import DPHelper
from .general import *
from .utils import *
# =======... | code_fim | hard | {
"lang": "python",
"repo": "shitian-taiger/relational-extraction",
"path": "/generation/dependency_parse/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yasin624/torch-ile-kendi-kendine-giden-arac path: /ALEX_NET.py
import torch,cv2,os,time
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
<|fim_suffix|> self.boyut=None
... | code_fim | hard | {
"lang": "python",
"repo": "yasin624/torch-ile-kendi-kendine-giden-arac",
"path": "/ALEX_NET.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class NET(nn.Module):
def __init__(self):
super(). __init__()
self.conv1=nn.Conv2d(1,64,5)
self.conv2=nn.Conv2d(64,128,5)
self.conv3=nn.Conv2d(128,64,5)
x=torch.randn(86,86).view(-1,1,86,86)
self.boyut=None
self.uzun... | code_fim | medium | {
"lang": "python",
"repo": "yasin624/torch-ile-kendi-kendine-giden-arac",
"path": "/ALEX_NET.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
x=F.max_pool2d(F.relu(self.conv1(x)),(2,2))
x=F.max_pool2d(F.relu(self.conv2(x)),(2,2))
x=F.max_pool2d(F.relu(self.conv3(x)),(2,2))
if self.boyut is None:
self.boyut=x[0].shape[0]*x[0].shape[1]*x[0].shape[2]
return x
def for... | code_fim | hard | {
"lang": "python",
"repo": "yasin624/torch-ile-kendi-kendine-giden-arac",
"path": "/ALEX_NET.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> def do_minimisation(self, x, data, weights = 1, **kwargs):
self.fit_result = minimize(self.residuals_wrapper, self.parameters, args = (x, data, weights), kws = kwargs)
logging.info('Fit Result')
logging.info('==========')
return self.fit_result
def get_opt_paramete... | code_fim | hard | {
"lang": "python",
"repo": "jamesbate/phd_code",
"path": "/code/lib/FitTemplate.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jamesbate/phd_code path: /code/lib/FitTemplate.py
"""After seeing how great the lmfit package, I was inspired to create my own
object using it. This acts as a fitting template.
"""
##-------------------------------PREAMBLE-----------------------------------##
import numpy as np
import matplotli... | code_fim | hard | {
"lang": "python",
"repo": "jamesbate/phd_code",
"path": "/code/lib/FitTemplate.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.