index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
990,700
6f1631db7ac048861f8b30f209e0297d580c221b
import turtle turtle.speed(100) turtle.shape('turtle') for i in range (1, 10, 1): turtle.forward(50*i) turtle.left(90) turtle.forward(50*i) turtle.left(90) turtle.forward(50*i) turtle.left(90) turtle.forward(50*i) turtle.right(45) turtle.penup() turtle.forward(50*2**(1/2)/2) ...
990,701
9688b7734208ed97d5ee7c625164e1c53c9f50f2
import re pattern = re.compile(r'^<HTML>', re.MULTILINE) pattern.search("<HTML>") pattern.search(" <HTML>") pattern.search(" \n<HTML>")
990,702
af1ce09e1642ce1686a7f19b8cb1fc807e4b69d0
import os, sys new_path = os.path.dirname(os.getcwd()) sys.path.append(new_path+ "/scripts") import unittest from math import pi from circles import circles_area class TestCircleArea(unittest.TestCase): def test_area(self): self.assertAlmostEqual(circles_area(1), pi) self.assertAlmostEqual(circles_...
990,703
803e710bf8683d0787be44a51f20d34281fb7cb7
import csv from load_trucks import get_hash_table hash_table = get_hash_table() # Read distance & address csv files # Big O = O(1) with open('./data/distances.csv', 'r', encoding='utf-8-sig') as distance_csv: distance_list = list(csv.reader(distance_csv)) with open('./data/addresses.csv', 'r', encoding='utf-8-s...
990,704
6511be134d4641f351052dc567f29ac852731f04
#! /usr/bin/python ################### # ConfigParser.py # ################### import logging log = logging.getLogger('ConfigParser') class ParseConfig: """ Simple config file support -> main-app passes file for required args """ _db_args, _table_args, region = {}, {}, [] def __init__(self, conf_to_parse...
990,705
0ef3b06383bd0da51efa44014a8fc03bb518ee75
#!/usr/local/bin/python3 # -*- coding = 'utf-8' -*- # This is time line; import sys import os import curses from time import sleep class Timelinebar: progress_bar_lenth = 25 # progress bar progress_bar_lenth******------- info = "" info_lenth = 0 count = 0 console_col, console_lin = os.get_terminal_...
990,706
b9f07c144261cf9d830ca9f93fee752684c39343
from Persistence.DBCon.connection import * #relProcedimietnoMaterial def create_procedimiento_material(procedimiento, material): id_procedimiento = procedimiento.id id_material = material.id cnx = dbconnect() cursor = cnx.cursor(buffered=True) query = ("INSERT INTO relProcedimietnoMaterial VALUES(...
990,707
e0053979daa8cc86b23c3ec6a692d416a434a3b3
from __future__ import with_statement import logging from logging.config import fileConfig from alembic import context from sqlalchemy import engine_from_config, pool from ultron8.api import settings from ultron8.api.db.u_sqlite.base import Base from ultron8.api.middleware.logging import log from ultron8.web import ...
990,708
60b1a6eb2478c640d45718185d1d3c8c5ba9ee4f
# Generated by Django 3.1.3 on 2020-12-07 15:12 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('myapi', '0003_auto_20201207_2308'), ] operations = [ migrations.RemoveField( model_name='user',...
990,709
56ca2649424d5aad49a17dd5a698ba4d8441208d
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-07 14:19 from __future__ import unicode_literals import django.core.validators from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('restaurant', '0009_restaurant_restaurant_image_thumbnail'), ...
990,710
0f9e0de265708d2dec9cd506cd1ff63e0a52dead
from flask import Flask import ratingscrape app = Flask(__name__) @app.route("/analysis/<user>") def hello(user): userlist = ratingscrape.getRatings(user) if __name__ == "__main__": app.run(host='0.0.0.0')
990,711
0b026da0b84d7c9cd184ddfc1727f3e0e4f2f4db
# -*- coding:utf-8 -*- import asyncio import urllib.request url_imglist = [ 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4858554,2092434492&fm=26&gp=0.jpg', 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1115057027,1261114857&fm=26&gp=0.jpg', 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1...
990,712
38c25a28031cb53a1096d34c8001397d5748cf85
import xml.etree.ElementTree as ET import zipfile from io import BytesIO ns = { "office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0", "text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0", "fo": "urn:oasis:names:tc:opendocument:xmln...
990,713
84e3380a60593ea8817f47cc59539647975349c0
"""empty message Revision ID: a561c41b9a5d Revises: Create Date: 2019-07-25 20:49:30.563270 """ import sqlalchemy_utils from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'a561c41b9a5d' down_revision = None branch_labels = None depends_on = None def upgrade(): #...
990,714
e2d0271d5659a5a18427a1a85f333edc6f4c1ed3
""" TCP服务端 1,导入模块 2,创建套接字 3,设置地址重用 4,绑定端口 5,设置监听,让套接字由主动变为被动接收 6,接受客户端连接 定义函数 request_handler() 7,接收客户端游览器发送的请求协议 8,判断协议是否为空 9,拼接响应的报文 10,发送发送响应报文 11,关闭操作 """ import socket from application import app_基础框架2 import sys import threading """ 1,在类的初始化方法中配置当前的项目 {"2048":"./2048", "植物大战僵尸v1":"./zwdzjs-v1", ...} 2, 在类增加一个初...
990,715
fc4991d3fda556c4b9650b7cf356178369af994b
print('* Write a function in Python code that adds 2+2 and returns the result:') def sum(num): return num+num result=sum(2) print('Result: ',result)
990,716
da58c9cbe3c55a0000110e4fa36cb033b44d996f
import sys sys.dont_write_bytecode = True from flask import Flask, g, Blueprint, url_for, request, jsonify, render_template #import connection from sqlalchemy.ext.declarative import declarative_base from flask.ext.sqlalchemy import SQLAlchemy import sqlalchemy from sqlalchemy.orm import sessionmaker from sqlalchemy imp...
990,717
e3fd7395ee1b08c88155cb1a4bb2ac0937fb0ff7
from typing import List import collections class Solution: def removeBoxes(self, boxes: List[int]) -> int: if not boxes: return 0 boxes_merge = [] num = 0 pre = boxes[0] box_map = collections.defaultdict(int) for box in boxes: if box == pre: ...
990,718
4b4d626c9b350ad4f6887838f3e54b99c5f08d40
from pyspark.sql import SparkSession from datetime import datetime, timezone from io import StringIO import csv,time def split_complex(x): return list(csv.reader(StringIO(x), delimiter=','))[0] def get_esoda(x): return int(x[6]) def get_eksoda(x): return int(x[5]) spark = SparkSession.b...
990,719
f3ed3f13178a5e866fdb5873b8b7d1ff24d31e37
import sys import socket import argparse from threading import Timer from time import sleep def getCmdArg(): parser = argparse.ArgumentParser() parser.add_argument("-p", "--port", help="Give a port to bind.", action="store", default=9000) #port = 9000 if not args.port else args.port # if --port not supplied defaul...
990,720
6961fdac8a2bbb8e9ea6e97c40a4d56e4ddd538f
import logging from book.models import Book from home.models import Utilities from home.views import all_filters_from_db from datetime import timedelta,datetime from redisClient import Client def categorySchedular(): try: categories = Book.objects.values_list("category").filter(category__isnull=False).disti...
990,721
1df33dae9ea47f3a6f637e611bee3c534caea1fb
''' Description : Author : CagedBird Date : 2021-10-10 20:43:19 FilePath : /rl/src/utils/show_chinese.py ''' def show_chinese(): from matplotlib import rcParams config = { "font.family": 'serif', "font.size": 14, "mathtext.fontset": 'stix', "font.serif": ['Si...
990,722
256f1e9a17d837dfdf1d5b7daf36382b458baf7c
""" Have the function MaximumSquare(strArr) take the strArr parameter being passed which will be a 2D matrix of 0 and 1's, and determine the area of the largest square submatrix that contains all 1's. A square submatrix is one of equal width and height, and your program should return the area of the largest submatri...
990,723
33fce609bd35a7e258fefdedac4e459f406fa03d
""" Convolutional Denoising Autoencoder Contains functions to read in preprocessed data, split according to training parameters, train models, and save model outputs """ import os from numpy.random import seed seed(1) import tensorflow tensorflow.random.set_seed(2) from tensorflow import keras from tensorflow.keras.cal...
990,724
064e5dd8352a16b07425c7758a816ef509ca52df
import matplotlib.pyplot as pyplot import numpy from ode_cheb import ode_cheb f = lambda x: x*0 ab = [(1, 1), (-2, 2), (3, 4), (1, 0), (0, 1)] for a,b in ab: n = 20 x, L, rhs = ode_cheb(a, b, f, n) u = numpy.linalg.solve(L, rhs) u = u[0:n] pyplot.plot(x, u, label="a = {}, b = {}".format(a, b)) pypl...
990,725
6205c4244a827aeb430de9c581b26723b018f27d
#!/usr/bin/env python from autoware_msgs.msg import VehicleStatus, Gear from itolab_senior_car_msgs.msg import Servo import std_msgs.msg import math import rospy class Mpc_subscriber(object): def __init__(self): print("RUN Vehicle Status") self.center_steering = 85 self.steering = 0 ...
990,726
55f7f6b202d34d43a1a88f3bd51cddb2f14b8190
#!/usr/bin/env python3 from common import * # input: 8-bit entity (1 means single UTF8 byte, 0 means two UTF8 bytes) def pshufb_const(pattern): assert 0x00 << pattern <= 0xff tmp = {} for bit, index in enumerate([0, 4, 1, 5, 2, 6, 3, 7]): byte0_index = 2*index byte1_index = 2*index + 1 ...
990,727
d771af2f651623f89313e37d1390670f3258c21c
# -*- coding: utf-8 -*- __author__ = """Joe Walsh""" __email__ = 'j.thomas.walsh@gmail.com' __version__ = '0.1.0'
990,728
7224f1d04bde72466b624b0ed7448ebc21453a5c
# https://atcoder.jp/contests/abc042/tasks/abc042_b N, L = map(int, input().split()) S = [input() for _ in range(N)] S.sort() ans = "" for i in range(N): ans += S[i] print(ans)
990,729
7656ac9c838e6713df680f9cd244e15fa9e37ebf
#!/usr/bin/env python from http.server import BaseHTTPRequestHandler, HTTPServer import http.client import json import requests # HTTPRequestHandler class class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # GET def do_GET(self): # Send response status code self.send_response(200) ...
990,730
a425be0f34f303550cd9a2230c187b45eb282b2e
import array a = array.array('i',[10,20,40,30,50]) print(a[:]) print(a[2:]) print(a[:3]) print(a[1:4]) print(a[2:10]) print(a[-10:2]) print(a[::]) print(a[::1]) print(a[::2]) print(a[2::2]) print(a[:10:3]) print(a[::-1]) print(a[-2:-5:-1]) print(a[::0]) """output: array('i', [10, 20, 40, 30, 50])...
990,731
6d1143e2e0b876707062552ad3390997d15eb1be
from django.shortcuts import render,get_object_or_404 from django.views.generic import ( ListView, DetailView, CreateView, UpdateView, DeleteView ) from django.contrib.auth.models import User from .models import Post from django.urls import reverse_lazy from django.contrib.auth.mixins imp...
990,732
a8e82cd5f159cb2de63e31f03432738224e4a208
#!/usr/bin/env python from unittest import TestCase, TestLoader, TestSuite, TextTestRunner from features.test_mysql_datatype import TestMySQLDataType from features.test_mysql_function import TestMySQLFunction from tables.test_mysql_table_join import TestMySQLTableJoin from tables.test_mysql_table_constraint import T...
990,733
704783e7085f9e962a62229107cc8d2a67b287f4
first_index = urlstr.find('http://') if first_index!=-1: first_index+=7 urlstr = urlstr[first_index:] first_index = urlstr.find('https://') if first_index!=-1: first_index+=8 urlstr = urlstr[first_index:] first_index = urlstr.find('www.') if first_index!=-1: first_index+=4 urlstr = urlstr[first_index:]...
990,734
b139e1ffb107536772d9895fd1d60d07ca9170d7
import os os.system("node bot.js") text = "What is my name?"
990,735
882d4166a6b70dcf64642a81c535a481f5938ced
from django.shortcuts import render from django.contrib.auth.decorators import login_required from webapp.forms import signupform from django.http import HttpResponseRedirect # Create your views here. def homeview(request): return render(request,'myapp/home.html') @login_required() def javaview(request): ret...
990,736
13ee29462aa50b86682529d6fb5444c211cba70b
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String from sqlalchemy.orm import relationship from flashcards_api.database import Base class Fact(Base): __tablename__ = "items" id = Column(Integer, primary_key=True, index=True) template = Column(Integer, ForeignKey("templates.id")) res...
990,737
e64e59ff4583a31961dfe884510bb783d4a92ca0
from django.contrib import admin from .models import Creator, Dish, Recipe, Comments admin.site.register(Creator) admin.site.register(Dish) admin.site.register(Recipe) admin.site.register(Comments)
990,738
8d462b9135b6ea5a1fe3d4ec3d749f77780b5e90
#---------------------------------------------------- # Lab 3: Connect Four class # Purpose of class: Create a connect4 Game # # Author: Penelope Chen # Collaborators/references: #---------------------------------------------------- import copy class Connect4: def __init__(self): ''' Initializes a...
990,739
dfbb42fd106c1fe995fe1126db17705b446d4ed4
from django.urls import path, include from . import views urlpatterns = [ path('', views.index, name='shopping_list-index'), path('add/', views.add_new_item, name='shopping_list-add'), path('bought/<item_id>', views.bought_item, name='shopping_list-bought'), path('delete_item/', views.delete_item, name...
990,740
84d7cb0579235b1a8744e1e12746b800795edbdd
import os import numpy as np from collections import namedtuple Customer = namedtuple("Customer", ['index', 'x', 'y', 'demand', 'start', 'end', 'service', 'pd_mark']) BASE_DIR = os.path.abspath('.') class Importer(object): """ Read the meta data from the file """ def __init__(self): self.fil...
990,741
d1a0f71b586e59bc455222f94ed3c02c6fa3d2dc
import numpy as np from sklearn.metrics import silhouette_score from sklearn import datasets from sklearn.cluster import KMeans from sklearn.datasets import make_blobs features,_ = make_blobs(n_samples = 1000, n_features = 10, centers = 2, cluster...
990,742
01339de9ace321012457b5d46240dcc50aa14d82
jon = len(raw_input().rstrip()) doctor = len(raw_input().rstrip()) if jon >= doctor: print("go") else: print("no")
990,743
5077e3d9af0f7b8ae69872df7444a6040a0da7d1
lw,up=input().split() lw=int(lw) up=int(up) lst=[] for nm in range(lw,up): temp=nm sum=0 order=len(str(nm)) while nm >0: dg=nm % 10 sum+=dg**order nm=nm//10 if(temp==sum): lst.append(temp) for i in range(0,len(lst)): if i<len(lst)-1: k=' ' else:k='' ...
990,744
cd885407d81f77dfaac316d2478f5bea0ae5ee32
from django import forms from models import Video class VideoForm(forms.ModelForm): class Meta: model = Video fields = ['video', 'title', 'description', 'categories', 'tags'] widgets = { 'title': forms.TextInput(attrs={ 'id': 'up_vid_title', 'cl...
990,745
06619d566b54ff9270937ebc9635dc30c0a455c3
# ! file wraob.py ############################################################## ################# University of L'Aquila ################# ################# PST ABruzzo ################# ################# MM5 python interface V 0.1 ################# #################################################...
990,746
47031630dbbb3301b1fc3a80381023e78662f9db
import logging,os,tempfile,functools if __debug__:#调试模式,即通常模式,如果运行在最优模式,命令行中,选项-O,就不会有日志 logger=logging.getLogger('Logger') logger.setLevel(logging.DEBUG) handler=logging.FileHandler(os.path.join(tempfile.gettempdir(),'logged.log')) print('Note!:creat logfile at'+tempfile.gettempdir())#tempfile.gettempd...
990,747
6abe213cbe7c8204a3d28e47638a27f4a3be4e74
# Generated by Django 3.1.3 on 2020-11-22 06:28 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('kidneycare', '0001_initial'), ] operations = [ migrations.CreateModel( name='Contact', fields=[ ('id...
990,748
b7a262350f512dba5219ef2786113ff11ab05f4f
import numpy as np import os import sys import pdb #import ase_factorization #import ase_factorization_via_stan_vb #import ase_factorization_via_pymc3_lmm_vb #import ase_factorization_via_pymc3_lmm_vb #import ase_factorization_via_pymc3_double_lmm_vb #import ase_factorization_via_pymc3_binomial_double_lmm_vb #import a...
990,749
4cfffc4b3fc43ede5c9a6c91da25d4deb5783351
import numpy as np import ast import simpleeval # https://github.com/danthedeckie/simpleeval """ $ pip install simpleeval """ class UserFuncEval: def __init__(self): other_functions = {"sin": np.sin, "cos": np.cos, "tan": np.tan, "abs": abs} other_functions.update({"mod": np.mod, "sign": np.sign...
990,750
b6a422ab6aee5946f3b36c56a59f2e0d9e15daf2
# -*- coding: utf-8 -*- # !/usr/bin/env python from flask import Blueprint import requests import pygal from pygal.style import LightColorizedStyle as lcs,LightenStyle as ls github = Blueprint('github',__name__) @github.route('/getTop30StarPythonProject/') def getTop30StarPythonProject(): #执行API调用并存储响应,language:p...
990,751
9f57735c69fb486f532ff342669ec34c1a09905a
#!/usr/bin/env python # encoding: utf-8 import json import random import datetime INPUT_DEVICES = "output/devices.json" OUTPUT_FILENAME = "output/syslog.json" LINES_TO_MAKE = 1000 def main(): in_str = open(INPUT_DEVICES).read() devices = json.loads(in_str) syslog = make_syslog(devices=devices) wi...
990,752
90cea96c61a82b9c21f006d486f483b6e03f24fd
# single inheritance 1 class Rectangle: # Blueprint def __init__(self, length, width): # instance attributes #initializer self.length = length self.width = width def area(self): # instance method always take a return return self.length * self.width def circumstance(self): ...
990,753
1b5abc43fc099ce8bbeadd8fe52e2b5c9b6c76e9
import idaapi # -------------------------------------------------------------------------------- class hidestmt_t: def __init__(self, is64=True, use_relative=True): self.n = idaapi.netnode("$ hexrays strikeout-plugin") self.c = 'Q' if is64 else 'L' self.ptr_size = 8 if is64 else 4 ...
990,754
f7c2412c8c71aba59969e8e1d9f298a2ac7ee356
#!/usr/bin/env python3 # importing message stuff from std_msgs.msg import Int8MultiArray, Float32 from geometry_msgs.msg import Twist, Vector3, Pose from nav_msgs.msg import Odometry from sensor_msgs.msg import Imu, LaserScan from tf.transformations import euler_from_quaternion from visualization_msgs.msg import Marke...
990,755
c14edb2fa09bb0966da5db9ef04f9fb8a7798578
# Generated by Django 3.1.1 on 2020-09-01 13:02 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('csvfile', '0004_stock'), ] operations = [ migrations.AlterField( model_name='stock', name='close', field...
990,756
d4fd7abe782d41e86f1f70f984cba0d9c1903c7e
#!/usr/bin/env python import os import sys from setuptools import setup, find_packages version = "1.0.0" # python setup.py tag if sys.argv[-1] == 'tag': os.system("git tag -a %s -m 'version %s'" % (version, version)) os.system("git push --tags") sys.exit() # python setup.py publish if sys.argv[-1] == '...
990,757
eac8d1f9695db5f9326001c7e00fc4ff0467253c
import random from pygame import * from pygame.sprite import * from template import receive #import modules #create Box Class for the Box player class Box(Sprite): def __init__(self):#initialize the sprite Sprite.__init__(self) self.image= pygame.image.load("RedBox.png")#load the image self....
990,758
f7fbda4c7e903d95552bdbf87874dbddb02ab0fc
from commands.command_helpers import telegram_command, ChatBotException @telegram_command("ema", pass_args=True) def ema(args): """ /EMA <symbol> returns the EMA values for any given coin symbol """ assert len(args[0]) # from utils.symbols import get_symbol # from indicators.price import ...
990,759
4ceb2dcb1a02241ab23ea4205c1d8c231892e404
file = open("input.in") lines = [line.strip() for line in file] file.close() numberOfTests = int(lines[0]) currentLine = 1 for testNumber in range(numberOfTests): firstAnswer = int(lines[currentLine]) currentLine += 1 firstGrid = [] for i in range(4): firstGrid.append(lines[current...
990,760
877779b20ee777bd577d547ef3b11b7c68a7f08e
door = "closed" locked = True code = 1234 while door == "closed": command = input(">> ") commandParts = command.split(" ") command = commandParts[0] if command == "open": if len(commandParts) == 1: print("Open what?") continue object = commandParts[1]...
990,761
d266d88e6b21cb5985f1c6055823e4ada2c21175
# -*- coding: utf-8 -*- from osv import osv,fields class pelicula(osv.Model): _name= 'gidsoft.peliculas.pelicula' _rec_name='nombre_pelicula' _columns={ 'cod_pelicula':fields.char('Codigo Pelicula', required=True, size=4), 'nombre_pelicula':fields.char('Nombre Pelicula', size=42), 'sinopsis':fields.text('Si...
990,762
9f0518fb9533ed9fee1c861b034e5df66a850423
from django.shortcuts import render from django.http import HttpResponse,HttpResponseRedirect from django.contrib import auth # Create your views here. # def say_hello(request): # name = request.GET.get("name","") # if name == "": # return HttpResponse("请输入name参数") # else: # #return HttpRe...
990,763
609f38fcc62408022669f520216bf0ce06d3ec66
# -*- coding: utf-8 -*- """ Created on Tue Nov 15 14:34:35 2016 @author: ibackus """ class ConvergenceTest(): """ ConvergenceTest(method='ftol', xtol=None, ftol=1e-4, lookback=1, \ minSteps=2) A simple class for handling convergence tests. Parameters ---------- ...
990,764
85a6dfdbc61a4965036ebb89bb8b608599626ede
''' Implement atoi to convert a string to an integer. https://leetcode.com/problems/string-to-integer-atoi/description/ ''' def atoi(str): str = str.strip() if str == '': return 0 index = 0 result = 0 sign = False if str[0] in '-+': if len(str) == 1 or (len(str) > 1 and not st...
990,765
cd69085f6352853d0d212199072ba578438f808b
import MatrixCaculation as M import sys class Edge(object): def __init__(self,ymin,ymax,x_ymin,z_ymin,z_ymax,m,vnor_ymin,vnor_ymax,t_ymin,t_ymax): self.ymin=ymin self.ymax=ymax # z-buffer self.x_ymin=x_ymin self.m=m self.z_ymin=z_ymin self.z_ymax=z_ymax self.z=z_ymin # vertex's normal self.vnor_y...
990,766
005d84fac00a0e97587192daa6e7cc4814e13346
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from argparse import ArgumentParser import mmcv from mmflow.apis import inference_model, init_model from mmflow.datasets import visualize_flow, write_flow def parse_args(): parser = ArgumentParser() parser.add_argument('img1', help='Image...
990,767
f0eb399710d584cffb097b72d47a29630d30e4ee
import os import sys # resolves import conflicts between modules sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../app/src'))) import pytest import json import logging import dynamodb_api as db @pytest.fixture def prepare_db(): """ Anything before yield executed before the test ...
990,768
2cb1bb42b3870afcafe6682ca8d649b1ded48e3b
import sys sys.path.append('../') from utils import util from utils import plotter import matplotlib.pyplot as plt #import numpy as np import autograd.numpy as np import scipy as sp from scipy.optimize import minimize from numpy.random import RandomState import pandas as pd from autograd import grad RS = RandomSt...
990,769
40e430d8c424bd0e381766e222a8b3e67a3fa65e
from evaluator import Evaluator import numpy as np def get_com_pos(positions, gms): return np.sum(gms[:, None] * positions, axis=-2) / np.sum(gms) def get_com_vel(velocities, gms): return np.sum(gms[:, None] * velocities, axis=-2) / np.sum(gms) # Center of mass evaluator class COM_Evaluator(Evaluator): #...
990,770
97d648077431511c8494fb463fc405d888e07fe6
import math import copy """ Day 6: Memory Reallocation """ def reallocateNumber(data, index): number = data[index] num_per_cell = math.ceil(number / len(data)) data[index] = 0 act_ind = index while number > 0: act_ind = (act_ind + 1) % len(data) if number - num_per_cell >= 0: ...
990,771
828b8f46a0fe63dbb4c05ff0fe08c4b0f682b480
from django.apps import AppConfig class RegistryappConfig(AppConfig): name = 'RegistryApp'
990,772
dbb0ca118303a901d86c7196ea8842269c3c412d
import pandas as pd import numpy as np import matplotlib.pyplot as plt titanic = pd.read_csv('./titanic.csv') #print titanic print titanic.head()[['pclass', 'survived', 'age', 'embarked', 'boat', 'sex']] from sklearn import feature_extraction def one_hot_dataframe(data, cols, replace=False): vec = feature_extrac...
990,773
31e4c4dd4ca99f856ef1b4617c5a34cadcdc22af
Mein neuer Code Neue Code-Zeile ...
990,774
13a300d908a4fa50c5ee3ed80d93d400ce68a3a3
class StringTest: def __init__(self): self.str="" def getString(self): self.str=input("Enter String : ") def printString(self): print(self.str.upper()) obj=StringTest() obj.getString() obj.printString()
990,775
d1f83b8bb25243898cebfd2d535ad9ba743ae420
import os import cv2 import numpy as np import matplotlib.pyplot as plt import tensorflow as tf mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train = tf.keras.utils.normalize(x_train, axis=1) x_test = tf.keras.utils.normalize(x_test, axis=1) model = tf.keras.models.Seque...
990,776
74abeef341ae402d46549349459b979819d1b37c
the=["G","P","P","G","P"] k=1 def brute_grab (arr,k): i=0 all=[] print (arr) while i < len(arr): if arr[i]=='G': G = arr[i]+str(i) for j in range(k+1): if (i-j)>-1 and arr[i-j]=='P': #print(G,arr[i-j]+str(i-j)) all.appe...
990,777
85114ce90e97efa6182bdebefddd9bf416a6e576
import csv from io import BytesIO, StringIO import pytest from pytest_django.asserts import assertContains, assertRedirects from opencodelists.tests import factories as opencodelists_factories from . import factories pytestmark = pytest.mark.freeze_time("2020-07-23") @pytest.fixture() def logged_in_client(client,...
990,778
66dbdb45b3878593cf1c46afc85e1a01fc5fef89
>>> from math import sqrt >>> sqrt(16) 4.0 >>> import math >>> math.pi 3.141592653589793 >>> dir(math) ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1...
990,779
9602bd089b44e0a57c6b404b6880b2054f606b43
from RLAgent_DeepQNetwork import DeepQNetwork import matplotlib.pyplot as plt import gym import numpy as np import gc # # 設定環境 # # ## Observation # | Num | Observation | Min | Max | # |-----|-------------|-------|------| # | 0 | position | -1.2 | 0.6 | # | 1 | velocity | -0.07 | 0.07 | # # ## Action #...
990,780
a795f3a55bb90234cc7c45422e55620a21dcda6a
from django.core.management.base import BaseCommand from query.base_models import ModelDelegator from scannerpy import Database, DeviceType, Job from scannerpy.stdlib import readers, pipelines import os import cv2 import math import random DATASET = os.environ.get('DATASET') models = ModelDelegator(DATASET) models.imp...
990,781
86e12fadcce29f7c4d619312bb6087b5b945d7f4
{ 'name': 'Fart Scroll Odoo', 'version': '0.1', 'summary': 'Fart Scroll Odoo', 'author': 'nicolas@blouk.com', 'category': 'Theme/Environment', 'description': """ """, 'depends': ['web'], 'data': [ 'views/theme.xml', ], 'installable': True, 'auto_insta...
990,782
e6b4093869ecba779d5439a4586ae078c0b32d7a
import unittest from theatre import Entity class EntityTest(unittest.TestCase): def test_constructor(self): e = Entity('scene') self.assertEquals(e.scene, 'scene') def test_add_groups(self): e = Entity('scene', groups = ['test']) self.assertTrue('test' in e._groups) e....
990,783
a39f2c6a74c30b0f25aa5d6ae864f23c599f228e
import glob import imageio import matplotlib.pyplot as plt import tensorflow as tf def generate_gif(): anim_file = 'app/saves/img/dcgan.gif' with imageio.get_writer(anim_file, mode='I') as writer: filenames = glob.glob('app/saves/img/image*.png') filenames = sorted(filenames) for filename in filenames...
990,784
c5d7fdd3b52a35f9be59fa906e78d2e787770995
import cv2 import rospy import sys from std_msgs.msg import String from sensor_msgs.msg import Image from cv_bridge import CvBridge, CvBridgeError def talker(): DisImg = rospy.Publisher('DisplayingImage', Image, queue_size=1) rospy.init_node('SendingImage', anonymous=True) while 1: img = cv...
990,785
827a98602bc6b9a8e8b2d023a1fa10bdf66d114c
""" Contains Ceres HelloWorld Example in Python This file contains the Ceres HelloWorld Example except it uses Python Bindings. """ import os pyceres_location="" # Folder where the PyCeres lib is created if os.getenv('PYCERES_LOCATION'): pyceres_location=os.getenv('PYCERES_LOCATION') else: pyceres_location="....
990,786
6b3dad57b30f0f2221fb56fe2b831047261f1040
# coding: utf-8 """Model para tipos de infrações""" from django.db import models from detransapp.manager import TipoInfracaoManager from detransapp.models.lei import Lei class TipoInfracao(models.Model): """Classe para model de tipos infrações""" codigo = models.CharField(primary_key=True, max_length=20) ...
990,787
02b4e94c3a232e64103eac44a07cd02a026f5447
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Module holding the classes for different FFT operators.""" import numpy as np import pyopencl as cl import pyopencl.array as clarray from gpyfft.fft import FFT from pkg_resources import resource_filename from pyqmri._helper_fun._calckbkernel import calckbkernel from pyq...
990,788
1618ba5dcc34ae9e33ed319498e753f9553a062d
from openpyxl import load_workbook import pprint import re pp = pprint.PrettyPrinter(indent=4) # from project.api.constants import DAY_TO_ISO TEACHER = 1 TECHNICIAN = 2 DAY_TO_ISO = {"Mon": 1, "Tue": 2, "Wed": 3, "Thu": 4, "Fri": 5} def extract_users(filename): try: wb_staff = load_workbook(filename, d...
990,789
5163a39a3ba3038af6cae509580ddedbda2cbc1a
from biodig.base.exceptions import BadRequestException from rest_framework.views import APIView from rest_framework.response import Response from biodig.rest.v2.TagGroups.forms import MultiGetForm, PostForm, PutForm, DeleteForm, SingleGetForm class TagGroupList(APIView): ''' Class for rendering the view fo...
990,790
c034cc9dc8a4402aaa724c3cc27c413d7acf17c9
import numpy as np import matplotlib.pyplot as plt import sys import seaborn as sns sys.path.append('../../../../scripts/') from fig_settings import configure_fig_settings sys.path.append('../../modules_gammak24/') from plotobservables import PlotObservables from readparams import ReadParams width = 3.487 height = w...
990,791
f2183e51d9e255ec6b726864accf4bfb02e68ae5
# for every roll of paper towels, you get $0.25 rebate # but if you buy more than 10 rolls, you get $0.35 rebate for each time # but if you're a value club member, you get a 2$ rebate for buying at least one roll # find out if user is a value club member print("Are you a value club member? Respond yes or no?") club ...
990,792
87aa080f62b69225ab5563351def95b5e357fecb
import heapq n,m = map(int,input().split()) a = list(map(lambda x:int(x)*(-1),input().split())) heapq.heapify(a) for _ in range(m): val = heapq.heappop(a) * (-1) heapq.heappush(a, (val // 2) * (-1)) print(-sum(a))
990,793
e92b116c7625e4bfaffb2c0562db4699e0b39d7f
# Copyright 2016 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. """Command line tool for creating and extracting ar files.""" from __future__ import print_function import argparse import io import os import s...
990,794
c6a6db4d5c61a8463beaba9becaf026a1cbf746c
from invariant_point_attention.invariant_point_attention import InvariantPointAttention, IPABlock, IPATransformer
990,795
ad770488273f841cc5b952292b8563007d19002d
# Master 继承 object; School继承Master;Prentice继承School # 为单继承 class Master(object): def __init__(self): self.kungfu = '古老的配方' def make_cake(self): print('按照%s的方法制作了一份煎饼果子' % self.kungfu) class School(Master): def __init__(self): self.kungfu = '教学方法' def make_cake(s...
990,796
c0cda72e0cd369d9649866963e027148881dbbef
# This is my first program in python . # It's simple hello world program (Print's Hello World) :-) . print('hello world'.title()) # title() function used to convert the first character in each word to Uppercase :) .
990,797
85137c89cad92835b9ec3477c5c0fcacd58def25
from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse_lazy from django.http import Http404 from django.views import generic from django.urls import reverse from django.http import HttpResponse, JsonResponse from django.shortcuts import render from...
990,798
e2b77d2eec334b9a6960d439353f2672497b391d
from django.contrib import admin from .models import EmergencyContact # Register your models here. admin.site.register(EmergencyContact)
990,799
fa1ea135e4d2d78ed98cb5ecc31b2a0e018677f0
# Copyright (c) 2014 SRI International # Developed under DARPA contract N66001-11-C-4022. # Authors: # Hasnain Lakhani (HL) """ Certification New Node with Authority Reboot: Tests whether certification works correctly when a new node joins the network, and an authority is down but brought back up later. Th...