index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
16,600 | 8968a15aaa1f8a31caf5108240f3740944def166 | #!/usr/bin/env python
# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Tests for code coverage tools."""
import os
import re
import shutil
import subprocess
import sys
import unittest
import coverage_utils
def _RecursiveDir... |
16,601 | d68f1dc1a7b8f16102579df40bc60c44fe2a0e7c | import pandas as pd
fandango = pd.read_csv('fandango_score_comparison.csv')
# Use the head method to return the first two rows in the dataframe, then display them with the print function.
print('\nPeak at 1st 2 rows using head\n')
print(fandango.head(2))
# Use the index attribute to return the index of the d... |
16,602 | 579638fac54f2e891b8ea137f4f34f37b00407a5 | from django.contrib.sitemaps import Sitemap
from guardian.shortcuts import get_anonymous_user
from .models import Case
class CaseSitemap(Sitemap):
def items(self):
return Case.objects.all().for_user(get_anonymous_user())
|
16,603 | 8826b367a92d9e3eef24a9e8a6bea8738747eb4a | # -*- coding: utf-8 -*-
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.core.urlresolvers import reverse
def redirect(request, mode=1):
if 'redirect_inscription' in request.session:
try:
redirect_inscription = request.session['redirect_inscription']
del request.session['redir... |
16,604 | 70a0c111bc56ff0955c7b489b7c300d043b19a1a | import sys
pp = "C:\\Python27\\lib\\site-packages\\nose-1.3.7-py2.7.egg"
sys.path.append(pp)
import maya.standalone
maya.standalone.initialize(name='python')
import nose
nose.run()
|
16,605 | 9193ad1f278effbc6c75a8265552820096fe1b01 | # -*- coding: utf-8 -*-
import os
# flask
SECRET_KEY = os.environ.get("CG_SECRET_KEY") or "thisIsNotASafeKey"
TEMPLATES_AUTO_RELOAD = True
# sqlalchemy
SQLALCHEMY_DATABASE_URI = os.environ["CG_SQL_DATABASE_URI"]
SQLALCHEMY_POOL_RECYCLE = 7200
SQLALCHEMY_TRACK_MODIFICATIONS = "FLASK_DEBUG" in os.environ
# server
CG_E... |
16,606 | 39cc3b60e5b5aef5d5a91f59d5cc347e367a290d | import time
t_0 = time.time()
print('a')
def rgb_tiles_ii(x, len_colour):
f_in = [0, 1, 2, 4, 8]
for n in range(5, x + 1):
#print('n', n)
f_n = f_in[n - 1] + f_in[n - 2] + f_in[n - 3] + f_in[n - 4]
#print('n, f_in:', n, f_in)
print(n, f_n)
f_in.append(f_n)
print(... |
16,607 | cff81b7b2ec761871ae8f6d4ff7ad5ad900a6fc0 | import requests
import json
import time
import random
url = "http://119.3.209.144:6200"
for i in range(0,10):
names=['Kelly','Addison','Alex','Tommy','Joyce','Andrew','Alonso','Karen','Denny',
'Kenney','Colin','Warren','Ben','Carl','Charles','Easter','Bill','Glen','Alva',
'Roger','Solomon','Pa... |
16,608 | 25c90b3be2cad27bc9b6e3b234a6019faf779d46 | """
Author : A. Emerick
Assoc : Columbia University - American Museum of Natural History
Date : April 2016
Code to extract (most) of the SED from binned OSTAR2002 data
and repack with first column as the frequency, and each subsequent
column a separate OSTAR2002 model. Due to the silliness of the
S... |
16,609 | f91a665c70848771ddae2030404b38b26f851ec8 | # Highest repeated word (histogram program)
name = input("Enter file: ")
p = open(name, "r")
# Counts word frequency
counts = dict()
for line in p:
words = line.split()
for word in words:
word = word.lower() # Makes all words in lowercase to count correctly
counts[word] = counts.get(... |
16,610 | bce4fd832ec222f75f62a770c21b968823dcf6be | from math import *
n = float(input())
a = n - int(n)
print(a)
a = a * 100
print(floor(n), round(a), end=' ')
|
16,611 | c5a9123cf9920ec6c97752f417daf88ae8adb474 | import os
from cm.util import paths
from cm.util import misc
from cm.services import service_states
from cm.services import ServiceRole
from cm.services import ServiceDependency
from cm.services.apps import ApplicationService
import logging
log = logging.getLogger('cloudman')
INVOKE_SUCCESS = "Successfully invoked ... |
16,612 | d09052c22b7598db0ebaf1db0716e626a6ec5a91 | def func(param, **kwargs):
pass
func(param=1, param2=1) |
16,613 | 95ab2802615bc47447294d52d4333bcec170872b | '''
from keras.backend.tensorflow_backend import set_session
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True # dynamically grow the memory used on the GPU
config.log_device_placement = True # to log device placement (on which device the operation ran)
sess = tf.Session(config=... |
16,614 | 98fa948765ed6a71b82548753105f7086fb43550 | import math
class Problem:
def __init__(self) :
self.data = {"X": 0, "R": 0, "C": 0}
self.X = 0
self.X = 0
def readProblem(input):
problem = Problem()
line = input.readline().split()
problem.data["X"] = int(line[0]);
problem.data["R"] = int(line[1]);
probl... |
16,615 | 152a21ad011bfe4912fdba4fda48acc98b939521 | """Support for Netatmo Smart thermostats."""
from datetime import timedelta
import logging
from typing import List, Optional
import pyatmo
import requests
import voluptuous as vol
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT,
... |
16,616 | 3dc8fd9243467e234fe915093bed7dc8e8015c6b | from .declarations import (
result_type, nothing, requires as RequiresType,
returns as Returns, returns_result_type as ReturnsType
)
class CallPoint(object):
next = None
previous = None
requires = nothing
returns = result_type
def __init__(self, obj, requires=None, returns=None):
... |
16,617 | b7ed62e478a72c716c3530687ac5b1e38b52a1b5 | """
在CSDN上看到“不脱发的程序猿"的文章《基于Python的人脸自动戴口罩系统》
https://blog.csdn.net/m0_38106923/article/details/104174562
里面介绍了怎么利用Dlib模块的landmark人脸68个关键点识别人脸五官数据,从而实现带口罩。
本文是在作者的基础上,增加了添加眼镜的部分。
"
"""
# _*_ coding:utf-8 _*_
from PIL import Image, ImageTk
from tkinter.filedialog import askopenfilename
import cv2
i... |
16,618 | 2e1b4d4aca0d4424d8c1a205fa1168acea3de80c | from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse
class BookAd(models.Model):
CAT_CHOICES = (
('FANTASY', 'fantasy'),
('BIOGRAPHY', 'biography'),
('CLASSIC', 'classic'),
('COMMIC', 'commic'),
('HORROR', 'horror')... |
16,619 | 622d21f44c91eb87608495e9519d0cd7e9f58d3f | class board:
def __init__(InitMap,self):
|
16,620 | 7f4f3f38b8126a404953bbd0016561d5ae714907 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'selectlines.ui'
#
# Created: Sun Oct 30 19:53:08 2016
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except At... |
16,621 | 1fa9291f928c1a65483dc382870cce517ec2885a | from django.contrib import admin
from .models import Teacher, Student
# Register your models here.
@admin.register(Teacher)
class TeacherAdmin(admin.ModelAdmin):
pass
@admin.register(Student)
class StudentAdmin(admin.ModelAdmin):
pass |
16,622 | b9f0f5846d3f0a09451a77ff78642f0439eda0eb | import argparse
import json
import re
import sys
import threading
import time
from socket import AF_INET, SOCK_STREAM, socket
from common.variables import DEFAULT_PORT, ENCODING, MAX_PACKAGE_LENGTH
from log.client_log_config import LOG
def log(func):
def wrap_log(*args, **kwargs):
res = func(*args, **kwa... |
16,623 | 5f794bf2ad428e216548c832bf5030c93827b36d | task_string = 'Hello, Python my name is Bahram' #print the third character of this string
print(task_string[2]) #1 task
print(task_string[-1]) #2task
print(task_string[0:5]) #3 task
print(task_string[:-2]) #4 task
print(task_string[::2]) #5task
print(task_string[-1::2]) #6 task
print(task_string[::-1]) #7task
pr... |
16,624 | 46cdf2b96388729f001fc0933534740049fe62a9 | import pulp as _pulp
import numpy as _np
'''
Graph description
v0 -> v2
v0 -> v1
v0 -> v3
v1 -> v3
v2 -> v3
v0
/ |\
/ | \
v1 | v2
\ | /
\ |/
v3
All the initial capacities are 1. Max flow is 3
Cost function
Cost of increasing capacity on any edge by factor of x is x.
--------------------------... |
16,625 | b0e1b793c28f3ee013cb31f4ef037ab04e52ff2c | # -*- coding: utf-8 -*-
import os
import re
import xlwt
from PyQt5.QtWidgets import QWizardPage, QWidgetItem, QSpacerItem, QComboBox
from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
class QIWizardPage(QWizardPage):
def __init__(self, settings, parent=None):
super(QIWizardPage, self).__init__(p... |
16,626 | 6d1875443f6d3907f5193e25ce1b78e88bba6f0c | #!/usr/bin/python
from server.Emolytics import emolytics
from wsgiref.simple_server import make_server
from werkzeug.debug import DebuggedApplication
if __name__ == '__main__':
application = DebuggedApplication(emolytics, True)
httpd = make_server('0.0.0.0', 8051, application)
httpd.serve_forever()
|
16,627 | 3010d6f049611dc04d217bf37e0e6b14862ac71e | from unittest import TestCase
import games.cards.Class_Player
from games.cards.Class_Card_Game import Card_Game
from games.cards.Class_Player import Player
from games.cards.Class_DeckOfCard import DeckOfCards
class TestCard_Game(TestCase):
def setup(self):
self.game1 = Card_Game("ori", "snir", 15)
... |
16,628 | d7d6e0bc6f9019a3c1c14525a9691e0122f7e809 | rows = int(input("Enter the no. of rows in A"))
for i in range(rows):
space = rows - i - 1
while space>0:
space = space -1
print(" ",end='')
for j in range(i):
if j == 0 or j == i-1:
print("*",end=' ')
elif i==rows/2:
print("*",end=' ')
else:
... |
16,629 | 4c8832e53699ab950cf3cf8707e6872757048f3f | import sqlite3
from track import Track
from playlist import Playlist
def create_database():
try:
sqliteConnection = sqlite3.connect('FinalProjectDatabase.db')
cursor = sqliteConnection.cursor()
cursor.execute("DROP TABLE IF EXISTS Spotify_Data")
create_spotify_table_sql ='''
... |
16,630 | 1ba4740aea169759dd854db348dff1fc9063cd12 | # Generated by Django 2.2.6 on 2020-01-16 00:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tribal', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Organisation',
fields=[
('i... |
16,631 | 37e8d7694c8385c1f3c5502b279755a31c5e78c2 | """
The source code in this file is adapted by reusing
some part of the source code from the official
RabbitMQ documentation.
"""
from typing import Any, Optional, Union
from pika import (
BasicProperties,
BlockingConnection,
ConnectionParameters,
PlainCredentials
)
from pika.adapters.blocking_connecti... |
16,632 | 92f1e0a66fde2bd81a9cc5aed3f26bbd61bffa6a | from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from quest.models import Action, Record, Quest
# Register your models here.
@admin.register(Action)
class ActionAdmin(ImportExportModelAdmin):#admin.ModelAdmin):
list_display = ('id', 'category', 'name', 'xp', )
list_displ... |
16,633 | 769e223662b2564b1a5562e0caeb4b2ad0ceb897 | from django.conf.urls import url
from django.views.generic.base import TemplateView
from rest_framework.compat import pygments_css
from rest_framework.exceptions import NotFound
from rest_framework.views import APIView
from tg_apicore.schemas import generate_api_docs
class APIDocumentationView(TemplateView):
""... |
16,634 | 8662890cd5c0dcdcbb92748694bb1bbad78baf58 | import numpy as np
from utils import split_treatment_control
def ite_best(train_df, test_df, features, outcome, treatment):
"""
Best possible ITE learnt model (i.e. without exploiting the observable interference).
Only available for synthetic datasets.
"""
train_t_df, train_c_df = split_treatment_... |
16,635 | 5e2ffa201dcecdcd7eb935c5206a0c25b05336d4 | # addition and count
def add (n):
box=0
for i in range(1,n+1):
box=box + i
print("count=",box)
num = int(input("enter the number:"))
add (num)
|
16,636 | 3cda1ef15d044168edbc0efe932260de7b75762a |
import sys
import os
import time
import tkinter
print('学生信息管理系统 V1.0')
|
16,637 | 29e8ebebcd0df37c109e5d0281880a24c7119a8f | import requests
from pprint import pprint
from data import db_session
from data.films import Films
"""Api кинопоиска для парсинга фильмов"""
db_session.global_init("db/blogs.sqlite")
db_sess = db_session.create_session()
# data = {
# 'actors': data_film['actors'],
# 'age': data_film['age'],
# 'collapse': ... |
16,638 | e096fc0fe38b1c9b82ebabb31bccdc7ae558cc8c | import BattleReplay
import BigWorld
import gui.Scaleform.daapi.view.battle.shared.markers2d.plugins as plug
from Avatar import PlayerAvatar
from AvatarInputHandler import AvatarInputHandler
from Vehicle import Vehicle
from aih_constants import CTRL_MODE_NAME
from constants import AIMING_MODE
from vehicle_systems.tankSt... |
16,639 | dbe5020f84aa2996e023cc8d1e26a1faf0e253e9 | alpha_dict = {
'a': 0.0575,
'b': 0.0128,
'c': 0.0263,
'd': 0.0285,
'e': 0.0913,
'f': 0.0173,
'g': 0.0133,
'h': 0.0313,
'i': 0.0599,
'j': 0.0006,
'k': 0.0084,
'l': 0.0335,
'm': 0.0235,
'n': 0.0596,
'o': 0.0689,
'p': 0.0192,
'q': 0.0008,... |
16,640 | 3a7fab634088508da3e2cff7c6834c6b718f2d07 | numbers =[1,5,2,8,6,10,3,4,2,10]
latters =['a','n','z','b','g','k']
value=min(numbers) #en küçük sayı değerini alır.
value=max(latters) #en büyük harfi alır.
value=numbers[3:6] #3. indek il 6. index arasındakileri yazdırır.
print(value)
latters[3]='AYŞE' #3. indekse... |
16,641 | 6fc2b1531f47f6b33fd40e9858a77f1506f44e42 | from typing import List
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
if not nums:
return [[]]
ans = [[]]
for num in nums:
ans+=[i + [num] for i in ans]
return ans
class Solution:
def subsets(self, nums: List[int]) -> List[List[i... |
16,642 | 4c2f2578bd3a33354c4e5c83ac93d07fabd6c825 | from dms.models import Location, DisasterType, Disaster
from dms.services.stats_summary import StatsSummaryService
from dms.tests.base import MongoTestCase
class DisasterSummaryStatsTest(MongoTestCase):
def setUp(self):
self.disaster_type = DisasterType(**dict(name='Flood', description="Some flood")).save... |
16,643 | 268c88e8fce20db46f88f5586fe38ddb703de157 | from .problems_facade import get_available_days, get_day_calculator
|
16,644 | eecc5f3e6b4b0e539ab1d6e8d8eab5cb1195273a | import pickle as p
filename = 'features.pkl'
with open(filename, 'rb') as f:
x = p.load(f)
for a,b in x.items():
print("img_id: "+ a)
print("img_desc: "+ str(b))
break |
16,645 | c144a64e2e1fd0016533dfbd629783893d22feac | # -*- coding: utf-8 -*-
import time
import asyncio
import threading
"""
协程
相比于多线程,协程的特点在于它使用一个线程来完成并发任务,多任务切换由程序自己控制。在IO密集型任务中,可以把耗时长的IO操作做成异步处理。
根本区别:多进程与多线程性能更多取决于机器的性能,但协程则更多依赖程序员自身的能力。
协程的优势:
1. 协程中程序的切换不是依靠线程切换,而是通过程序自己控制。因此没有线程切换的开销,效率更高。
2. 协程不涉及锁机制。因为协程是单线程,不存在同时写变量的冲突,在协程中控制共享资源不加锁,只需要判断状态就好了。所以效率进一步提高。
如果想要利用... |
16,646 | 675c2913602fe10787864d97ffcec15d9a0c4f45 | import tensorflow as tf
import common
class TRANSITION(object):
def __init__(self, in_dim, out_dim, size, lr, do_keep_prob):
self.arch_params = {
'in_dim': in_dim,
'out_dim': out_dim,
'n_hidden_0': size[0], #800,
'n_hidden_1': size[1], #400,
'do... |
16,647 | 0a5c0784ace7d4b3b7be81b6071897f5b962a560 | # -*- coding:utf-8 -*-
__author__ = 'lynn'
__date__ = '2021/5/12 18:12'
import numpy as np
import cv2
# 自适应阈值出来了很多噪点,感觉更适合自然场景多些
def prepare_gray_(img_color):
img_gray = cv2.bitwise_not(cv2.cvtColor(img_color, cv2.COLOR_RGB2GRAY))
return cv2.adaptiveThreshold(img_gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.TH... |
16,648 | 446f42faedb7cbc7d5712c9d8b0d008d69ca8f5b | #!/usr/bin/env python
"""
Module "init_catalog" create catalog.db
with example content to test the application.
"""
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from model_catalog import Category, Base, Item, User, engine
# Create database session ( engine is created in model_catalog ... |
16,649 | c5c9e2a08c8a1293761e017a4ab4c1e3af744831 | import socket
def CheckThereIsConnection(host="8.8.8.8", port=53, timeout=3):
try:
socket.setdefaulttimeout(timeout)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
return True
except socket.error:
return False
|
16,650 | e0b7cfdef680f0a899320a909a4e65f4c3c4ee8d | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from django.db import models
from django import forms
from .models import Post, Category, Tag
class CommentAdmin(admin.ModelAdmin):
list_display = ('user_id', 'post_id', 'pub_date', 'content')
class PostAdmin(admin.... |
16,651 | a4a2910537e3a7a5307cd463eb5232abcba2eb74 |
def assignment(date):
date = date.split('/')
if len(date[0]) != 4:
return False
else:
if int(date[1]) >= 13 or len(date[1]) < 2:
return False
else:
return True
|
16,652 | de485502b96efbc021317aebff64545f23423ccd | import librosa
import torch_audiomentations
from torch import Tensor
import torch
from hw_asr.augmentations.base import AugmentationBase
class Stretch(AugmentationBase):
def __init__(self, min_=0.75, max_=1.25, *args, **kwargs):
self.min_ = min_
self.max_ = max_
def __call__(self, data: Tens... |
16,653 | 494dde8ad26f3a0064ed368913115648e78c4d8b | # Copyright (c) 2009-2014 Stefan Marr <http://www.stefan-marr.de/>
#
# 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 without limitation the rights
# to use, cop... |
16,654 | 965ea90eb7ab675e12a864537dff0395765d8a3d | def multiplier(n):
a = [] #вывод множителей
b = 2
while b * b <= n:
if n % b == 0:
a.append(b)
n //= b
else:
b += 1
if n > 1:
a.append(n)
return a
|
16,655 | a885b111b399dbafaaf1bd39574835221ad82105 | import numpy as np
from .record_inserter import inserter
from .numeric_inserter import ArrayInserter as NumericArrayInserter
from .utils import set_encoded
@inserter
class FileInserter(NumericArrayInserter):
""" Inserter for file-like objects.
File groups register as 'file' type, whereas the data registers ... |
16,656 | 25e99ed5ed165357611d11826c5c6747f9a2c1c7 | """
Django settings for busshaming project.
Generated by 'django-admin startproject' using Django 1.9.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os... |
16,657 | b8cc1ee4ed391e7a6c7263573bfeb2b3b07d832e | fruits=['apple',"banana","mango","apple",'guava','orange','jack-fruits']
print(fruits.count('apple'))
number=[2,9,4,7,0,1]
print(sorted(number)) # numbers are shorted in print but the list not sorted
print(number)
number.sort() # the list was sorted
print(number)
number.clear() # remove all elements of the list
print(... |
16,658 | fa92b286cc19ba45a8b53abedb92c5133e4e2d59 | from django.shortcuts import render
from post.models import Post
from django.core.paginator import Paginator
from django.db import connection
# Create your views here.
def query_post(request, num=1):
post_list = Post.objects.all().order_by('-create_time')
paginator = Paginator(post_list, 2)
num = int(num)... |
16,659 | 52f060b9f55d2986dae4c3f3e1e4cf1b68d6cc99 | import os
from unittest import TestCase
import subprocess
class LocustTestCase(TestCase):
def test(self):
path = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'django/project/db.sqlite3'
)
)
subprocess.call(['cp', os.devn... |
16,660 | 3fc26f25cab014c852277f270603a38d89a2a3ae | print ("我的第一隻Python程式")
name=input("what is your name\n")
print("hi,%s."%name)
|
16,661 | 198510006be3bf84a38b9a6dd9ae533c96edc0dc | # Main DRNN Restoration Script
from brahms_restore_ml.drnn.drnn import *
from brahms_restore_ml.audio_data_processing import PIANO_WDW_SIZE
import sys
import random
from scipy.io import wavfile
import numpy as np
import json
import math
import multiprocessing
def run_top_gs_result(num_str, best_config,
... |
16,662 | 52d1c31e9329dbbaa4dde6dd455c4af90cbb1be8 | from flask import Flask, render_template
from config import Config
from forms import *
from models import *
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy()
db.init_app(app)
app.config['SECRET_KEY'] = 'you-will-never-guess'
@app.route('/home')
def home():
return render_template('hom... |
16,663 | 370078580aa2502aebc40a50aac4dc34d503e5af | from django.apps import AppConfig
class NessieConfig(AppConfig):
name = 'nessie'
|
16,664 | 5234f0163d0a3dc0511ca2096c48fa46fbf5c56b | # f2 3位水仙花数计算B
def flowercal():
flowerls = []
for i in range(100,1000):
if i == (i//100)**3 + ((i%100)//10)**3 + (i%10)**3:
flowerls.append(i)
print(",".join(str(item) for item in flowerls))
flowercal()
|
16,665 | e4ebac790764e331e5973bdc353da8c1fd5fee02 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/12/17 下午9:21
# @Author : tudoudou
# @File : googLeNet.py
# @Software: PyCharm
import warnings
from keras.models import Model
from keras import layers
from keras.layers import Activation
from keras.layers import Dense
from keras.layers import Input
fr... |
16,666 | bc7438cd91b9085c47395811636ceef6ddf84588 | import unittest
import sys
import os
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../src")
from GUI.Chat.User import UserListEntry
class User_Test(unittest.TestCase):
def test_inequality(self):
userA = UserListEntry("a")
userB = UserListEntry("b")
self.assertNotEqual(us... |
16,667 | 58caa8fcc4e5873080f7daa29b59a477e9bb8934 | #!/usr/bin/env python
#
#
# Software License Agreement (Apache License)
# Copyright (c) 2017, <Advanced Remanufacturing Technology Centre/Mingli Han>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Lice... |
16,668 | cf9f73d2e56821c58b77628d195a9a231a3219df | #!/usr/bin/env python
#
# Copyright 2019 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... |
16,669 | e9fcf027227dc2c76d58b56afc8a0ae3827d8785 | import time
from PyQt4 import QtCore
import sys
from PyQt4 import QtGui
import os
import Kmean
import Region_grow
import graph_based
import thread
import otsu
import Err
import fuzzy
import GlobalThresholding
from PIL import Image
from skimage import io
import matplotlib.pyplot as plt
import numpy as np
try:
_from... |
16,670 | 69256a5ab8d5931a799cd6c871fc5b6ad8cf0f4c | # -*- coding: utf-8 -*-
# @Time : 2018/11/24 5:23 PM
# @Author : zeali
# @Email : zealiemai@gmail.com
from core.template import gen_token
from dueros.card.ImageCard import ImageCard
from dueros.card.ListCard import ListCard
from dueros.card.ListCardItem import ListCardItem
def gen_image_card(items=[], hints=[])... |
16,671 | ffad62e3e12dfcab7e6e3982a01fa9789f9b9e18 | from src.pairs.TriangularDeck import TriangularDeck
from src.pairs.util import intMapper
from src.pairs.GameState import GameState
from src.pairs.DPSolver import DPSolver
from src.pairs.Deck import Deck
import numpy as np
def main():
deck = TriangularDeck(4)
game = GameState(deck, 7, 3)
solver = DPSolver(... |
16,672 | 0af9c7571673f2a6c61316987ce3696b357b7cfb | from owe.utils.stats import *
from owe.utils.utils import *
from owe.utils.embedding_utils import *
|
16,673 | 9a2bb2528c4f0393b85b7dd3091da8f515c8b307 | #!/usr/bin/env python
# coding:utf-8
from PoboAPI import *
import datetime
import numpy as np
#开始时间,用于初始化一些参数
def OnStart(context) :
print("I\'m starting...")
#登录交易账号,需在主页用户管理中设置账号,并把期货测试替换成您的账户名称
context.myacc = None
if "回测期货" in context.accounts :
print("登录交易账号[回测期货]")
if context.acco... |
16,674 | 8ced2bfd3549e136b499862ae203bf77b4b67bee | import numpy as np
import random
vetor = []
vetortorre=[]
tam = int(input("insira o tamanho do vetor \n"))
for i in range(tam):
vetor.append(
int(input("insira o valor do vetor na posicao " + str(i) + "\n")))
ordenavetor = np.sort(vetor)
print(ordenavetor)
n=int(input("alcance da torre\n"))
for i in rang... |
16,675 | 651519db3d8cc207808d5f3dc1ea96f56452d723 | import glob
import pandas as pd
import reddit_utils
import pushshift
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
import matplotlib.dates as mdates
import datetime
from datetime import timedelta
def get_relative_freq(word, subreddit, rolling=False):
word_df = reddit_utils.utc_to_d... |
16,676 | 22ba5ff934518e4a07d6049bac171312e2c3c623 | import click
import os
from rover.rover.tools import n_pages
from .rover.main import show_missions, show_downlink_status, show_stats, get_cameras, downloader
@click.group()
def cli():
pass
@cli.command("missions", help="show list of active missions.")
def missions():
show_missions()
@cli.group(help="show ... |
16,677 | 569cdb1eec0958d49d3b615018262496c80bb20f | #!/usr/bin/env python
# coding: utf-8
import pyglet.canvas
import numpy as np
# Input display information
inch = 23
aspect_width = 16
aspect_height = 9
# Input a variety
# size variation = [1, 2]
# eccentricity = [1, 2]
# Input stereogram size in cm unit
size = 5
# Input line size in cm unit
line_length = 0.7 # 3... |
16,678 | e8676d3dc0428892d484b3ba2cdaa3472a0fde04 | a = int(input("Введите число a: "))
b = int(input("Введите число b: "))
c = int(input("Введите число c: "))
if a / b == c:
print(a, "разделить на", b, "равно", c)
else:
print(a, "разделить на", b, "не равно", c)
if a ** b == c:
print(a, "в степени", b, "равно" , c)
else:
print(a, "в степени", b, "не рав... |
16,679 | 5a17ebc48d315b9cbbc31857ad2012f58e49ad11 | #!/usr/bin/env python
from pdb import set_trace as br
from operator import itemgetter
from numpy.polynomial.polynomial import Polynomial
from modules.utils import OUT_CONFIG
from modules.geometry.hit import HitManager
from modules.geometry.sl import SL
from modules.geometry.segment import Segment
from modules.geometry... |
16,680 | 4a200f763691aac47cb4b361dbac5f9dd18fc7d4 | """segmentation_dataset_generator_controller controller."""
from controller import Robot
from controller import Connector
from controller import RangeFinder
from controller import Camera
from controller import Supervisor
import random
import socket
import struct
import pickle
import numpy as np
import math
import cv2
... |
16,681 | 678ed3247125fdd17e2fd121713823b5e74bafc3 | from django.db import models
from django.contrib.auth.models import User
#Querying User model with use_natural_foreign_keys=True returns username instead of key
class UserManager(models.Manager):
def unatural_key(self):
return self.username
User.natural_key = unatural_key
class ForumPost(models.Model)... |
16,682 | c7f70cd4c28882d8114a79c919e820d8c271fb97 | import requests
import time
url = 'http://localhost:8000/'
payload = "welcome world"
now = int(time.time())
r = requests.post(url, data=payload)
print("timestamp: " + str(now) + " | message sent! - status: " + str(r.status_code))
|
16,683 | 105457c0de9c599e05ba8cf0467594dcb85bbc09 | import pandas as pd
import csv
import plotly.figure_factory as ff
import statistics as st
import random
import plotly.graph_objects as go
df=pd.read_csv("School1.csv")
data=df["Math_score"].tolist()
#fig=ff.create_distplot([data],["Math_score"],show_hist=False)
#fig.show()
popMean=st.mean(data)
popStd... |
16,684 | 35bf9cae2f482af7ca275cddbdd1c1686a88a643 | def colorindo(string, cores):
RED = "\033[1;31m"
BLUE = "\033[1;34m"
CYAN = "\033[1;36m"
YELLOW = "\033[1;33m"
GREEN = "\033[0;32m"
RESET = "\033[0;0m"
BOLD = "\033[;1m"
REVERSE = "\033[;7m"
dicionario = {
'vermelho': RED,
'azul': BLUE,
'ciano': CYAN... |
16,685 | c551ac8ed6081253269872ac6a472f2b73c9b474 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on March 01 9:47 PM 2020
Created in PyCharm
Created as Misc/bh_binary_power
@author: Dylan Neff, Dylan
"""
import matplotlib.pyplot as plt
import numpy as np
# Constants
g = 6.67e-11 # m^3 kg^-1 s^-2
c = 2.9927e8 # m s^-2
m_solar = 1.989e30 # kg
def mai... |
16,686 | 56f5c60a19b43f34ff724d9b0ae5f4851f4de5e0 | # Generated by Django 2.0.13 on 2021-01-26 17:32
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('shop', '0005_product_bi... |
16,687 | 745ec82b38ca3de1b6375cd37f826dd894a2c710 | '''
Saravanan Ramanathan
January 2016
'''
# Function to generate multi-core task set
from taskparam import ts
import mrand as MR
from math import *
from random import *
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
import pylab
import random
import numpy
# Function to generate all task set
... |
16,688 | 50cc5a08455dc81fd8224fce2ec0aa21047f416b | # -*- coding: utf-8 -*-
import xlrd
import IPy
import time
import json
from datetime import datetime
from openpyxl import Workbook
from openpyxl.writer.excel import save_virtual_workbook
from django.shortcuts import render, get_object_or_404, get_list_or_404, redirect
from django.http import HttpResponse, HttpRespons... |
16,689 | d8fac4b6271f92906ee4fe4885996d0fbc088899 | import picamera
import picamera.array
import io
from config import IMAGE_WIDTH, IMAGE_HEIGHT
from PIL import Image
import numpy as np
import logging
from logging import INFO, DEBUG
logging.basicConfig(level=INFO, format="%(levelname)s [%(filename)s line %(lineno)d]: %(message)s")
logger = logging.getLogger()
logger.d... |
16,690 | b0c67ce4b40c15457d0d87be169509a5e709db3c | a=int(input())
def test(a1,result):
if a1/10>0:
result+=1
a1=int(a1/10)
return test(a1,result)
else:
return result
print(test(a,0))
|
16,691 | 89c3e61b701509a5e22fd7add915e9d5f6ee5979 | # valid 를 통해서 유효한 범위 내인지를 확인
# check 함수를 통해 거리두기를 지키고 있는 지 여부확인
def solution(places):
answer = []
size = 5
def valid(r, c):
return -1<r<size and -1<c<size
def check(x, y, place):
dist = [(1,0),(0,1),(-1,0),(0,-1)]
for dx, dy in dist:
nx, ny = x+dx, y+dy
... |
16,692 | 1b2984a740426f3c0a36ed99342364f6ebe1a81f | def parse(data):
# TODO: your code here
i = 0
list = []
for n in data:
if n == "i" :
i += 1
elif n == "d" :
i -= 1
elif n == "s" :
i *= i
elif n == "o":
list.append(i)
return list
|
16,693 | 7d48b81d49d3c5b88467e25c3df31c095beafe8b | import os
import numpy as np
def create_dawa(class_names_to_load, path_to_dawa):
# Set the paths to the attribute information
path_to_attribute_names = os.path.join(path_to_dawa, 'attributes.txt')
path_to_class_names = os.path.join(path_to_dawa, 'classes.txt')
path_to_attribute_matrix = os.path.join(p... |
16,694 | 1d93a198a9877fc3bd0e23c8f6c5dd7d36bc379e | #!/usr/bin/env python
import sys
from distmesh_dyn import DistMesh
from imgproc import findObjectThreshold
from synth import test_data, test_data_texture, test_data_image
from kalman import IteratedMSKalmanFilter, stats, IteratedKalmanFilter
from renderer import VideoStream
import pdb
import time
import cv2
impor... |
16,695 | fbae963ec6c60958677cf78c31b94d52be7b2032 | import sklearn
from sklearn import datasets
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
iris = datasets.load_iris()
|
16,696 | 1e847078c419a51fada0b15c29c2909c76da2359 | import numpy as np
import pandas as pd
import sys
from keras.layers.core import Dense, Dropout, Activation
from keras.layers import Conv2D, MaxPooling2D, Flatten, BatchNormalization
from keras.models import Sequential,load_model
from keras.optimizers import SGD, Adam
from keras.utils import np_utils
from keras.initiali... |
16,697 | ab5823891ba450affe47b20081b6a8517f8a6124 | #!/usr/bin/python
# encoding:utf-8
"""
@author: yuanxin
contact:
@file: 2017/9/14-muti_proc_demo01.py
@time: 2017/9/14
"""
from multiprocessing import Process,current_process
import time
def worker():
while True:
print('this is worker NO. %s ' % current_process())
time.sleep(0.5)
if __name__=='... |
16,698 | 9e87e86783fe207b5c5c76b63797b5c12d3597e9 | #!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import hashlib
import json
import os
import re
import sys
from pprint import pprint
import argparse
import deepdiff
def get_suspect_packages():
"""
Package names suspected of possible hijacking.
Thi... |
16,699 | 914a29e10e5fda1c620707caf7c56c21d14070c2 | #!/usr/bin/env python
import blaze as bz
import gtabview
data = bz.Data('data_ohlcv.csv')
gtabview.view(data)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.