blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
507923e6a7d195afa60dcaeaa3f28fa3cbe2d95e | ProEgitim/Python-Dersleri-BEM | /Ogrenciler/Erdogan-Canbay/soru13.py | UTF-8 | 476 | 4.0625 | 4 | [
"MIT"
] | permissive | """
Kullanıcıdan alınan iki sayı ile yine kullanıcının seçtiği işlemi yapacak hesap makinası programını yazınız.
"""
sayi1=int(input("1.sayiyi giriniz.."))
islem=input("işlemi seçiniz + - * / ..")
sayi2=int(input("2.sayiyi giriniz.."))
if islem == "+":
sonuc=sayi1+sayi2
elif islem == "-":
sonuc = sayi1-sayi2... | true |
0f0dc177b6c9e687c3f29915c0ccb07abcec429e | hcxgit/PycharmProjects | /Test_9/car.py | UTF-8 | 997 | 3.6875 | 4 | [] | no_license | class Car():
def __init__(self,make,model,year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0 #汽车里程
def get_descriptive_name(self): #汽车信息
long_name = str(self.year) + ' ' + self.make + ' ' + self.model
return long_name.title()
def get_raed_odometer(self): ... | true |
9d5dad2503f41b6b82113a93231dafe0dc0d1885 | dk-master/pythonday | /정렬/큰수.py | UTF-8 | 390 | 3.203125 | 3 | [] | no_license | array = [1, 5, 2, 6, 3, 7, 4]
commands = [[2, 5, 3], [4, 4, 1], [1, 7, 3]]
def solution(array, commands):
answer = []
for i in range (len(commands)) :
temp = sorted(array[(commands[i][0]-1):(commands[i][1])])
print(temp)
answer.append(temp[commands[i][2]-1])
print(answer)
... | true |
3f384347226e423909b395d99ee9c06ababfbf03 | billyxs/notes.md | /python/learning/code/api-looper.py | UTF-8 | 1,267 | 2.84375 | 3 | [] | no_license | import pprint
import requests
from collections import defaultdict
raises={'Part-Time': .1, 'Full-Time': .2, 'On-Leave': .01 }
def getStatusRaise(status):
return raises[status]
def getIt(url, retry=3):
res = (requests.get(url)).json()
if (type(res).__name__ == 'dict' and res['status'] != 200 and retry > ... | true |
18710a244bdb3b1f4e1655e573b0088162de4916 | wang8063/Python | /ex3a.py | UTF-8 | 764 | 4.03125 | 4 | [] | no_license | ##this program is for the exercise 3a
def main():
startamount= input("please gimme a start amount of money in dollars.cents: ")
targetamount= input("please gimme a target amount of money in dollars.cents: ")
annualinterest= input("please gimme an interest rate: ")
startamount= float(startamount)
... | true |
59d7590fce900f2dfc55ce595f85a2f269c9dc15 | nisalpadukka/robo | /sub/motor.py | UTF-8 | 379 | 2.5625 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
import drive
GPIO.setup(11, GPIO.IN) #SO1
GPIO.setup(13, GPIO.IN) #SO2
GPIO.setup(15, GPIO.IN) #S03
GPIO.setup(19, GPIO.IN) #SO4
GPIO.setup(21, GPIO.IN) #SO5
drive.SetSpeed(50,0)
time.sleep(0.8)
drive.SetSpeed(50,50)
time.sleep(0.05)
drive.SetSpeed(0,50)
time.slee... | true |
f7a03be5106e422244c5922620619b9688ac36c1 | Ragib95/python-assessment | /problem4.py | UTF-8 | 115 | 3.203125 | 3 | [] | no_license | def spiralorder(matrix):
n = 3
for i in range(0,n):
for j in range(0,n):
print i,j
return 0
spiralorder(1) | true |
a431a6c1f76b4552e6c954fa1795f3dfc7fab999 | Jcnovoa1/tallerIntegradorPythonUNLZ | /GuiaEjercicios/Ejercicio1.3.py | UTF-8 | 1,937 | 4.34375 | 4 | [] | no_license | """
Ejercicio 1.3
Pedir al usuario que ingrese por teclado dos números reales y
utilizarlos para realizar todas las operaciones aritméticas vistas
(suma, resta, multiplicación, división, potencia, división entera y resto).
Mostrar todos los resultados por pantalla (un resultado por línea) con
su respectiva leyenda a... | true |
35db7e675677ba5d11b2c0f1e3ed0e0c3cae9cee | xbrainmap/xbrainmap | /xbrainmap/xbrain-py/segment_big_data/segment_vessels.py | UTF-8 | 5,402 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# #########################################################################
# Copyright (c) 2015, UChicago Argonne, LLC. All rights reserved. #
# #
# Copyright 2015. UChicago Argonne, LLC. This... | true |
4093c3e5ed1d27bf7892a2088539dd40dc3c3c77 | yte9pc/Machine-Learning-Models | /KNN/knn.py | UTF-8 | 3,697 | 3.453125 | 3 | [] | no_license |
import numpy as np
import random
#file is just a filename, this method will just return a 2d array of the file contents
from sklearn.neighbors import KNeighborsClassifier
#this method should return a 2d array of the file contents
def read_csv(file):
# Load data from a text file and ignore the he... | true |
52ff0746ce9be8214ed0bc76614a25e9366678a7 | mgeier/jupyter-format | /tests/test_serialize.py | UTF-8 | 678 | 2.703125 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | from jupyter_format import serialize
import nbformat
import pytest
@pytest.fixture
def nb():
return nbformat.v4.new_notebook()
def test_minimal_notebook(nb):
nb.nbformat_minor = 1
assert serialize(nb) == 'nbformat 4\nnbformat_minor 1\n'
def test_only_version_4_is_allowed(nb):
nb.nbformat = 5
w... | true |
bd8f92539f737521458dccbd103683556737c2e2 | biabulinxi/Python-ML-DL | /黑马机器深度学习_all/03_贝叶斯案例/02_keywordExtraction.py | UTF-8 | 6,373 | 3 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Project:AID1810
# @Author:biabu
# @Date:2019/4/15 11:33
# @File_name:02_keywordExtraction.py
# @IDE:PyCharm
"""
贝叶斯新闻关键词提取 和 新闻分类
"""
import pandas as pd
import jieba
import jieba.analyse
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
fr... | true |
5638382b253807c599198d1ee6eefee4e4f16faa | JacobJaffe/EMID | /src/.ipynb_checkpoints/camera-checkpoint.py | UTF-8 | 2,556 | 2.96875 | 3 | [] | no_license | import numpy as np
import cv2
from transform import four_point_transform
import imutils
class Marker:
def __init__(self, id, corners):
self.id = id
self._corners = corners
def get_corner_center(self):
corner = self._corners
x = (corner[0][0] + corner[1][0] + corner[2][0] + cor... | true |
3927eb22be08a85a842e89e9013b932b0cb326c7 | sanjeev602/Python_Start | /lambda.py | UTF-8 | 325 | 3.484375 | 3 | [] | no_license | from functools import reduce
lst = [1,3,6,3,4,8]
evens = list(filter(lambda n: n%2==0,lst))
print(evens)
sqr = list(map(lambda n: n*n, evens))
print(sqr)
result = reduce(lambda a,b: a+b, sqr)
print(result)
'''f1 = lambda a,b: a + b
f2 = lambda x, y: x*y
print(f1(3,4))
print(f2(4,5))... | true |
3cd8db9b5d36b5b1161a4031332f0843837e104e | YolieQQQ/AtCoder | /abc169/b.py | UTF-8 | 180 | 3.03125 | 3 | [] | no_license | N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for a in A:
ans *= a
if ans > 1000000000000000000:
print(-1)
quit()
print(ans) | true |
a943bcc9936ae4a32bc668f162efac53bd8f1818 | carocollazo/annenberg-cs-project | /filter_functionality_tests.py | UTF-8 | 3,569 | 3.140625 | 3 | [] | no_license | #!/usr/bin/python
from filter_functionality import *
# EXAMPLE DATA
p1 = {
"pName": "project1",
"time": "inSchool",
"period": "academicYear",
"term": "shortTerm",
"lead": "staffLed",
"funding": "sustained",
"isActive": False
}
p2 = {
"pName": "project2",
"time": "afterSchool",
... | true |
9093e9791d8a15580b714a3e34b9fa3d57a3a78b | douglase/recon-tools | /root/recon/tools/GetParam.py | UTF-8 | 1,417 | 3 | 3 | [
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause"
] | permissive | "Defines a tool for extracting values from a Varian procpar file."
import sys
import os.path
from recon.tools import ConsoleTool
from recon.scanners.varian import ParsedProcPar
##############################################################################
class GetParam (ConsoleTool):
usage=\
"""usage: %prog pro... | true |
29cbd17e5daeb0b0df9af290735947ab8ad9bf6c | Daniiarz/neobis-1-file-projects | /python/Cyclic algorithms/GCD.py | UTF-8 | 94 | 2.984375 | 3 | [] | no_license | import math
def GCD(num1=int(input()), num2=int(input())):
return math.gcd(num1, num2)
| true |
8fb7ab239d3dc44853dde817262465ac8dec840d | amartya18x/TicTacML | /random_agent.py | UTF-8 | 217 | 2.765625 | 3 | [
"MIT"
] | permissive | import numpy as np
class random_agent(object):
def __init__(self):
print("Created Random Agent")
def get_move(self):
return (np.random.random_integers(3)-1, np.random.random_integers(3)-1)
| true |
3c60e9d9c55035a46fbda0f7525cb02573260bfd | jasonkwh/studiospates-python | /users.py | UTF-8 | 2,718 | 2.765625 | 3 | [
"MIT"
] | permissive | """
@author: Hanxiang Huang (Jason)
"""
import bottle
import uuid
# this variable MUST be used as the name for the cookie used by this application
COOKIE_NAME = 'studiospates'
def check_login(db, usernick, password):
"""returns True if password matches stored"""
cur = db.cursor()
# retrieve user informa... | true |
7850cc40cdf89a6da7c900a7fd0b86d3fd08a661 | weilbith/pacurses | /pacurses/gui/menus/default.py | UTF-8 | 1,504 | 2.640625 | 3 | [] | no_license | from urwid import RadioButton, SimpleFocusListWalker
from pacurses.constants.menu_names import MenuNames
from pacurses.constants.sink_types import SinkTypes
from pacurses.gui.abbreviation import abbreviate_sink
from pacurses.gui.menus.menu import Menu
from pacurses.pulse_audio.information import Information
RADIO_BUT... | true |
9edbfb170e1b16ec9c8333cbf9bae348146084da | CraigRiggins/pandas-practical-python-primer | /training/level-4-creating-web-services/dragon-warrior/tmarsha1/friends_api/friends.py | UTF-8 | 3,692 | 3.078125 | 3 | [] | no_license | """
some module to do something class related
"""
from flask import Flask, jsonify, make_response, request, Response
from friends_api import datastore, api_helpers
from werkzeug.exceptions import BadRequest
app = Flask(__name__)
@app.route('/api/v1/friends', methods=["GET"])
def friends() -> Response:
"""
R... | true |
c81e74e67e1af8afb70b54caf27597a011b2d264 | ulillilu/MachineLearning-DeepLearning | /01-03.CSS_Selector/sel_orange.py | UTF-8 | 644 | 3.46875 | 3 | [] | no_license | #여러 방법으로 추출하기
from bs4 import BeautifulSoup
fp = open("fruits-vegetables.html", encoding="utf-8")
soup = BeautifulSoup(fp, "html.parser")
# CSS 선택자로 추출하기
print(soup.select_one("li:nth-of-type(4)").string)
print(soup.select_one("#fr-list > li:nth-of-type(4)").string)
print(soup.select("#fr-list > li[data-lo='ko']")[1].... | true |
88c6c259dc3aa5bc4dd266a51213609f7f68072e | wljSky/numpy-pandas-exercise | /Matplotlib画图基础/一图多线.py | UTF-8 | 1,012 | 3.171875 | 3 | [] | no_license | from matplotlib import pyplot as plt
import matplotlib
import random
from matplotlib import font_manager
y1 = [random.randint(1,15) for i in range(10)]
y2 = [random.randint(1,15) for i in range(10)]
y3 = [random.randint(1,15) for i in range(10)]
x = range(11,21)
#设置图形
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y1,c... | true |
f2f1bca4c571184c56dd38f16663b4a6e77bdbdb | RobotVU/das | /common/command.py | UTF-8 | 10,207 | 2.96875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import json, math, time
from common.constants import *
from common.user import User
import logging
logger = logging.getLogger("sys." + __name__.split(".")[-1])
gLogger = logging.getLogger("game." + __name__.split(".")[-1])
class Command(object):
"""
The common pattern for each command's apply is as follows:
... | true |
9aba927ac3f73c1e4661cc1684fd11a063b46e61 | rlkelly/holdem | /main.py | UTF-8 | 1,149 | 3.265625 | 3 | [] | no_license | from poker_functions import finish_hand
from models.dealer import Dealer
from models.player import Player
from models.pokertable import PokerTable
def main():
dealer = Dealer('Floyd', PokerTable(2))
dealer.shuffle_deck()
player1 = Player('Abbott')
player2 = Player('Costello')
dealer.seat_player(p... | true |
c5b248cc5a426c5f865e6ea38f4f4f98e39b3c5c | 1877762890/python_all-liuyingyign | /day06任务及课上代码/代码/day06/diction/travel.py | UTF-8 | 1,752 | 3.28125 | 3 | [] | no_license | # author:jason
data = {
"北京":{
"昌平":{
"天通苑":["海底捞","呷哺呷哺"],
"龙泽":["永辉超市","永旺超市"]
},
"海淀":{
"公主坟":["军事博物馆","中华世纪园"],
"科普场馆":["中国科技馆","北京天文馆"],
"高校":["清华","北大"]
},
"朝阳":{
"龙城":["鸟化石国家地质公园","朝阳南... | true |
c4bdada8a2670db354a532e34b08cb88e56b7ea5 | biomed-bioinformatics-bootcamp/bmes-t580-2019-coursework-Yilin-Y | /Module01/hello_world.py | UTF-8 | 207 | 3.296875 | 3 | [
"MIT"
] | permissive | print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print(' Hello world ')
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
user_input = input('What is your name?')
reply = 'Nice to meet you ' + user_input
print(reply)
| true |
a9eb4e572fd217ea3cabfc9a9cb7c80ca3088e93 | gerecorrea/Curso_Python | /Secao21_Gerenciamento_memoria/multi_processing.py | UTF-8 | 715 | 3.296875 | 3 | [] | no_license | """
Aplciando o GIL realmente, agora uso de mjutex para acessos
Demandam mais recursos e, consequentemente, são mais pesado que multithread
Mas melhora o desempenho
ELe utiliza o CPython como interpretador.
"""
from multiprocessing import Pool
import time
contador = 50000000
def contagem_regressiva(n: int) -> None... | true |
629bd690b0fff7529c398aa1b0df0439e381de2f | the-mrd/datedisertatie | /ddme.py | UTF-8 | 3,876 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python3
import pandas as pd
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
from sklearn import preprocessing
def normalize(df):
df_norm = (df - df.mean()) / (df.max() - df.min())
return df_norm
def autolabel(rects, ax, names, bottom=False):
# Get ... | true |
f192224d5052107ba024323383b57313c7ca60f4 | chalk13/kottans-backend | /python_basics_1/12_list_ends.py | UTF-8 | 472 | 4.53125 | 5 | [] | no_license | """
Write a program that takes a list of numbers and makes a new list
of only the first and last elements of the given list.
For practice, write this code inside a function.
"""
a = [5, 10, 15, 20, 25]
def first_last_item(input_list: list) -> list:
"""Returns first and last elements of the given list"""
if le... | true |
5e0c57a254e195ccd80de16a4e19590ce2aa322d | sandra79147/pdsnd_github | /bikeshare.py | UTF-8 | 6,249 | 3.734375 | 4 | [] | no_license | import time
import pandas as pd
import numpy as np
import datetime as dt
"""
Statistics and analysis about rideshare data for several cities
Author: Sandra Rudnicka
"""
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_... | true |
6d4fa876e0893dd6ceff80f62064f8224f07ad5c | atakanozguryildiz/HackerRank | /lisas_workbook.py | UTF-8 | 722 | 2.984375 | 3 | [] | no_license | #!/bin/python3
nk = input().split()
n = int(nk[0])
k = int(nk[1])
arr = list(map(int, input().rstrip().split()))
page = 1
pages_and_indexes = {}
special_problem = 0
for chapter_index in range(n):
problem_start_index = 1
problem_count = arr[chapter_index]
while problem_count > 0:
if problem_count >=... | true |
d286bf652f09c1614cc6dfa01a9fd62101de2e56 | UNREALre/TelegramBotProductsKK | /db_filler.py | UTF-8 | 4,261 | 2.828125 | 3 | [] | no_license | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from config import db, appConfig
import pymongo
from os import listdir
from os.path import isfile, join
import csv
csv_path = str(appConfig['resources']['csv'])
def get_file(mask):
"""Получает маску имени файла
Возвращает массив с именами файлов найденных, соот... | true |
101d683c79f27b80f357f3bff0e7dc75ce31e28c | jlrobbins/class-work | /paysilly.py | UTF-8 | 719 | 3.9375 | 4 | [] | no_license | def computepay(hours, rate):
pay = hours * rate
overtime = rate * 1.5
if hours > 40.0:
hours2 = hours - 40.0
pay = ((hours - hours2) * rate) + (hours2 * overtime)
return pay
else:
pay = hours * rate
return pay
try:
hours = float(input('Enter Hours: '))
except:... | true |
585cb9f86bc6a9587086e05a2f728846bad31390 | sys123-data/SOLID-principles | /SOLID Demos/OCP/main.py | UTF-8 | 1,173 | 3.65625 | 4 | [] | no_license | # classes modules functions should be open for extension but closed for modification
import re
def special_match(strg, search=re.compile(r'[^a-z]').search):
'''
:param strg: the string
:param search: should have !!!!only!!!! [0-9] and ( ,. or , or . or '' )
:return: True or False
'''
return not... | true |
4f2196c7fa80b02908ea7b3b0c1519020053da1c | huangmgithub/codes | /ftp/FtpServer/core/server.py | UTF-8 | 6,089 | 3 | 3 | [] | no_license | ### ①-⑤ -->> 链接与验证 ###
### 1-6 -->> 文件上传 ###
################################################
import socketserver
import json
import configparser
from conf import settings
import os
STATUS_CODE = {
250:"Invalid cmd format,e.g:{'action':'get','filename':'test.py','size':344}",
251:"Invalid cmd",
... | true |
5db757392615d5bf3b184fa0240afcd6fd9e08aa | Yunkun-Zhang/Supervisor-Recommendation | /utils/process_data.py | UTF-8 | 15,427 | 2.5625 | 3 | [] | no_license | import pymysql
import pickle
import tqdm
import numpy as np
from collections import defaultdict
def load_authors(path='../data/author_info.pickle'):
with open(path, 'rb') as f:
authors = pickle.load(f)
return authors
def list_to_dict(lst):
d = dict()
for idx, item in enumerate(lst):
... | true |
73ff291a99e283a82443982b8eae67e9cf1561ab | luizfpq/PythonDjango | /Exercicios IFSP/try.py | UTF-8 | 380 | 3.625 | 4 | [] | no_license | # -*- coding:utf-8 -*-
try:
altura = float(raw_input('Digite a altura: '))
peso = float(raw_input('Digite o peso: '))
imc = peso / (altura**2)
print ('O IMC é: {}'.format(imc))
if imc < 1:
raise Exception('IMC menor que um')
except ZeroDivisionError:
print('Altura não pode ser zero')
... | true |
15e3ef631074e14916f54e0f6464dc662fa32af2 | bzcheeseman/kur | /kur/containers/layers/ntm_backend/head.py | UTF-8 | 4,204 | 2.53125 | 3 | [
"Apache-2.0",
"Python-2.0"
] | permissive | #
# Created by Aman LaChapelle on 3/7/17.
#
# pytorch-NTM
# Copyright (c) 2017 Aman LaChapelle
# Full license at pytorch-NTM/LICENSE.txt
#
import torch
import torch.nn as nn
import torch.nn.functional as Funct
from torch.autograd import Variable
from .similarities import cosine_similarity
from .flatfeatures import nu... | true |
00084c55d802ce9028bdb00bcefdb288f7114c5e | krusek/advent_of_code | /day9.py | UTF-8 | 1,040 | 2.90625 | 3 | [] | no_license | f = open('day9.data', 'r')
lines = f.readlines()
smallest = lambda l, r: l > r
biggest = lambda l, r: l > r
comp = smallest
connections = {}
for line in lines:
parts = line.strip().split(" ")
n1 = parts[0]
n2 = parts[2]
v = int(parts[-1])
if connections.has_key(n1) == False:
connections[n1] = {}
if co... | true |
517d8691a02c903d65459c4c764cd2d6c3aec2e1 | thombashi/pytablewriter | /examples/py/excel_table_single.py | UTF-8 | 647 | 2.84375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""
from pytablewriter import ExcelXlsxTableWriter
def main() -> None:
writer = ExcelXlsxTableWriter()
writer.table_name = "example"
writer.headers = ["int", "float", "str", "bool", "mix", "time"]
writer.valu... | true |
89b7360602f23520be2872417b0c682af9121159 | pratyusa98/Open_cv_Crashcourse | /opencvbasic/task6.py | UTF-8 | 671 | 2.984375 | 3 | [] | no_license | #building trackbar with canny edge
import cv2
img = cv2.imread("resources/building.jpg")
img = cv2.resize(img, (600, 700))
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
def nothing(x):
pass
cv2.namedWindow("Canny")
cv2.createTrackbar("Threshold1", "Canny", 0, 255, nothing)
cv2.createTrackbar... | true |
965a6eb8bf4e442402d58713e4e7159cd03b18e6 | solomn1991/Game | /lab/test_memory.py | UTF-8 | 911 | 2.59375 | 3 | [] | no_license | import psutil
import os
import time
import gc
import sys
class Inner_object(object):
def __init__(self,outter_object):
self.outter_object = outter_object
self.space = '1'*1024*1024*50
class Outter_object(object):
def __init__(self):
self.space = '1' * 1024 * 1024 * 10
... | true |
84e4d57a3123d93d97e0e37879bd12abf2636b44 | lgan1989/leetcode | /Trapping Rain Water.py | UTF-8 | 920 | 3.140625 | 3 | [] | no_license | class Solution:
# @param A, a list of integers
# @return an integer
def trap(self, A):
#print A
l = len(A)
if l <= 1:
return 0
max_h = -1
sec_h = -1
p_max = -1
p_sec = -1
for i in range(0 , l):
if A[i] > max_h:
... | true |
f311e0389b1c761d98b9a2ac34d61398693bdde8 | macoto35/Data_Structures_Fundamentals | /python/binarySearchTree/test_avlTree.py | UTF-8 | 4,222 | 3.4375 | 3 | [] | no_license | import unittest
from avlTree import AvlTree
from node import Node
class AvlTreeTest(unittest.TestCase):
def setUp(self):
self.tree = AvlTree()
'''def test_insert(self):
13
10 15
5 11 16
4 6
root = self.tree.avlInsert(13, None... | true |
ef9cd994805abb065e1105e70cfe804e6d1b52d7 | Deathcup/trafficLights | /lab4/trafficLights.py | UTF-8 | 6,271 | 2.59375 | 3 | [] | no_license | import time
import random
from pyknow import *
import serial
exeTimes = 30 # time in second
serialPort = "COM3" # 串口
baudRate = 9600 # 波特率
ser = serial.Serial(serialPort, baudRate, timeout=0.5) # 连接串口
state = 0
we = 0
count = 0
class TrafficLights(KnowledgeEngine):
# def __init__(self):
# self.serial... | true |
df01f6092a879813e4fcbeafbb4b21264f073c8d | qenops/dGraph | /lights/__init__.py | UTF-8 | 2,653 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
'''Light submodule for dGraph scene description module
David Dunn
Jan 2017 - created by splitting off from dGraph
ALL UNITS ARE IN METRIC
ie 1 cm = .01
www.qenops.com
'''
__author__ = ('David Dunn')
__version__ = '1.6'
__all__ = ["Light", "PointLight", "DirectionLight"]
from dGraph impor... | true |
92188231d760c914e3e77f352dda1782a2f13194 | K0414/xcodexp | /leetcode/gas_station.py | UTF-8 | 1,464 | 3.65625 | 4 | [] | no_license | from nose.tools import assert_equal
class Solution:
# @param gas, a list of integers
# @param cost, a list of integers
# @return an integer
def canCompleteCircuit(self, gas, cost):
if not gas or not cost: return 0
gas = gas
cost = cost
net = [ gas[i] - cost[i] for i in r... | true |
94c0dfedaa54745985c982df2d36384137693840 | catherinaxu/cs224s | /svm_glove_mfcc_actual.py | UTF-8 | 9,624 | 2.671875 | 3 | [] | no_license | import collections
import numpy
import csv
import os
import textgrid
import numpy as np
import random
import re
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cross_validation import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn import svm
from sklearn.sv... | true |
8fb6d2b5180db20c4032ccb6164e227280be0e10 | Ravi1998h/python-coding-problem-slutions | /total count of characters.py | UTF-8 | 208 | 2.546875 | 3 | [] | no_license | #output=l5m5j1
a='lllllmmmmmj'
count,str1=0,''
for i in a:
if i not in str1:
for k in a:
if i==k:
count=count+1
str1=str1+i+str(count)
count=0
print(str1)
| true |
370d59a24ebe83e17008d2825c81c5f69739d071 | newtoallofthis123/python-dev-bin | /Ready/NoobNote_v.1.1/font.py | UTF-8 | 785 | 2.625 | 3 | [
"MIT"
] | permissive | from tkinter import *
font = Tk()
font.title("Font Chooser")
font.iconbitmap("icon.ico")
clicked = StringVar()
clicked.set("Cascadia")
font_options = [
"Cascadia",
"Arial",
"Lucida",
"Calibri",
"Segoe UI",
"Times New Roman",
"Verdana",
"Noto Sans",
"Noto Mono",
"MS Sans Serif",
"Lucida Calligraphy",
"Ink Free",
"Cou... | true |
e3b8fd5489cc7d573dc9f2fb331ac6af1f8c9475 | rexhzhang/LeetCodeProbelms | /LeetCode934_ShortestBridge.py | UTF-8 | 3,863 | 3.5625 | 4 | [] | no_license | """
In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected group of 1s not connected to any other 1s.)
Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.
Return the smallest number of 0s that must be flipped. (It is guaranteed that th... | true |
2c813cf884c7696249ef6db4b296f702a8468f5a | SvineruS/kpi_radio_bot | /kpi_radio/music/text.py | UTF-8 | 1,964 | 2.5625 | 3 | [] | no_license | import logging
import re
from typing import Optional, Tuple
from urllib.parse import quote_plus
from bs4 import BeautifulSoup
from consts.config import AIOHTTP_SESSION, LOOP
from utils.lru import lru
_RE_GENIUS_BRACKETS = re.compile(r" \([\w\d ]+\)")
@lru(maxsize=100, ttl=60 * 60 * 12)
async def search_text(name: ... | true |
4ce0aa5886f171adab28fe3d33e94464e3bfb52c | dimonshikkk/Python | /Поиск слов в hml.py | UTF-8 | 464 | 2.578125 | 3 | [] | no_license | import urllib.request
from xml.dom import minidom
url = "http://www.rbc.ru"
webFile = urllib.request.urlopen(url)
data = webFile.read()
# Имя файла
FileName = "yandex.xml"
with open(FileName, "wb") as localFile:
localFile.write(data)
webFile.close()
#Качает файл по ссылке:
urllib.request.url... | true |
cc6589dcd09ee8b439e28ef2f43b9178dc58ff7e | mosesadelere/SeleniumCookBook | /PurePython/jsonExample.py | UTF-8 | 846 | 3.734375 | 4 | [] | no_license | import json
filename = 'myjson.json'
myList = [2,3,6,3,7,8,23]
with open(filename,'w') as fjson:
json.dump(myList,fjson)
with open(filename) as f:
myjson = json.load(f)
print(myjson)
def get_newUser():
username = input('What is your name? ')
filename = 'username.json'
with open(filename, 'w') as... | true |
41b8c299a35ac9830209b229e08863aa98e744d1 | suryakc/design-patterns-py | /strategy/strategies/dtdc_shipping_strategy.py | UTF-8 | 377 | 2.546875 | 3 | [
"MIT"
] | permissive | """ Implementation for a dtdc shipping strategy """
from strategies.shipping_strategy import ShippingStrategy
class DTDCShippingStrategy(ShippingStrategy):
""" Class for calculating DTDC shipping cost """
def __init__(self) -> None:
super().__init__()
def calculate(self, order):
... | true |
8212c3f2cf734f7ccd05890a41d5e876b618ab7a | jnthnklvn/ultimate-ttt | /ultimate-ttt.py | UTF-8 | 6,365 | 3.5 | 4 | [] | no_license | class UltimateTicTacToe(Game):
## variaveis iniciais e de configuração
## win_resul armazena as posições de todas as vitorias
win_resul = [(0,4,8),(2,4,6)]
win_resul += [(i, i+3, i+6) for i in range(3)]
win_resul += [(i*3, i*3+1, i*3+2) for i in range(3)]
def __init__(self, h=3, v=3, k=3):... | true |
0a594398892125903a10c9bcbfee3470964759b8 | dgrubb/TofuDoorbell | /doorbell/tofugpio/tofugpio.py | UTF-8 | 2,601 | 2.875 | 3 | [] | no_license | # File: tofugpio.py
# Author: dgrubb
# Date: 09/07/2017
# Provides GPIO access.
# System modules
import logging
import os
# Pi modules
import RPi.GPIO as GPIO
MODULE = "Tofu GPIO"
LOG = logging.getLogger(MODULE)
INVALID_PINS = {
"5v": [2, 4],
"3.3v": [1, 17],
"Ground": [6, 9, 14, 20, 30, 39],
... | true |
558ebcd780f8b8316ac2858f012c65c4faef8aec | vrashi/python-coding-practice | /digits.py | UTF-8 | 131 | 3.703125 | 4 | [] | no_license | #program to find number of digits in an integer
integer = int(input("enter an integer"))
string = str(integer)
print(len(string))
| true |
3614845c3538e63e717cc61da581355379e7d067 | jseale/autocomplete | /library/autocomplete/autocompleter.py | UTF-8 | 4,371 | 3.3125 | 3 | [] | no_license | """ Receives user-generated prefix and returns autocompletion suggestions """
import os
import sys
import re
from collections import Counter
#Get package prefix; insert library on path for imports
AUTOC = os.path.abspath(__file__ + "/../../../")
sys.path.insert(0, "{}/library".format(AUTOC))
from data_load import data... | true |
946369cc50b7e90ee1f2d7630720b3413a5a977c | sachin88888/python | /secretfiles.py | UTF-8 | 499 | 2.8125 | 3 | [] | no_license | import os
def rename_files():
file_list=os.listdir(r"C:\Users\sachin\Desktop\py udacity\my secret message")
#print(file_list)
saved_path=os.getcwd()
#print("the current working directory is"+saved_path)
os.chdir(r"C:\Users\sachin\Desktop\py udacity\my secret message")
#print("after changing dire... | true |
6bbfef8e0f41dda18cc8ca478179bf8e7172ce4e | wasyl078/Python-Pathfinder | /graphs/graph.py | UTF-8 | 6,473 | 3.40625 | 3 | [] | no_license | # imports
from graphs.node import Node
import random
from graphs.edge import Edge
from general.priority_queue import PriorityQueue
import sys
import math
from general.consts_values import Color, Blocks
from typing import List, Set
from general.matrix_of_blocks import Matrix
from blocks.abstract_block import AbtractBloc... | true |
4bf9e78dd8e2cb6b1418063ee434a6ce748c47b5 | saierding/leetcode-and-basic-algorithm | /leetcode/exhaustive search/接雨水.py | UTF-8 | 1,263 | 3.984375 | 4 | [] | no_license | # 42. Trapping Rain Water
# Input: [0,1,0,2,1,0,1,3,2,1,2,1]
# Output: 6
class Solution:
# 建立left和right两个指针。判断height[left]<height[right],
# 如果成立的话,left+=1,否则的话,我们right-=1。
# 挪动left和right的同时需要记录左右的最大值maxLeft和maxRight。
# 如果height[left]<height[right]并且height[left]<maxLeft的话,
# 那么说明此时的left处于较低位置,增加水量m... | true |
bc6dcaa43c95392536de51b1fe9796eabe2c77e0 | greenelab/ccc | /tests/test_utils.py | UTF-8 | 8,764 | 2.984375 | 3 | [
"BSD-2-Clause-Patent",
"BSD-3-Clause"
] | permissive | """
Tests the utility_functions.py module.
"""
import sys
from unittest.mock import MagicMock
from pathlib import Path
import numpy as np
import pandas as pd
import pytest
def reload_package(root_module):
"""
Reloads all modules given a root module. It deletes loaded modules from sys.modules and reloads them... | true |
b5b17b51003d7172d2b6bdb9e51a556246582a35 | zachard/python-parent | /hello_python/chapter09/calzz_def_use.py | UTF-8 | 2,900 | 4.28125 | 4 | [
"Apache-2.0"
] | permissive | # 类包含任何类型的通用属性及动作
class Dog(): # 类名称大写, 根据约定, 在Python中, 首字母大写的名称指的是类.
"""模拟狗这个动物类型"""
# __init__()是一个特殊的方法, 每当你根据Dog类创建新实例时, Python都会自动运行它
# 这个方法的名称中, 开头和末尾各有两个下划线, 这是一种约定, 旨在避免Python默认方法与普通方法发生名称冲突
# 三个形参: self、name和age. 形参self必不可少, 还必须位于其他形参的前面
# 每个与类相关联的方法调用都自动传递实参self,(注: 是每个方法, 不仅仅是默认方法)
... | true |
0ddb5487780b06bc1e17ee0f2530f637065b893a | atigerboy/PythonCookBook | /chapter2/2_10Working with Unicode Characters in Regular Expressions/2_10.py | UTF-8 | 359 | 3.734375 | 4 | [
"MIT"
] | permissive | import re
num = re.compile(r'\d+') #\d matches any unicode digit character
print( num.match('123'))
#Arabic digits
print( num.match('\u0661\u0662\u0663') )
arabic = re.compile('[\u0600-\u06ff\u0750-\u077f\u08a0-\u08ff]+')
pat = re.compile('stra\u00dfe', re.IGNORECASE)
s = 'straße'
print( pat.match(s) )
print( pat.m... | true |
1acf7e069e048dad31143263833e2feda394c09c | kumar-brar/ML-and-visualization | /best_fit_slope_and_intercept.py | UTF-8 | 997 | 3.609375 | 4 | [] | no_license | from statistics import mean
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
#xs = [1,2,3,4,5,6]
#ys = [5,4,6,5,6,7]
xs = np.array([1,2,3,4,5,6], dtype=np.float64)
ys = np.array([5,4,6,5,6,7], dtype=np.float64)
def best_fit_slope_and_interce... | true |
e9fbb51ca94c7be786c8fdbb0a176328a96823cf | brizjose/JBCodingDojo | /python_stack/python_fundamentals/encryption/hash_with_bcrypt/bcrypt.py | UTF-8 | 3,738 | 2.84375 | 3 | [] | no_license | from flask import Flask, render_template, request, redirect, session, flash
from mysqlconnection import MySQLConnector
#import bcrypt
from flask.ext.bcrypt import Bcrypt
import re
EMAIL_REGEX = re.compile(r'^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$')
app = Flask(__name__)
#create the bcrypt object
bcrypt = Bcrypt(a... | true |
156c152652ff9bc74df214f2f1695dcdc9830329 | Genne23v/test-scripts-with-python | /auto-test-using-selenium-webdriver.py | UTF-8 | 1,984 | 2.546875 | 3 | [] | no_license | from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://google.com')
element = driver.find_element_by_name('q')
element.send_keys('test')
from selenium.webdriver.common.keys import Keys
element.send_keys(Keys.RETURN)
# from selenium import webdriver
# driver = webdriver.Chrome()
driver.get('h... | true |
d7a31abcffa213662385bca9f270630139ab043e | leojohnsonm/Python | /mobile_no_validation_india.py | UTF-8 | 378 | 3.46875 | 3 | [] | no_license | import re #starts with zero then the first digit must start with 6-9
a = "0979019749917708955853919944337977"
x = re.findall("^0+[6-9]\d{9}|[6-9]\d{9}",a)
print(x)
import re #starts with 91 then the first digit must start with 6-9
a = "91979019749991770895585391723923467391944227372991965... | true |
bf8ef6742348a03b16351dc895a45bf3d0a67873 | tpainter/adsb_range | /antennarange.py | UTF-8 | 5,433 | 3.265625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Copyright 2016 Travis Painter (travis.painter@gmail.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 applicable law... | true |
f4add601e429ceeb35094a22eb42e72c0bd8b8f0 | tooyeah/shapley-regression | /shapreg/shapley.py | UTF-8 | 8,956 | 2.796875 | 3 | [
"MIT"
] | permissive | import numpy as np
from shapreg import utils, games, stochastic_games
from tqdm.auto import tqdm
def default_batch_size(game):
'''Determine batch size.'''
if isinstance(game, (games.DatasetLossGame, games.DatasetOutputGame)):
return 32
else:
return 512
def default_min_variance_samples(ga... | true |
0fb74707553d01f5337acfe80f67af75f5ab72e5 | cgxabc/data-science-at-scale---data-manipulation | /week 3/asymmetric_friendships_guo.py | UTF-8 | 900 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 19 18:26:42 2017
@author: apple
"""
import MapReduce
import sys
mr = MapReduce.MapReduce()
def mapper(record):
# key: person A&friend sorted, so person&friend is the same as friend&person
# value: person A, friend
pair = [x.encode('u... | true |
72a906da44d2d37d8c66e18a77e4c3ca6e27dee8 | bentheiii/Measure | /measure/linear.py | UTF-8 | 5,934 | 2.859375 | 3 | [
"MIT"
] | permissive | from typing import Dict, Tuple, Union
from numbers import Real
from collections import namedtuple, Counter
from math import isclose
from .measure import Measure, Measurement, AggregateMeasure, Unit
from ._util import split_amount_args
class Ladder(namedtuple('LadderBase', 'scale offset')):
"""
A... | true |
79c0a1126effcd4b9e11dc58b15d0a161f4a18db | siddhesh10/graphs | /main.py | UTF-8 | 342 | 2.609375 | 3 | [] | no_license | import sys
sys.path.insert(0, 'C:/Users/sidd/Desktop/graphs/')
import dfs
import node
import bfs
A=node.node("A")
B=node.node("B")
C=node.node("C")
D=node.node("D")
E=node.node("E")
A.links.append(B)
A.links.append(C)
B.links.append(D)
D.links.append(E)
dfs.dfs().depth_first_search(A)
bfs.bfs().bre... | true |
7a87b08b7cd481c1683d1e6a35770dc464fc60a7 | tonebeta/BuildingMachineLearningSystemsWithPython | /ch08/chapter.py | UTF-8 | 6,372 | 3.015625 | 3 | [
"MIT"
] | permissive | import numpy as np # NOT IN BOOK
from matplotlib import pyplot as plt # NOT IN BOOK
def load():
import numpy as np
from scipy import sparse
data = np.loadtxt('data/ml-100k/u.data')
ij = data[:, :2]
ij -= 1 # original data is in 1-based system
values = data[:, 2]
reviews = sparse.csc_matri... | true |
ba4720849e96c18403d86b2b24ccb6e9a8d406f2 | chrisr1896/Exercises | /introduction_to_python/recursive_functions/1_count_down/solution/solution.py | UTF-8 | 233 | 3.328125 | 3 | [] | no_license | #def count_down_from(num):
#if num >= 1:
#print(num)
#count_down_from(num - 1)
#list = [1, 1, 2, 3, 5, 8, 13]
#print(list[list[list[4]]])
for i in range(10):
if not i % 2 == 0:
print(i+1) | true |
1a9ddc9685a7d749b9f741e421607825899b89b6 | SlivnikN/PSA1 | /naloge/2016/dn1/matrix/NinaSlivnik/cheapmatrix.py | UTF-8 | 9,462 | 3.359375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from .slowmatrix import SlowMatrix
class CheapMatrix(SlowMatrix):
"""
Matrika s prostorsko nepotratnim množenjem.
"""
def multiply(self, left, right, work = None):
"""
V trenutno matriko zapiše produkt podanih matrik.
Kot neobvezen argument la... | true |
0b62de0caeea5198756c2bf98329878250767fe7 | saumyasinha023/PythonProgramming | /Practice/LinkedLists/ReverseLinkedList.py | UTF-8 | 971 | 3.609375 | 4 | [] | no_license | # 1->2->3->4
# 4->3->2->2->1
# None<-1<-2<-3<-4
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
first = ListNode(1)
first.next = ListNode(2)
first.next.next = ListNode(3)
first.next.next.next = ListNode(4)
first.next.next.next.next = ListNode(5)
class Solution:
def reve... | true |
85ddd0faf744d4592abcc8295cf6972251ee1d73 | PSRahul/facial-keypoint-cnn | /PythonFiles/trainer.py | UTF-8 | 4,295 | 2.75 | 3 | [] | no_license | #A wrapper Function for training the model
def trainer_function(hparams):
from torch.utils.tensorboard import SummaryWriter
from datetime import datetime
from torch.utils.data import DataLoader
import torch
from torchvision import transforms
import pathlib
from PythonFiles.data_manip import ... | true |
d1191ad6631cf1eca4e0e9ca97f1cff7d6d32a51 | FUKUSHUN/cow_python | /COW_PROJECT/analyze_main/move_ave.py | UTF-8 | 2,149 | 3.234375 | 3 | [] | no_license | #-*- encoding:utf-8 -*-
import csv
import pandas as pd
import numpy as np
import datetime
def read_values(filepath):
count = 6 #何個分の移動平均をとるか
df = pd.read_csv(filepath, header = 0, index_col=0)
header = ["TIME"] + list(df.head(0))
df = df.fillna(0) #nanを0に
index_list = df.index[1 * (count - 1):]
... | true |
5d15c67e7161f32caa0fa2ab46af52e9e21ba783 | ecds/readux | /utility/ingest_scripts/alto_ocr.py | UTF-8 | 1,501 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | import argparse
import os
import glob
from bs4 import BeautifulSoup
def write_ocr(args):
dirlist = []
dirlist = sorted(glob.glob(os.path.join(args.alto_dir, '*.xml')))
for file in dirlist:
filename = os.path.basename(file)
text = open(file, 'rU').read()
soup = BeautifulSoup(text,... | true |
6538bd289a99b5b61759f6d53ca9e4c100b106d5 | dougphaney/Lab_Python3 | /dataquest.io/python-programming-de/Encodings and Representing Text in a Computer-451.py | UTF-8 | 1,273 | 3.75 | 4 | [] | no_license | ## 1. The ASCII Encoding ##
data = "QUEST"
for c in data:
ascii_c = bin(ord(c))
print(c, ascii_c)
## 2. ASCII Limitations ##
text = "The Swedish word for quest is sökande"
encoded = text.encode(encoding='ascii', errors='replace')
print(encoded)
print(type(encoded))
## 3. Bytes ##
bytes1 = bytes.fromhex('02... | true |
875222f915a28ffd218baf8295a953d609cdcf4a | ajn123/Python_Tutorial | /Python Version 2/Advanced/graph.py | UTF-8 | 441 | 3.703125 | 4 | [
"MIT"
] | permissive | #!/usr/bin/python
# Numpy is a library for handling arrays (like data points)
import numpy as np
# Pyplot is a module within the matplotlib library for plotting
import matplotlib.pyplot as plt
# Create an array of 100 linearly-spaced points from 0 to 2*pi
x = np.linspace(0,2*np.pi,100)
y = np.sin(x)
# Create the pl... | true |
93e151b5a7e90b499df61175ea045e5d65ba9bbb | anant-pushkar/competetive_programming_codes | /python/MUH_and_Sticks/main.py | UTF-8 | 547 | 3.234375 | 3 | [] | no_license | '''
Project name : MUH_and_Sticks
Created on : Fri Sep 26 21:06:12 2014
Author : Anant Pushkar
http://codeforces.com/contest/471/problem/A
'''
import sys
debug_mode = len(sys.argv)>1 and sys.argv[1]=="DEBUG"
def debug(msg):
if debug_mode:
print msg
sticks = [int(x) for x in str(raw_input()).split(" ")]
count = {}
f... | true |
8b4cadc540ee3635f4eef02ad5f9c81ec80b434d | cs207-2016/cs207project | /tests/test_cs207rbtree.py | UTF-8 | 7,826 | 2.84375 | 3 | [
"MIT"
] | permissive |
''''
Authors:
Sophie Hilgard
Ryan Lapcevic
Anthony Soroka
Ariel Herbert-Voss
Yamini Bansal
Date: 28 Oct 2016
Course: Project CS 207
Document: test_cs207rbtree.py
Summary: Testing RBTree Class
Example:
Example how to run this test
$ source activate py35
$ py.test test_cs207rbtree.py
'''
from ... | true |
822b507a62f026cb7f601c771a614e39b7815bb3 | taeyoung0103/MindTree | /mindtree/modules/word_cloud.py | UTF-8 | 3,313 | 2.875 | 3 | [] | no_license | from wordcloud import WordCloud
import sys
from mindtree import db
from mindtree.models import Post, SeriesPost
from mindtree.utils.DTO import PathDTO
from mindtree.utils.util import get_time_str
class CreateWordCloud(PathDTO):
def __init__(self):
super().__init__()
# WordCloud 객체 initialization
... | true |
0e1cb1df086dd3e45e371079ad7bc9d1947433ba | tangmingcan/minist | /layers.py | UTF-8 | 21,064 | 2.921875 | 3 | [] | no_license | import numpy as np
from utils.tools import *
class Layer(object):
"""
"""
def __init__(self, name):
"""Initialization"""
self.name = name
self.training = True # The phrase, if for training then true
self.trainable = False # Whether there are parameters in this layer t... | true |
2e24279471a98995d215ab10f1015d72d6c564ed | notandy/python-brewer | /pythonbrewer/errors.py | UTF-8 | 1,212 | 2.59375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
__all__ = [
"PackageNotFoundError",
"MultiplePackagesFoundError",
"PackageFetchError",
"HashValidationFailedError"
]
class PackageNotFoundError(Exception):
def __init__(self, package_name):
super(PackageNotFoundError, self)... | true |
cd2b9a02faeda1218a3a9cd323222784781acf16 | e-aditi/Application-of-Face-mask-detector-rakshak-2.0mini-project-2 | /Rakshak 2-0.py | UTF-8 | 1,598 | 2.671875 | 3 | [] | no_license | ## loading the saved model ##
model=load_model(r"path for the saved model with good accuracy.")
model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])
model.summary()
## face- mask detection ##
face_classifier=cv2.CascadeClassifier(r" path for haar-cascade-classifier")
labe... | true |
010d3bb244623dd3db681babcce1df6c23e94b5e | utexas-bwi/scavenger_hunt | /bwi_scavenger/scripts/absim/prob_prox_agent.py | UTF-8 | 1,532 | 3.046875 | 3 | [] | no_license | import agent as agent
import world as world
class ProbProxAgent(agent.Agent):
"""This agent visits the location with the least expected wasted cost.
This cost is the product of the probability of not finding an object at
the location times the distance to the location.
"""
def setup(self):
... | true |
5fa672cd65332d017378450bb11d849180a40127 | JadsyHB/holbertonschool-machine_learning | /supervised_learning/0x07-cnn/0-conv_forward.py | UTF-8 | 1,208 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python3
"""convolutional forward prop"""
import numpy as np
def conv_forward(A_prev, W, b, activation, padding='same', stride=(1, 1)):
"""Returns: the output of the convolutional layer"""
m, h_prev, w_prev, c_prev = A_prev.shape
kh, kw, c_prev, c_new = W.shape
sh, sw = stride
if p... | true |
3499e1aa6fbcad9aee344186734f0a3b7e6f77ec | woxsao/Canny-Edge-Detection | /CannyEdge.py | UTF-8 | 5,490 | 2.96875 | 3 | [] | no_license | import numpy as np
import cv2 as cv
import math
from numpy.core.numeric import convolve
class CannyEdge:
def __init__(self, img, sigma, kernel_size, lowthresh_ratio, highthresh_ratio):
self.img = img
self.sigma = sigma
self.kernel_size = kernel_size
self.lowthresh_ratio = lowthres... | true |
98031687f0911d25f5756410298a0428270ec8f3 | moinudeen/sentimix | /src/models/transformer_models.py | UTF-8 | 3,438 | 2.71875 | 3 | [] | no_license | from typing import Any, List, Tuple
import numpy as np
import pandas as pd
import torch
from nlp import load_dataset
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
from transformers import Trainer, TrainingArguments, pipeline
class SentimixDataset(torch.utils.data.Dataset):
def __ini... | true |
e43c55c535c241171ce4f5a9af3bf0992f34c22d | irtfrm/leet-code | /142.linked-list-cycle-ii.py | UTF-8 | 741 | 2.90625 | 3 | [] | no_license | #
# @lc app=leetcode id=142 lang=python3
#
# [142] Linked List Cycle II
#
# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
normal = head
... | true |
60d6af73a3f22b825a6b5f935021ef14a2c2b937 | ath32/ASCs | /0_Python_scripts/7.5_Fifth_site_freqs.py | UTF-8 | 3,142 | 2.734375 | 3 | [] | no_license | ### IMPORTS ###
import os
import numpy as np
import csv
import scipy.stats as st
### CHOOSE SOURCE FOLDER (EMBL) ###
source = '2_FASTA_Eubacteria_cds_TT11'
#source = '2_HEGs_fasta'
#source = '2_LEGs_fasta'
def main(source):
CSV_total = []
for root, dirs, filenames in os.walk(source):
for f in fi... | true |
df075aba9865bf3dba900e0d338073c8f1d1a52a | LeronQ/Kaggle | /breast_cancer/EDA.py | UTF-8 | 4,807 | 2.78125 | 3 | [] | no_license |
# coding: utf-8
# In[143]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# In[144]:
train_data=pd.read_csv('data/breast_cancer_data.csv')
train_data=train_data.drop(['id'],axis=1)
# In[145]:
# 或者采用map: train_data['diagnosis']=train_data['diagnosis'].map({'M':1,'B':0})
train_data[... | true |
b6a69fe66d264c2400ce1eec292f64d426baa89d | xthzhjwzyc/LinkLevelSimulator | /src/parameters/parameters.py | UTF-8 | 2,679 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Parameters class.
Code adapted from: https://github.com/SIMULATOR-WG/SHARC
Created on Thu Mar 30 16:32:35 2017
@author: Calil
"""
import numpy as np
from src.support.enumerations import ChannelModel
from src.support.enumerations import SimType
class Parameters(object):
__instanc... | true |
05a1c1fe8bdb7800613a6b2f04c1caae2b28c85c | Sankalp679/Competitive-Programming | /Leet Code/30 Days of Code/week_01/Group_Anagrams.py | UTF-8 | 403 | 3.359375 | 3 | [] | no_license | from collections import defaultdict
def groupAnagrams(strs):
ans = defaultdict(list)
for s in strs:
count = [0]*26
for c in s:
count[ord(c)-ord("a")] += 1
ans[tuple(count)].append(s)
return ans.values()
for t in range(int(input())):
N = int(input())
strs = []
... | true |