index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
992,800
e2da27f305354eafc38d7172445d5dbab30d93c1
""" @Author: huuuuusy @GitHub: https://github.com/huuuuusy 系统: Ubuntu 18.04 IDE: VS Code 1.36 工具: python == 3.7.3 介绍: 函数科里化,参考《利用Python进行数据分析》3.2.5 """ # 科里化指通过部分参数应用方式从已有函数中衍生出新的函数 def add_number(x, y): return x+y # 方法一 add_five1 = lambda y : add_number(5, y) # 方法二 from functools import partial add_five2 = par...
992,801
654940c3d27394235438e2edf0b701eac6857428
#!/usr/local/bin/python3 from pprint import pprint import requests import json r = requests.get('https://api.sncf.com/v1/coverage/sncf/stop_areas', auth=('a930ee62-5850-42a7-9889-1a9851c1737d', '')) pprint(r.json())
992,802
efcc2feddc992d68eafab61469cce40e3b20d4fc
""" You are given a long line (a monospace font), and you have to break the line in order to respect a given width. Then you have to format the text according to the given style: aligh to left/right, center text or justify it. Lines of the output shouldn’t end with a whitespace. If you have to put 2 * n + 1 spaces arou...
992,803
c4ec44d3379021cf494f565f34c649ae81f9fea9
from agents import * from envs import * from utils import * from config import * from torch.multiprocessing import Pipe from tensorboardX import SummaryWriter import numpy as np import copy def main(): print({section: dict(config[section]) for section in config.sections()}) train_method = default_config['Tr...
992,804
006c469447c80c4ef302105faa9f516e688321eb
# Probability of obtaining Prime Numbers as product of values obtained by throwing N dices # Given an integer N denoting the number of dices, the task is to find the probability of the product of numbers appearing on the top faces of N thrown dices being a prime number. All N dices must be thrown simultaneously. # #...
992,805
885c5c7f6d2bc09108b85835025f42a3a7488e30
"""Jupyter server config.""" c.SimpleApp2.configD = "ConfigD from file" # type:ignore[name-defined]
992,806
a4e1f694e48f0d6013ff9b95f39926a540514cbd
# coding: utf-8 ''' 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 示例 1: 输入: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] 输出: [1,2,3,6,9,8,7,4,5] 解题思路: 1、将二维数组由外向内分成一圈圈 2、每圈拆分成上(从左往右)、右(从上往下)、下(从右往左)、左(从下往上)四条线,依次遍历 3、对每个圈重复第二步骤 ''' class Solution: def spiralOrder(self, matrix): result = [] ...
992,807
430c5674abd86784e0d25866f9cf8f311f6fa90b
from __future__ import unicode_literals from django.contrib.auth.models import User from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.encoding import python_2_unicode_compatible from plans.models import Buyer @python_2_unicode_compatib...
992,808
8926e295c1f7b6c43a8dd2735e18fad65ad4c5cd
# -*- coding: utf-8 -*- # Generated by Django 1.11.1 on 2017-06-14 15:20 from __future__ import unicode_literals from django.db import migrations import django.db.models.deletion import smart_selects.db_fields class Migration(migrations.Migration): dependencies = [ ('WebPortal', '0002_auto_20170614_0551...
992,809
9f4592a169bafab6eb2900c7df259effe4d41453
import sys class CountdownCache: def __init__(self, count=25): self.count = count self.__cache = {} def set(self, key, value, count=0): if count <= 0: count = self.count self.__cache[key] = {'value': value, 'count': count} def get(self, key): cached_pa...
992,810
9b84c12291d212876a7882aca266d932b783c85b
import requests from tkinter import * import tkinter.font as tfont from tkinter import messagebox # creates window of program root = Tk() root.geometry('400x500') root.config(bg='#222') root.title('Weather App') root.resizable(0, 0) # creating different font sizes font1 = tfont.Font(family='Helvetica', size=40) font2...
992,811
c7ff03ea068e6d52478d4c3ed41463c1b39a4ee4
from django import forms from sections.messaging.models import PrivateMessage class Compose(forms.ModelForm): class Meta: model = PrivateMessage fields =('subject','receiver','content',) class ReplyForm(forms.Form): content = forms.CharField(widget=forms.Textarea,required=True,label="")
992,812
2efa340af12cd8f57a22918e61d7e166c4257b15
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2013 Mellanox Technologies, Ltd # # 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 # #...
992,813
53a46bb5f07efe03c6cd81606d8ae08f33543e94
from math import sqrt import stats_batch as sb import numpy as np from pytest import approx from scipy.stats import ttest_ind_from_stats from scipy.stats import ttest_ind def test_batch_mean_var_t_test(): n = 10_000 a = np.random.normal(size=n) b = np.random.normal(size=n) # First batch # a ------...
992,814
e5f3d919ae885babb81ba6344c05d6790b660445
import demjson #flickr geojson is not quite valid json, suffers from trailing commas import sys from shapely.geometry import asShape import codecs #python parse_flickr.py /path/to/flickrShapeFile.geojson | psql gaztest #continents , counties, countries, localities, neighbourhoods, regions def parse_flickr_geojson(fli...
992,815
fa9ef1bb3a5b8d3f2518d1ae56ba4b7be06e6095
# Generated by Django 3.1.7 on 2021-04-05 10:54 from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('catalog', '0001_initial'), ] operations = [ migrations.CreateModel( ...
992,816
722067b239808da1f3a27b350c140f97b0fabf19
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import metrics from sklearn.model_selection import GridSearchCV from sklearn.metrics import classification_report from sklearn.metrics import confusion_matrix from collections import defaultdict from sklearn.metrics import * from sklear...
992,817
849abd7f16ce4f46ee684c458e2d0fb62c5083d6
from django.shortcuts import render from django.contrib.auth import authenticate, login, logout from django.contrib.auth.models import User from .models import Usuario, Proyecto, Tarea from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse from django.contrib.auth.decorators import l...
992,818
b1e996cd2eb3842bdbb15f99fe1bb23caf276160
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode: def depth(node): if not node: r...
992,819
5414a810f3469d426c275dba63f14a82826ef40a
import json import re import scrapy from locations.hours import OpeningHours from locations.items import Feature DAY_MAPPING = { "MONDAY": "Mo", "TUESDAY": "Tu", "WEDNESDAY": "We", "THURSDAY": "Th", "FRIDAY": "Fr", "SATURDAY": "Sa", "SUNDAY": "Su", } class QdobaSpider(scrapy.Spider): ...
992,820
22579eb5b80971f2c6b5fbcbefe970bbf6dc1564
def populate_board_with_example(board): board[5][5] = 1 board[5][6] = 1 board[5][7] = 1 board[5][8] = 0 board[5][9] = 1 board[6][5] = 1 board[6][6] = 0 board[6][7] = 0 board[6][8] = 0 board[6][9] = 0 board[7][5] = 0 board[7][6] = 0 board[7][7] = 0 board[7][8] = 1 ...
992,821
11d988c9599756718733a840c47b0029aa94427c
# coding=utf-8 from subzero.lib.dict import DictProxy from config import config class ExcludeDict(DictProxy): store = "ignore" # single item keys returned by helpers.items.getItems mapped to their parents translate_keys = { "section": "sections", "show": "series", "movie": "video...
992,822
dbaeec4daee87aa0f30819ca23fac01a335c840d
from time import clock import sys, os path = os.path.dirname(__file__).split('test')[0] sys.path.append(path + "lib/") import numpy as np from spectrum import Spectrum import matplotlib as mpl import matplotlib.pyplot as plt plt.style.use('fivezerosix') # import fits file and initialize stack # spectra_path = path + ...
992,823
6c8adf35cf0f0b34034fc942c8c889a797a28b0c
import sys import os import subprocess import math def run_command(command): p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) return iter(p.stdout.readline, b'') if __name__=="__main__": pr...
992,824
5f147d8c70d9f2a7df94b2f456d166b665565abf
#!/usr/bin/env python from . import config, logdir import logging import sys from multiprocessing import Process from rq import Queue, Connection, Worker from rq.worker import logger rqLoggerFileHandler = logging.FileHandler(logdir + "/worker.log") rqLoggerFileHandler.setFormatter(logging.Formatter( fmt='%(asctime...
992,825
62d9db3148f879fa2e4702515bd8c477d9dee838
# -*- coding: utf-8 -*- # Generated by Django 1.9 on 2016-01-05 20:24 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('tasks', '0011_auto_20160101_2208'), ] operations = [ migrations.AddField( ...
992,826
5087ee8eff13bd5b80ac9f67b581c167635e887f
# 3. Сформировать из введенного числа обратное по порядку # входящих в него цифр и вывести на экран. Например, если # введено число 3486, то надо вывести число 6843. # ссылка на блок-схему # https://drive.google.com/file/d/1Br7etzOCWARCVSA9do66tzF_1eg_xW-B/view?usp=sharing number = int(input('Введите натуральное числ...
992,827
2650e234399c19af09cd6c51c56e449916fd3356
from sklearn.tree import DecisionTreeClassifier from sklearn.datasets import load_iris iris = load_iris() features= iris.data labels = iris.target from sklearn.cross_validation import train_test_split X_train, X_test, Y_train, Y_test = train_test_split (features, labels, test_size =.3) clf = DecisionTreeClassifier(...
992,828
2b0dcf8e35ef0caa51f68ced0d67430654d8edfa
#!/usr/bin/python #created by Marquette REU team from os.path import isfile, join import time, os, sys, getopt from os import listdir #absolute path to the arduses folder where most of the files of the system are hosted mypath="/var/www/html/MUBlocklyDuino/ardusers/" def cleanHouse(argv): #default hours=0 minutes=0 ...
992,829
06844c296c806c31e2ed6c5737513c0e9bda1a56
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'chat.ui' # # Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets import os import urllib import urllib2 import json class Ui_Form(object): def setu...
992,830
515f0013e7938551b10b228d98d108a536e97641
from setuptools import setup def readme(): with open("README.md") as f: return f.read() setup(name="proto", version="0.1", description="Prototype project", author="Daisuke Kato", author_email="kato.daisuke429@gmail.com", license="MIT", packages=["proto"], zip_sa...
992,831
70f2cd702f01119646d32a621acc49fe59a48baa
def heapify(a, i, length): n = i le = 2 * i + 1 new_root_position = None if le < length -1: ri = 2 * i + 2 if a[le] >= a[ri] and a[le] > a[n]: swap(a, n, le) new_root_position = le if a[ri] > a[le] and a[ri] > a[n]: swap(a, n, ri) n...
992,832
e1805aefbd0a42d6a3299dc87ed967afe61979a4
#------------------------------------------------------------------------------- # Name: TestData.py # Purpose: model software licensing test data # # Author: wah # Created: 18/07/2014 #------------------------------------------------------------------------------- import json class TestData(objec...
992,833
410523634a042c0a8681ce34f87f315193333cba
# Copyright 2016 Autodesk Inc. # # 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 agreed to in writing...
992,834
0c5f8c3f8d8eeaf6d7d1ee51897e8691c03b6d08
import pygame from pygame.locals import * FPS = 30 # frames per second, the general speed of the program WINDOWWIDTH = 580 # size of window's width in pixels WINDOWHEIGHT = 480 # size of windows' height in pixels REVEALSPEED = 8 # speed boxes' sliding reveals and covers BOXSIZE = 20 # size of box height & width in pi...
992,835
43868b25f8a077c68ba206b0a4e30e5b5d41bc69
import unittest class Solution(object): def minMutation(self, start, end, bank): """ :type start: str :type end: str :type bank: List[str] :rtype: int """ from itertools import chain new = [start] seen = set([start]) ATCG = 'ATCG' ...
992,836
9310a5cd566dab20beb397a92c9ace6244aaa801
#!/bin/python3 print("""\033[1;36m @:::::::::@:@@@@@@@:@@@@@@@@@@:@:::::::@: @@:::::::@@:@:::::@:::::@::::;;@:::::::@: @:@:::::@:@:@:;:::@:::::@::::;:@:::::::@: @::@:::@::@:@:::::@:::::@::::;;@@@@@@@@@: @::;@:@:::@:@@@@@@@:::::@::::;;@;::::::@: @::::@::::@:@:::::@::;;;@:;::;;@:::::::@; @::::...
992,837
e757c41701055c463b936ee1cd8764b8fc4f4742
import decimal x = 23 / 1.05 print(x) print(23 / 105) print(decimal.Decimal(23)/decimal.Decimal("1.05"))
992,838
e44dbbd7733421dbe6b5e9e59bcd375bb80c2fba
fin = open('06_08_input.txt', 'r', encoding='utf8') a = 'a' mark_list = [] while len(a) > 0: a = fin.readline().strip() if a != '': mark_list.append(a.split()) mark_list.sort(key=lambda x: x[0]) # mark_list.pop() for name in mark_list: print(name[0], name[1], name[3])
992,839
2f3ceb94509644a9ed7177bff8e38096ee12341f
n,k=map(int,input().split()) n+=1 lis=[] for j in range(n,k): i=2 k=1 while(i<j): if(j%i==0): k=0 break else: i+=1 if(k==1): lis.append(j) for i in range(0,len(lis)): print(int(lis[i]),end=' ')
992,840
bda16c961eddaad70fa995576d0262ead36177ab
from pytube import YouTube yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') print(yt.streams.all()) # To list only audio streams: print(yt.streams.filter(only_audio=True).all()) # To list only mp4 streams: print(yt.streams.filter(subtype='mp4').all())
992,841
d7971663b9dd2b0e9a7325dc7d4633e9c498c150
#Discord ProtOS Bot # #Author: Jascha "fredi_68" Hirsekorn # #MegaHAL chatbot implementation host = "localhost" port = 50011 port2 = 50012 import os import sys import asyncio import subprocess import logging logging.basicConfig(level=logging.INFO) #set log level logger = logging.getLogger("MegaHAL") wd = "bin/mega...
992,842
4c2ba6ca396d1f463685783aedba6521752dd023
from django import forms class NameForm(forms.Form): search_text = forms.CharField(label='search_text', max_length=100)
992,843
1f0a8453b1e2cc113beb1db952ccf2452affe342
from model import connect_to_db from server import app, db if __name__ == "__main__": connect_to_db(app) db.create_all()
992,844
6f75268983f0096910955564bb629c23945241e5
def math1(a,b,c): pay = (a*b) / (1-((1+a)**(-c))) return pay def math2(a,b,c,d): remain = (b*(1-(1+a)**(d-c))) / (1-(1+a)**(-c)) return remain def principle(a,b): prin= (a-b) return prin def interest(a,b,c): intleft= (a)*(b)*((1/c)) return intleft def totalint(a,b): ...
992,845
50b7ecc7eda3803f24b584c1b99764e364d586cf
f_number = int(input()) s_number = int(input()) magic_number = int(input()) i = 0 match = False for x in range(f_number, s_number + 1): for y in range(f_number, s_number + 1): i += 1 if x + y == magic_number: print(f"Combination N:{i} ({x} + {y} = {magic_number})") match = T...
992,846
73a21a240a836ae3f31e19a0b57b42e6907ab702
# -*- coding: Utf-8 -*- import sys import random import math debug = True player = 1 NB_PODS = 3 WIDTH = 100 HEIGHT = 100 pods = [] walls = [] checkpoints = [] MAX_TRUST = 100 EXPO = 1.2 MAX_SPEED = 1000 MIN_SPEED = 1 def next_input_must_be(value): if input() != value: print("expected input was '",va...
992,847
55dbf87830aa8f3818f57fd0bc1fbe8c6bc21016
"""Add indexes for partial name matches Revision ID: 77ebcc9cf355 Revises: cdcb4018dd0e Create Date: 2022-06-04 10:40:48.710626 """ from alembic import op # revision identifiers, used by Alembic. revision = "77ebcc9cf355" down_revision = "cdcb4018dd0e" branch_labels = None depends_on = None def upgrade(): # in...
992,848
ca00f1d5494b01e7dda13589fbd7571dbd2fda4f
from dingtalkchatbot.chatbot import DingtalkChatbot class Ding: def __init__(self): self.webhook = "你自己钉钉机器人的webhook" def send_text(self, message): dingding = DingtalkChatbot(self.webhook) dingding.send_text(msg=message)
992,849
e045d484d954c8af8ff277371ec0572507c85736
from django.shortcuts import render, redirect from django.views import View from content.models import Post, ContentTag from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger class ContentDisplay(View): """Single post default view""" def get(self, request, content_id): post = Post.ob...
992,850
e12188e16ba55503df36cf0ec319bf46c5f48df0
# Created by Marcin "Cozoob" Kozub at 26.04.2021 11:45 from random import randint def tank_a(P, S, L): counter = 0 R = [] """ Na kazdej stacji tankujemy do pelna i jedziemy tak daleko jak damy rade Jezeli nasze optymalne rozwiazanie w pierwszym kroku nie jedzie tak daleko jak da rade, a...
992,851
c646704939a91e4b6295098301dbd5a70c66c874
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jul 28 23:22:35 2018 @author: chuxuan """ import sys class Solution: def maxProfit(prices): r=0 l=len(prices) if l<=1: return 0 start=[0]*(l+1) end=[0]*(l+1) i=l-1 maxp=prices[-1] ...
992,852
896aea09decdf97d9d58622ba9e53bc3db2d0764
import os import pickle import pandas as pd import numpy as np class Cardio(object): def __init__(self): #self.smt = pickle.load(smt, open("/home/jorge/repos/pa001_cardio_catch_diseases/parameter/smt.pkl", "rb")) self.scaler_ap_lo = pickle.load(open("/home/jorge/repos/pa001_cardio_cat...
992,853
403bbf59b0db7373fd1f5d58036f5c730028d45f
#!/usr/bin/python from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG def ubi(ubi, tab=''): print '%sUBI File' % tab print '%s---------------------' % tab print '\t%sMin I/O: %s' % (tab, ubi.min_io_size) print '\t%sLEB Size: %s' % (tab, ubi.leb_size) print '\t%s...
992,854
697b082776333cab44b8fcd565fcf933e27cf4e6
import cartadmin import clientadmin import orderadmin import productadmin
992,855
c96b4a7aa9a6a26ea4b8ac7e66afa828d9a5edfe
import requests from flask import Flask, request, send_from_directory, send_file, g from flask_cors import CORS import csv import logging import json import sqlite3 as sql app = Flask(__name__) CORS(app, resources=r'/*') DATABASE = "data/annotations.db" # This returns the database connection instance for the current ...
992,856
2ccf6282292dea6c0a09aabaab2d6cfd098722ee
def add(): a=input('enter the value') b=input('enter the value ') c=a+b return c
992,857
ed760c5ed68cca9bd8ca9f82721672d53b528537
import json import sys import os import calendar import requests from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS, cross_origin from sqlalchemy.exc import StatementError from datetime import datetime, timedelta app = Flask(__name__) app.config['SQLALCHEMY_...
992,858
65352eb7f9305c3f4fb946f7892592a9b8047438
import numpy as np import torch from networks import Generator, Discriminator, Downsampler CHANNELS = [16, 16, 32, 64, 128, 256] resume = 'exp/resume_official_train_5/epoch_44.pth' def random_latent_vectors(batch_size, latent_dim): return np.random.randn(batch_size, latent_dim, 1, 1) g = Generator(6, 32, CHANN...
992,859
8cb620d7f4733efd4ee852c56684bb2fda579a36
#!/usr/env/bin python3 """ Main utility for logging sensor data to database / regular picture uploads. """ import datetime import configparser from loguru import logger import os import time import uuid from adafruit_htu21d import HTU21D import board import busio import cowsay from dotenv import load_dotenv import p...
992,860
1c25024f83b989005b1fe235e4802e36fa7349ff
""" the Dynamic Host Configuration Protocol (DHCP) for IPv6 http://www.networksorcery.com/enp/rfc/rfc3315.txt """ from construct import * from ipv6 import Ipv6Address import six dhcp_option = Struct("dhcp_option", Enum(UBInt16("code"), OPTION_CLIENTID = 1, OPTION_SERVERID = 2, OPTION_IA_N...
992,861
4a7e165a2b81a4fc9f5bbcc3a44c69d855b4e3eb
K, C, A = input().split(' ') k = int(K) batik = [[C for i in range(k)]for j in range(k)] for x in range(k): batik[x][x] = A batik[k-1-x][x] = A for c in range(k): for d in range(k): if d == k-1: print(batik[c][d]) else: print(batik[c][d], en...
992,862
6b0deac33281e511f26ff049c8f5dc38d5ed5dd8
import pandas as pd import numpy as np import matplotlib.pyplot as plt dataset = pd.read_csv('/Users/savita/desktop/ML_proj/Simple_Linear_Regression/Salary_Data.csv') x= dataset.iloc[ : , 0].values y= dataset.iloc[ : , 1].values from sklearn.cross_validation import train_test_split x_train , y _train , x_test , y...
992,863
8b3d6e607d5f2e369a21f5d25beb2db3af4de2f9
#! /usr/bin/env python3 import pygame import matplotlib matplotlib.use ("Agg") import matplotlib.backends.backend_agg as agg import matplotlib.pyplot as plt from app import App from constants import ORIGIN # https://stackoverflow.com/questions/13714454/specifying-and-saving-a-figure-with-exact-size-in-pixels def p...
992,864
ac4040c65d2d7734eb987cc10ca4000dc3183434
from __future__ import annotations from typing import overload from prettyqt import animations, widgets from prettyqt.utils import listdelegators class StackedWidget(widgets.FrameMixin, widgets.QStackedWidget): """Widget containing stack of widgets where only one widget is visible at a time.""" def __init_...
992,865
bb6ff086e85cc1bb2a42f10025b8fd377f0b1b65
""" Main entry point of the ONMT library """ import onmt.inputters import onmt.encoders import onmt.decoders import onmt.models import onmt.utils import onmt.modules from onmt.trainer import Trainer
992,866
b321aae87bb8643ca7fcdab2f24ea06b08f2f059
import sys,re filename = sys.argv[1] Size=sys.argv[2] size=int(Size) lines = [] with open(filename) as f: lines = f.readlines() #read all lines for line in lines: line=line[:-1]+' ' #remove newline and add space at end spaces=[m.start() for m in re.finditer(' ', line)] #find spaces in the line cutline=[0...
992,867
143198f5d34236489f012f8482897bb5232f12eb
#!/usr/bin/env python """Test the RegisterOutputData class""" import sys import unittest from mock import patch, MagicMock as Mock from ILCDIRAC.Tests.Utilities.GeneralUtils import assertEqualsImproved, assertDiracFailsWith, \ assertMockCalls, assertDiracSucceedsWith from ILCDIRAC.Workflow.Modules.RegisterOutputDat...
992,868
1e9818366d8e4c67403d41c9f69a3c07babbec89
import argparse import numpy as np import PIL def get_parser(): parser = argparse.ArgumentParser() parser.add_argument('image_folder', help='path to images') parser.add_argument('annotations', help='path to annotations') parser.add_argument('boxes', help='path to bounding boxes') return parser def...
992,869
d766d0a955a397217c2c5394efee1536ce7e87c0
# -*- encoding: UTF-8 -*- from mongoengine import * import flask app=flask.Flask(__name__) app.secret_key = '123456' # #为了解决下面这个错误!!!!!! #The session is unavailable because no secret key was set. #Set the secret_key on the application to something unique and secret. # #用ORM操作数据库 connect('test') class User(Document...
992,870
bde8c51f0c1ec2b7d69893e7c507a9c115102f95
from __future__ import division import csv import sys import random from efficiency.log import fwrite def read_mr(): contents = [] for ix, pos_neg in enumerate(['neg', 'pos']): file = '../data/mr/rt-polarity.{}'.format(pos_neg) with open(file, 'rb') as f: contents += [[str(ix + 1),...
992,871
365ad46dddaf5761007a6439caf1a8d0128bda89
import sys from PyQt5.QtWidgets import * from PyQt5 import QtWidgets from PyQt5.QtGui import * from PyQt5 import QtGui import home_window from test2_question1_window import Test2_Question1_Window class Test2_StartWindow(QtWidgets.QMainWindow, QPushButton): def __init__(self, parent=None): super().__init__(...
992,872
450fada6104ed7776d214bf7c1a261b7706c45a0
#!/usr/bin/python3 import subprocess def connect_hint(): print("please do: \nsudo snap connect hwlog:time-control;sudo snap connect hwlog:hardware-observe") def system(command): return subprocess.check_output(command).decode('utf-8').strip() def hwlog_main(): print("uptime: {0}".format(system("uptime")))...
992,873
1f5e0ed58a95254a1bfcea8abde1a1eb4c6cc31e
# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html import os class GamecrawlPipeline(object): def process_item(self, item, spider): base_dir = os.getcwd() fo...
992,874
e65c20e0e232c55cf933f5e773d2bfbaa97285da
import tensorflow as tf from tensorflow.keras.layers import DenseFeatures, Dense from easyrec import blocks class DCN(tf.keras.models.Model): """ Deep & Cross Network (DCN). Reference: Ruoxi Wang et al. Deep & Cross Network for ad Click Predictions. ADKDD. 2017. """ def __init__(self, ...
992,875
4ca592e395498fbc3757a513d6a181a71ea89c0b
from django.contrib import admin from .models import TestInfo class TestInfoAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): if not change: obj.Uploader_info = request.user.username obj.save() admin.site.register(TestInfo, TestInfoAdmin)
992,876
4144342dc908fb6a18d26bedfe9f382dca52fd80
from django.db import models class Article(models.Model): nom = models.CharField(max_length=200) stock = models.PositiveIntegerField() def __str__(self): return 'Article: {}'.format(self.nom) class Vente(models.Model): article = models.ForeignKey(Article, on_delete=models.CASCADE) date ...
992,877
0cd16cc707882e858e48021e2b3d7172e050038c
import copy state = [] with open("Input.txt", "r") as f: line = f.readline() while line: state.append([i for i in line.replace("\n", "")]) line = f.readline() prev = [] while not state in prev: prev.append([copy.copy(i) for i in state]) for y in range(len(state)): for x in range(len(state[y])):...
992,878
82c910d355c57fd76638a0e271596592e1904452
from PIL import Image imga = Image.open('b.jpg') imgb = Image.open('c.jpg') Image.blend(imga,imgb,0.5).show()
992,879
3a584db2eb5e3d0ee8dc5323fd8040489ba261d5
from __future__ import absolute_import from __future__ import division from __future__ import print_function import six from tframe import tf from tframe.utils import checker from tframe.utils.arg_parser import Parser def relu(input_): if input_.dtype in [tf.complex64, tf.complex128]: with tf.name_scope("c_...
992,880
e8a19c435ea9a7dcf0170da2e00248adcf697ef0
def parse_binary(code): if len(code) == 0 or any([x not in ['0', '1'] for x in code]): raise ValueError return sum([2 ** i if x == '1' else 0 for i, x in zip(range(len(code)), reversed(code))])
992,881
850075d5b7d413117dbf98e7fb51c5947fbab2c3
"""""" # Standard library modules. import os import enum # Third party modules. import h5py # Local modules. import pymontecarlo from pymontecarlo.util.path import get_config_dir from pymontecarlo.util.signal import Signal from pymontecarlo.entity import EntityBase, EntryHDF5IOMixin # Globals and constants variable...
992,882
f9cef65415410192a57bdff7e3194183d93acb0f
from os import environ from flask import Flask, redirect, url_for, render_template, \ flash, session, request, jsonify from functools import wraps from forms import LoginForm, SignupForm, \ EmailResetPasswordForm, ResetPasswordForm, \ SearchForm from models import db, User, Search from flask_mail import Mai...
992,883
8366a4856468eb95335343e530ecdc375bd24eee
#lex_auth_0127136021907046401165 def find_upper_and_lower(sentence): #start writing your code here c=0 d=0 for i in sentence: if i.islower(): c+=1 elif i.isupper(): d+=1 result_list=[d,c] return result_list sentence="Come Here" print(fin...
992,884
f79a2238cd5bd687425251eb531565795c333120
import csv import matplotlib.pyplot as plt import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.svm import SVR from f_functions import * import sys sys.path.insert(0, '/home/ben/Documents/proj.0.1/f_functions') from f_functions import holder import pandas as pd ...
992,885
fe686285f2499f86abcfb683e8875d68f4ac495d
# -*- coding: utf-8 -*- # @author = himkt # @create = 2015/07/20 ''' 20. JSONデータの読み込み Wikipedia記事のJSONファイルを読み込み, 「イギリス」に関する記事本文を表示せよ. 問題21-29では,ここで抽出した記事本文に対して実行せよ. ''' import json w = open('../data/jawiki-country-uk.txt', 'w') for line in open('../data/jawiki-country.json', 'r'): record = json.loads(line) ...
992,886
f4b78ca5a795f8be355dd2642536c17a1cee5f50
import os import gym import numpy as np from gym import error, spaces, utils from gym.utils import seeding from ctypes import * import random import pybullet as p import time cwd_path = os.getcwd() ''' * in raisim the real value is in the first and py bullet its in the last * the end effector co - ordinates should be w...
992,887
bc9ee56a9c570d8e46fb2b8ba05a4b5994a2eed5
n = int(input()) a, b = map(list, input().split()) if len(a) == len(b): for i in range(0, len(a)): print(a[i] + b[i], end = "")
992,888
a26a16db12a3cc00dc1c371dbf53f1e53443e090
#!/usr/bin/env python3 from math import ceil, log2 import itertools UPDATE = 'U' QUERY = 'Q' def read_ints(): return [int(i) for i in input().split()] def read_int_arr(): return list(map(int, input().split())) def parse_query(line): op, x, y = line.split() return op, int(x), int(y) def read_input(): num_...
992,889
c2a2eaa5b90027ddd32e982a594090a9c69c4663
# Window - Preferences - PyDev - Interpreters - Python Interpreter - Forced builtins - new... - antlr4 # https://stackoverflow.com/questions/2112715/how-do-i-fix-pydev-undefined-variable-from-import-errors from antlr4 import * #@UnusedWildImport from ansonpy.JSONLexer import JSONLexer from ansonpy.JSONListener import ...
992,890
8729645f08ea4b66f647a3aabea7079d1ceda431
import os def loadRules(): print(os.listdir()) f = open('./Compiler/Strings/rules.ro', 'r') contentInArchive = f.readlines() lista = [] for i in contentInArchive: lista.append(i.rstrip()) return(lista) class StringProcessor(): def __init__(self, session): self.session = ses...
992,891
7955d2b163316f6018e1f76ae8bdad0d4a9d73ea
''' Created on March 12th, 2018 author: Julian Weisbord sources: description: ''' import sys from clothing.clothing_em import ClothingEM from body_type.body_type_classifier import BodyTypeClassifier from load_data import LoadData DEFAULT_LIVE_IMG_PATH = '../data_capture/live_input/imgs/' DEFAULT_INDIVIDUAL_IMG_PATH = ...
992,892
f4f7643a2b5d6870e64c23668727cf08df5b3065
import os import json import random from argparse import ArgumentParser sep = "#" def construct_p2v_dictionary(path_prefix): path_file_path = path_prefix + ".path" vectors_file_path = path_prefix + ".c2v.vectors" save_path = path_prefix + ".p2v.vectors" dic_file = open(path_file_path, 'r', encoding=...
992,893
877e523945186097eff743d6ea17da9533e18934
import functools import time import io import win32file import win32pipe import pywintypes import win32event import win32api cERROR_PIPE_BUSY = 0xe7 cSECURITY_SQOS_PRESENT = 0x100000 cSECURITY_ANONYMOUS = 0 MAXIMUM_RETRY_COUNT = 10 def check_closed(f): @functools.wraps(f) def wrapped(self, *args, **kwargs)...
992,894
5a8dd925ba10bcd000963271bf8787d00c030d77
from ugc.models import Post from like.models import Like, Likeable from django.db.models.signals import post_save, pre_save, pre_delete, post_delete from django.contrib.contenttypes.models import ContentType from django.db.models import Q from django.shortcuts import get_object_or_404 def recount_rating(num, post): ...
992,895
ef620d8bd409ebb11c52279d072989cc3cc58ccc
## This file will set up the database models and structure for the flask API to make calls to the database. ## This file will also be used to help with the data base migrations ## It serves the prupose for creating new data tables however data tables must be updated with the manage.py file. #from sqlalchemy import all ...
992,896
93bbf625dd0b6f9673437b891e6ce5b0ece1976f
import glob import os import csv from itertools import islice import math import regex as re2 # Pre-defined variables folder_path = 'Dataset' # Folder containing the datasets row_count = 6587830 # No. of Dialogues rate = 2785.5153203342757 # No. of entries read per second def char_preprocess(text): # Removing Pun...
992,897
971b845e4d90a1904e013e48bd61d6e0c165d2da
from django.http import HttpResponse from django.shortcuts import render def index(request): return render(request, 'index2.html') def analyze(request): mystring = request.POST.get('text') removepunc = request.POST.get('removepunc') charcount = request.POST.get('charcount') punctuations = '''!()...
992,898
d24f223e3a0a784c07287b3ec58a8e73b6ad3433
import os import pytest from basicRegex import basic_regex def test_short_regex_positive(): regex_string = ".*." check_string_pos = "ab" assert (basic_regex.regex(regex_string, check_string_pos)) def test_short_regex_negative(): regex_string = ".*." check_string_neg = "a" assert (not basic...
992,899
f136029d955443ce7290f84372d2125acc114c7a
import csv from django.core.management.base import CommandError from django.template.loader import get_template from django.template import Context from django.conf import settings from django.core import mail from django.contrib.auth.models import User from .. import auth def from_csv(filename, org_parent_or_ccg_m...