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
bd8ebf4bacc7a106627fbca4cc2b20c05d3cbc7d
cassidyhere/Code
/spider/Engine.py
UTF-8
2,894
3.25
3
[]
no_license
''' Engine与其子类负责具体的页面抓取. Engine的子类需要实现run方法,其工作流程为: 1.当满足条件时,从TODO表取出一个url 2.抓取url对应页面内容,抓取成功则将返回的response对象交给Spider的parse_response方法处理 3.将该url添加到Visited表 ''' import requests import threading from spider.Vector import TODO, Visited class Engine: '''Engine完成一些初始化工作 初始化工作包括TODO表与Visited表,将Spider类中的urls添加至TODO...
true
78eb8da649a463496b06f63899df57676339028a
AdityaBurugu/My_Python_Basic_Programs
/Tuples/Tuples.py
UTF-8
882
4.5625
5
[]
no_license
###Learning the Concepts of Tuples #Creating a Tuple Numbers = (21,36,14,23,23) print('Numbers :',Numbers) #Accessing Values in Tuple #Accessing only element from the Numbers Tuple print('Output :',Numbers[1]) #Accessing Multiple Values at a time from the Numbers Tuple print('Output :',Numbers[1:]) #Accessing a value i...
true
d0bdaf6edd585a5d564386bc0fbd83212dd95fe1
Remmeauth/block-producer-calculator-back
/tests/domain/test_reward.py
UTF-8
2,419
2.671875
3
[ "MIT" ]
permissive
""" Provide tests for reward. """ from calculator.domain.block import ( BlockProducer, BlockReward, ) from calculator.domain.economy import Economy from calculator.domain.reward import ( ActiveBlockProducerReward, BlockProducerReward, ) def test_get_block_producer_reward(): """ Case: get block...
true
8666e071927ea7d1b0197388add47612d3af5f37
edhom/aws-workflow
/inputfiles/inputCreator.py
UTF-8
602
2.703125
3
[]
no_license
import random import json import sys request = { "A": { "x": 23, "y": 1 }, "B": { "x": 30, "y": 5 }, "Profit": '', "Overhead": '', "OverheadInTime": '', "OptimalPickUp": { "x": '', "y": '', "inMinutes": '', } } for i in range (int(sys.argv[1])): request['A']['x'] = ra...
true
69184fd74bb7cb568b9e37aac53b4ee5e1e90c27
DemoAuguste/Flint-Implementation
/flint/custom_sampler.py
UTF-8
835
2.984375
3
[]
no_license
from torch.utils.data.sampler import Sampler, BatchSampler import torch import numpy as np class CustomSampler(Sampler): """ Customed sampler. Given a sequence, return sub-sequence by batch. """ def __init__(self, data_source, batch_size, shuffle=False): # data_source: a list of indices. ...
true
a2ac616a7ef48df559bab81a6bf26d1f62469703
FrankFang0813/TOPIC
/104_connect_mongodb.py
UTF-8
1,614
2.921875
3
[]
no_license
import pymongo from pymongo import MongoClient import json import os # 開啟json檔 def open_json_file(CACHE_FNAME): try: cache_file = open('./data/'+CACHE_FNAME, 'r') cache_contents = cache_file.read() # print(type(cache_contents)) CACHE_DICTION = json.loads(cache_conte...
true
94700fca8274c1e7c9573f25a4e8db8ad7ea1066
WolfeCub/GameOfLife
/GameOfLife.py
UTF-8
1,224
3.578125
4
[]
no_license
# -*- coding: utf-8 -*- import time import copy def main(): grid = [[0 for i in range(50)] for j in range(50)] grid[1][2] = 1 grid[2][3] = 1 grid[3][1] = 1 grid[3][2] = 1 grid[3][3] = 1 while True: display(grid) grid = check(grid) time.sleep(0.7) print() ...
true
7d741fd24117fc60c8104ca118b611eb95a8cf3d
asqqwwd/Jamming
/tests/test_kws.py
UTF-8
3,497
2.515625
3
[]
no_license
import os, time, wave from pocketsphinx import * # def run(): # def A(a,b): # print(a,b) # p = {"a":1,"b":2} # A(**p) # def run(): # model_path = get_model_path() # data_path = get_data_path() # # Create a decoder with a certain model # config = DefaultConfig() # config.set_st...
true
049ba12798874731c19391cce4bb09825ef608fb
nandazman/Project-Euler
/nandazman/1 Multiple of 3 And 5/solution.py
UTF-8
516
3.703125
4
[]
no_license
import math def multiplesOf3and5(number): number = number - 1 # sum = 1/2 n(n+1) # sum of 1,3,4,5, ... , n + 1 # math.floor(number / 3) to get how many iteration (n) sumOfMultiple3 = 3 * math.floor(number / 3) * (math.floor(number / 3) + 1) / 2 sumOfMultiple5 = 5 * math.floor(number / 5) * (math.floor(numb...
true
f65222af473324ee0a4b97163d5736ca799c43ef
Julien-B-py/Space-Invaders
/player.py
UTF-8
2,125
3.21875
3
[]
no_license
import pygame from config import SCREEN from projectile import Projectile class Player: def __init__(self, explosions_grp: pygame.sprite.Group, sound, aliens): self.image = pygame.image.load("img/sprites/player.png") self.image = pygame.transform.scale(self.image, (self.image.get_width() // 4, s...
true
89d41b62b410bca18d75c8dde6f9c80f9438f7ec
MicaeTr/HackerNewsAPIVisualization
/hn_submissions.py
UTF-8
1,259
3.0625
3
[]
no_license
from operator import itemgetter import requests def get_popular_hn_articles(): """A function that retrieves the most popular Hacker News articles on the website""" # Make an API call and store the response url = 'https://hacker-news.firebaseio.com/v0/topstories.json' r = requests.get(ur...
true
cb72e38e1994d99055bd698f800d461f8ea2ec12
bvsbrk/Algos
/src/Codeforces/round_458_and_codecraft/A.py
UTF-8
270
2.90625
3
[]
no_license
def ps(n): return n ** 0.5 == int(n ** 0.5) if __name__ == '__main__': n = int(input().strip()) ar = [int(i) for i in input().strip().split()] ar.sort(reverse=True) for i in ar: if i < 0 or not ps(i): print(i) break
true
47ba976065803aa8102561c6c88e2a013c867e63
andysai/python
/黑马程序员-python/python从0开始学编程/day03/20-if章节总结.py
UTF-8
610
3.546875
4
[]
no_license
""" if 语句语法 if 条件: 条件成立执行的代码 if...else... if 条件: 条件成立执行的代码 else: 条件不成立执行的代码 多重判断 if 条件1: 条件1成立执行的代码 elif 条件2: 条件2成立执行的代码 else: 以上条件都不成立执行的代码 if嵌套 if 条件1: 条件1成立执行的代码 if 条件2: 条件2成立执行的代码 ... 三目运算符 条件...
true
4e5c25f08cc841246b580e733b925e1f315a79cc
daniel-reich/ubiquitous-fiesta
/n4JA3je7FEFfZKaWp_14.py
UTF-8
163
2.765625
3
[]
no_license
def million_in_month(m, mu): # goal = 10**6 or 1000000 s = m * mu c = 1 while s <= 1000000: m *= mu s += m c += 1 return c
true
8423bc60774cc0546456bfb0b2fa5fad44431b3f
DlyanRutter/Seattle-Weather-
/seattle_weather_classifiers.py
UTF-8
2,737
2.734375
3
[]
no_license
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import warnings from sklearn.metrics import accuracy_score, log_loss from sklearn.neighbors import KNeighborsClassifier from sklearn.svm import SVC, LinearSVC, NuSVC from sklearn.tree import DecisionTreeClassifier from sklearn...
true
dbae5df17c4273347bc65d56be6b27342b710382
lilium513/competition_programing
/119ABC/c.py
UTF-8
402
2.9375
3
[]
no_license
import math N,A,B,C = list(map(int,input().split(" "))) ls = [] for i in range(N): ls.append(int(input())) def fun(rec,a,b,c): if rec == N: return abs(A-a) + abs(B-b) + abs(C-c)-30 if a*b*c != 0 else 10e20 ans = [fun(rec + 1 ,a,b,c) , fun(rec + 1 ,a+ls[rec],b,c) + 10 ,fun(rec + 1 ,a,b+ls[rec],c)...
true
b25667f13a3168faf9cf9a0d970fa83175102fc7
geekyarthurs/iws_assignments
/assignment1/q17.py
UTF-8
148
2.90625
3
[]
no_license
from typing import List def product(items: List[int]) -> int: prod = 1 for i in items: prod *= i return prod #OR use reduce.
true
64d43a0a997ba115f5f21b96f80c09edac46e34f
rajivanisetti/dono
/data/classifiers.py
UTF-8
3,851
3.09375
3
[]
no_license
import numpy as np import pandas as pd from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import KFold from sklearn.preprocessing import StandardScaler from sklearn.neural_network import MLPClassifier from sklearn.tree import DecisionTr...
true
1afc67279320bc476996bfd9a5220d96e50acafe
Consolate/Challenge-three-week-four-
/cli.py
UTF-8
1,196
3.109375
3
[]
no_license
import click import requests apikey= 'ced42af865c5482aa78652be689b4af0' # four news sources def newsFromBBC(): #news from bbc main_url = " https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=ced42af865c5482aa78652be689b4af0" #main_url = "https://newsapi.org/v2/top-headlines?source...
true
e0c792db934473352c5180a212c8385cca876302
jadnohra/connect
/ddq/fol/semantics/types.py
UTF-8
582
2.953125
3
[ "Unlicense" ]
permissive
from typing import Union class Type: pass class Term(Type): pass class Formula(Type): pass class TermTuple(Type): def __init__(self, arity: int): self._arity = arity def arity(self) -> int: return self._arity class FunctionalType: def __init__(self, to...
true
68604a6a7d8dc6e24b8e589f15a9ed9eef6d320f
RicardoBernal72/CYPRicardoBS
/libro/ejemplo1_14.py
UTF-8
77
2.875
3
[]
no_license
NUM=int(input("un numero entero") CUA = NUM*NUM CUB = NUM**3 print(CUA, CUB)
true
b6e0390b9973d43b7b3dec5a009c7e773a79225b
quaz4/A-Star
/NodeManager.py
UTF-8
2,461
3.109375
3
[]
no_license
import random import os import glob from GraphNode import GraphNode class NodeManager(): """A* search object""" def __init__(self): self.LIMIT = 10 self.graphNodesCount = 0 self.loadedNodes = [] self.treeCount = 0 self.frontierCount = 0 self.frontier = [] def generateGraph(self, graphFil...
true
e10b68c1def16c5231fc3a541ff5b8dff0695756
mkowoods/zipcode_webapp
/zipcode_webapp.py
UTF-8
3,911
2.671875
3
[]
no_license
# -*- conding: utf-8 -*- from flask import Flask, render_template, request, Response import requests import json import sqlite3 CONN = sqlite3.connect("us_zip.db", check_same_thread=False) app = Flask(__name__) class NoResultsFound(Exception): pass class Inventory: def __init__(self): self._data =...
true
3ec488d4dbce4951956ccbe867872203005cd1c8
daniel-reich/turbo-robot
/CzrTZKEdfHTvhRphg_9.py
UTF-8
1,688
4.15625
4
[]
no_license
""" Create a function that takes a string representing a fraction, and return a string representing that input as a mixed number. * Mixed numbers are of the form `1 2/3` — note the space between the whole number portion and the fraction portion. * Resulting fractions should be fully reduced (see example #2). ...
true
173d88ada3cf75ad8473d0db14448bdf0dd225ff
rocky/python-control-flow
/pytest/test_bb.py
UTF-8
1,215
2.828125
3
[]
no_license
"""Test control_flow.bb: basic blocks and basd-block management""" from control_flow.bb import basic_blocks, BB_ENTRY, BB_EXIT, BB_RETURN from example_fns import two_basic_blocks, if_else_blocks debug = False if debug: import dis def check_blocks(bb_list: list): assert ( len(bb_list) >= 2 ), "min...
true
f5b70592ebdd0db6a41737ce8a09121dd6ba6751
itkasumy/PythonGrammer
/day05/03-if-elif语句.py
UTF-8
293
3.171875
3
[]
no_license
age = 18 if age >= 18: print("欢迎光临,可以上网...") elif age >= 17: print("您过两天再来就可以上网了...") elif age >= 12: print("您稍微存两年钱,就可以来上网了...") else: print("滚犊子,再不滚我叫你妈来了...") print("over...")
true
f9edbfe34d8d96557bedbc12466d11bc79e45fd3
pablogugarcia/scripts-py
/JPGtoPNGconverter.py
UTF-8
466
2.96875
3
[]
no_license
import sys import os from PIL import Image if not len(sys.argv) == 3: print('Es necesario ingresar origen y destino') exit() images_folder = sys.argv[1] output_folder = sys.argv[2] if not os.path.exists(output_folder): os.makedirs(output_folder) for filename in os.listdir(images_folder): img = Imag...
true
42c482992064c135e185926f6dbeb796676fd75e
DilyanTsenkov/SoftUni-Software-Engineering
/Python Fundamentals/Final exam/03_battle_manager.py
UTF-8
2,081
3.1875
3
[]
no_license
records = {} people = 0 while True: line = input() if line == "Results": break line = line.split(":") action = line[0] if action == "Add": name = line[1] health = int(line[2]) energy = int(line[3]) found = False for key in records.keys...
true
e78250b506a35a9857c26d41891f8d1e96c7d0b9
dungruoc/GeeksforGeeks
/Basic/DisariumNumber.py
UTF-8
1,090
4.34375
4
[]
no_license
# -*- coding: utf-8 -*- """ Given a number “n”, find if it is Disarium or not. A number is called Disarium if sum of its digits powered with their respective positions is equal to the number itself. Input: The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. ...
true
2329e14d8d1b6d832f69a501391bde6f0040572f
Jingli-Tao/Image_Analogy
/main.py
UTF-8
4,299
2.703125
3
[]
no_license
import cv2 import numpy as np import os import errno from os import path from glob import glob from preprocess import YIQ2BGR, preprocessImages, cropOneImage from pyramid import gaussPyramid, gaussPyramid_init, compute_L from feature_space import feature_space_concat from match import MatcherInit, BestMatch def creat...
true
103ce8aef658e8227125c507d03154127744324f
ophw2020f-team1/awesome-catapult
/server/app.py
UTF-8
1,246
2.84375
3
[]
no_license
from flask import Flask import flask import os app = Flask(__name__) class Channel: def __init__(self, channelPath) -> None: super().__init__() self.channelPath = channelPath def read(self): res = '' with open(self.channelPath, 'r') as file: res = file.read() ...
true
2597eeeff6cc4de686232e7ca2d94498eb233421
jamesliang91/data_processing_tools
/stock_data.py
UTF-8
19,839
2.90625
3
[ "Apache-2.0" ]
permissive
import os import time import numpy as np import datetime as dt class stock_tick (object): def __init__(self, EpochTime, MDStreamID, TimeStamp, ExchangeID, InstrumentID, PreClosePrice, OpenPrice, ClosePrice, HighPrice, LowPrice, LastPrice, TradeCount, TotalTradeVolume, TotalTradeValue, ...
true
873dbac4b233e999c03aedb08d613d1d4d89fb3c
bmlegge/CTI110
/P4HW3_Factorial_Legge.py
UTF-8
223
4.15625
4
[]
no_license
#CTI-110 #P4HW3: Factorial #Bradley Legge #3/25/2018 print("Enter a nonnegative integer: ") num = int(input()) fact = 1 for i in range(1, num + 1): fact = fact * i print("The factorial of ", num, "is: ", fact)
true
9960a56eeafc1a52644609954eb808be077193fa
jturmel/twinturbo
/search.py
UTF-8
2,209
3.578125
4
[]
no_license
from abc import ABCMeta from abc import abstractmethod from google.appengine.api import search class TokenFilter(object): __metaclass__ = ABCMeta @abstractmethod def create(self, token_string): return token_string class EdgeNGramTokenFilter(TokenFilter): def __init__(self, min_gram_size=1...
true
1f4a7f69fafe6b778c99e95965debe65aaaee864
johnhw/blender_knots
/knot_plugin.py
UTF-8
17,692
2.703125
3
[ "MIT" ]
permissive
bl_info = { "name": "Knot generator", "description": """Creates 3D meshes of knots from simple ASCII art descriptions.""", "author": "John H. Williamson", "version": (0, 0, 1), "blender": (2, 7, 0), "location": "3D View > Tools", "warning": "", # used for warning icon and text in addons pane...
true
60e883f5e7d07152bb042910cb27ae86a2a6c3e4
jdthorne/sublime-config
/User/ViewNavigation.py
UTF-8
929
2.625
3
[]
no_license
import sublime, sublime_plugin history = [] forwardHistory = [] class ViewNavigation(sublime_plugin.TextCommand): def run(self, edit, direction): global history global forwardHistory file = self.view.file_name() if direction == "back": forwardHistory.append(file) while (...
true
c28f4ecf4d52c062442b9e8e8db5ad28cc0f5d4f
rachitmanchanda/male_female_beginner
/m_f.py
UTF-8
648
3.25
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Wed Mar 18 14:26:53 2020 @author: Rachit """ from sklearn import tree #[height,weight,shoe_size] X = [[181, 80, 44], [177, 70, 43], [160, 60, 38], [154, 54, 37], [166, 65, 40], [190, 90, 47], [175, 64, 39], [177, 70, 40], [159, 55, 37], [171, 75, 42], [181, 85, 43]] ...
true
5b55a4186171600801203bceab2d1c25086352af
reenadangi/python
/python_stack/Algos/list_comprehension/interview3.py
UTF-8
1,069
3.890625
4
[]
no_license
# LIST COMPREHENSIONS # 1. return a list of numbers between (1-100) # 2. List - I want n for each n in nums[1,2,3,4,5,6,7,8,9,10] -(even/odd) # 3. NESTED FOR LOOPS I want (letter,num) pair for each letter in ('abcd') and each num in(0123) # 4. List of dictionary- return list of brand and models for year>2000 # cars=[ ...
true
350e432eebad22cd4fcefa9e23fc61a2789b7947
Zapadlo13/Algorithms_and_data-_tructures_in_Python
/Lesson-2/Task-7.py
UTF-8
597
4.1875
4
[]
no_license
# 7. Напишите программу, доказывающую или проверяющую, # что для множества натуральных чисел выполняется равенство: 1+2+...+n = n(n+1)/2, где n - любое натуральное число. n = int(input('Введите n: ')) sum = 0 for i in range(n + 1): sum += i rezult = n * (n + 1) / 2 print(f'Сумма чисел:{sum}, результат формулы: ...
true
4e0b1bb195ef642d72c2405f49f3ce342712b93a
PaddlePaddle/PaddleTest
/models/PaddleHub/hub_all_func/test_senta_cnn.py
UTF-8
884
2.640625
3
[]
no_license
"""senta_cnnsenta_cnn""" import os import paddlehub as hub import paddle if paddle.is_compiled_with_cuda(): paddle.set_device("gpu") use_gpu = True else: paddle.set_device("cpu") use_gpu = False def test_senta_cnn_predict(): """senta_cnn predict""" os.system("hub install senta_cnn") senta...
true
1cae1561233e0a26910dd36dcb0020d3bfd34b60
cash2one/shuzhai
/snowLNP.py
UTF-8
899
3.28125
3
[]
no_license
#!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'vincentnewpro' from snownlp import SnowNLP def getKeyWords(text,keyWordsNum): s = SnowNLP(text) return s.keywords(keyWordsNum) text = u'''自然语言处理是计算机科学领域与人工智能领域中的一个重要方向。 它研究能实现人与计算机之间用自然语言进行有效通信的各种理论和方法。 自然语言处理是一门融语言学、计算机科学、数学于一体的科学。 因此,这一领域的研究将涉及自然...
true
1f925a810e14d1dc8289e2a23caef779064f61de
koike-ya/research
/weather/zip2weather.py
UTF-8
8,578
2.828125
3
[]
no_license
import sys import time from datetime import timedelta from pathlib import Path import pandas as pd import requests from JmaScraper import JmaScraper from bs4 import BeautifulSoup def access_site(url): # スクレイピング先のサーバーに負荷がかかりすぎないよう、0.5秒おく time.sleep(0.5) html = requests.get(url).content soup = Beautifu...
true
1365de1f5f5518797af961c78f164cc5a8a0f4c8
DaHuO/Supergraph
/codes/CodeJamCrawler/CJ/16_0_4_ashuwp_frac.py
UTF-8
526
3.46875
3
[]
no_license
def fractiles(x, y, z): if x == 1: return 1 if y == 1: if x > z: return 'IMPOSSIBLE' else: return ' '.join(str(v) for v in range(1, x + 1)) if z <= x - 2: return 'IMPOSSIBLE' else: return ' '.join(str(v) for v in range(2, x +...
true
a7650a7bda1a18ce98673d049a9ccc3257df4293
rishinkaku/Software-University---Software-Engineering
/Python_Advanced/Lists as Stacks and Queues/05. Truck Tour/Truck Tour.py
UTF-8
730
3.421875
3
[]
no_license
from collections import deque number_of_pumps = int(input()) stops = deque() truck_fuel = 0 fuel_station = [] for _ in range(number_of_pumps): data = input() stops.append(data) fuel_station.append(data) flag = False while not flag: for station in stops: fuel = int(station.split()[0]) tr...
true
8c44b10983065576b85311fc8757ab2cf7ada5cc
minhhien2112/MacroVirus
/obfuscate.py
UTF-8
945
3.390625
3
[]
no_license
def chrchar(s): res = '' l = len(s) for i in range(0,l): res += 'ChrW(' + str(ord(s[i])) + ') & ' res = res[:-3] return res def Addvariable(k): p = "" if (k==0): return p p += " Dim " + chr(k) + " As String\n" return p def split(s,l): ...
true
2256968035d0bd04ce837e8f076f7f9d4a8d6545
daniel-reich/ubiquitous-fiesta
/FSRLWWcvPRRdnuDpv_15.py
UTF-8
1,528
3.46875
3
[]
no_license
import math def round_half_up(n, decimals=0): multiplier = 10 ** decimals return math.floor(n*multiplier + 0.5) / multiplier ​ def mil_time_func(hour, AM_PM): if AM_PM == 'a.m.': hour = hour else: hour = hour + 12 return hour ​ ​ def min_in_decimals(minute): if minute == 0: ...
true
f4154b50af28ed2079456238a9d5ac0dd3dc0968
wangduizhang/myex
/ex25.py
UTF-8
955
3.734375
4
[]
no_license
#_*_coding:utf-8 #麦乐鸡 def McNuggets(n): r = False for a in range(0,11): for b in range(0,11): for c in range(0,11): if 6 * a + 9 * b + 20 * c == int(n): r = True return r print McNuggets(220) #代码改错 def fixedPoint(f, epsilon): """ f: a function of one argument that returns a float epsi...
true
605fd7385fd77fd18b1a0bc9cdad688c94d080d9
jjsync/CheckPoint_API_Utilities
/ping_host_objects.py
UTF-8
5,511
2.90625
3
[]
no_license
# # ping_hosts.py # version 1.2 # # Purpose: Pings IP address of all Check Point Management Server host objects and prints results to csv file # Author: Joshua J. Smith (JJSYNC) # Writen: October 2018 # Updated: January 2019 # A package for reading passwords without displaying them on the console. from __future__ impo...
true
ffc140e9b3aa44c8b9bffb4e92ff0bbb719a6689
chenyk1990/useful-utilities
/projects/ipython/1508_Mapping_and_validating_lineaments.py
UTF-8
18,582
2.59375
3
[]
no_license
#https://github.com/seg/tutorials/blob/master/1508_Mapping_and_validating_lineaments/1508_Mapping_and_validating_lineaments.ipynb import numpy as np import scipy as sp from fatiando.gravmag import transform import matplotlib.pyplot as plt import matplotlib.cm as cm import matplotlib.colors as clr from pylab import im...
true
f231cfa0c60353d92f68346b38fc25a168bdaac3
Arxcis/ProgMatteKompendium
/docs/Ymse/maze.py
UTF-8
2,183
3.484375
3
[]
no_license
import numpy as np import numpy.linalg from random import * # # Adds doors in the maze graph # def addDoor(s1,s2,M): M[s1][s2] = 1 M[s2][s1] = 1 # # M is the matrix of a graph # after calling M is an associated Markov Chain and N contains numer of doors # for each state # def createMarkov(...
true
f71c51e028eca15a4a67bad18653e4c05cb6cf44
MarceloDL-A/Python
/15-Statistics_with_NumPy/Introduction_to_NumPy/Creating_an_Array_from_a_CSV.py
WINDOWS-1252
866
4.28125
4
[]
no_license
""" INTRODUCTION TO NUMPY Creating an Array from a CSV Typically, you wont be entering data directly into an array. Instead, youll be importing the data from somewhere else. Were able to transform CSV (comma-separated values) files into arrays using the np.genfromtxt() function: Consider the following CSV, sample.csv...
true
9d6212dc42aaa566872a2490305ce0f51c3c776a
KKTIII/POS
/admin/admin.py
UTF-8
25,095
2.515625
3
[]
no_license
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.textinput import TextInput from kivy.uix.button import Button from kivy.uix.label import Label from kivy.uix.spinner import Spinner from kivy.uix.popup import Popup from kivy.lang import Builder from collections import OrderedDict ...
true
d8fca2a823296991304f3e7a6e64f914f4de22b3
danimrprofe/apuntes-infote
/18. Programacion estructurada/pong/pong1.py
UTF-8
887
3.515625
4
[]
no_license
# pong_1.py: Ventana de juego import pygame from pygame.locals import * # Constantes para la inicialización de la superficie de dibujo VENTANA_HORI = 800 # Ancho de la ventana VENTANA_VERT = 600 # Alto de la ventana FPS = 60 # Fotogramas por segundo BLANCO = (255, 255, 255) # Color del fondo de la ventana (RGB) ...
true
42ae1bd4f0e7fd625c1728bf4197dfd4ec80e844
KongChan1988/51CTO-Treasure
/Python_Study/第二模块学习/Day01/Practice Notes/ATM/modules/authentication.py
UTF-8
4,608
2.640625
3
[]
no_license
#-*- Coding:utf-8 -*- # Author: D.Gray import os,json BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) '''数据库文件相对路径''' __db_users_dict = BASE_DIR + r"\database\users_dict" __db_creditcard_dict = BASE_DIR + r"\database\creditcard_dict" '''认证装饰器''' def auth(auth_type): def outer_wrapper(func)...
true
f87b04e90e243112f9c7e38c3d4d1df99dd20a84
GabrielDalrymple/Lab-4-Recursion
/Lab 4 - Recursion/point.py
UTF-8
246
3.171875
3
[]
no_license
class point: def __init__(self, x = 0, y = 0): self.__x = x self.__y = y def getX(self): return self.__x def getY(self): return self.__y def setX(self, x): self.__x = x return True def setY(self, y): self.__y = y return True
true
3259c9263c56ee217d19f58549c5b068a7459d99
elejke/hack2020
/src/dpipe_metrics.py
UTF-8
7,951
2.734375
3
[]
no_license
import numpy as np from functools import wraps, partial from typing import Callable, Sequence, Iterable import numpy as np from scipy.ndimage import center_of_mass # --- checks from scipy.ndimage import distance_transform_edt, binary_erosion def extract(sequence: Sequence, indices: Iterable): """Extract ``indic...
true
937775abce4a2feda6a7814045bd3f77f68a6b68
RickUniverse/Python
/02_分/hm_02_and-or-not.py
UTF-8
126
3.265625
3
[]
no_license
# and && if True and False: print("and") # or || if True or False: print("or") # not ! if not False: print("not")
true
7b01764cc7d92b5b9d867410bd642ce357231067
vbukovska/SoftUni
/Python_fundamentals/Lists_basics/FaroShuffle.py
UTF-8
276
3.28125
3
[]
no_license
cards = input().split(' ') times = int(input()) for time in range(times): shuffled_list = [] for i in range(0, (len(cards) // 2)): shuffled_list.append(cards[i]) shuffled_list.append(cards[len(cards) // 2 + i]) cards = shuffled_list print(cards)
true
8f9d6a2f3c05295bb17ad8b9eada2ccaafa38814
16460117/automatas2
/Ejercicio 3.py
UTF-8
456
4.09375
4
[]
no_license
""" Autor: Carbajal Ramos Juan Jesús Fecha: 04/07/19 """ #Realice un programa en Python que dado como datos los sueldos de 10 trabajadores de una empresa, #obtenga el total de nómina de la misma. Puede utilizar un ciclo for o un ciclo while. def main(): st = 0.0 for i in range(0, 10): print('Sueldo',...
true
6b280e8edb3cb0d4f26217c8bd34bb7a5057dfdd
watsotc1/email_domain_check
/scripts.py
UTF-8
937
3.328125
3
[]
no_license
import numpy as np def Levenshtein_Analysis(string1, string2): dist = np.zeros((len(string1) + 1, len(string2) + 1)) for t1 in range(len(string1) + 1): dist[t1][0] = t1 for t2 in range(len(string2) + 1): dist[0][t2] = t2 a = 0 b = 0 c = 0 for t...
true
bd68d139467e59df9f47967d960824e05374af07
htczero/PyTorch_Study
/Other/Load_Data_and_Processing/Data_Loading_and_Processing.py
UTF-8
9,480
3.0625
3
[]
no_license
# -*- coding:utf-8 -*- ''' pytorch 0.4.0 data: https://download.pytorch.org/tutorial/faces.zip tutorials: https://pytorch.org/tutorials/beginner/data_loading_tutorial.html ''' from __future__ import print_function, division import os import torch import pandas as pd # 用于解析csv文件 from skimage import io, transform # 用...
true
0a1e560943ebeb1ae2b77920d84f466e626becca
Aivree/SnippetMatcher
/main/PythonResults/_pythonSnippet15/83/ArrayRange10.py
UTF-8
113
3.109375
3
[]
no_license
import numpy as np npA = np.arange(1, 10000001, 1) print 'AMount of numbers in array: {:,}'.format(npA.size)
true
88f8e6a1fff7dd02f237051271a4705182de5fa6
vuhonganh/coding_interview
/LeetCode/python/longest_substring_no_repeat.py
UTF-8
1,062
3.59375
4
[]
no_license
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ max_len = 0 cur_queue = [] for c in s: if c in cur_queue: idx_dup = cur_queue.index(c) cur_queue = cur_...
true
6eebecf9dc7f10e9f25c61242ed52660b26937d0
fcarsten/tic-tac-toe
/tic_tac_toe/TFSessionManager.py
UTF-8
1,444
3.203125
3
[ "Apache-2.0" ]
permissive
import tensorflow as tf class TFSessionManager: """ Class to manage the TensorFlow session for all NN based players. Since it seems best to just have a single TensorFlow session which is shared by all players, this class is used to manage that one sessions. In order for this to work, all players...
true
dc8c0cf409b3f01918f479f5d88c7f7410577a0a
JScones/agilefant-timesheet-parser
/timesheet-parser.py
UTF-8
8,324
3.046875
3
[]
no_license
#!/usr/bin/python3 import re import sys from os.path import join, dirname, abspath from collections import defaultdict import xlrd valid_tags = {"implement", "document", "test", "testmanual", "fix", "chore", "refactor"} commitless_tags = {'commits', 'chore', 'document', 'testmanual'} required_columns = {"Story", "Co...
true
21a00e4ccde6e5ffe8612089d833b30d1bb6306e
manubr99/LMSGI
/XML Y PYTHON/provincias5.py
UTF-8
323
2.640625
3
[]
no_license
from lxml import etree doc = etree.parse('provinciasypoblaciones.xml') poblacion = input("Seleccione un municipio: ") provincias=doc.findall("provincia") for provincia in provincias: localidades=provincia[1].findall("localidad") for localidad in localidades: if localidad.text == poblacion: print (provincia[0].te...
true
58cd18d4914847cae95b3707fc51de24bd1e6362
Junaid199f/Pashto-POS-Tagging-Project
/Pashto POS Tagger/convert_vectors_to_pkl.py
UTF-8
890
3.0625
3
[]
no_license
import os import pickle import numpy as np import chardet ''' This script converts the specified Glove file into a pickled dict ''' def find_encoding(fname): r_file = open(fname, 'rb').read() result = chardet.detect(r_file) charenc = result['encoding'] return charenc embeddings_index = {} textencoding...
true
5048ca6478200ca4e862f12f5d9a105ce2f58848
charalambos02/Indoor-Navigation
/Code Base/2 Model Evaluation/evaulating_simple_knn.py
UTF-8
4,351
2.59375
3
[]
no_license
from numpy import * from pandas import DataFrame import mysql.connector import pandas as pd import time from matplotlib import pyplot as plt from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix, precision_score, recall_sco...
true
6672e2dd621c837079e5c6a54efa17179208a3f0
mattlgibbs/depoy
/apps/login_app/models.py
UTF-8
2,270
2.5625
3
[]
no_license
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models #import models for... import re #import regex for verification import bcrypt class UserManager(models.Manager): def regVal(self, PostData): results = {"status": True, 'errors': []} if len(PostData['first_na...
true
1123a1053d96f255e94d51ac2e539b0849af3dd3
lunabox/leetcode
/python/problems/s113_Path_Sum_II.py
UTF-8
773
3
3
[ "Apache-2.0" ]
permissive
class Solution(object): def pathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: List[List[int]] """ result = [] def search(r, s, line): if r is None: return None if r.left is None and r.right is No...
true
737ddf1034fda89ee45ec1d8291b4833af3f3cfe
Aasthaengg/IBMdataset
/Python_codes/p03107/s017628520.py
UTF-8
622
2.84375
3
[]
no_license
#!/usr/bin/env python3 import sys def solve(S: str): stack = [-1] for c in map(int, S): if stack[-1] + c == 1: stack.pop() continue stack.append(c) return len(S)-len(stack)+1 # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools def main(): def i...
true
4cab51f6629eafc6ee8e233c58fd14b85e877a71
fengxia41103/myblog
/content/downloads/euler/p30.py
UTF-8
240
2.921875
3
[]
no_license
# -*- coding: utf-8 -*- """ """ def main(): result = 0 for i in range(2, 199999): tmp = sum(int(x) ** 5 for x in str(i)) if tmp == i: result += i print result if __name__ == '__main__': main()
true
63b75284e7d634656ab19b67e187c4e41c9ee5c0
two4suited/python-unittesting
/tests/mathclasstest.py
UTF-8
223
3.140625
3
[]
no_license
import unittest from cut.mathclass import Math class MathTests(unittest.TestCase): def test_add(self): num1 = 2 num2 = 3 math = Math(num1, num2) self.assertEqual(2 + 3, math.add())
true
10dc433836d1a26671819b8c27eb6415d0084779
MinusD/maximum
/СИМ марафона 1/24/24.py
UTF-8
170
3.109375
3
[]
no_license
with open('24.txt', "r") as f: maxi = 0 for i in f: if i.count('F') + i.count('Z') < i.count('A'): maxi = max(maxi, len(i)) print(maxi-1)
true
0ef0e04722661edf700650a4300facc5a8293aae
ohperhaps/Algorithm
/LeetCode/13.Roman to Integer.py
UTF-8
919
3.4375
3
[]
no_license
class Solution: def romanToInt(self, s: str) -> int: def calculate(roman): num, minus = symbol[roman[-1]], -1 if symbol[roman[-1]] > symbol[roman[0]] else 1 for j in roman[:-1]: num += minus * symbol[j] return num s, result = '^' + s + '$', 0 ...
true
402a9f1f83fe4b102f324b122c1cda46accbe06f
sunshiding/CS131
/Homework1/filters.py
UTF-8
5,924
3.78125
4
[]
no_license
import numpy as np def conv_nested(image, kernel): """A naive implementation of convolution filter. This is a naive implementation of convolution using 4 nested for-loops. This function computes convolution of an image with a kernel and outputs the result that has the same shape as the input image. ...
true
d40cf2be38a443c856bb8341b81e6276b65e8031
daiwenlin/SupervisedQueryExpansion
/ExpResultAnalysis/AddGroundTruthToExpTerm.py
UTF-8
688
2.546875
3
[]
no_license
''' Created on Aug 22, 2014 add ground truth data to expansion terms in: expterm +_ ground truth data output: expterm\tlabel score @author: cx ''' import sys if 4 != len(sys.argv): print "3 para: expterm + ground truth terms + output" sys.exit() hScore = {} for line in open(sys.argv[2]): line = line...
true
79d6444b12e5637421f68cc1c84b6049f5e27984
AdamZhouSE/pythonHomework
/Code/CodeRecords/2564/60653/235537.py
UTF-8
922
2.9375
3
[]
no_license
import re; s = [int(n) for n in re.findall(r"\d+", input())] k = int(input()) x = int(input()) a = list([0]*len(s)) res = list([]) for i in range(0, len(s)): a[i] = s[i] - x left = 0 if a.count(0) >= k: res = list([x]*k) elif a.count(0) > 0: res = list([x]*a.count(0)) left = k - a.count(0) else: l...
true
821489d63a4d71b3e27a3c2e8fbd7aef5b102463
plilja/project-euler
/problem_56/powers.py
UTF-8
214
2.921875
3
[ "Apache-2.0" ]
permissive
from common.functions import number_as_digits def powers(a, b): res = 1 for i in range(1, a + 1): for j in range(1, b + 1): res = max(res, sum(number_as_digits(i ** j))) return res
true
96385af390d299cfc3d7937ea273132683da522e
Codestar007/PoP1_ExamPractice
/AllRepos/examples/session-ten/power_sum.py
UTF-8
261
3.453125
3
[]
no_license
def powersum(power, *args): '''Return the sum of each argument raised to the specified power.''' total = 0 for i in args: total += pow(i, power) return total if __name__ == "__main__": assert 25 == powersum(2, 3, 4) assert 100 == powersum(2, 10)
true
6986b2f22c9a622febf88460611728678f74c3e5
Cowa/NLP-Sandbox
/python_tokenizer/tokenizer.py
UTF-8
1,116
2.921875
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 # author: Brice Thomas import os import re import glob import codecs """ Only for \w+ followers Please, join us. """ # Get text files files = glob.glob("txt/*.txt") filesContent = [] # Get all text files' content for file in files: fh = codecs.open(file, "r", "utf-8") file...
true
4b7de27869d92328ca63d85f979931f8a787846e
olarcheveque/auf-fabkit
/auf/fabric/ssl.py
UTF-8
1,037
2.53125
3
[]
no_license
# -*- coding: utf-8 -*- """ Module SSL ========== Module permettant d'installer openssl et de créer des certifcats. """ from fabric.contrib import files from utils import runcmd def install(): """ Installe openssl """ runcmd('apt-get -y install openssl') def create_certificats(project): """ ...
true
e2fd89ddcc2a5229eadc4677ec084352ea217d70
popoffib/IntroductionToPython
/src/m5_your_turtles.py
UTF-8
1,802
3.328125
3
[ "MIT" ]
permissive
""" Your chance to explore Loops and Turtles! Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, their colleagues and Isabella Popoff. """ ######################################################################## # DONE: 1. # On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name...
true
a2886221b6847b787a85b98e30ee85cf4420ad22
stgn/aoc18
/20.py
UTF-8
1,549
3.078125
3
[]
no_license
import fileinput from collections import defaultdict, deque from typing import NamedTuple class Vec2(NamedTuple): x: int = 0 y: int = 0 def __add__(self, other): return Vec2(self.x + other.x, self.y + other.y) class PathNode(NamedTuple): distance: int parent: Vec2 Vec2.CARDINAL = { ...
true
df8d48d153bf4b73c6a9fde26b0855fd06b4fed2
alexpy11/robokids-il
/basic_machine_vision/solutions/4_line_by_loop.py
UTF-8
222
2.90625
3
[]
no_license
import Image, sys, os im = Image.open("32_32_red_dot.bmp") width, height = im.size for i in range(height): x = i; y = i im.putpixel( (x,y), (255,255,255) ) im.show() #x = raw_input("Press Enter")
true
f13c5c04e1dea5d91d6cbc4254853dde4f6b19e9
Ivan-Toropygin/stepik_autotests_course
/scriptsforautomation/2_2_3.py
UTF-8
806
2.90625
3
[]
no_license
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select import time try: browser = webdriver.Chrome() browser.get("http://suninjuly.github.io/selects1.html") num1 = int(browser.find_element_by_css_selector("#num1").text) num2 = int(br...
true
360f8af1d957a2f62242df57f659be81334be809
Aasthaengg/IBMdataset
/Python_codes/p02420/s011116277.py
UTF-8
275
3.53125
4
[]
no_license
def shuffle(str, m): return str[m:] + str[0:m] if __name__ == '__main__': while True: str = input() if str == '-': break m = int(input()) for _ in range(m): str = shuffle(str, int(input())) print(str)
true
29fdd085c20a1fe421116aba5d4d27eaab10848d
kennyouyang/alg
/LeetCode/0978.py
UTF-8
519
2.75
3
[]
no_license
#!/usr/bin/env python3 # -*- coding:utf-8 -*- class Solution: def maxTurbulenceSize(self, A: List[int]) -> int: def cmp(a, b): return 0 if a == b else (-1 if a < b else 1) pre = 0 cur = 0 msize = 1 size = 1 for i in range(1, len(A)): cur = cmp(A[i-1], A[...
true
a7492914b62c6a640a9c1d3ab1a7e1615c18f35e
stefanrsathianathen/AI-Project
/PartA/parta.py
UTF-8
469
3.515625
4
[]
no_license
#Marzuk Amin 824100 #Stefan Sathianathen 868514 import board as b #creates the board board = b.Board() #reads all the input no_of_lines = 8 lines = [[]]*no_of_lines for i in range(no_of_lines): lines[i]=list(input().replace(' ', '')) #get task gameName = input() #populates the board with the pieces board.create...
true
9f21465b2d452c7b78c72980062dc897b979467f
passion4energy/Elyane
/optimizers/amsgrad.py
UTF-8
1,562
3.453125
3
[]
no_license
""" AmsGrad Optimization without bias correction """ import numpy as np from .adam import Adam class AmsGrad(Adam): """ Class for the AmsGrad Optimization algorithm. The AmsGrad optimizer with default values and without bias correction. Extends: Adam Attributes: var_dw (array): Var...
true
a7c9379bba75f1ec9b47a667f2fc1da7217d28aa
shilad/wikibrain-mds
/evaluate.py
UTF-8
3,703
2.765625
3
[]
no_license
import random import sys import numpy as np import scipy.sparse import scipy.stats from sklearn.neighbors import NearestNeighbors from utils import * SAMPLE_SIZE = 200 TOP_K = 5 class Evaluator: def __init__(self, cosim, embedding, out=sys.stdout): self.cosim = cosim self.out = out self....
true
a99d3341c27e6c3547b0caafd8225c0b7de01388
ldickmanns/masters-practicum-mlcms
/final-project/dynamical_systems.py
UTF-8
732
3.625
4
[]
no_license
import numpy as np def linear_system(x1, x2, a): dx1 = -a * (x1 + x2) dx2 = 0.25 * x1 return dx1, dx2 def vec_linear_system(x, a): x1 = x[0] x2 = x[1] return np.array(linear_system(x1, x2, a)) def andronov_hopf(x1, x2, a): dx1 = a * x1 - x2 - x1 * (x1 ** 2 + x2 ** 2) dx2 = x1 + a *...
true
cb246f804c3e8cd2a0ebce71142b6571b6b6664f
RedLicorice/crypto-forecast
/old/old_script/old/feature_selection_results2.py
UTF-8
2,319
2.59375
3
[]
no_license
import json import pandas as pd import matplotlib.pyplot as plt def main(dataset): resultFile = 'data/datasets/{}/feature_selection2.json'.format(dataset) results = {} with open(resultFile) as f: results = json.load(f) for _sym, result in results.items(): rfecv_03 = result["test_size=0...
true
13b0d193e61f36491d4989dd68c0106429270381
CastielLiu/robot_ws
/src/remote_control/src/LAN/LAN_server.py
UTF-8
1,373
2.546875
3
[]
no_license
#!/usr/bin/env python import rospy from std_msgs.msg import String from geometry_msgs.msg import Twist import socket class ReoteControl: def __init__(self,host,port): self.addr = (host,port) self.tcpSerSock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.tcpSerSock.setsockopt(socket.SOL_SOCKET, socket.SO...
true
2108ad33e6cb69988d9111460a36bda43957653b
KUAN-HSUN-LI/Missing-Feature-Learning
/task2/src/trial1/preprocessor.py
UTF-8
973
3.015625
3
[]
no_license
from tqdm import tqdm def preprocess_samples(dataset, missing=None): """ Worker function. Args: dataset (list of dict) Returns: list of processed dict. """ processed = [] for sample in tqdm(dataset.iterrows(), total=len(dataset), ascii=True): processed.append(preproces...
true
76bfd2c38997448254a942d798c86fa852f086d9
nikolovd/Accelerometer_integration
/convertCSV.py
UTF-8
2,747
2.578125
3
[]
no_license
import numpy as np def ValidationData(Data) : print("Verification des donnees en cours") colNum = Data['Num'].values cpt = 0 nbErreur = 0 tailleTab = len(colNum) for element in colNum : if ((cpt + 1) < tailleTab-1) and (element != (colNum[cpt + 1] -1)) : print ("erreur ligne : " + str(element)) nbErreur...
true
2b177e11724bb940c434fc6c84bd53bd0f5645f9
vusaliko/Laboratorniye
/Лабораторная 7.7.py
UTF-8
412
3.703125
4
[]
no_license
while True: print("Введите числа a,b,c") a=int(input()) b=int(input()) c=int(input()) if a+b>c: if a+c>b: if b+c>a: print("Существует") else: print("Не существует") else: print("Не существует") else:...
true
4460927ff0996c759bade5fb0b168b6fb3bb8556
cbrahana/FRC-Localizer-Systems
/G4 Localizer/main.py
UTF-8
1,724
3.328125
3
[ "MIT" ]
permissive
#Mostly Notes for now #Start of main program loop #Run every 0.25 seconds #Get ORP (Odometry Robot Position) as (float,float) tuple #Get ORH (Odometry Robot Heading) as 0-360 range, float #Function - Check if ORP and ORH make sense #This is probably quite complicated , so do be mindful #Function - Take ...
true
00d1c0337404d6d5cdbd015665c887708e655570
7QYe/practice
/Hogwarts/test_selenium_po/page/add_member_page.py
UTF-8
1,770
2.6875
3
[]
no_license
""" author : QY """ from test_selenium_po.page.base_page import BasePage from test_selenium_po.page.contacts_page import ContactsPage from test_selenium_po.page.departmnt_details_page import DepartmentDetailsPage class AddMemberPage(BasePage): """ 添加成员 """ def add_member(self, username, acctid, phone...
true
867b3b814549ca37742ba08ac8ae9064e9f64905
DominikPott/fracture
/fracture/_utils.py
UTF-8
760
2.8125
3
[ "MIT" ]
permissive
""" Holds small utility functions and classes """ # ------------------------------------------------------------------------------ class Signal(object): """ A simple signal emmisison mechanism to allow for events within functions to trigger mid-call callbacks. """ # ------------------------------...
true