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
e2b7e1ac77221ed317c74cf364ff86a2c5ba3ce6
pamhrituc/AI
/AI5/NeuralNetwork.py
UTF-8
1,749
3.140625
3
[]
no_license
from Neuron import * from Layer import * from Function import * input, output = readFromFile("data.txt") layer0Weights = [] layer0 = Layer(15, 6) #15 neurons with 6 inputs each; connects input w/ hidden for neuron in layer0.neurons: layer0Weights.append(neuron.weights) layer1Weights = [] layer1 = Layer...
true
aa737233825595c77499491d8b99da339f33aa4a
SongofG/Python_Basics
/circle_test.py
UTF-8
223
3.578125
4
[]
no_license
import circle def main(): r = float(input("what is the radius: ")) ar = circle.ar_circle(r) # circle.py -> ar_circle() print("Area:", ar) ci = circle.ci_circle(r) print("Circumference: ", ci) main()
true
e1a446e55f6ef1c94df621ef6c5fdd20ab32a7fa
loti-ibrahimi/WIT-CMU
/Code/proximity-test.py
UTF-8
806
2.71875
3
[]
no_license
#!/usr/bin/python ''' Setup: - sudo apt-get install bluez - sudo apt-get install python-bluez ''' from wia import Wia import bluetooth import time wia = Wia() wia.access_token = "" # Wia secret key. print ("Proximity Check") while True: print ("Checking " + time.strftime("%a, %d %b %Y %H...
true
d9b0df76266325526fee3395b7d9e675829bb6d3
Gackle/leetcode_practice
/41.py
UTF-8
878
3.546875
4
[]
no_license
# coding: utf-8 ''' 41. 缺失的第一个正数 算法的时间复杂度应为O(n),并且只能使用常数级别的空间 ''' class Solution: def firstMissingPositive(self, nums): n = len(nums) res = 1 if n == 0: return res for num in range(0, n): if nums[num] < 0: nums[num] = 0 if nums[n...
true
c7f14efc2d4ad148b22de718cbd7993a09fc7604
cs1201/AOC_2020
/util/generate_day.py
UTF-8
774
2.640625
3
[]
no_license
import sys import os import shutil import fileinput here = os.path.dirname(os.path.abspath(__file__)) target_dir = os.path.dirname(here) blank_py_file = os.path.join(here, "day_X.py") data_dir = os.path.join(target_dir, "data") if len(sys.argv) < 2: print("No day number given") sys.exit() # Create empty py f...
true
c31e182ba07ebb844a462d6bfc50a6c1088f2804
mcrors/SimPyInvoice
/tests/unit_tests/test_models.py
UTF-8
748
3.125
3
[ "MIT" ]
permissive
import pytest from app.models import User class TestUserShould: @staticmethod def test_password_setter(): user = User(password='cat') assert user.password_hash is not None @staticmethod def test_no_password_getter(): user = User(password='cat') with pytest.raises(Attr...
true
4bf6956b419240046ed12f0a6768e4db82a726d9
imsodin/academia_ai
/academia_ai/neural_network/layers/relu.py
UTF-8
448
2.703125
3
[ "MIT" ]
permissive
class ReLuLayer(object): # TODO: gaus distribution ''' ReLu: for some nonlinearity. o=max(0,i)''' def __init__(self, iid=-1): self.iid = iid def pprint(self): print("ReLu Layer with ID=", self.iid) def forward_prop(self, data, debug=False): self.i = (data >= 0) * data # f...
true
118dfbedb89ca55b85962d30d42ea77be78fae0b
HIT-jixiyang/offer
/剑指offer/66-机器人的运动范围.py
UTF-8
708
2.84375
3
[]
no_license
class Solution: def movingCount(self, threshold, rows, cols): # write code here board = [[0 for _ in range(cols)] for _ in range(rows)] def block(r,c): s = sum(map(int,str(r)+str(c))) return s>threshold self.count=0 def traverse(r,c): if no...
true
6592ddc845085b2ae720640e3824d3e349d3b02d
omidsrezai/empirical-mt
/pelic/gabors.py
UTF-8
2,462
3.171875
3
[]
no_license
import numpy as np def makeGabors(size, num_of_fq = 4, num_of_ori = 4, deg2pix=10/9., center=None): """Building the Gabor filter bank. It has been tested only for 4x4=16 filters.""" n_filters = num_of_fq*num_of_ori filters = np.zeros((size,size,n_filters*2))#.astype(np.complex64) x = np.arange(0, size...
true
d7568d80266a1a1005bb9c465b7fd86fee85306a
yalin1997/RealTime_System_HW
/timeline.py
UTF-8
4,603
3
3
[]
no_license
import json import numpy as np from os import listdir import os # 只允許讀取 json ALLOWED_PICTURE = set(['json']) threshold = 0.5 # 篩選副檔名 def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_PICTURE # 篩選副檔名 def allowed_file_Week(filename , day): return '...
true
cb3f9119d36a90d40568b1840a45f6e27df4876f
Limlin-Qs/MachineLearningAlgorithm
/classificationAnalysis/Neural_Networks/ELM.py
UTF-8
1,167
2.796875
3
[]
no_license
# -*- coding: UTF-8 -*- import numpy as np """ Author: limlin Contact: limlin95@126.com Datetime: 2021/9/8 22:40 Software: PyCharm Profile: 极限学习机是一种单隐含层的前馈神经网络,其效率高,正确率高,泛化性能强,从初学该算法至今一直有在使用。 """ #加载数据 def loadData(): train_x = [] train_y = [] fileIn = open('testSet.txt') for line in fileIn.re...
true
c0682b61dfbb8f6907cd07c7d9b8b644e1a51c35
MatheusGitMhub/AWS-Lambda-Function-Application
/reporte/misma_carga_v2.py
UTF-8
1,352
3.203125
3
[]
no_license
import pandas as pd def misma_carga_v2(df, concat_time=0.25): """ La funcion concatena las cargas de combustible para cosmos Parameters ---------- df : dataframe Contiene información acerca de las cargas de combustible concat_time : float DESCRIPTION. The default is 0.25. Defi...
true
c54cba62dc42c23e9198e628f21c05e47fbf609e
Matt2111/Pygame-Gui
/PyGui/Line.py
UTF-8
492
3
3
[]
no_license
from pygame.draw import line class Line: def __init__(self, gui, start, end, borderWidth, borderCol, z=0): self.z = z self.gui = gui self.start, self.end = start, end self.width = borderWidth self.colour = borderCol def draw(self): line(self.gui.displ...
true
0365b6444f3bb1396c934f6dbe5885f5d58208d8
moshekagan/Computational_Thinking_Programming
/frontal_exersices/recitation_solutions_5/ex3.py
UTF-8
572
3.828125
4
[]
no_license
divisors = [2, 5] size = int(input("Insert a list size: ")) my_list = [None]*size for i in range(0, len(my_list)): my_list[i] = int(input(str(i+1) + ". Insert number:")) print(str(my_list)) for i in range(0, len(my_list)): is_divided = True for j in range(0, len(divisors)): if my_list[i] % divi...
true
501a304f8ab69b41413d3d3adeccc12441174fd6
YannCarteret/lensed_SNe_time_delay
/Main_scripts/param_timedelay_plot.py
UTF-8
759
2.546875
3
[]
no_license
# define here some set of distribtuion that you want to study param = [("./sim/sim_results/tst.pkl", 30, "orangered",['','','','']), ("./sim/sim_results/tst2.pkl",30,"royalblue",['','','','']), ("./sim/sim_results/tst3.pkl",30,"seagreen",['','','','']), ] ###############################...
true
41530152a7482c6b1f9fc8a8fec8477ab4bcfbf2
bingohu92/Exotic-Option-Payoff-Tool
/GUI.py
UTF-8
39,822
2.984375
3
[]
no_license
import Tkinter import matplotlib.pyplot as plt import numpy as np import scipy.stats as ss import time import tkMessageBox #Black and Scholes def d1(S0, K, r, sigma, T): return (np.log(S0/K) + (r + sigma**2 / 2) * T)/(sigma * np.sqrt(T)) def d2(S0, K, r, sigma, T): return (np.log(S0 / K) + (r - sigma**2 / 2...
true
0cd812799dfbc6921fa9acd521e05f7777999c4b
esmou2/Kylearn-pytorch
/Dataloader/reactionattention.py
UTF-8
2,538
2.765625
3
[ "MIT" ]
permissive
import torch from torch.utils.data import Dataset, DataLoader from torch.utils.data.sampler import SubsetRandomSampler from Dataloader.samplers import BalanceSampler import numpy as np class ReactionDataset(Dataset): def __init__(self, f1_path, f2_path, y_path): super(ReactionDataset, self).__init__() ...
true
18cad9d6ddc9e462311c130586b89ac01bbd359d
thomai-sta/kth_thesis
/code/experiments/method_1/hmm_similarity.py
UTF-8
6,276
2.796875
3
[]
no_license
#!/usr/local/bin/python # -*- coding: utf-8 -*- # http://www.ece.tamu.edu/~bjyoon/journal/IEEE-SPL-2010-HMM-similarity.pdf import numpy as np import kld from discreteMarkovChain import markovChain def get_stationary(transmat): mc = markovChain(transmat) mc.computePi('eigen') # We can also use 'power', 'kry...
true
6f72e8b4dc6e432206d4204e91c7c6f09aaf004d
zhangybzbo/ColonHoleDetect
/centerline.py
UTF-8
16,506
2.515625
3
[]
no_license
import open3d import os import pickle import argparse import numpy as np from scipy import stats import matplotlib import matplotlib.pyplot as plt import time from collections import defaultdict from skimage import morphology from scipy import ndimage, interpolate, spatial SAMPLE_SCALE=1 def ComputeCovariance(demo, i...
true
0b35d4215c1c7da0952bfa3c98d829e3f74dc0b8
IsidorosTziotis/Second-Order-Optimality-in-Non-ConvexDecentralized-Optimization-via-Perturbed-GradientTracking
/node.py
UTF-8
9,574
2.71875
3
[]
no_license
import numpy as np import torch import torch.nn as nn from copy import deepcopy class Node: def __init__(self, node_id, K, M, rank, U=None, V=None): self.node_id = node_id # The id of the node in the graph object self.K = K # total number of users in the system self.neighbors = [] # list o...
true
8a33b40548d130264fa832cf7680e17d7fd29f9b
bullingtong/bullingtong
/assignments/assignment5/test_submit.py
UTF-8
1,522
2.671875
3
[]
no_license
import pytest from submitAssign import Submission, WrongFiletype from login import Login, FailLogin from checkGrading import GradeCheck, FailGradeCheck from comments import Comments, FailComments from averages import Averages, FailAverages def test_login(): username = "Ricky" password = "Bobby" print("\nChecking %s...
true
91e2a559a589e184676a17a3810a6f6b7146475d
Saket97/Symbolic-Parser
/msat.py
UTF-8
3,886
2.703125
3
[]
no_license
from z3 import * from init import * import copy def get_num_disabled_soft_constraints(m,num_soft_constraints,aux_const): num_disabled = 0 for i in range(len(aux_const)): num_disabled += int(str(m.evaluate(aux_const[i]))) return num_disabled def add_soft(constraint, solver): # print "constrain...
true
a0275ccc2babf467f44403ae28d73de04515aea4
mulhod/pylox
/pylox/Interpreter.py
UTF-8
17,976
2.765625
3
[]
no_license
import time from typing import Any, Dict, List, Optional, Union import pylox from .Environment import Environment from .ExprOrStmt import (Assign, Block, Binary, Call, Class, Expr, ExprVisitor, Expression, Function, If, Literal, Logical, Get, Grouping, Print, Return, S...
true
9a96d4bb53a7d8a6dfd717dbb006b2a50a09e3ee
Xalion/RoverSim
/engine/EngineHelpers.py
UTF-8
201
3.28125
3
[ "MIT" ]
permissive
def resolve_direction(x): direction_dictionary = { "NORTH": [1, 0], "SOUTH": [-1, 0], "EAST": [0, 1], "WEST": [0, -1] } return direction_dictionary.get(x)
true
e32ddfec201eee50472991d4b280af3a966d7d6a
Bobbadillio/mcts_tic_tac_toe
/player.py
UTF-8
719
3.28125
3
[]
no_license
import random from board import Board class Player(): def __init__(self): # Do nothing! Someday this should probably load a file or something # That will probably matter for a game that isn't trivially solved self.token = None self.randomizer = random.Random() def ready(self,t...
true
514ee59b16f2ac69fb094249b1895a5755799349
shaheming/leecode
/summer/2018_07_31/hamming-distance.py
UTF-8
592
3.046875
3
[]
no_license
class Solution: def canPartition(self, nums): """ :type nums: List[int] :rtype: bool """ total = sum(nums) if total % 2 != 0: return False p = total // 2 dp = [False for _ in range(total + 1)] dp[0] = True for n in nums: ...
true
8a6981834ca3918529d7422b3a55c887ea9567bd
zuzy/python_network_program_study
/demo/list.py
UTF-8
830
3.453125
3
[]
no_license
#!/usr/bin/python3 # coding: utf-8 vec = [2,4,6] print([x*x for x in vec]) print([x*x for x in vec if x > 3]) freshfruit = [' banana', ' loganberry ', 'passion fruit '] print([weapon.strip() for weapon in freshfruit]) vec1 = [1,2,3,4] vec2 = [5,6,7,8] # vec2 = [5,6,7] print([x+y for x in vec1 for y in vec2]) print...
true
aeb97ab21b2baaa34baa30d8f7a3b51fbbd64c86
blancaalcala/Api-recommendation
/src/post_functions.py
UTF-8
1,008
2.609375
3
[]
no_license
import requests import pandas as pd def createUser(username): url="http://localhost:8080/user/create" params={'username':username} user = requests.post(url,data=params).text return username,user def appendInfo(username,user_id,table): table = table.append({'INFO':username,'ID':user_id},ignore_inde...
true
7bc797968b392d1eb2db5eeb55d4d376d6761947
honeywang991/test01
/python9/homework_0807/human_vs_machine.py
UTF-8
3,117
4.625
5
[]
no_license
#5 人和机器猜拳游戏写成一个类,有如下几个函数: #1)函数1:选择角色 1曹操 2张飞 3刘备 #2)函数2:角色猜拳 1剪刀 2石头 3布 玩家输入一个1-3的数字 #3) 函数3:电脑出拳 随机产生1个1-3的数字,提示电脑出拳结果 #4)函数4:角色和机器出拳对战,对战结束后, #最后出示本局对战结果...赢...输,然后提示用户是否继续?按y继续,按n退出。 #5)最后结束的时候输出结果 角色赢几局 电脑赢几局,平局几次 游戏结束 import random class HumanVsMachine: fist_dict = {"1": "剪刀", "2": "石头", "3": "布"} rol...
true
fe2f790f7d957d1e89f14927dd246a83fdf7dc74
DenBlacky808/test_works
/code_wars_2.py
UTF-8
352
3.265625
3
[]
no_license
def find_outlier(integers): even_list = [] odd_list = [] for num in integers: if num % 2 == 0: even_list.append(num) else: odd_list.append(num) odd_list.append(num) if len(even_list) > 1: return odd_list[0] if len(odd_list) > 1: ...
true
83e311baa8a730dbe6d089c94414371b8f5f340a
VojtaSara/MFFStudium
/Year2_Semester2/AutomatyGramatiky/AutomatyGramatikyDU1_2.py
UTF-8
858
3.296875
3
[]
no_license
# vytvoření automatu m3= DFA() # definice abecedy m3.setSigma(['a','b']) # vytvoření stavů m3.addState('0') m3.addState('a') m3.addState('b') m3.addState('ab') m3.addState('abb') m3.addState('abba') m3.addState('ba') m3.addState('bab') # nastavení počátečního stavu m3.setInitial(0) # přidání přijímacích stavů m3.addFin...
true
eed75b031c2b3456f146d3aee71b380b6528a8dd
sagelga/prepro59-python
/133_BadApple.py
UTF-8
994
3.546875
4
[ "MIT" ]
permissive
"""This program will ask input then, run the program, later then print out the results""" def major_branch(): """This is the main fuction. It will do everything.""" players = int(input()) global player_a global player_b while player >= 2: a-counter() b-counter() ma...
true
2ce2b38bb2eb2649c77240a6b36e05816163edf5
GeorgeDanicico/Fundamentals-of-Programming-Year1
/Fundamental Of Programming/Lab12/recursive.py
UTF-8
1,751
4
4
[]
no_license
def print_solution(solution, array, length): paranthesis_string = '' for i in range(length): if array[i] == 1: paranthesis_string = paranthesis_string + '(' else: paranthesis_string = paranthesis_string + ')' solution.append(paranthesis_string) def is_solution(len...
true
2c64c96982b021db830c37cfafb66ccc0a4c33b9
HHMoon13/FUWS-uWSInc-uWSIncPlus
/UtilityTechniques/WAMCalculation.py
UTF-8
529
2.578125
3
[]
no_license
from Parameters.ProgramVariable import ProgramVariable from Parameters.Variable import Variable class WAMCalculation(): upto_wSum = 0.0 upto_sum = 0.0 @staticmethod def update_WAM(): for itm in ProgramVariable.cnt_dic: wgt = ProgramVariable.wgt_dic.get(itm) cnt = Progr...
true
a5e61c81a2c36eb87530f158fb4fbc0ab2092260
deppe/SpaceShooter
/SpaceGame/enemy.py
UTF-8
347
2.8125
3
[]
no_license
import pygame from bouncyobject import GenericBouncyObject class Enemy(GenericBouncyObject): def __init__(self, side, vector, color): GenericBouncyObject.__init__(self, side, vector, "enemy.png") pixelArray = pygame.PixelArray(self.image) pixelArray.replace((255,255,255), color) ...
true
e7fbb8842832ee89e455ae778353fcc84d8d026c
tggithub619/Codewars_Python
/8 kyu Grasshopper - Summation.py
UTF-8
214
3.140625
3
[]
no_license
#https://www.codewars.com/kata/55d24f55d7dd296eb9000030/train/python def summation(num): s = 0 for i in range(0,num + 1): s+= i return s def summation(num): return sum(range(1, num + 1))
true
87ddbce1b8d805e523d8289a308ad13f2055dbf2
marvinamorim/sw_code_alert_bot
/main.py
UTF-8
946
2.515625
3
[]
no_license
from time import sleep import dataset import schedule import requests from config import settings from telegram import send_code db = dataset.connect(settings.DATABASE_URL) table = db[settings.CODES] def get_rewards(rewards): rewards_text = "" for reward in rewards: rewards_text += f'{reward["Quan...
true
009a8d7eabf2ce42b778ee6f0b9cd16b74b447cd
xugaoxiang/learningPyQt5
/p27_显示matplotlib图表/main.py
UTF-8
1,761
2.96875
3
[]
no_license
import sys import matplotlib matplotlib.use('Qt5Agg') from PyQt5 import QtWidgets from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure # 在PyQt5中显示matplotlib,它的原理就是使用FigureCanvasQTAgg作为后端(backend),将plot渲染成简单的bitmap图片 class M...
true
2b6d74238faf28e27dfd613b0765596f1ef8db70
MTG/mtg-jamendo-dataset
/scripts/filter_toptags.py
UTF-8
2,311
2.53125
3
[ "Apache-2.0", "CC-BY-NC-4.0", "LicenseRef-scancode-unknown-license-reference", "CC-BY-NC-SA-4.0" ]
permissive
import argparse import commons import get_statistics import util def filter_tags(tracks, tags, tag_threshold, directory=None, tags_file=None): if directory is not None: util.mkdir_p(directory) # TODO: refactor to properly handle and not disconnect category+tag tags_merged = {} tags_with_pref...
true
aa2389cc60dc0d8aaaa37bbde498b573825f0017
lv10/bestbuyapi
/bestbuyapi/api/bulk.py
UTF-8
3,123
2.625
3
[ "MIT" ]
permissive
import json import zipfile from io import BytesIO from ..constants import BULK_API from ..api.base import BestBuyCore from ..utils.exceptions import BestBuyBulkAPIError class BestBuyBulkAPI(BestBuyCore): def _api_name(self): return BULK_API def archive(self, name, file_format): """BestBuy ge...
true
8a95db4cb6525e24cf2001c34800a1b9ca82275c
hupantingxue/advancedpython
/thread/multi_thread_with_lock.py
UTF-8
717
3.21875
3
[ "Apache-2.0" ]
permissive
#-*- coding: utf-8 -*- import thread import time def loop(nloop, nsec, lock): print("start loop", nloop," at ", time.ctime()) time.sleep(nsec) print("finish loop", nloop," at ", time.ctime()) lock.release() def main(): print("Process start at ", time.ctime()) loops = [4, 2] nloops = len(lo...
true
9eb00d9a10e031a039c002f04434cb1a416bd0f7
surajshrestha-0/Python_Basic_I
/Data Types/Question36.py
UTF-8
213
3.9375
4
[]
no_license
""" Write a Python program to sum all the items in a dictionary. """ def sumDict(input_dict): return sum(input_dict.values()) sum_dict = {'value1': 10, 'value2': 20, 'value3': 30} print(sumDict(sum_dict))
true
35454df04aaad0b4cb70db65a53cee04ecb752f5
hosseinkshvrz/git-mining
/filter.py
UTF-8
1,834
2.6875
3
[]
no_license
import time from os.path import join, dirname import pandas as pd import requests path = dirname(__file__) data_dir = join(path, 'data') class Filter: def __init__(self, path): self.df = pd.read_csv(path) self.base_url = 'https://api.github.com/repos/apache/activemq/commits/' @staticmethod ...
true
0302e4cd45142a138ca16e11e3aad23a60b1687c
40309/variables
/Moodle/Example 1.py
UTF-8
93
3.640625
4
[]
no_license
first_name = input("Please enter your name: ") print("Hello, {0}!".format(first_name))
true
8d075113665ce6f9bc667e89feab9808f3397e13
soft9000/PyDAO
/SqltDAO/UpdateTestCase.py
UTF-8
3,484
2.671875
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 ''' Generated by Soft9000/PyDAO, Ver. 1.01 (Alpha) Generated @ Fri Jun 7 07:37:30 2019 ''' from collections import OrderedDict import sqlite3 class MyTable: def __init__(self): self.db = '/d_drive/USR/code/Python3/PyDAO-master/SqltDAO/MyTable.sqlt3' self.conn = None ...
true
59cb79dc86d3a717115671ce14af397625c7c4ad
asmaamirkhan/AppliedDataScienceSpecialization
/3-AppliedMachineLearning/2-SUPERVISED-LEARNING-P1/AsmaaSVM.py
UTF-8
5,713
3.078125
3
[]
no_license
# author: Asmaa ~ 2019 # Coursera: Applied Machine Learning # WEEK2 - Supervised Learning - Support Vector Machines # import libraries from sklearn.datasets import make_classification, make_blobs import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.svm import SVC, LinearSV...
true
979860fca035e84f3174fda483f58a4fb21df6b9
DragonZ2013/Sem1_FP
/Lab1-2a/main.py
UTF-8
436
3.421875
3
[]
no_license
def isprim (val): if(val<2): return False if(val==2): return True if(val%2==0): return False i=3 while i*i<=val: if(val%i==0): return False i=i+2 return True def a1 (val): if val>=0: print("2") nr=3 i=1 while i<val: ...
true
287cbfa9976a4f08b1d3b5b8195409a81ab3a4a1
bitcraft/chimp20
/chimp.py
UTF-8
5,894
2.734375
3
[]
no_license
import os os.environ['PYSDL2_DLL_PATH'] = os.path.dirname(__file__) import sys import time import sdl2 import sdl2.ext from sdl2.ext.compat import * from ctypes import c_uint32, c_int, byref SDL_PRESSED = 1 def load_texture(renderer, name, colorkey=None): fullname = os.path.join('data', name) fullname = byt...
true
e53c603a97f4d89402057f4b7911c5d67a011665
MariinoS/projectEuler
/problem9.py
UTF-8
940
3.921875
4
[]
no_license
# Project Euler: Problem 9 Source Code. By MariinoS. 7th Feb 2016. # Task: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a^2 + b^2 = c^2 # For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. # There exists exactly one Pythagorean triplet for whi...
true
234ece0088970f4eb8965f75377bc731d79b7a98
17b01a0534/DornalaRevathi
/rummy.py
UTF-8
7,757
2.78125
3
[]
no_license
def check_pure(L) : if check_pure_equal(L) : return True c = 0 c = check_pure_half1(L) + c c = check_pure_half2(L) + c if c == 2 : return True else : return False def check_pure_half2(L) : c = 0 if len(L) == 4 : if L[0][0] == L[1][0] == L[2][0] == L[3][0]...
true
ffa32209cd8c0888cd8a8916d81432946535f229
drproduck/dnm
/sampling/stochastic_block_model.py
UTF-8
992
2.890625
3
[]
no_license
"""make artificial data using stochastic block model""" from numpy.random import * import matplotlib.pyplot as plt import numpy as np import networkx as nx K = 7 M = 100 # phi = np.random.randint(1,10,size=K) phi = np.array([10]*K,dtype=float) alpha = 1 beta = 10 # cluster parameter theta = np.random.beta(alpha,beta,...
true
ec2454290ef9040dd42252df4b9d8db7b08f4653
himanshu0137/codechef
/TSORT.py
UTF-8
123
3.15625
3
[]
no_license
a = [] n = int(raw_input()) for i in xrange(n): a.append(int(raw_input())) a.sort() for i in xrange(n): print a[i]
true
4b93573d089ced2f558dd0bcca4266d86a506859
moumitaghanti/Py-Me-Up
/Python Homehork/pybank/pybank1.py
UTF-8
2,373
3.328125
3
[]
no_license
# Modules import os import csv filename = os.path.join( "budget_data.csv") output_file= os.path.join( "budget_data_out.csv") header = [] rows = [] total = 0 cnt = 0 change = 0 total_change=0 profit_loss = [] date_rev =[] maxrev = 0 minrev = 0 with open(filename, newline="") as csvfile: csv...
true
e7fdb9974f18d9a3ec788da628e499c1404f75fb
chrislengerich/zero
/eval.py
UTF-8
4,672
3.15625
3
[]
no_license
import numpy as np import copy from loader import Dataset import tqdm def eval_loop(model, data_loader, use_cuda=True): tq = tqdm.tqdm(data_loader) losses = [] for i, (x, y) in enumerate(tq): if use_cuda: x = x.cuda() y = y.cuda() out = model(x) if i == 0: ...
true
522e5f518044392e7be03f50905ca95ea6d29dac
sumajali/Learning-Python-
/dictionaries/access_items.py
UTF-8
1,143
4.09375
4
[]
no_license
# accessing items this_dict = {"name":"gunasekhar R", 'age':23, 'door_no': 20.3, 'boo':True} print(this_dict["name"]) #Example2 this_dict = {"name":"gunasekhar R", 'age':23, 'door_no': 20.3, 'boo':True} access = this_dict["age"] print(access) # get() is the another method of accessing items in the dict. this_dict = ...
true
9b9b12505a6c5276eadd766513eccf834783d2ea
PullBack993/Python-Advanced
/4. Comprehensions - Exersice/04. Number Classification.py
UTF-8
550
3.90625
4
[]
no_license
# Input # 1, -2, 0, 5, 3, 4, -100, -20, 12, 19, -33 nums = [int(el) for el in input().split(", ")] positive = [] negative = [] even = [] odd = [] for num in nums: if num >= 0: positive.append(num) else: negative.append(num) if num % 2 == 0: even.append(num) else: odd.ap...
true
52bcd966a14397dfd1bd72395fc7cbae4d5c2878
sgandhi9/Yelp-Review-Highlights-Extractions-for-Menu-Recommendation
/ngramscode.py
UTF-8
3,068
3.171875
3
[]
no_license
import nltk from nltk.util import ngrams from nltk.tokenize import sent_tokenize from nltk import load """ The script includes the following pre-processing steps for text: - Sentence Splitting - Term Tokenization - Ngrams - POS tagging The run function includes all 2grams of the form: <ADVERB> <ADJECTIVE>...
true
ac7eb12cf395d11ec48ce9d416d0df1be7db0956
ZHOUXINWEN/LCZ42
/AnalysisTools/Plot_Embeding.py
UTF-8
3,895
2.859375
3
[]
no_license
""" ============================================================================= Manifold learning on handwritten digits: Locally Linear Embedding, Isomap... ============================================================================= An illustration of various embeddings on the digits dataset. The RandomTreesEmbed...
true
5b78a8a2af7f12afdc96db8e815e8a16e37dba39
azizsaad/55-CodeWars-Problems
/codewars/6 kyu/your_order_please.py
UTF-8
389
3.015625
3
[]
no_license
def order(sentence): if sentence == '': return '' var2 = sentence.split(' ') print (var2) dict = [str(i) for i in range(1,10)] result = [i for i in range(len(var2))] for i,x in enumerate(var2): for letnum in x: if letnum in dict: result[int(letnum)-1] ...
true
ecacc609d8cd5c330bbd46b101e7804ba2a2a726
lszyman/PressNotePropagation
/cluster.py
UTF-8
1,878
2.8125
3
[]
no_license
# -*- coding: utf-8 -*- #!/usr/bin/env python import codecs from pressnote import PressNote from nltk.stem.snowball import SnowballStemmer class Cluster: def __init__(self, id, tags): self.ID = id self.tags = tags self.stemm_tags = list(set(self.get_stemm_tags(tags))) self.pressnotes = [] def __repr__(sel...
true
2fde0154822af6bf289f6681dbf42ee4294ee4d9
HenryBalthier/Python-Learning
/Leetcode_easy/twopointer/125.py
UTF-8
697
3.8125
4
[]
no_license
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ s = s.lower() l = len(s) if not s: return True left = 0 right = l-1 while left < right: if not s[left].isalnum(): ...
true
77a140c57e143c66cd28f45247f21697ebcb8fae
DocDriven/tflite_tests
/keras_conversion.py
UTF-8
1,477
2.65625
3
[ "MIT" ]
permissive
import tensorflow as tf import numpy as np ### CONVERSION keras_file = 'vae_test.h5' dataset = np.random.rand(100, 90).astype(np.float32) def representative_dataset_gen(): for i in range(100): yield [dataset[i:i+1]] converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(keras_file) converter.represe...
true
7365d77f4f2fc9c88c0820b2721906727d21d2f1
indico/indico
/indico/web/fields/base.py
UTF-8
5,038
2.53125
3
[ "MIT" ]
permissive
# This file is part of Indico. # Copyright (C) 2002 - 2023 CERN # # Indico is free software; you can redistribute it and/or # modify it under the terms of the MIT License; see the # LICENSE file for more details. from copy import deepcopy from wtforms.fields import BooleanField, StringField, TextAreaField from wtform...
true
1b092fa91e3ccd3f6cf2606f20f61e218b734715
Grz3hu/GameOfLife
/cli.py
UTF-8
1,418
3.453125
3
[]
no_license
from os import system import time import game import tests import ast def printBoardNum(board,size): for i in range(size): for j in range(size+1): if j==size: print("{}".format(i)) else: print(board[i][j],end='|') for i in range(size): pr...
true
0c66577564e8b112b87fb6e4a04e753fab999df3
zhczhong/Yatsen-lion-mnistOcr
/test.py
UTF-8
1,220
2.59375
3
[]
no_license
import cv2 import numpy as np from sklearn.externals import joblib import numSplit if __name__ == '__main__': img = cv2.imread( '1.jpg', 0 ) #read image res = numSplit.splitNum(img) #split the num in image,return position(x,y),width,height clf = joblib.load( './model/finalKnnOcr.pick...
true
ffa411e8020dae873e657f8f6269161b8cba1ab3
Pusnow/KS-X-1026-Python
/tests/test_enclosed.py
UTF-8
2,856
2.96875
3
[ "MIT" ]
permissive
""" Tests for Enclosed CJK Letters and Months """ from __future__ import unicode_literals from ksx1026 import uchar, normalization import unittest import unicodedata import six class EnclosedTest(unittest.TestCase): def setUp(self): self.parenthesized = list( six.unichr(x) for x in range(int("...
true
58339d8f435a51438a0a253b4ebcdce363f980c1
atulb123/PyTestDemoFramework
/testcases/Test_Login.py
UTF-8
1,024
2.5625
3
[]
no_license
from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions import pytest from pages.LoginPage import LoginPage from utils.ReadJson import ReadJson class Test_Login: @pytest.mark.smoke def test_verifytTitle(self,setup): self.driver,self.wait=setup ass...
true
bfa7fe76c0451fc86a94ed884338f3db88761dc1
odysseusmax/ktu-notifications
/app/notifications.py
UTF-8
2,774
2.515625
3
[]
no_license
import re import traceback import logging import aiohttp from yarl import URL from bs4 import BeautifulSoup, element base_url = URL("https://www.ktu.edu.in") ktu_url = base_url.join(URL("/eu/core/announcements.htm")) headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Fire...
true
b27dfdfa3b95c712b6646729d1f6b800ecef4bd8
qiiyang/SETI2016
/Q. I. Yang/02. midterm/ifft.py
UTF-8
1,667
2.875
3
[]
no_license
# Attempt to detect squiggles by fft # for matplotlib python-2 compatibility from __future__ import (absolute_import, division, print_function, unicode_literals) import six import os import numpy as np import scipy.misc import scipy.fftpack as fft import matplotlib.pyplot as plt # Global "con...
true
aa04fe67e3c3a655a19258b2337313eedc2bef6e
Nazgul2k/SF_DS
/sf_module_0/Game.py
UTF-8
2,025
3.953125
4
[]
no_license
import math #подключаем библиотеку, чтобы использовать метод округления вверх def game_core_v3(number, A, B): # в функцию передаем загаданное число из диапазона от A до B # Определяем серидину интервала - это первое предсказание. count = 1 predict = A + round((B-A)/2) predict_step = round((B-A)/2)...
true
df792091204eac487c8b211d3ec8dafbab3dab17
auriod/training-projects
/python-gui-trave-agency/classes/orders_window.py
UTF-8
9,598
2.546875
3
[]
no_license
import tkinter as tk from tkinter import ttk from tkinter import messagebox as mb import sqlite3 import datetime ####################################### # SETTING # ####################################### main_color = '#2E9AFE' btn_color = 'white' font_select = 'Vernada 10' font_main = 'Aria...
true
13039ccc38ced9df159ba64b6b0b080993785d41
seallard/walker
/tests/test_network.py
UTF-8
2,684
2.671875
3
[ "MIT" ]
permissive
from neat.genome import Genome from neat.network import Network from neat.enums.node_types import NodeType from unittest.mock import Mock from math import exp def sigmoid(x): return 1 / (1 + exp(-4.9*x)) def test_create_nework(standard_config, tracker): genome = Genome(id=1, config=standard_config, tracker=t...
true
739053c2b20d24c2fc8b37c43ff0de8de8c3cbcd
CarnegieLearning/MathFluency
/src/generators/generator_l03.py
UTF-8
4,814
2.921875
3
[]
no_license
import core import items import random import fractions import operator #Shortcut abbreviations RI = random.randint RC = random.choice F = fractions.Fraction #Globals LOAD_PREVIOUS_CONFIG = 0 SAVE_CURRENT_CONFIG = 0 GENERATE = 1 #generator specific configuration settings #EXPECTS: engine string, hea...
true
4adcbf7f0e8fc4a3d4b94c6b693fa4197f098cc4
hoon4233/Algo-study
/2021_spring/2021_03_29/1744_GU.py
UTF-8
1,604
3.53125
4
[]
no_license
import sys # 2개 묶을 수 있다 최대? # 음수 / 0 / 양수 # 음수 * 음수 = 양수 # 1과 2는 곱하는 것보다 더하는게 크다 !!!!!!!!!! N = int(sys.stdin.readline()) num_list = [] positive = 0 zeros = 0 negative = 0 for _ in range(N): tmp = int(sys.stdin.readline()) if tmp > 0: positive += 1 elif tmp < 0: negative += 1 num_lis...
true
bd3c795d4b7018ffd89b7770c730842595fd61a4
DjohanP/progjar
/ERRORHANDLING/lib.py
UTF-8
312
3.265625
3
[]
no_license
def spl(asx): try: a,b,c=asx.split(" ") return 1 except ValueError: return 0 def fungsi(jenis,x,y): try: if(jenis=='MUL'): return int(x)*int(y) elif(jenis=='ADD'): return int(x)+int(y) elif(jenis=='SUB'): return int(x)-int(y) else: return 'ERR' except ValueError: return 'ERROR'
true
4722d3691143cfcf68e26e21b7d55de7ff7472a0
fingerman/python_fundamentals
/python_bbq/proj_minfin/check_csv.py
UTF-8
813
2.546875
3
[]
no_license
import os import csv tar_folder = 'F:\mfleak\databg\ALL_BREACH' dir_tree = os.walk(tar_folder) n = 0 for k, v, list_csv_files in dir_tree: for csv_file in list_csv_files: with open(os.path.join(k, csv_file), encoding='utf') as f: reader = csv.reader(f) data = [r for r in f] ...
true
983c6eb20b4c49f06b01069aa6cafab96216fb3f
Monni/RaspberryPi-3G-Drone
/tests/test.py
UTF-8
10,677
2.515625
3
[]
no_license
import unittest from unittest.mock import MagicMock import numbers from drone import * class droneTests(unittest.TestCase): # Setup method to create a test object def setUp(self): self.drone = drone() print ("setUp") # Teardown method to delete the test object def tearDown(self): ...
true
9d445b39119fe870d8630435068046ff2cd08409
AnamFarooque/Prediction-and-Analysis-of-Students-grades-using-Cluster-Algorithm
/task.py
UTF-8
7,092
2.6875
3
[]
no_license
#graphing animation #import matplotlib.animation as animation import pandas as pd from sklearn.cluster import KMeans import sklearn.metrics as sm #get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib import numpy as np import matplotlib.pyplot as plt from sklearn import metrics from sqlalchemy import...
true
fe9e66a6f4384b772de7504de06fe4d5daef73b3
Dpentester/Automation_with_Python
/FacebookLoginAutomation.py
UTF-8
816
2.84375
3
[]
no_license
# import webdriver from selenium import webdriver # import email and password from credentials from Credentials import email, password # import time import time # Initialize the dirver to open the browser driver = webdriver.Chrome() # Maximize the window driver.maximize_window() # Provide URL to navigate driver.ge...
true
9fa6de66b48df1e0649f7c52dd9979b9b4f93dbb
will-henney/bowshock-shape
/Dust-wave/dragoid_shape.py
UTF-8
2,745
2.796875
3
[]
no_license
import sys import numpy as np from astropy.table import Table import statsmodels.api as sm from bow_projection import Spline_R_theta_from_grid class Dragoid(object): def __init__(self, alpha, mu=None, lowess_frac=None): if mu is None: astring = 'dust-couple-stream' else: ast...
true
52cc28123a805411e6ec1910f926629868ba8120
Supersund/splitStakeSimulation
/main.py
UTF-8
10,087
3.203125
3
[]
no_license
import hashlib import time import random from block import Block from stake import Stake """ A simulation of a proof of stake blockchain network using the timestamp and utxo (address of previous winning stake) as kernel. The simulation aims to show the improvement of cooperation between stake owners in a low trust req...
true
15f3e4b89ec637f2b03e98955b4fbc4dfa4f5f9e
JonhFiv5/aulas_python
/aula_64_getters_setters.py
UTF-8
1,910
4.0625
4
[]
no_license
class Produto: def __init__(self, nome, preco): self.nome = nome self.preco = preco # Getters ------------------------------------------------------------------ # Os getters possuem o decorador @property definidos acima deles # outra particularidade, tanto em getters quanto setters, é ...
true
a0fce1174f4deed49779def466f18ff6475c1c4e
hoppfull/Learning-Python
/Advanced/design patterns1/ex10 - composite/main.py
UTF-8
901
3.765625
4
[ "MIT" ]
permissive
"""Composite Design Pattern (Made in Python 3.4.3) This pattern is a way of organizing hierarchies. The pattern is simple. But how I implement it is a different story. This might need to be reworked! """ class Leaf: # Contains no children def __init__(self, name): self.name = name self.description = "No descript...
true
c44639db099596d28ac733554bf023451135118f
karan306/CourseWork
/CS252/Sound Based Telecomm System/Networks (2)/decoder.py
UTF-8
332
2.65625
3
[]
no_license
def decoder(List): Final=[] prev = 3 for i in List: if i == prev: continue elif (i == 3 or i==2): prev=i else: Final.append(i) prev=i return Final def nearer(x): diffs=map(lambda k: abs(k-x),constants.frequencies) if __name__ == '__main__': print decoder([1,1,1,1,2,2,2,1,1,1,0,1,0,0,1,1,0,0,0...
true
74d0dda0ac40290d29638e9e739c7b32c83d7218
EricRob/spindle
/CHARLES_convertDT.py
UTF-8
2,445
2.75
3
[]
no_license
import sys # Finds the text in the middle of two bracketed clauses # removeBracketed('<tag>example</tag>') returns example def getContent(line): curr = 0 beginning = -1 ending = -1 for c in line: if(beginning == -1): if(c == '>'): beginning = curr + 1 else: #beginning set already if(c ==...
true
2fa2001d5dce27ae874a254706754a04bb0e034a
T-13/DroneTasks
/UVRG_Trilateration/trilateration_sync.py
UTF-8
4,539
2.984375
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 import sys import argparse import math import numpy as np def main(): # Parse arguments parser = argparse.ArgumentParser( description="Trilateration requiring time synchronization only between base stations.") for i in range(1, 11): parser.add_argument( ...
true
08768aebab439b11aa87e20c06f525d3b0d4d86b
akneves/tf_tutorial_ipi
/tf_tutorial_dataset_cifar.py
UTF-8
3,308
2.9375
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Tue May 22 16:25:18 2018 @author: Lin Chen This file is adapted from github project: image-classification-CIFAR-10-using-tensorflow https://github.com/TapanBhavsar/image-classification-CIFAR-10-using-tensorflow """ import tensorflow as tf import pickle import sy...
true
4637faa764496a6bdaf843b080252eb6566f8295
amitaid/scheme-compiler
/reader.py
UTF-8
7,932
2.515625
3
[]
no_license
from fractions import gcd from pc import * import sexprs ps = ParserStack() pSexpr_d = delayed(lambda: sexpr) ######### Comment ########### line_comment = ps. \ parser(pcChar(';')). \ const(). \ parser(pcChar('\n')). \ butNot(). \ star(). \ parser(pcChar('\n')). \ catens(3). \ done...
true
53ea51504dfd43b4021862081588031a301c8616
rawkit1/ModUtil
/libs/recipe.py
UTF-8
2,520
3.265625
3
[]
no_license
""" 1.12 Shaped Recipe Generator by enwash todo: forge oredict support metadata """ import time import os from os.path import join as pjoin def main(): print("1.12 JSON Recipe Generator\nby enwash\n") numItems = int(input("How many items in your recipe? (plaintext):\n")) itemDict = {} charReps = [] ...
true
219f823ea5608aadff622d17b4e155f61b276ffa
stdiorion/competitive-programming
/recommendations/kujikatsu/243/e.py
UTF-8
874
2.75
3
[ "BSD-2-Clause" ]
permissive
from itertools import accumulate n, k = map(int, input().split()) p = [int(x) - 1 for x in input().split()] c = list(map(int, input().split())) visited = [False] * n loops = [] loopcost = [] for start in range(n): if visited[start]: continue now = start loop = [] while not visited[now]: visi...
true
262a7b8edb65a71a07b1638bb89925ab5cfe0a22
albakir13/python_for_everybody
/whileTry.py
UTF-8
79
3.0625
3
[]
no_license
x = 1 while x < 41: print(x) x = x + 1 print('Wrote it succssfully')
true
262984f4590450c2b206859c21d0392b258fd9e6
narasimhareddyprostack/python-Aug-7PM
/Basic-Python/output1.py
UTF-8
162
2.984375
3
[]
no_license
print("Hello", end=" ") print("Good Evening") #by default, print() end with newline #print("Hi , This is Narasimha - from \n Pro Stack Academy")
true
9d59807e563d3ffa19b433aaff5ba339ae9ce2bf
ritikapatel1410/Python_Data_Structure
/Basic_Programs/Data_Structure/Basic_Program/list_to_string.py
UTF-8
652
3.578125
4
[]
no_license
''' @Author: Ritika Patidar @Date: 2021-02-23 22:15:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-23 22:15:38 @Title : convert list into string ''' def list_string(list_element): """ Description: this function define convert list into string Parameter: list_element...
true
dbe21ad13af7c437c4cdf6136808f964ef419292
yang4978/Hackerrank_for_Python
/Problem Solving/Algorithms/Strings/11_funny_string.py
UTF-8
621
3.359375
3
[]
no_license
#https://www.hackerrank.com/challenges/funny-string/problem #!/bin/python3 import math import os import random import re import sys # Complete the funnyString function below. def funnyString(s): diff = [abs(ord(s[i])-ord(s[i+1])) for i in range(len(s)-1)] for i in range(len(diff)//2): if(diff[i]!=dif...
true
866951cf3d6922d3686e6be80d211ea3230e7634
AndreiMircea07/Bezier-and-B-Spline-graphics
/UI.py
UTF-8
1,418
2.65625
3
[]
no_license
from GHD.Punct import Punct def citireCardinal(): n=int(input("Cate puncte doriti sa introduceti?")) return n def citirePoligon(n): print("introduceti varfurile poligonului") l=[] for i in range(0,n): x=float(input("abscisa:")) y=float(input("ordonata:")) P=Punc...
true
e11b811acf08e679045d940229d4e0f1294f5ccb
BarkingPuppy/QQAQ_preprocessing
/crawler_fromDB/gen_lstm_rewrite.py
UTF-8
4,423
2.671875
3
[]
no_license
#! python3 # coding: utf-8 import math, json, time import numpy as np tStart = time.time() RECENT_SIX_PATH = './recent6' RESULT_PATH = './lstm_input' KNN_K = 3 # "k" of k-NN STATIONS_TOTAL = 76 # 註: PM2.5有兩個,第一個是PM2.5差值(當前-上一小時),第二個是PM2.5值; # PASS為預留給風向資料拆成cos和sin的位置,會於迴圈中略過 FEAT_LIST = ["PM2.5","PM2.5","PM10","WS_H...
true
641bfa20af8ce378a13235ede36107374ee25886
ucsb-ccs-cs20-s18/Sean-State-Fragility
/PrintStateFragility.py
UTF-8
383
2.96875
3
[ "MIT" ]
permissive
import json with open('state_fragility_10.json') as json_data: stateFragility = json.load(json_data) for state in stateFragility: print("Country:",state["Country"]) print("Legitimacy:",state["Metrics"]["Legitimacy"]) print("Effectiveness:",state["Metrics"]["Effectiveness"]) print("State Fragility I...
true
03281ccf1752f10f7f5b45f7c049b02868332e7f
shuvo14051/python-data-algo
/Problem-solving/URI/URI-1064.py
UTF-8
202
3.390625
3
[]
no_license
positive = 0 sum = 0 for i in range(6): n = input() n= float(n) if n>0: positive += 1 sum += n average = sum/positive print("%d valores positivos" %positive) print("%.1f" %average)
true
add461caa9bd3c896a27fad4fdbc21adc372e780
ynaka81/DeepPose
/datasets/human_eva/camera_parameter.py
UTF-8
1,460
2.828125
3
[]
no_license
import numpy as np import cv2 ## Camera parameter # # The structure of the camera parameter class CameraParameter(object): ## constructor # @param cal_file The filename of the calibration data def __init__(self, cal_file): # load camera parameter from calibration data f = open(cal_file) ...
true
eb9758bcc349fa7d120148234b519adfffe8f539
Pringles-ver-01/muffin_backend_flask_heejin
/static/Read_csv.py
UTF-8
492
2.8125
3
[]
no_license
import csv import json class Read_csv_create_wordcloud: def read(self): with open('./static/data/30_news_threeDays_mining.csv','r',encoding='utf-8') as f: data = csv.reader(f) t = list() for x, y in data: aa = dict(text = x, value = y) pri...
true