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
9d6fd394c3d935fe6d17e25ff9d8e43dba01945d
shouryaveer/rock-paper-scissors
/rock_paper_scissors.py
UTF-8
769
3.953125
4
[]
no_license
import random print("********Welcome to Rock Paper Scissors********") def play(): n = 1 u = 0 c = 0 while n <= 5: user = input("Press r for Rock, p for Paper, s for Scissors: ") comp = random.choice(['r','p','s']) print("Computer:",comp) n += 1 if user == comp: ...
true
588c3e7d65d05d63d4cd06124e54db1dac873306
NitinRamola/GeeksforGeeks
/Smallest_greater_elements_in_whole_array/Solution.py
UTF-8
527
2.828125
3
[]
no_license
def getoutput(a): b= a.split() b = [int(i) for i in b] sb= sorted(b) #print(b) #print(sb) for i in range(len(b)): if b[i] == max(b): print("_",end = " ") else: for j in sb: if j <= b[i]: continue p...
true
30cb2152ba61fdc70e20fde9f9b71daa05ffafa1
divyachandramouli/Data_structures_and_algorithms
/4_Searching_and_sorting/Bubble_sort/bubble_sort_v1.py
UTF-8
555
4.1875
4
[]
no_license
# Implementation of bubble sort def bubble_sorter(arr): n=len(arr) i=0 for j in range(0,n): for i in range(0,n-j-1): #In the jth iteration, last j elements have bubbled up so leave them if (arr[i]>arr[i+1]): arr[i],arr[i+1]=arr[i+1],arr[i] return arr array1=[21,4,1,3,9,20,25,6,21,14] prin...
true
4b1135053823f46f91e20fc293c652979a2a250d
alagappanr/python_training
/codingbat/Warmup-1/sum_double.py
UTF-8
127
2.9375
3
[]
no_license
def sum_double(a, b): return a==b and 2*(a+b) or (a+b) print sum_double(1,2) print sum_double(2,3) print sum_double(2,2)
true
b942c25db45ecb2d6133cd66808664b4c727c05c
timokoola/perkele
/tweet_parse_utils.py
UTF-8
575
2.609375
3
[ "Apache-2.0" ]
permissive
from operator import itemgetter def strip_by_indices(text, indices): indices.sort(key=itemgetter(0)) ret = [text[i[1]:j[0]].strip() for i, j in zip([[None,0]]+indices, indices+[[None]])] ret = filter(None, ret) return " ".join(ret) def get_entity_indice_list(entities_dict): indices = [] f...
true
6cf1c4caa3366843b6b128837ba822af284a8371
Brain-Cog-Lab/BP-STA
/code/losses.py
UTF-8
2,855
2.875
3
[ "MIT" ]
permissive
# Thanks to rwightman's timm package # github.com:rwightman/pytorch-image-models import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class LabelSmoothingBCEWithLogitsLoss(nn.Module): def __init__(self, smoothing=0.1): """ Constructor for the LabelSmoothing module...
true
335d43c574e9db99d3f336a2aa6e1fa38661c8d2
sheikh210/LearnPython
/data_structures/dictionaries/meal_planner.py
UTF-8
2,309
4.125
4
[]
no_license
from data_structures.dictionaries.dictionaries_meals import pantry, recipes # Dictionary Comprehension (At the time of writing this, I need to understand this code better) # display_dict = {str(index + 1): meal for index, meal in enumerate(recipes)} def add_item(our_shopping_list: dict, item: str, quantity: int) -> ...
true
514d1abc387caa43a9a046767818976c53d08475
mishtineha/MLM
/project/Neha/script.py
UTF-8
862
2.671875
3
[]
no_license
from django.contrib.auth.models import User from Neha.models import Profile,Tree # for i in range(1,17): # u = User.objects.create(username = "Neha"+str(i),password="project@123") # p = Profile.objects.create(user=u,first_name="Neha",last_name="Mishra",phone=12345678,email="mneha2173@gmail.com",pan_card=123) # ...
true
99e6f11a4169b9c1508d18e0f62080cb766f4920
shaked20-meet/meetyl1201819
/lab2.py
UTF-8
723
3.25
3
[]
no_license
#list_1 = [1, 2, 3, 4] #def make_list1 (): #global list_1 #print(list_1[0], list_1[-1]) #make_list1() ################################## #num1 = input("Enter 1 number") #a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] #def list_a(): #global a #global num1 #for i in (a): #b = [] #if i < num1: #b.append (i) #pri...
true
d4dabb3027772e4b5ccd01bd70451f9f30088018
pulosez/Python-Crash-Course-2e-Basics
/#8: Functions/user_profile.py
UTF-8
633
3.4375
3
[]
no_license
def build_profile(first, last, **user_info): """Створити словник, що міститиме всю інформацію про користувача.""" user_info['first_name'] = first user_info['last_name'] = last return user_info user_profile = build_profile('albert', 'einstein', location='princeton', ...
true
ae5976d7a92b170d2099b42999ad2071e1d5646e
corbincallahan/QRencryption
/Encryptor.py
UTF-8
1,627
3.34375
3
[]
no_license
from random import Random p = 10 ** 55 + 21 def diffieHellman(base, e): return pow(base, e, p) def elGamalKey(g, a): if(not (1 <= a and a <= p)): return -1 return pow(g, a, p) def elGamalEncrypt(m, g, A): rand = Random() k = rand.randrange(1, p) c1 = pow(g, k, p) c2 = m * pow(A, ...
true
cfaf66cf77f306b5d9d44525e876b0bd6e1bd41e
MBetters/cpeg498_venom
/spider_raspberry_pi/client1.py
UTF-8
582
2.796875
3
[]
no_license
import urllib2 import time import serial import json #A custom server is used to send signals to the Raspberry Pi info_url = "http://128.4.25.156/info" ser = serial.Serial('/dev/ttyACM0', 9600) ser.timeout = 1 time.sleep(1) last_action = '' while True: try: latest_info = urllib2.urlopen(info_url).read() ...
true
969e4eb70b2ea4e8a1b23414b7cae52427249371
marbali8/DD2437
/lab3/train.py
UTF-8
1,601
2.703125
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt def hopfield(train, recall, seq = False, max_epochs = 1000): P = recall.shape[0] N = recall.shape[1] # number of units w = 1 / N * train.T @ train # w = np.random.uniform(0, 1, (N, N)) converged = False e = 0 _recall = recall.copy() ...
true
37a76c468a3a33630cd2c3a3211ba57b08a0f71b
colorfulxd/RNN
/utils.py
UTF-8
3,266
3.296875
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections import random import numpy as np def read_data(filename): with open(filename, encoding="utf-8") as f: data = f.read() data = list(data) return data def index_data(sentences, dictionary): shape = sentences.shape sentences ...
true
82f65516a76e84f2db903ade6cda470eb96c22c6
robgoyal/CodingChallenges
/CodeFights/Arcade/Intro/edgeOfTheOceans/matrixElementsSum.py
UTF-8
717
3.65625
4
[]
no_license
# Name: matrixElementsSum.py # Author: Robin Goyal # Last-Modified: June 20, 2017 # Purpose: Return the price of the rooms which aren't # inhabited by ghosts. Ghosts are marked by a 0 price # and any room below a 0 shouldn't be included in the price def matrixElementsSum(matrix): # List to s...
true
b7d3eb7303aa4eeb73d87c6e01572f15ad589287
Aasthaengg/IBMdataset
/Python_codes/p02681/s866265041.py
UTF-8
182
3.390625
3
[]
no_license
s=input() t=input() i=0 bool=False while i<=len(s)-1: if s[i]!=t[i]: print("No") bool=True break else: i=i+1 if bool==False: print("Yes")
true
c2b6cec2d7d623326cdd6dd21be16d7b8849ae7a
nerohuang/LeetCode
/Tree/897. Increasing Order Search Tree(Easy).py
UTF-8
1,048
3.65625
4
[]
no_license
897. Increasing Order Search Tree# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def increasingBST(self, root: TreeNode) -> TreeNode: store = []; ...
true
f57661bac3973899c91155eb8787a2c83d2ee163
shon/sphc
/sphc/tests.py
UTF-8
2,021
2.796875
3
[]
no_license
import sys sys.path.append('.') import re import unittest from sphc import tf class TestSPHC(unittest.TestCase): def test_textarea(self): ta = tf.TEXTAREA() textarea_pat = '<TEXTAREA[ ]*>[ ]*</TEXTAREA[ ]*>' ta_s = str(ta) self.assertEqual(bool(re.match(textarea_pat, ta_s)), Tru...
true
225de85556ee0c8111af0c6bb4bb03f905b76166
yoavfreund/BigData_Management
/boto.scripts/iam_admin_example.py
UTF-8
844
3.15625
3
[]
no_license
""" IAM boto examples: In this example, we show how to create a group for administrators who have full access to IAM functionality but no access to other AWS services. """ import boto # # First create a connection to the IAM service # iam = boto.connect_iam() # # Create an Admin group for users who have admin privile...
true
900d883ff06606a89ce4516aaf73a608c3ef42bd
cloew/WiiCanDoIt-Framework
/CwiidResearch/TestAll.py
UTF-8
1,039
2.734375
3
[]
no_license
import cwiid import WiimotePairing import sys X_UPPER = 200 X_LOWER = 50 Y_UPPER = 200 Y_LOWER = 50 Z_UPPER = 200 Z_LOWER = 50 def main(): wiimote = WiimotePairing.PairWiimote() report_mode = 0 report_mode ^= cwiid.RPT_BTN report_mode ^= cwiid.RPT_ACC wiimote.rpt_mode = report_mode wiimote.mesg_callback = c...
true
7176bbd360884a75a534e60d3b20e81f7a266f49
AkshayVarma29/Power-Programmer
/01_Easy/03_first_fit_room.py
UTF-8
425
3.84375
4
[]
no_license
# You are given a list of integers rooms and an integer target. # Return the first integer in rooms that's target or larger. If there is no solution, return -1. rooms = [15, 10, 30, 50, 25] target = 20 def solve(rooms, target): for value in rooms: if value>=target: return value else: ...
true
87c1426d1203205ad921a80a4899e7f351590c0e
LiuDaveLiu/ibllib
/brainbox/modeling/poissonGLM.py
UTF-8
3,335
2.9375
3
[ "MIT" ]
permissive
import torch import torch.nn as nn import torch.nn.functional as F from tqdm import tqdm class PoissonGLM(torch.nn.Module): def __init__(self, in_features, out_features): super(PoissonGLM, self).__init__() self.linear = nn.Linear(in_features, out_features) def forward(self, x): out = ...
true
68dbb323dd2a2ad10d4359875d6eae4d6f3cb00c
xiaoxiaoniao1/python
/angus/exercise_02.py
UTF-8
309
2.953125
3
[]
no_license
result = set() with open("1.txt","r") as f: for line in f.readlines(): result.add(line.replace(" ","")) keys = [] for i in result: key = i.split("=")[0] if key in keys: print "key is exists %s" % key else: keys.append(key) with open("2.txt", "w") as f: for i in result: f.write(i)
true
b5b9bd8d7917f96735343051c8e4596eb141c771
growth-austen/disavow_automator
/checker.py
UTF-8
1,526
3.1875
3
[]
no_license
import requests import webbrowser import time #pulls in the disavow file with open('disavow.txt', 'a+') as disavow: disavow_urls = disavow.read().splitlines() #adds a comment to the disavow file that you're updating it today disavow.write("\n\n#Updated " + time.strftime("%x") ) #pulls in your URLs with open('urls...
true
c969895af192a5b2a054e7ae23528c595ca91c64
mohitsudhakar/coding
/greedy/activity_selection.py
UTF-8
320
3.34375
3
[]
no_license
def activity(): times.sort(key=lambda t: t[1]) i = 0 ans = 1 for j in range(1, len(times)): if times[j][0] >= times[i][1]: ans += 1 i = j return ans if __name__ == '__main__': times = [(1,2), (3,4), (0,6), (5,7), (8,9), (5,9)] ans = activity() print(ans)
true
2c69770b4f19e95e68f93eb5a4f5fa011c9bba18
zhcui/PyDMRG
/simple_scripts/excited_states/two_site_model.py
UTF-8
4,277
2.59375
3
[]
no_license
import numpy as np ######## Inputs ############################## # Model alpha = 0.35 # In at left beta = 2/3 # Exit at right s = -1 # Exponential weighting gamma = 0 # Exit at left delta = 0 # In at right p = 1 # Jump right q = 0 # Jump Lef...
true
4555c9a731ba43ab12b383d3e454c0a666cae306
emilioramirezeguia/Sprint-Challenge--Data-Structures-Python
/names/names.py
UTF-8
1,673
4.28125
4
[]
no_license
import time from binary_search_tree import BSTNode start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] # Return the list of ...
true
0263acaba62ae4f73203e61a2613308ab661cee2
noctrog/Breakout_DDQN
/common.py
UTF-8
3,274
3.078125
3
[]
no_license
import numpy as np class SumTree: data_pointer = 0 def __init__(self, capacity): self.capacity = capacity self.tree = np.zeros(2 * capacity - 1) self.data = np.zeros(capacity, dtype=object) def __len__(self): return self.capacity def _propagate(self, idx, change): ...
true
a24c97d21f0b09b433c1b2fa54a8a2c0dd074490
DigitalGlobe/pyveda
/pyveda/vedaset/veda/loaders.py
UTF-8
6,259
2.515625
3
[]
no_license
import os import json import mmap import numpy as np import requests from tempfile import NamedTemporaryFile from shapely.geometry import shape import warnings from pyveda.config import VedaConfig cfg = VedaConfig() def args_to_meta(name, description, dtype, imshape, mltype, public, sensors, backgrou...
true
dfba49c2875cdb5e2e3e481d420d3764e7be691d
michikrug/PogomBOT
/DataSources/DSRaid.py
UTF-8
1,350
2.71875
3
[]
no_license
from geopy.distance import vincenty class DSRaid: def __init__(self, gym_id, name, latitude, longitude, start, end, pokemon_id, cp, move1, move2): self.gym_id = gym_id self.name = name self.latitude = latitude self.longitude = longitude self.start = start ...
true
7930b267e98a09fb3cdfcb71675e57838be63337
GuillaumeCisco/substra-backend
/substrabac/node/management/commands/get_outgoing_node.py
UTF-8
1,068
2.515625
3
[ "Apache-2.0" ]
permissive
from django.core.management.base import BaseCommand from node.models import OutgoingNode def pretty(s1, s2): return f'{s1.ljust(64)} | {s2.ljust(128)}' class Command(BaseCommand): help = 'Get outgoing nodes' def add_arguments(self, parser): parser.add_argument('node_id', nargs='?') def han...
true
5806e64c3fa3e380b98af7de861d2874f6047eee
davidwilson826/SpaceGameTests
/MoveTest2.py
UTF-8
1,326
3.234375
3
[]
no_license
from ggame import App, Sprite, ImageAsset, Frame from math import sin, cos, pi class Player(Sprite): asset = ImageAsset("images/four_spaceship_by_albertov_with_thrust.png", Frame(0,0,85,125)) def __init__(self, position): super().__init__(Player.asset, position) self.fxce...
true
11f7860f61be7745548a4201e3160489d6b9253b
akangakang/agv_car
/smartcar/scripts/lane_detection.py
UTF-8
10,856
2.578125
3
[]
no_license
#!/usr/bin/env python # -*- coding: UTF-8 -*- import rospy from sensor_msgs.msg import Image from cv_bridge import CvBridge from geometry_msgs.msg import Twist import cv2 import numpy as np class laneDetector: def __init__(self): rospy.init_node('lane_detection', anonymous=True) rospy.Subscriber('/...
true
f42d27c818e6aec9b6f98c0f7eece331cbf21771
avetmichael/OOP1-10.10.2019
/OOP1.py
UTF-8
3,869
3.59375
4
[]
no_license
import random import math class Vector(): def __init__(self, n): self.m_length = n self.arr = [] for i in range(n): self.arr.append(random.randint(-10, 10)) def ex_211(self): a = 0 b = 0 for i in self.arr: if i > 0: ...
true
f91661d3224a8188710c2a07f3fbf2db817a39f1
jwon/adventofcode
/2021/15/p2.py
UTF-8
1,623
3.28125
3
[]
no_license
from queue import PriorityQueue with open('input.txt') as f: cavern = [[int(i) for i in line.strip()] for line in f] full_cavern = [[((level-1+i+j) % 9)+1 for i in range(5) for level in row] for j in range(5) for row in cavern] max_row = len(full_cavern) max_col = len(full_cavern[0]) min_row = 0 min_col = 0 # ...
true
01bed0e737aa27e5864b279fc47b97a21fb15c2e
ryanleofficial/gps-controller
/testgps.py
UTF-8
584
2.953125
3
[]
no_license
import GPSController import time gps = GPSController.GpsController() try: # start controller gps.start() while True: print "latitude ", gps.fix.latitude print "longitude ", gps.fix.longitude print "time utc ", gps.utc, " + ", gps.fix.time print "altitude (m)", gps.fix.altit...
true
6c25572bcd6ba71b13238349544756687ce65c9f
nicolasgapa/ML-methods-for-binary-classification
/Neural_network.py
UTF-8
2,522
2.921875
3
[]
no_license
# -*- coding: utf-8 -*- """ Nicolas Gachancipa Neural Network - Binary Classification """ # Imports. # -------------------- # import tensorflow.keras as k from keras.callbacks import ModelCheckpoint from sklearn.model_selection import train_test_split import pandas as pd import numpy as np # Define d...
true
b8996d07573b6a16e36634092dbfb5ea16a27d69
ekeilty17/Personal-Projects-In-Python
/Math/gcd.py
UTF-8
191
3.1875
3
[]
no_license
def gcd(a, b): #accounting for this annoying case if b > a: a, b = b, a #gcd(a,b) = gcd(b,a%b) --> Euclid's Algorithm while b != 0: a, b = b, a%b return a
true
fc8a0b0f0638a995be60270acf041b884a297e03
subhamb123/Python-Projects
/Level 2/forRange.py
UTF-8
50
3.09375
3
[ "MIT" ]
permissive
for i in range(1,13): print(i, end = ' ')
true
072d685874b83727dd88c93ecf3aa0d5827d9108
fabouzz/Marble_processing
/BubbleTracking/BubbleDetection.py
UTF-8
7,777
2.71875
3
[]
no_license
import cv2 as cv import trackpy as tp import os import imutils import numpy as np import pandas as pd from skimage import filters, morphology, util from scipy import ndimage class Bubble: """ Classe permettant la détection de bulle sur une mesure vidéo - Plusieurs méthodes de filtrage sont proposés ...
true
ee1465e4aac2402e4332ff0bb9bfdc6dcfc6a251
Namratha76/python-project
/main1.py
UTF-8
1,057
3.6875
4
[]
no_license
import os from os import system from car import Cars system('cls') carList = [] numberOfcars = int(input('How many cars do you want to buy? >> ')) #typeOfcar = input('What is the brand name of the car >> ') print() for a in range(numberOfcars): car = Cars() print(f'----- car # {a + 1} -------') make =...
true
d3ac13f7ee97bbaf0397581a44034db8b2572c53
immutableweb/immutableweb-core
/immutableweb/tests/content_tests.py
UTF-8
2,217
2.75
3
[]
no_license
#!/usr/bin/env python3 import os import unittest from tempfile import NamedTemporaryFile from nose.tools import assert_equals from immutableweb import stream from immutableweb import crypto from immutableweb import exception as exc class TestContentEncryption(unittest.TestCase): def setUp(self): self.fil...
true
a7e3578837dbec8683b894b01a79821c3c9233b8
jugosoft/social_analyzer
/Social Analyzer/src/api.py
UTF-8
2,552
2.890625
3
[]
no_license
import vk import src.configuration as conf import src.helpers as help """ Perfoms actions on API. """ class ApiVK: session = vk.Session() api = None def __init__(self): self.session = vk.AuthSession(access_token=conf.apikey, scope=['offline', 'messages', 'friends']) self.ap...
true
b55d081edf9291fa8acb57c9221baf6a7a2130be
dsavelyev/vpirod-mapreduce
/matmult.py
UTF-8
1,661
2.84375
3
[]
no_license
#!/usr/bin/env python2 import csv import glob import operator import os.path import string import sys import mincemeat as mm fieldnames = ['matrix', 'row', 'col', 'value'] def run_server(mat_file): matrices = list(csv.DictReader(mat_file)) matsize = max(int(x['row']) for x in matrices) + 1 s = mm.Serv...
true
311af6dd9d7aecd301d4ba2b3a39908b8b4e4036
julibinho/cloneCluster
/data/Real/Extracted_CDR3/extract_cdr3_imgt.py
UTF-8
2,359
2.890625
3
[]
no_license
import sys #=================================================================================== #Global variables Input_file = "" #Usage usage = "python format_output_realdata.py -i Input_file \n" #=================================================================================== #Read parameters def readParamete...
true
838067a57d1219306e1356d1c71890dc8249fd9b
witlox/gc3pie
/gc3libs/etc/archive-etl.py
UTF-8
9,070
2.921875
3
[]
no_license
import argparse import bz2 import csv import json import os import tarfile import time from multiprocessing import Manager, Process, current_process, cpu_count from zipfile import ZipFile, is_zipfile class Decoder(object): def __init__(self): self._dialect = None self._data_type = None def _...
true
f41baf5e93f50384833b62d00bd0eb0a9d199666
xakinon/Ballscrew
/calicurate.py
UTF-8
15,129
2.671875
3
[]
no_license
# -*- coding: utf-8 -*- import itertools import math class Calicurate(): def __init__(self, calculationConditions, ballscrews=[None], servomotors=[None], couplings=[None], supportunits=[None], linearguides=[None]): self.conditions = calculationConditions self.ballscrews = ballscrews ...
true
404f93ed37d33601ae298fe535c10d7bc7774d0d
Sethupathy-Lab/miRquant
/bin/process_all_summary2tab.py
UTF-8
4,304
2.515625
3
[]
no_license
#!/usr/bin/python2 usage = ''' Usage: python process_all_summary2tab.py path/to/sample Where: path/to/sample = Full path to any unique file in g1Results directory -eg: /proj/seth_lab/users/USER/smrnapipeline/SAMPLE. ''' import sys import os import argparse import subprocess as sp from utils import loa...
true
329ad8e25f4e18ab64d40f4d611fdf1fa06692d2
MidhunGopalakrishnan/SmartHomeGestureControl
/pythonflaskservercode.py
UTF-8
719
2.609375
3
[]
no_license
from flask import Flask, request, redirect import os app = Flask(__name__) app.config["VIDEO_UPLOADS"] = "/Users/midhungopalakrishnan/IdeaProjects/FlaskTestServer/videos/uploads" @app.route("/upload-videos", methods=["GET", "POST"]) def upload_videos(): if request.method == "POST": if request.files: ...
true
12410ff81cb269af110b78882fac68e40ca066c4
Aasthaengg/IBMdataset
/Python_codes/p02935/s268569779.py
UTF-8
162
3
3
[]
no_license
N = int(input()) v = list(map(int, input().split())) while len(v) > 1: v.sort() t1 = v.pop(0) t2 = v.pop(0) v.append((t1 + t2) / 2) print(v[0])
true
589deed79b0771119c5eb06eeb68c252ec17d142
alvarolop/digital_comms
/digital_comms/ccam_fixed.py
UTF-8
8,159
3.109375
3
[ "MIT" ]
permissive
from pprint import pprint class Exchange(object): """ Defines a generic exchange. Arguments --------- data: dict """ def __init__(self, data, cabinets, dist_points, buildings): self.id = data["id"] self.exchange_type = data["exchange_type"] self.cabinets_per_exchange = d...
true
27b2d3c8d3e6fb5ef29755325c764324eacf08fd
yrudreLau/Course-assignment_graduate_fresh
/dataset_utils.py
UTF-8
1,810
2.9375
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Wed Nov 25 11:40:04 2020 @author: Jiajun Liu BP Neural network homework: dataset_loads """ import numpy as np import pandas as pd import sklearn.linear_model import sklearn.datasets from sklearn.model_selection import StratifiedShuffleSplit breast_cancer = skl...
true
636d6d1f9f62e4b765cd5c2e1c5c57e2e40c261d
learningandgrowing/Data-structures-problems
/length_linkedlist.py
UTF-8
651
3.71875
4
[ "MIT" ]
permissive
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def getCountRec(...
true
1a66f3fca21fc2e19a2bfe5ae352dedc6044c59a
andnp/single-hyperparameter-benchmark
/shb/shb.py
UTF-8
10,506
2.6875
3
[]
no_license
import numpy as np from logging import warn from typing import Any, Callable, Dict, List, Generator, Optional, Tuple, Union from PyExpUtils.utils.dict import merge from PyExpUtils.utils.permute import getParameterPermutation, getNumberOfPermutations # Type aliases Params = Dict[str, Any] AlgDescription = Tuple[str, Pa...
true
d4adcebaae429a1651194c32821949cb130f1170
dxcv/VectorTrader
/VectorTrader/mod/sys_simulation/simulation_broker.py
UTF-8
4,567
2.609375
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Mon Aug 21 13:23:37 2017 @author: FSB """ # simulation_broker.py from VectorTrader.events import EVENT,Event from VectorTrader.model.orders import FillOrder class SimulationBroker(): def __init__(self,env): self.env = env self.blotter = [] ...
true
fabfd0bfdecb59c99aacdf821dd874f7c44080d9
omnunum/vscope
/vscope/shared.py
UTF-8
2,601
2.640625
3
[ "MIT" ]
permissive
from datetime import datetime as dt from os import path as osp import sys import logging import json def grab_logger(): log = logging.getLogger('vscope') if not log.handlers: log.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ...
true
a29ccbcc26362e6a8f4d2606ba5c7b67de9b4bd2
miguelgfierro/pybase
/machine_learning/k_nearest_neighbor.py
UTF-8
985
3.5
4
[ "BSD-3-Clause" ]
permissive
from sklearn.neighbors import NearestNeighbors import numpy as np def knn(X, Y, K): """Find the K nearest neighbor in X for each point in Y. Args: X (np.array): A matrix, where the columns are the features and the rows are the examples. Y (np.array): A matrix to query, where the columns a...
true
a96ddad3ebea6ac15a2ab2265f3b96255bf7f4e5
joeaoregan/AIT-MSc-AppliedMaths
/Wk2-DataStructures-Compression/Data_Structures/List_Data_Structure1.py
UTF-8
633
3.75
4
[]
no_license
players = ['Simon', 'Mary', 'Louise', 'Tony'] print (players) print (players[2]) print (players[1:3]) print ('The numbers of players in the list is: %d' %len(players)) players.sort() print (players) players.insert(3,'Karol') print (players) players.remove('Mary') print (players) players.sort() print (players) players.a...
true
80542406c3aef8ba1f2b74dfe4c3966fd1d1fd7e
lei940324/toy
/小工具/word套打/word.py
UTF-8
2,337
3.109375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """ Created on Wed Apr 8 13:49:12 2020 @author: lei """ import pandas as pd import docx from docx.shared import RGBColor # 设置颜色 from docx.shared import Pt # 设置字体 from docx.oxml.ns import qn # 设置中文字体 class word(): def __init__(self, doc, data): self.doc = doc ...
true
b0f8a599034a3a76fee6715b63646d624b851dcb
hongyong3/TIL
/Algorithm/Swea/D2_1288.py
UTF-8
404
2.78125
3
[]
no_license
import sys sys.stdin = open("D2_1288_input.txt", "r") T = int(input()) for test_case in range(T): N = int(input()) num, K = [], 0 while len(num) <= 9: K += 1 mat = str(K * N) for i in range(len(mat)): if mat[i] not in num: num.append(mat[i]) ...
true
fb0ff3e258065b90ac9673f0d982a3683c3a95ef
svram/sorting-benchmark
/bubblesort.py
UTF-8
202
3.234375
3
[]
no_license
def bubbleSort(A): indexOfLast = len(A) - 1 for i in xrange(len(A) - 1): for j in xrange(indexOfLast): if A[j] > A[j+1]: A[j], A[j+1] = A[j+1], A[j] indexOfLast -= 1 return A
true
002b58293faaf82f7dc5bd3f23498a5d5ccf8932
WuPedin/LeetCodePractice
/LintCode/Hash/129_Rehashing_Hash.py
UTF-8
1,238
3.984375
4
[]
no_license
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param hashTable: A list of The first node of linked list @return: A list of The first node of linked list which have twice size """ def...
true
2331e2dfe1ce9cebe5767d7bb56838990031786f
SeanEmac/Python
/MosquitoMultiplication.py
UTF-8
306
2.953125
3
[]
no_license
import sys for line in sys.stdin.readlines(): M, P, L, E, R, S, N = map(int, line.split()) mosquito = M pupae = P larve = L for i in range(N): M = pupae // S P = larve // R L = mosquito * E mosquito = M pupae = P larve = L print(M)
true
1da5c962cb2a58fb80c63cce5c0f490c35dbef42
yo-ga91/PycharmProjects
/GetIpFromUrls.py
UTF-8
1,212
2.796875
3
[]
no_license
import csv, socket #import whois, time #Format shortlist csv Ursl Name; # def getip (s_name="google.ru"): try: ip = socket.gethostbyname(str(s_name)) print(ip) return ip except Exception: #myDomenStatus=whois.whois(str(s_name)) print('error') return 'error' #...
true
285ce4a4909a55a5011caf577b290aa5c1ec8344
latermonk/Hadoop
/Python/mapper.py
UTF-8
398
2.71875
3
[]
no_license
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Date : 2018-04-16 14:13:44 # @Author : Nessaj (fourierrr@gmail.com) # @Link : http://www.csdn.com/fourierrr """mapper.py""" import os import sys import re for line in sys.stdin: line = line.strip() words = re.split('[,.?\s"]',line) for word in wo...
true
30edc82395de3bbe2db8d1cff2168a64bde74c4b
Aasthaengg/IBMdataset
/Python_codes/p02937/s421385214.py
UTF-8
527
2.984375
3
[]
no_license
import bisect s=input() t=input() i=1 dic=[[] for _ in range(27)] for ss in s: dic[ord(ss) - 97].append(i) i+=1 for index,item in enumerate(dic): item.sort() dic[index]=item posi=-1 count=0 for tt in t: if dic[ord(tt) - 97]==[]: print(-1) exit() r=bisect.bisect_right(di...
true
91b4c07b5a485128e3169fa74e392d2ce5e21d87
ATurn1p/RPG-Game
/main.py
UTF-8
2,884
3.921875
4
[]
no_license
from setup1 import person from setup2 import Intimidate import random # recalling the classes and provding the arguments and values stare = Intimidate("Stare", 10, 100, "dark") growl = Intimidate("Growl", 12, 120, "dark") bark = Intimidate("Bark", 40, 200, "dark") # creating a list int_list = [stare, growl, bark] # cr...
true
b8fd0c72e6f04691a3f3eccb7e7120bd3000d0b7
KTD-prototype/100-fungoes-of-python-data-analysis
/chapter4/33_analyse_clusteringresults.py
UTF-8
1,645
2.953125
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- # code for python3 import pandas as pd from sklearn.cluster import KMeans from sklearn.preprocessing import StandardScaler from dateutil.relativedelta import relativedelta import matplotlib.pyplot as plt # set the MAX num of rows and columns that will be displayed at term...
true
60e9cb3d37973964677d992fda68b12abff7e99f
daniel-leinad/progrepository
/hw9/hw9.py
UTF-8
1,285
3.265625
3
[]
no_license
#5 variant from random import choice #sozdaem massiv i slovar words = [] hints = {} #otkryvaem fayl i zagruzhaem iz nego dannye v massiv i slovar f = open("hw9.csv", "r", encoding="utf-8") s = f.readlines() f.close() for oneline in s: wordinfo=oneline #ubiraem \n v konce strok if wordinfo[-1...
true
a4f9ded968b8cb944a400d823c0aacf38570b941
Peterror/KSR-2018
/kNN/kNN.py
UTF-8
5,248
3.59375
4
[ "Apache-2.0" ]
permissive
import operator from collections import Counter from math import sqrt import time from random import randint class StructNeighbour(object): """ Structure of the neighbour. Pass objects of this class to kNN distance functions. """ def __init__(self, vector, name): super(StructNeighbour, sel...
true
898328fec0d22e522c021c7693e6fc639aa7cbb8
Tao4free/Python
/multiprocessing/sharelist/sharelist_01.py
UTF-8
511
3.265625
3
[]
no_license
# https://stackoverflow.com/questions/23623195/multiprocessing-of-shared-list from multiprocessing import Process, Manager def worker(x, i, *args): sub_l = manager.list(x[i]) ch = chr(ord('A') + i) sub_l.append(ch) x[i] = sub_l if __name__ == '__main__': manager = Manager() x = manager.list(...
true
1410df41af8d34078ebb074c380af7c7fa28c1cd
WBradbeer/port-routing
/tests/tests.py
UTF-8
4,660
2.71875
3
[ "MIT" ]
permissive
import os import unittest import pandas as pd import lp_helpers as lp import opt_helpers as oh FILE_PATH = os.path.abspath(os.path.dirname(__file__)) class OptTestCase(unittest.TestCase): def setUp(self): case_path = "/../data/test_cases/tc1/" self.c_sent = pd.read_csv(FILE_PATH + case_path ...
true
78bc53e45a99d9794e829607e48cd647f221fbf5
Roflcopterpaul/Python-Practice
/Random Apps/todo_list.py
UTF-8
1,032
4.375
4
[]
no_license
# make a list that will hold onto items todo_list = [] # print out instructions on how to use app print("What do you want to get done today?") def show_help(): print(""" Enter 'HELP' for more options Enter 'SHOW' to see your current list Enter 'DONE' when you are finished adding items """) show_help() def sho...
true
fdfff4bee1262f87dde53950b12da8aa8b30e8d9
Eacaen/diff_Code_Learn
/python/源代码/第二章/2_3.py
UTF-8
166
2.859375
3
[]
no_license
class A: def funX(self): print( "funY()") def funY(self): print ("funY()") if __name__ == "__main__": a = A() a.funX() a.funY()
true
84990cff79148da549052e0a5ae7cf4baaf7e564
cosminm/test
/management/load_csv.py
UTF-8
1,303
2.78125
3
[]
no_license
import sys, os, csv from random import choice def import_csv(): csv_filename="OUTPUT.csv" djangoproject_home="/home/io/Projects/management/management/" sys.path.append(djangoproject_home) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from cms.models import Student, Profesor, Clasa ...
true
212e7500bd0d53e76288272e66f534ba904ca52e
allisonchanykei/SchoolPython
/tcpsend.py
UTF-8
597
3.109375
3
[]
no_license
#!/usr/bin/python #CLIENT-send tcp import socket import sys #python tcpsend.py ip port #AF_INET = adress family internet #SOCK_STREAM = TCP (Transmission Control Protocol) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #tcp sock_stream host = sys.argv[1] port = int(sys.argv[2]) s.connect((host,port)) #create con...
true
c65b9a6796d8ac8a0fff7c1ac06e5ffb7a5bbf23
sky1456723/ML2018FALL
/hw2/train.py
UTF-8
4,110
2.796875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sun Oct 14 13:19:00 2018 @author: jimmy """ import numpy as np import pandas as pd #process training data train_x = pd.read_csv('./data/train_x.csv') train_y = pd.read_csv('./data/train_y.csv') ''' #withou one-hot sex = pd.get_dummies(train_x['SEX'], prefix='gender') education =...
true
9e07f94988b43be20dca56cabd3428f620865a8e
100th/Baekjoon-Algorithm
/Tests/test10 Amo/01.py
UTF-8
80
2.9375
3
[]
no_license
user_input = str(input()) result = user_input.replace(' ', '') print(result)
true
77c616384074d21377516149c084f2872053cb8b
rasc0/Caesar
/PythonAssignment.py
UTF-8
1,955
4.21875
4
[]
no_license
# rotate an array n times: def rotate(n, array): for i in range(0, n): # the next lines of code are to rotate an array ONE time, hence the for loop above first = array[0] for j in range(0, len( array) - 1): # Removes the first object and shifts each object one index to the ...
true
852b634aecbdf02530ea15393549bac20aa85b1e
mwangikinuthia/db
/db_init.py
UTF-8
1,188
2.53125
3
[]
no_license
import json # ----------- db.__init__.py ----------- # from flask import Flask # from flask_sqlalchemy import SQLAlchemy # app = Flask(__name__) # app.config.from_object('config.DevelopmentConfig') # db = SQLAlchemy(app) # -------------------------------------- # EP: once we are importing db from db.__init__ we have...
true
513dcafdd19f2789b7d2b46e049f56ad3bfcab91
Spartabariallali/Pythonprograms
/Functions/functions4.py
UTF-8
220
3.609375
4
[]
no_license
#passing and artbitrary amount of arguments def make_pizza(*toppings): for topping in toppings: print('-' + topping) make_pizza('pepperoni') make_pizza('mushroom','green peppers','extra cheese') make_pizza
true
3acc8a941c4399a57190fad6fd10ae1815a49219
Destroyer4114/Python
/cleararr.py
UTF-8
456
2.546875
3
[]
no_license
t= int(input()) for i in range(t): n,k,x= map(int,input().split()) a= list(map(int,input().split())) c=sum(a) a.sort(reverse=True) t1=0 r=0 while t1 ==0: if a[r]+a[r+1]>x and k>0: c=c-(a[r]+a[r+1])+x k= k-1 r=r+2 else: r=r+1 ...
true
e7c31152917829330dd7b381599cec6502aeb979
ganjingcatherine/LeetCode-1
/Python/Word Ladder II.PY
UTF-8
1,900
3.546875
4
[]
no_license
""" Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example, Given: start = "hit" end = "cog" dict = ["hot","dot","dog","lot","log"] Return [...
true
e70161a03e61354250c453785ae44409e28401ef
ycgithub2000/example_projects
/LSTM_DQN_Price_Prediction/models.py
UTF-8
1,346
2.734375
3
[]
no_license
from torchvision import models import torch.nn as nn import torch import numpy as np class PrototypeModel(nn.Module): def __init__(self, input_size, num_layers): super(PrototypeModel, self).__init__() self.input_size = input_size self.num_layers = num_layers final_concat_size = 0 ...
true
785f560f35c7fe639bb51b6d255f8d664c93d308
willsnedegar/bookReview
/import.py
UTF-8
284
2.90625
3
[]
no_license
import csv f = open("books.csv") reader = csv.reader(f) for isbn, title, author, year in reader: db.execute("INSERT INTO books (isbn, title, author, year) VALUES (:isbn, :title, :author, :year)", {"isbn": isbn, "title": title, "author": author, "year": year}) db.commit
true
276b231fa8986c1bae1944f2b3d3e95a78a89933
phenry725/blinds-api
/api.py
UTF-8
2,299
2.734375
3
[]
no_license
#load API frameworks from time import sleep import RPi.GPIO as GPIO from flask import Flask, request, json app = Flask(__name__) #Pin numbers based on Board mapping for Raspbery Pi 3 Model B UP_GPIO_PIN = 37 STOP_GPIO_PIN = 35 DOWN_GPIO_PIN = 33 #multi-step because it doesn't look like python supports simultaneous in...
true
7a691b981e0230005dc7c5038a6b24900d308ef6
311210666/Taller-de-Herramientas-Computacionales
/Clases/Programas/gradosS.py
UTF-8
321
2.875
3
[]
no_license
import grados from grados import * L1 = listaC(-15,32,10) L2 = listaF (L1) mostrarListas(L1,L2) a = input ("¿Cuál es el extremo izquierdo del intervalo?") b = input ("¿Cuál es el extremo izquierdo del intervalo?") n = input ("Cuántos subintervalos?") L1 = listaC (a, b, n) L2 = listaF (L1) mostrarListas (L1, L2)
true
991f2ee5d92181cff86bfa9d0e4bdbbc9ebcac7f
janeymcnab/inheritance_lab
/inheritance_examples.py
UTF-8
3,444
3.53125
4
[]
no_license
class Animal: def __init__(self, name): self.name = name class Cat(Animal): def __init__(self, name, fur, kittens): super().__init__(name) self.fur = fur self.kittens = kittens def meow(self): return "Meow" class Chicken(Animal): def __init__(self, name, ...
true
99e897967df8e34e55f34a5a158d971f12e2a872
Rashmima/riya
/yer.py
UTF-8
155
3.4375
3
[]
no_license
year=int(input("Enter the year number:")) if((year%400==0)||(year%100!=0))); print("%d year is leap year"&year); else: print("%d is not leap year",&year)
true
6469b767754df834631e61ebdc0503ab76638fcf
mooonpark/flask-demo
/timer/timer.py
UTF-8
1,268
2.609375
3
[]
no_license
# coding: utf-8 from flask import Flask, render_template, redirect, url_for, flash, request import re app = Flask(__name__) app.config['SECRET_KEY'] = 'hard to guess' @app.route('/') def index(): return redirect(url_for('timer',num=25*60)) @app.route('/<int:num>s') @app.route('/<int:num>') def timer(num): ...
true
38fb649360612bfa3ede42e4715c30d6bd45e0ea
ucsb-seclab/difuze
/helper_scripts/setup_difuze.py
UTF-8
3,968
3
3
[ "BSD-2-Clause" ]
permissive
""" This script clones and setups llvm and friends in the provided folder. """ import argparse from multiprocessing import cpu_count import os import sys def log_info(*args): log_str = "[*] " for curr_a in args: log_str = log_str + " " + str(curr_a) print log_str def log_error(*args): log_s...
true
df35cbec22f4d071fbed2502c0ec850a42d39d99
Joshualau23/Physics-474
/Assignment1.py
UTF-8
5,031
3.03125
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sun Sep 15 19:42:15 2019 @author: joshu """ ### Q1 a) import numpy as np import matplotlib.pyplot as plt import datetime from astropy.io import ascii import random from scipy.stats import linregress from astropy import constants from math import e ''' Mv_list = [] R_list = [...
true
00e48265f0aec2e3b238ba73ff78e95793eebe81
kushagragarwal2443/course-contents
/Bayesian/autohire/encoder.py
UTF-8
856
3.078125
3
[]
no_license
import numpy as np class LabelEncoder: """ Label encode a series of labels """ def __init__(self, data) -> None: self.__training_data = data self.index_to_token = list(set(data)) self.token_to_index = { token: index for index, token in enumerate(self.index_to_token...
true
3e19d413875fb9bc382076f8fe7474a7bec20563
theOrangeBlock/LabArchive
/populateArchive.py
UTF-8
549
2.84375
3
[]
no_license
#gsheets doesnt like empty string (or maybe this is just a python thing) #so replacing all empty string with N/A from gsheets import Sheets sheets = Sheets.from_files('credential.json', 'storage.json') url = 'https://docs.google.com/spreadsheets/d/1LBaWNrb4opb5k8QVYNUDL3x8LuAIt79q2VbO5nGFP5o/edit#gid=0' sheet ...
true
bfd9b737dd0bd60983e052c0715a26924ca785ea
gwhealan/422-proj2
/Main.py
UTF-8
5,130
2.90625
3
[]
no_license
import sys import WordFinder import AStar import Grid RUN_CONSTANT = 5 # ---------------------- # HELP PRINTING FUNCs. # ---------------------- def help_general(start='', end=''): print('Print the help stuff') def help_run(start='', end=''): print('Print help info for run') def help_dict(start='', end=''):...
true
dfb30d1434758184f8d76fc0e0adecc241102f7b
Ran-oops/python
/2/01Python中的字符串数学列表 内键函数 数学模型/12.py
UTF-8
1,107
4.15625
4
[]
no_license
#列表的序列操作 #列表相加 lists1 = ['张全蛋'] lists2 = ['赵铁柱','李小花'] lists = lists1 + lists2 print(lists) #列表相乘 lists = ['小嘴'] result = lists * 5 print(result) #索引操作 lists = ['守护在她身边','帮她盖上被子','亲吻她一下','把她XX了'] #男人的期待 print(lists[2]) print(lists[3]) print(lists[3]) print(lists[3]) print(lists[1]) print(lists[0]) #女人的...
true
fc8ed15d706bc03aa572f0b0203d5bdc5c3fb9a1
daniel-reich/ubiquitous-fiesta
/Aj377wZtxWya7gjK9_10.py
UTF-8
107
3.03125
3
[]
no_license
def sum_missing_numbers(lst): return sum([k for k in range(min(lst) + 1, max(lst)) if k not in lst])
true
3f26a1f88f331b8bb4fcd8651ac0fdea4b2ae969
DevJ5/Socket_Programming
/UDP_Pinger/udppinger_server.py
UTF-8
391
2.859375
3
[]
no_license
#!/usr/bin/python3 import random from socket import * # Create UDP Socket serverSocket = socket(AF_INET, SOCK_DGRAM) serverSocket.bind(('', 12000)) print("Server listening on port: 12000") while True: rand = random.randint(0,10) message, address = serverSocket.recvfrom(1024) message = message.upper() i...
true
9f5846f5d55b11dff7b72e23da0892ed7f91332e
frhl/transcription-factor-binding-site-prediction
/cnn_model.py
UTF-8
2,970
2.953125
3
[]
no_license
def cnn_model(x_ph, dropout_rate): ################################################################################ # - x_ph: one-hot encoded DNA input data / placeholder of shape [?, 1, 101, 4] # - dropout_rate: dropout rate (1 - keep probability) of dropout layer # Return values: # - y_hat_op: cl...
true
34f7ed122d56bdab1d803efd0740a74b7ea80c76
WhyGKing/PythonClass_2104
/Exercise/Exercise_crawling.py
UTF-8
429
2.625
3
[]
no_license
import os from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager url = 'https://www.gopax.co.kr/exchange/btc-krw' def crawl(self): driver = webdriver.Chrome(ChromeDriverManager().install()) driver.maximize_window() driver.implicitly_wait(10) driver.get(url) bitc...
true