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
1d966a78397ed0097c156a80f4d5cc003b220165
aburenko/intermediate-python
/enumarate.py
UTF-8
333
4.625
5
[]
no_license
# using of enumarate list_e = ["first", "second", "third", "fourth"] # bad style # for i in range(len(list_e)): # print(i, list_e[i]) # good style with enumerate for number, element in enumerate(list_e): print(number, element) # turn list to dict enumerated new_dictionary = dict(enumerate(list_e)) print(new...
true
16745e64f7aa3f1a6de544077f405f8ae4eb6f84
eldridgejm/publish
/publish/_publish.py
UTF-8
2,568
3.140625
3
[]
no_license
import pathlib import shutil import re from .types import BuiltArtifact, PublishedArtifact # publishing # -------------------------------------------------------------------------------------- class PublishCallbacks: def on_copy(self, src, dst): """Called when copying a file.""" def on_publish(sel...
true
9486f5869e4d37d85bd41725a5cdf1554282be5c
bacalfa/cmu06-640
/Codes/HWs/hw03_3.py
UTF-8
2,215
2.765625
3
[]
no_license
#!/bin/python ''' Problem 3 ========= ''' from jasp import * from enthought.mayavi import mlab from ase.data.vdw import vdw_radii from ase.data.colors import cpk_colors from ase.data.molecules import molecule CO2 = molecule('CO2') CO2.set_cell([8, 8, 8], scale_atoms=False) CO2.center() with jasp('molecules/hw03/CO2...
true
eec5ac741644fbc351650858d8438a0ee4e6cf32
Luketss/p2p_player
/peer2.py
UTF-8
682
2.6875
3
[]
no_license
import socket import json peer = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) peer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) peer.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) peer.bind(("", 37020)) avaliable = [1, 2] def treat_msg(data, addr): data = data.decode('utf-8...
true
c9dc2274419a658aeeac74fd7a1b0741a6eec9d8
pranavdave893/Leetcode
/shortest_palindrome.py
UTF-8
520
3.546875
4
[ "MIT" ]
permissive
""" Q: https://leetcode.com/problems/shortest-palindrome/ A: https://leetcode.com/problems/shortest-palindrome/discuss/60191/Share-my-easy-AC-python-solution-(without-fancy-algorithm) """ class Solution: def shortestPalindrome(self, s: str) -> str: s2 = s[::-1] n = len(s) final_index = 0 ...
true
aeb829c849abbb8c941ba0b45c6c4913fb31cd94
edwinekyang/srpms
/srpms/accounts/models.py
UTF-8
2,282
2.546875
3
[]
no_license
""" Define database models for user through Django ORM (Object-relation Mapping). """ __author__ = 'Dajie (Cooper) Yang' __credits__ = ['Dajie Yang'] __maintainer__ = 'Dajie (Cooper) Yang' __email__ = 'dajie.yang@anu.edu.au' from django.db import models from django.core.exceptions import ValidationError from django....
true
7389bac5b20c041c05311f89964680614138b56d
Jyotsnab07/CRD-Key-Value-Datastore
/access.py
UTF-8
2,631
3.078125
3
[]
no_license
import time import json import source as x import threading from threading import Thread print("This is a student marks data store containing student name and marks in the form of key-value pair[Student-pair]") print("Example of format ") with open('data.json') as j: json_data = json.load(j) print(js...
true
cb17c67efae0da1c7068c108ac15f979bf83e4a2
joezuntz/flask
/src/scripts/hilbert2info.py
UTF-8
6,030
2.78125
3
[]
no_license
#! /usr/bin/env python """ USAGE: hilbert2info.py <CLASS_INPUT> <FIELDS_INFO_FILENAME> EXAMPLE: hilbert2info.py lcdm_10bins.ini lcdm_10bins/fields-info.dat This script takes a CLASS input file and creates a file used by FLASK describing the simulated fields and redshift bins (basically a table of field and redsh...
true
6601af62ca34aa507bd8f38d7a3729b15395fc19
archiver/spoj
/palin.py
UTF-8
371
3.15625
3
[]
no_license
import sys import pdb def ispalin(d): t=str(d) n=len(t) for i in range(0,n/2): if t[i]!=t[n-1-i]: return False return True def nextpalin(num): number=num+1 while True: if ispalin(number): return number number+=1 if __name__=='__main__': inp=sys.stdin inp.readline() for line in inp: ...
true
08672c1f6964f6605910456a235561b3bd510972
yuancf1024/learn-python-exercise
/2020-01-lxf-python/generator1.py
UTF-8
334
4.1875
4
[]
no_license
# 要创建一个generator,有很多种方法。第一种方法很简单,只要把一个列表生成式的[]改成(),就创建了一个generator L = [x * x for x in range(10)] print(L) g = (x * x for x in range(10)) print(g) # 输出generator 的所有元素 g = (x * x for x in range(10)) for n in g: print(n)
true
21353c870b9d0cb8166f58ad536cf4e6cafe0600
gogognome/mastermind
/mastermind/game.py
UTF-8
2,003
3.953125
4
[ "Apache-2.0" ]
permissive
import random from typing import Sequence, Tuple import attr @attr.s(auto_attribs=True) class Score: correct_position: int wrong_position: int @classmethod def determine(cls, guess: Sequence, code: Sequence) -> "Score": if len(guess) != len(code): raise ValueError(f"The guess mus...
true
97087574269480954bec076b50e1ef268c093119
oahehc/LEARNING
/deeplearning/quiz_1-10.py
UTF-8
917
3.1875
3
[]
no_license
# encoding: utf-8 import numpy as np import math def softmax(scores): if((type(scores[0]) is int) | (type(scores[0]) is float)): row = len(scores) sumArray = 0 for j in range(row): sumArray += math.exp(scores[j]) resultArray = np.full(row, 0, dtype=float) for j...
true
d6f9dd3983493a81614d4796abc38f915ba35b67
larsks/bitparser
/bitparser/__init__.py
UTF-8
6,750
2.828125
3
[]
no_license
import os import sys import struct from exceptions import * import utils __author__ = 'Lars Kellogg-Stedman' __email__ = 'lars@oddbit.com' __version__ = '1' __license__ = 'GPL' class Container(dict): def __init__ (self, struct, *args, **kwargs): self.__struct__ = struct if 'fd...
true
bcb5aab486fbb396e3c190702de45053ab637305
mbarja/SistemasDistribuidos
/L1/p3/a/Cliente/ClientStub.py
UTF-8
2,323
2.71875
3
[]
no_license
import grpc import sys import file_system_pb2_grpc, file_system_pb2 import time class Stub: def __init__(self, host_port): self._appliance = host_port self._channel = None self._stub = None def connect(self): try: self._channel = grpc.insecure_channel(self._applian...
true
a42cb17ddb64080863f545d26b88de09bc6cf61b
Teslothorcha/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
UTF-8
1,189
3.40625
3
[]
no_license
#!/usr/bin/python3 """ Class Square """ from models.rectangle import Rectangle class Square(Rectangle): """ Class Square manager that inherits from rectangle """ def __init__(self, size, x=0, y=0, id=None): """constructor""" self.size = size super().__init__(size, size,...
true
afbf42414b46fc03f58e4d574a098765318873cc
simplaj/WLAN_predict
/Scoring method/function/ErrorShow.py
UTF-8
1,083
2.921875
3
[]
no_license
# -*- coding=utf-8 -*- import math import matplotlib.pyplot as plt import tensorflow as tf import matplotlib as mpl # 画出测试数据集的预测数据和测试数据 from sklearn.metrics import mean_squared_error def draw(predData, trueData, name): i = 0 fig = plt.figure(figsize=(24, 12)) for name1 in ['RP', 'TI', 'TT', 'UT', 'LMS'...
true
17d77e46a25d218643871690ed9c05d07b897cc0
datto171/TranQuocDat-fundamental-c4e23
/Labs/Lab3/freaking_match.py
UTF-8
657
2.984375
3
[]
no_license
from random import randint, choice # import func_intro from func_intro import eval def generate_quiz(): x = randint(0,10) y = randint(0,10) op_list = ["+", "-", "*", "/"] o = choice(op_list) error = randint(-1,1) r = eval(x, y, o) + error return x, y, o, r a, b, op, r = generate_quiz() prin...
true
b66583001768b401198830c8d1b33a5fc7b5fdfd
silverbulletmdc/mdc_tools
/scripts/smail
UTF-8
1,234
2.5625
3
[]
no_license
#! /usr/bin/env python # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText from email.header import Header import yaml import click import os @click.command() @click.argument('title') @click.option('-r', '--receiver', default="") @click.option('-c', '--content', default="") def main(receiver, ...
true
537f827324b5a8f7943d4fd2af4b335f28900224
atosh/unittest_tutorial
/src/pyunit/exercise/item.py
UTF-8
174
2.625
3
[]
no_license
# coding: utf-8 ''' Created on Oct 15, 2013 @author: toshi ''' class Item(object): def __init__(self, name, price): self.name = name self.price = price
true
f582e2aa011451dc24c31276d7214458ade2b561
PBati9876/Pythoncode
/linuxcommand.py
UTF-8
358
2.625
3
[]
no_license
#!/bin/python """ Linux command in python """ import os import commands import subprocess os.system("touch testfile") os.system('echo "This is the content" >> testfile') os.system('cat testfile') files = os.popen("ls").read() #subprocess = subprocess.check_output("ls") #print subprocess commands = commands.getoutp...
true
6d51ab90e852c92027b3899e12fa50e62a371f9f
WooHooMan43/dungeon-game
/models/game_object.py
UTF-8
1,066
3
3
[]
no_license
from __future__ import annotations import pygame import pygame.mask, pygame.sprite from models.screen import Screen # The base class for about everything in the game. Creates basic # attributes that each of its subclasses uses. class GameObject(pygame.sprite.Sprite): def __init__( self, dest: tuple[int, ...
true
6f7e8a099369d43304cfa81bfc56bda8dd91bbb8
IGBC/scripts
/sketch_runner.py
UTF-8
2,701
2.875
3
[ "Unlicense" ]
permissive
#!/usr/bin/python3 import os import sys from importlib.machinery import SourceFileLoader # Library imports (Imports only for use in the sketches library) import time # try to import RPi.GPIO if is available try: import RPi.GPIO as GPIO print("RPi.GPIO Loaded") except ImportError: print("todo mask GPIO") ...
true
4ea7aaf9c60bfaafae4b5b889f28723d0cb7488b
tiantiantian123/curiosity_baselines
/rlpyt/utils/misc.py
UTF-8
2,247
3.484375
3
[ "MIT" ]
permissive
import numpy as np import torch def wrap_print(text): """Prints things wrapped with a border and some spacing for clarity. """ print('\n') print('-'*50) print(text) print('-'*50) print('\n') def iterate_mb_idxs(data_length, minibatch_size, shuffle=False): """Yields minibatches of inde...
true
14d072a941bdc54b0c1b30853f9a472ed85be622
Sarandeep2000/Logistic-Regression
/LogisticRegression.py
UTF-8
7,628
3.46875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Tue Mar 30 16:17:29 2021 @author: Sarandeep Singh """ import numpy as np from math import exp from Functions import accuracy_score from matplotlib import pyplot as plt class Logistic_Regression: """ A class for binary Logistic Regression Classifier. ...
true
408f38ce0061a9db42a7155f2c3a684cffe11e20
3point14thon/bill_analyzer
/src/govinfo_api.py
UTF-8
4,869
2.9375
3
[ "MIT" ]
permissive
import json import requests import pandas as pd from gov_api_key import api_key from xml_parser import mk_dict class GovInfoApi(): ''' Object designed to interact with govinfo.gov to retrive bill data. Could be used or modified to extract other government data. Methods: get_collection: ...
true
07071bec7ef98fdfd364bec54328709ea7a890cc
optittm/bugprediction
/utils/database.py
UTF-8
1,023
2.515625
3
[ "MIT" ]
permissive
import os from typing import List from configuration import Configuration from models.file import File from models.version import Version from utils.proglang import guess_programing_language def save_file_if_not_found(session, file_path): file = session.query(File).filter(File.path == file_path).first() if no...
true
a6fed87213ccff54e11eb4f02bfc4f12374bbd1f
pierre94/Design_pattern_of_python
/Decorator.py
UTF-8
457
3.109375
3
[]
no_license
# encoding: utf-8 """ @version: 1.0 @author: pierrexiong @file: Decorator @time: 27/05/2018 7:09 PM """ import time def log(func): def wrapper(*args, **kw): print "call %s():" % func.__name__ return func(*args, **kw) return wrapper @log def now(): print time.time() """ 装饰器模式与代理模式有点相近。p...
true
983a34355b1c7f1fb5ac2d4f05b722d68d3c7a3f
borao/make-teams
/student.py
UTF-8
605
3.078125
3
[]
no_license
class Student(object): name = None affiliation = "" skill = 0 outgoing = 0 grade = 0 years = -1 power = 0 def __init__(self,name, affiliation, skill, outgoing, grade, years): self.name = name self.affiliation = affiliation self.skill = skill self.outgoing...
true
934787dcb791ae5f6ddd94caba9685938df0b599
ChaitanyaDave/Stock-Market-Analysis
/KBC_Trading.py
UTF-8
10,798
3.03125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """ Created on Mon Nov 11 16:31:04 2019 @author: chait """ import getpass as gp import os from datetime import datetime as dt from datetime import timedelta as td import pandas as pd import KBC_trading_functions as pk #functions def analyse_company(company_df): search_...
true
a0868fccd8f5d025b3b064ee72f00a3cf6ba394b
kanika-mahal/DigitalClock
/main.py
UTF-8
687
2.71875
3
[]
no_license
from tkinter import * from tkinter import ttk from tkinter import font import time import datetime def quit(*args): root.destroy() def clock_time(): time= datetime.datetime.now() time= (time.strftime("%H:%M:%S")) txt.set(time) root.after(1000,clock_time) root = Tk() root.title("DIGITAL CLOCK - ka...
true
78da43c116677bf875a03a98b47102e877de8aa9
KataTech/JustEnoughHotDogs
/exploratory.py
UTF-8
1,909
3.8125
4
[]
no_license
import pandas as pd import matplotlib.pyplot as plt # This is a python script for creating visualization of sales changes per month to see if month is a variable # we would like to subset the data by. df = pd.read_csv("/Users/kaihung/Desktop/Rice/Data Science/Chevron_2021_Datathon_Challenge/filesForStartOfDatathon/t...
true
a5b0dd8c0715226ebf0d51fc7aff05218c0c8087
zx1989031/pytest
/regular.py
UTF-8
825
3.765625
4
[]
no_license
#coding:utf8 #!/usr/bin/python/ #fileName : regular.py 正则 import re str = 'hello world' print str.replace('hello','namehello') pattern = re.compile(r"hello") match = re.search(pattern,str) print match.group(0) # key = r"<html><body><h1>hello world<h1></body></html>"#这段是你要匹配的文本 # p1 = r"(?<=<h1>).+?(?=<h1>)"#这是我们写的正则表...
true
87125de85af9d820e68d7f6b48bea250fc55081f
angrybayblade/myclass_bot
/main.py
UTF-8
2,819
2.671875
3
[]
no_license
import time import re import json from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.webdriver import WebDriver with open("./creds.json", 'r') as file: creds = json.loads(file.read()) class ClassBot(webdriver.Chrome): _USERNAME = creds['username'] ...
true
32bdbbeeb5a42e7844d9d930fb4416e734697758
jpablor2/solar-system-visualization
/vis_algorithms/SURF/example_surf.py
UTF-8
479
2.59375
3
[]
no_license
import cv2 import numpy as np img = cv2.imread('image5.jpeg',0) # Create SURF object. You can specify params here or later. # Here I set Hessian Threshold to 400 surf = cv2.xfeatures2d.SURF_create(400) # Find keypoints and descriptors directly kp, des = surf.detectAndCompute(img,None) surf.setHessianThreshold(500) # A...
true
ee7f230e719da7f673f4ff92e81286ed7d7abee3
yonamagic/Students4Students
/SQL.py
UTF-8
1,565
2.953125
3
[]
no_license
import sqlite3 def create(): conn = sqlite3.connect('user1.db') conn.execute('''CREATE TABLE users ( username TEXT PRIMARY KEY NOT NULL, password TEXT NOT NULL, strong_subjects TEXT NOT NULL, weak_subjects TEXT NOT NULL );''') conn.execute('''CREATE TABL...
true
b0fde1d0173cfd649f8bf30953bbe07f61a9adbc
tooManyNeutrons/PHYS_581
/Assn1/rng/plot.py
UTF-8
844
3.515625
4
[]
no_license
import numpy as np import matplotlib.pyplot as plt def gaussian(x, mu, sigma): factor = 1 / (np.sqrt(2 * np.pi) * sigma) return factor * np.exp(- (x - mu)**2 / (2 * sigma**2)) # 1.2 Random Numbers from a Normal Distribution with open('normal.txt', 'r') as file: lines = file.readlines() ar, ctl...
true
d70292d53624bc3eb69f341616b17ce6e7bc2bcd
sohammehta96/Leetcode
/896. Monotonic Array.py
UTF-8
615
4.09375
4
[]
no_license
""" An array is monotonic if it is either monotone increasing or monotone decreasing. An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j]. Given an integer array nums, return true if the given array is monotonic, o...
true
bfbad8f9b9878d1c5b3e7fb256422bb7b756c4ca
mehulghosal/DHVEPB
/Data.py
UTF-8
646
3.59375
4
[]
no_license
#class for data structure so i can kep track of all necessary info class Data(): #parameters #t is file number; lat is line number; lon is posiiton in line; v is the actual value def __init__(self, time, latitude, longitude, v): self.t = time self.lat = latitude self.lon = longitude self.val = v def __str_...
true
05e79eca49fe58db934bdf520d542a0318534122
DeanHe/Practice
/LeetCodePython/MaxNumberOfKSumPairs.py
UTF-8
1,376
3.859375
4
[]
no_license
""" You are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array. Return the maximum number of operations you can perform on the array. Example 1: Input: nums = [1,2,3,4], k = 5 Output: 2 Explanation: Starting with n...
true
7df80bda6181ae776b0e6d2eaf2cc82ecd0f6b4b
TaihuLight/renew-skyline-path-query
/skyline_path/test/renew_selector_test.py
UTF-8
1,358
2.78125
3
[ "MIT" ]
permissive
import unittest import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from algorithms.renew_selector import RenewSelector from strcture.multi_attribute_graph import MultiAttributeGraph from strcture.edge import Edge E1 = Edge(0, 1, 2, [6]) E2 = Edge(1, 1, 2, [1]) E3 = Edge(2, 1, 2, [3]) ...
true
5cf89539a8328180d78ee639d8eed87a5d934492
RenanGreca/CompSec
/trab2/crawler.py
UTF-8
1,144
2.734375
3
[ "LicenseRef-scancode-public-domain" ]
permissive
import urllib2 from bs4 import BeautifulSoup website = 'https://www.letras.mus.br' response = urllib2.urlopen(website + '/legiao-urbana/') content = response.read() encoding = response.headers['content-type'].split('charset=')[-1] html = unicode(content, encoding) html_soup = BeautifulSoup(html, 'html.parser') ul ...
true
9738cddbfa124011e53a72123282949bf656edd8
santosh241/Windary
/Python/ThreeSum.py
UTF-8
1,953
3.765625
4
[ "MIT" ]
permissive
# -*- coding: UTF-8 -*- # # Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? # Find all unique triplets in the array which gives the sum of zero. # # Note: The solution set must not contain duplicate triplets. # # For example, given array S = [-1, 0, 1, 2, -1, -4], # # A solution...
true
2cd022e6544fa69f92c9b8f671d99428aa7a08c4
Yajie-Chu/cs242
/Assignment2.0/New folder/Graph.py
UTF-8
3,883
3.484375
3
[]
no_license
# -*- coding: utf-8 -*- """ @author: aldos """ from Node import Node import heapq class Graph(object): def __init__(self): self.nodelist = [] self.edgelist = [] ''' Function that return nodelist ''' def get_node(self): return self.nodelist ''' Function...
true
1dadbc9c6b7c912f9f8fdc98b9310f692e1ff155
phisinger/Algorithmen
/Python/arry.py
UTF-8
640
3.984375
4
[]
no_license
# Pseudo Code!!! global n n = 500 zahlen = [] global k k = 100 for i in range(0,k): zahlen.append(i) def loeschen(array, stelle): for a in range(stelle, k): array[a] = array[a+1] k = k - 1 def insertMid(array, stelle, ele): b = k while(b >= stelle): array[b+1] = array[b] ...
true
e4e032b497235600a24ecee0b5db8b57503c8f9d
aliechoes/pytorch-multichannel-image-classification
/optimizers/__init__.py
UTF-8
1,130
2.546875
3
[ "MIT" ]
permissive
import torch.nn as nn import torchvision import torch def get_optimizer( optimizer_configs, model, checkpoint): """ function for getting the optimizer: Args: ml_config(dict): machine learning config model: machine learning model checkpo...
true
128d5fbbd02e81a869e113e3bee296525b788e35
airportbio/airport-web
/data/refined_json_files/refine_jsons.py
UTF-8
489
2.609375
3
[]
no_license
import glob import json from string import punctuation import re regex = re.compile("[{}]".format(re.escape(punctuation))) for f_name in glob.glob('*.json'): print(f_name) with open(f_name) as f: jf = json.load(f) new = [{'path': d['path'], 'files': d['files'], '...
true
e42c1b9ecf0496ae9a21f0ed0647b8cb08b6ff8d
sachin-pandit/Hobby-Projects
/MarkovModel/hmmdecode3.py
UTF-8
7,167
2.671875
3
[]
no_license
#!/usr/bin/python3.4 -tt import sys import math from collections import defaultdict tag_dict = {} end_tag_dict = {} line_count = 0 emission_dict = defaultdict (dict) trans_dict = defaultdict (dict) probability = defaultdict (dict) backpointer = defaultdict (dict) def print_dictionary(): print ("Emission >>>>...
true
170b4bdae2b10c30c7635b410104b41dc3b0dd8d
yunedaalfajr/Distracted-Driver-Detection-1
/webcam.py
UTF-8
5,059
2.65625
3
[]
no_license
#import numpy as np #import cv2 # #cap = cv2.VideoCapture(0) # #while(True): # # Capture frame-by-frame # ret, frame = cap.read() # # # Our operations on the frame come here # #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # # # Display the resulting frame # cv2.imshow('frame',frame) # if cv2.wait...
true
986c262e5cf79aa454af4d2de25a50b056637705
L-Ezray/zpp
/5.py
UTF-8
88
3.59375
4
[]
no_license
a = 1 while a <= 100: if a%7==0 and a%5!=0: print(a) a+=1 print('over')
true
1da5009e548cf97251c6f10ed960da3ed62997c8
tl-its-umich-edu/kartograafr
/util.py
UTF-8
5,720
3.375
3
[]
no_license
# Converted to Python 3. # Make UtilMixin a no-op. # remove CaptureStdoutLines import datetime import logging logger = logging.getLogger(__name__) # Method names are now hard-coded so this is a no-op. class UtilMixin(object): def methodName(self): logger.debug("call methodName") def stringContainsAllC...
true
2f745c57e9bb47b67b328f7007179c6b87eb3dfe
scbentley/Robotic-Arm
/drawbot.py
UTF-8
4,791
2.9375
3
[]
no_license
#!/usr/bin/env/python3.7 import time, math, sys import board, busio import RPi.GPIO as GPIO from surface_mapping import * from adafruit_servokit import ServoKit import adafruit_vl53l0x from motors import IK_Solve from get_xy import get_xy, read_SVG from svgpathtools import svg2paths2 #Initialize servo communication k...
true
ca63e11e933d8e56def3d78af41c7da8c92401ba
mmazz/Analisis_go
/Analisis/KGS/handicap19.py
UTF-8
1,116
2.5625
3
[]
no_license
import os name = os.path.basename(__file__).split(".py")[0] import matplotlib.pyplot as plt import pandas as pd import numpy as np df = pd.read_csv('./data_set.csv') skills = [df[df.handicap==i].iloc[-1].h_mean for i in range(2,10)] sigmas = [df[df.handicap==i].iloc[-1].h_std for i in range(2,10)] NumeroPartidas = [] ...
true
12d6840cb8a613c9abaeb3ac55cfca9b3172e982
jensmcatanho/data-driven_astronomy
/week1/1b/2_mean_of_a_set_of_signals/program.py
UTF-8
422
3.09375
3
[ "MIT" ]
permissive
import numpy as np def mean_datasets(files): datasets = [] for file in files: datasets.append(np.loadtxt(file, delimiter=',')) result = np.mean(datasets, axis=0) return np.round(result, decimals=1) if __name__ == '__main__': # Test Case 1 print(mean_datasets(['data1.csv', 'data2.csv'...
true
18806ab9cffcf0e083d67188ea18f113e779533b
DoZor-80/LeetCode
/python/1732_Find_the_Highest_Altitude.py
UTF-8
266
2.953125
3
[ "MIT" ]
permissive
class Solution: def largestAltitude(self, gain: List[int]) -> int: max_alt = 0 current_alt = 0 for g in gain: current_alt += g if current_alt > max_alt: max_alt = current_alt return max_alt
true
406c5f84c3cc24dc2951171c5aaaab609110902b
easorwe/apiAutoTest
/script_测试用例脚本/test_weidaima_script.py
UTF-8
3,064
2.625
3
[]
no_license
# 导包 import unittest, logging from api_被封装测试接口.test_01_login_api import LoginApi from api_被封装测试接口.test_weidaima_api import EmpoyeeApi import app_配置信息 # 创建测试类 from utils_工具类 import assert_common class TestIHRMEmployee(unittest.TestCase): # 初始化unittest的函数 def setUp(self): # 实例化登录 self.login_...
true
2a36ba5aae145d5b7aeee60f2c964dd69a6df159
buzuloiu/robix
/research/symbolic_math.py
UTF-8
2,951
2.90625
3
[]
no_license
import numpy as np from sympy import trigsimp, simplify, Symbol, cos, sin, asin, acos, atan from sympy.matrices import Matrix, eye from sympy.printing import latex from sympy.solvers import solve config = { 'theta_1': {'min': -80.0, 'max': 80.0, 'offset': 0, 'l': 9.28, 'd': 16.39, 'alpha': 0.0, 'theta_offset': 0,...
true
e6510feb6f4c4885e733489090d4a0725acc8875
mirrorneuronwang/HCP_face_connectome
/PPI analysis/ICA-AROMA-master/ICA_AROMA_functions.py
UTF-8
23,168
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
#!/usr/bin/env python # Functions for ICA-AROMA v0.3 beta from __future__ import division from __future__ import print_function from future import standard_library standard_library.install_aliases() from builtins import str from builtins import range from past.utils import old_div def runICA(fslDir, inFile, outDir, m...
true
eca1078f96313f945baba1e48eb61609bc9fec2c
Calebhn/Disaster-response-pipeline-project
/data/process_data.py
UTF-8
3,556
3.578125
4
[]
no_license
import sys import pandas as pd from sqlalchemy import create_engine def load_data(messages_filepath, categories_filepath): ''' Loads messages and categories ,csv files and merge them into one dataframe. Parameters ---------- messages_filepath : string file path containing messages. cat...
true
71a6a40a363db83112b2f92585e0c3244f78cea7
cclain/LeetCode-Problem-Solution
/289. Game of Life.py
UTF-8
964
3.375
3
[]
no_license
class Solution(object): def gameOfLife(self, board): """ :type board: List[List[int]], int = 0 dead,1 live " 2 dead -> live ; 3 live -> dead :rtype: void Do not return anything, modify board in-place instead. """ if not board:return m = len(board); ...
true
48f738d0d1b5b5b36638bb81aef82fc110c28645
nelsonwhf/element_lda
/generate_data.py
UTF-8
877
2.671875
3
[]
no_license
import logging, gensim, codecs, sys __author__ = 'nelson' def generate_dictionaries(infile,outfile): dictionary=gensim.corpora.Dictionary(line.lower().split() for line in open(infile)) dictionary.save(outfile) print("dictionary save done!:\n"+dictionary.token2id) return dictionary def generate_corpus(...
true
134d27b484dc64226705a5a5a04dfa36f908bb8c
Sayan-Otaku/Assignment12
/iterate-dict.py
UTF-8
118
3.625
4
[]
no_license
d = {'x': 1, 'y': 2, 'z': 3} for the_key, the_value in d.items(): print(the_key, 'corresponds to', the_value)
true
6b02ee8fd9e36776994b818eca1fb2bcadce7119
alanfranz/pydenji
/pydenji/test/test_overrider.py
UTF-8
525
2.71875
3
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- # (C) 2010 Alan Franzoni. import unittest from pydenji.userproperties.overrider import override_with class Obj(object): pass class OverridenConfig(object): def myobj(self): myobj = Obj() myobj.property1 = 123 return myobj class TestPrope...
true
40e1739b03776c83f7aedbf2aa9ee854967b9a21
Ogleiv/IWI
/collocations_common.py
UTF-8
3,716
3.15625
3
[]
no_license
from stemming.porter2 import stem def sort_collocations(collocations): collocations_list = [] for first_word in collocations.keys(): for second_word in collocations[first_word].keys(): collocations_list.append((first_word, second_word, collocations[first_word][second_word])) collocatio...
true
cd71393f8d40796998f5944b4167c4a42d1dd1b7
daiyunbin/hyys2018
/utils/file_utils.py
UTF-8
181
3.015625
3
[]
no_license
def save(content, data_dir, name): """将内容以name命名保存在data_dir目录中""" file = open(data_dir + '/' + name, 'w+b') file.write(content) file.close()
true
85f4d4e9fd826846ce951dd296bab5b8d223277f
uniericuni/leetcode
/106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py
UTF-8
817
3.359375
3
[]
no_license
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def build(self, postorder, inorder): if len(inorder)==0: return None curVal=post...
true
69fb7dcd36f3d6954f97700a4874ce4424b7dc1e
zahraEskandari/persian-profanity-check
/preprocessing.py
UTF-8
4,511
2.71875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Wednesday January 15 22:26 @author: eskandari """ from __future__ import unicode_literals from hazm import * from nltk.stem.wordnet import WordNetLemmatizer import pickle #hazm import re import html import pandas as pd import numpy as np import pickle def cleanhtml(raw_html): ...
true
b3fa3c4bbb77dfad04356b793727cd818d3f538d
fabiomacdo/curso-python
/mundo3/ex076.py
UTF-8
484
3.234375
3
[]
no_license
listagem = ('Notebook', 2300, 'Mochila', 90, 'Teclado', 50, 'Mouse', 25, 'CPU', 800, 'Headphone', 120, 'Webcam', 60, 'Impressora', 900, 'Nobreak', 300) print('-'*40) print(f'{"LISTAGEM DE PREÇOS":^40}') print('-'*40) for pos...
true
4e5f56685fee398a168e5d10dd71c95666af6225
aircode610/project3
/orders/models.py
UTF-8
1,402
2.78125
3
[]
no_license
from django.db import models # Create your models here. class User(models.Model): name = models.CharField(max_length=60) lastname = models.CharField(max_length=60) email = models.CharField(max_length=60) username = models.CharField(max_length=60) password = models.CharField(max_length=60) def ...
true
b92c7844cd40c4f7b262ccc31713a53d1400d02c
bhaveshrane125/Grocerry-DBMS-project-
/unit_table_dao.py
UTF-8
681
2.765625
3
[]
no_license
from sql_conector import get_sql_connection from customer_dao import create_customer def get_units(con): mycursor=con.cursor() query = "select * from unit_table;" units_data = [] mycursor.execute(query) for (u_id, unit_name) in mycursor: units_data.append( { "u_i...
true
4e387771d269c5e3c0d3cb8ebad064a5c8ae9cbf
vmara2/Cookbook
/JES Jython/vmara2lab12.py
UTF-8
2,792
3.265625
3
[]
no_license
#Valo Mara #vmara2 #CS111 #Lab 12 #Monday at 3:00PM #Increasing and decreasing volume according to time def makeSoundByte(sound1, start, end): sound2 = makeEmptySound(end - start) samples1 = getSamples(sound1) samples2 = getSamples(sound2) for i in range(0, end-start, 1): value1 = getSampleValue(s...
true
25b4ee3690031236911b05621cb6ba0cc8869eb7
lmbaeza/AdHocProject
/Compiler/src/SemanticAnalyzer/SemanticAnalyzer.py
UTF-8
18,390
3.171875
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- from Compiler.src.utils import Global from Compiler.src.utils.Global import VariableGlobal from Compiler.src.utils.Global import getCode from Compiler.src.IntermediateCode.IR import IntermediateRepresentation from Compiler.src.Exceptions.Exceptions import * varGlobal = V...
true
c84a485f2af1a65bc40aea3e396462558d25a2e5
carmar04/di
/Listas 5/P5_2_CarlesSoroMartinez.py
UTF-8
749
4.125
4
[]
no_license
checked = True while checked == True: print("Dígame cuántas palabras tiene la lista:") numeroLineas = input() numeroLineas = int(numeroLineas) indice = 0 lista = [] while indice < numeroLineas: print("Digame la palabra "+str(indice + 1)+":") respuesta = input() lista.append(respuesta) indice = indice + 1 ...
true
1b5ab550d2262b4c5d03902c96d1ad12c82a3549
miracle-xxw/challenge-python
/0229/challenge-1.py
UTF-8
1,049
3.40625
3
[]
no_license
#print("hello ") #name='adea ' #print(name.title()+"\npython") #print(name.rstrip()) #3**2 #age=12 #print("wo"+str(age)) #2/29 #import this languages = ['java','c','php','python','.net'] print(languages[0]) print(languages[-1]) languages.append('c++') languages.insert(1,'go') for lan in languages: print(lan) ...
true
5320099436f36ec272b0081468c89cf4db35b19f
MacGuff/clrs
/insert_sort.py
UTF-8
799
3.875
4
[]
no_license
def insert_sort(A): ''' 对于已排序的子数组A[0:j],从后往前依次扫描, 将值与A[j]比较, 并向后移动一个位置,直到 找到第一个不小于A[j]的值A[i],将A[j]插入i处. 如此子数组A[0:j+1]也变成有序的了. ''' for j in range(1,len(A)): key = A[j] i = j-1 while i >= 0 and A[i] < key: A[i+1] = A[i] i -= 1 ...
true
8d5a99fc78763ddf7e69c46253f3446d661d248a
kimth007kim/python_choi
/Chap8/8_9.py
UTF-8
732
3.609375
4
[]
no_license
import turtle import random import math player = turtle.Turtle() player.color("blue") player.shape("turtle") player.penup() player.speed(0) screen=player.getscreen() a1 =turtle.Turtle() a1.color("red") a1.shape("circle") a1.penup() a1.speed(0) a1.goto(random.randint(-300,300), random.randint(-300,300)) a2 =turtle.Tu...
true
cc46c33cb64d557772ee9e540d5d819262a1542a
chng3/Python_work
/第十二章练习题/圣诞大战.py
UTF-8
703
3.0625
3
[]
no_license
import sys import pygame from settings import Settings from rocket import Rocket def run_game(): # 初始化游戏并创建一个屏幕对象 pygame.init() ai_settings = Settings() screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height)) pygame.display.set_caption("圣诞大战") # 创建一艘火箭 rocket = Rocket(screen)...
true
5696fc7f0050afa8892cac8a9dc70306e9b8e772
kamicloud/gersang-spritelib
/bmps2spr.py
UTF-8
820
2.859375
3
[ "MIT" ]
permissive
import os import sys import time from spritelib.sprite import open_sprite if __name__ == '__main__': if len(sys.argv) < 2: print 'Usage: python bmps2spr.py spr_name' sys.exit(0) spr_name = sys.argv[1] if not os.path.isdir(spr_name): print 'Error: invalid sprite directory name.' ...
true
adf993e13e7a75cc595328c559fb8a8a81fb047a
uukefei/liuyaopaipan
/sizhu.py
UTF-8
7,153
2.734375
3
[]
no_license
#!/usr/bin/python3 import time from datetime import date class sizhu(object): def __init__(self, year, month, day, hou, minu): self.year = int(year) self.month = int(month) self.day = int(day) self.hou = int(hou) self.minu = int(minu) self.t0 = time.mktime...
true
37581c5e86edd31c4abbe544496170358e7ee2b7
antoinert/masters-thesis
/ml-algorithms/preprocessing.py
UTF-8
8,811
2.65625
3
[]
no_license
import pandas as pd import numpy as np import glob from sklearn.utils import resample from sklearn.model_selection import train_test_split from imblearn.over_sampling import RandomOverSampler def remove_unnecessary_columns(master_table): master_table.drop('has_churned_y', 1, inplace=True) master_table.drop('...
true
38d8fd7efbdf9f5fa924ace8c3fc6794d4efcb5f
NoelGlamann/Movie-Library
/3make_serachbys.py
UTF-8
11,499
3.65625
4
[]
no_license
#!/usr/bin/python3 #Noel Glamann #27 January 2020 ''' this is going to be used to develop my own program following in the footsteps of our example with big_brother.py.''' '''last updated: Jan 27, 2020''' #---IMPORT------------------------------------------- import pickle as p #---FUNCTIONS------------------------...
true
d4406c81af0a91ecbe43a30395a5b005496ae160
shagunattri/PythonScripts
/python/solves/D1/1_2.py
UTF-8
83
3.1875
3
[]
no_license
# dict n =int(input()) dict = {} for i in range(1,n+1): dict[i]=i*i print(dict)
true
3761f083538ba3582e3ac6240ec625a75e42c3ff
plammens/HearthBombe
/Minion.py
UTF-8
2,243
3.375
3
[]
no_license
""" """ import copy import Card import Player class Minion(Card.Card): def __init__(self, mana_cost: int, attack: int, health: int): super(Minion, self).__init__(mana_cost) self._attack = {'base': attack, 'current': attack} self._health = {'base': health, 'current': health} sel...
true
98ca2a522ff2769cc0bc1f3db21d132f903a0e56
jrubin01/Contrastive-Predictive-Coding
/plotter.py
UTF-8
622
2.5625
3
[]
no_license
import matplotlib.pyplot as plt plt.switch_backend('agg') def plot(trains,valids,dataset,code_size): plt.plot(trains) plt.ylabel("train loss") plt.xlabel("epochs") plt.title("Train Losses") plt.savefig("./Contrastive-Predictive-Coding/train_loss_"+dataset+"_"+str(code_size)+".pn...
true
dd48168fccb1050759c804a187c33ed901d58760
SahilPasricha/XAI
/Misc/tools/code/jupyter/July20/TempRegFunc.py
UTF-8
1,768
2.875
3
[]
no_license
import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error, r2_score import sys import os sys.path.append(os.getcwd()) from ReadCsv.read_csv import CsvToArray def calc_reg(csv_file,pred_steps): #pred steps is number of steps to be predicted import pdb ;pdb.se...
true
bcbf7057149a4987d8704ef7393901587c0f97e2
Anuar7/PP2
/T/3TSIS3.py
UTF-8
33
2.796875
3
[]
no_license
a=input().split() print(*a[::-1])
true
2851a233827e762da23352c074d60dd8199ed5ac
yangsibai/SiteMiner
/SiteMiner/util.py
UTF-8
1,197
2.75
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- __author__ = 'massimo' import re import urlparse regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d...
true
25ae3606008e72b47a806498cd68c9894c55b02d
neallausson/MSMS
/InterfaceGraphique/CreateDatasetSnake.py
UTF-8
1,788
2.96875
3
[]
no_license
import pygame import pygame.draw from pygame.locals import * import random nb_train = 20; path="image/" TailleEcran = 720 dicoClassImage = {} dicoClassImage["Up"] = "ArrowUp.png" dicoClassImage["Down"] = "ArrowDown.png" dicoClassImage["Right"] = "ArrowRight.png" dicoClassImage["Left"] = "ArrowLeft.png" dicoClassImage[...
true
1fceddd31f76784876c4f3d3f34accbaaf629176
kushalasn/python-codes
/thread-concept.py
UTF-8
238
2.515625
3
[]
no_license
import _thread import time def print_time(thread_name,delay): count=0 while count<5: time.sleep(delay) count+=1 print(thread_name,time.ctime(time.time())) try: thread.start_new_thread
true
e5de25ff4e286631d90c3adaadf07baf8b36dc57
shaxbee/eu07-spt
/applications/sptEditor/src/db/export.py
UTF-8
2,448
2.609375
3
[]
no_license
import math import os.path from sptmath import Vec3, Decimal from model.tracks import Track, Switch from model.groups import RailContainer from time import sleep from sctwriter import writeSector, SECTOR_SIZE from scvwriter import writeVariant DEC_SECTOR_SIZE = Decimal(str(SECTOR_SIZE)) #SECTOR_CENTE...
true
bb1db50dd2baa3c64d5cbec97b3f27f83d27bb6f
microsoft/topologic
/topologic/embedding/spectral_embedding.py
UTF-8
2,831
2.625
3
[ "LicenseRef-scancode-generic-cla", "MIT" ]
permissive
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import logging import networkx as nx import numpy as np from sklearn.utils.extmath import randomized_svd from .elbow_finder import find_elbows from ..graph_augmentation import rank_edges, \ diagonal_augmentation def _create_augmented_adja...
true
0f1d3a83179fbc1cf62dc2ae8e2a033fb94091bf
hectortu/exercise
/python/d561.py
UTF-8
514
2.84375
3
[]
no_license
import sys for s in sys.stdin: s=s.rstrip('\n') s+='000' s=[i for i in s] if s[s.index('.')+3]>='5': if s[s.index('.')+2]<'9': s[s.index('.')+2]=chr(1+ord(s[s.index('.')+2])) else: i=0 while s[s.index('.')+2-i] in '9.': if s[s.index('.')+2-i]!='.': s[s.index('.')+2-i]...
true
ac17a2269448ec028ffa1792840a46748b68e298
roertbb/tomograph
/analysis.py
UTF-8
3,494
2.546875
3
[]
no_license
from main import load, gen_emiter_pos, get_detectors_pos, gen_sinogram, gen_image,apply_window from matplotlib import pyplot as plt import numpy as np def mse_compare(image1, image2, size): return np.square(np.subtract(image1, image2)).mean() def iteration_error(): errors = [] delta_alpha = 1 n = 400 ...
true
f43186b4aafae81c5a29878e01beeb968cded77e
qwertycoin-org/qwertycoin-testnet
/cmake/polly/bin/detail/verify_msys_path.py
UTF-8
700
2.5625
3
[ "BSD-2-Clause", "MIT", "GPL-3.0-only" ]
permissive
# Copyright (c) 2014, Ruslan Baratov # All rights reserved. import os import sys def verify(msys_path): if not msys_path: sys.exit( "Please set environment variable MSYS_PATH " "to directory with make.exe" ) make_found = False for path in msys_path.split(';'): if not os.path.isdir(pa...
true
7efd57fe3fd5b6d12b8035cbb15cdb65d5a2eb26
evancjx/CORD-19_NLP
/src/tfidf.py
UTF-8
3,597
3.140625
3
[]
no_license
from .helper import doc_dot_product, sort_dict from collections import Counter from math import log, sqrt from multiprocessing import Pool, cpu_count from tqdm import tqdm class TFIDF: def __init__(self, corpus, text_preprocessor=None): self.n_doc = len(corpus) self.text_preprocessor = text_prepro...
true
1b245584f34670df790eb3d1a7a85082675d49cf
comprehensiveMap/EI328-project
/ADDA_voting/models.py
UTF-8
855
2.546875
3
[ "MIT" ]
permissive
from torch import nn EXTRACTED_FEATURE_DIM = 128 class Net(nn.Module): def __init__(self): super().__init__() self.feature_extractor = nn.Sequential( nn.Linear(310, 256), nn.ReLU(True), nn.Linear(256, EXTRACTED_FEATURE_DIM), nn.Dropout(0.2), ...
true
06f8851ea8078e9a44187aa1a576a9b6b7ac7199
briantccj/pytorch
/Dive-into-DL-PyTorch/3_softmax-regression-scratch.py
UTF-8
1,268
2.640625
3
[]
no_license
import torch import torchvision import numpy as np import sys import d2lzh_pytorch as d2l import fashion_mnist batch_size = 256 train_iter, test_iter = fashion_mnist.load_data_fashion_mnist(batch_size) num_inputs = 28 * 28 num_outputs = 10 w = torch.tensor(np.random.normal(0, 0.01, (num_inputs, num_...
true
529f1621ec0f5c1030f88c45c011bae53fad10bf
Seon82/tracemymed
/notebook_test/generate_blockchain.py
UTF-8
3,099
2.796875
3
[]
no_license
from ellipticcurve.ecdsa import Ecdsa from ellipticcurve.privateKey import PrivateKey import requests import hashlib import json # Adress of the flask server: NODE_ADRESS = "http://localhost:5000" # Arbitrary key that is set for the creating blocks: ADMIN_PRIVATE_KEY = PrivateKey.fromPem('-----BEGIN EC PRIVATE KEY---...
true
5540618b50789b9c07b5525146b51ec44660b686
priya-gitTest/flask-typed-mounter
/tests/test_api.py
UTF-8
2,484
2.78125
3
[ "MIT" ]
permissive
import json import unittest from flask import Flask from flask_typed_mounter import TypedMounter class AppTest(unittest.TestCase): def setUp(self): app = Flask(__name__) self.tm = TypedMounter(app) self.app = app.test_client() @self.tm.attach_endpoint('/mul', methods=['POST'], a...
true
2b03f14f9c80f1dfdc0bae01a6cc959c1db39ca5
adoc/pieEngine
/pie_examples/old/game_proto1.py
UTF-8
2,919
2.75
3
[]
no_license
# TODO: Broken! import time import pygame from pygame.locals import * from lanchester.model.side import Battalion from pie_examples.ameiosis.sprite import Army from pie_examples.ameiosis.game import Ameiosis as AmeosisBase class Ameosis(AmeosisBase): def __init__(self,*args, **kwa): super(Ameosis, self...
true
fcdff2c80721d825df4e0b75d49675659c1e5d8f
coder8080/disk
/generate_token.py
UTF-8
2,245
3.515625
4
[ "MIT" ]
permissive
"""Скрипт, который сгененирует надёжный ключ и заменит им слова insert-secret-key-here в файле настроек проекта. Рекомендуется выполнить перед использованием. Должен находится в корневой директории проекта """ # Импортируем нужные библиотеки import random import string import hashlib import os # Выводим краткое описа...
true