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 |
|---|---|---|---|---|---|---|---|---|---|---|
16aa0030ca27914bffad9f57dbbd44671a433708 | joshleejosh/shufflebuddy | /shufflebuddy/__init__.py | UTF-8 | 1,759 | 3.3125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Persist shuffled sequences across runs of a program.
"""
from __future__ import unicode_literals
from builtins import open
import os.path
import json
import random
class ShuffleBuddy:
def __init__(self):
self.filename = ''
self.state = {}
self.rng = random.Random... | true |
418fb40948f8116a3ad79b07291d18bb75e13ef0 | sazzadrupak/db_api | /app/analyze/serializers.py | UTF-8 | 808 | 2.5625 | 3 | [
"MIT"
] | permissive | from rest_framework import serializers
from django.core.exceptions import ValidationError
class AnalyzeSerializer(serializers.Serializer):
"""Serializer for Analyze API payload object"""
text = serializers.CharField(trim_whitespace=False, allow_blank=True)
def validate_text(self, value):
"""
... | true |
0d6bdd6d83b280a4b14418f3b8a02826184e7cf9 | Daishijun/InterviewAlgorithmCoding | /bishi/PDD/secondTime/p3.py | UTF-8 | 1,161 | 3.375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/9/1 16:29
# @Author : Daishijun
# @Site :
# @File : p3.py
# @Software : PyCharm
'''n个骰子,求最大值期望'''
'''
用DP,dp[i][j]表示用前i个骰子,最大值为j的情况数量
'''
n = int(input())
nlist = list(map(int, input().split()))
def getdp(nlist):
dp = [[0]* (max(nlist)+1... | true |
037bde9ed2592f165ee7af8d18840383d6802812 | hhweeks/graymatter | /MeasureScoreAnalyzer/Main.py | UTF-8 | 1,349 | 2.796875 | 3 | [] | no_license | import os
import sys
from src.MeasureScoreCalculator import getMeasureScore
from src.DataReader import readColumnCSV
def printUsage():
print("incorrect usage\nplease use python3 Main.py MEASURE_NAME (optional)DATAFILE.csv")
print("if specified, DATAFILE should be located in data/ directory")
print("vali... | true |
7827e6549ff862da2776ceee2a3b9dc167526869 | FYYFU/NMT | /data_processing/convert_iso639code_to_language.py | UTF-8 | 1,522 | 2.765625 | 3 | [
"MIT"
] | permissive | import pycountry
import argparse
import json
from collections import OrderedDict
from utils.tools import read_data
def test():
for lang in pycountry.languages:
assert len(lang.alpha_3) == 3
try:
assert len(lang.alpha_2) == 2
except AttributeError:
continue
def c... | true |
1e250ed2b6f06af03351f5699e0b9a063a3a7bf3 | xkender/Cloud-programming | /Python Crash Course/List_dictionary_nesting.py | UTF-8 | 1,013 | 3.890625 | 4 | [] | no_license | #Creating an emtpy list and appending dictionaries to it
car_pool = []
#creating a pool of 10 cars from each car dictionary
for cars in range (10):
car_1 = {'make': 'ferrari', 'model': '911', 'color': 'red', 'package': 'luxury'}
car_2 = {'make': 'honda', 'model': 'accord', 'color': 'black', 'package': 'limite... | true |
7fb097c70457a18be081fbbf94aa48284a9ffed6 | orb1t-ua/Philo | /Philo_Sim.py | UTF-8 | 2,271 | 2.90625 | 3 | [] | no_license | #!/usr/bin/python
# Philo's Free Body Simulation
# ----------------------------
# Author: Ara Kourchians
# ----------------------------
# TODO List:
# TODO: UPDATE Ma, Ve, and Area calculations with correct equations!
import matplotlib
import numpy as np
# import matplotlib.pyplot as plt
import sys
import os.path
f... | true |
63348f88fe5cc9489fcf3c60c42bdd53904fb528 | Keshav1506/competitive_programming | /Dynamic_Programming/007_leetcode_P_1143_LongestCommonSubsequence/Solution.py | UTF-8 | 7,426 | 3.84375 | 4 | [] | no_license | #
# Time :
# Space :
#
# @tag : Dynamic Programming
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 1143: Longest Common Subsequence
#
# Description:
#
# Given two strings text1 and text2, return the length of their longe... | true |
c35160ebc6d90bed9bb06ffff684f22611f15557 | RoboJackets/evgp-rcs | /evgp_rcs/tcpclient.py | UTF-8 | 5,198 | 2.875 | 3 | [
"MIT"
] | permissive | import socket
import sys
import signal
import re
import time
import select
import argparse
import platform
from race import RaceState
class TCPClient:
START_CHAR = '$'
END_CHAR = ';'
def __init__(self, server_ip, server_port):
# Create a TCP/IP socket
self.sock = socket.socket(socket.A... | true |
816f9c477a03a34e3b734cd7e314fa61736c719a | kfang87/untitled-project1 | /epnumos/dbaccess.py | UTF-8 | 4,856 | 2.859375 | 3 | [] | no_license | __author__ = 'Kayla'
from py2neo import Graph
import HTMLParser
from collections import OrderedDict
graph = Graph()
h = HTMLParser.HTMLParser()
# Name queries
def get_person_dict_for_name( base_name):
person_dict = {}
# Fill in persons dictionary
query = ("MATCH (n:Name {{base_name: '{0}'}}) -[r]- (p:P... | true |
32c5e735f148d2bbc7058dc616d083bcdca9c59b | sezan92/CarND-Advanced-Lane-Lines | /src/util.py | UTF-8 | 6,678 | 2.984375 | 3 | [
"MIT"
] | permissive | import os
import cv2
import numpy as np
def imread(image_name, colorspace="RGB"):
"""
Reads image and returns RGB numpy array
Parameters:
image_name: Image path , str
colorspace: RGB or BGR, str
Returns:
img: numpy array
"""
img = cv2.imread(image_name)
if colorspa... | true |
cc95399fdbcbc5e4953dfd5f1a1300e696b9a367 | vibhav011/CS747 | /Assignments/Assn1/submission_local/bandit.py | UTF-8 | 6,801 | 3.0625 | 3 | [] | no_license | import numpy as np
import argparse
class Bandit:
# This class represents a bandit instance.
class Arm:
# This class represents a bandit arm.
def __init__(self, pdf, support = [0, 1]):
# prob: the probability distribution of different outcomes
# support: the support vect... | true |
388fa62921373d764f8db1d9f51ef940777ebf8e | KaKaPe/projekt_dashboards | /tab3.py | UTF-8 | 1,765 | 2.53125 | 3 | [] | no_license | import pandas as pd
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go
def render_tab(df):
df['weekday'] = df['tran_date'].dt.weekday
grouped = df[df['total_amt'] > 0].groupby([pd.Grouper(key='weekday'),
... | true |
245b2c3724daf14a78469dce23c7b22ac108c61c | rapiderosion/Python-Programs | /gexestr.py | UTF-8 | 219 | 3.203125 | 3 | [] | no_license | def donuts(count):
if count >10:
return 'Number of Donuts:many'
else:
return 'Number of Donuts:' + str(count)
print donuts(4)
print donuts(9)
print donuts(10)
print donuts(99) | true |
f82ede1b4dc8023249f7813463dec84eee22d4bc | grayblu/MachineLearning | /TensorflowTest/modelUsable.1.py | UTF-8 | 3,821 | 2.8125 | 3 | [] | no_license | import tensorflow as tf
import numpy as np
data = np.loadtxt('C:/Users/student/machineLearning/Tensorflow/iris.csv', delimiter=',', dtype='float32')
np.random.shuffle(data)
train_data = data[:100]
test_data = data[100:]
print(train_data.shape, test_data.shape)
x_data = test_data[:, 1:5]
y_data = ... | true |
3cf8d02e9e6393312d23950a2add6f35d404dc2a | faffyroypeter/DeepLearning | /13.text generation/word level-language modelling.py | UTF-8 | 2,610 | 2.75 | 3 | [] | no_license | from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.layers import LSTM, Embedding, TimeDistributed, Dropout
import numpy as np
from keras.preprocessing.text import Tokenizer
from keras.utils import np_utils
from keras.callbacks import ModelCheckpoint, EarlyStopping
from keras.optim... | true |
d00ef8812361fc81843a9dbb4de0d07896ee3102 | XrosLiang/ultraopt | /ultraopt/utils/config_space.py | UTF-8 | 8,515 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : qichun tang
# @Date : 2020-12-14
# @Contact : qichun.tang@bupt.edu.cn
from collections import Counter
from copy import deepcopy
from typing import List, Union
import numpy as np
from ConfigSpace import CategoricalHyperparameter, ConfigurationSpace, Unifo... | true |
ee3b618a45c58327784895dee85a661fd9c1273b | enisteper1/ML_with_and_without_sklearn | /Multiple_Linear_Regression/Multiple_LR_with_sklearn.py | UTF-8 | 1,446 | 3.25 | 3 | [] | no_license | from sklearn import datasets
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def main():
# Create Dataset
x, y = datasets.make_regression(n_samples=200,n_features=5,bias=1,noise=15)
... | true |
0defcb4a5084230d05e781c2f10d326120c83350 | unpreghini/htanh-fundamental-c4e21 | /session1/temperature_converter.py | UTF-8 | 151 | 3.78125 | 4 | [] | no_license | celcius = int(input("Enter temperature in Celcius: "))
fahrenheit = 9.0/5.0 * celcius + 32
print("The equivalent in Fahrenheit is", fahrenheit, "(F)")
| true |
ac4ec931058b20a8a7c9e85edb7ca51f84d01a42 | shinobu-x/reinforcement-learning | /sac.py | UTF-8 | 5,964 | 2.828125 | 3 | [] | no_license | import numpy as np
import random
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from copy import deepcopy
from torch.distributions import Normal
# Soft Actor-Critic:
# Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor
# https://arxiv.org/abs/... | true |
b64e6faf95f7a73f5e03f18378caf3ff6fed4e04 | testgitmuseum/Museum | /Utilities/WebConnectDownload/MarketDataAPIConnection.py | UTF-8 | 1,568 | 2.734375 | 3 | [] | no_license | from flask import Flask, request
from flask_restful import Resource, Api
from sqlalchemy import create_engine
from json import dumps
__author__ = 'vfourrier'
source__ = 'https://impythonist.wordpress.com/2015/07/12/build-an-api-under-30-lines-of-code-with-python-and-flask/'
"""
Create connection to a restful API... | true |
1064f31c77a2990d3a73df46fc71560593c5af49 | ivory2006/forecasting_profession | /unintroduced programs_some middle results/ScreenNameTransferId.py | UTF-8 | 470 | 2.625 | 3 | [] | no_license | from twitter_client import get_twitter_client
import json
import csv
exampleFile=open('new200k_250.csv')
exampleData=csv.reader(exampleFile)
exampleList=list(exampleData)
client = get_twitter_client()
for i in range(1,26257,1):
try:
profile = client.get_user(screen_name=exampl... | true |
37502b5f840ab2b4fa63758c78521cca5e2d2149 | shennyrs/bash | /python/dictionary/sort.py | UTF-8 | 195 | 2.546875 | 3 | [] | no_license | #!/bin/python
all={'name1':"raju",'name2':"praveena",'name3':"george",'name4':"sona"}
girls={'name2':"praveena",'name4':"sona"}
boys={'name1':"raju",'name3':"george"}
students=list(all.keys())
| true |
8b96e904c0ca1c57232240939d799eed3cbee1e2 | 1tianjing/python- | /2017年旧代码/python基础/2018/王者荣耀版.py | UTF-8 | 3,044 | 4 | 4 | [] | no_license | print('欢迎来到召唤师峡谷!')
name = "wangzherongyao"
print(name.title())#首字母大写
print(name.upper())#全部字母大写
first_name="郑"
last_name="开州"
full_name=first_name+" "+last_name
print(full_name)
print('尊敬的召唤师:'+full_name+',欢迎来到召唤师峡谷!')
print("欢迎来到召唤师峡谷!")
print("\t欢迎来到召唤师峡谷!")#文本后缩进一个单位
print("\n欢迎来到召唤师峡谷!")#文本换行
msg = " 努力有用的话还要... | true |
f3a9411e7d965e4b1b2e78c2c718f7861a2d7409 | anirudh1808/Python | /python_tut/dates_time.py | UTF-8 | 395 | 2.921875 | 3 | [] | no_license | import pytz
import datetime
date1=datetime.date(2019,7,24)
date2=datetime.date(2019,7,28)
tdelta=datetime.timedelta(days=5)
print(date1-date2)
print(date1+tdelta)
print(date1-tdelta)
tdelta2=datetime.timedelta(days=-5)
print(date1-tdelta2)
t=datetime.time(9,30,45,100)
print(t.minute)
dt_utcnow=datetime.dat... | true |
561c4896cb0bd8f51e425a9e17f4ec020cb982e6 | ValeryParfenov/infa_2021_baranov | /lab3/3_draw.py | UTF-8 | 1,194 | 2.890625 | 3 | [] | no_license | import pygame
from pygame.draw import *
WHITE = (255, 255, 255)
YELLOW = (255, 255, 51)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
pygame.init()
FPS = 30
screen = pygame.display.set_mode((700, 700))
screen.fill(WHITE)
pygame.draw.circle(screen, YELLOW, (350, 350), 100) #face
pygame.draw.circle(screen, BLACK, (350, 350),... | true |
3ecda0f03c7a3e5a96f11f473f89b422b0cda55c | MiracleHW/GAN-demo | /model.py | UTF-8 | 2,297 | 2.53125 | 3 | [] | no_license | import tensorflow as tf
import tensorflow.contrib.slim as slim
BATCH_SIZE = 64
def generator(z, train=True,reuse=None):
with tf.variable_scope("g_",reuse=reuse):
#h1 = tf.nn.relu(batch_norm_layer(fully_connected(z, 1024, 'g_fully_connected1'),is_train=train, name='g_bn1'))
h1=slim.fully_connecte... | true |
528c782bac3cb1a0f57f88ba1a431f2148d30d46 | HDRamosMendoza/Python-GIS | /ExampleAnalysis/Project/Seccion-2/2c-Erase.py | UTF-8 | 1,865 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Source: https://pro.arcgis.com/es/pro-app/tool-reference/analysis/erase.htm
# Nos permitira eliminar informacion que se intersecta.
# Autor : Ing. Daniel Ramos Mendoza
# Web : HDRamosMendoza.github.io/Perfil-Profesional
# Email : heber.daniel.ramos.mendoza@gmail.com
#... | true |
f8c9cc07d7afa0f9af251b5a4239dcd4b540b817 | keisuke-ito/Atcoder_program | /abc083_b.py | UTF-8 | 339 | 3.28125 | 3 | [] | no_license |
def findsum(n):
sum = 0 # 各桁の和
while n > 0:
q, mod = divmod(n, 10)
sum += mod
n = q
return sum
N, A, B = map(int, input().split())
arr = range(1,N+1)
sum = 0 # 条件内の各桁の和の合計
for i in range(N):
a = findsum(arr[i])
if A <= a <= B:
sum += arr[i]
print(sum) | true |
557c22bf5dc4a56865f323144c3e9e18a7433069 | tomohiro1221/mushikuizan | /main.py | UTF-8 | 801 | 2.640625 | 3 | [
"MIT"
] | permissive | from argparse import ArgumentParser
from mushikuizan.mul import Multiplication
def parse_args():
parser = ArgumentParser()
parser.add_argument('col_mult')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False)
args = parser.parse_args()
return args.col_mult, arg... | true |
4ef9c9b462c9037ba5fcc45d0f49e250417bc8a4 | AlejandroFernandezUCAB/Proyecto-Distribuidos | /Documentos Cluster/programasMPI/chksum/pchksum.py | UTF-8 | 2,206 | 2.96875 | 3 | [] | no_license |
#!/usr/bin/env python
"""
Crecion de archivo checksum en sha512 para todo un directorio
en paralelo.
"""
import sys
import hashlib
import os
from mpi4py import MPI
BUF_SIZE = 65536
def get_chksums(file_name):
md5 = hashlib.md5()
sha1 = hashlib.sha512()
with open(file_name, 'rb') as file_d:
while... | true |
bf5ed85b2df9fb2212162695d0cdcf07cf510bb2 | 8589/codes | /python/leetcode/dynamic_programming/91_Decode_Ways.py | UTF-8 | 861 | 2.9375 | 3 | [] | no_license | class Solution:
def numDecodings(self, s):
"""
:type s: str
:rtype: int
"""
if not s or s[0] == "0" or "00" in s: return 0
cur, pre1, pre2 = 1, 1, 1
for i in range(1, len(s)):
if s[i] == "0":
if i-1 >= 0 and int(s[i-1]) > 2:
... | true |
36b62c72da698dea758e09080cfbd01beb59d0c2 | PythonDayMX/MLaaS | /full/iris.py | UTF-8 | 1,430 | 3.03125 | 3 | [
"MIT"
] | permissive | # ===============================================================
# Author: Rodolfo Ferro
# Email: ferro@cimat.mx
# Twitter: @FerroRodolfo
#
# ABOUT COPYING OR USING PARTIAL INFORMATION:
# This script was originally created by Rodolfo Ferro, for
# his workshop in PythonDay Mexico 2018 at CUCEA in Gdl, Mx.
# Any explici... | true |
00009defa3281f0bcc00e95f96cb6ccb52343c3c | squeakus/bitsandbytes | /pyopenni/depth-old.py | UTF-8 | 1,104 | 3.4375 | 3 | [] | no_license | #!/usr/bin/python
## The equivalent of:
## "Working with Depth, Color and Audio Maps"
## in the OpenNI user guide.
## WARNING: This sample is deprecated and kept only
## for historical reasons. It's recommended to use the
## new way of calculating the index of a pixel;
## see depth.py instead.
"""
This creates a dep... | true |
699150aedb50c4d714c7ea4e9313eebfa7a952db | AminAnvari/LinearProgrammingProject | /user_output.py | UTF-8 | 227 | 2.765625 | 3 | [] | no_license | from print_table import print_table
from print_text import print_text
def user_output(window, ans, t, n, x):
if ans == 'Finished!':
print_table(window, 100, t, n, x)
else:
print_text(window, 100, ans)
| true |
b26b4a010106f31f70a62c4f585ca2de8696d1c9 | ywchiao/shot | /component/sprite_manager.py | UTF-8 | 560 | 3.15625 | 3 | [
"MIT"
] | permissive |
import pygame
class SpriteManager:
def __init__(self):
self._sprites = []
def load_sprite(self, fname):
# 取得 sprite sheet
sprites = pygame.image.load(f"{fname}").convert_alpha()
for i in range(3):
self._sprites.append(
sprites.subsurface(pygame.Rec... | true |
237bf3b9e6f4b16cd98df9345833e037b614c8ed | thebind/gcp-dataflow | /05_08_publish_demo.py | UTF-8 | 505 | 2.84375 | 3 | [] | no_license | #Import pubsub libraries
from google.cloud import pubsub
import time
#setup publisher client
publisher=pubsub.PublisherClient()
#setup topic to publish to.
topic='projects/universal-code-210021/topics/test-topic'
#Publish to topic 10 times with a sleep in between for 2 seconds.
for n in range(1,10):
... | true |
15e33d55a4778eefe6986d2056ed393fb2b0e6f3 | Psyche111/MiniScanner | /lib/sql.py | UTF-8 | 4,372 | 2.625 | 3 | [] | no_license | # coding = utf-8
# 数据库操作
import sqlite3
import time
import re
import logging
class Sqldb:
def __init__(self, dbname):
self.name = dbname
self.conn = sqlite3.connect(self.name + '.db', check_same_thread=False)
def commit(self):
self.conn.commit()
def close(self):
self.con... | true |
6949ae4add48373a8d27be11d36d62ae92541b8d | capncrockett/beedle_book | /Ch_07 - Decision Structures/babysitter_calc.py | UTF-8 | 2,538 | 4.0625 | 4 | [] | no_license | # babysitter_calc.py
# A program to calculate pay for a babysitter.
def main():
print("Babysitting Calculator")
print("Enter times in 24 hour format (e.g. 8pm = 20:00)")
start_hrs, start_min = input("Enter start time: ").split(":")
end_hrs, end_min = input("Enter end time: ").split(":")
s... | true |
7da08129d4dabc40d5bc45547aec501054975785 | atishjain9/Python_Practice | /ch3/15_grades.py | UTF-8 | 635 | 3.96875 | 4 | [] | no_license |
# Program to Print Grades
c=int(input("Enter C Language Marks:"))
java=int(input("Enter Java Programming Marks:"))
python=int(input("Enter Python Programming Marks:"))
total=c+java+python
avg=total/3
print("Total is:",total)
print("Average is:",avg)
if c>=40 and java>=40 and python>=40:
if avg>=60:... | true |
d91b73cced198a7de4d3e3c76ad162b0bf966585 | jmtaysom/Python | /CodeEval/digitsSum.py | UTF-8 | 229 | 2.8125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri May 13 11:58:52 2016
@author: jmtaysom
"""
import sys
with open('digitsSum.txt', 'r') as f:
for line in f:
print(sum((int(char) for char in line[:-1])))
sys.exit() | true |
972f83dc0cc82881f55ad0e02b86490b2669e91d | WilliamsTravis/revruns | /revruns/rrbatch_logs.py | UTF-8 | 3,850 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""Check all batch run logs for success.
"""
import json
import os
from glob import glob
import click
from colorama import Fore, Style
FOLDER_HELP = ("Path to a folder with a completed set of batched reV runs. "
"Defaults to current directory. (str)")
MODULE_HELP = ("The reV... | true |
76d44c6fd5f2f7f8a73a6149ac8216720b8e5d4e | joao-afonso-pereira/Stock_Price_Prediction | /regression.py | UTF-8 | 11,422 | 2.53125 | 3 | [] | no_license | import numpy as np
import os
import glob
import datetime
import pandas as pd
pd.options.mode.chained_assignment = None
from sklearn.preprocessing import MinMaxScaler
import random
from sklearn.linear_model import LinearRegression
import calendar
from sklearn import svm
from sklearn import neighbors
from skl... | true |
e66bd944bf3a7379d93c197905b4e96b08a039db | MoazMansour/data-structures | /open-hash.py | UTF-8 | 2,496 | 4.15625 | 4 | [] | no_license | #!/usr/bin/env python3
'''Hashed table class using lists and open addressing'''
class HashTable():
def __init__(self, size=3, n=0):
'''initate a hash table with an empty list'''
self.items = n
self.size = size
self.table = [None] * self.size
def hashKey(self, key):
'''... | true |
c4f1431f03129b2285ad73c308e30ba407c36240 | gjorgjinac/johnsons_algorithm_aps | /johnsons.py | UTF-8 | 2,127 | 3.140625 | 3 | [] | no_license | from bellman_ford import BellmanFord
from dijkstra import Dijkstra
from graph import WeightedDirectedGraph, WeightedEdge
def JohnsonAlgorithm(graph: WeightedDirectedGraph, verbose=True):
graph_edges_with_extra_node = graph.edges + [WeightedEdge('new_node', 0, node) for node in graph.nodes]
graph_with_extra_nod... | true |
ca1c016e59e8f8730b1b342d92da1f8d0a048666 | thortoyo/study | /ABC154/A.py | UTF-8 | 105 | 2.859375 | 3 | [] | no_license | S,T=input().split()
A,B=map(int, input().split())
U=input()
if S==U:
A -= 1
else:
B -= 1
print(A,B)
| true |
c8ba4eaa524b8f510a14ab5e6f5f891608777f5e | pollipayne/core-problem-set-recursion | /part-1.py | UTF-8 | 920 | 4 | 4 | [] | no_license | # There are comments with the names of
# the required functions to build.
# Please paste your solution underneath
# the appropriate comment.
# factorial
def factorial(num):
if num < 0:
raise ValueError
if num <= 1:
return 1
return num * factorial(num - 1)
# reverse
def reverse... | true |
c1948d7dc1e5416605cdddf2895486751f0b4913 | arjunmathur/auto-auction-scraper | /analyze_993.py | UTF-8 | 5,184 | 2.5625 | 3 | [] | no_license | import json
import re
import csv
import requests
import os.path
import datetime
from bs4 import BeautifulSoup, SoupStrainer
from concurrent.futures import ThreadPoolExecutor, as_completed
from tqdm import tqdm
BAT_RESULTS_URL = 'https://bringatrailer.com/porsche/993/'
RAW_AUCTIONS_FILENAME = 'raw_auctions.json'
RA... | true |
d7965766190d23dc1c1feeefa33c00f25bbce125 | davecarr1024/libfhe | /acce2/graphics/prims2d/rect.py | UTF-8 | 691 | 2.6875 | 3 | [] | no_license | from sceneNode import SceneNode
from OpenGL.GL import *
class Rect(SceneNode):
def onAttach(self):
SceneNode.onAttach(self)
self.defaultVar("filled",True)
self.defaultVar("center",False)
def geom(self):
if self.center:
glTranslatef(-0.5,-0.5,0)
... | true |
f4575b4234885e32effd34254752a0a40a6f1726 | danielcamp23/Autemde | /src/id_detector.py | UTF-8 | 11,987 | 2.671875 | 3 | [] | no_license | import cv2
import numpy as np
from PIL import Image
from sympy import symbols, Eq, solve
import matplotlib.pyplot as plt
def filter_image(img):
#median = cv2.medianBlur(img, 3)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #convert to grey to reduce detials
gray = cv2.bilateralFilter(gray, 30, 17, 17)#Blu... | true |
254efb1f8bd2d290aac248c190580e98fcf88414 | alokhegde2/passwordGenerator | /main.py | UTF-8 | 429 | 3.625 | 4 | [] | no_license | import random
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
symbols = "[]_-+=@!.,*/{}"
all = lower+upper+numbers+symbols
length = int(input("[+] Enter the strength of the password (must be more than 8)"))
if length< 8:
print("[+] Length of password is weak pleas... | true |
16dfb23d406ed85907598de5791ae53a9fa11868 | hyeon95y/Deep_Learning-Frank-Noe- | /TimelaggedAutoencoder_Challenge/TLE/Legacy_1.py | UTF-8 | 9,286 | 3.015625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from keras.utils import np_utils
# LOAD DATA
path = '/Users/HyeonWoo/Library/Mobile Documents/com~apple~CloudDocs/University/2018-1/';
with np.load(path + 'dimredux-challenge-01-data.npz') as fh:
print(fh.files)
data_x = fh['data_x']
validation_x = fh['val... | true |
71a500cc3f510051a749d324b71cbaeee9a167bd | shank54/Leetcode | /Validate IP Address.py | UTF-8 | 972 | 2.984375 | 3 | [] | no_license | class Solution(object):
def validIPAddress(self, IP):
"""
:type IP: str
:rtype: str
"""
def is_hex(s):
hex_digits = set("0123456789abcdefABCDEF")
for char in s:
if not (char in hex_digits):
return False
r... | true |
739fb4a76bd7ed3ae1867c9d55305c7e4e200cf0 | alibinfarooq/Text-Recognition | /codea.py | UTF-8 | 1,242 | 2.875 | 3 | [] | no_license | import cv2
import numpy as np
import pytesseract
def ocr_core(image):
test= pytesseract.image_to_string(image)
return test
img = cv2.imread('index.png')
# get grayscale image
def get_grayscale(image):
return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# noise removal
def remove_noise(image):
return ... | true |
adcb65d1e6f0786b0345f6406e7dc64bace17451 | podhmo/csvresumable | /csvresumable/__init__.py | UTF-8 | 1,341 | 2.546875 | 3 | [] | no_license | import operator
import csv
import itertools
from csvresumable.loader import Loader
from csvresumable.recorder import Recorder
from csvresumable.capture import capture # noqa
from csvresumable.consts import TMP_DIR
def DictReader(f, writename=None, resume=None, key=None, dir=TMP_DIR, *args, **kwargs):
reader = cs... | true |
5776ae25e2ada4ec91ac807dc28bc5876ba6649d | hatanakatakashi/flurs | /flurs/data/entity.py | UTF-8 | 1,553 | 2.84375 | 3 | [
"MIT"
] | permissive | import numpy as np
class Base:
def __init__(self, index, feature=np.array([0.])):
self.index = index
self.feature = feature
def encode(self, dim=None,
index=True, feature=True,
vertical=False):
if not dim:
dim = self.index + 1
x = n... | true |
f57d3c9aa1e73571333a1b81c0ca8adee47ea7da | barbikorn/pramern_scraping | /crawl_legal_new/stuff/db/crud.py | UTF-8 | 2,438 | 2.953125 | 3 | [] | no_license | import psycopg2
import dblib
class Crud :
def __init__(self,conn , tableName ):
self.conn = conn
all_template = dblib.readIni( "ini/table.ini" , tableName )
self.select_by_id_template = all_template['select_by_id_template']
self.select_by_condition_template = all_template['select... | true |
aedcb452eec616ddad72be1b8503bf31393cecf6 | 95subodh/Leetcode | /120. Triangle.py | UTF-8 | 711 | 3.953125 | 4 | [
"MIT"
] | permissive | #Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
#
#For example, given the following triangle
#[
# [2],
# [3,4],
# [6,5,7],
# [4,1,8,3]
#]
#The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).
#
#Note:
#Bonus point if ... | true |
6ae38dbb3e9bb089c5c455a768a649fc347cf718 | pariahGH/electrochemical_analysis | /fuel_cell_power_model/util.py | UTF-8 | 782 | 2.859375 | 3 | [
"MIT"
] | permissive | from scipy.optimize import curve_fit
import numpy as np
from locale import setlocale, LC_NUMERIC, atof
setlocale(LC_NUMERIC, "")
def generateFuelCellCurveFromPoints(points, scale):
[equation, popt] = gencurve(points)
t = 0
while True:
yield equation(t)
t+=1/scale
#assuming exponential form
def func(t, a, b... | true |
55cebdc17f46be8d3a32cf0414393f22a5120ca0 | intohole/b2 | /test/rand2.py | UTF-8 | 4,858 | 3.171875 | 3 | [] | no_license | # coding=utf-8
from random import randint
import sys
class SampleDatas(object):
def __init__(self, sample):
self.data = []
self.__idx = 0
self.__sample = sample
def reset(self, sample):
del self.data[:]
self.__idx = 0
self.__sample = sample
def __add__(... | true |
45ac06da9210df3900debbdde0bb67f238df00ee | jeanmmlima/Artificial-Intelligence | /RNA-python/RNA-pybrain/RNA-FeedForwardTest.py | UTF-8 | 1,716 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 10:20:11 2018
@author: jean
"""
from pybrain.structure import FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer
from pybrain.structure import FullConnection
from pybrain.datasets import SupervisedDataSet
from pybrain.sup... | true |
9c3b8a5210d3aff5121cf4d94e2c4c3aeee8035b | takumiw/AtCoder | /ABC003/C.py | UTF-8 | 287 | 2.828125 | 3 | [] | no_license | import sys
readline = sys.stdin.readline
def main():
N, K = map(int, readline().rstrip().split())
R = list(map(int, readline().rstrip().split()))
R.sort()
ans = 0
for r in R[-K:]:
ans = (ans + r) / 2
print(ans)
if __name__ == '__main__':
main() | true |
1db83a8a528a231327ea46bef87384e632c4f849 | nathanhorst/MD | /build/particles/addpolymer/hydrocarbon/rotate_polymer.py | UTF-8 | 3,396 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 08:52:46 2016
@author: waltmann
"""
from __future__ import division
import os
import sys
import numpy as np
from numpy import linalg as LA
###############################
##defines arctan on the entrire interval from (0,2pi) in order be used in angle
##difference fun... | true |
91b8912cd72673c528b43259e2691f858555a1c1 | kcaa/kcaa | /server/kcaa/kcsapi/repair_test.py | UTF-8 | 3,258 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | #!/usr/bin/env python
import pytest
import jsonobject
import repair
import ship
class TestRepairDock(object):
def pytest_funcarg__repair_dock(self):
return repair.RepairDock(slots=[
repair.RepairSlot(id=1, ship_id=100, eta=123),
repair.RepairSlot(id=2, ship_id=0, eta=0)])
d... | true |
cff8851f395dc1283c4a97e8d8515ae7f02a3cea | pdst-lccs/lccs-python | /Section 4 - Lists/List slicing 1.py | UTF-8 | 532 | 4 | 4 | [
"CC0-1.0"
] | permissive | # Event: LCCS Python Fundamental Skills Workshop
# Date: May 2018
# Author: Joe English, PDST
# eMail: computerscience@pdst.ie
# Purpose: A program to demonstrate list slicing
# A program to demonstrate list slicing
fruits = ['apple', 'pear', 'orange', 'banana', 'kiwi']
print(fruits[1:3]) # ['pear', 'orange... | true |
2f59f5cab1f8cac047c64a46241e06e9c23f71a8 | GeraltCN/study | /py/eightQueens.py | UTF-8 | 741 | 3.296875 | 3 | [] | no_license | def judgeBoard(board, newQueen):
if newQueen in board: return False #判断新皇后是否有同列
for queen in board : #判断新皇后是否在同一斜线
if abs(newQueen - queen) == abs(len(board) - board.index(queen)): return False
return True
def forGodsSake(boardForNow, boardSize):
if len(boardForNow) == board... | true |
31d4aad8cdee335c661b741b19d63536bea3a007 | LeonLenclos/Ognon | /ognon/control/layersorganizer.py | UTF-8 | 1,075 | 3.03125 | 3 | [] | no_license | """
This module provide control functions to create, delete layers into animation.
"""
from .. import model
from . import navigator
from . import change_project_state
from . import change_cursor_state
@change_project_state
def add_layer(cursor):
"""Add a new Layer to the anim."""
idx = cursor.get_pos('layer')... | true |
b7aa0eecbbc5ee552064df61f088491c5f5da72e | subotto/subotto | /subot.py | UTF-8 | 8,516 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Bot di Telegram per il Subotto
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, Job
from telegram import TelegramError
import logging
import requests
import sys
import time
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as pl... | true |
69c52f10fac57beb25e121856c5ad2bc5f8ad307 | geoin/ControlloVoliRT | /check_samples/src/config.py | UTF-8 | 1,284 | 2.59375 | 3 | [] | no_license | import ConfigParser, glob, os
class Data:
def __init__(self, path):
config = ConfigParser.ConfigParser()
# remove lowercase convrtion
# config.optionxform = str
config.read(path)
self.input = config.get("DATA", "IN")
self.output = config.get("DATA", "OUT")
s... | true |
e8234d6d7f1278ffcf87a6ed72117d49851e8eae | dfurrer/vergissminoed | /server/unittest_database.py | UTF-8 | 1,798 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
import os
import datetime
import copy
import socket
from database import Database
def main():
hostname = socket.gethostname()
if hostname == 'hpenvy':
data_dir='c:\\hackathon\\vergissminoed\\server\\data'
else:
raise RuntimeError('Hostname %s has not been handled.' % hostname)
... | true |
b77f0f162799e9589a40935e34fc392b19459052 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4424/codes/1836_1278.py | UTF-8 | 444 | 2.890625 | 3 | [] | no_license | from numpy import *
from numpy.linalg import *
mat=array([[0,2,11,6,15,11,1],[2,0,7,12,4,2,15],[11,7,0,11,8,3,13],[6,12,11,0,10,2,1],[15,4,8,10,0,5,13],[11,2,3,2,5,0,14],[1,15,13,1,13,14,0]])
soma=0
a=0
b=0
aux=111
vet=zeros(7,dtype=int)
for i in range(7):
vet[i]=aux
aux+=111
x=int(input(":"))
y=1
while(y!=-1):
... | true |
c141d90f6093381b1b820926f1a25a0ea44b4bdc | gebijiaxiaowang/leetcode | /other/45.py | UTF-8 | 569 | 3 | 3 | [] | no_license | #!/usr/bin/python3.7
# -*- coding: utf-8 -*-
# @Time : 2020/11/20 22:17
# @Author : dly
# @File : 45.py
# @Desc :
class Solution(object):
def jump(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
ans = 0
end... | true |
ff468d3d788ea9213b8a97c869d591f5a56170ae | Fryzu/MMWD | /unitTests/test_solution.py | UTF-8 | 1,123 | 3.078125 | 3 | [] | no_license | import unittest
from Solution import Solution
import os #files and directories
project_dir = os.path.dirname(os.path.abspath(__file__))
class TestSolution(unittest.TestCase):
@classmethod
def setUpClass(self):
self.solution = Solution()
#imports test_file.json and loads it to the solution
... | true |
af6056ea0ac420bdb0157a5edc582e53b1f57feb | Spiritsword/Python-Challenge-Business-Intelligence-2019 | /JonathanPuddicombePythonDeveloperTestSolution.py | UTF-8 | 17,205 | 3.359375 | 3 | [] | no_license | """
Please write you name here: Jonathan Puddicombe
"""
import csv
import operator
import math
from pathlib import Path
from pprint import pprint
# NB MUCH EXCEPTION CHECKING CODE WOULD NORMALLY BE REQUIRED
# BUT THIS HAS BEEN OMITTED AS THE TEST SPEC SAID 'NO ALERTS'.
# Functions to manipulate time for... | true |
87eb4687f9ca6f17638ed7eef5cab3ceebc8c0bc | michaelGorokhovsky/Python-Practice-Problems | /CH8 practice projects/mcb.pyw | UTF-8 | 1,074 | 2.984375 | 3 | [] | no_license | #! python3
# mcb.pyw - Saves and loads pieces of text to the clipboard.
# usage: py.exe mcb.pyw save <keyword> - Saves clipbord to keyword.
# py.exe mcb.pw <keyword> - Loads keyword to clipboard.
# py.exe mcb.pyw list - Loads all keywords to clipboard.
# py.exe mcb.pyw delete <keyword> - delete's keyword from... | true |
fe6a67ff95b1d0b06c3a0a32fb725c4fc8db85e9 | nino-famnit/FamnitBook | /getdata.py | UTF-8 | 1,280 | 2.84375 | 3 | [] | no_license | import requests
import re
r = requests.get('https://www.famnit.upr.si/en/about-faculty/staff/')
# print(r.text)
p = r"<tr id='person_(\d+)' class='(odd|even) '>(.*?)</tr>"
staff = re.findall(p, r.text, flags=re.DOTALL)
def extract_professor(s):
p2 = r"<td class='name'><a href='(.*)'>(.*)</a></td>\s*" + \
r"... | true |
2c572a1037fd1abf4b2803f1356e737f999b9011 | MelVimL/CAS19 | /fractories.py | UTF-8 | 8,816 | 3.09375 | 3 | [
"MIT"
] | permissive | import networkx as nx
import random as r
from actors import Actor
class Graphs:
def __init__(self):
pass
@staticmethod
def create_complete(**kwargs):
"""
Creates a completely connected graph.
:param n: number of nodes.
:return: a Graph with n Nodes and all connec... | true |
153e2b067f073a02633b546e263a86a53528dcf2 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_59/175.py | UTF-8 | 751 | 2.890625 | 3 | [] | no_license | T = int(raw_input())
for t in range (1,T+1):
(N,M) = map(int,raw_input().split())
existingPaths = []
toCreatePaths = []
completePaths = []
for i in range(0,N):
existingPaths.append(raw_input())
for i in range(0,M):
toCreatePaths.append(raw_input())
for existingPath in existingPaths:
while existi... | true |
bc416cfdb611854bb23fab43f11e8811622756a6 | tsonglew/learn-python | /Exercises/fork.py | UTF-8 | 173 | 2.671875 | 3 | [] | no_license | import os
f = open("ex.txt", mode="rb", buffering=0)
pid = os.fork()
print("getpid {:>5}, fork {:>5}, fd {}: {}".format(os.getpid(), pid, f.fileno(), f.read(6)))
f.close()
| true |
4c8a9e2376890c38ef42e73c57936a8c4bd831be | databand-ai/dbnd | /examples/src/dbnd_examples/tests/documentation/tracking/test_doc_functions.py | UTF-8 | 1,790 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | # © Copyright Databand.ai, an IBM Company 2022
from pandas import DataFrame
#### DOC START
# module1.py
def calculate_alpha():
pass
def calculate_beta():
pass
def calculate_gamma():
pass
#### DOC END
class TestDocFunctions:
def test_tracking_functions_with_decorator(self):
#### DOC ST... | true |
dedb083f98dc123db8b56937515aa9f6f0bce5fd | m2cci-NMZ/sasview | /test/sasrealspace/test/early_test.py | UTF-8 | 8,534 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | from __future__ import print_function
import VolumeCanvas
from sas.models.SphereModel import SphereModel
from sas.models.CoreShellModel import CoreShellModel
import math, time
def form_factor(q, r):
qr = q*r
f = 3*( math.sin(qr) - qr*math.cos(qr) ) / (qr*qr*qr)
return f*f
def test_1():
... | true |
d93e7c695fee7772387d34c50910a8c29235dc66 | techthiyanes/PARADE | /input_parser.py | UTF-8 | 2,778 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive |
import tensorflow.compat.v1 as tf
def input_fn_builder(dataset_path, is_training, max_num_segments_perdoc, max_seq_length):
"""Creates an `input_fn` closure to be passed to TPUEstimator."""
def input_fn(params):
"""The actual input function."""
batch_size = params["batch_size"]
output_buff... | true |
838bb55d2e9106b86a80f44c0dca611b42c01c1f | yoggi-yalla/aoc2020 | /24/solution.py | UTF-8 | 1,676 | 3.46875 | 3 | [] | no_license | from collections import defaultdict
def parse_instruction(line):
instruction = []
i = 0
while i < len(line):
if line[i] in ('s', 'n'):
instruction.append(line[i:i+2])
i += 2
else:
instruction.append(line[i])
i += 1
return instruction
dire... | true |
65cd8d4fef1d2316f9351fbd03481c3ccb4ed675 | 19828373863/am205_examples | /4_optimization/h_bfgs.py | UTF-8 | 603 | 3.359375 | 3 | [] | no_license | #!/usr/bin/python3
import numpy as np
import scipy.optimize as op
# Himmelblau function - a common example used for testing optimization algorithms
def f(z):
x=z[0];y=z[1]
return (x*x+y-11)**2+(x+y*y-7)**2
# Gradient of the Himmelblau function
def grad_f(z):
x=z[0];y=z[1]
return np.array([4*x*(x*x+y-1... | true |
8119eff6deaf6ef4f149502fc6312de7519d26d9 | a88169312/KM | /utiity/demo18.py | UTF-8 | 217 | 2.953125 | 3 | [] | no_license | l1 = [1, 3, 5, 7, 9]
l2 = l1
print(l1, l2)
print(l1 == l2, hex(id(l1)), hex(id(l2)))
l3 = l1[:]
print(l3, l1 == l3, l2 == l3)
print(hex(id(l3)))
l4 = list(l1)
print(l4, l1 == l4, l2 == l4, l3 == l4)
print(hex(id(l4))) | true |
5dfe00c6dd63ff9b24ffe9336608e3bc8b81728c | python4d/imd | /IMD3D/IMD3D/floatctrl.py | ISO-8859-1 | 11,453 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: iso-8859-15 -*-
'''
Module Cr le 19 dc. 2012
@author: Python4D/damien compilation de floatctrl.py et events.py du projet zoobie (cf note)
@note: http://nullege.com/codes/show/src@t@h@thezombieengine-HEAD@zombie@code@conjurer@conjurer@gui@floatctrl.py
'''
##\file floatctrl.py
... | true |
c80b84c867872e9703fd3e94287cfc74357998c7 | joepollastrini/Loan-Prediction | /Automation/applicant prediction.py | UTF-8 | 1,912 | 3.015625 | 3 | [] | no_license | ### This script will grab the applicant's data
### It will run the data through the model to predict the loan status
import os
import pandas as pd
import numpy as np
import pickle
# Variables #
direct = os.getcwd()
os.chdir('..')
parent = os.getcwd()
inputName = 'toModel.csv'
modelName = 'loan pred mod... | true |
883b46fdd95713272a813212fa6e6787ab6faecd | ericbrowne/PythonScripts | /sort.py | UTF-8 | 325 | 3.71875 | 4 | [] | no_license |
### An example of INCREMENTAL DESIGN ###
def sort(A,n):
print(f"Before Sort: {A}")
for i in range(1,n-1):
key = A[i]
j = i-1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1]=key
return A
A =[1,6,7,3,5,8]
print(sort(A,len(A... | true |
47f3629a4b472a0f4efa22e4e3d72156455965c0 | materechm/Math | /goldbach_triplets.py | UTF-8 | 2,671 | 3.328125 | 3 | [] | no_license | import csv
import math
class PrimeManager:
def __init__(self, fileName, path, path_1mod6, path_5mod6):
self.fileName = fileName
self.primes = []
self.triplets = []
self.relationships = {}
self.path = path
self.path_1mod6 = path_1mod6
self.path_5mod6 = path_5m... | true |
62ede1f35d72bef8204ca106948614e28ae1d99e | windard/leeeeee | /216.combination-sum-iii.py | UTF-8 | 1,415 | 3.328125 | 3 | [
"MIT"
] | permissive | # coding=utf-8
#
# @lc app=leetcode id=216 lang=python
#
# [216] Combination Sum III
#
# https://leetcode.com/problems/combination-sum-iii/description/
#
# algorithms
# Medium (52.54%)
# Likes: 674
# Dislikes: 34
# Total Accepted: 131.7K
# Total Submissions: 249.9K
# Testcase Example: '3\n7'
#
#
# Find all poss... | true |
ec3fe3fc8fc1070dfef2ec7ca4fbf5bbddcd852e | AirHug/clean-architecture-1 | /Operations/Add.py | UTF-8 | 185 | 2.890625 | 3 | [] | no_license | from Operations.Operation import Operation
class Add(Operation):
def __init__(self, x):
self.addend = x
def compute(self, result):
return result + self.addend
| true |
7e63fd7604e143e4ab749795ef325daf3179fae2 | jiangzhengshen/AlgorithmCollection | /Python/search.py | UTF-8 | 2,050 | 3.890625 | 4 | [
"MIT"
] | permissive |
class Algorithms:
@staticmethod
def binary_search(data_list, element):
begin_idx = 0
end_idx = len(data_list)
while begin_idx < end_idx:
mid = (begin_idx + end_idx) // 2
if data_list[mid] > element:
end_idx = mid
elif data_list[mid] < ... | true |
45ad76168b25b2e4f523135fbdba2e17a430549a | jefimenko/data-structures | /stack.py | UTF-8 | 936 | 4.03125 | 4 | [
"MIT"
] | permissive | class Level(object):
"""
Level class to be used by Stack class
Create a Level to reference another Level in a Stack
"""
def __init__(self, data, under=None):
self.data = data
self.under = under
class Stack(object):
"""
Stack class using the Level class for individual node
... | true |
ad411c83c0ef5cbf15de6b1bae1a66ff023edf39 | qingjiaqi/AutoTest | /APIautotest-python/api/testcases/test_api_register_login.py | UTF-8 | 4,694 | 2.78125 | 3 | [] | no_license | """
============================
author:MuSen
time:2019/6/14
E-mail:3247119728@qq.com
============================
"""
import os
import random
import unittest
from librarys.ddt import data, ddt
from common.read_excel import ReadExcel
from common.logger import logger
from common.config import conf
from common.constant i... | true |
29d01fa888add5141dec2e2f85534ba282be9b28 | JamesKrW/FederatedLearning-on-Mobile-Devices | /face_recognition/picDelete.py | UTF-8 | 764 | 2.59375 | 3 | [] | no_license | import os
import shutil
def photo_sampling(path):
for dir in os.listdir(path):
dirpath=os.path.join(path,dir)
copydir=os.path.join('./data1/train_data', dir)
testdir = os.path.join('./data/test_data', dir)
if os.path.isdir(dirpath):
count=0
for img in os.list... | true |
147a679a2275d998094c68214c503ef016925737 | Guppy16/Reinforcement-Learning | /RL_Book_Ex/Ex2-5.py | UTF-8 | 2,279 | 3.796875 | 4 | [] | no_license | """
Using non-stationary 10-armed bandit testbed
q_*(a) starts of as 1.
Then, each one takes an independent random walk,
by adding a X~N(0,.01^2)
2 Agents: (\epsilon = .1) \alpha_n =
1/n
0.1
Plot graphs of action value against time-step (upto t = 10^4)
"""
import numpy as np
import random
cl... | true |
1d198a6d0ae46e9feac1ab544f54dcdd8cce9ee4 | emilyhuynh98/graph-viewer | /Function.py | UTF-8 | 3,054 | 3.703125 | 4 | [] | no_license | from abc import ABC, abstractmethod
import numpy as np
class Function(ABC):
"""
This is an abstract class that describes what other functions that extend from it should do.
The only abstract method to be implemented by the 'concrete' classes is the y value.
Otherwise, all classes similarly require a get_parameter ... | true |
63d0d2798c9c15c6bd6e98273c08b1f9390d9a68 | Ramanathan1405/Python-programms | /Insertion_sort.py | UTF-8 | 838 | 4.1875 | 4 | [] | no_license | #Ramanathan Moorthy - 18201670
#Insertion Sort Function
def Insertion_sort(int_lst):
for i in range (1, len(int_lst)):
key = int_lst[i]
j=i-1
while j>=0 and key < int_lst[j]:
int_lst[j+1] = int_lst[j]
j -= 1
int_lst[j+1] = key
#Print Sorted List
print("Sorted List\... | true |
c446ac2b286dc973fdc15ef30ab968f2651ec557 | SherazKhan/mne-camcan | /camcan/library/utils.py | UTF-8 | 9,149 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | import copy
import mne
from mne.io.constants import FIFF
import numpy as np
def make_overlapping_events(raw, event_id, overlap, duration,
stop=None):
"""Create overlapping events"""
if stop is None:
stop = raw.times[raw.last_samp]
events = list()
for start in np.ara... | true |
a8d040d6eef0ea01f99e9ab1c9b4651e4d5cca7c | marcuskmlee/COMP9517Proj | /Fluo.py | UTF-8 | 1,039 | 2.625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2 as cv
from PIL import Image
import argparse
from utilis import *
def otsuThreshold(img, start, end):
blur = cv.GaussianBlur(img,(5,5),0)
# mask = cv.adaptiveThreshold(blur, 255, cv.ADAPTIVE_THRESH_MEAN_C,\
# cv.THRESH_BIN... | true |