index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
14,400 | 49ebc9445040e93dbac8e7871f51cfd1c7c511a1 | print("Hello World from Leonela Comina /n ESPE /n GEO")
#imput variables
addend1 = imput("Enter The first number --> ")
addend2 = imput("Enter The second number --> ")
#add two numbers
sum= float(addend1) + (float(addend2)
# displaying the sum
print("the sum of the (0) and (1) is (2)". format(addend1, a... |
14,401 | 43c0f511c44ba5b901a7b011722a408329916716 | #anand python problem 4 3:4
# Write a program to print directory tree. The program should take path of a directory as argument and print all the files in it recursively as a tree.
import os
a='|--'
b='| '
c='\--'
def directory_tree(dire,v=0):
#print os.listdir(dire)
names=os.listdir(dire)
for i in names:
#pri... |
14,402 | 7eb3f9952b6d7aa1e658976f6949ea0a50adcee7 | import tkinter as tk
from responsechatbot import ChatbotResponse as cr
from posTag_spellCheck import check, pos_tagging
def show_entry_fields():
print("First Name: %s" % (e1.get()))
def insertContent():
reply = ""
cor = ""
#
try:
cor = checkSpelling()
print(cor... |
14,403 | 27fc2ece806720fa87e994230001d2a7a3c01c32 | import re
def parse(xml):
for element in re.findall('<\w*?>.*?</\w*?>', xml):
data = element.replace('>', '<').split('<')
if not data[1] == 'tokens':
yield(data[1], data[2].strip())
def unparse(data):
xml = ''
for element in data:
xml += '<{type}> {text} </{type}>\n'.fo... |
14,404 | 6834ecc52bf8cf497c0084ecc2fb7f3394444e1f | # Generated by Django 3.2 on 2021-05-05 19:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('acc', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='safety',
old_name='opertion_status',
n... |
14,405 | e42e70dea00d09b3732c8339c2188cea86bfca6d | import sys
import pandas
import argparse
from intervaltree import Interval, IntervalTree
class gitree(object):
def __init__(self, parameter_list):
pass
def build_from_bed(self, bedfile): |
14,406 | 545f6acbba781f76cc638dab68e67805da794c4c | #!/usr/bin/env python
import os
import sys
import socket
import gtk.glade
import cloudfiles
from config import CloudFilesGconf
from constants import GLADE_DIR
from show_container import ShowContainersList
CF_CONNECTION = None
USERNAME = None
API_KEY = None
class CheckUsernameKey(object):
"""
Check Username ... |
14,407 | 9b44e6048816465abfe8044aa0e1c74fdc08de26 | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import copy
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from ... import _u... |
14,408 | fa58a76929ebb6cedb4e453027d5c6c6da2af0d3 | import sys
import termios
import tty
import cv2
import numpy as np
from PIL import Image
from nes_py.wrappers import JoypadSpace
import gym_super_mario_bros
env = gym_super_mario_bros.make('SuperMarioBros-v2', apply_api_compatibility=True, render_mode="human")
MY_MARIO_MOVEMENT = [
['right', 'B'],
#['right'],... |
14,409 | 1d6c3c7f9106d62826651d5071def16427fbd034 | """Screening test questions for the Facebook Production Engineering Apprenticeship
role."""
# My Code:
# Complete the stickers_for function below.
def stickers_for(phrase):
"""returns number of 'instagram' stickers needed to make a phrase"""
stic_dict = {}
for ltr in 'instagram':
if ltr not in st... |
14,410 | 6918c586805d21fc3e11f90a8604c4fe7b7a03f8 | from ichnaea.models.content import (
decode_datamap_grid,
encode_datamap_grid,
DataMap,
RegionStat,
Stat,
StatKey,
)
from ichnaea.tests.base import (
DBTestCase,
TestCase,
)
from ichnaea import util
class TestDataMapCodec(TestCase):
def test_decode_datamap_grid(self):
self... |
14,411 | 2313bfe65cb87840251463fc943d2a425f797d08 | """Lambda that reads from a table and sends emails out for new music within the last 7 days. Invoked daily"""
# Standard library imports
import base64
import datetime
import json
import logging.config
import os
import traceback
# Third party library imports
import boto3
import requests
USER_FAVORITES_TABLE = boto3.r... |
14,412 | add34816606b6c5a629643610ff9c837e3f97158 | import ipaddress
import socket
from urllib.parse import urlparse
from django.shortcuts import reverse as django_reverse
from django.utils.translation import ugettext as _
from django.conf import settings
URL_TEMPLATE = "{scheme}://{domain}/{path}"
def build_url(path, scheme="http", domain="localhost"):
return UR... |
14,413 | 9ae5295a04a838a829a31ec1ddffd33c2e0c279c | from enum import Enum
import cv2
import numpy as np
from scipy.stats.stats import pearsonr
def get_bounds(x, y, descriptor_offset, search_offset):
# For descriptor blocks, search_offset should be 1
# This defines bounds of sliding window
top = y - int(descriptor_offset * search_offset) - 1
bottom = y ... |
14,414 | 8e91bba5053c114a34ba879aa9d207bf68849034 | # flake8: noqa
from . import history
|
14,415 | 80f0a2d25669bbd7d4f46ab38877f453d6ee267b | """
Utility functions for Brisera
"""
##########################################################################
## Imports
##########################################################################
import os
import time
##########################################################################
## Module Constants
#... |
14,416 | 870b8d97a1c2cf83d24ae15ad96ad7e8506d2050 |
# coding: utf-8
# In[4]:
import regex, os
# In[104]:
f1 = "37) Alfa 31. Bis.jpg" #folder 1
f2 = "38) Palmira. T. di Bel, temenos. 20 marzo '93. Bis.jpg" #folder 1
f3 = "149 Apamea. Alfa 31. Bis.jpg" # folder 2
f4 = "138 Apamea. 20 marzo '93 Bis.jpg"# folder 2
f5 = "148 Santuario San Simeone. Chiesa esterna. 20 ma... |
14,417 | 80b45e2772a277d953ded8dfbd05124883e83f33 | # Generated by Django 2.0.1 on 2018-02-08 13:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('catalog', '0049_auto_20180201_1259'),
]
operations = [
migrations.AddField(
model_name='tool',
name='pmneeded',
... |
14,418 | 6a6553098e8a23076fab8f4a3aba065dd5a214f8 | '''
Created on Feb 2, 2015
@author: daqing_yi
'''
from TrajectoryReader import *
from WorldMapMgr import *
import copy
import numpy as np
class HomotopyMgr(object):
def __init__(self, world_map, reader):
self.world_map = world_map
self.reader = reader
self.refStrPath = None... |
14,419 | 952863a616535d0e45b6567088bc301ccf584b05 | #set fileencoding=utf-8
"""
00. 文字列の逆順
文字列"stressed"の文字を逆に(末尾から先頭に向かって)並べた文字列を得よ.
"""
string="stressed" #逆順にする文字列
print (string[::-1])
###############################################
# rev="" #答えを入れる変数
# for i in reversed(range(len(string))):
# rev+=string[i]
# print rev
|
14,420 | 02976e22d4801ed89d58acb936bd2b5621d25ec9 | import os
from itertools import zip_longest
from string import ascii_lowercase
# Complete the makingAnagrams function below.
def makingAnagrams(s1, s2):
collection_1 = dict()
collection_2 = dict()
for i, j in zip_longest(s1, s2):
collection_1[i] = collection_1.get(i, 0) + 1
collection_2[j... |
14,421 | 79203fed3ec345f5036df0d75359bad7312c79a6 | """
Test cases for the core Models
"""
from django.test import TestCase
from core.models import Person, Story, CuratedStory, Gift
from common import LhrTests
class ModelTests(LhrTests):
"""
Test case for Models
"""
def setUp(self):
"""
"""
pass
def tearDown(self):
... |
14,422 | fa469e3ab126adbe7ce779f569852865ae7b6f7e | import trimesh
import numpy as np
class Camera():
# camera coordinates: y up, z forward, x right.
# consistent with blender definitions.
# res = [w,h]
def __init__(self):
self.position = np.array([1.6, 0, 0])
self.rx = np.array([0, 1, 0])
self.ry = np.array([0, 0, 1])
se... |
14,423 | 45e82b7ab8dad14b76a633d800a91ddb1ea4c867 | import numpy as np
import matplotlib.pyplot as plt
import cv2
image = cv2.imread("Assets/Demo.jpg")
#image[0:100,] = image[0:100, 50:100]
# Car Coords = # Car Coords = 142:220, 80:130
image[0:78, 0:50] = image[142:220, 80:130]
cv2.imshow("image", image)
# plt.imshow(image)
# plt.show()
cv2.waitKey(0)
cv2.destroy... |
14,424 | 8143e443c86cdcf853b8755c3ef95b670798a78a | import tkinter
from tkinter import messagebox
import string
import random
from ArbolBinario import ArbolBinario
from tkinter import *
class VentanaArbolAle:
def __init__(self):
def informacionNodo():
charNodo.set(text_nodo.get())
flag = arbol.buscarNodo(arbol.root, charNo... |
14,425 | e2f6c567c5ca47ddd9bcec2de64d1c6c596e9c54 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import os
from glob import glob
import sys
from datetime import datetime, timedelta
from collections import OrderedDict
import time
import settings
import queries
from utils import *
# --------------------------------------------------------------------------------
# списо... |
14,426 | 1f624b03b9f5f09f75ca7bd8d7ec1faf161b92ae | from flask import Flask, flash, render_template, redirect, url_for, request, session
from dao.DAOUsuario import DAOUsuario, DAOProducto, DAOCheckout, DAOLista
app = Flask(__name__)
app.secret_key = "mys3cr3tk3y"
db = DAOUsuario()
dbProducto = DAOProducto()
dbCheckout = DAOCheckout()
dbLista = DAOLista()
@app.rout... |
14,427 | ea3fd69e4d2b35a3d363a54fdea085ed78ed7b2f | from flask_login import login_required
from flask import flash,render_template,redirect, abort, url_for
from . import aboutt
from .forms import AboutForm
from .. import db
from ..models import about
@aboutt.route('/info',methods=['GET','POST'])
@login_required
def info():
result= about.query.all()
return ren... |
14,428 | f1a56ab35d5543615988f084bd703f22aa5cf941 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
forex_11 = pd.read_csv('FOREX_20180111.csv', sep=',', parse_dates=['Date'])
forex_12 = pd.read_csv('FOREX_20180112.csv', sep=',', parse_dates=['Date'])
time_format = '%d-%m-%Y'
forex = forex_11.append(forex_12, ignore_index=False)
forex['Date'] =... |
14,429 | 48db83d807b50519f3f6fddd84f478928bed0b0b | # db models for bolchal
import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.sql import func
db = SQLAlchemy()
# relationship between page and profile where profile is admin of page
admins = db.Table('admins', db.Column('page_id', db.Integer, db.ForeignKey('page.id', ondelete='... |
14,430 | f869c1bef7571f021c0c71cbcea95bffad84b8d2 | import json
import random
terrainlists = lambda : {"plains": [], "farm": [], "forest": [], "mountain": [], "waste": [], "swamp": [], "cave": [], "water": [], "deepwater": [], "coast": []}
class Random4Indies:
def __init__(self, rarechance, strength):
self.rarechance = rarechance
self.s... |
14,431 | f170a00182adff18819faba24c1994fbf68259a9 | import os
import math
import random
import datetime
import functools
from app.models import *
# from app import csrf
from hashlib import md5
from .forms import TaskForm
from app import api
from . import main
from flask_restful import Resource
from flask import jsonify # flask 封装后的json方法
from flask_sqlalch... |
14,432 | d4ad8019c7fbb870d45d97ec5c46e4213a2f88d8 | """
字典dict
练习:exercise01~03
"""
# 创建
dict01 = {10001: "金海", 10002: "铁林", 10003: "徐天"}
# 序列 --> 字典:一分为二
# dict02 = dict([(10001,"金海"), [10002, "铁林"], "徐天"])
list01 = [(10001, "金海"), (10002, "铁林"), (10003, "徐天")]
dict02 = dict(list01)
# 添加(字典不存在该key)
if 10004 not in dict01:
dict01[10004] = "田丹"
# 定位 根据key... |
14,433 | 422747bb20f1e8b65b0b37ec56937a7991630acc | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 02:20:27 2018
@author: keshav
"""
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 21 23:11:34 2018
@author: keshav
"""
import pyaudio
import wave
from array import array
#from matplotlib import pyplot as plt
FORMAT=pyaudio.paInt16
CHANNELS=2
RATE=... |
14,434 | cf739da1cde151bb00ae9b22026a5081d4a29580 | #!/usr/bin/env python
#
# Copyright 2007 Google 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 o... |
14,435 | da4b7154e3780c37ffbb5bb437216c71f30fc466 | #
# @lc app=leetcode id=494 lang=python3
#
# [494] Target Sum
#
# @lc code=start
class Solution:
def findTargetSumWays(self, nums: List[int], S: int) -> int:
dp = {0: 1}
for n in nums:
nxtDp = {}
for cur in dp:
nxtDp[cur + n] = nxtDp.get(cur + n, 0) + dp[cur... |
14,436 | a1cb98a5d7c83ef66b456e7b286ba72476420d62 | import heapq
from typing import List
class Solution:
def smallestRange(self, nums: List[List[int]]) -> List[int]:
# 核心思想--最小堆
# 在堆heap中放入每个列表的第一个元素,堆中元素的最大值和最小值,即为区间范围res
# 利用堆的性质,每次从堆中弹出最小的一个元素,
# 并将该元素所在列表的下一个元素存入堆中,因为由题可知,列表都是有序的,往下一个元素移动,res范围可能会变小
# 维护最大值与最小值... |
14,437 | c1bc79589f4eb9ee9c2590f74185f7db6cd37e04 | # programmers L2 : 소수 찾기
# solved by JY
# DATE : 2021.02.21
# 완전탐색, 순열
# 소수 구하는 방법 (시간복잡도는 O(√N))
# 약수들의 곱으로 봤을때 루트를 씌운 값이 중간값임
# 2에서부터 √N의 값까지 검색하면 이후의 값은 확인할 필요가 없음
import itertools
def find(num): # num이 소수이면 True 반환
i = 2
while i*i <= num:
if num % i == 0: # 나머지가 0이면 소수가 아님
return F... |
14,438 | a28df42234e7906f4c5c3409674a3694a955eb8e | '''
Created on 2015/11/25
@author: FZY
'''
#the baseline of mase of two vlaue is
'''
Created on 2015/11/4
@author: FZY
'''
import random
from sklearn.linear_model import Ridge,Lasso,LogisticRegression
from hyperopt import hp
import numpy as np
import pandas as pd
from hyperopt.pyll_utils import hyperopt_param
from... |
14,439 | 4920e8fb269de84db586cb789b72a9f48ba2d353 | import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
model = GPT2LMHeadModel.from_pretrained('gpt2')
prompt_text = input("text: ")
num_results = int(input("num results: "))
encoded_prompt = tokenizer.encode(prompt_text, add_special_tokens=False, retur... |
14,440 | 79b114cf58e7bb95ee1337d1c94b241d985c1dd4 | import sys
import mysql.connector
# Usage: $ python testMysql.py 'root' 'password'
# Validate arguments
if len(sys.argv)!=3:
print("USAGE: $ python testMYSql.py <user> <password>")
exit()
# Connect to database
print("1. Connecting to db...")
mydb = mysql.connector.connect(
port=3306,
user=sys.argv[1],
... |
14,441 | 8263f254c29b1e5ebea1315c2602f5b59fd8c6e6 | from app import cfg
from app import db
from app import util
from flask import Blueprint
from flask import jsonify
from flask import render_template
from flask import request
import math
bp_bans = Blueprint('bans', __name__)
@bp_bans.route("/bans")
def page_bans():
page = request.args.get('page', type=int, default=... |
14,442 | a2f99be0c94a4152dd6b028db82327d2ffba75f1 | '''
i/p:['five plus three', 'seven minus two', 'two plus eight minus five', 'eight divide four']
o/p:['eight', 'five', 'five', 'four']'''
list1=['five plus three', 'seven minus two', 'two plus eight minus five', 'eight divide four']
dict1={'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':... |
14,443 | 6aec0f87e9138a07fd3cc970564e39b8bfa66b15 | from copy import deepcopy
INPUT = """165
78
151
15
138
97
152
64
4
111
7
90
91
156
73
113
93
135
100
70
119
54
80
170
139
33
123
92
86
57
39
173
22
106
166
142
53
96
158
63
51
81
46
36
126
59
98
2
16
141
120
35
140
99
121
122
58
1
60
47
10
87
103
42
132
17
75
12
29
112
3
145
131
18
153
74
161
174
68
34
21
24
85
164
52... |
14,444 | 6a4e827de9ff591744cf6585d149a60712680f19 | from aylienapiclient import textapi
import api_access
client = textapi.Client(api_access.id, api_access.key)
url = "http://techcrunch.com/2015/04/06/john-oliver-just-changed-the-surveillance-reform-debate"
extract = client.Extract({"url": url, "best_image": True})
print(type(extract))
print(extract["title"])
|
14,445 | 9cbf2b076446c58351f84a81403de8c6d7d0aee8 | import time
localtime = time.localtime(time.time())
print("Local current time :", localtime)
from datetime import datetime
dt1 = datetime(year=2020, month=3, day=31)
print(dt1)
dt1 = datetime(year=2020, month=3, day=31, hour=21, minute=21, second=21)
print(dt1)
dt1 = datetime(2020, 3, 31)
print(dt1)
dt1 = datetim... |
14,446 | 47b6c95137869509c14152ea0d92125995a44bdd | # pymonome - library for interfacing with monome devices
#
# Copyright (c) 2011-2014 Artem Popov <artfwo@gmail.com>
#
# 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, incl... |
14,447 | f43fd29de45fb088f5ab751cdeccc60ef387a554 | import src.simple_arules.simple_arules as ar
transactions = [["bli", "bla", "blubb"], ["bla"]]
support_dictionaries_expected = [
{("bla",): 2, ("bli",): 1, ("blubb",): 1},
{("bla", "bli"): 1, ("bla", "blubb"): 1, ("bli", "blubb"): 1},
{("bla", "bli", "blubb"): 1},
]
association_rules_expected_7 = [
... |
14,448 | 71c99be60201d5df09cc695e73a7674466b09587 | from abc import ABC, abstractclassmethod
import pathlib
import imghdr
import os
from typing import Union, Tuple, List, Callable, Any, Dict
class dataLoaderABC(ABC):
@abstractclassmethod
def __init__(self, file_directory: Union[str, pathlib.Path, os.DirEntry], fileType: str='image'):
self.fileType = fil... |
14,449 | b715a9d7405765e6ab02d81248293f5d39a49efe | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_hypothesisapi
----------------------------------
Tests for `hypothesisapi` module.
"""
import unittest
from hypothesisapi import hypothesisapi
class TestHypothesisapi(unittest.TestCase):
def setUp(self):
pass
def test_something(self):
... |
14,450 | 027d4993312a1cd9f8c320f100e76622ae926deb | import numpy as np
from .strategy import Strategy
from sklearn.cluster import KMeans
from dataset.data import MoleculeDataset
class KMeansSampling(Strategy):
def query(self, n):
idxs_unlabeled = np.arange(self.n_pool)[~self.idxs_lb]
if self.args.data_pool is not None:
idxs_unlabeled = np.random.choice(idxs_u... |
14,451 | 464ba03f787a4b255a7c3b295bc75ec215aee4ae | # coding: utf-8
"""
tweak-api
Tweak API to integrate with all the Tweak services. You can find out more about Tweak at <a href='https://www.tweak.com'>https://www.tweak.com</a>, #tweak.
OpenAPI spec version: 1.0.8-beta.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
... |
14,452 | d3cd2f591dfd8cf8c4a4e3151270083edce94cac | from flask import Flask, request
import ml
import pandas as pd
import numpy as np
import json
from utils import allowed_file
app = Flask(__name__)
# data = pd.read_csv('DELL EMEA TEST DATASET.csv')
# df = pd.DataFrame(data)
# df["slow_dispatch"] = np.where(df["velocity"].astype('int64') >= 30, 1, 0)
# df = df.dropna(... |
14,453 | 60014a1371e938704aa59b4132ae5fd2dfe29f15 | from pymongo import MongoClient
import requests
import json
client = MongoClient("localhost", 27017)
URL_decrypt_dev = "http://10.0.5.4:8108/crypto/v1/decrypt?env=dev&orgname=hire&domain_name=scikey"
#URL_decrypt_qa = "http://10.0.4.4:8108/crypto/v1/decrypt?env=dev&orgname=hire&domain_name=scikey"
db = client.hire_s... |
14,454 | e0950ad92b2b39650b21215c9a5f0278ac62f4a1 | # Django
from django.apps import AppConfig
class ClassroomsAppConfig(AppConfig):
name = "asistance.classrooms"
verbose_name = "Classrooms" |
14,455 | abc8762a3aa2ae308c07327716fdf2fd4a98b98c | from flask import Flask, render_template, jsonify, request
app = Flask(__name__)
API_RESULTS = {
"Arby's": {"lng":-122.429763, "lat":37.680394},
"Hackbright":{"lng":-122.411540, "lat":37.788862},
"Barney's": {'lat': 37.8781148,'lng': -122.2693882}
}
@app.route("/")
def show_homepage():
"""show the i... |
14,456 | 380166d306e568505ab753eb5ec61a331f76ddb6 | """
Get a full absolute path a file
"""
import os
def full_path(file):
return os.path.abspath(os.path.expanduser(file))
|
14,457 | e289a5dbf3cd87ac61ed89c45775951c7caf65b1 | var1=3
var2=34
var3=112
newfile=open("storedata.txt","w")
newfile.write(str(var1)+"\n")
newfile.write(str(var2)+"\n")
newfile.write(str(var3)+"\n")
newfile.close()
s1=["david","John","sara","michael","lucy","Brian"]
newfile=open("dostoredata.txt","w")
for name in s1:
newfile.write(name+"\n")
newfile.close()
s1... |
14,458 | e6ddae835eb1ba4f32c4839d14e61042cc690040 | from DbConnector_MySQL import DbConnector_MySQL
from decouple import config
from tabulate import tabulate
from haversine import haversine
import datetime
import numpy as np
import pandas as pd
class QueryExecutor:
def __init__(self):
self.connection = DbConnector_MySQL()
self.db_connection = self.... |
14,459 | c4243cac20963cca5a097fe09fb8c2dd67268760 |
class FileSorter(unittest.TestCase):
def_sort_file(files):
|
14,460 | 93d2fbc99db7a8b42bfb120ab70e4ddc15c90a05 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 11 07:58:19 2020
@author: migue
"""
import pandas as pd
path_guardado = "C:/Users/migue/OneDrive/Documentos/EPN/Sexto Semestre/Desarrollo web con python/Github/py-reina-gamboa-miguel-esteban/04 - Pandas/data/artwork_data.pickle"
df = pd.read_pickle(path_guardado)
fi... |
14,461 | 1caef96820af02fdf1be4ca43d335d0ea2290699 | maximum = 0
def maxPathSum(self, A):
global maximum
if not A:
return 0
val = A.val + self.maxPathSum(A.left) + self.maxPathSum(A.right)
if val > maximum:
maximum = val
return maximum
|
14,462 | 9f3f402411600c9421a62369882cfb689d067748 | # -----------------------------------------------------------------------
#
# nir library v0.1.3
# ------------------
# (Newman, Ian R = nir)
# https://github.com/irnewman/nir
#
# This is a library of tools for the Cognitive Science Lab at the
# University of Saskatchewan. Please note that this is a work in progress
# ... |
14,463 | 9854a3bf9e56cee33a3baa260962236e7b0c808b | '''
# not used, no time yo.
This file stores constants and global configuration variables
'''
import pickle
# constants
MODELS_DIR = 'models/'
MAIN_RESULTS_DIR = 'results/'
ALL_RESULTS_FILE = MAIN_RESULTS_DIR + 'all_results.pkl'
# settable vars
hyperparams = {
'preprocessing': {},
"dataloader": {
"params": {
... |
14,464 | 07b651e2563358ec7008d52b10d44664c9bac4c4 | #!/bin/python
#*******************************************************************************
# @File's name : auto_test_command.py
# @Company : Light Co.
# @Author : Hung.Bui - Light's QC team
# @Revision : 1.0.0
# @Date : 16-August-2016
#****************************************... |
14,465 | d7c8e2d3f60377a7e92e8bff3245ad83f2ce729e | #!/usr/bin/env python3
# Written by mohlcyber v.0.1 (17.02.2021)
# based on a process name script will automatically launch MVISION EDR query
import sys
import getpass
import time
import requests
import logging
import json
from argparse import ArgumentParser, RawTextHelpFormatter
class EDR():
def __init__(self)... |
14,466 | 3dc30d2955955bb0a8cd588338d675d4bcace502 | #!/home/frappe/frappe-bench/env/bin/python
from __future__ import annotations
import argparse
import os
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any, List, cast
import boto3
import frappe
from frappe.utils.backups import BackupGenerator
if TYPE_CHECKING:
from mypy_boto3_s3.service_re... |
14,467 | bbdc30ed2dd590b2834f0a357208276590b6d71f | # This file is for param search (optimizing)
'''
'''
import numpy as np
import pandas as pd
import os, sys, csv
from progress.bar import Bar
# Implementation part of HW2
def myStrategy(pastData, currPrice, stockType, l, s, au, bl):
# stock-wise param config starts here
if stockType[0:3] == 'SPY':
w_l... |
14,468 | 5c537228c18656cc65e23fa28333de1769174c1c | import os
from PyQt5.QtCore import QTimer, pyqtSignal
from PyQt5.QtWidgets import QWidget
import Const
from QFlowLayout.ItemWidget import ItemWidget
from QFlowLayout.FlowLayout import FlowLayout
from QFlowLayout.SqlUtils import SqlUtils
Url = "http://v.qq.com/x/list/movie?pay=-1&offset={0}"
# 主演
Actor = '''<a href="{... |
14,469 | b7164164588a7a9c3a4fff3b932f0413341d8fe6 | import yfinance as yf
from datetime import datetime
class Yahoo(object):
@staticmethod
def history(stockCode, interval, startDate):
endDate = datetime.now().strftime('%Y-%m-%d')
stock = yf.Ticker(stockCode)
historyData = stock.history('max', interval, startDate, endDate,
auto_adjust = False)... |
14,470 | f2dd161dd33c5db71fe77acd33ba0fa13d8d68df | import json
import os.path
import firebase_admin
from firebase_admin import credentials, firestore
def main():
key_json = os.path.expanduser("~/.config/serviceAccountKey.json")
cred = credentials.Certificate(key_json)
firebase_admin.initialize_app(cred)
with open('data.json', 'r') as f:
item... |
14,471 | 10e5bfdb2a51c7907ad50fab8b0ec035db2515ea | from contextlib import contextmanager
import sys
import os
import os.path as path
import subprocess
import argparse
import json
import logging
import errno
import copy
import re
dependency_file = 'subprojects.quark'
freeze_file = 'freeze.quark'
logger = logging.getLogger(__name__)
catalog_cache = {}
catalog_urls_overr... |
14,472 | 96f1a08bb77bee81970cd9da4df0a7a2539a0846 | class Logger:
_TAG = "VectraTvOnlinePlugin"
_DEBUG = 'Debug'
_INFO = 'Info'
_WARNING = 'Warning'
_ERROR = 'Error'
def __init__(self, prefix):
self.prefix = prefix.replace('_', '') + '.py'
def i(self, message):
self.__log__(message, self._INFO)
def d(self, message):
... |
14,473 | 55d546806dca82abb54695c9bbb22ff0decb007e | # @Time : 2020/7/20 19:18
# @File : Deeplabv3plus
# @Email : dean0731@qq.com
# @Software : PyCharm
# @Desc : Deeplabv3plus + Xception
# 参考:https://github.com/bubbliiiing/Semantic-Segmentation/tree/master/deeplab_Xception/nets
# @History :
# 2020/7/20 Dean First Release
import tensorflow as tf
from ... |
14,474 | b9e4266519b95e5cdff676e4561f977c34db2ab0 | #!/usr/bin/python
import sys
import csv
import string
import os
import numpy as np
def calcGamesToCooperate(fname, label):
types = ["ABCD", "ABDC", "BACD", "BADC", "ABCxD","BACxD", "AxBCD", "AxBDC", "AxBCxD"]
numAgents = len(types)
#create and open all files
data = fname+label+"_rawData/"+label+"_combinedOve... |
14,475 | b7b0d863ce8ea91d0c5ea89b93c6f97e33108d81 | # Functions
"""
Functions give us the ability to make our programs much more powerful and clean
while also saving us time. We use functions is because of the ability to write once and call repeatedly.
Overview
• How to use functions and what they are
• Passing data around using parameters
• Returning data from functi... |
14,476 | 69ebbe69f5f7d982b4125eb1aa4784fce62ef173 | from dot import Dot
class Dots:
"""A collection of dots."""
def __init__(self, WIDTH, HEIGHT,
LEFT_VERT, RIGHT_VERT,
TOP_HORIZ, BOTTOM_HORIZ):
self.WIDTH = WIDTH
self.HEIGHT = HEIGHT
self.TH = TOP_HORIZ
self.BH = BOTTOM_HORIZ
self.LV =... |
14,477 | a42da82e4f13a061bf2588809ea5b41a03ae1c1a | import random
#Enemies top left coordinate is located
#and then we check if a rectangle can be made by these x,y
class Enemy1:
def __init__(self,matrix):
x=random.randrange(2,42,2)
y=random.randrange(4,80,4)
self.x=x
self.y=y
e=0
for k in range(0,2):
for l in range(0,4):
if matrix[x+k][y+l]=="X" or ... |
14,478 | 46db70c9076a2a1b68660847d5a828898b8c74fd | #!/usr/bin/python
def main():
heights = map(int, raw_input().strip().split(' '))
assert len(heights) == 26
word = str(raw_input().strip())
curr_height = 0
for c in word:
indice = ord(c) - 97
height = heights[indice]
if height > curr_height:
curr_height = he... |
14,479 | 15fc914f7ad25bc46eb0a2431067fb21f853904b | #Params object for mono_dram
class DramParams(object):
##Bookkeeping params
#Base output directory
out_dir = "/home/slundquist/mountData/ram/"
#Inner run directory
run_dir = out_dir + "/mono_dram/"
#Save parameters
save_period = 100000
#output plots directo... |
14,480 | 383a97a4d2803b4a5f970acc4691f6c59f362255 | from sqlalchemy import Column, Integer, String, Boolean
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy import create_engine
Base = declarative_base()
# Place your database schema code here
# Example code:
class Student(Base):
__tablen... |
14,481 | e47620f0637185999605b19204f479cde71587ed | # Ty Bergstrom
# remove_duplicates.py
# September 2020
# CSCE A401
# Software Engineering Project
# Input a dataset and find duplicates.
# Generate hashes for each image to find duplcate hashes.
# Important for ML projects because duplicates can cause bias, and you can get a lot of duplicates from scraping etc.
#
# py... |
14,482 | f2e8a7da050b44ddb2632ecf9783e2f4e00e0f40 | import os
p="E:\\办公资料\\python\\pythontest\\test.txt"
p1="E:\办公资料\python\pythontest\\test1.txt"
p2="D:\Log\\b.txt"
#打开文件逐行读取 先转成二进制
data=open(p,'rb')
s = data.readlines()
data.close()
#循环处理每一行
for lines in s:
decodedLine = lines.decode('utf8')
print(decodedLine.replace("\n",""))
writedata=open(p,'a',... |
14,483 | 44804eda1ee17336531c27f64a1aa208f4b0062c | rows = int(input('Digit the # of rows: '))
collums = int(input('Digit the # of collums: '))
def tiktaktoe(rows, collums):
if rows <= 30 and collums <= 108:
for r in range(1, rows+1):
if r % 2 != 0:
for c in range(1, collums+1):
if c < collums:
... |
14,484 | 79b7f000712698a2a1cdf1030ea2d66005b39a65 | from my_library.modules.seq2vec_encoders.weighted_boe_encoder import WeightedBagOfEmbeddingsEncoder |
14,485 | 34c515d0e7263037ae926a5ca2698f72ef5ef87a | """
This test will run for annotator_mixin.py
"""
import unittest
from lxml import etree
from xmodule.annotator_mixin import get_extension, get_instructions, html_to_text
class HelperFunctionTest(unittest.TestCase):
"""
Tests to ensure that the following helper functions work for the annotation tool
"... |
14,486 | af045f9620f87127e94e099ac4d02a09d30426ab | #
-
*
-
coding
:
utf
-
8
-
*
-
"
"
"
h2
/
events
~
~
~
~
~
~
~
~
~
Defines
Event
types
for
HTTP
/
2
.
Events
are
returned
by
the
H2
state
machine
to
allow
implementations
to
keep
track
of
events
triggered
by
receiving
data
.
Each
time
data
is
provided
to
the
H2
state
machine
it
processes
the
data
and
returns
a
list
of
... |
14,487 | 37329224c1ed4cb5cef3614fe3a1e2c303b893ba | #-*- coding:utf-8 -*-
###########################################################################################
# author: luu
# info: 获取查询信息,除icd、伤害、故障和评价信息
# Revision: 1.0
###########################################################################################
"""
功能说明: 获取查询信息,包含以下数据:
... |
14,488 | 7b5bb8bd9082dedcee68d25f4f595424d457cfb9 | import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
import numpy as np
from sklearn.cluster import KMeans
# generate 2-D dataset with four blobs.
from sklearn.datasets.samples_generator import make_blobs
X, y_true = make_blobs(n_samples = 500, centers = 4,
cluster_std = 0.40, random_st... |
14,489 | 1fddbd93f11efa9764877199935d77a4a26826d8 | # Copyright 2017-2019 EPAM Systems, Inc. (https://www.epam.com/)
#
# 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 appli... |
14,490 | 4a961ba5a2d087fd7487643522c1023b00bb6a5d | import jieba
from collections import defaultdict
def cut(s: str) -> list:
return jieba.cut(s)
word_map = defaultdict(list)
if __name__ == '__main__':
with open("zhwiki_pinyin.sc", encoding="utf-8") as f:
for line in f:
line = line.strip()
words = cut(line)
for wo... |
14,491 | e048c92df027293401af4db26df6944e4dc99974 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\Programming\Soundexy\Soundexy\GUI\DesignerFiles\Gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
... |
14,492 | 1c667813a814275e6accc1a39fb10c619e0658ad | # coding: utf-8
import tweepy
import json
import os
from datetime import datetime
import pandas as pd
import credentials.credentials_twitter as cred
class Twitter_Analysis:
""" copyright© 2019 — Luc Bertin - License MIT """
__consumer_key = cred.CONSUMER_KEY
__token = cred.TOKEN
__api = None
def ... |
14,493 | 1e2d818b6b30b51f6256f2ce55e34b4de360e93d | #!/usr/bin/env python
# -*- coding=utf-8 -*-
class DbTools:
# 数据库基类
def __init__(self, task):
self._host = task['dbhost']
self._port = task['dbport']
self._name = task['dbname']
self._user = task['dbuser']
self._pass = task['dbpass']
self._index_name = task['in... |
14,494 | 74dacb847802b87037e785bff3d020f4a6def5e1 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2018/10/21 21:13
# @Author : Administrator
# @Site :
# @File : Python练习实例8.py
# @Software: PyCharm
"""
题目:
输出 9*9 乘法口诀表
-----------------------------------------------------
思路:
分行与列考虑,共9行9列,i控制行,j控制列
--------------------------------------------... |
14,495 | 04008080ec9e22b6ba96d9f1b1c34947928c3408 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import jenkins
import time
import configparser
#配属文件信息(地址,登陆用户名,登陆token)
JKS_CONFIG = {
'jenkins_server_url': 'http://jks.pre.gomeplus.com:8787/jenkins',
'user_id': 'admin',
'api_token': '9d9fe1b771538d889550aa686d526ee2'
}
#实例化jenkins对象,连接远程的jenkins master serve... |
14,496 | 02e4e0fa118fe95635b1cd38797547f050e6d053 | # Prolog
# Author: David Yurek, Stanley McClister, Evan Whitmer
# Team 3
# Section: 012
# Nov. 1, 2013
# Lab 10 Team
def main():
too_high = False
too_low = False
for i in range(10):
number = float(input('Enter number ' + str(i+1) + ' '))
if number > 30:
too_high... |
14,497 | 97579c9c6c507c3c4431865083e51a9de2f2d6f0 | class Position:
def __init__(self, seeds_value, bot_statu):
self.cells_player = [4 for i in range(seeds_value)]
self.cells_computer = [4 for i in range(seeds_value)]
self.computer_play = bot_statu
self.seeds_player = seeds_value
self.seeds_computer = seeds_value
def get... |
14,498 | 223f8f3af858838a3577025a99ba1dea21423613 |
import threading
import time
import random as r
class simDataCapture(object):
"""this class is a simulation for Zach J's MAV interface.
It will spawn a thread that will wait a random amount of time, and
then fill the fields of a mav-data struct which will be later paired with
images. This data will b... |
14,499 | 2f6c3383f3857a533e88376bab2984723b9ad629 | import json
import utils
import accepts
from urllib import request
from trans_order import TransportOrder
from order_sequence_head import OrderSequenceHead
class OrderTask(object):
'''
define how to create an order task
attention: no try-catch in this class
'''
def __init__(self, logname = 'order... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.