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
61f62ff005d6e721ed8c7a7aae4493eb5027e772
tlhlee838/learntocode
/python101/LED_examples/020c_serenity_led.py
UTF-8
1,634
3.078125
3
[]
no_license
import requests import time # SERENITY MODE: cycle through color range 0/255, where each of R/G/B is offset. DURATION = .03 # in seconds, frequency we send updates STEP_SIZE = 2 # with fixed DURATION, controls the speed of color shifting RGB_ENDPOINT = 'http://10.56.4.123:8934/blink1/fadeToRGB' red_val = 25...
true
e2ecb972b7eb914e3da7252c55cf94d399d7e384
1553007/BBC-News-Clawler
/remove_vi_stopwords.py
UTF-8
1,313
2.703125
3
[]
no_license
import os, io, codecs import sys from underthesea import word_tokenize path = sys.argv[1] def sorted_stopwords_list(stopwords_list): stopwords_list.sort(key = lambda s: len(s), reverse=True) return stopwords_list def load_vietnamese_stopwords(): vi_stopwords_list = [] with io.open("stopwords.vi", 'r', ...
true
f91c8107b0bf9c0cb55018009f17fec95f3c302b
kyunghwanleethebest/inflearn_leaf
/code/1_g_l_variables.py
UTF-8
789
3.921875
4
[]
no_license
# Scope, Global, Nonlocal, Locals, Globals # Global / Local a = 10 def test(): # global a를 선언하면 달라 위에 a가 20으로 변함! a= 20 print('local a {}'.format(a)) print('global a {}'.format(a)) test() # Nonlocal def nl_test(): # Closure 형태 k = 7 def nl_test_in(): nonlocal k k +=11 pri...
true
11cadf83b8bdae1568b06ce6a9a652f83d1f3dcd
shubhaam13/google-code-sample
/python/src/video_playlist.py
UTF-8
583
3.703125
4
[]
no_license
"""A video playlist class.""" class Playlist: """A class used to represent a Playlist.""" def __init__(self, name: str, videos, original_name): self._name = name self._videos = videos self._original_name = original_name @property def get_name(self): """The name of the ...
true
72ed03d496ae50d7ac9b46c059ce17d6aeca3c8c
Anmol-sh/Apparel-Classification-and-Recommandation
/splitData.py
UTF-8
1,230
2.8125
3
[]
no_license
from os import listdir, mkdir from os.path import isfile, isdir, join from shutil import rmtree,copy2 import random, config def cleanup(dir): rmtree(dir) mkdir(dir) def split_data_set(): print("Splitting Data") categories = [ file for file in listdir(config.dataFile) if isdir(join(config.dataFile,file...
true
62abcedc8bfca7993753ae4daeb13acfe8523dd6
taewoo-b/test1
/006.py
UTF-8
53
3.1875
3
[]
no_license
tot = 0 for i in range(1,11): tot +=i print(tot)
true
7922f20a93694bad54dbd5135ec66ef07b8497ac
myrimur/algo_prakt01
/results.py
UTF-8
3,425
3.21875
3
[]
no_license
import sort import json from random import sample, randint from time import time def generate_random(arr_len: int) -> list: arrays = [] for _ in range(5): arrays.append(sample(list(range(arr_len)), arr_len)) return arrays def generate_increasing(arr_len: int) -> list: return [i for i in ra...
true
0b5c6b953790fcf645c97ddd5c9d3ced54566a5c
apy444/Linear-regression-git
/Linear_regression.py
UTF-8
4,972
3.859375
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Tue Sep 4 10:54:08 2018 @author: AndiGabi """ """ Machine Learning Problem Solving: Implementing Linear Regression with one varible This exercise based on Andrew NG: Machine Learning Coursera week2 assignement, which could only solved in MATLAB or OCTAVE. I used t...
true
ab210623bbb4fc2967c2953c715484c0d7617b2b
cmap/psp
/broadinstitute_psp/utils/psp_utils.py
UTF-8
2,697
2.734375
3
[ "BSD-3-Clause" ]
permissive
import logging import ConfigParser import os import numpy as np import pandas as pd import cmapPy.pandasGEXpress.parse as parse def read_gct_and_config_file(gct_path, config_path): """Read gct and config file. The config file has three sections: io, metadata, and parameters. These are returned as diction...
true
d52e39076ae66a4b77d35380e084d7b65260f1a9
TebbyKape/Project_Group2
/Editable Files/CCTDdb_BackEnd.py
UTF-8
2,022
2.609375
3
[]
no_license
#backend import sqlite3 as lite def PatientData(): con=lite.connect("patient.db") cur = con.cursor() cur.execute("CREATE TABLE IF NOT EXISTS patient(id INTEGER PRIMARY KEY, PntID text, Firstname text, Surname text, DoB text,\ Age text, Gender text, Address text, MoNo text, LastPersonContact text)")...
true
ebfe124b8f1e534f526f240e1b2ba36e7d4a5abb
li-clutter-org/http2-test
/scripts/freeze_instances.py
UTF-8
1,906
2.921875
3
[]
no_license
#!env python """ Freeze the browser-bearing instances (the ones that we denote as StationA and StationB). Check the comment at file "findout_instance_ips.py": the requirements for AWS cli tools also apply here. """ import json import subprocess as sp INSTANCE_NAMES = [ "testInstance", "harvestInstance", ...
true
65572ab1c76afe588e9a5e1ae1c5c784fbd85bd0
PeterRydberg/rl_peg_solitaire
/project/game/BoardGraph.py
UTF-8
2,796
3.390625
3
[ "Apache-2.0" ]
permissive
import networkx as nx import matplotlib.pyplot as plt import itertools class BoardGraph: def __init__(self, board_content, board_type, live_update_frequency): self.graph = nx.Graph() self.live_update_frequency = live_update_frequency self.generate_graph(board_content) self.pos = s...
true
d121d9cc2a76d227cf352745d01450fb765e8b01
Bimsickle/HIT137_A2_awitp
/sprites.py
UTF-8
38,216
3.1875
3
[]
no_license
# sprite calsses # Created by Angie Hollingworth # HIT137 2019 # This file is the sprite management file for the game associated with it. # all sprites are generated and updated with this file. import pygame import random from settings import * vec = pygame.math.Vector2 # x & y changer - 2 dimensions for gravity c...
true
3c5ae62d8dac9b4617a59b0e4aed8dfb4a66bed8
wjwei-handsome/Machine-Learning
/example2_housing.py
UTF-8
6,827
3.328125
3
[ "MIT" ]
permissive
import os import pandas as pd import numpy as np ##加载数据 housing=pd.read_csv('datasets/housing/housing.csv') housing.info() print(housing["ocean_proximity"].value_counts()) print(housing.describe()) import matplotlib.pyplot as plt housing.hist(bins=50,figsize=(20,15)) plt.show() #plt.savefig('housing_bins50.png') ##测试...
true
db1b6a71ad973bd23c51aa81a082e0ad7f5cfc57
Dowell-Lab/OCR_transcription_detection
/coverage_histograms.py
UTF-8
12,114
2.515625
3
[ "MIT" ]
permissive
import pandas as pd import numpy as np import matplotlib as mpl # to prevent display weirdness when running in Pando: mpl.use('Agg') import matplotlib.pyplot as plt plt.ioff() HISTOGRAM_BINS = 50 DATA_DIR = './new_models/results/bed_files/' chromosomes = [ 'chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chr6', 'chr7',...
true
ae8bfa71ee90645d26b930217f125a2c7041f6c4
mrmittag/Introduction-to-Programing
/Projects/project_2/snake_6.py
UTF-8
2,673
4
4
[ "MIT", "CC0-1.0" ]
permissive
import curses import time import os screen = curses.initscr() # Create screen object head=[1,1] # This is a list that holds the y and x coordinates of the snake def initialize(): """This function sets the attributes and appearence of our screen""" screen.border() screen.keypad(1) screen.nodelay(1) def pro...
true
f1e07df638f95be9edcc865e1ff0a729448e2d2d
LangfeldN/python_
/analyseKassenlogs/controllKAZA.py
UTF-8
1,738
2.75
3
[]
no_license
## Das Skript dient der Kontrolle der Kartenzahlung # File einlesen # Betraege raussuchen # summieren # 1) import new import os # --------------------------------------------------------------------- # 1) File einlesen - Dateien ermitteln from cgitb import enable os.chdir('C:\Users\langfeldn\Desktop...
true
34a12d36afee3fc844985d1facf8cc4b12693e53
RivasCVA/AlgoShell
/mvp/AlgoShell/solutions/pancake_sort.py
UTF-8
569
3.90625
4
[]
no_license
def pancake_sort(arr): workingLength = len(arr) # 2 while workingLength > 0: i = getGreatestIndex(arr, workingLength) # 1 flip(arr, i + 1) flip(arr, workingLength) workingLength -= 1 return arr def flip(arr, k): i = 0 j = k - 1 while i < j: temp = arr[j...
true
1017f2ec2563f1c62b506989673e80ba065ef307
Esiver/shoes_and_sandals
/game_main.py
UTF-8
6,798
2.890625
3
[]
no_license
import playerchar import items import monsterchar import game_events import world #declare characters playerone = playerchar.Player(100,1,[], "Forest",1,11) monster1 = monsterchar.Monster('booby brown',22,2000,10,[]) w_stt = items.Weapon('Sword of a Thousand Truths', 29, 5) shoes1 = items.Shoes('Silk Slippers',45,'si...
true
53c5dadd4e58743066b936b65c49cf418fe7e996
raindigi/sepal
/modules/google-earth-engine/docker/sepal-ee/sepal/ee/dates.py
UTF-8
1,692
2.9375
3
[ "MIT" ]
permissive
import calendar from datetime import date, datetime, timedelta from typing import Union import ee from dateutil.parser import parse def to_date(d: Union[int, str, date]) -> date: if isinstance(d, int): return datetime.fromtimestamp(d / 1000).date() elif isinstance(d, str): return parse(d).dat...
true
dde89bccd053bb251d6a88b52d902c1f27100c79
davidspu/path-finder
/PathFinder.py
UTF-8
1,207
3.625
4
[]
no_license
import sys import math import PathFinder2 def pathfinder(n): if n == 0: print(0) elif n == 1: print(1) elif n < 0: print('invalid entry') exit(1) else: # Initialize all entries to 0 matrix = [[0 for i in range(n)] for j in range(n)] # Only one p...
true
201d4c46a74ed887a69f24be2ce386ba0a968afb
satyamprogrammer/Image-Translator
/binary.py
UTF-8
974
2.734375
3
[]
no_license
import cv2 import numpy as nm from matplotlib import pyplot as plt #Create MSER object mser = cv2.MSER_create() #Your image path i-e receipt path img=cv2.imread('C:/Users/satya/Desktop/python/pic2.jpg',0) #Convert to gray scale #gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) gray = cv2.adaptiveThreshold...
true
62ca47d8acbc2f63262dd7e7134cd415ecd0b03d
nmaypeter/project_nw_190501
/SeedSelection_NaiveGreedy.py
UTF-8
5,521
2.828125
3
[]
no_license
from Diffusion import * import heap class SeedSelectionNG: def __init__(self, g_dict, s_c_dict, prod_list, monte): ### g_dict: (dict) the graph ### s_c_dict: (dict) the set of cost for seeds ### prod_list: (list) the set to record products [kk's profit, kk's cost, kk's price] ### n...
true
ba905fa8abf836e14c1e9b87d64181c2ff8b3e20
ballerupgis/notebooks
/utils/connections.py
UTF-8
2,391
3.1875
3
[]
no_license
""" Connections for databases and functions for generating connection string for SQL Alchemy and creating Pandas dataframe from SQL. example: ------------------- import sys sys.path.append('/path/to/folder') import connections as con con.sql_to_dataframe('DISTRIBUTION', 'select * from proj_belysning.belysning limit ...
true
b0b7c5c6ed333c0e42b5214f5db616d8fea9bcfb
HuipengXu/leetcode
/isScramble.py
UTF-8
1,631
3.328125
3
[]
no_license
# @Time : 2019/6/27 10:23 # @Author : Xu Huipeng # @Blog : https://brycexxx.github.io/ from collections import Counter, defaultdict from functools import lru_cache class Solution: def isScramble(self, s1: str, s2: str) -> bool: @lru_cache() def helper(s1: str, s2: str) -> bool: ...
true
0467fd73bba3d4b86c8da9ce5e700eba96214f3e
longrobot1988/NLP
/test3/remove26.py
UTF-8
237
2.609375
3
[]
no_license
#!/usr/bin/env python #-*-coding:utf-8-*- # #Author:Weilong Guo import re for line in open('medline_1.txt'): m = re.match(r'.+ness|.+ly',line.strip()) #'.' 改行以外の任意の文字にマッチする # if m : print line.strip()
true
f1d93ecfdb1383e2cc69ea359bc47a6216df52f7
rishi23root/class_automations
/File_manager/main.py
UTF-8
9,427
2.796875
3
[ "MIT" ]
permissive
# python main.py import time,os,sqlite3,datetime,json # pip install watchdog from listener import EventHandler,Listener from Teleporter import Teleporter from pathlib import Path class supervisor: '''this class is responsible for the using all the modules and senitization of the events and returing ...
true
2a54f66d9f05436238f86493afc72c03a8cdc937
Ruth-ikegah/python-mini-projects
/projects/convert_png_images_to_ico_format/convertUI.py
UTF-8
1,713
3.515625
4
[ "Python-2.0", "MIT" ]
permissive
import tkinter as tk from tkinter import filedialog, messagebox from PIL import Image # Initialize Tkinter window root = tk.Tk() # Initialize variable to store image path img = None # Initialize font, background color, foreground color and width for the buttons font = ('helvetica', 12, 'bold') bg = 'blue' fg = 'white'...
true
a98098aef0758441aa1a7204c0b9b24efff802ad
r-nba/TeamSubredditManager
/SubredditManagerV2/SubredditManagerV2/SubredditManagerV2.py
UTF-8
256
2.65625
3
[]
no_license
from ClipperBot import ClipperBot import sys cb = ClipperBot() while 1==1: try: cb.wakeUp() except: print('HOLY SHIT AN EXCEPTION!!!!!!') print ('Error: ', sys.exc_info()) cb.sleep(120) #try again in 2 min
true
4972b06db76135ce241ee66f110ff20a0496ac2c
VingtCinq/django_stack_it
/stack_it/images/mixins.py
UTF-8
1,388
2.640625
3
[ "MIT" ]
permissive
from django.utils.translation import ugettext_lazy as _ from django.db import models class ImageRelatedMixin(models.Model): """ A mixin to allow to track down which models uses an fk to "stack_it.Image" Attributes: image (ForeignKey to Image): Reference to the original image ref_alt (Char...
true
f6f040dd0a9a00e061c72355372885925c5b6159
jiangshshui/leetcode
/thirdPage/133_CloneGraph.py
UTF-8
1,318
3.46875
3
[]
no_license
class UndirectedGraphNode: def __init__(self, x): self.label = x self.neighbors = [] class Solution: def __init__(self): self.m={} # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): if node is None: retur...
true
44310d3c69e8f346df4246e1e52cb7c10dc3e2ef
zhangchizju2012/LeetCode
/tensorflow/attention-mechanism/dense.py
UTF-8
4,659
3.09375
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 9 21:11:43 2018 @author: zhangchi """ # reimplement attention_dense.py using pure TensorFlow. import numpy as np import tensorflow as tf import matplotlib.pyplot as plt import pandas as pd input_dim = 32 he_normal = tf.keras.initializers.he_nor...
true
6649a53a9ea903b18112cb388e4cc789af023237
SHSBStudentRobotics/SRProject2018
/MockFramework/MockMotorBoard.py
UTF-8
685
2.9375
3
[]
no_license
global BRAKE BRAKE = 0 global COAST COAST = "coast" #A Mock motor board that prints out every change. class MockMotorBoardPrinter: def __init__(self): self._m0 = 0 self._m1 = 0 def setM0(self , value): print("m0 Changed to: " + str(value)) self._m0 = value def getM0(self,...
true
4f2657cfc522a3af5305aaa1a9162b9e184bc19d
Mubashar-javed/Article_crawler_FBVs
/crawler/views.py
UTF-8
4,712
2.859375
3
[]
no_license
# we will importing these for web-crawling import requests from requests.compat import quote_plus from bs4 import BeautifulSoup # .......... # for showing popup messages in case of any error. from django.contrib import messages from django.contrib.auth.decorators import login_required from django.contrib.auth.models im...
true
7a445d5287fc76df9c20dc0936235acf21a790ce
simplymanas/python-learning
/test_fizzbuzz.py
UTF-8
442
3.09375
3
[ "Apache-2.0" ]
permissive
import unittest from fizzbuzz import checkio class TestFizzBuzz(unittest.TestCase): def test_fizz(self): for i in [3, 6, 9, 18]: print('testing', i) assert checkio(i) == 'Fizz' def test_buzz(self): for i in [5, 10, 50]: print('testing', i) assert checkio(i) == 'Buzz' def test_fizzbuzz(self): for ...
true
8333ba132078a04dabc17a2a498bb2cbfee4da7c
monoscale/Project-Euler
/1-9/problem7.py
UTF-8
333
3.609375
4
[]
no_license
import math def is_prime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True total_primes = 0 current_num = 1 while(total_primes <= 10000): if(is_prime(current_num)): total_primes = total_primes + 1 current_num = current_num + 1 print...
true
86150d6257597bf9c2dd030d43d9e7431471e652
jm9176/V-REP-Self-reconfigurable-Robot-Simulations
/LiDAR_data_Py_V-REP.py
UTF-8
2,698
2.90625
3
[]
no_license
# Make sure to have the server side running in V-REP: # in a child script of a V-REP scene, add following command # to be executed just once, at simulation start: # # simRemoteApi.start(19999) # # then start simulation, and run this program. # # IMPORTANT: for each successful call to simxStart, there # should ...
true
07f51a750d9f9c91687d07c446c5def3a897b950
CoryCollins/src-class
/code25_all/python/1636940.txt
UTF-8
2,007
2.5625
3
[]
no_license
#!/usr/bin/env python import wsgiref.handlers from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.ext.webapp import template import models class showPhoneBook(db.Model): """ property to store user_name from UI to persist for the session """ user_name = db.StringP...
true
f739af25f0240b218d1d00e6088c245aea362793
westpa/westpa
/tests/test_binning.py
UTF-8
12,658
2.765625
3
[ "MIT" ]
permissive
import pytest import numpy as np from scipy.spatial.distance import cdist from westpa.core.binning.assign import ( RectilinearBinMapper, PiecewiseBinMapper, FuncBinMapper, VectorizingFuncBinMapper, VoronoiBinMapper, RecursiveBinMapper, ) from westpa.core.binning.assign import coord_dtype cla...
true
f86862884e571089565e94f3db5b32df1ab2a378
efleisig/semantic_shift_IW
/diachrony_master/score_word.py
UTF-8
1,913
2.84375
3
[]
no_license
from diachrony_for_russianmaster.algos import GlobalAnchors, Jaccard, KendallTau, ProcrustesAligner from argparse import ArgumentParser from diachrony_for_russianmaster.utils import load_model import os def main(): parser = ArgumentParser() parser.add_argument('--word', '-w', required=True, help='word to be s...
true
ba4f676c4008053afdd35217eeb5a4e23b99b372
IsseiNagi/django-practice-2-sns
/snsapp/views.py
UTF-8
4,612
2.6875
3
[]
no_license
from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.models import User # Userモデルをimport from django.contrib.auth import authenticate, login, logout # ログインのために from django.db import IntegrityError # IntegrityErrorの表示のために from .models import SnsModel # from django.contrib.auth.dec...
true
ebf74ba93d04d13aae3a0ef078d301384b81d0cd
Wanted-Preonboarding-Backend-1st-G5/Assignment5
/commands/management/commands/import_csv_to_db.py
UTF-8
1,733
2.53125
3
[]
no_license
import csv, re from django.core.management.base import BaseCommand from research.models import ResearchInformation from execptions import FileExtensionNotMatchError class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('-p', required=True, type=str, help='Csv file path') ...
true
30b198b847ede0e82fcbe711a4bcf9454786b24f
LEXAPAIN/refactoring
/filter.py
UTF-8
1,050
2.9375
3
[ "MIT" ]
permissive
from PIL import Image import numpy as np img = Image.open("img2.jpg") arr = np.array(img) width = len(arr) height = len(arr[1]) cell_size = 10; step = 50; for i in range(0, width - cell_size + 1, cell_size): for j in range(0, height - cell_size + 1, cell_size): avg_brightness = 0 for row ...
true
c387c179a367e5b7f467a4c38088a298a6d30459
pawan-terdal/youtube_dl
/adjustLines.py
UTF-8
215
2.609375
3
[]
no_license
fread = open("hindi","r") fwrite = open("hindi_proper","a") for line in fread: if not line.rstrip(): continue print(line[line.find('"'):]) fwrite.write(line[line.find('"'):]) fwrite.close() fread.close()
true
37a5e69b21aee67c45b7fd07c28536252219c444
martadominguezm/TFG
/escalonate_data.py
UTF-8
655
2.96875
3
[]
no_license
# Based on https://www.kaggle.com/parasjindal96/how-to-normalize-dataframe-pandass import pandas as pd from sklearn import preprocessing from data_treatment import DataAtts import matplotlib.pyplot as plt file_names=["original_data/creditcard.csv", "original_data/data.csv", "original_data/diabetes.csv"] for name in f...
true
147853faaf74cbcf90c5551b68d1e6996a816d90
komal-kumarii/python_basics
/komal/odd_even.py
UTF-8
206
3.546875
4
[]
no_license
num=[1,2,3,4,5,6,7,8,9,10] index=0 even=[ ] odd=[ ] while index<len(num): if num[index]%2==0: even.append(num[index]) else: odd.append(num[index]) index+=1 print(even) print(odd)
true
76dd39d5b3d68d59556792aa5b7ab3c4f1b76f92
slinan/tareaPython
/fibonacci.py
UTF-8
345
3.78125
4
[]
no_license
# coding=utf-8 #Correr en Python 2! #Santiago Liñán - s.linan10 try: x=int(raw_input('Número:')) except ValueError: print "No es un número" fibo = [] def fib(n): if n==0 or n ==1: return n return fib(n-1)+fib(n-2) i = 0; n = fib(i); while n < x: fibo.append(n) i+=1 n=fib(i) print 'Serie de Fibonacci ...
true
bb5c3ea804ea21ae360e39d02091278a94e47bd6
qtux/instmatcher
/instmatcher/geo.py
UTF-8
2,096
2.609375
3
[ "CC0-1.0", "CC-BY-3.0", "Apache-2.0" ]
permissive
# Copyright 2016 Matthias Gazzari # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
true
1158df4ce1e9d30af9d30b1953cd46b986836ce0
Thialves02/blueEdtech-mod1
/Projetos/projeto-1.py
UTF-8
999
3.6875
4
[]
no_license
print("Responda as perguntas com [S/N]") qntd = 0 p1 = input("Você telefonou para a vítima?\nSua resposta = ").upper() p2 = input("Você esteve no local do crime?\nSua resposta = ").upper() p3 = input("Você mora perto da vítima?\nSua resposta = ").upper() p4 = input("Você devia para a vítima?\nSua resposta = ").upp...
true
59d3be8e2c7160ea3cc0eb52f9d4b8ee07da8071
alyl/ClassifieurBN
/fabrique de tableaux/Gen_Ben_-1.py
UTF-8
1,935
2.640625
3
[]
no_license
import time import collections import csv import os User = collections.namedtuple( 'User', ['id', 'age', 'sexe', 'job', 'zip', 'ratings']) start = time.time() users = [] notes = [[-1]*1682]*943 with open('u.user', 'rb') as user_file: user_reader = csv.reader(user_file, delimiter='|') for user in user_...
true
e52545121ccf3132a31fdbd98bc40b852956fb84
SAILResearch/replication-npm_downgrades
/npm_parser/semanticversion.py
UTF-8
2,567
2.875
3
[]
no_license
from semanticversionparser import SemanticVersionParser, RelaxedSemanticVersionParser class Version(): pass class SemanticVersion(Version): major = None minor = None patch = None pre_release = None build = None def __init__(self, version_str): semantic_version = SemanticVersionPar...
true
3614ad5ba10e49687b148bab97ec500014dc1824
stormaaja/scripts
/bluetooth-audio.py
UTF-8
449
2.625
3
[ "MIT" ]
permissive
#!/bin/python3 import subprocess import sys #device = '00:16:94:1A:C9:AA' device = '2C:41:A1:82:BB:D9' command = 'bt-device -i {0} | grep -c "Connected: 1"'.format(device) connected = int(subprocess.getoutput(command)) > 0 if len(sys.argv) > 1 and sys.argv[1] == '1': command = 'bt-device -{0} {1}'.format('d' if ...
true
1f96ee279c3f652ca07ebcef947ef8e96c7e33d2
lmangiag/detector-emulation
/python/main.py
UTF-8
1,412
3.203125
3
[]
no_license
import events import random import time import queue ## Helper function to provide input def generateInput(): chargeGen = random.random()*10 # These lines can be substituted to timeGen = random.random() # input data from a different source X = random.random() # Y = random.r...
true
113d3d747e68f7714e2d4a9dd85b73d3d9d316d5
gabrielavirna/interactive_python
/problem_solving_with_algs_and_data_struct/chp3_linear_structures/list_unordered.py
UTF-8
10,221
4.65625
5
[]
no_license
""" Lists ------ - A list is a collection of items where each item holds a relative position with respect to the others (unordered list). - We can consider the list as having a first item, a second item, a third item, and so on. - We can also refer to the beginning of the list (the first item) or the end of the list (t...
true
2e37dd8f41b45fd486cfe836a6f4c9c86f6a3dc4
levabala/python-uni
/sorts/insertion.py
UTF-8
588
3.75
4
[]
no_license
from sorts.sortInfo import SortInfo def insertionSort(data, progress=lambda x: x): swaps = 0 compares = 0 for i in range(len(data)): j = i - 1 key = data[i] while True: compares += 1 if not data[j] > key: break compares += 1 if not j >= 0: break data...
true
96baee690cb2a725b260d582aff6a99a07a1182b
Vincent-Vercruyssen/anomatools
/src/anomatools/utils/copkmeans.py
UTF-8
13,832
2.71875
3
[ "Apache-2.0" ]
permissive
# -*- coding: UTF-8 -*- """ Constrained KMeans. Reference: https://github.com/Behrouz-Babaki/COP-Kmeans :author: Vincent Vercruyssen (2019) :license: Apache License, Version 2.0, see LICENSE for details. """ import math import random import numpy as np from sklearn.utils.validation import check_X_y from sklear...
true
609f508e41cbdaab204e0200119c9b37f2d82fe2
Sheshadri-1992/ds256-jan2019
/ds256-project/jsk/Plots/erasurefamily.py
UTF-8
627
3.234375
3
[]
no_license
import matplotlib.pyplot as plt import numpy as np X = ["1.5", "1.35", "1.25"] Y = [43.549, 48, 45] Z = [175, 315, 376] fig, ax = plt.subplots() ind = np.arange(3) # the x locations for the groups width = 0.35 # the width of the bars p1 = ax.bar(ind, Y, width, color='deepskyblue', bottom=0) p2 = ax.bar(ind + widt...
true
065d440b9eae54a63b860149d54a6b86fc618841
meghalrag/MyPythonProjrects
/ActivityRecognition/myFunctions.py
UTF-8
2,949
2.5625
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt import os def CalculateSMA(x,y,z): modX = np.absolute(x) modY = np.absolute(y) modZ = np.absolute(z) numerator = (np.sum(modX) + np.sum(modY) + np.sum(modZ)) denominator = x.shape sma = numerator/denominator return sma def Cal...
true
4da865280002dfbed81cb4499925359a2bd762da
Jobegiar99/Garden-Palooza
/server/src/game/levelGenerator/groundExtraDecorator.py
UTF-8
539
2.59375
3
[ "MIT" ]
permissive
import random class GroundExtraDecorator: def __init__( self, secondLayer, GROUND_EXTRA_SPRITE_MAP, groundArea, GROUND_SPRITE_MAP ): for point in groundArea: row, column = point if secondLayer[row][column] in GROUND_SPRITE_MAP: probability = random.unifo...
true
67c2418e084b17110bffc47e591b9bcaf91bf764
Pnikanti/interface-guard
/examples.py
UTF-8
1,399
3.453125
3
[ "MIT" ]
permissive
from IFG import IFG from typing import Union class TypeSafeBaseClassExample(IFG): """ Example base class using InterfaceGuard base class. """ my_str_property: str my_union_property: Union[list, tuple] def __init__(self): super().__init__() print("type safe base class instanti...
true
495f18f2ba7f315cf001212499b33c7ce6d90546
fatemizuki/python-
/first_atm/db/db_handler.py
UTF-8
918
3.0625
3
[]
no_license
''' 数据处理层 ''' import json import os from conf import settings # 查看数据 def select(username): # 1.接收接口层传来的username,拼接成json路径 user_path = os.path.join( settings.USER_DATA_PATH, f'{username}.json' ) # 2.校验user的json路径是否存在 if os.path.exists(user_path): # 3. 存在则返回给接口层 with open(...
true
82c1d9496b2f10b3d4e025994a79d57bdcfd9033
gracewa/newsapi
/app/sources_test.py
UTF-8
666
2.8125
3
[ "MIT" ]
permissive
import unittest from .models import sources Sources = sources.Sources class SourcesTest(unittest.TestCase): ''' Test Class to test the behaviour of the Sources class ''' def setUp(self): ''' Set up method that will run before every Test ''' self.new_sources = Sources( ...
true
987bdff7f0756437a0c7624511bb8d22d93e2dca
yfp/cnt_bot
/actions.py
UTF-8
10,229
2.875
3
[]
no_license
import sqlite3 import image from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove from os.path import exists as pathexists from imset import get_imset config = {} def use_config(_config): global config config = _config def start(update, context): for key in ('make', 'guess'): if key in context.chat_...
true
981c0d9f826694dd32e547ad38694e9b7959357b
uzaktabilisim/makinaogrenmesi
/openCVtest/opencvBase.py
UTF-8
4,652
2.765625
3
[]
no_license
import cv2 import numpy as np import os path = './256_GRAY_shift/A/test/' savePath = './128_GRAY_shift/A/test/' # viewImage(Image, name_of_window) def viewImage(image, name_of_window): cv2.namedWindow(name_of_window, cv2.WINDOW_NORMAL) cv2.imshow(name_of_window, image) # cv2.waitKey(0) cv2.destroyAl...
true
a9911969919a4b25ed5b9ae5d596f99821280b2b
kunalJa/leetcodeforces-etc
/LeetCode/easy/543_diameter_of_a_binary_tree.py
UTF-8
1,367
4.03125
4
[]
no_license
""" https://leetcode.com/problems/diameter-of-binary-tree/ Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. """ """ Accepted Time Complexity:...
true
374152a3ac32e601471cb0229d2790bf38a6125c
yashbonde/chessshhh
/chess_engine/utils.py
UTF-8
5,881
2.984375
3
[ "Apache-2.0" ]
permissive
"""utility functions""" import os import json import chess import logging import hashlib import argparse DB_STRING = os.environ["DB_PATH"].format(user=os.environ["POSTGRES_USER"], password=os.environ["POSTGRES_PASSWORD"], host=os.enviro...
true
302ee0ed9a55d1a2dc98b959a2874dfd90ebba8b
mross12/Birch-Hill-Data-Science-Analyst-application---supporting-files
/YahooFinance Data Scraper + Value Investing Stock Analyzer/Raw Data Adjuster + Net-Net Analyzer/Net-Net Analyzer for Venture Data (Text File)
UTF-8
1,912
3
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 # In[1]: import requests import pprint from bs4 import BeautifulSoup from datetime import datetime as dt import pandas as pd import csv import os # In[2]: #the analyzer - a basic example of how to use this data # In[3]: os.getcwd() os.chdir('C:/Users/Mac/Desktop/Investin...
true
6782459ad71a8ebc43c32969fad3ab104604dd38
simonlegrand/pysit
/pysit/gallery/horizontal_reflector.py
UTF-8
5,527
2.78125
3
[]
no_license
import numpy as np from pysit.gallery.gallery_base import GeneratedGalleryModel __all__ = ['HorizontalReflectorModel', 'horizontal_reflector'] def _gaussian_derivative_pulse(ZZ, threshold, **kwargs): """ Derivative of a Gaussian at a specific sigma """ T = -100.0*ZZ*np.exp(-(ZZ**2)/(1e-4)) T[np.where(a...
true
9c129110f95dbc5f4d2ab07dcb1f33556b927a90
KrSiddhartha/R_Scripts
/modelevaluation.py
UTF-8
2,051
2.75
3
[]
no_license
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from sklearn import metrics class modeleval(): def confusion_mat_plt(y_test, y_pred, cat_cnt, figs=(10,10), cat_names=None): cf_matrix = metrics.confusion_matrix(y_test, y_pred) group_counts ...
true
cfd327f00705d37b88b483affeed7abd132433d9
AnsgarSchmidt/sensomatic
/knot/python/LEDKey.py
UTF-8
5,553
2.53125
3
[ "Apache-2.0" ]
permissive
import os import time import redis import TM1638 import datetime import threading import ConfigParser DIO = 17 CLK = 27 STB = 22 class LEDKey(threading.Thread): def _readConfig(self): update = False if not os.path.isdir(self._homeDir): print "Creating homeDir" os.makedirs...
true
65efe67117fd653104c3018e3b5a083b3ba17963
rpunit/python-programs
/sumOfTwoNum.py
UTF-8
263
3.609375
4
[]
no_license
def printIfSum ( a, tot ): a.sort() i,j = 0, len(a) -1 while (i < j) : if a[i] + a[j] > tot : j -= 1 if a[j] + a[i] == tot : return True if a[j] + a[i] < tot : i += 1 return False a = [1,4,45,6,10,8] print(printIfSum(a,49))
true
50a3768e2bb87c0b86915a4677e9409b55e6d664
guoheli/opencv
/06_机器学习/07_HOG特征.py
UTF-8
1,709
3.5
4
[]
no_license
""" HOG 特征: 步骤: 1:模块划分 image windows窗体: 特征计算的最顶层单元:包含所有的目标信息 窗体的大小是任意的 step: 滑动步长 block: block小于windows的大小 windows的大小一般是block的整数倍 step: 滑动步长 block 对windows遍...
true
834bb50ffd30ca4b8765a56b1a2354bdebf748b6
Muhammad-UsamaIshtiaq/flask-2
/cyberteck-develop/course-api/application/errors.py
UTF-8
1,092
2.6875
3
[]
no_license
class AppException(Exception): def __init__(self, message, statusCode): self.statusCode = statusCode self.message = message class InternalServerError(AppException): def __init__(self, message): super(InternalServerError, self).__init__(message, 500) class SchemaValidationError(AppExc...
true
3e44df25ea319616a3d9696cd8808af5f963e42f
adamgarcia02/projectEverGreen
/projectEverGreen/FTP_Main.py
UTF-8
1,556
2.5625
3
[]
no_license
#!/usr/bin/python3 from FTP_Library import fileUpload_temp, fileUpload_humidity, fileUpload_pressure from config import SERVER, USERNAME, PASSWORD from bmetest import temp_read, humidity_read, pressure_read import os import time import json def main(): temp_list = [] humidity_list = [] pressur...
true
1e7b41c6991a3d704987a02cc921b5e7500b9892
gurpsi/python_projects
/Basics/Hello.py
UTF-8
122
3.046875
3
[]
no_license
print("Python is a great language") def say_anything(): print("Hello python") # Calling the function say_anything()
true
64bd98045e1892036aed6acb047cd6fe7e1558bf
LyingCortex/HFSS
/IronPython/corrugated_edge_0602.py
UTF-8
2,203
2.625
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Thu Jun 2 21:52:52 2016 @author: LY """ x = 3 y = 0.6 pp = [] N = 12 L1 = 9 L2 = 17.2 L3 = 13 DD = 18.6 LL = 4 height = 2 # the length of the step for i in range(N): if(i % 2 == 0): pp.append(((i // 2)*(x + y), 0)) pp.append(((i // 2)*(x + y), height))...
true
b63eedced61689a6f66a16c0be6b7d979f937304
jaymccon/taskcat-v9
/taskcat/_utils.py
UTF-8
5,192
2.59375
3
[ "Apache-2.0" ]
permissive
import logging import os import re from collections import OrderedDict import yaml from taskcat.exceptions import TaskCatException LOG = logging.getLogger(__name__) class CFNYAMLHandler: """Handles the loading and dumping of CloudFormation YAML templates. Example usage: from taskcat import utils ...
true
ba88d17bb2b634b12d34a52bc803093280c313fb
Ditchbuster/AdventOfCode2017
/day11/day11b.py
UTF-8
953
2.953125
3
[]
no_license
import math with open('input.txt') as f: content = f.readlines() count = 0 size = 100 grid = [] for i in range(size): grid.append([]) for j in range(size): if (j % 2 == 0 and i % 2 == 0) or (j % 2 == 1 and i % 2 == 1): grid[i].append(0) else: grid[i].append(-1) for li...
true
b100fa0f5c24b16bcc8160af149df5b23f737b6a
Hoffmannia/tsalesman-ga
/src/inputfile-automation/input_generator.py
UTF-8
601
3.078125
3
[]
no_license
#!/usr/local/bin/python # Above can be changed to wherever python is located on the machine # NOTE: Run from root directory of project in order for file path to work import random CITY_LIMITS = 400 filename = raw_input("Enter desired inputfile name: ") numDest = input("Enter number of cities for file: ") outFile =...
true
45989ee981342d07f2fa9edc3b724a7ca615a8d6
l627851201/Python004
/Week01/maoyanSpiders/maoyanSpiders/pipelines.py
UTF-8
1,041
2.75
3
[]
no_license
# Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html # useful for handling different item types with a single interface from itemadapter import ItemAdapter import os,sys,csv class MaoyanspidersPipeline...
true
cd71038a6f9171bca3c0d774694c1b826b9afb35
jeffersonpedroza/Docker
/fibonacci.py
UTF-8
597
3.140625
3
[]
no_license
import os from flask import Flask, jsonify, request from math import sqrt app = Flask(__name__) @app.route('/') def nao_entre_em_panico(): nmax = 50 n1 = 0 n2 = 1 cont = 0 fib = 0 res = "Essa é sequencia dos 50 primeiros números da razão de Fibonacci: <br> Desenvolvido por Jefferson Alves. ...
true
f33432a7d895cd9d47d2c384cd39bbaad963bfdd
LEE-JAEHAK/Algorithm
/백준저지/파이썬코드/ref1_permutations.py
UTF-8
129
3.09375
3
[]
no_license
from itertools import product, permutations data = [1,2,3] print(list(product(data,repeat=3))) print(list(permutations(data,2)))
true
4d98ffe3cc3b069104b3f9bc4a5fa8efdaecbbe4
zghcxq/bash_tool
/add_tool.py
UTF-8
424
2.578125
3
[]
no_license
def addtool(tl): employee_file = open('config/tools.json','r') solvethesign = len(employee_file.read()) employee_file.close() if solvethesign == 0: employee_file = open('config/tools.json','w') employee_file.write(tl) employee_file.close() else: employee_file = open('config/tools.json'...
true
11fff04fd8325be466e1d4e811b2546c781c51bb
kbenyattou/project-euler
/solutions/001.py
UTF-8
160
3.46875
3
[]
no_license
def factorsum(upper_bound, numbers): return sum(x for x in range(1,upper_bound) if any([x%number == 0 for number in numbers])) print(factorsum(1000,[3,5]))
true
31176bb8c551fb33ff921feccbd742583b82b544
jervisfm/cs229a-project
/util.py
UTF-8
2,960
2.96875
3
[]
no_license
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np import itertools # Dimension for the input feature bitmap vectors. BITMAP_DIM = 784 label_mapping = { 1 : 'A', 2 : 'B', 3 : 'C', 4 : 'D', 5 : 'E', 6 : 'F', 7 : 'G', 8 : 'H', 9 : 'I', 10 :...
true
aab954d8d39d925f23582a259066c8380b85e1b0
ishiki-lab/ishiki-client
/src/ishiki_client/shared/tinkerforge_controller.py
UTF-8
2,696
2.90625
3
[ "MIT" ]
permissive
import time from tinkerforge.ip_connection import IPConnection from tinkerforge import device_factory # oo wrapper for callback using curried callable class EnumerateCallback: def __init__(self, controller): self.controller = controller def __call__(self, *args, **kwargs): self.controller.cb...
true
8c4ad99bf9aa56a1885f9e0740514fd7b8d90532
LucasDM19/python-stuff
/Soccer Review/PTD_html_extract.py
UTF-8
1,321
3.15625
3
[]
no_license
 # -*- coding: utf-8 -*- from html.parser import HTMLParser #Strings de teste #pstring = source_code = """<span class="UserName"><a href="#">Martin Elias</a></span>""" pstring = """<html></html>""" """ Esse link: http://stackoverflow.com/questions/11804148/parsing-html-to-get-text-inside-an-element Salvou a ...
true
447d7bda1ab60ee2679b6291148fc70be4671dbf
dlittleton/aoc2020
/6/6-2.py
UTF-8
340
2.9375
3
[]
no_license
import string import sys def count(stream): unique = set(string.ascii_lowercase) for line in map(str.strip, stream): if not line: yield len(unique) unique = set(string.ascii_lowercase) else: unique.intersection_update(line) yield len(unique) print(sum...
true
dac21cfeb570ed235cc43568ac436cc540a1dbeb
GoldF15h/LeetCode
/1365. How Many Numbers Are Smaller Than the Current Number.py
UTF-8
450
2.890625
3
[]
no_license
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: d = {} for cur in nums : if d.get(cur) : d[cur] += 1 else : d.update({cur:1}) op = [] for cur in nums : tmp = 0 for i in ...
true
64ec9f77b3d06e41cce279738231dea1ffee9d93
Epistimio/orion
/src/orion/core/utils/diff.py
UTF-8
1,273
3.890625
4
[ "BSD-3-Clause" ]
permissive
""" Utilitary functions for diffs ============================= Utilitary functions to provided colored diffs of (multi-line) strings """ from difflib import Differ def red(string): """Return the string wrapped in code to color it in red in user's terminal""" return color(string, "31m") def green(string)...
true
a0193207f3116a80b2cc1f027ec8c8c1841bdfe7
Marco2018/leetcode
/leetcode1248.py
UTF-8
418
2.796875
3
[]
no_license
class Solution(object): def numberOfSubarrays(self, nums, k): def subarray(k): ans, i = 0, 0 n = len(nums) for j in range(n): k -= nums[j]%2 while (k < 0): k += nums[i]%2 i += 1 ...
true
4fae593aa8e5dfa9a30ec6bca6193a5ec2346317
guits/ezi-store
/ezistore/tools.py
UTF-8
2,304
2.578125
3
[]
no_license
import logging class Colorize(object): _grey = '\033[1;30m' _red = '\033[1;31m' _green = '\033[1;32m' _yellow = '\033[1;33m' _blue = '\033[1;34m' _magenta = '\033[1;35m' _cyan = '\033[1;36m' _white = '\033[0;37m' _end = '\033[1;m' @staticmethod def grey(text): retur...
true
606abf0e6740231c21f0143b3ad387cffd294e53
hiviji/selpy
/radiobutton.py
UTF-8
503
2.796875
3
[]
no_license
from selenium.webdriver import Chrome from selenium.webdriver.common.by import By from pprint import pprint driver = Chrome () driver.get("https://formy-project.herokuapp.com/radiobutton") rb1 = driver.find_element(By.ID,'radio-button-1') rb2 = driver.find_element(By.XPATH,'//input[@value="option2"]') # print(rb1.is...
true
cf458a7780a03d996c94cd28f0de7cff225c4d2a
wyqmanutd/ReinforcementLearningInAutoPilot
/src/common/ThreadingUtils.py
UTF-8
799
3.34375
3
[ "MIT" ]
permissive
# coding:utf-8 import time import threading def invoke_repeating(start_delay, interval, func): time.sleep(start_delay) def run(): while 1: time.sleep(interval) func() t = threading.Thread(target=run) t.start() # 每次间隔执行某个函数 def invoke_repeating_old(start_delay, interv...
true
fb85d8f16de41dcb92669ffca53a0116f20b358c
BIAOXYZ/variousCodes
/_CodeTopics/LeetCode/601-800/000621/deliberate-WA--000621.py
UTF-8
1,699
3.203125
3
[]
no_license
class Solution(object): def leastInterval(self, tasks, n): """ :type tasks: List[str] :type n: int :rtype: int """ dic = {} for ch in tasks: if dic.has_key(ch): dic[ch] += 1 else: dic[ch] = 1 max...
true
274831aa9a85ca13130ae84714841b5c865fa35b
nischalshrestha/automatic_wat_discovery
/Notebooks/py/vikasbz/titanic-survivors-prediction/titanic-survivors-prediction.py
UTF-8
9,176
3.515625
4
[]
no_license
#!/usr/bin/env python # coding: utf-8 # **Import necessary libraries** # # In[ ]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sbn from sklearn import tree, preprocessing #%matplotlib inline #sbn.set() # **Read Data.** # In[ ]: train = pd.read_csv("../input/train.c...
true
fed0e8808bd88090fd4075a9055d3c16c1b89c6f
SbSharK/PYTHON
/PYTHON/stack.py
UTF-8
2,871
4.28125
4
[]
no_license
#!/usr/local/bin/python3.7 class Stack: """Stack implementation using list""" def __init__(self, size = 10): self.__mStack = [] self.__mSize = size print("Created stack with size: ", self.__mSize) def __del__(self): print("Stack destroyed") def isFull(self): re...
true
b5bc1be657d1f5cd68199eba4f4c2a8e479e13fd
Lyechen/-Python-C-
/python/heap_sort.py
UTF-8
807
3.171875
3
[]
no_license
# _*_ coding: utf-8 _*_ from sort_helper import SortHelper def __shift_down(arr, n, k): while 2 * k + 1 < n: j = 2 * k + 1 if j + 1 < n and arr[j] < arr[j + 1]: j += 1 if arr[k] > arr[j]: break arr[k], arr[j] = arr[j], arr[k] k = j def __heapify(ar...
true
0411eaefd42700fa70c7f93de5f9951d9ea76bb4
StephenHodge/piRadio
/RadioPi.py
UTF-8
8,505
2.609375
3
[ "CC0-1.0" ]
permissive
#!/usr/bin/env python #this should hopefully allow you to twist a potentiaomiter and play music import RPi.GPIO as GPIO import time import subprocess import os import signal #variables for LED GPIO LED_PIN = 5 GPIO.setmode(GPIO.BCM) GPIO.setup(LED_PIN, GPIO.OUT) #variables for chipset thingy DEBUG = 1 lastTrimPot_tu...
true
1a49ce7f491db27bd33330c69c3c344484874138
arunsprasath/kaggle-machine-learning
/Data Science Practice/Files and Loops-2.py
UTF-8
1,593
4.1875
4
[]
no_license
## 1. Opening Files ## f = open("crime_rates.csv", "r") ## 2. Reading In Files ## f = open("crime_rates.csv", "r") data = f.read() ## 3. Splitting ## # We can split a string into a list. sample = "john,plastic,joe" split_list = sample.split(",") # print(split_list) # Here's another example. string_two = "How much...
true