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 |
|---|---|---|---|---|---|---|---|---|---|---|
8ce6f34cba8a07779a4fc3fa82b5af0744c51cda | ChangxingJiang/LeetCode | /1601-1700/1608/1608_Python_1.py | UTF-8 | 611 | 3.28125 | 3 | [] | no_license | from typing import List
class Solution:
def specialArray(self, nums: List[int]) -> int:
lst = [0] * 101
for n in nums:
for i in range(min(n + 1, 101)):
lst[i] += 1
for i, n in enumerate(lst):
if i == n:
return i
return -1
if... | true |
aa098c5fce20db5342e5188644edcb90e76e4c06 | jacobgarrison4/Python | /cis122project5.py | UTF-8 | 2,602 | 4.125 | 4 | [] | no_license | #Problem 0
def word1():
word = input('Enter a word ')
if len(word) >= 5:
return True
else:
return False
def word2():
word = input('Enter a word ')
if str.isalnum(word):
return False
else:
return True
def word3():
word = input('Enter a... | true |
efb4d49f3f7fb0b0fa9e9b2a270e722abed035ff | xiaozhi1995/project | /Python/MouseGame.py | UTF-8 | 365 | 2.953125 | 3 | [] | no_license | import pygame
pygame.init()
windowSize=[400,300]
screen=pygame.display.set_mode(windowSize)
clock=pygame.time.Clock()
done=False
while not done:
for event in pygame.event.get():
if event.type==pygame.MOUSEBUTTONDOWN:
pos=pygame.mouse.get_pos()
print pos
if event.type==pyga... | true |
00c97cfa0f4a2b1266a80752723fc02ccea31144 | DarrenDanielDay/BackupManager | /utils/type_checker.py | UTF-8 | 1,108 | 3.09375 | 3 | [] | no_license | from typing import *
import typing
def strong_check(value, expected_type: Union[Type, Tuple[Type, ...]]):
if isinstance(expected_type, tuple):
return any(strong_check(value, item) for item in expected_type)
return type(value) is expected_type
def weak_check(value, expected_type):
return isinstanc... | true |
366c23942ce522b1422dfef4411a349e14dbfd54 | hai-h-nguyen/competitive-programming | /PERMUT2.py | UTF-8 | 1,139 | 4.15625 | 4 | [] | no_license | """Input Specification
The input contains several test cases.
The first line of each test case contains an integer n (1 ≤ n ≤ 100000). Then a permutation of the integers 1 to n follows in the next line.
There is exactly one space character between consecutive integers. You can assume that every integer between 1 and n... | true |
4c3c59f8bc83073a4910e04fd7da07e50be43842 | samelstob/notes | /management-notes/algorithms/src/justify.py | UTF-8 | 4,617 | 4.125 | 4 | [] | no_license | #!/usr/bin/env python3
import sys
fh = open("test.txt", "r")
file = fh.read()
words = file.split()
#print(words)
"""
DP aims to turn an exponential algorithm into a polynomial one by recursion + memoisation
Reusing solutions to sub-problems in the recursion tree
"""
def count_chars(words):
chars = 0
for w... | true |
8660188bc33eea21461c9af399d95998948ab5be | EvanSMartin/parseltongue | /d01/ex00/00_so_long.py | UTF-8 | 1,189 | 3.09375 | 3 | [] | no_license | animal_plural = "monkeys"
emotion = "perturbed"
character_trait = "wholesomeness"
adjective = "vivacious"
animal_2 = "horses"
emotion_2 = "love"
character_trait = "honest"
adjective_2 = "attractive"
print("So long and thanks for all the {}".format(animal_plural))
print("So {} that it should come to this".format(emoti... | true |
6b8b4a5f7f9802fb0a08a03701430108ceffe034 | mdutia/DBMS_WorkloadModel | /db-createfirst.py | UTF-8 | 2,074 | 2.515625 | 3 | [] | no_license | from app import db, WLM_data, Admin, AdminRole, ResearchRole, TeachingRole, Course
db.drop_all()
db.create_all()
F= 'admins.csv'
with open (F) as f:
classlist= f.readlines() # should only be one line, but can cope with more
for line in classlist:
lin= line.strip().split(',')
for u in lin:
a=Admin(... | true |
b87d733db42ba0e823522757151fe65715371436 | lixiang30/code | /test_author_book.py | UTF-8 | 841 | 2.578125 | 3 | [] | no_license |
import unittest
from author_book import Author,db,app
class DatabaseTest(unittest.TestCase):
def setUp(self):
app.testing = True
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://root:huang921118@127.0.0.1:3306/flask_test"
db.create_all()
def test_add_author(self):
"""测试添加作者的数... | true |
20fd0c7ee11cdea153c0cfe431b763aef48b0137 | SheetanshKumar/smart-interviews-problems | /Maximum Non-adjacent Subsequence Sum.py | UTF-8 | 1,136 | 3.59375 | 4 | [] | no_license | '''Given an array of integers, find the maximum subsequence sum, such that no 2 elements of the subsequence are adjacent to each other. Note that you cannot select an empty subsequence.
Input Format
First line of input contains T - number of test cases. Its followed by 2T lines. First line of each test case contains ... | true |
fd79685ecd53782a4cf32325865d13ec253f5cf6 | eomdayeon/AlgorithmTrain | /Baekjoon/동적 프로그래밍/[완]14002_가장 긴 증가하는 부분 수열 4.py | UTF-8 | 771 | 3.421875 | 3 | [] | no_license | import sys
def solve(n, arr):
'''
table[i] = arrr[i]를 포함했을 때 가장 긴 증가하는 부분 수열의 길이
'''
table = [1 for _ in range(n)]
temp = [str(arr[i]) for i in range(n)]
for i in range(n):
for j in range(i):
if arr[i] > arr[j]:
if table[i] < table[j] + 1:
... | true |
546d9ee2a2fcf0d6fdaa5a4da1952365f77e682b | drawAgirl/PAT | /Python3/1100.py | UTF-8 | 752 | 3.3125 | 3 | [] | no_license | earths = ["tret","jan","feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov","dec"]
mars= ["","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"]
n=int(input())
for _ in range(n):
s = input()
try:
a = int(s)
if a>=13:
b = a%13
... | true |
795e3d7d0d1052c279cbaae261dc98fe021488a2 | savourylie/cracking_the_code_interview | /ch1/1_4_palindrome_perm.py | UTF-8 | 976 | 3.390625 | 3 | [] | no_license | def palindrome_perm(string):
if len(string) == 0 or len(string) == 1:
return True
string = string.lower()
string = string.replace(' ', '')
char_dict = {}
for i, x in enumerate(string):
char_dict[x] = char_dict.get(x, 0) + 1
if len(string) % 2 == 0:
for key, value i... | true |
abf4bceace98387e225984d4c18ef4bd7dbd5622 | sunschong/Zendesk-Challenge | /ticketview.py | UTF-8 | 2,585 | 3.578125 | 4 | [] | no_license | import requests
import webbrowser
#****************************************
#function prints tickets in the terminal
#****************************************
def print_tickets_on_terminal():
#keeps track of ticket number
count = 0
#format and display contents of the tickets into file
for t... | true |
e8a7a94da1f47a8e2179a8211699ae6722631015 | liyi0206/leetcode-python | /235 lowest common ancestor of a BST.py | UTF-8 | 1,016 | 3.828125 | 4 | [] | no_license | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
"""
:type root: TreeNode
:type p: TreeNode
:type q: Tre... | true |
86006bef71c85a20e6a573b140c94bc7ff59f416 | crew/dds-frontend | /src/dds/playlist.py | UTF-8 | 3,047 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
# vim: set shiftwidth=4 tabstop=4 softtabstop=4 :
"""slide playlist
"""
import gflags
import logging
import thread
import random
FLAGS = gflags.FLAGS
class SlideItem(object):
def __init__(self, position, ids, weights, mode):
self.position = position
self.ids = ids
se... | true |
3d8d2e49e8cda21a0d61a2c15c60d1daf0a00960 | DevParapalli/SchoolProjects_v2 | /44_MySQL_dataframes.py | UTF-8 | 1,244 | 3.28125 | 3 | [] | no_license | "Write a Program to show database connectivity of python Data Frames with mysql database"
import mysql.connector
import pandas
# Boilerplate code
database = mysql.connector.connect(
host="127.0.0.1",
user="python",
password="python",
database="python"
)
# pass this to function
cursor = database.cursor... | true |
5092e4967fbe6beca44868923bb394a856442e0f | supernifty/newton | /newton.py | UTF-8 | 834 | 3.890625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python
'''
find x such that y is zero using newton's method
'''
import logging
import math
def f(x):
'''
the formula entered will be optimized to zero using Newton's method
ENTER YOUR FORMULA HERE
'''
return x * math.log(x, 2) - 1e6
def newton():
x = 10
step = 1e-3
max_error = 1e... | true |
4f6beecebba24150ab78a52c1d649b79c8bf50f4 | ercymiranda/Penny | /source/gcp_billing/gcp_billing.py | UTF-8 | 3,306 | 2.84375 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
# cloudstoragedownload.py
# It is an example that handles Cloud Storage buckets on Google Cloud Platform (GCP).
# Download an object from a Cloud Storage bucket to a local file.
# You must provide 3 parameters:
# BUCKET_NAME = Bucket name
# OBJECT_NAME = Object name in ... | true |
a50e39031ee3fb8e56f98efae5b360329f6374e6 | sun9121/CodeUp | /Python_basic100/09.py | UTF-8 | 325 | 4.28125 | 4 | [] | no_license | # 문자(character)는
# 0~9, a~z, A~Z, !, @, #, {, [, <, ... 과 같이
# 길이가 1인 기호라고 할 수 있다.
# 변수에 문자 1개를 저장한 후
# 변수에 저장되어 있는 문자를 그대로 출력해보자.
# 예시
# c = input()
# print(c)
# 와 같은 형태로 가능하다.
c = input()
print(c) | true |
182dddd77177cb045f8dee35fa1582aed0a79d5b | AdItYa302007/Project-100 | /ClassAtm.py | UTF-8 | 1,052 | 4.0625 | 4 | [] | no_license | class Atm(object):
def __init__(self,cardnumber,pin,expiry):
self.cardnumber=cardnumber
self.pin=pin
self.expiry=expiry
def check_balance(self):
print("Your Balance Is 100000")
def withdrawl(self,amount):
new_amount = 100000 - amount
print("You Ha... | true |
cd98b25ea87a1fca7e24db1802c7ef194b867777 | dannymulligan/Project_Euler.net | /Prob_683/prob_683.py | UTF-8 | 3,611 | 3.90625 | 4 | [] | no_license | #!/usr/bin/env python3
# coding=utf-8
#
# Project Euler.net Problem 683
#
# The Chase II
#
# Consider the following variant of "The Chase" game. This game is
# played between n players sitting around a circular table using two
# dice. It consists of n−1 rounds, and at the end of each round one
# player is eliminated an... | true |
6bccac375b2d95065b84d440f7d18ccf1f8ac68c | rags1357/Deep-Learning-Traffic_Sign_Recognizer | /inout/fileparser.py | UTF-8 | 1,775 | 3.1875 | 3 | [] | no_license | import xlsxwriter
__author__ = 'Group16'
"""
This class contains the code to:
- Read a image as input
- Write a csv file as output
Written by Group 16: Tim Deweert, Karsten Goossens & Gilles Vandewiele
Commissioned by UGent, course Machine Learning
"""
class FileParser:
def __ini... | true |
333d52926860d5dac8d33d65ecdfd1980eeae9dc | noralebe/python | /pybank/main.py | UTF-8 | 1,848 | 3.296875 | 3 | [] | no_license | import csv
#file = "../Python Stuff/budget_data.csv"
months = 0
rows = []
profitslosses = 0
greatestincrease = 0
greatestincrease_date = 0
greatestdecrease = 0
greatestdecrease_date = 0
variance=0
newcolumn=[]
with open("budget_data.csv", "r") as csvfile:
csvreader = csv.reader (csvfile, delimiter=",")
... | true |
6e2dd2fe16e516e4c385f3301e1b69ad50f9f38b | MatterMiners/cobald | /src/cobald/composite/weighted.py | UTF-8 | 3,651 | 3.140625 | 3 | [
"MIT"
] | permissive | from typing import Literal
from ..interfaces import Pool, CompositePool
class WeightedComposite(CompositePool):
"""
Composition of pools weighted by their current state
The aggregation of children's :py:attr:`~.Pool.demand`,
:py:attr:`~.Pool.utilisation` and :py:attr:`~.Pool.allocation`
is weigh... | true |
72ec4db7da19ba1c5b37a16d348235a41461164d | taojt/hello_python | /do_slice.py | UTF-8 | 136 | 2.9375 | 3 | [] | no_license | # -*-coding: utf-8 -*-
# Create by Jiang Tao on 2016/9/20
L = ["Tom", "Michael", "Tracy"]
print('L[0:3]=', L[0:3])
print('L[:2]=', L[:2])
| true |
002768b54f22deb856e1d90a633a11ad2edddfc0 | Kkim50/majors-fair | /majors-react-app/majorsfair.py | UTF-8 | 7,729 | 2.859375 | 3 | [] | no_license | import pandas as pd
import tabula
import os
import re
import json
from difflib import SequenceMatcher
def print_dict(arg_dict):
for key, val in arg_dict.items():
print(key, val)
print()
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
def find_best_match(majors, category_list, ca... | true |
80fa3cd0aaa655f60ce59fc63823266c2c7f6363 | wangwillson1/stock-scraper | /webscraper-test.py | UTF-8 | 2,516 | 3.359375 | 3 | [] | no_license | # Importing files for web scraping
from urllib.request import urlopen as urlReq
from bs4 import BeautifulSoup as soup
# Setting URL variables
test_url = 'https://www.newegg.ca/Cell-Phones-Unlocked/SubCategory/ID-2961?Tid=165973'
urlClient = urlReq(test_url)
page_html = urlClient.read()
urlClient.close()
# Parsing HTM... | true |
80c791211da1da84f577f839855ba0c3908239ec | KennethJHan/Bioinformatics_Programming_101 | /066.py | UTF-8 | 466 | 2.5625 | 3 | [] | no_license | #!/usr/bin/python3
import sys
if __name__ == "__main__":
if len(sys.argv) != 2:
print("#usage python", sys.argv[0],"<fastq>")
sys.exit()
InFASTQ = sys.argv[1]
lQual = []
iCnt = 0
with open(InFASTQ) as fr:
for line in fr:
iCnt += 1
if iCnt % 4 == 0:
sQual = line.strip()
iQual = 0
for s in ... | true |
59423c9919bdea46e2e53e93cc73d95453093f1d | bcongdon/advent_of_code_2016 | /Day20-25/23.py | UTF-8 | 1,699 | 2.765625 | 3 | [
"MIT"
] | permissive | def simulate(inst, initial_values={}):
registers = {x: 0 for x in 'abcd'}
registers.update(initial_values)
def get_val(i):
if i in registers:
return registers[i]
return int(i)
instructs = map(lambda x: x.split(), inst)
pc = 0
pairs = {
'inc': 'dec',
... | true |
d2f1169dc3f7630e12ffb424de8fc4149064edb0 | luogan1234/CAIL-sfks | /processor.py | UTF-8 | 7,404 | 2.53125 | 3 | [] | no_license | import json
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import tqdm
import numpy as np
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
from model.model_classify import ModelClassify
from model.model_pred import ModelPred
class Proce... | true |
be05cd0ab41a63d861eb2889e0ddc3cb8bbb8dfb | kingsamchen/Eureka | /crack-data-structures-and-algorithms/leetcode/python-impl/3sum_q15.py | UTF-8 | 1,767 | 3.6875 | 4 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# 0xCCCCCCCC
# Given an array nums of n integers, are there elements a, b, c in nums such that
# a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
def three_sum(nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
# sort first; taken ... | true |
140bfe267b24452924280746ba12e5bbb4dfa540 | leh13-uci/snake-game | /ssnake.py | UTF-8 | 5,287 | 3.265625 | 3 | [] | no_license | import pygame
import random
pygame.init()
#RGB color code
# Color for grass map
GREEN = (0, 200, 0)
LIGHTGREEN = (0, 255, 0)
WHITE = (255,255,255)
BLUE = (0, 0, 255)
SHADOW = (192, 192, 192)
WALL = (166, 186, 171)
DARKGREEN = (0, 100, 0)
BLACK = (0, 0, 0)
SPEED = 15
class Map:
def __init__(se... | true |
8304ef1678746f9d8cc74746e3435cd82fdb7b9e | ImperialSpaceSociety/MQTT_logger | /prediction_manager.py | UTF-8 | 1,430 | 2.6875 | 3 | [] | no_license | from datetime import datetime, timedelta
import requests
from file_saver import FileSaver
BASE_URL = "http://predict.cusf.co.uk/api/v1/"
HOURS_AHEAD_TO_PREDICT = 120 # hours
class PredictionManager:
def __init__(self):
self.filesaver = FileSaver()
def predict_and_save(self, ts, alt, long, lat, fi... | true |
cffc282549078095885c7366977d0ab96c9c3fff | lifecrisis/aeolus | /aeolus-drivers/experiment_01/summary.py | UTF-8 | 1,269 | 3.375 | 3 | [] | no_license | """
This module prints a summary report for the accompanying "results.csv" file
generated by running experiment #01 on Spark.
"""
def print_record(record):
""" Format and print a CSV record. """
fields = record.split(',')
print " Neighbors : %s" % fields[0]
print " Power : %s" % fields[1]
... | true |
bb94f5f5c85ce1ca51b9a03968af1319d5b9c43b | Bemoliph/lakeception | /lakeception/events.py | UTF-8 | 6,677 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division
import logging
import pygame
LOGGER = logging.getLogger()
class EVENTS(object):
u"""
Primary event types left unused by PyGame + SDL for our custom use.
Only 8 user-defined events are allowed by PyGame's version of SDL, so use sp... | true |
6d9cc55fae82705ab1727c1149d33cbc823b667f | Qian-Yu-Lu/ycsh_python_course | /L08/factorize.py | UTF-8 | 154 | 3.984375 | 4 | [] | no_license | x = int(input("請輸入數字"))
while x > 1:
for i in range( 2, x+1 ):
if x % i== 0:
print(i)
break
x = x // i | true |
dafdb4f94b4648c43877d542514c17afa7700a0d | seantitus/Python-Practice | /pageDistance.py | UTF-8 | 1,729 | 3.21875 | 3 | [] | no_license | import urllib.request as urlr
import urllib.parse as urlp
import re
import queue
from html.parser import HTMLParser
class Page:
def __init__(self, url, level, parent):
self.url = url
self.links = []
self.level = level
self.reachable = True
self.parent = parent
def addLink(link):
self.links.append(link)
... | true |
4a0f823a44dc4890392307e9043f1deb7c4fd864 | pz325/tt-ner | /ner_nltk/ner.py | UTF-8 | 1,668 | 3.609375 | 4 | [] | no_license | import nltk
def get_ner(text):
'''
Get NER chunks from text
@return { 'person': [], 'location': [], 'organization': [] }
'''
tokens = nltk.word_tokenize(text)
pos_tags = nltk.pos_tag(tokens)
ner_chunks_tree = nltk.ne_chunk(pos_tags)
return _transform_ner_chunks(ner_chunks_tree)
def _... | true |
d4f08280744fa5ca01b14e1ad6a853f091a1970b | mikias21/Code-For-Algorithms- | /linkedlist/CircularLinkedList.py | UTF-8 | 4,676 | 3.6875 | 4 | [] | no_license | #Circular linked list class
class CircularLinkedList(object):
#constructor
def __init__(self):
self.head = None
self.data = None
self.next = None
self.length = 0
#setters and getters
def setData(self, data):
self.data = data
def getData(self):
return self.data
def setNext(self, next)... | true |
bcd43fb2d7e026cfdedffa2457652644c4f1d056 | kivancguckiran/biometrics | /fingerprint/step3.py | UTF-8 | 1,031 | 2.8125 | 3 | [] | no_license | from os import listdir
from skimage.morphology import disk, square
from utils import populateFiles, readImages, saveImageFile, applyCustomThreshold, applyOtsuThreshold, applyAdaptiveThreshold
# Let's apply median, gaussian and mean
# all of the morphed images
sourceDir = 'step2'
destDir = 'step3'
# get mor... | true |
2fd109c099f4f692e5b32b5693360e9d6cacfb7b | raonina/qbb2016-01 | /day2-hmw/03-test_line_from_FlyID.py | UTF-8 | 337 | 2.828125 | 3 | [] | no_license | #!usr/bin/env python
"""
Test if filter works line of code
Count number of "FBgn" appears in line and compare with all lines
"""
import sys
file = open(sys.argv[1])
sun = 0
for line in file.readlines():
if "FBgn" in line:
continue
sun = sun+1
shine = 0
for line in file.readlines():
shine = += 1
print (sun + "... | true |
d384a59fd5d114fb606337d635d407bb1271469e | Mujju-palaan/Flask01 | /section2/19)list_imp.py | UTF-8 | 314 | 3.421875 | 3 | [] | no_license | my_list = [0,1,2,3,4]
an_equal_list = [x for x in range(5)]
multiply_list = [x*2 for x in range(5)]
#print(multiply_list)
print([n for n in range(20) if n%2 ==0])
people_you_know = ["Rolf", "John", "anna", "GREG"]
normalised_people = [person.strip().lower() for person in people_you_know]
print(normalised_people) | true |
a93c33052d64fb35e9754518862b61773b3f58f5 | murayama333/python2020 | /01_basic/tr/src/03/if_tr5.py | UTF-8 | 150 | 3.109375 | 3 | [] | no_license | user_id = input("User Id: ")
password = input("Password: ")
if user_id == "Alex" and password == "secret":
print("OK")
else:
print("NG")
| true |
3d717ae8315ea070d88e7dadeaa3d20223c2f381 | jaskaran-hub/DiceByKaran | /dice.py | UTF-8 | 210 | 3.671875 | 4 | [] | no_license | import random
rolling = True
while rolling:
print(random.randint(1,6))
again=input("Do you want to print again: (y\n) ")
if again.lower() == "y":
continue
else:
break | true |
e1504855f270c8db8bd9c0e860ebb02f4b7a69ff | kaiser101/Packages | /Packages/yaml_macros_engine/tests/test_simple.py | UTF-8 | 885 | 2.59375 | 3 | [
"MIT"
] | permissive | from unittest import TestCase
from io import StringIO
from yamlmacros import process_macros
from yamlmacros.src.yaml_provider import get_yaml_instance
from sublime_lib import ResourcePath
FIXTURES_PATH = ResourcePath('Packages/yaml_macros_engine/tests/fixtures')
class TestSyntaxes(TestCase):
def _test_fixtur... | true |
743ea6727a2581cc3c4742c1749026fd31198a04 | liza0525/algorithm-study | /BOJ/boj_9019_DSLR.py | UTF-8 | 880 | 3.03125 | 3 | [] | no_license | import sys
sys.stdin = open('../input.txt', 'r')
import collections
def D(num):
return (num * 2) % 10000, 'D'
def S(num):
return (num - 1, 'S') if num != 0 else (9999, 'S')
def L(num):
return (num % 1000)*10+(num // 1000), 'L'
def R(num):
return (num // 10)+(num % 10)*1000, 'R'
for _ in range(i... | true |
a4602fc2ca3c458efd24cd51461b856752cb5d57 | HichamZouarhi/CodinGame | /ShadowOfTheKnightEp2.py | UTF-8 | 2,415 | 3.328125 | 3 | [] | no_license | import sys
import math
w, h = [int(i) for i in input().split()]
n = input()
x0, y0 = [int(i) for i in input().split()]
x, y = x0, y0
x_search, y_search = range(w), range(h)
def narrow_search(previous_position, next_position, search_range):
if info == "UNKNOWN":
pass
elif info == "SAME":
sear... | true |
c9d3a2bf78a2d60c4b3a1dfd52f19fbb5cbba610 | dustinengle/smart-mailbox | /gateway/kit/receiver.py | UTF-8 | 1,416 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import json
import os
from Queue import Queue
import random
import time
from logger import error, info
from mqtt import MQTT
class Receiver():
def __init__(self):
info('receiver', 'init')
self.queue = Queue()
self.mqtt = MQTT(os.environ['KIT_CHANNEL'], client_id='rec... | true |
cfeee7ddf64c1e21b4aca25370aea489bc15be6a | TrellixVulnTeam/Python-Exercises_3RSX | /Training/Training.py | UTF-8 | 15,093 | 3.46875 | 3 | [] | no_license |
import tkinter
from tkinter import *
#Page 107~111
class ParentWindow(Frame):
def __init__(self, master):
Frame.__init__(self)
self.master = master
self.master.resizable(width=False, height=False)
self.master.geometry(f'{700}x{400}')
self.master.title('Learning Tkinter'... | true |
2a5327fa0bca4d9341211d0dd5af58a591b9189b | danielnuno/PAP | /Allst.py | UTF-8 | 6,463 | 2.640625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import math
from sklearn import neighbors
from sklearn import preprocessing
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import cross_val_score
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import RandomFores... | true |
bc91c18c6e4de93b242cd29775e41a2bb991cac2 | sputt/homepi | /GPIO/poll_gpio.py | UTF-8 | 1,113 | 2.5625 | 3 | [] | no_license | from collections import namedtuple
import RPi.GPIO as GPIO
import time
import requests
INPUT_DEBOUNCE_MS = 200
GPIO.setmode(GPIO.BCM)
PinMapping = namedtuple('PinMapping', 'pin name hsid')
INPUT_PINS = [
PinMapping(24, 'Water Sensor', 3),
PinMapping(23, 'Kitchen Door', 84)
]
def post_to_homeseer(hsid, val... | true |
92ba16ccdca85d8c101d967c3a447e98161e7c6f | cameronliang/bayesvp | /bayesvp/mcmc_setup.py | UTF-8 | 7,153 | 2.59375 | 3 | [
"MIT"
] | permissive | ################################################################################
#
# mcmc_setup.py (c) Cameron Liang
# University of Chicago
# jwliang@oddjob.uchicago.edu
#
# Perform maximum likelihood fit to data given the config file specification
# and output the MCMC chains
###############... | true |
ea6a55896e42da3465bd6c804b925c7812647542 | LQXshane/leetcode | /array/sort/linkedlist/has_cycle.py | UTF-8 | 1,073 | 3.4375 | 3 | [] | no_license |
# definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def hasCycle(self, head):
"""
:type head: ListNode
:rtype: bool
"""
# fast and slow (pointer) will meet if t... | true |
a3596d7c9c6c99704fb4c98533be4d83d9f06963 | PUranger/TF | /lineSlope.py | UTF-8 | 2,112 | 3.484375 | 3 | [] | no_license | from statistics import mean
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
import random
style.use('fivethirtyeight')
#xs = np.array([1,2,3,4,5,6], dtype=np.float64) #changes to numpy array
#ys = np.array([5,4,6,5,6,7], dtype=np.float64)
def create_dataset(hm, variance, step=2, corr... | true |
ae8f9754e8aaeafab99ec3d18dedf964a11365d3 | Merkulov-Mikhail/MyGame | /Game.py | UTF-8 | 10,873 | 2.6875 | 3 | [] | no_license | from blocks import *
import pygame
from Player import *
from monsters import *
Win_Width = 800
Win_Height = 600
Display = (Win_Width, Win_Height)
BackGround_color = "#000000"
PlatformWidth = 32
PlatformHeight = 32
PlatformColor = "#ffffff"
ICON_DIR = os.path.dirname(__file__)
Player_SpeedX = 0
Player_SpeedY = 0
class C... | true |
9e5774d18237a7a943a60dab1cb056498e1e8ecc | mateusz-kleszcz/Algorithms-and-Data-Structures | /kolosy/kolokwium I/13 zad3.py | UTF-8 | 812 | 3.421875 | 3 | [] | no_license | def count(counters, word):
for char in word:
i = ord(char)
counters[i] += 1
def possible(u, v, w): #O(n + k)
E = 256
countersUandV = [0] * E
count(countersUandV, u)
count(countersUandV, v)
counters = [0] * E
count(counters, w)
for i in range(E):
if counters[i... | true |
d96792257b0afd7a1334545159536f067c33b512 | anyaa0402/pygames | /pygame_pong_comp.py | UTF-8 | 3,774 | 3.078125 | 3 | [] | no_license | import pygame
from pygame.locals import *
import random
import time
import pygame_pong_menu
#import pygame_pong_user
pygame.init()
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
white = (255,255,255)
black = (0,0,0)
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("Pong! - One Player")
l_p... | true |
be83dda4127d4d3321e3d56b933dd9c495e00e4e | minhngh/Keras-Utils | /Data Loader/HDF5/HDF5DataGenerator.py | UTF-8 | 1,039 | 2.671875 | 3 | [] | no_license | import numpy as np
import h5py
class HDF5DataGenerator:
def __init__(self, dbPath, data_name, label_name, batch_size, aug = None):
self.db = h5py.File(dbPath)
self.batch_size = batch_size
self.num_samples = self.db[label_name].shape[0]
self.data_name = data_name
self.label_n... | true |
9731a68bb78b46f7d16a9011ff7f0e59a0e8cd41 | Rpratik13/HackerRank | /Tournament_Practice/quickSort.py | UTF-8 | 548 | 3.328125 | 3 | [] | no_license | def partition(array: list) -> list:
p = array[0]
less = []
grt = []
for i in range(1, len(array)):
if array[i] < p:
less.append(array[i])
else:
grt.append(array[i])
ans = quickSort(less) + [p] + quickSort(grt)
print(' '.join(map(str, ans)))
return an... | true |
6e2a36d9fbf2c91373c8e6ae9b097e02389009de | cumtdingkai/Petri | /src/unit_test/activity_transform_epf_unittest.py | UTF-8 | 4,202 | 2.65625 | 3 | [] | no_license | '''
Created on 02.12.2015
@author: Kai
'''
import unittest
from ad_to_petri import activity_transform_epf
from bean import uml_activity_diagram_element as uml_element
class Mytest(unittest.TestCase):
'''test class
'''
# initial
def setUp(self):
'''setup
'''
# new the to unit t... | true |
5c53521d3d7d74ea0b5618e9603fab0dcb128782 | loveu3000s/learnPython | /exp5/multiple_subplots.py | UTF-8 | 474 | 3.40625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 03 16:57:26 2016
@author: gsdx
"""
import matplotlib.pyplot as plt
import numpy as np
def f(t):
return np.exp(-t) * np.cos(2 * np.pi * t)
t1 = np.arange(0, 5, 0.1)
t2 = np.arange(0, 5, 0.02)
plt.figure(12)
plt.subplot(221)
plt.plot(t1, f(t1), 'bo', t2,... | true |
1a6a34cc291746390650891087bc0d23f03c6c73 | kannibalox/tranny | /tranny/stats.py | UTF-8 | 1,578 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Functions used to retrieve statistics from historical data.
"""
from __future__ import unicode_literals, absolute_import
from collections import Counter
from tranny import app
from tranny import datastore
from tranny.app import Session
def count_totals(records, key_getter):
""" Get the... | true |
4776300debf6df0a19738eba960bcaed9fcc2ee7 | ssahn0806/kw-SW_Preparatory | /Day4/Chap7/new_Ex1.py | UTF-8 | 630 | 3.875 | 4 | [
"MIT"
] | permissive | def get_sum(a,b,c):
return a+b+c
def get_avg(a,b,c):
return (a+b+c)/3
def get_grade(a,b,c):
avg = get_avg(a,b,c)
grade = 'F'
if avg >= 90:
grade = 'A'
elif avg >= 80:
grade = 'B'
elif avg >= 70:
grade = 'C'
elif avg >= 60:
grade = 'D'
return grade
... | true |
7da56619bb7bd0961f1bb08b11707caf88ddf39b | Thoremp/trend | /cn_trend.py | UTF-8 | 8,758 | 2.71875 | 3 | [] | no_license | #coding=utf-8
import urllib
from lxml import etree
import cn_trendUtil
import re
import time
import usa_trend
import sys
from multiprocessing.dummy import Pool
reload(sys)
sys.setdefaultencoding('utf-8')
"""
信息顺序:标题,公司名字,公司网址,月薪,工作地点,发布日期,工作性质,工作经验,最低学历,招聘人数,职位类别
最重要的是人数和职位类别
"""
# 循环搜索所有类别 返回数组urls-102个url
d... | true |
3200aacbe8f7bbceabe36996844ab1101045c3d7 | yang-jiayi/public_repo | /suspicious_behavior_detection/video_config.py | UTF-8 | 2,579 | 2.625 | 3 | [] | no_license | # Databricks notebook source
# DBTITLE 1,画像を抽出する動画、抽出画像の保存場所の設定
# ソースのトレーニング動画
srcVideoPath = "/databricks-datasets/cctvVideos/train/"
# ソースのテスト動画
srcTestVideoPath = "/databricks-datasets/cctvVideos/test/"
# ソースのトレーニング動画(MP4)
srcVideoMP4Path = "/databricks-datasets/cctvVideos/mp4/train/"
# ソースのテスト動画(MP4)
srcTestVide... | true |
7edcadbfb5d3be5f88b962c04da52c8361dac3f4 | Rishiv02/Trading-strategy- | /EWMA.py | UTF-8 | 638 | 3.09375 | 3 | [] | no_license | import pandas as pd
import yfinance as yf
import matplotlib.pyplot as plt
tick = ["^NSEI"]
nse = yf.download(tick, start = "2017-01-01", end = "2021-05-05")
nse.to_csv("nse.csv")
NSE = pd.read_csv("nse.csv", parse_dates =["Date"], index_col = "Date", usecols = ["Date", "Close"])
print(NSE.head(10))
ewma_10 = NSE.Close.... | true |
161b673cfe395f8e0e67b7306c1452c4e6757dcc | alisure-ml/python-study | /temp/study_plt/1-figure.py | UTF-8 | 316 | 2.65625 | 3 | [] | no_license | import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(221, facecolor='r')
ax.set_title("PCA")
ax = fig.add_subplot(222, facecolor='g')
ax.set_title("PCA")
ax = fig.add_subplot(223, facecolor='b')
ax.set_title("PCA")
ax = fig.add_subplot(224, projection='polar')
ax.set_title("PCA")
plt.show()
| true |
b57f7117e6080b059be8e06aab622fa9d3dbb9b0 | oneshan/Leetcode | /accepted/034.search-for-a-range.py | UTF-8 | 2,412 | 3.90625 | 4 | [] | no_license | #
# [34] Search for a Range
#
# https://leetcode.com/problems/search-for-a-range
#
# Medium (31.26%)
# Total Accepted:
# Total Submissions:
# Testcase Example: '[5,7,7,8,8,10]\n8'
#
# Given an array of integers sorted in ascending order, find the starting and
# ending position of a given target value.
... | true |
8e410056e9fcc66aaa242aa0d24b0dcc0b5f0ac9 | saikiran03/competitive | /Spoj/Python/Spoj_Palin.py | UTF-8 | 1,317 | 2.796875 | 3 | [] | no_license | def compare(a,b):
la = len(a)
for i in xrange(la):
if(ord(a[i])>ord(b[i])):
return 1
elif(ord(a[i])<ord(b[i])):
return -1
return 0
def increment(a):
l = len(a)
sol = list(a)
for i in xrange(l):
if(a[l-i-1]!='9'):
sol[l-i-1] = chr(ord(a[l-1-i])+1)
carry = 0
break
else:
... | true |
658df3d0d29b5b687ff72abd26fcc9a8fab945b6 | RORO11/TalkNet_ASD | /model/attentionLayer.py | UTF-8 | 1,356 | 2.53125 | 3 | [] | no_license | import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.nn import MultiheadAttention
class attentionLayer(nn.Module):
def __init__(self, d_model, nhead, dropout=0.1):
super(attentionLayer, self).__init__()
self.self_attn = MultiheadAttention(d_model, nhead, drop... | true |
ac58dabe6f40e59b3106ee20ee883d2aade945a3 | Kawser-nerd/CLCDSA | /Source Codes/CodeJamData/12/23/10.py | UTF-8 | 965 | 3 | 3 | [] | no_license | import sys
import string
from itertools import combinations
def lowest(line):
sums = {}
for n in range(1, len(line)):
print n
for c in combinations(line, n):
if sums.has_key(sum(c)):
return [c, sums[sum(c)]]
else:
sums[sum(c)] = c
retu... | true |
0ddb79cc2631c7bc0c8f0ddcf63165329fd233fb | code-pylet/Tutorials | /Rectangle.py | UTF-8 | 3,128 | 2.609375 | 3 | [] | no_license | import sys
import random
import math
import pygame
import pygame.gfxdraw
from pygame.locals import *
pygame.init()
pygame.font.init()
FONT = pygame.font.Font(None, 30)
DISPLAY_WIDTH = 1280
DISPLAY_HEIGHT = 720
DW_HALF = DISPLAY_WIDTH / 2
DH_HALF = DISPLAY_HEIGHT / 2
DISPLAY_AREA = DISPLAY_WIDTH * DISPLAY_HEIGHT
DS... | true |
9d6f55d48f34fa7fa7c7743a12469942ca6e2bc6 | tommyphan8/verdant-octo-sniffle | /hashTable.py | UTF-8 | 1,983 | 3.59375 | 4 | [] | no_license | class HashTable:
def __init__(self):
self.size = 11
self.key = [None] * self.size
self.value = [None] * self.size
def put(self, key, val):
hashValue = self.hashFunction(key)
if self.key[hashValue] == None:
self.key[hashValue] = key
self.value[has... | true |
cf04b6fe7d227e7923eb94ab369004dbd0bcaf73 | VVKot/coding-competitions | /leetcode/python/520_detect_capital.py | UTF-8 | 120 | 2.578125 | 3 | [
"MIT"
] | permissive | class Solution:
def detectCapitalUse(self, word):
return word.islower() or word.isupper() or word.istitle()
| true |
aa6cb6f2cab9150256b7926e96f8830cac37162a | mizm/TIL | /python/swexpert/sw4013.py | UTF-8 | 1,653 | 3.421875 | 3 | [] | no_license | def turn(dct,mag) :
if dct == 1 :
# 0 0 1 0 0 1 0 0
# 0 0 0 1 0 0 1 0
# pop 마지막 insert 처음으로
mag.insert(0,mag.pop(7))
elif dct == -1:
#반대로
mag.insert(7,mag.pop(0))
return mag
def turnall(mag,dct,allmag) :
le_mag = ri_mag = mag #
le_dct = ri_dct = dct # ... | true |
c0a8360ea1fe5e1acfe81833797031f9d24af68a | anlongfei/cake | /src/cake/test/threadpool.py | UTF-8 | 995 | 2.828125 | 3 | [
"MIT"
] | permissive | """ThreadPool Unit Tests.
"""
import unittest
import threading
import sys
import cake.threadpool
class ThreadPoolTests(unittest.TestCase):
def testSingleJob(self):
result = []
e = threading.Event()
def job():
result.append(None)
e.set()
threadPool = cake.threadpool.ThreadPool(n... | true |
03ae446b75a763d32156621f9e24290c348b9aa5 | xiaocaiji233/cxsj2020shang | /gensokyor_XiongFeng_18052229/2020/0303/nltk_ana.py | UTF-8 | 677 | 3.25 | 3 | [] | no_license | import nltk_fun
import collections
def wcollec(p):
ss=nltk_fun.splitSentence(p)
ws = nltk_fun.p2w(ss)
c = collections.Counter()
for i in ws:
c[i] += 1
for (i, j) in c.most_common(10):
print("%s:%s" % (i, j))
return c
def tagcollc(p):
w_tags = nltk_fun.wordtag_set(p)
c... | true |
d90b20586e618c5fba4be6d0cc873367b82b89c9 | hypster/socket-app | /new_system/server_new.py | UTF-8 | 5,715 | 2.78125 | 3 | [] | no_license | import re
import socket
import threading
HOST = '127.0.0.1'
PORT = 13370
client_information = []
id_connections = []
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((HOST, PORT))
server.listen()
print("Server up and running!")
def registration(id, first_name, last_name, public_key):
inf... | true |
7e1d9f15e5c58503362f2e24c1caf794b9db383a | pranayagr/InterviewBit | /Strings/Roman to Integer.py | UTF-8 | 457 | 3.5 | 4 | [] | no_license | class Solution:
# @param A : string
# @return an integer
def romanToInt(self, A):
values = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000}
n = len(A)
res = 0
for x in range(0,n-1,1):
if(values[A[x]] >= values[A[x+1]]):
res = res + values... | true |
c61fa483bcce065f0ad9b977c6b83472bf3c3e92 | martin-hanicinec-ucl/plaschem | /unit_tests/test_pygmofwork/test_config.py | UTF-8 | 5,709 | 2.53125 | 3 | [] | no_license |
import unittest
import os
import shutil
from pygmo_fwork.config import Config
from pygmo_fwork.exceptions import \
ConfigError, GlobalModelAttributeError
class TestConfig(unittest.TestCase):
context = os.path.dirname(os.path.realpath(__file__))
temp = os.path.join(context, '.temp') # temp dir path
... | true |
2d268bb5e38605136051562bf85ae0797b22ff45 | chenhao-ye/uFS | /cfs_bench/exprs/filebench_plot/webserver/parse_log.py | UTF-8 | 3,073 | 3.015625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env python3
import sys
import csv
def print_usage_and_exit():
print(f"Usage: {sys.argv[0]} <ufs|ext4> <data_dir>")
exit(1)
if len(sys.argv) != 3:
print_usage_and_exit()
fs_type = sys.argv[1]
data_dir = sys.argv[2]
if fs_type != "ufs" and fs_type != "ext4":
print_usage_and_exit()
clas... | true |
a531db8383787d41465cf4d05fed6e2ce6673efd | XuanBu21/CAPP30254 | /hw4/pipeline.py | UTF-8 | 7,481 | 3.203125 | 3 | [] | no_license | '''
CAPP30254 HW4
Xuan Bu
Pipeline for Unsupervised Learning
'''
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from itertools import combinations
from sklearn import preprocessing
from sklearn.cluster import KMeans
import graphviz
from sklearn.tree import DecisionTreeClassifier
from sklearn... | true |
10304fcac8410e3d4aa9a4bad995223b80ccad89 | ZombieSave/Python | /Урок1.4/Задача4.py | UTF-8 | 618 | 3.5625 | 4 | [] | no_license | # 4. Представлен список чисел. Определить элементы списка, не имеющие повторений. Сформировать итоговый массив чисел,
# соответствующих требованию. Элементы вывести в порядке их следования в исходном списке. Для выполнения задания
# обязательно использовать генератор.
list_1 = [2, 2, 2, 7, 23, 1, 44, 44, 3, 2, 10, 7,... | true |
eda03093060aac4a559f3ada9a09ed39f925f73d | pratikdk/transformers_keras_dataloader | /transformers_keras_dataloader/scripts/util/load_tokenizer_and_model.py | UTF-8 | 2,544 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | import warnings
import torch
from transformers import AutoTokenizer, AutoModel, AutoConfig
def load_pretrained_model_and_tokenizer(pretrained_model_name_or_path, return_model=True, use_cuda=False):
r"""
A simple function to automatically retrieve the relevant model and tokenizer given the name/path to the pretrain... | true |
bcc22c28726c899349c75774b2947c30b322b2a4 | Zachary-Jackson/Tacocat | /models.py | UTF-8 | 1,377 | 2.59375 | 3 | [
"MIT"
] | permissive | import datetime
from flask.ext.bcrypt import generate_password_hash
from flask.ext.login import UserMixin
from peewee import *
DATABASE = SqliteDatabase('taco.db')
class User(UserMixin, Model):
"""This is the model for a user."""
email = CharField(unique=True)
password = CharField(max_length=35)
joi... | true |
689bccf38ffb84da91e66152a96cf8e9105ba878 | hsk-kr/community-comments-analyzer | /crawler/crawling/tools/http_tools.py | UTF-8 | 177 | 2.734375 | 3 | [] | no_license | import requests
def get_html(url):
"""
Return html source from the url, If there is an error, raise the error.
"""
res = requests.get(url)
return res.text
| true |
561c46caa6d965fc54c87e77be1334aefba078a2 | vol357/25_5 | /test_25_3.py | UTF-8 | 5,263 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
# to run
# cd C:\skill_factory\253\petsfriend_api_tests\tests
# py -m pytest -v --driver Chrome --d... | true |
4e0885e8cdfa1e00e678232918d1b96d97865310 | Davidxswang/leetcode | /medium/400-Nth Digit.py | UTF-8 | 1,212 | 3.9375 | 4 | [
"Apache-2.0"
] | permissive | """
https://leetcode.com/problems/nth-digit/
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
Note:
n is positive and will fit within the range of a 32-bit signed integer (n < 231).
Example 1:
Input:
3
Output:
3
Example 2:
Input:
11
Output:
0
Explanation:
The 11th digit ... | true |
d2b271e141f47b560c3df242d34cb0f04783def8 | szr712/SkipRope | /Analyse_Circle.py | UTF-8 | 3,725 | 2.984375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
def process(data):
"""
分圈,陀曼源码
:param data: 全部数据
:return:
"""
res = []
for line in data:
line = np.array(line)
line[6:] = line[6:] / 18000 * np.pi
sx = np.sin(line[6])
sy = np.sin(... | true |
a51752999f31e426237f0382cac728758c5c985a | sundnes/solving_odes_in_python | /docs/src/chapter5/SIR_class_v1.py | UTF-8 | 948 | 3.125 | 3 | [] | no_license | """
Class implementation of the SIR model. The model is exactly the
same as the function implementation in SIR_fun.py, but the
class implementation is more convenient for varying parameters.
"""
from ODESolver import RungeKutta4
import numpy as np
import matplotlib.pyplot as plt
class SIR:
def __init__(self, be... | true |
347f6be4a2938ea39a037cece5ea0171fb1cb39f | Batman001/leetcode_in_python | /array_relate/binary_search.py | UTF-8 | 1,165 | 4.09375 | 4 | [] | no_license | # -*- coding:utf-8 -*-
def search_matrix(matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
二分查找实现
step1: 先在第一列上二分查找,寻找目标值所在列
step2: 在目标列执行二分查找,判断target是否存在
"""
if matrix is None or matrix == [[]]:
return False
col = len(matrix)
left =... | true |
31fe51220de99f55c0970aa760cbbf27bf3e8c88 | NOVAPokemon/NOVAPokemon | /scripts/check_client_logs.py | UTF-8 | 745 | 2.828125 | 3 | [] | no_license | import sys
import os
def main():
args = sys.argv[1:]
if len(args) != 1:
print('Usage: python3 check_client_logs.py <client_logs_folder>')
exit(1)
client_logs_folder = os.path.expanduser(args[0])
for subfolder in os.listdir(client_logs_folder):
subfolder_path = os.path.join(c... | true |
8b5da94d3465cc6bff40747ba6f9b0aa2fc20753 | ridlonurrahman/cnn-playground | /alexnet/loss.py | UTF-8 | 598 | 2.984375 | 3 | [] | no_license | import tensorflow as tf
def loss(logits, labels):
""" Loss function
Args:
logits: Logits
labels: Targets
Returns:
Loss tensor.
"""
# Calculate the cross entropy.
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=labels, name='cross_entropy_per_exa... | true |
e7ed1ae3c6771528e3f79167b8500ca0310830e5 | kaisjessa/Project-Euler | /pe069.py | UTF-8 | 529 | 3.4375 | 3 | [] | no_license | import math
def prime_factors(x):
factors = []
current = 2
new_x = x
while current <= math.ceil(math.sqrt(x)+1):
if new_x % current == 0:
factors.append(current)
new_x = new_x / current
else:
current += 1
if(new_x != 1):
factors.append(int(new_x))
return list(set(factors))
def euler(n):
facts = ... | true |
0eab761dd0ddffea1808e36918fd0dc557c10ede | artheadsweden/python_oct_18 | /day1/immutable.py | UTF-8 | 272 | 2.75 | 3 | [] | no_license | def main():
x = 10
y = x
print(id(x))
print(id(y))
y += 1
print(id(x))
print(id(y))
l1 = [1,2,3]
l2 = l1
print(id(l1))
print(id(l2))
l2.append(4)
print(id(l1))
print(id(l2))
if __name__ == '__main__':
main()
| true |
2b644d014585f8cad838ed6b69438d4198964795 | zxf864823150/PAT_B | /pat1004.py | UTF-8 | 586 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env python3
number=eval(input('a number:'));
A=[];
B=[];
C=[];
D=[];
while number!=0:
name,schoolnumber,grade=map(str,input('name:,school:,grade:').split())
A.append(name);
B.append(schoolnumber);
C.append(grade);
number=number-1;
#print(A,B,C);
for i in range(0,len(C)):
a=eval(C[i])... | true |
592b76372d47ae2139e5edef7acb7e9e413875f8 | adeshpdelhi/MLProject2 | /generateROC.py | UTF-8 | 2,250 | 2.78125 | 3 | [] | no_license |
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import rand
# Generate ROC
def generate_roc(scoreMatrix,trueLabels,nROCpts =100 ,plotROC = 'false',title="ROC PLOT"):
tpr = np.zeros([1,nROCpts])
fpr = np.zeros([1,nROCpts])
nTrueLabels = np.count_nonzero(trueLabels)
nFalseLa... | true |
8c35185dd7945bce053fe9b1e2c996fd852126b4 | martiansideofthemoon/Algorithms-Practice | /counting_sort.py | UTF-8 | 617 | 3.625 | 4 | [] | no_license | #!/usr/bin/python
def counting_sort(arr=[],lower=0,upper=0):
counter=[]
for i in range(0,upper-lower):
counter.append(0)
for element in arr:
if element<lower or element>=upper:
print "Invalid Bounds!"
return arr
counter[element-lower]=counter[element-lower]+1
for i in range(1,upper-lower):
counter[i]=... | true |
92cf790ef5e8c7bcc61dc95bb6fd8bb98df8698e | aratik711/100-python3-programs | /95.py | UTF-8 | 583 | 4.28125 | 4 | [] | no_license | """
Determine if a word or phrase is an isogram.
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.
Examples of isograms:
lumberjacks
background
downstream
six-year-old
The word isograms, however, is not an ... | true |