blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
133
path
stringlengths
2
333
src_encoding
stringclasses
30 values
length_bytes
int64
18
5.47M
score
float64
2.52
5.81
int_score
int64
3
5
detected_licenses
listlengths
0
67
license_type
stringclasses
2 values
text
stringlengths
12
5.47M
download_success
bool
1 class
2feefac0211b9283d7f8cf2bb053f073216e3157
Python
vigneshsarma/webhunter
/wsgi/hunter/parser.py
UTF-8
1,326
3.375
3
[]
no_license
from HTMLParser import HTMLParser # create a subclass and override the handler methods class LinkFinder(HTMLParser): def start_parsing(self,content): self.data = "" self.url = [] self.entered_title=False self.title = "" self.feed(content) if self.title== "": ...
true
7034fc46694b2550636c613a94685ea12b729394
Python
Fila757/generating_simple_drawings_of_graphs
/drawing_of_cliques/predictions_of_intersections/fingerprint_dataset.py
UTF-8
2,654
2.921875
3
[]
no_license
import tensorflow as tf import numpy as np import random def shuffle_respectively(a, b): c = list(zip(a, b)) random.shuffle(c) a, b = zip(*c) return list(a), list(b) class Dataset: _train_constant = 0.8 # end of train _dev_constant = 0.9 # end of dev def __init__(self, args, size): ...
true
ba11dd83e90324193ce0fa05f70b61f3a49e2a45
Python
abaric/visualizing-tweets
/parse_twitter.py
UTF-8
1,149
2.734375
3
[]
no_license
import json from google.cloud import language from google.cloud.language import enums from google.cloud.language import types data = [] #connect to google language API client = language.LanguageServiceClient() with open('mined_tweets.json') as f: for line in f: l = json.loads(line) try: ...
true
9b3304fffae7fa565ef2e9a9d73a6e995ca8d93c
Python
rok-povsic/Lekcija12
/izpis_stevil_manjsih_od_5.py
UTF-8
207
2.53125
3
[]
no_license
def izpisi_manjse_od_5(seznam_stevil): for stevilo in seznam_stevil: if stevilo < 5: print stevilo seznam_stevil = [ 4, 6, 7, 4, 1, 100, 44444, -30] izpisi_manjse_od_5(seznam_stevil)
true
b4686d0372f205ec1429af626561a3d51f6b7052
Python
hsezhiyan/MARLO_A3C
/plots.py
UTF-8
396
2.5625
3
[]
no_license
#import matplotlib.pyplot as plt import numpy as np import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt def create_reward_curve(list_reward, display=False): plt.figure(1) x_len = len(list_reward) t = np.arange(0, x_len) plt.plot(t, list_reward) if display == True: ...
true
b1f03524def960284720f00a90496faf1eb07481
Python
koturn/kotemplate
/templates/Python/main_option.py
UTF-8
1,488
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Description """ __author__ = '<+AUTHOR+> <+MAIL_ADDRESS+>' __status__ = "production" __version__ = '0.0.1' __date__ = '<+DATE+>' import argparse if __name__ == '__main__': N_REQUIRED_MEMAININGS = 1 parser = argparse.ArgumentParser( usage='\n $ ...
true
e1c9a364af2f72117e39c7942282e5609cce1424
Python
Alexander3/workshops
/ogar_io/client.py
UTF-8
673
2.859375
3
[]
no_license
import pygame import requests s = requests.Session() pygame.init() pygame.display.set_caption("OgarIO") screen = pygame.display.set_mode((300, 300)) url = 'http://localhost:5000/' while True: event = pygame.event.poll() # quit if the quit button was pressed if event.type == pygame.QUIT: exit() ...
true
921e366fa2794a8af39af2328972c4e3f738702b
Python
antongt/DenseProject
/greedy/utils.py
UTF-8
2,146
3.15625
3
[]
no_license
import time import sys # A function to measure how long something takes to run. # Returns a string holding the time since last time the function was called. # Uses a global variable to hold the time of previous call. def timer(): global lastTimeStamp try: elapsedTime = time.clock() - lastTimeStamp ...
true
c6cb57ba90e66bad9f9f0c9188b785fcc8a27fac
Python
DanBrown501/totalbodyperformance
/test_exercise_models.py
UTF-8
4,638
3
3
[]
no_license
"""Exercise model tests.""" import os from unittest import TestCase from sqlalchemy import exc from models import db, User, ExerciseCategory, Exercise, UserExercise, ExerciseComment # Set an environmental variable to use a different database for tests os.environ['DATABASE_URL'] = "postgresql:///capstone-test" from...
true
7d3f8bb8c1ce2225f2f7678da589f01d19482c75
Python
AmitTsvi/decentralized_rl_multi
/CoopBoxPushAgent.py
UTF-8
4,778
3
3
[]
no_license
from __future__ import absolute_import from __future__ import division from __future__ import print_function import random import pyspiel import numpy as np from absl import app import torch game_name = "coop_box_pushing" players = None load_state = None def state_to_board_tensor(state): s = state.__str__() ...
true
f77d6e1369f8594d6a9a1955b1dadb051562e1dd
Python
kayfour/opencv_examples
/12_DetectFace.py
UTF-8
1,559
2.703125
3
[]
no_license
# 모듈 불러오기 import cv2 as cv import numpy as np import os # 정면 얼굴 분류 파일 불러오기 strfile = os.getcwd() + "/datas/haar_cascade_files/haarcascade_frontalface_default.xml" cascade = cv.CascadeClassifier(strfile) # 눈 분류 파일 불러오기 strfile = os.getcwd() + "/datas/haar_cascade_files/haarcascade_eye.xml" cascadeEye = cv.CascadeClass...
true
3c618bd65b222211dd6b4a9d24d5c598015a4d42
Python
vincenttuan/yzu_python
/lesson05/DefDemo5.py
UTF-8
295
3.453125
3
[]
no_license
x = 0 # global var y = 0 # global var z = [0] def changeX(n): x = n # local var def changeY(n): global y y = n def changeZ(m, n): m[0] = n print("z=", z) changeZ(z, 100) print("z=", z) print("x=", x) changeX(100) print("x=", x) print("y=", y) changeY(100) print("y=", y)
true
39e04a1b8a496a8d21fde812447a7cce8412276e
Python
oflyt/a3c_intro_ai
/util_plotter.py
UTF-8
1,362
3.375
3
[]
no_license
import threading, time import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import spline from IPython import display class Plotter(threading.Thread): stop_signal = False def __init__(self, rewards, agent): threading.Thread.__init__(self) self.rewards = rewards se...
true
ab09f15a8af7a072057298b008604ec5fde10a79
Python
iamharsh1312/Python-Code
/image classification using Random forest.py
UTF-8
1,899
3
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 # In[1]: ## Image classification using RandomForest: An example in Python using CIFAR10 Dataset def Snippet_349(): print() print(format('Image classification using RandomForest: An example in Python using CIFAR10 Dataset','*^88')) # In[2]: import warnings warnings...
true
910a868d11b79e3f1689987bd6ef7111fc1a77de
Python
dahem/handbook
/uri/beginner/2310.py
UTF-8
442
3.703125
4
[]
no_license
n = int(input()) asum = 0 apos = 0 bsum = 0 bpos = 0 csum = 0 cpos = 0 for x in range(n): input() a, b, c = map(int, input().split()) asum += a bsum += b csum += c ap, bp, cp = map(int, input().split()) apos += ap bpos += bp cpos += cp print("Pontos de Saque: %.2f %%." % (apos*100.0...
true
e105a00d80742bc644f415aa2b8c178b3281e140
Python
sjzyjc/leetcode
/921/921.py
UTF-8
460
2.96875
3
[]
no_license
class Solution: def minAddToMakeValid(self, S): """ :type S: str :rtype: int """ if not S: return 0 left, right = 0, 0 for char in S: if char == '(': left += 1 else: if left > 0: ...
true
20efdc17e593a25b6a7bfbda7bfcb88be39417fe
Python
tongjintao/project-euler
/9_find_triplet_of_1000.py
UTF-8
432
3.640625
4
[]
no_license
"""Project Euler 9: Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000 There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.""" import math for i in range(1, 999): for j in range(1,999): #print i+j+math.sqrt(i*i+j*j) if i+j+math.sqrt(i*i+j*j)==1000: ...
true
46f83629d477a87c90b5e95aa04ff75bec712972
Python
duststorm/cryptanalysis
/five_blocks/bc2_mitm_attack.py
UTF-8
3,680
2.875
3
[]
no_license
#!/usr/bin/env python """ ..:: MitM attack against a custom Lai-Massey scheme ::.. 'five blocks' - VolgaCTF Quals 2016 (Crypto/600) by Jos Wetzels """ import sys import struct from math import sqrt def split_int(m): return ((m>>16) & 0xFFFF, m & 0xFFFF) def join_int(l, r): return (l<<16...
true
b8518342ec8cf00f1642179505b8cb057d494ce7
Python
TauOmicronMu/Y13Computing
/GenerateCode.py
UTF-8
987
2.71875
3
[]
no_license
#============================================================ #====================== Code Gen. ========================== #============================================================ #================= Author: T.A.Goodman 2014 ================= #=============== Copyright: T.A.Goodman 2014 ================ #=========...
true
9df5c731e7d6f9b67da536bb0182477eed1a4039
Python
CaioChaves/Road-Detection-KITTI
/kitti_semantics_dataloader_patch.py
UTF-8
4,093
2.578125
3
[]
no_license
import os from imageio import imread import torch from torch.utils.data import Dataset from torchvision import transforms, utils import numpy as np from PIL import Image import random import torchvision class KittiDatasetPatch(Dataset): def __init__(self, rootDir, ppi, patch_size, target_type = 'semantic_binary_gr...
true
08f0a1ca88ec81813cf435dae37797396e55718c
Python
luca-medeiros/portal
/src/engine/server/services/__init__.py
UTF-8
182
2.5625
3
[ "Apache-2.0" ]
permissive
from urllib.parse import quote, unquote ENCODING = "utf-8" def encode(string): return quote(string.encode(ENCODING), safe="") def decode(string): return unquote(string)
true
24c5cf30c0fbbbefe46290bf9f6ee3c8a75d2776
Python
Lalcenat/Homework
/Project Two Changes/Website/app.py
UTF-8
1,206
2.578125
3
[]
no_license
# import necessary libraries from flask import ( Flask, render_template, jsonify, request) from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = "sql:///db/db.data_base.sql" db = SQLAlchemy(app) from .models import Pet @app.route("/") def index(): ...
true
710187aec22e1117b6c4964eee3b46890a2f0272
Python
akshatsoni64/PythonProgramming
/FriendsParty.py
UTF-8
355
3.921875
4
[]
no_license
""" There are number of friends, they want to attend a party But they can either go to party all alone or in a pair Give the number of ways they can go to the party """ def friends(n): return n if n == 1 or n == 2 else friends(n-1) + (n-1)*friends(n-2) print("Number of ways they can go to party: ", friends(in...
true
a6e82eb7c5ef1bac8d4d4bd99bc1484152758811
Python
sandeepkumar8713/pythonapps
/23_thirdFolder/48_monarchy.py
UTF-8
2,835
4.25
4
[]
no_license
# https://leetcode.com/discuss/interview-question/302164/Google-or-Phone-Screen-or-Monarchy # Question : Given a list of births and death. Return a list of order of succession of the monarchy. # It is pre-order in n-ary tree. # # Question Type : Easy # Used : When a birth function is called, we maintain a map of nodes ...
true
630e9d07865f4e4e09930841df7ddb5f6fd40b5c
Python
shikixyx/AtCoder
/etc/Hitachi/2020/2020_C.py
UTF-8
893
2.578125
3
[]
no_license
import sys from collections import deque sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # 距離3のペア求めようとしてた # これはNが10^5とかだと絶対無理 # WA N = int(readline()) E = [[] for _ in range(N+1)] for _ in range(N-1): a, b = map(int, readlin...
true
03acfc6544d8f5a3bdd98dc45f14511a32f3f993
Python
dm36/interview-practice
/codewars/pete_the_baker.py
UTF-8
474
3.5
4
[]
no_license
def cakes(recipe, available): max_cakes_4_pete = float("inf") # if the ingredient is not available return 0 for item in recipe: if item not in available: return 0 # if the ingredient is available divide what's available by # the recipe and update if we get a smaller quotient for ingredient in recipe: if ...
true
f04204d437587e8b8eaba7b8afe7ff5948e34f34
Python
fergatica/python
/vowels_and_consonants.py
UTF-8
375
4.40625
4
[]
no_license
def main(): user_sting = input("Enter a word: ") vowels= 0 consonants = 0 for ch in user_sting: if ch == "a" or ch == "e" or ch == "i" or ch == "o" or ch == "u": vowels += 1 else: consonants +=1 print("The word " + user_sting + " contains " + str(vowels) + " v...
true
1f5b84c6f964713fb71659bdaaa318314a076132
Python
xieyupengzZ/python3
/app1/utils/ExcelTest.py
UTF-8
6,756
3.46875
3
[]
no_license
import xlrd import xlwt import datetime ''' Excel读写 xlrd: 读,xls,xlsx xlwings: 读,xls,xlsx pandas: 读,xls,xlsx xlwt: 写,xls 【优点】:支持xls; 【弱点】:功能很弱,可能因为Excel2013本身功能就弱; xlsxwriter: 写,xlsx 【优点】:功能强大,可以设置各种格式;支持大数据写入(每次内存中只保留一行的数据,写入文件后,再继续读取下一行到内存,这样就不会内存溢出...
true
d62379f1d07ad5a39201264932be8bfeae034f29
Python
ASangave/FlaskApp
/FlaskApp/app.py
UTF-8
281
2.65625
3
[]
no_license
# Import flask module from flask import Flask # create an app using Flask app = Flask(__name__) # defined the basic route / and its corresponding request handler @app.route("/") def main(): return "Welcome!" if __name__ == "__main__": app.run(debug=True,host='0.0.0.0')
true
2b64dbdb09cae9c7b257b9f274a367d33e996230
Python
Noxy3301/AtCoder
/ABC/abc123_c.py
UTF-8
96
2.84375
3
[]
no_license
import math n = int(input()) d = [int(input()) for i in range(5)] print(math.ceil(n/min(d)) + 4)
true
4449457555b950ff5775d1eef83a5c2a20e8e280
Python
baranee-18/Data-Structures-and-Algorithms
/largest-rectangle-in-histogram/largest-rectangle-in-histogram.py
UTF-8
512
2.875
3
[]
no_license
class Solution: def largestRectangleArea(self, heights: List[int]) -> int: stack = [-1] heights.append(0) import sys ans = -sys.maxsize - 1 for i in range(len(heights)): while stack and heights[stack[-1]] > heights[i]: h ...
true
4073c558d1de4b3d73540c333b70e485c230c851
Python
Ampexa/CrashCourse
/chapter06.py
UTF-8
2,784
4.53125
5
[]
no_license
################################# # Chapter 6 ##################### ################################# """ This chapter contains examples for the following things: - Dictionaries - Looping through dictionaries - Nesting of dictionaries """ # 1. Dictionaries #---------------- # simple dictionary person0 = { 'first...
true
9d6bf62fcbbb0b3a5f16c76301851292b6262be1
Python
JiancongWang/LinearInterpolation3DTF
/elastic_transform_tf.py
UTF-8
5,129
2.765625
3
[]
no_license
# This is a tensorflow implementation of elastic transformation for data augmentation import numpy as np import tensorflow as tf import LinearInterpolation #%% class elastic_param(): def __init__(self): # Affine parameters # Rotation, specify the maximum random rotation in radians self.ro...
true
fe16ad34d6ad4c0851ee780be4dec2526b2ea5ba
Python
SmolPO/Simple_Server
/src/Application.py
UTF-8
701
2.75
3
[]
no_license
# coding=utf-8 from threading import Thread from Connection import Connect from GlobalQueue import Server_Thread class Application(Thread): connect_class = None server_thread = None def __init__(self): """ создает класс Connect и очередь сервера передает в класс Connect себя ...
true
9c1cdca1c3585283e56c58cc0d9ffcbe3bcc5c4b
Python
ilgindogan/Motion_Detection_Rpi
/main.py
UTF-8
1,073
2.953125
3
[]
no_license
#!/usr/bin/python ''' Author: ILGIN DOĞAN -- lgndogan@gmail.com A Simple Motion Detection v1.0 ''' # You need to install picamera to run this script import motionDetecting import picamera from time import sleep from datetime import date,datetime import time motionState = False path = "/home/pi/Desktop/images" #Rasp...
true
2ebca41397aaa80e8291acd82593034c7dda9236
Python
austinpgraham/Recommendations-GAN
/src/ganrecs/scripts/ganrecs_mnist.py
UTF-8
3,799
2.828125
3
[]
no_license
#!/usr/bin/env python3 # This is an adaptation of an online tutorial # on Generative Adversarial Networks to test # that the customized construction constructs # correctly # Original code: https://github.com/wiseodd/generative-models import os import argparse import numpy as np import tensorflow as tf import matplotl...
true
4f1ea782ed81248cb394535c5d7c529791a436e5
Python
Jesse9009/Intro-Python-II
/src/player.py
UTF-8
322
4.09375
4
[]
no_license
# Write a class to hold player information, e.g. what room they are in # currently. class Player: def __init__(self, name, cur_room): self.name = name self.cur_room = cur_room items = [None] def __str__(self): return f"Hello {self.name}. Your current location is: {self.cur_room...
true
f65b6134df8a714b6cdf043dc4467ad17c215bf3
Python
mreh528/phys5070FinalProject
/utilities.py
UTF-8
1,165
3.328125
3
[]
no_license
""" Utility module of random functions that are convenient to have """ import numpy as np ## Expand bound states to a larger box. ## Mostly a convenience function and not actually sure if is needed def pad_with_zeros(xnew, xold, psiold): psi_new = np.zeros(len(xnew), dtype=psiold.dtype) start = np.argmax(xn...
true
f0c671f4ddca161ab8f053617216bbfd6a36ee19
Python
HermanMolodchikov/python_learn
/L24dicMethod.py
UTF-8
2,517
4.03125
4
[]
no_license
# dict.clear() - очищает словарь. # dict.copy() - возвращает копию словаря. # classmethod dict.fromkeys(seq[, value]) - создает словарь с ключами из seq и значением value (по умолчанию None). # dict.get(key[, default]) - возвращает значение ключа, но если его нет, не бросает исключение, а возвращает default (по умолчан...
true
55fe37cc3f566c9d2ae6a7aefb13d83507370646
Python
Holdrick/Chess_Python
/Pawn.py
UTF-8
1,832
3.15625
3
[]
no_license
from Piece import Piece class Pawn(Piece): def __init__(self, column, row, colour): self.position = column + row self.colour = colour self.shape = colour[0] + "p" def validMove(self, start, finish, player, destination, board): si = self.columns.index(start[0]) fi = sel...
true
70205b0c16b83c9ea04107bd1368d6f4499ad8f0
Python
davikawasaki/utfpr-ce-undergrad-final-project
/training/snippets/misc_snippets.py
UTF-8
1,437
3.46875
3
[ "MIT" ]
permissive
# encoding: utf-8 """Misc snippets to manipulate data. Methods: " >>> bind_question_text_alternatives(question) " >>> tokens_to_vector(tokens, label, word_index_map) " >>> has_numbers(s) """ import numpy as np def bind_question_text_alternatives(question): """Bind question text with each alternati...
true
88e6fd74bfb736a00bc47dd7d8e5f494f824ae1d
Python
mamadyonline/Projet_HPC
/TreeMethods/RandomForest.py
UTF-8
3,057
3.53125
4
[]
no_license
from random import randrange from random import seed seed(1) class RandomForest (object): """ A Random Forest base class. Classification and Regression Random Forests will be derived classes that override certain functions of this class. This was done because many common methods, so to reduce code they are wr...
true
35b4e3ded45c218b3d56a5266e4b3923f1152faf
Python
dejmail/kodtjanst
/kodtjanst/templatetags/split.py
UTF-8
639
2.71875
3
[]
no_license
from django.template import Variable, VariableDoesNotExist from django import template import re from pdb import set_trace register = template.Library() @register.filter(name='split') def split(value, key): """ Returns the value turned into a list. """ matches = ['länk','klartext'] if value: ...
true
a5c06a2a3bbaafe0b94eb7f462155e15cf872ec5
Python
TmxkGtw/python_linq
/main.py
UTF-8
398
3.0625
3
[]
no_license
from linq.linq_methodchain import * def main(): linqed_list = Items([1, 2, 3, 4, 5] ).map([ lambda index, value : index * value, lambda index, value : index + value,] ).filter([ lambda index, value : index % 2 == 0,] ).reduce( lambda v1, v2 : v1 + v2, initial_va...
true
53fb40aa9728af4c86cd6171ac4292ecc13fd918
Python
Ajaysingh647/python647
/shop_problem.py
UTF-8
200
3.4375
3
[]
no_license
# shop problem re=int(input('Enter the amount:- ')) if re>=1000: pr=re*0.1 print(f'The amount to be given to shopkeeper:- {re+pr}') else: print('No discount is given to te customer')
true
d6b9a79e119dc6928106da930b081b6dcecd12b5
Python
stliam42/algorithms
/sirius_algorithms/liniar.py
UTF-8
30,387
3.734375
4
[]
no_license
from random import randint def max_fraction(n: int, a: tuple) -> tuple: """ Отношение. Дан массив a1,a2,…an. Необходимо выбрать в нём два элемента ai и aj такие, что i<j, и отношение aj/ai максимально и больше 1. Входные данные: В первой строке задано целое число 2 ≤n≤ 100 000 — количество ...
true
ce90ac71d3be1793eaa548b0fbbdc766e1727716
Python
NAMD/pyquality
/tests/test_generate_csv_files.py
UTF-8
3,343
2.59375
3
[]
no_license
# coding: utf-8 import glob import os import tempfile import unittest from re import compile as regexp_compile from shlex import split as shlex_split from shutil import rmtree from subprocess import Popen, PIPE from textwrap import dedent import pyquality def execute(command): process = Popen(shlex_split(comma...
true
84083b72b20836005bc9e21b051e55cba4b03cf9
Python
mywns123/dojangPython
/unit43/unit43.py
UTF-8
697
3.03125
3
[]
no_license
import re # print(re.search("^Hello", "Hello World!! haaaa,,,")) # # print(re.search("World!$", "Hello World!! haaaa,,,")) # print(re.search("World!$", "Hello World!")) # # print(re.match("Hello|World", "Hello")) # print(re.match("[0-9]", "11aaaa1235")) # print(re.match("a*b", "b")) # print(re.match("a+b", "b")) # pri...
true
e3b72af145146ed1905dc1f17cafbcb9e7f014e1
Python
mjbrann4/python_training
/py_data_sci_1/8_pandas/4_pandas_vis.py
UTF-8
1,025
3.4375
3
[]
no_license
#visualize in pandas import pandas as pd import numpy as np import matplotlib.pyplot as plt import datetime import pandas_datareader as pdr # Package and modules for importing data #aapl = pd.read_csv('aapl.csv', index_col='date', parse_dates=True) # Examine stock prices over the last year start = datetime.datetime...
true
86d3070079cb89f4b2632395ed05acc19be09949
Python
hanhansoul/PythonCookbook
/chapter04/section_a.py
UTF-8
7,539
4.53125
5
[]
no_license
def section_4_1(): """ 4.1. Manually Consuming an Iterator 不使用for循环,而使用next()来遍历迭代器 StopIteration异常用于标识迭代终止,或标记None作为终止标识。 next() """ def test1(): with open('input.txt') as f: try: while True: line = next(f) print(l...
true
c4038f1cf96a2afdafc814b360de5083115ded94
Python
ankitstar01/2048-ai
/chromectrl.py
UTF-8
4,019
2.703125
3
[ "MIT" ]
permissive
from __future__ import print_function import json, threading, itertools try: import websocket except ImportError: websocket = None # Python 3 compatibility try: from urllib2 import urlopen except ImportError: from urllib.request import urlopen try: input = raw_input except NameError: pass cl...
true
1d0e4e4d6f471672ed107bba0335030f2f9dc770
Python
pankajkarman/probflow
/src/probflow/applications/dense_classifier.py
UTF-8
1,428
3.015625
3
[ "MIT" ]
permissive
from typing import List import probflow.utils.ops as O from probflow.distributions import Categorical from probflow.models import CategoricalModel from probflow.modules import DenseNetwork from probflow.utils.casting import to_tensor class DenseClassifier(CategoricalModel): r"""A classifier which uses a multilay...
true
78695474d4aa06c0b3a327702dda3e7f13745fc0
Python
simone-campagna/sequel
/tests/unit/sequence/test_functional.py
UTF-8
928
3.265625
3
[ "Apache-2.0" ]
permissive
import pytest from sequel.sequence import derivative, integral, compile_sequence @pytest.mark.parametrize("source, ref_source", [ ("derivative(p + 5)", "derivative(p)"), ("derivative(p - 5)", "derivative(p)"), ("derivative(3 * p - 5)", "derivative(3 * p)"), ("derivative(3 + 2 * p)", "derivative(2 * p...
true
233b5dcdf0afa076e1fcc2e6d7d41fa03b56c449
Python
PerisOduol618/News-Articles-
/app/models.py
UTF-8
680
2.5625
3
[ "MIT" ]
permissive
class Sources: ''' Sources class to define Sources Objects ''' def __init__(self, id, name, description, url, category, country, language): self.id = id self.name = name self.description = description self.url = url self.category = category self.country =...
true
8151972d4691c65ff84a987c1ff7d8543be8dae9
Python
erdos2n/Capstone
/Infinite-Agency/MultiArmBandit.py
UTF-8
1,403
2.75
3
[]
no_license
import numpy as np from Bandits import Bandits from BayesianBandit import Bayesian_Bandit from Create_Dictionary import Ad_Dictionary from plot_bar import plot_dictionaries from BayesianBandit import regret import matplotlib.pyplot as plt thresholds = [100] myGame = Ad_Dictionary() results = [] for threshold in thre...
true
bdf8a8d93264f81ddd7b6cab86f996e5820e594e
Python
RodrigoMarcelin/CursoPythonColder
/manipulacao_de_arquivos/io_v3.py
UTF-8
240
2.9375
3
[]
no_license
arquivo = open(r'C:\Users\Rodrigo\Documents\Documentos do Rodrigo\cursos\CursoPythonColder\manipulacao_de_arquivos\pessoas.csv') for registro in arquivo: print('Nome: {}, Idade: {}'.format(*registro.strip().split(','))) arquivo.close()
true
fe0f6676265d2486f7c5d8f120f4c9469a5ed93a
Python
MishaVatulich/Map_API
/2.1/afasg.py
UTF-8
563
2.65625
3
[]
no_license
def keyPressEvent(self, event): if event.key() == Qt.Key_PageUp and int(self.map_api.zoom) < 20: self.map_api.zoom = str(int(self.map_api.zoom) + 1) self.map_api.draw() elif event.key() == Qt.Key_PageDown and int(self.map_api.zoom) > 0: self.map_api.zoom = str(int(self.map_api.zoom)...
true
047dabb493a069de0eeb52f675c349e4fdb84dc8
Python
hybras/Cataract
/cataract.py
UTF-8
1,893
2.9375
3
[]
no_license
import cv2 import numpy import math from enum import Enum class CataractPipeline: """ An OpenCV pipeline generated by GRIP. """ def __init__(self): """initializes all values to presets or None if need to be set """ self.__find_blobs_min_area = 11.0 self.__find_blobs_ci...
true
36f753d7c9281c7655a360ed69a97547db485089
Python
JustBeingFriendly/Mixologist_Logic
/Queue_Controller.py
UTF-8
2,936
3.0625
3
[]
no_license
#!/usr/bin/env python from collections import deque from collections import namedtuple from DB_ControllerV2 import getDatabaseOutput #import GPIO_processor from GPIO_processor import makeDrink theQueue = deque() OrderNumber = 0 order = namedtuple('DrinkOrder', ['UserID', 'Drink', 'OrderNumber']) def addAndroidToQu...
true
499fdebf7b6906be51bbd50bd33dfc087e661283
Python
donyeun/fgsm_attacking_privacy_preserving_nlp
/sentiment/data_helpers.py
UTF-8
18,035
2.53125
3
[]
no_license
from __future__ import division import sys import numpy as np from tensorflow.contrib import learn # import cPickle import pickle import re from collections import Counter def clean_str(string): """ Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonk...
true
20bdc5d582bfb09878d749d217f76e65a1d549d8
Python
sunrobotics/RPI_Quick_Starter
/Python_Code/11_voltmeter.py
UTF-8
649
3.140625
3
[]
no_license
#!/usr/bin/env python #----------------------------------------------------------- # File name : 11_Voltmeter.py # Description : a simple voltmeter # Company : SunRobotics Technologies # Website : www.sunrobotics.co.in # E-mail : support@sunrobotics.co.in(For Any Query) #-----------------------...
true
092117e409cf87402d4fe327e6f9394bd018f2a8
Python
s-kim333/StatML_proj1
/Jayan_export_links.py
UTF-8
2,349
3.171875
3
[]
no_license
import pandas as pd from datetime import datetime from tqdm import tqdm import networkx as nx def timeStamp(): dateTimeObj = datetime.now().time() return dateTimeObj.strftime("%H:%M:%S") def exportToCSV(df, filename): export_path='outputs/' + filename + '.csv' df.to_csv(export_path, index=F...
true
0c7d959448ef18f453d48e96dc0461be7f11c799
Python
fedormyskin/textreuse-blast
/blast_batches.py
UTF-8
5,913
2.609375
3
[ "MIT" ]
permissive
import argparse, os, time, subprocess from copy import deepcopy from shutil import copytree, rmtree, copyfile from blast import MultipleBlastRunner import time from text_logging import get_logger ''' to run on a cluster computer, it might be helpful to copy db to the hardrive of the node This file can be run instead ...
true
86bfccde842f1392a92579c2094bbe195dc11617
Python
jiadaizhao/LeetCode
/1501-1600/1579-Remove Max Number of Edges to Keep Graph Fully Traversable/1579-Remove Max Number of Edges to Keep Graph Fully Traversable.py
UTF-8
1,211
2.71875
3
[ "MIT" ]
permissive
class Solution: def maxNumEdgesToRemove(self, n: int, edges: List[List[int]]) -> int: parent = list(range(n + 1)) def findParent(i): while parent[i] != i: parent[i] = parent[parent[i]] i = parent[i] return i def union(u, v): ...
true
55f2e0b326c741d6a573de1062abfc7e6ab6c6e0
Python
dev-himanshu/basic_python
/BasicPythonConcept/17. Set_data_type.py
UTF-8
726
3.46875
3
[]
no_license
# set data-types with their built-in functions : s = {"hello,", "this", "is", "0832cs171065"} bif_of_set = dir(s) print("\n\n", "Built-in function of set data".upper().center(160, '-')) print("Total functions are : ", len(dir(s))) for i in range(0, len(dir(s))): print(bif_of_set[i], end=" ") if (i % 10) ==...
true
f8e5317d8c66b66e37d06b98ca0fe9812bc74646
Python
double-o-z/stats
/data_structures.py
UTF-8
6,282
2.859375
3
[]
no_license
import os import operator from helper_methods import * class ExtensionsDataStructure: def __init__(self, path): self.path = path self.d = [[], 0, 0] self.create_data() self.aggregate_data() self.sort_data() self.format_data() def sorted_structure(self): ...
true
82dbd0fded66d1fe5d23cfefcff0f5e213b859eb
Python
oliverhuangchao/epic_interview
/py_solution/8_two_prime.py
UTF-8
946
4.21875
4
[]
no_license
# Two Primes # Goldbach's conjecture : Every even integer greater than 2 can be expressed as the sum of # two primes. Write a function which takes a number as input, verify if is an even number # greater than 2 and also print at least one pair of prime numbers. import math def isPrime(num,primelist): if num == 0...
true
0ce96c1b5f0d6cfb9ae9dadd6aca7f648af111e9
Python
rajatjaing/PyComp
/venv/test.py
UTF-8
3,604
2.703125
3
[]
no_license
# try: # from xml.etree.cElementTree import XML # except ImportError: # from xml.etree.ElementTree import XML # import zipfile # # # """ # Module that extract text from MS XML Word document (.docx). # (Inspired by python-docx <https://github.com/mikemaccana/python-docx>) # """ # # WORD_NAMESPACE = '{http://sche...
true
fbe61869139da03928e39eaf7db5049551d92dca
Python
Ex-Ark/Amulet-Map-Editor
/amulet_map_editor/api/opengl/canvas_container.py
UTF-8
462
2.9375
3
[]
permissive
import weakref from wx.glcanvas import GLCanvas class CanvasContainer: """A helper class to store a reference to a canvas. If a canvas is hard referenced there may be cyclic references leading to memory leaks. Subclass this class if you intend to store a reference to the canvas.""" def __init__(self,...
true
c006ee34e81676f18543e51080838be0d7402326
Python
DiCarloLab-Delft/PycQED_py3
/pycqed/tests/analysis/tools/test_data_manipulation.py
UTF-8
1,764
2.65625
3
[ "MIT" ]
permissive
import unittest import pycqed as pq import os import numpy as np from pycqed.analysis import measurement_analysis as ma from pycqed.analysis.tools.data_manipulation import \ populations_using_rate_equations from uncertainties import ufloat class Test_AnalysisToolsDataManipulation(): def test_populations_using...
true
462756120af2e7743dd6336ad3d800702b3e24f8
Python
jatinrajani/Pycodes
/Documents/pyinformatics/number.py
UTF-8
151
2.671875
3
[]
no_license
import re fhand=open('mbox') for line in fhand: ine=line.rstrip() x=re.findall('^X\S.*: ([0-9.]+)',line) if len(x)>0: print x
true
d0088fdbddc602d0e9b9e574ec1834696a85926f
Python
Tool-69-man/python-
/全局变量.py
UTF-8
268
3.453125
3
[]
no_license
#global X 声明全局 def fun(): #print('一开始的x',x) global x x=212 print('全局变量x',x) x=111 fun() print(x) x=555 def fun1(x): print('输出fun后x',x) x=12 print('局部变量12',x) fun1(x) print('最后显示全局',x)
true
86288be8f14988f0242b80f5ca40638fedd3738d
Python
nazrulworld/fhir.resources
/fhir/resources/STU3/codeableconcept.py
UTF-8
1,893
2.578125
3
[ "BSD-3-Clause" ]
permissive
# -*- coding: utf-8 -*- """ Profile: http://hl7.org/fhir/StructureDefinition/CodeableConcept Release: STU3 Version: 3.0.2 Revision: 11917 Last updated: 2019-10-24T11:53:00+11:00 """ import typing from pydantic import Field from . import element, fhirtypes class CodeableConcept(element.Element): """Disclaimer: A...
true
1f0e394ac761f824df8b83ffdfc78a28b6f14617
Python
hinxx/Feature-Extraction-and-Image-Processing-Book-Examples
/ExamplesPython_3.6/Chapter4/PrewittOperator.py
UTF-8
1,465
3.625
4
[ "MIT" ]
permissive
''' Feature Extraction and Image Processing Mark S. Nixon & Alberto S. Aguado http://www.southampton.ac.uk/~msn/book/ Chapter 4 PrewittOperator: Compute gradient by using the Prewitt operator ''' # Set module functions from ImageUtilities import imageReadL, showImageL, createImageF, showImageF from PrintUtilities i...
true
aa869ca66f96e399521932927bd9c901b1a2fd8d
Python
JoshuaYosen/Data-Warehouse-Project
/Data_Warehouse_Prjct/Scripts/graph.py
UTF-8
960
3.203125
3
[]
no_license
import pandas as pd import matplotlib.pyplot as plt import datetime import numpy as np def DataFrame(file_name): df = pd.read_csv(file_name, index_col=0) print(df.head(10)) def sales_per_month(file_name): DataFrame(file_name) df['Date'] = pd.DatetimeIndex(df['InvoiceDate']).date df['Month']...
true
16b8554e181f1d7bf9edae0c909ec548f974950f
Python
mjacob1002/Eir
/Eir/DTMC/spatialModel/Hub/HubSIRV.py
UTF-8
7,757
2.59375
3
[ "MIT" ]
permissive
import numpy as np import pandas as pd from matplotlib import pyplot as plt from .HubSIR import HubSIR from Eir.utility import Person, randEvent from Eir.DTMC.spatialModel.simul_details import Simul_Details class HubSIRV(HubSIR): """ SIRSV compartmental model with the Hub model assumption. Parameters ...
true
72c13336be0bd440414e976d6a21a9cf02075186
Python
jpena9/Personal-Python-Projects
/AdventPuzzle1_2020.py
UTF-8
740
3.265625
3
[]
no_license
# -*- coding: utf-8 -*- read=open('2020puzzle1_input.txt','r') acct=read.readlines() nums=[float(line) for line in acct] ## Part 1 sumyear=0 prodyear=0 for i in range(len(nums)): for j in range(len(nums)): sumyear=nums[i] + nums[j] if sumyear == 2020: prodyear=nums[i]*nu...
true
31d6bc9c9e52326eb6a0dbcba4c0448daf490e9e
Python
lefteggjuice/pitunbot
/tests.py
UTF-8
1,059
2.984375
3
[]
no_license
# -*- coding: utf-8 -*- import re, random, urllib, json def choiser(): orig = u'питун, пилить тебя дальше или заняться работой?' words = orig.split(u'питун') com = re.sub(u',?','',words[1]) m = re.match(ur'(.+)\s+или\s+(.+)',com) print m.group(1) print m.group(2) choices = [m.group(1),m.group(2)] msg = choice...
true
a189f481cc8997389140262d416f8c739c3ca1e5
Python
SergiuIliev/fire-detection
/process_data.py
UTF-8
4,682
3.5
4
[ "MIT" ]
permissive
''' Project: Fire-Detection File Name: process_data.py Group Members: Austin Saunders, Sergiu Iliev, Yuan Li, Peng Zeng Capabilities: Loads MODIS and VIIRS Data, transforms and aggregates all data so it corresponds to a spatial grid, then gets passed to Risk_Calculation.py (when called by main.py) MIT License, Copyrig...
true
e6ae47b4993ef0bb8c5ad6e85549e9fb8b523b60
Python
tw-alexander/CodeHS-Intro_To_Computer_Science-Answers-Python
/CodeHs/5.Strings/2. Slicing/7.2.6 First Character.py
UTF-8
166
3.359375
3
[]
no_license
def first_character(a): return a[0] def all_but_first_character(a): return a[1:10] print first_character("hello") print all_but_first_character("hello")
true
ef55bfb7e9825b8a7aa4919506132e0a40da3b07
Python
r08922130/ADL
/Final/src_seperate_ensemble/preprocess_grand_parent_sib.py
UTF-8
15,495
2.625
3
[]
no_license
import pandas as pd import unicodedata import re import glob from transformers import BertTokenizer,AlbertTokenizer,AlbertModel import torch class Preprocess: def __init__(self,path,max_length=256,train=True): self.train = train self.max_length = max_length self.path = path self.d...
true
c69f1e2e2d62f67e2b63a645d68af0148617a0b2
Python
ryanspoone/Server-Performance-Evaluation-Tool
/spet/lib/utilities/json_file.py
UTF-8
720
3.0625
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """JSON functions.""" import json import logging from spet.lib.utilities import file def write(file_path, json_data): """Writes JSON to file. Args: file_path (str): JSON file to write to. json_data (json): JSON data to write. """ try: file.write(file_...
true
4b4debf9e0802820b9eb2c1bb201aa20aedab0bc
Python
vektor-knight/quantum-fog
/examples_cbnets/WetGrass_unfilled_pymc2.py
UTF-8
1,594
2.625
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
import numpy as np import pymc as pm2 # node names in lexicographic (alphabetic) order nd_names_lex_ord = ['Cloudy', 'Rain', 'Sprinkler', 'WetGrass'] # node names in topological (chronological) order nd_names_topo_ord = ['Cloudy', 'Rain', 'Sprinkler', 'WetGrass'] # did_obs_Cloudy = False # data_Cloudy = None # did...
true
8827b43adee32a5e0d2b1269b8d65a8f7d16acba
Python
stiley/pyimage-work
/module1/contours-1.11.1.py
UTF-8
2,408
2.953125
3
[]
no_license
# import the necessary packages ################################################################ # See this page for discussion https://gurus.pyimagesearch.com/topic/finding-and-drawing-contours/ ################################################################ import numpy as np import argparse import cv2 import imuti...
true
3c66f9aed3a5d06268db5f643de7f4bd84001768
Python
sargerasy/vuuvv_old_one
/fixtures/gen-news.py
UTF-8
3,798
2.671875
3
[]
no_license
""" Basically just an API wrapped around Douglas Savitsky's code from http://www.ecp.cc/pyado.html Recordset iterator taken from excel.py in Nicolas Lehuen's code from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440661 """ AD_OPEN_KEYSET = 1 AD_LOCK_OPTIMISTIC = 3 import win32com.client import json class A...
true
07ea1366adb21fb993406eb7fec7ed26ed24249c
Python
AustinGarrick1818/BadBot_v2
/modules/utils.py
UTF-8
90
3.203125
3
[]
no_license
def exit(exit_code): # Convert string into integer code = int(exit_code) sys.exit(code)
true
609516048bac1c3535097d81d9339e57b5dfd823
Python
iGEM-Thessaloniki-2019/Genetic-Algorithm-System-Sequencing
/Genetic_Algorithm/Genetic_Algorithm/RandomReplace.py
UTF-8
2,485
2.84375
3
[]
no_license
import os import re import argparse import random parser = argparse.ArgumentParser(description='The script puts random Nuclotides in a .pil file.') parser.add_argument('-ip','--pil_file', help='The input .pil file') parser.add_argument('-op','--new_pil', help='The output .pil file') args = parser.parse_args() pil_fi...
true
536259c9a7914dd5d237478d84a3dbd2ef25b3fa
Python
ProjectDBD/CPAudio
/BitStream.py
UTF-8
1,676
2.546875
3
[]
no_license
from cpaudio_lib import * from BitPacker import BitPacker import struct class BitStream: def __init__( self, buffer ): if( type( buffer ) is str ): self.stream = python_bit_stream_initialize( buffer ) else: self.stream = \ python_bit_stream_initialize_from_bit_packer( buffer.packer ) ...
true
ebdbd8e56323b21b65b06b34785496f828a69ae8
Python
whole-tale/girder_wt_data_manager
/server/resources/session.py
UTF-8
5,012
2.515625
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- from girder.api.rest import Resource, RestException from girder.api.rest import filtermodel from girder.constants import AccessType from girder.api import access from girder.api.describe import Description, autoDescribeRoute from ..models.session import Session as Session...
true
d8223817f074c89c3e04540ba5aeac7c32c69d82
Python
fera0013/FullStackWebDevelopment
/fullstack-nanodegree-vm/vagrant/catalog/catalog/model.py
UTF-8
4,995
2.84375
3
[]
no_license
import sys from sqlalchemy import Column, ForeignKey, Integer, String, DateTime, desc from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy import create_engine from datetime import datetime import sqlite3 from flask import g from sqlalchemy.orm import sessionma...
true
a2cd318f1a8ac140dd3d3fe8106c3d306e5db9c6
Python
bluedai180/PythonAdvance
/chapter6/muti_process.py
UTF-8
363
2.75
3
[]
no_license
from multiprocessing import Process, Pipe, Queue q = Queue() p1, p2 = Pipe() def f_pipe(p): p.send(p.recv() * 2) def f_queue(q): print('start') print(q.get()) print('end') if __name__ == "__main__": # Process(target=f, args=(q,)).start() # q.put(2) Process(target=f_pipe, args=(p2,)).st...
true
8bb4502c2a3691a6985dd3f8734b003eeb64eebe
Python
b3b/midistream
/midistream/helpers.py
UTF-8
7,159
3.4375
3
[ "MIT" ]
permissive
"""Helpers to work with MIDI messages. """ import re from enum import IntEnum from typing import Dict, Generator, List def midi_note_on(note: int, channel: int = 0, velocity: int = 64) -> List[int]: """MIDI 9nH message - note on. >>> midi_note_on(70) [144, 70, 64] >>> midi_note_on(70, velocity=127, c...
true
70e6ec34abd62f95ccb0ba09fd4f4e44413d7af3
Python
WarrenGreen/AI-Norvig
/ai/search/classical/recursive_best_first_search.py
UTF-8
2,008
3.28125
3
[]
no_license
from ai.search.exception import ( NoValidPathException, CostLimitReachedException, ) # TODO: Doesn't work yet def search(problem, heuristic_fn): """ Args: problem (GraphProblem): heuristic_fn (Callable[GraphNode, GraphNode]): function to estimate cost between parameter ...
true
94d6bc3390bebdfc85787db4a9aea46ed5980b42
Python
mpi2/LAMA
/lama/qc/metric_charts.py
UTF-8
3,166
2.953125
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env python """ Given a directory containing a multi-level registration, make plots of the cost function for each resolution. Creates a html report concatentating all the images into one. """ ITER_PREFIX = 'IterationInfo' CSS_FILE = 'style.css' import os from os.path import join, relpath import matplotlib ...
true
7c6145db88a90936561aa50582f704b5f2eb9760
Python
ishwarjindal/Think-Python
/Ex11_04_hasDuplicates.py
UTF-8
858
3.78125
4
[]
no_license
#Author : Ishwar Jindal #Created On : 06-Oct-2019 09:07 AM #Purpose : Checks if a list has duplicate elements def has_duplicates(lstItems): items_dict = dict() for item in lstItems: if not item in items_dict: items_dict[item] = '' else: return True return False if ...
true
55bfe78c065c989557102f0fa7a67dabd7f0391f
Python
AnupamKP/py-coding
/stack/stack.py
UTF-8
1,160
4.59375
5
[ "MIT" ]
permissive
# Q. Design an queue using linkedlist and have basic capabilities of add , delete and get methods class AStack: def __init__(self): """ initialize stack data structure using list. """ self.stack = [] self.top = -1 def push(self, val: int) -> None: """ ...
true
5d72f6f17fb5c4907783cc9cf237b2883af4f87a
Python
Bharathbrothers/LeetCode
/solutions/python3/0079.py
UTF-8
943
3.296875
3
[]
no_license
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: if not board: return False for i in range(len(board)): for j in range(len(board[0])): if self.dfs(board, word, i, j, 0): return True return False def...
true
fbc090ec403062d6f8b62aebecf522764fcdde6b
Python
dilawarm/competitive-programming
/leet/nextrightpointer.py
UTF-8
690
3.078125
3
[]
no_license
class Solution: def process(self, child: 'Node', prev: 'Node', head: 'Node'): if child: if prev: prev.next= child else: head = child prev = child return prev, head def connect(self, root: 'Node') -> 'Node': ...
true
cccd14621f3ec0cbc77f3d6892fed111c7dfbd7e
Python
xiaojinghu/Leetcode
/Leetcode0264_Heap.py
UTF-8
626
3.21875
3
[]
no_license
import heapq class Solution(object): def nthUglyNumber(self, n): """ :type n: int :rtype: int """ if n == 1: return 1 minHeap = [2,3,5] count = 1 prev = 1 while(count<n): res = heapq.heappop(minHeap) ...
true
f5d8f87ff11ad0d7f9a89f955dc3421a12d15ba1
Python
GuillaumePayeur/PHYS350_Assignment_5
/compute_coefficients.py
UTF-8
513
3.015625
3
[]
no_license
import numpy as np from scipy.special import legendre import matplotlib.pyplot as plt from scipy.integrate import quad as integrate def f(theta, l): return legendre(l)(np.cos(theta))*np.sin(theta) def compute_coefficient(l): coefficient = (1/2)*(integrate(f,0,np.pi/2,args=(l),epsabs=1e-3)[0] ...
true