index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
996,900 | 075a8d5236489c858d67fc84e47bc823ff1df48f | from graphics import *
win = GraphWin('Smiley Faces', 400, 400) # give title and dimensions
win.setBackground('cyan')
win.setCoords(0, 0, 400, 400)
def drawFace(center, size, window):
head = Circle(center, size * 20)
head.setFill("green")
head.draw(win)
mouth = Circle(center, size * 13)
mouth.s... |
996,901 | 5f7347580b2a9ac61897efb1bb5d74dc45e111fb | # TODO: Change working directory
import os
WORKING_DIRECTORY = os.getcwd()
DEBUG_MODE = True
DEVELOP_MODE = True
|
996,902 | 1ce6f0197930932b23ab91feca26214d52deb074 | # coding=utf-8
import bootstrap # noqa
import inspect
import six
from markii import markii
from markii.markii import (
deindent,
getframes,
getprocinfo,
getrusage,
getsource,
resource
)
def test_getrusage():
try:
import resource # noqa
assert getrusage()
except Impor... |
996,903 | 8cbbcabe3d3185e8814f4612aafebf28d6f0c0aa | import csv, json, requests
# set the index and mapping to use
index = 'http://localhost:9200/phd/wellcome'
mapping = {
"wellcome" : {
"dynamic_templates" : [
{
"default" : {
"match" : "*",
"match_mapping_type": "string",
... |
996,904 | 1097b01bfde041e2f861682bf8dd77687db4e414 | # CREATE TIC TAC TOE FOR 2 PLAYERS
def display_board(board):
clear_output()
print(board[1] + '|' +board[2] + '|' +board[3])
print(board[4] + '|' +board[5] + '|' +board[6])
print(board[7] + '|' +board[8] + '|' +board[9])
test_board = ['#', 'X','O','X','O','X','O','X','O','X']
display_board(test_board)
def player... |
996,905 | 69bbe689fe9051aa87216c11fbf3979d1baf6a87 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# bots/followfollowers.py
from GoogleNews import GoogleNews
googlenews = GoogleNews()
googlenews.search('Bolsonaro')
result = googlenews.result()
print(len(result))
for n in range(len(result)):
print(n)
for index in result[n]:
print(index, '\n', result[n... |
996,906 | 6898257db5185206826b2fa2abd8cc4526660183 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 3 15:54:34 2016
@author: nathanvc
Functions to reorganize DSR data for analysis and plotting
"""
import DSR_basicfn as bf
import numpy as np
import itertools as it
from nltk.stem.porter import PorterStemmer
from nltk.corpus import stopwords
import scipy
# -----------
... |
996,907 | 4c19960bdf9437c6745358b6058793a0d61c1660 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 13 18:56:32 2018
@author: nnir
"""
import numpy as np
import os
#import six.moves.urllib as urllib
import sys
#import tarfile
import tensorflow as tf
#import zipfile
#from collections import defaultdict
#from io import StringIO
from matplotlib import pyplot as plt
fr... |
996,908 | 430257b0b41e9f8bcbcb34199ab78ffb2e8eb3ed | #! /usr/bin/env python3
import sys
input_file = "Baby_Shark.txt"
print("Output: Baby_Shark.txt")
with open(input_file, 'r', newline='') as filereader:
for row in filereader:
print("{}".format(row.strip()))
|
996,909 | c854d1a8b23e9c1d5ca26c3222ef60f02076cc3d | """Locally Selective Combination of Parallel Outlier Ensembles (LSCP).
Adapted from the original implementation.
"""
# Author: Zain Nasrullah <zain.nasrullah.zn@gmail.com>
# License: BSD 2 clause
# system imports
import collections
import warnings
# numpy
import numpy as np
# sklearn imports
from sklearn.neighbors i... |
996,910 | 983096de8c3532c77e36392f27fff8f1c6fb1d3c | class Solution(object):
def maxProduct(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
from functools import reduce
from operator import mul
dic = {}
s = 1
# ans = []
if 0 in nums:
# ans.append(0)
ans = 0
... |
996,911 | 114f3282b9f14931eca27afb03101192269e423b | import random
class Card(object):
RANKS = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"]
SUITS = ["C","S","H","D"]
def __init__(self, rank, suit, isFaceUp = True):
self.rank = rank
self.suit = suit
self.isFaceUp = isFaceUp
def __str__(self):
if self.i... |
996,912 | b0b065d767b7c4c4022d54fad49336fa4382429e | class Solution:
def rob(self, nums: List[int]) -> int:
"""
首先,首尾房间不能同时被抢,那么只可能有三种不同情况:
要么都不被抢;要么第一间房子被抢最后一间不抢;要么最后一间房子被抢第一间不抢。
"""
n = len(nums)
if n == 1: return nums[0]
return max(self.rob_range(nums, 0, n - 2), self.rob_range(nums, 1, n - 1))
def rob_r... |
996,913 | efd2a8d8299907d5dfebd31e7697e5e203aa0941 | class Solution(object):
def maximumUniqueSubarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
ans = 0
l = s = 0
mem = {}
n = len(nums)
for r in range(n):
s += nums[r]
while l < r and nums[r] in me... |
996,914 | 27ff80c4c6f90ba3bf36ad514095afae3956875a | """Creates a dictionary given fastalign's outputs
Author: Antonios Anastasopoulos <aanastas@andrew.cmu.edu>
"""
import argparse
from collections import Counter
import string
def align(textfile, alignmentfile, l1, l2, N):
outputfile=f"dict.{l1}-{l2}"
# Read the text and the alignment files
with open(textfile, mode... |
996,915 | 4e2f9a63a9bfa9f61fa28a5bf0952acb76dd32a3 | from .base import *
ALLOWED_HOSTS = ['101.101.219.148'] |
996,916 | 8cbb595886461c6bb2b47f4330eeacc426a014d6 | from typing import List
class Solution:
def findShortestSubArray(self, nums: List[int]) -> int:
hashmap = {}
for n in nums:
if n in hashmap:
hashmap[n] += 1
else:
hashmap[n] = 1
maximum = max(hashmap.values())
max_nums = []
... |
996,917 | 4b34b685512657cf9be2b555d82eca60c6ba0d2a | #!/usr/bin/env python
# table auto-generator for zling.
# author: Zhang Li <zhangli10@baidu.com>
kBucketItemSize = 4096
matchidx_blen = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7] + [8] * 1024
matchidx_code = []
matchidx_bits = []
matchidx_base = []
while len(matchidx_code) < kBucketItemSize:
for bit... |
996,918 | cee551fc70f7c5e1388692cf9227f4bd17640f05 | from collections import deque
import sys
def bfs(s, trail):
q = deque()
q.append((s, 0))
trail[s] = 0
while q:
p, step = q.popleft()
for np in edge[p]:
nstep = step + 1
if trail[np] > nstep:
q.append((np, nstep))
trail[np] = nstep... |
996,919 | bc30dc5c2b523bbb7a02e58ad5850e6a987a6a7a | from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
import uuid
import os
# Create your models here.
class Course(models.Model):
coursename= models.CharField(max_length=100, blank=True, null=True)
description=models.CharField(max_length=500, blank=True, null=Tru... |
996,920 | c3a3391a849fb40a225415a1778a96af61c45f50 | # coding: utf-8
from boost_collections.zskiplist.zskiplist_level import ZskiplistLevel
class ZskiplistNode(object):
def __init__(self, level, score, ele=None):
super(ZskiplistNode, self).__init__()
self.ele = ele
self.score = score
self.backward = None
self.level = [Zskip... |
996,921 | fd2701ae304e6c2b046ef3ae3c00c9807d816882 | from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse, JsonResponse
from django.template import loader
from django.views import View
from .models import *
from django.core.exceptions import ValidationError
from django.contrib import messages
from django.views.decorators.c... |
996,922 | c5505e4a67d3dbf6ea2b6524ffbfd7fba179ca8a |
import SimpleITK as sitk
def create_composite(dim, transformations):
"""
Creates a composite sitk transform based on a list of sitk transforms.
:param dim: The dimension of the transformation.
:param transformations: A list of sitk transforms.
:return: The composite sitk transform.
"""
co... |
996,923 | 8c6309f7e150d0ded0d1c06031b0c65158e87df6 | #!/usr/bin/env python3
#coding:utf-8
class LNode(object):
def __init__(self, x=None):
self.val = x
self.next = None
def isLoop(head):
"""
方法功能:判断单链表是否有环
输入参数:head: 链表头结点
返回值:若无环,返回 None;若有环,返回入环结点
"""
if head is None or head.next is None:
return None
hash_set = ... |
996,924 | 1f632bfa31612f6d0512f2159e23350d4b7a728a | from django.shortcuts import render
# Create your views here.
import django_filters
from rest_framework import viewsets, filters
from rest_framework import status
from rest_framework.response import Response
from .models import Condition, Entry
from .serializer import ConditionSerializer, EntrySerializer
class Condi... |
996,925 | 360866ae533bc88c058dbf80e6e59605e5d6d7b5 | import datetime
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
class AddForm(forms.Form):
search = forms.CharField(max_length = 50, widget=forms.TextInput(attrs={'class': 'form-control'}))
def clean_search(self):
cle... |
996,926 | 26dd4af69534d57c9f1138e8c9c1fe19ad46974b | # -*- coding: utf-8 -*-
from __future__ import division
import math
#COMECE SEU CODIGO AQUI
a=int(input('digite um numero: '))
b=20
c=10
d=5
e=2
f=1
g=(a%b)
if g==0
print a/b
else (g%c)/10
if (g%c)/10 == 0
print g/b
else (g
|
996,927 | f85aee2b1ea851122ddf645ff8ca8c0f38c1f3fe | #!/usr/bin/python
# Example use:
# ~ $ percent 26,943,452,560 27,089,972,296
# +146519736
# +0.543804605864%
import sys
def remove_commas(str):
return str.replace(",", "")
before = float(remove_commas(sys.argv[1]))
after = float(remove_commas(sys.argv[2]))
diff = after - before
if diff > 0:
sign = "+"
else... |
996,928 | f2e0d70e41381839039f9280b3a09905cb85f7c1 | import datetime
from project.server import db
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Answer(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
comments = db.Column(db.String(255))
question_id = db.Column(db.Integer)
section_i... |
996,929 | 609f6ecb4194c6118f4eb1bfc30812a1fc2987bd | import mysql.connector
import csv
import time
#---------------------------
# COUNTRY
#---------------------------
def uploadCountryData(fileName, db):
try:
with open(fileName, 'r') as dataFile:
print '[+] Importing \'%s\''%fileName
dataReader = csv.DictReader(dataFile, delimiter=',... |
996,930 | 52bab96e3ed0e7a980c640973726d8aed7301dc2 | LINKS_REPR = [
(
"Link(link_id='d7dd01d6-9577-4076-b7f2-911b231044f8', link_type='ethernet',"
" project_id='4b21dfb3-675a-4efa-8613-2f7fb32e76fe', suspend=False, nodes=["
"{'adapter_number': 0, 'label': {'rotation': 0, 'style': 'font-family:"
" TypeWriter;font-size: 10.0;font-weight:... |
996,931 | 14113bd0021b849cc3d59818b8c7ad6af7447013 | # Creates html files with a page source string.
def createHtmlFile(fileName, html):
with open(f"{fileName}.html", "w") as file:
file.write(html)
file.close() |
996,932 | e42bfe25d52e045b0d058561eb1f23d79c92ab5f | from django.db import models
from django.urls import reverse
# import datetime
import django
class Saloon(models.Model):
name=models.CharField(max_length=250)
ad_first=models.CharField(max_length=250)
ad_second=models.CharField(max_length=250)
city=models.CharField(max_length=250)
country=models.C... |
996,933 | 57ae0e8367bb6ec4116785ce6803810bbc7a2673 | """
=============
Multipage PDF
=============
This is a demo of creating a pdf file with several pages,
as well as adding metadata and annotations to pdf files.
If you want to use a multipage pdf file using LaTeX, you need
to use `from matplotlib.backends.backend_pgf import PdfPages`.
This version however does not su... |
996,934 | 77e5162b142059fa64f6d4f68eca73769bf313f1 | # -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html
import scrapy
class ArticleItem(scrapy.Item):
description = scrapy.Field()
description2 = scrapy.Field()
titre = scrapy.Field()
soustitre = scrapy.F... |
996,935 | 8cb460003da2132b7d8f360d5de030ec3d7b9204 | import sublime
import sublime_plugin
import os
class ProjectFolderListener(sublime_plugin.EventListener):
def on_activated_async(self, view):
dir_name = self.get_dir_name(view)
if dir_name == None:
return
self.add_folder_to_project(dir_name)
def on_close(self, view):
return
project_data = sublime.ac... |
996,936 | dbfcfc7755e3833e1c85e8021efc09cdb0391f63 | import json
from copy import copy
from functools import reduce
class ComputeGraph(object):
"""Class for calculations with tables.
Table is a list of dict-like objects without omissions.
Operations are specified in format of Computing Graph.
Computing(including reading) occurs separately from spec... |
996,937 | 7314719bfbdc85b0d6041ce5a518231bc76816e1 | from django.contrib import admin
from .models import Movie, Director
admin.site.register(Movie)
admin.site.register(Director) |
996,938 | 71465e59a3182ccfeb7bf5b7ebb479985e88196c | from products import product, Product
from summations import summation, Sum
|
996,939 | 01f5d95db09511851a07425ae694f76f180d1c43 | class Solution:
def numTrees(self, n: int) -> int:
if n==0 or n==1:
return 1
count =0
for i in range(1, n+1):
#LEFT SUBTREE i-1
#RIGHT SUBTREE n-i
count += self.numTrees(i-1)* self.numTrees(n-i)
return count |
996,940 | ab443d5e0fbad5bef22a701ebc3cd029c9a2f50a | import random
import numpy as np
from Player import Player
import matplotlib.pyplot as plt
NB_GAME = 10 # number of games each player will be playing
class PublicGoodsGame:
def __init__(self, n, m, p, runs, generations, r, c, mu, s):
self.n = n
self.m = m
self.p = p
self.runs = runs
self.generations = g... |
996,941 | a1098c6f2ca46a1d8d269be49876caab295dce20 | import scrapy.cmdline as cmdline
cmdline.execute(['scrapy','crawl','job51']) |
996,942 | e539783358f49461d765f378bb0474b4da7ea9fd | import numpy as np
import numpy.linalg as npla
import matplotlib.pyplot as plt
from problem_2a import QR_fact_iter
from problem_6b import lancoiz
def main():
B = np.random.random((100, 100))
Q, R = QR_fact_iter(B)
D = np.diag(np.arange(1, Q.shape[1] + 1))
A = np.dot(np.dot(Q, D), Q.T)
Q, H, rvals = lancoiz(A)
... |
996,943 | d3af1c9da6ac0e4a3a9f512a4179b23bc2676b73 | from django.conf.urls import patterns, url
from Conferencia import views
urlpatterns = patterns('',
url(r'^$', views.indice, name='indice'),
url(r'^mostrarFormConferencia/$',views.mostrarFormConferencia, name='mostrarFormConferencia'),
url(r'^editarDatosConferencia/$', views.editarDatosConferencia, ... |
996,944 | 074859e90d8560d64674a6f2169ebe697dd47b9e | # -*- coding: utf-8 -*-
__virtualname__ = 'priv'
def call(hub, ctx):
return ctx.func(*ctx.args, **ctx.kwargs)
|
996,945 | 24a7c23b807372ba418850c3e8df23774f4c532b | import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
import time
from PIL import Image
import mss
import cv2
import pyautogui as gui
# This is the path to the Tensorflow object detect... |
996,946 | f6df1b9dcb9e672406df3885cebf22de3a26aeaa | import random
from random import shuffle
from django.db import models
from django.db.models import Model, TextField, JSONField, IntegerField, CharField
from django.db.models.signals import post_init
from django.dispatch import receiver
from cities.card import Card
class Game(Model):
name = CharField(max_length=... |
996,947 | 91b6035c63f293adaddaf62d3ce4578411cbe3b9 | import time
import json
import requests
from pyquery import PyQuery as pq
from urllib import parse
def get_wymx(page):
# area = 1内地 2港台 3欧美 4日韩 999其他
url = 'http://ent.sina.com.cn/ku/star_search_index.d.html?area=999&page='+str(page)
hd = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) Appl... |
996,948 | beb16ca46aa13561876e0cf0a986511359700788 | import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style('whitegrid')
titanic = sns.load_dataset('titanic')
titanic.head()
# Exercises
#
# ** Recreate the plots below using the titanic dataframe. There are very few hints since most of the plots can be done
# with just one or two lines of code and a hint wo... |
996,949 | 1d4dc3b4ec8e5c4afa2cd08e9db1f5db6169165b | import re
from collections import defaultdict
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, cast
import fastjsonschema
from openslides_backend.models.base import model_registry
from openslides_backend.models.fields import (
BaseRelationField,
BaseTemplateField,
Boolea... |
996,950 | c204ea4360025bdcb57aab4dcd2e14e8a9d54244 | from __future__ import print_function
import piplates.RELAYplate as RELAY
import piplates.DAQCplate as DAQC
import time
ppADDR=1
ADCchan=0
print('reading adc channel', ADCchan)
while True:
adcread = DAQC.getADC(ppADDR, ADCchan)
print("ADC reading #, val: ", ADCchan, adcread)
time.sleep(1.0)
ADCchan... |
996,951 | dd27eaf628372321fc50146b7596ca90554bee81 | import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
from math import floor
from skimage import transform as tf
from numpy.linalg import norm
from numpy.linalg import inv
from util import *
#The local affine Algorithm
def local_affine(ori_img,proto_img,e,regions,is_in_regions,distance_funs,affine_fu... |
996,952 | d9057b3347ad8f84cb7e59a37c3f633e709cfe17 | from PIL import Image, ImageDraw, ImageFont
class ImageText:
"""
ImageText
:param kwargs: strings, font, color, image_width, image_height, image_padding
strings: list of strings
font: string path to font
color: RGB tuple
image_width: integer
image_height: integer
image_padding: i... |
996,953 | d2f5ccd8f2a28a2a060e4e85035cc432ba0e27b0 | """
Copyright 2013 LogicBlox, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following di... |
996,954 | fe1279a76a73730a15b60638e40e182b25ba470a | from math import sqrt
def suite(n):
#Initialisation
#i = 0
u = 1
for i in range(n):
u = sqrt(1+u)
return u
|
996,955 | 42e7b6ea5d66afec87d04482f7f54589421571f1 | #!/usr/bin/env python3
import sys
def input():
return sys.stdin.readline()[:-1]
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append(... |
996,956 | 001a6effcb0534f2f3cf51555a54acbf44c9d3c0 | """Solution to task 4 from lesson 10."""
def dict_with_attrs(*args):
"""Return class extended from dict with predefined attributes."""
class CustomDict(dict):
__slots__ = args
def __init__(self, *args, **kwargs):
super(CustomDict, self).__init__(*args)
for k, v in kwa... |
996,957 | 2108929ea10a2413c6dfaf6e803a2a281022ac70 | def cantidad_jugadas(matriz):
total = 0
for i in matriz:
fila = i
for j in fila:
if(j!=""):
total = total + 1
return total
def imprimir_matriz(matriz):
for i in matriz:
fila = i
print("|",end="")
for j in fila:
if j !=... |
996,958 | 59143c3ed347577d3484a411fe2493e1742f71fe | from ControlActions import *
from Gestures import *
class ConfigReader:
def __init__(self):
pass
@classmethod
def fromPath(cls, path):
return {}
@classmethod
def default(cls):
return {
PALM: MOVE,
FIST: LEFT_CLICK,
KNIFE: ESCAPE,
... |
996,959 | 8a807addb0ee5426979468bebeeaa57a4be58457 | from plenum.test.helper import sdk_send_random_request, \
sdk_send_random_requests, sdk_get_and_check_replies, sdk_send_random_and_check
from plenum.test.pool_transactions.helper import sdk_pool_refresh
def test_sdk_pool_handle(sdk_pool_handle):
ph = sdk_pool_handle
assert ph > 0
def test_sdk_wallet_han... |
996,960 | 0ed6d37d6ba086e300438db56a6c13f65e368da3 | def symbolToNumber(symbol):
if symbol=="A":
return 0
elif symbol=="C":
return 1
elif symbol =="G":
return 2
elif symbol=="T":
return 3
def patternToNumber(pattern):
if pattern =="":
return 0
count = 0
symbol = pattern[len(pattern)-1]
prefix = pat... |
996,961 | e200cd7f9f1f5beb015ccf700e35909166053b82 | from skimage.feature import hog
from HSV import *
from scipy.ndimage import filters
def grayScale_feature(img_name, image_size):
return(array(Image.open(img_name).convert('L').resize(image_size)).flatten())
def HOG_feature(img_name, image_size):
img_PIL = Image.open(img_name).resize(image_size)
imgBW = array(im... |
996,962 | d937005dcb00b5cb103fd2190c279eec0fbd1bf0 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Jonny"
# Email: jonnysps@yeah.net
# Date: 2017/10/13
import requests
def func_t():
headers = {'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/5... |
996,963 | d5c42faf674e0f049c3fed61c4acc7399cfba893 | from bs4 import BeautifulSoup
import requests
import re
import os
class GetPics:
def __init__(self, url, post_number):
self.url = url
self.post_number = post_number
self.img_number = 1
def getpic(self):
raw_page = requests.get(self.url)
raw_page.encoding = 'utf-8'
... |
996,964 | fb8b383b59d1a2f457ebb9aef283d36f76fb0de3 | import os
folder = os.path.realpath('.')
import numpy
import math
import pylab
import scipy
import scipy.special
datafile = 'Campo_magnetico.txt'
rawdata = numpy.loadtxt(os.path.join(folder, datafile)).T
V = rawdata[0]
dV = rawdata[1]
t = 4
dt = 1
r = rawdata[2]
dr = rawdata[3]
I = rawdata[4]
dI = rawdata[5]
e = 1.6... |
996,965 | f7c98ebd702d8960e9fe81650ed7a5323f9b9b06 | import random
import pygame
from data.Resources_Loading_File import SONG_ONE
# from data.Resources_Loading_File import SONG_TWO
# Random background music
# Music lives forever
next_song = None
stop_music = False
# TODO: Maybe add some new songs
# All the songs that can be played
background_songs = [
SONG_ONE,
... |
996,966 | 5f1ff4800b944dff50f53852e2f0c527294d4737 | from keras.layers import Input, Dense
from keras.models import Model
from rl.core.value_function import NeuralNetStateMachineActionValueFunction
class AntActionValueFunction(NeuralNetStateMachineActionValueFunction):
def __init__(self):
super(AntActionValueFunction, self).__init__()
input_size ... |
996,967 | acbe28bb64d2211cb902cb1c9f9c996cd0935287 | def checkIndex(key):
"""The key should be non-negative integer.
if it is not an interger a TypeError is raised.
if it is negative a IndexError is raised.
"""
if not isinstance(key, (int, float)): raise TypeError
if key<0: raise IndexError
class CounterList(list):
def __init__(self,*... |
996,968 | 425508092169f7d1e3b65697b9a9eb65258d1332 | #!/usr/bin/python
import subprocess
def _run_cmd(cmd, module):
try:
return subprocess.check_output(cmd, shell = True).strip()
except subprocess.CalledProcessError as e:
module.fail_json(msg = "Command '"+e.cmd+"' failed: "+e.output)
def main():
module = AnsibleModule(
argument_spe... |
996,969 | f8f143cf22eeb12fb56ecc987a82608e944b1f30 | # Data Culling class, Python 3
# Henryk T. Haniewicz, 2018
# Local imports
import utils.pulsarUtilities as pu
import utils.plotUtils as pltu
import utils.otherUtilities as u
import utils.mathUtils as mathu
# PyPulse imports
from pypulse.archive import Archive
from pypulse.singlepulse import SinglePulse
from pypulse.u... |
996,970 | 014598398418413f17643823b47336d3a5df3df7 | # -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-03 11:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='UnsafeUse... |
996,971 | bed9ae662bc2263d2f22aedf23561d68f31fd437 | T = int( input().strip() )
O = list()
for t in range(T) :
I = int( input().strip() )
x = [0 for x in range(10)]
if I == 0 :
O.append('INSOMNIA')
else :
to = 0
while sum(x) != 10 :
to = to + I
i = to
while i > 0 :
x[ int(i % 10) ] = 1
i //= 10
O.append(to)
for i,o in enumerate(O):
print('C... |
996,972 | 57c0d0dba3c83ce02856b2cf01b451e4329d9123 | # encoding=utf-8
"""
景江苑账单隐藏
"""
__AUTHOR = 'thor'
class BillNoConfirm(object):
__BASE_PATH = 'file/'
def __init__(self):
self.field_index_dict = {
'house_code': 0,
'september_num': 1,
'october_num': 2,
}
def handle(self):
per_sql = 'update bil... |
996,973 | acbdca902ecf95496ea88e371bd9c60f6edd00b8 | import os
import re
from vee import log
from vee.cli import style, style_note
from vee.pipeline.base import PipelineStep
from vee.subproc import call
from vee.utils import cached_property
from vee.exceptions import AlreadyInstalled, PipelineError
_installed_packages = set()
class RPMChecker(PipelineStep):
fact... |
996,974 | df243af66be7b28b0c48e42e84e7580c1e3756c4 | from pytorch3d.renderer import (
FoVPerspectiveCameras,
PointLights,
RasterizationSettings,
TexturesVertex,
look_at_view_transform,
)
from pytorch3d.renderer import (
FoVPerspectiveCameras, look_at_view_transform,
RasterizationSettings, BlendParams,
MeshRenderer, MeshRasterizer, HardPhon... |
996,975 | 0475b7b57cde36f5204f10d45468856c5c5fc85c | # pylint: disable=missing-module-docstring, missing-function-docstring
import pytest
from aqua.interface.parser_plaintext import PlainTextParser
def test_parse_normal_msg():
inp = PlainTextParser.parse_input("0 request foo")
assert inp.request == "request"
assert inp.return_id == 0
assert inp.params ... |
996,976 | 989cffd656222ca8898339720c11c46265d1b8ac | """
Tests for Packet20.
"""
from irobot.packet import Packet20
def test_id():
"""Tests the packet `id`."""
assert Packet20.id == 20
def test_size():
"""Tests the packet `size`."""
assert Packet20.size == 2
def test_from_bytes_counter_clockwise():
"""Tests `from_bytes` with a counter-clockwis... |
996,977 | e8b9d6c5f566b4b9f1d684e20382a1a4956a7c00 | # Write a code to generate a half pyramid pattern using numbers.
# Sample Input :
# 5
# Sample Output :
# 5
# Sample Output :
# 55555
# 4444
# 333
# 22
# 1
N = int(input(''))
for index in range(0, N):
for secondIndex in range(0, N-index):
print(N-index, end='')
print('')
|
996,978 | 38388a3280d7841f6589e246a02213bae5149d1f | from mng.models import KV
def kvs():
settings = KV.objects
zero_year = 2016
zero_month = 2
zero_day = 28
desk_max = 20
tent_max = 20
umbrella_max = 15
red_max = 5
cloth_max = 5
loud_max = 2
sound_max = 1
projector_max = 1
if settings.count() <= 0:
zero_year... |
996,979 | d0429d506e0092b862834803b1ec7ab298c33d99 | #corey b. holstege
#2018-10-18
#problem 2.4.4
a = 6
b = 2
c = 9
print(c - a)
print(a + b * c)
print((a * c) / (4 * a))
print(c / (a - 3 * b))
|
996,980 | c77187f825812d7631fb7a985b0d1a18e359b45d | from util import memoized
from itertools import count
@memoized
def fib(n):
"""Returns the nth number in the Fibonacci sequence"""
if n in (0, 1): return n
return fib(n-1) + fib(n-2)
if __name__ == "__main__":
sum = 0
for n in count(1, 1):
result = fib(n)
if result > 4000000: brea... |
996,981 | ce5ced353bc4417f4f000f71973c1542382c4032 | """
Part 1: Discussion
1. What are the three main design advantages that object orientation
can provide? Explain each concept.
Abstraction
Abstraction allows chunks of code to be hidden, enabling users of the code to
access the functionality but not requiring that they understand the underlying
nuts an... |
996,982 | 24495d8311ce8d85605764ba1f5e4bfcee3fe639 | from flask_wtf import FlaskForm
from wtforms.fields import StringField, IntegerField, RadioField
from wtforms import validators
class FeatureInput(FlaskForm):
sex = RadioField('sex', choices=[('man','a man'),('woman','a woman')], validators=[validators.Required()])
pclass = RadioField('passenger_class', choice... |
996,983 | 97a60df3d3496c393008d0a228a46412552997f5 | '''
Created on 2012-9-9
@author: TheBeet
'''
result_tag_count = 13
result_all = ['Waiting',
'Accepted',
'Presentation Error',
'Wrong Answer',
'Runtime error',
'Time Limit Exceed',
'Memory Limit Exceed',
'Ou... |
996,984 | 71b3f43d01bda2a4169a1b24a09d5d3e0024eeaa | from kivy.app import App
class opencvApp(App):
pass
if __name__ == '__main__':
opencvApp().run() |
996,985 | 9c659528b869bcbe2af01aff5cdef23bd35dd431 | import pygame
# SCREEN
#######################################
# Set gamescreen size
WIDTH_SCREEN = 800
HEIGHT_SCREEN = 800
SCREENSIZE = (WIDTH_SCREEN, HEIGHT_SCREEN)
screen = pygame.display.set_mode(SCREENSIZE)
# GENERAL SETTINGS
###########################################
# COLORS
RED = (255, 0, 0)
GREE... |
996,986 | 01f73c7531c00b1fba2f688e3fa7f5311414f546 | import ctypes
lib = ctypes.CDLL('./libPython.so.2')
lib.print_python_int.argtypes = [ctypes.py_object]
i = -1
lib.print_python_int(i)
i = 0
lib.print_python_int(i)
i = 1
lib.print_python_int(i)
i = 123456789
lib.print_python_int(i)
i = -123456789
lib.print_python_int(i)
i = 12345678901
lib.print_python_int(i)
i = 1030... |
996,987 | 216350318ed16a4568192387b1fd908915626c37 | import requests
url="http://cc.linkinme.com/hljtv5/9"
headers={"Referer":"http://www.hljtv.com/live/folder424/","User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"}
r=requests.get(url,headers)
r.encoding='utf-8'
r=r.text
print(r) |
996,988 | 90e79ce8936ed4acc826141cbdfe446cf433cc84 | import rhinoscriptsyntax as rs
class Turtle:
def __init__(self, pos = [0,0,0], heading = [1,0,0]):
self.heading = heading
self.point = rs.AddPoint(pos)
pointPos = rs.PointCoordinates(self.point)
self.direction = rs.VectorCreate(heading,pointPos)
self.lines = []
... |
996,989 | 85726754dcd2b8d8d1f4abbdde84fb6adfd3547a | ids = ['316219997', '316278670']
import utils
from itertools import chain, combinations
class Node:
def __init__(self, state, parent=None, action=None):
self.state = state
self.parent = parent
self.action = action
self.depth = 0
if parent:
self.depth = parent... |
996,990 | 9ef40157524fb27b6be48a80eded433825cf8949 | from sqlalchemy.engine import Engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, INT, create_engine, TEXT
Base = declarative_base()
class VirusStatics(Base):
__tablename__ = 'VirusStatics'
id = Column(INT, primary_key=True, autoincrement=True)
report_da... |
996,991 | df652ee8a72d537c9d512abd7f1bacee993f552e | print "Tarea python"
import numpy as np
N=30
tres=[]
cinco=[]
siete=[]
nueve=[]
print tres
for i in range (N+1):
tr=3*i
cin=5*i
sie=7*i
nue=9*i
if(tr<=N):
tres.append(tr)
if(cin<=N):
cinco.append(cin)
if(sie<=N):
siete.append(sie)
if(nue<=N):
nueve.a... |
996,992 | 2376b5b1ea6f0de0b95f32e127d1f02f19685488 | # Generated by Django 2.2.4 on 2019-08-20 10:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('goods', '0003_auto_20190814_1545'),
]
operations = [
migrations.AlterModelOptions(
name='goods',
options={'verbose_name': '商... |
996,993 | 093ca9803474de0f92fba9726d4f3b79ff2b8bda | # Generated by Django 3.0.5 on 2020-08-05 15:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0005_auto_20200805_2028'),
]
operations = [
migrations.AlterField(
model_name='blog',
name='createdon',
... |
996,994 | 2c3ab6a02bb4e3c0b1650b7e4b952c703fac2948 | from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
import logging
class DataQualityOperator(BaseOperator):
ui_color = '#89DA59'
@apply_defaults
def __init__(self,
# Define your operators params ... |
996,995 | a331d3ef4a5f919ba8d935964890045d74885983 | # @Author: Mikołaj Stępniewski <maikelSoFly>
# @Date: 2017-12-16T02:09:12+01:00
# @Email: mikolaj.stepniewski1@gmail.com
# @Filename: main.py
# @Last modified by: maikelSoFly
# @Last modified time: 2017-12-17T15:20:01+01:00
# @License: Apache License Version 2.0, January 2004
# @Copyright: Copyright © 2017 Mikoła... |
996,996 | 3134c30ff591b33bd3b2eb242e72dcd593bc82e6 | import cv2
import numpy as np
import math
import queue
import time
import dlib
import zerorpc
import base64
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
#######################################################################################################################... |
996,997 | 30b01587e9fed94c3a5cafdda064cee72595614b | # Write your MySQL query statement below
select Email
from Person
group by Email
having count(Email)>1
|
996,998 | 3011d55c79647729100c9cc7ac2ef303ee658ebd | # major, minor, revision
# major 1, 2, 3
# minor new feature 1.0, 1.1, 1.2
# revision small fix 1.1.1, 1.1.2
# 0.1, 0.5... pre-release versions
def get_length(version_str):
nums = version_str.split('.')
num_size = len(nums)
if num_size == 3:
return len(nums[0]), len(nums[1]), len(nums[2])
elif ... |
996,999 | 7be00fced609aa164c23eb1c98d5b89eb1f326ee | #!/usr/bin/env python3
import time
import csv
DATA_FILE = "data.csv"
def load(tasks):
with open(DATA_FILE) as csvfile:
timesheetData = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in timesheetData:
try:
tasks.append({"name": row[0], "estimate": row[1], "tim... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.