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
2435df09cc95520ba443b9f3c0ee710fe8d73d56
Python
thaisfreitas/intro-to-pytest
/tests/test_multiplication.py
UTF-8
895
3.671875
4
[]
no_license
import pytest # -------------------------- # Multiplication test ideias # -------------------------- # two positive integers # identity: multiplying any number by 1 # zero: multiplying any number by 0 # positive by a negative # negative by a negative # multiply floats # -------------------------- def test_multiply_...
true
4bbacd461189d7c2fbe397c3c35d68ca744ba6ce
Python
PRIVATpython/shop_bot
/db/db.py
UTF-8
1,139
2.515625
3
[]
no_license
from pymongo import MongoClient from settings import MONGO_DB_LINK, MONGO_DB client = MongoClient(MONGO_DB_LINK) db = client[MONGO_DB] def get_or_create_user(user_data): '''Создание/получение юзера''' user = db.users.find_one({'user_id': user_data.id}) if user : if user['username'] != user_data.u...
true
27377b39303053c3aab87962384aaa9928c05742
Python
MirrorN/NLP_beginner
/Dive_into_DL/mlp2.py
UTF-8
2,361
2.796875
3
[]
no_license
import torch import torch.nn as nn import torch.optim as optim import numpy as np import torch.utils.data as Data import torchvision import torchvision.transforms as transforms ''' GPU 版本 除了model 和 loss_function 以及训练数据转移到GPU之外 记的 evaluate 的时候也要把数据转移! ''' # 获取数据集 mnist_train = torchvision.datasets.FashionMNIST(root='....
true
e87894d5a45649af0efb5146a19da10ac38dcc90
Python
SamT123/VectorSim
/scripts/old/forward_time/linkage_functions.py
UTF-8
4,213
2.671875
3
[]
no_license
import itertools import numpy as np import simuPOP as sim import itertools from simuPOP.sampling import drawRandomSample def calculate_estimates(param_dict, m, repeats, vary = False,): if vary: print('\t',vary[0], " simulations") param_dict[vary[0]] = vary[1] param_combos = list(itertools....
true
5d57cea51b2125f4965edc60a117ae745f6ffa69
Python
JannaKim/PS
/dp/review/12865_평범한배낭1104.py
UTF-8
556
3.359375
3
[]
no_license
N, K = map(int, input().split()) P = [] for _ in range(N): a, b = map(int, input().split()) P.append((a,b)) # dp[i][j]: 0~i 물건들 중에서 무게 j 이하로 가져갈 때 가져갈 수 있는 최대 가치 dp = [] [dp.append([0]*(K+1)) for _ in range(N)] for i in range(N): for j in range(K+1): if P[i][0]<=j: dp[i][j] = max(dp[i-1...
true
3e43b6037bea0837b2cfadd5dc4f596fce85b162
Python
Alphadelta14/python-compile-engine
/compileengine/decompiler.py
UTF-8
2,936
3.34375
3
[ "MIT" ]
permissive
from expression import ExpressionBlock class Decompiler(ExpressionBlock): """Base Decompiler class for building expression blocks from a stream Attributes ---------- handle : readable File handle to read from. This should be seeked to the start of the expression. start : int ...
true
2043a2ae54412c4f0a2d9023466eac2ab63ba15e
Python
neel145512/pytholog-family-tree
/Neel_Ex1.py
UTF-8
6,770
3.328125
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 # In[1]: # Author : Neel V Zadafiya (1115533) #Import required libraries import pytholog as pl # In[2]: # Define class class SimpsonFamily: # Constructor function def __init__(self): # Set knowledge base self.family_base = pl.KnowledgeB...
true
a4bd6c4030cc4e74523227a6727d860140252648
Python
jsshim24/school-work
/Intro to Programming/Assignments/Assignment 5/ShimJunSeob_assign5_part3b.py
UTF-8
588
4.09375
4
[]
no_license
""" Assignment #5, Part 3b Jun Seob Shim 15/10/2020 Intro to Programming Section 012 Find all prime numbers between 1 and 1000 """ import math #start with 2 print("2 is a prime number!") #up until 999 for a in range(2,1000): #for determining whether number is prime at the end prime ...
true
649fc0a984524b03e2c8991625006a57c9c9b9ca
Python
eightnoteight/compro
/codejam/2016/qualifiers/CoinJam.py
UTF-8
624
2.765625
3
[]
no_license
def main(): s = '1{}1' for t in xrange(1, 1 + int(raw_input())): n, j = map(int, raw_input().split()) n -= 2 print 'Case %d:' % t for x in xrange(2**n): facs = [] num_s = s.format(bin(x)[2:].zfill(n)) for y in xrange(2, 11): num...
true
7507cebcf42f1b69bca5c3408562785a86d3cd67
Python
aircov/recmd_proj
/machine_learning/预测房价/house_price_prediction.py
UTF-8
2,796
2.828125
3
[ "Apache-2.0" ]
permissive
# -*- coding: utf-8 -*- """ @time : 2020/10/15 @author : 姚明伟 """ import pandas as pd import numpy as np import matplotlib.pyplot as plt import os from sklearn.linear_model import LinearRegression from sklearn.neighbors import KNeighborsRegressor from sklearn.svm import SVR from sklearn.linear_model import Lasso from ...
true
2af48a5a89d415d75c58adab8121d9dbe8fb0a7d
Python
RaphaelLarouche/radiance_endoscope_v3
/threadfile.py
UTF-8
4,099
2.703125
3
[]
no_license
# -*- coding: utf-8 -*- """ File with of threads. """ from PyQt5 import QtWidgets, QtCore, QtGui import imu_sensor import radiance import time from ximea import xiapi import numpy as np class Euler(QtCore.QThread): """ """ my_signal = QtCore.pyqtSignal(float, float, float) def __init__(self): ...
true
21defbefa45400b89a563bedb0d1ab4f0563b28e
Python
rzhang404/AOC2020
/Day 24/part_2.py
UTF-8
2,402
3.40625
3
[]
no_license
fo = open("input.txt","r") raw = fo.read() strs = raw.split() grid = set() for tile in strs: mod = "" x, y = 0, 0 # collapse to ne and e axes for char in tile: if char == "n" or char == "s": mod = char else: # if char == "e": if mod == "n": ...
true
db380907588f8232c2ebeff7015926c835cbf141
Python
dsharp32/wine_ordering
/send_loop.py
UTF-8
829
2.875
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 26 15:51:14 2020 @author: user """ import send_message_gmail as sm def send_loop(email, company, body,po,cc_email,bcc_email): num_loops = 0 try: sm.send_message(email, company, body,po,cc_email,bcc_email) except OSError: ...
true
466e183ef9dfaec57a2e97811ba6b4a8aa64b3da
Python
nikasnizhko/python_beetroot
/lesson7_homework.py
UTF-8
418
4.5625
5
[]
no_license
#Task.1 Dict comprehension exercise. user_input = input("Enter your text: ") text = user_input.split() new_dict = {word: text.count(word) for word in text} print(new_dict) #Task.2 List comprehension exercise I a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] b = [number for number in a if number%2 != 0] print(b) #...
true
b093686c5cd6f8be54b21af0ed040ae67fa7d343
Python
ppatali/cci-book
/ch01-arrays-strings/Q04PalindromePermutation.py
UTF-8
680
4.0625
4
[]
no_license
from collections import Counter def IsPalindromePermutation(input: str) -> bool: counter = Counter() oddCount = 0 for c in input: c = c.lower() if ord('a') <= ord(c) and ord(c) <= ord('z'): counter[c] += 1 if (counter[c] % 2 == 1): oddCount += 1 ...
true
15e8d0a5d741e2154f0172cd8dc8114e98339257
Python
BushuBushu/TIL-for-soyoungJung
/Inflearn/Section04/04_마구간 정하기/AA.py
UTF-8
1,668
3.203125
3
[]
no_license
import sys #sys.stdin = open('input.txt','r') ''' def Check(midd): for i in range(2, len(zero + 1)): if zero[i] == 1: N, C = map(int, input().split()) xi = [] for _ in range(N): xi.append(map(int, input().split())) #x좌표의 가장 큰 부분까지의 리스트 zero = [0] * (max(xi) + 1) #1번째 인덱스가 1이라면, x1번째 마구간 ...
true
bd8b9798e99bfc15e12c23684833fddf975efc8a
Python
MirzaMulaosmanovic/slackoff
/slackoff/threadfactory.py
UTF-8
274
2.671875
3
[]
no_license
import threading def default_factory(target, name=None, as_daemon=True, args=None): """ default thread factory, used to create threads as daemon """ t = threading.Thread(target=target, name=name, args=args or []) t.setDaemon(as_daemon) return t
true
dc26659af8b7acd21b6a2820ad2f318631d4d461
Python
ngraymon/494_dev
/Code/pathbuilder_PIGS.py
UTF-8
5,258
2.609375
3
[]
no_license
from MMTK import * from PIGSHarmonicOscillatorFF import PIGSHarmonicOscillatorForceField from MMTK.ForceFields.ForceFieldTest import gradientTest, forceConstantTest from MMTK_PIGSNormalModeIntegrator import PIGSLangevinNormalModeIntegrator from MMTK.Environment import PathIntegrals ...
true
6e98c44fe3df16ab7a3a2134cbd0310ee9044623
Python
TEAMLAB-Lecture/morsecode-glowing713
/morsecode.py
UTF-8
4,333
3.625
4
[]
no_license
# -*- coding: utf8 -*- import re # Help Function - 수정하지 말 것 def get_morse_code_dict(): morse_code = { "A": ".-", "N": "-.", "B": "-...", "O": "---", "C": "-.-.", "P": ".--.", "D": "-..", "Q": "--.-", "E": ".", "R": ".-.", "F": "..-.", "S": "...", "G": "--.", "T": "-", "H": "....", "U": "..-", "I":...
true
77b09eb97f73b271940c53aee88f5246546d6a4b
Python
amelialutz9/CSSI
/FirstPython/groceries.py
UTF-8
819
3.78125
4
[]
no_license
from random import randint def get_groceries(): groceries=[] amount=[] count=0 num=int(raw_input("How many groceries do you need? ")) for i in range(num): food=raw_input("What food do you need? ") num_food=int(raw_input("How many do you need? ")) if (count==0): g...
true
3a93d79c46e79dab7b75866da17cb8ba596cdffc
Python
projekt-fredrika/Fredrikas-Lupp
/scripts/pywikibot/csv-add.py
UTF-8
16,999
3.328125
3
[ "MIT" ]
permissive
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Script for adding pages to categories and simpliying names based on csvfile. Devloped for use in cleaning up island pages on svwiki and adding them to correct categories. Needs to be modified to support using with other categories/use cases. Script reads each page from ...
true
4753735b1deb3c7e8edf5317ba7b8c684948ae4a
Python
yz5201214/python_study
/chapter6/spider_office-cookie-case01/spider-authCode-case12.py
UTF-8
273
2.796875
3
[]
no_license
''' 识别简单图片验证码 ''' from PIL import Image import pytesseract def test01(): # 图片实例 image = Image.open(r'f:/4.png') # 转换后的结果 text = pytesseract.image_to_string(image) print(text) if __name__ == '__main__': test01()
true
27e1e8392c6ca079045025e53bf13bc17ad520d0
Python
haibonlp/LeaPI
/leapi/classifiers/sklearn_classifier.py
UTF-8
1,818
2.5625
3
[]
no_license
# coding:utf-8 import sys from sklearn.linear_model import LogisticRegression from time import time from sklearn.feature_extraction import DictVectorizer from sklearn.naive_bayes import BernoulliNB, MultinomialNB, GaussianNB from sklearn.ensemble import ExtraTreesClassifier from sklearn.svm import SVC import numpy as...
true
d485182fb098069fda7c95cfcb17dd2a45490225
Python
johncava/iccv_2019
/legacy/rename_jpg.py
UTF-8
370
2.53125
3
[]
no_license
import os import glob import numpy as np import sys directory = sys.argv[1] csv_input_path='./' + directory + '/*.jpg' files = glob.glob(csv_input_path) p = [] for file_ in files: num = int(file_.split('/')[-1].split('.jpg')[0]) p.append((num,file_)) files = sorted(p,key=lambda x: x[0]) i=1 for f in files: ...
true
27d834e27287dd15395b991fdfff0bc274512e9d
Python
HarshaaArunachalam/GUV
/code/48.py
UTF-8
159
3.3125
3
[]
no_license
number=int(input()) count=0 L=[] for i in range(1,number+1): if((number%i)==0): L.append(i) for j in L: if((j%2)!=0): print(j,end=" ")
true
d0dffb14e3d1349aaf0c4f3fa4cc3102af9620e5
Python
zhaonian/Camera-Finder
/Camera Localization/ProjectionEstimator.py
UTF-8
4,432
2.65625
3
[]
no_license
import math as m import numpy as np import lmfit as lf NUM_POINT_REFERENCE = 5 class ProjectionEstimator: def __init__(self): return def __t_rot(self, rx, ry, rz): m_rx = np.matrix([[1, 0, 0], [0, m.cos(rx), -m.sin(rx)], ...
true
63089f61394dada3f80dc661134eb7412fc353eb
Python
lyllbl/hello-world
/CCA175/R1/Python/Spark66_RDD.py
UTF-8
452
2.75
3
[]
no_license
from pyspark.sql import SparkSession spark = SparkSession.builder.enableHiveSupport().getOrCreate() sc = spark.sparkContext sc.setLogLevel("ERROR") a = sc.parallelize(["dog", "tiger", "lion", "cat", "spider", "eagle"], 2) b = a.keyBy(lambda item:len(item)) c = sc.parallelize(["ant", "falcon", "squid"], 2)...
true
c198aca6625598cf7f65ec78dd45b4d6454e33b1
Python
markraemer/mH-PriSe
/apk/checkObfuscation.py
UTF-8
3,956
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/python # KK, January 2015 # MK Jul 2016 # The script checks if an APK used Proguard obfuscation and outputs a probability from androguard.core.bytecodes import apk from androguard.core.bytecodes import dvm # from androguard.decompiler.dad import decompile from collections import defaultdict from db.Apps i...
true
330565a9661d58e7e4c76c5ef39efc811d5ac455
Python
Michael-Wisniewski/algorithms-unlocked
/chapter 2/4_factorial.py
UTF-8
497
4.125
4
[]
no_license
def factorial(n): """Time complexity - O(n), memory consumption - O(n) * * For small numbers where: - multiplication time complexity is O(1) - integer variable size is constant To check maximum available recursion depth run: import sys print(sys.getrecursionlimit()) >>> factorial(...
true
0b1a00fa40237da6b1656644d1d5dc838464fdd6
Python
ch0r1es-1n-ch0rge/starting_out_with_Python
/Chapter 3 - Programming Exercises/CH:3 - Roulette Wheel Colors.py
UTF-8
1,497
4.84375
5
[]
no_license
# On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows: # - Pocket 0 is green. # - For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black. # - For pockets 11 through 18. the odd-numbered pockets are black and the even-numb...
true
fd9a80daf3dae48976f5e63e30b86f55e2777ebf
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_201/1861.py
UTF-8
1,268
3.03125
3
[]
no_license
import sys def readFile(flname): lines = open(flname).read().split("\n") outputfl = open("output.txt","w") testAmount = int(lines[0]) for i in range(1,len(lines)-1): curTest = lines[i].split(" ") (y,z) = solveSpecificRow(int(curTest[0]), int(curTest[1])) outputfl.write("C...
true
aec79e082c5a05b2c2bc91174b98740b121732b5
Python
DeepWalter/python-projects
/alien_invasion/ship.py
UTF-8
4,123
4.125
4
[]
no_license
import pygame from pygame.sprite import Sprite class Ship(Sprite): """A class used to represent the ship. Attributes ---------- ai_settings: Settings All settings in alien invasion image: pygame.Surface The image of the ship rect: pygame.Rect Rectangular coordinates of...
true
6a81998c6395d93b7c3f8fba877818af87035497
Python
srbcheema1/remote-validator-websockets
/spike/hello/server.py
UTF-8
402
2.703125
3
[]
no_license
#!/usr/bin/env python3.6 import asyncio import websockets async def hello(conn, path): name = await conn.recv() print(type(name)) print("got : " , name) greeting = "Hello " + name.decode('ascii') await conn.send(greeting) start_server = websockets.serve(hello, 'localhost', 8765) asyncio.get_eve...
true
10de57406cd62e634c93908d53dbe175d82368f4
Python
EfJot314/Konwerter-pdf
/main.py
UTF-8
2,132
3.15625
3
[]
no_license
import tkinter as tk from tkinter import filedialog as fd from PIL import Image class Application(): def __init__(self): self.path = [] self.im = [] self.root = tk.Tk() self.root.title("Konwerter PDF") self.root.geometry('700x600') self.przew = tk.Scro...
true
bafb331540e299307c22f1f1bd5199df6f68ec92
Python
igaryok/stepik_python
/ciper.py
UTF-8
662
2.984375
3
[]
no_license
def main(): orig_alphabet = input() ciper_alhpabet = input() orig_message = input() ciper_message = input() dic_ciper = {} dic_unciper = {} for i in range(len(orig_alphabet)): dic_ciper[orig_alphabet[i]] = ciper_alhpabet[i] for i in range(len(ciper_alhpabet)): ...
true
511a81e178b6ebc8af69b10d61979ec8c275045d
Python
loganrf/currency
/currency.py
UTF-8
573
3.125
3
[ "BSD-2-Clause" ]
permissive
def parseCode(codeString): findIndex = codeString.find(',') if(findIndex!=-1): indices = [findIndex] while(findIndex!=-1): findIndex = codeString.find(',',indices[-1]+1) if(findIndex!=-1): indices+=[findIndex] codes = [] startIndex = 0 for i in range(len(indices)): codes+=[codeString[startIn...
true
a6f020d29a3827fa538012aefefd263ced0ba3e2
Python
Abhinavsuresh21/python-
/arithmetic/abhi.py
UTF-8
26
2.953125
3
[]
no_license
a=5 b=6 c=a+b; print(c)
true
c0cb36a4c2cba8b4ee9ecb5c42a9c2d747223bd9
Python
h4ckd0tm3/mangekyou-cli
/mangekyou/core/facematch.py
UTF-8
1,988
2.546875
3
[]
no_license
import numpy as np import face_recognition from typing import * from mangekyou.core.config import Config from mangekyou.beans.profile import Profile class Facematch(): config: Config def __init__(self, config: Config): self.config = config def load(self, image: str): return face_recogni...
true
54b65298ebb085ea7a9935d966d7e250e22ed717
Python
Suliv4n/pokeapitodatabase
/pokeapi/provider.py
UTF-8
3,841
2.59375
3
[]
no_license
import urllib.request import json import itertools from _md5 import md5 import os.path class PokeapiProvider: def __init__(self): self.__url = "http://pokeapi.co/api/v2/%s/%s" self.__user_agent = " Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0" self.__charset...
true
8b215e9398dd92fe238cbdf0a7d27ca8b34e04c8
Python
aiguy110/advent-of-code-2020
/day_14/solution2.py
UTF-8
1,583
3.109375
3
[]
no_license
import sys import re def load_program(filename): with open(filename) as f: instructions = [] for line in f: if line[:4] == 'mask': instructions.append( ('mask', re.match(r'mask = ([01X]{36})', line).group(1)) ) else: addr, val = map...
true
c2c38ea6c39eb4da6c8e3552fd7f910f35f52635
Python
gittyy1310/guvi-code-kata
/natural.py
UTF-8
64
3.46875
3
[]
no_license
n=int(input()) x = 0 while(n > 0): x=x+n n=n-1 print(x)
true
bfec886a1634104fc562c9544169fc0ed403b675
Python
EnderGuy999/theCalculatoreOne
/main.py
UTF-8
1,163
3.078125
3
[]
no_license
import sys import traceback from Feedback import feedback from addingStuff import Starfish from subtractingStuff import Seahorse def intruck(): print("***************************************************") print("* Type the number for the corresponding function. *") print("* 1: + ...
true
6c6ac44ad438f741483ba30994f0f414887c9e2e
Python
haru2036/autofav
/scripts/JsonFile.py
UTF-8
346
2.78125
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -* import json class JsonFile: def __init__(self,filepath): self.filepath=filepath def Read(self): with open(self.filepath,'rb') as f: return json.load(f) def Write(self,contentIn): with open(self.filepath,'wb') as f: ...
true
dac4eddbee0a0a767e2a3251aad54d9be475cba8
Python
HuiwonKo/dev
/python/Pro_0626_Huiwon_2.py
UTF-8
287
3.53125
4
[]
no_license
list_1 = [2,4,7,9] list_2 = [8,6,4,2] k = 10 """ print('output:') for i in list_1: for j in list_2: if i+j == k: print(i j) """ for i in list_1: if k-i in list_2: print(i, k-i) #print(''.join["%d,%d" % (i, k-i) for i in list_1 if k-i in list_2])
true
80eb4aae7d76740aa381e4222600092567d2807e
Python
Aasthaengg/IBMdataset
/Python_codes/p03282/s880742515.py
UTF-8
218
2.84375
3
[]
no_license
import sys input = sys.stdin.readline S = input() K = input() if len(S) <= int(K): a = len(S) else: a = int(K) for i in range(a): ans = S[i] if ans != '1': print(ans) exit() print(ans)
true
a3419e1f2e2a10731ee6b903baeaf69f92dd289d
Python
GabrielVDN/tkinter-stock-tracker
/frames/update_stock.py
UTF-8
11,789
2.75
3
[]
no_license
import tkinter as tk from tkinter import ttk from tkintertable import TableCanvas import requests from tkinter import messagebox class UpdateStock(ttk.Frame): def __init__(self, parent, controller): ttk.Frame.__init__(self, parent) self.controller = controller # Center your Frame, all the...
true
19146ec1c4579df03dda1d05eb54b1df80aad934
Python
Wilson-ZHANG/chinese_ocr
/demo.py
UTF-8
1,338
2.6875
3
[ "Apache-2.0" ]
permissive
#-*- coding:utf-8 -*- import os import ocr import cv2 import time import shutil import numpy as np from PIL import Image from glob import glob image_files = glob('./test_images/*.*') #coors_files = glob('./test_coors/*.*') def crop(image_path, coors, save_dir): image_name = os.path.split(image_path)[1].split('.')[...
true
da628422ad6a9236ab54e68e790ea858d8532153
Python
Explorer1092/biubiubiu
/python/S学习/day1/day1 code/列表练习题.py
UTF-8
1,755
4.09375
4
[]
no_license
#!/usr/bin/env python # -*- coding:utf-8 -*- """ @version: 1.0 @author: shen @file:列表练习题.py @time: 16-3-13 上午12:24 读取一个字符串,计算每个字母出现的个数 方案一: 生成26个变量,代表每个字母出现的个数 方案二:生成具有26个元素的列表,将每个字母转化为相应的索引值,如a-0,b-1... """ # 方案二实现: count = [0] * 26 for i in 'abcdeadbe': count[ord(i) - 97] += 1 # ord参数是一个字符,返回他对应的整数 print(cou...
true
fb2d3fcd391457c62cf1a4d1b443b488fe08dac1
Python
Alireza-Akhavan/face_squeeze_resnet_model
/centerloss.py
UTF-8
2,697
2.5625
3
[]
no_license
from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras.datasets import mnist import functools import keras.backend as K from keras.utils import to_categorical import tensorflow as tf import numpy as np img_rows, img_cols = 28, 28 def _center_loss_func...
true
d2a90f6a3bfa56eb0f49cd81ab2f1550c59ccc5a
Python
gitter-badger/AgentNet
/agentnet/environment/session_batch.py
UTF-8
3,838
2.734375
3
[ "MIT" ]
permissive
from theano import tensor as T from ..objective import BaseObjective from ..environment import BaseEnvironment import numpy as np import theano from collections import OrderedDict from ..utils import create_shared,set_shared, insert_dim from ..utils.format import check_list class SessionBatchEnvironment(BaseEnvironm...
true
df59b9030565151bae3c67c3a065757c74791658
Python
trolllabs/trollsim
/backend/misc.py
UTF-8
6,356
3
3
[ "BSD-2-Clause" ]
permissive
""" .. module:: misc The misc module contains a collection of smaller tools which does not fit any of the other categories (endpoints, protocols, processors, patterns etc...) """ import struct, json, argparse, sys, logging, os class ArgparseHelper(argparse.ArgumentParser): """ Prints help when flags or program ar...
true
a8c80a106a9be231ea2089652c799aee185f52a4
Python
Fadhs/itp112
/practical8/4.py
UTF-8
375
4.09375
4
[]
no_license
try: number_file = open('numbers.txt', 'r') sum = 0 count = 0 for number in number_file: sum += int(number) count += 1 except IOError: print('File cannot be found') except ValueError: print('Invalid integer') except: print('An unknown error occured') else: print('There ar...
true
5c375b1f432815ff0b6b6951c7e8432de23a3e5f
Python
awfeequdng/Reinforcement_Basic_to_Pro
/Basic_Gym_SingleAgent_Envs/random_search.py
UTF-8
1,171
3.3125
3
[]
no_license
import numpy as np import gym import matplotlib.pyplot as plt def random_action(s, w): return 1 if s.dot(w) > 0 else 0 def play_one_episode(env, param): observation = env.reset() t = 0 done = False while not done and t < 10000: # env.render() t += 1 action = random_action...
true
528a14a2bd540b9c9644231b4e2998c01dd7470a
Python
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc066/A/4123789.py
UTF-8
664
2.59375
3
[]
no_license
N=int(input()) ans=None tmp=0 z=1 if(N%2==0): tmp=int(N/2) ans=[2 for i in range(tmp)] A=map(int,input().split()) for i in A: if(int(i/2)<=int(N/2)): ans[int(i/2)-1]-=1 else: print(0) exit() else: tmp=int(N/2) ans=[2 for i in...
true
9e2642bde8df73a8957e66c10425a5ad88e04325
Python
chenlinlin6/Resuable_codes
/evaluate_model.py
UTF-8
1,082
2.515625
3
[]
no_license
def get_ks(y_true, y_prob, thresholds_num=250): # 生成一系列阈值 thresholds = np.linspace(np.min(y_prob), np.max(y_prob), thresholds_num) def tpr_fpr_delta(threshold): y_pred = np.array([int(i>threshold) for i in y_prob]) tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel() ...
true
361de9ab4d793bd2dbf1c10eb83044293becd1da
Python
mateimicu/ag_frame
/ag_frame/selections/turneu.py
UTF-8
947
3.046875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Roata norocului. """ from ag_frame.selections import base class Turneru(base.BaseSelection): """The fittest ones have the higher chance.""" _name = "Turneu" def __init__(self, representaion): """Initialize an Selection algorithm. :param ...
true
c72d8d970d9029694c75e769334c08858d7bb195
Python
mschoch/testrunner
/scripts/collect_server_info.py
UTF-8
3,390
2.515625
3
[]
no_license
import getopt import sys import time from threading import Thread from datetime import datetime sys.path.append(".") sys.path.append("lib") from remote.remote_util import RemoteMachineShellConnection import testconstants import TestInput import logger def usage(error=None): print """\ Syntax: collect_server_info....
true
8162704ec96376e351d46c0eeea2992e45f04093
Python
HongquanZhang9/Ramen
/src/average_star_country.py
UTF-8
1,840
3.171875
3
[]
no_license
import numpy as np import pandas as pd import matplotlib.pyplot as plt # for visualisation import seaborn as sns # for visualisation ramen_data = pd.read_csv('../data/ramen-ratings.csv') ramen_data['Stars'] = pd.to_numeric(ramen_data['Stars'], errors = 'coerce') ramen_data['Brand'] = ramen_data['Brand'].str.l...
true
d97d0f51cef3aa626d266ec1849be895e30fed47
Python
biolink/ontobio
/ontobio/model/GolrResults.py
UTF-8
1,527
2.671875
3
[]
permissive
from dataclasses import dataclass from typing import Dict, List, Optional @dataclass(frozen=True) class Highlight: highlight: str = None match: str = None has_highlight: bool = None @dataclass class SearchResults: """ Search results class from transformed solr results docs: pysolr.Results.d...
true
22bd5705af38235286b2144ef2f04298e919b8f5
Python
Zenrac/yuna
/cogs/nsfw.py
UTF-8
2,933
2.71875
3
[ "MIT" ]
permissive
import discord from discord.ext import commands import asyncio import aiohttp import requests from colorthief import ColorThief from io import BytesIO import random class NSFW(): """These commands can only be used in NSFW-Marked Channels""" def __init__(self, bot): self.bot = bot @com...
true
e5bbf7deb6dea5308bc075c850fc98ff8518f73f
Python
Skinbow/LearnVocabulary
/ListRandomiser.py
UTF-8
745
3.453125
3
[]
no_license
import random class ListRandomiser: def RandomizeList(list = [], dict = {}, randomizationType = ""): if len(list) != 0: newlist = list random.shuffle(newlist) return newlist if randomizationType == "first" or randomizationType == "second": randomKeys ...
true
f16105b7f5efb97498feeb5fdf4ad9a5ca16ead1
Python
takumiw/AtCoder
/ABC036/B.py
UTF-8
370
2.890625
3
[]
no_license
import sys readline = sys.stdin.readline def main(): N = int(readline()) inp = [readline().rstrip() for _ in range(N)] ans = [[None]*N for _ in range(N)] for j in range(N): for i in range(N-1, -1, -1): ans[j][N-i-1] = inp[i][j] ans = [''.join(l) for l in ans] print(*ans...
true
5969e90a30934589e5f8b50e7ca492ec2c5eb30c
Python
syurskyi/Python_Topics
/125_algorithms/_examples/100_Python_Exercises_Evaluate_and_Improve_Your_Skills/Exercise 48 - IndentationError NUKE.py
UTF-8
195
4.09375
4
[]
no_license
#The script is supposed to print a string item if that item is character "l". #Solution indent everything under an if statement for letter in "Hello": if letter == "e": print(letter)
true
f0ecf7f963362b3bb9d75f148dc8b9bd663e089f
Python
CU-Boulder-Course/MLProjectBYZ
/code/preprocess_test_v1.py
UTF-8
799
2.609375
3
[]
no_license
from csv import DictReader, DictWriter import string from nltk.stem.wordnet import WordNetLemmatizer from nltk.corpus import stopwords import csv import json from collections import defaultdict punct = set(string.punctuation) stop = stopwords.words('english') stemmer = WordNetLemmatizer() d = defaultdict(dict) for ...
true
2aacb6e79bf94e76bb41f2dc28470505a47ba6f5
Python
bcveber/COSC101
/lab8/Lab08_try2.py
UTF-8
3,665
3.765625
4
[]
no_license
# Brodie Cohen, Brian Veber Lab 8 # Part 1 def main_encrypt(): ''' Asks for the Vigenere key to be used. Asks for the file to encrypt. Saves encrypted file as encoded.txt. ''' key = input('What is the Vigenere key you want to use? ') txt_file = input('What is the name of the file to be encrypt...
true
ad173e58d5b2dd444ffc91ed2bf756e9686d2742
Python
Ovec/vs_project
/input.py
UTF-8
2,010
3.96875
4
[]
no_license
"""This is input reading module. Input reading module suplies functions for reading values from stdin and parse them to points. """ def parsePoint(pointInput): """Parse point to coordinates pair (list of two numbers). Args: pointInput (string): pointInput read from terminal Returns: li...
true
d993b50378c4c08c099a95fd334bcba303b5ed96
Python
minhdq99hp/dsa
/hackerrank/count-strings.py
UTF-8
2,885
3.390625
3
[]
no_license
#!/bin/python3 import os import sys # # Complete the countStrings function below. # def countCases(arr, remind, l): """ Input: arr[]: contain the lengths of elements remind[]: containt the result of countCases with l is the index of remind[]. l: length of required strings Output: ...
true
7a2906893a362e72b63bd7a3ba8af21341998fa5
Python
JonathanMbt/SNA_Parking_Behavior
/src/botometerTopTen.py
UTF-8
1,800
2.703125
3
[ "MIT" ]
permissive
import matplotlib.pyplot as plt import botometer from commands import * from functions import * import statistics as st def scrutinize(hashtags): rapidapi_key = "38940d0f3fmsh988bf0ed564bfb9p11f319jsn5db669988640" twitter_app_auth = { 'consumer_key': 'J2vBhcxzmgI3AkyMVBW14cG4K', 'consumer_secr...
true
011130f4857605a5b28d621693721863baddfa0b
Python
tiy-sat/scoots-python
/week1/PYPIGGY.py
UTF-8
4,311
3.375
3
[]
no_license
cont='y' #will be used to control while loop piglist=[] #will be used for `for` loop at the end. vow = ('a', 'e', 'i', 'o', 'u') def convert_word(word): first = word[0] #first = the first letter of (word) if first in vow: #checks i...
true
0e209f8275fffe95e19d5c84b1c40be97dc8947a
Python
hyeonahkiki/startcamp
/file/navermusic.py
UTF-8
524
2.90625
3
[]
no_license
import csv import requests from bs4 import BeautifulSoup url = "https://music.naver.com/" res = requests.get(url).text soup = BeautifulSoup(res, 'html.parser') tr = soup.select('tbody > tr') with open("naver_music.csv", 'w', encoding='utf-8', newline = "") as f: csv_writer = csv.writer(f) for r in tr : ...
true
e813030b55db207511ef02686121a69285e7e3ec
Python
VCloser/CodingInterviewChinese2-python
/45_SortArrayForMinNumber.py
UTF-8
781
3.8125
4
[]
no_license
""" 由于python3中sorted函数除去compare函数,无法自定义排序规则,所以使用内置的函数,将cmp函数转化为key的值 Note: functools.cmp_to_key() 将 cmp函数 转化为 key。 cmp函数的返回值 必须为 [1,-1,0] """ from functools import cmp_to_key def compare(strNum1, strNum2): newStrNum1 = strNum1 + strNum2 newStrNum2 = strNum2 + strNum1 if newStrNum...
true
3c93546524d6076f816a31e40d0f0639cc3fbd88
Python
velwu/Fall20-Projects
/print_board.py
UTF-8
1,663
2.828125
3
[]
no_license
import chess #import sunfish import math import random import pandas as pd import sys import chess.svg import mechanics # My IDE and test environments both use black backgrounds # so on GitHub pages, chess icon colors might be flipped # for clarification, uppercase means White, and lowercase means Black ...
true
29675d8ac4a23b77c4ecd29abf88911b2ab7cba7
Python
zhangfeng0812/quanta_competition
/使用GBDT+FM预测/gdbt_LR_stock_predict.py
UTF-8
4,267
2.703125
3
[]
no_license
import pandas as pd import numpy as np import csv from sklearn.preprocessing import OneHotEncoder from sklearn.ensemble import GradientBoostingClassifier from sklearn.linear_model import LogisticRegression from sklearn.utils import shuffle from sklearn.model_selection import train_test_split import matplotlib.pyplot as...
true
817467993c1760e83bd8bda488df44a9ae7b4eb8
Python
cfg-london/team-9
/backend/src/shared/entity.py
UTF-8
1,420
3.015625
3
[]
no_license
import json class Entity: @staticmethod def to_entity(entity, type, score=None): ans = json.loads(json.dumps({'id':'', 'type':'', 'label':'', 'value':''})) ans['type'] = type ans['value'] = entity if type == 'laureate': ans['id'] = 'laureate_' + entity['id'] ...
true
fe3c24837c574502f6f3238c02ba0d5360c280dc
Python
EduardoSantos7/Algorithms4fun
/Leetcode/430. Flatten a Multilevel Doubly Linked List/solution.py
UTF-8
758
3.34375
3
[]
no_license
""" # Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child """ class Solution: def flatten(self, head: 'Node') -> 'Node': if not head: return temp = head ...
true
e4fec584c15c8a2b508455bee3baab8341377a23
Python
jingggo/Python_100Days
/Day16-20/Day016/code/ex5.py
UTF-8
223
3.359375
3
[]
no_license
""" 迭代工具 - 排列 / 组合 / 笛卡尔积 @Author:jyang @Date:5/25/2019 """ import itertools print(itertools.permutations('ABCD')) print(itertools.combinations('ABCDE', 3)) print(itertools.product('ABCD','123'))
true
eb63eddfea554a2307aa732cb9fca104daf96a59
Python
rafaelwitter/UFSC
/ESTRUTURA_DADOS/projeto_pessoa_filtragem/DAO/pessoa_id.py
UTF-8
337
2.609375
3
[]
no_license
from DAO.abstract_DAO import DAO from model.pessoa import Pessoa class PessoaID(DAO): def __init__(self): super().__init__('DAO/pessoa_id.pkl') def inclui(self, pessoa: Pessoa): if (pessoa is not None) and (isinstance(pessoa.id, int)) and isinstance(pessoa, Pessoa): super().add(pe...
true
bda680e661baee71e2e3d61ab83e1333e8b79945
Python
tkzky/python-opencv
/codes/test_27.py
UTF-8
451
3.125
3
[]
no_license
''' canny边缘检测 过程: 去噪、梯度、非极大值抑制、泄后阈值 edges = cv.Canny(img,threshold1,threshold2) threshold1 minVal阈值1 threshold2 maxVal阈值2 阈值越小,边界越丰富 ''' import cv2 as cv o = cv.imread('lena256.bmp',cv.IMREAD_GRAYSCALE) r1 = cv.Canny(o,100,200) r2 = cv.Canny(o,64,128) cv.imshow('original',o) cv.imshow('canny1',r1) cv.im...
true
b9f6d37d00018ee02774130543066513681644ef
Python
z1223343/Leetcode-Exercise
/100_206_ReverseLinkedList.py
UTF-8
934
3.546875
4
[]
no_license
""" 1 level solution: 1. iteration time: O(n) space:O(1) """ # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: prev = None curr ...
true
95d8ea1ea6d2a521e4808ceee79a4ee07bd6543c
Python
Pyush146/Temp
/duplicatedictionary.py
UTF-8
218
3.34375
3
[]
no_license
d={} a={} n= int(input("enter number ")) for i in range(n): key= input("enter key") value=input("enter value") d[key]=value print(d) for key,value in d.items() : if value not in a.values(): a[key]= value print(a)
true
793f321efe946fdeaaa9856dd6c363375060d5fe
Python
BQSKit/bqskit
/bqskit/ir/structure.py
UTF-8
1,828
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
"""This module implements the CircuitStructure Class.""" from __future__ import annotations from bqskit.ir.circuit import Circuit class CircuitStructure: """Stores compressed positions of gates in a circuit as a hashable type.""" def __init__(self, circuit: Circuit) -> None: """ Construct a ...
true
baea8454fdee68aba06c32e2910eb5598df7bb1e
Python
paulsonvinsent/clustering
/wine_quality_analysis.py
UTF-8
10,644
2.5625
3
[]
no_license
import sys import pandas as pd from sklearn import mixture from sklearn import preprocessing from sklearn.cluster import KMeans from sklearn.decomposition import FastICA from sklearn.decomposition import PCA from sklearn.feature_selection import VarianceThreshold from sklearn.preprocessing import MinMaxScaler, Standar...
true
0f94eeb9cc834d165d3c4812e0ccf574346296fd
Python
AndreySperansky/TUITION
/FUNCTIONAL/Reduce/reduce_1.py
UTF-8
227
3.46875
3
[]
no_license
"""Вычисление суммы всех элементов списка при помощи reduce:""" from functools import reduce items = [1, 2, 3, 4, 5] sum_all = reduce(lambda x, y: x + y, items) print(sum_all) # 15
true
e2ab1a7856b6bcea1081664a61d0cbcad18ab719
Python
ypycff/pythonClass
/PythonDev/Demos/05-DataStructures/customSorting.py
UTF-8
370
3.8125
4
[]
no_license
def personNameLength(p) : return len(p) names = ["Andy", "Jayne", "Em", "Tom"] sortedNamesAlphabetically = sorted(names) print(sortedNamesAlphabetically) sortedNamesByLength = sorted(names, key=personNameLength) print(sortedNamesByLength) sortedNamesByLengthDescending = sorted(names, key=personNameLength, r...
true
bf3a05975730534856c6476d914b08cfb3012808
Python
KONEY/lego-space-base-leds-raspi
/led_async.py
UTF-8
5,668
2.609375
3
[]
no_license
#from EmulatorGUI import GPIO import RPi.GPIO as GPIO import time import threading from random import randint print ("RASPI ASYNC LEDS BY KONEY") keep_executing=True sleep_micro=0.01 sleep_minimum=0.02 sleep_shorter=0.06 sleep_short=0.07 sleep_medium=0.10 sleep_long=1.1 sleep_longer=2.4 sleep_maximum=4 #IO_ports=[14,...
true
36fc92ad2bfe5a18c2fd05400a3cad96d10f8963
Python
hnz71211/Python-Basis
/com.lxh/exercises/97_readline/__init__.py
UTF-8
286
3.484375
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 使用 sys.stdin.readline() 写一个和 input() 函数功能完全相同的函数 import sys def my_input(prompt): print(prompt, end='') return sys.stdin.readline().strip() str_input = my_input('请输入:') print(str_input)
true
ff5f8816efdfbe64493a5da0ffc0faa22aa5359e
Python
tanglan2009/mit6.00
/LecturePractice/L4P9.py
UTF-8
549
3.90625
4
[]
no_license
# def odd(x): # """ # x: int or float. # returns: True is x is odd, False otherwise # # """ # return x % 2 != 0 # # print odd(4) # def isVowel(char): # """ # char: a signle letter of any case # returns: True if char is a vowel and False otherwise # # """ # if char == 'a' or cha...
true
84077f9a591734459e1348b09dea5972dea55195
Python
blabber/mdjson-latex
/mdjson-latex.py
UTF-8
5,536
2.75
3
[]
no_license
# "THE BEER-WARE LICENSE" (Revision 42): # <tobias.rehbein@web.de> wrote this file. As long as you retain this notice # you can do whatever you want with this stuff. If we meet some day, and you # think this stuff is worth it, you can buy me a beer in return. # ...
true
f29db1008369eb8b7f05ba9cd372fda013919d39
Python
lwerdna/lwerdna.github.io
/binja-graphviz/helpers.py
UTF-8
4,134
2.921875
3
[]
no_license
import os import sys import re import json RECT_ATTRIBS = 'stroke="black" stroke-width="1" fill="none"' PATH_ATTRIBS = 'stroke="red" stroke-width="1" fill="none"' CIRCLE_ATTRIBS = 'stroke="red" stroke-width="1" fill="green"' SVG_HEADER = ''' <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/...
true
6455ea547bd3a27b3dd1d851965e14fc0b2e7756
Python
AlphaOrionis42/gtataryn_pi_photobooth
/tests/file test.py
UTF-8
374
2.859375
3
[ "MIT" ]
permissive
import os import fnmatch photo_files = os.listdir('/media/pi/P/pics/') num_files = len(photo_files) count = 0 print("Total files: " + str(num_files)) for i in range(0, num_files): #print(photo_files[i]) if fnmatch.fnmatch(photo_files[i], '*sm.jpg'): print("File name: " + photo_files[i]) count ...
true
d460bef6a08fa62bc46cfe70b3d78013d99c241b
Python
452990729/Basic
/TCGA/GetGeneForBoxplot.py
UTF-8
1,998
2.828125
3
[]
no_license
#!/usr/bin/env python2 import os import sys import re import argparse import numpy as np import pandas as pd def ReadData(file_in): pd_data = pd.read_csv(file_in, sep='\t', header=0, index_col=0) return pd_data def ReadClass(file_in): pd_data = pd.read_csv(file_in, sep='\t', names=['Class',], index_col...
true
0c07830d8bf994ae2814983db8d4d548c6b632ce
Python
filmackay/flypy
/flypy/tests/test_calls.py
UTF-8
766
2.78125
3
[ "BSD-2-Clause" ]
permissive
# -*- coding: utf-8 -*- from __future__ import print_function, division, absolute_import import unittest from flypy import jit class TestCalls(unittest.TestCase): def test_static_call(self): @jit def g(a): return a + 2 @jit def f(a): return g(a * 3) ...
true
14c87f67ded6479246946cf09fd925f5df404d06
Python
cpoulet/N-Puzzle
/astar.py
UTF-8
3,248
2.84375
3
[]
no_license
############################################################################### # _ _ _____ _ _ _____________ ______ # # | \ | | | __ \| | | |___ /___ / | | ____| # # | \| |______| |__) | | | | / / / /| | | |__ # ...
true
5341231df45c165ae9b7683f329460c7f5012ee1
Python
george1459/NLP-win-21
/idea_relations/fighting_lexicon.py
UTF-8
3,640
2.890625
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- import os import json import math import collections import functools import numpy as np import word_count as wc import utils def get_uniform_alpha(first, second, count=1.0): word_set = set(first.keys()) | set(second.keys()) alpha = dict([(w, count) for w in word_set]) return alpha...
true
f66efc6a3bfc86b4b08f245b42a6879c277d6997
Python
snaprick/PP2_20BD
/Final/W.py
UTF-8
85
2.6875
3
[]
no_license
d = {"SUN": 7,"MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1} print(d[input()])
true
16aed9d6c426cc3215e73e1f6bceda0588ba367e
Python
lavanyachitra/a
/special.py
UTF-8
136
3.671875
4
[]
no_license
string=input() n=0 for j in range(len(string)): if(string[j].isdigit()!=True and string[j].isalpha()!=True): n=n+1 print(n)
true
d78be860dd610ed026802a5db4fc1165d8702d18
Python
48cfu/CarND-Advanced-Lane-Lines
/source/lane_detection.py
UTF-8
12,423
3
3
[ "MIT" ]
permissive
# Define a class to represent the camera import numpy as np import cv2 import glob import matplotlib import matplotlib.pyplot as plt from camera import Camera from line import Line class LaneDetection(): def __init__(self): ''' Configuration parameters for each frame: tuned in main_images.py ...
true
c709b24faa08f9393f0fd80dc5f817842bbca894
Python
carl-phillips/PythonModule4
/venv/input_validation/validation_with_try.py
UTF-8
574
3.78125
4
[]
no_license
def average(score1, score2, score3): NUMBER_TESTS = 3 try: if score1 < 0 or score2 < 0 or score3 < 0: raise ValueError avg = (int(score1) + int(score2) + int(score3)) / NUMBER_TESTS except: raise ValueError print(str(avg)); return avg if __name__ == "__main__":...
true
001d842921d97d707a1cf987ac661bc9a180d3b0
Python
ternovandarius/FLCD
/Lab 4/main.py
UTF-8
3,673
3.296875
3
[]
no_license
import re class SymbolTable: def __init__(self, capacity): self.__capacity = capacity self.__symbols = [""] * capacity def hash(self, key): hashval = 0 j = 1 for i in key: hashval += ord(i) * j j = j*10 return hashval % self.__capacity ...
true
fb4d678df7ed0bb7ea32b1a98e12adf9c03af079
Python
zhzhussupovkz/pygraph
/graph/node.py
UTF-8
608
3.234375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- # node realization class Node(object): # create node with key and props def __init__(self, key): self.deg = 0 self.key = key self.neighbors = set() def __eq__(self, other): if isinstance(other, self.__class__): return other.key == self.k...
true