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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8a601949c081b062055a27e792234bc455b070d9 | Python | ijhajj/RabbitMQ | /consumer_ack.py | UTF-8 | 1,082 | 2.65625 | 3 | [
"MIT"
] | permissive | import pika
from ConnectLocal import do_connect
def consuming_callback(ch, method, body):
message = body.decode()
if "reject" in message:
#setting basic_nack: "Not acknowledged" : implies message was not consumed
# And needs to be requeued, this can be turned On/OFF
#... | true |
ee7f19f5829f5e984b1a2c2e34ea2eee80a45ad6 | Python | vishwatejn/30DayChallenge | /Integer to Roman.py | UTF-8 | 477 | 4 | 4 | [] | no_license | # Integer to Roman
a = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"]
b = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
a = a[::-1]
b = b[::-1]
def convertRoman(n):
op = ""
for i in range(len(a)):
while n >= b[i]:
n -= b[i]
op += ... | true |
e3875b49050cf06ba1fb7c0a4ff82601ecad3487 | Python | oyasai8910/SourceCodes | /Recomendation.py | UTF-8 | 4,342 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import print_function
from pyspark import SparkContext
from pyspark.mllib.recommendation import ALS, MatrixFactorizationModel, Rating
from pyspark.mllib.evaluation import RegressionMetrics
import math
TRAIN = 8
VALIDATION = 0
TEST = 2
ADJUST = 10 - TRAIN - VALIDATION - TEST
SPLIT... | true |
c48df1c45fc8c495759b37963cf6d20e4a9a239c | Python | tepharju/Code1--Harjoitusteht-v-t | /CODE1_5_6_Collatz.py | UTF-8 | 338 | 3.34375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 27 10:17:17 2021
@author: tepha
Collatzin konjektuuri
"""
luku = int(input("Anna luku:"))
while luku > 0 and luku != 1:
if luku % 2 == 0:
luku = luku // 2
print(luku)
else:
luku = luku *3 +1
print(luk... | true |
1b29d4b8a684ddcdc166aadc38051f323695e88c | Python | wangweifeng2018/pyBAC | /removesingleton.py | UTF-8 | 1,191 | 3 | 3 | [] | no_license | import pysam
bam=pysam.Samfile("filter4-3.sorted.bam",'rb') #Load input file
bam_out = pysam.Samfile("filter4-4.bam", 'wb', template=bam) #Create output file
names=[] #Keep list of names to match to mate
output=[]
for read in bam.fetch(): #Loop over all reads in file
if read.is_duplicate == False: #Filter out P... | true |
aab6ac585ef5b16979dc30330b48391347697751 | Python | Im-Siyoun/algorithm-learning | /graph searching/BFS/2644.py | UTF-8 | 625 | 3.125 | 3 | [] | no_license | from collections import deque
n = int(input())
matrix = [[0]*(n+1) for _ in range(n+1)]
a, b = map(int,input().split())
for i in range(int(input())):
x, y = map(int,input().split())
matrix[x][y] = matrix[y][x] = 1
visit = [0]*(n+1)
queue = deque()
def BFS(start):
chone = 0
queue.append(start)
vis... | true |
3127354bbd290d3f3b1581e655ecb2bc431eb7c7 | Python | jithinsarath/python3basics | /fibonacci_03_memoization.py | UTF-8 | 540 | 4.09375 | 4 | [
"Unlicense"
] | permissive | # Implementing Memoization in An recursive function to improve performance
# reference https://towardsdatascience.com/memoization-in-python-57c0a738179a
fibonacci_cache = {}
def fibonacci(num):
if num in fibonacci_cache:
return fibonacci_cache[num]
if num == 1:
value = 1
elif num == 2:
... | true |
7c76229bb82ee09e23229ef789b560e687ee9423 | Python | ghdus4185/SWEXPERT | /N2115-1.py | UTF-8 | 688 | 3.546875 | 4 | [] | no_license | # 수도코드
# M개의 원소에서 1개 이상 최대 M개를 고르는 방법
M = 3
arr = [6, 1, 9]
# 비트연산을 활용한 부분집합 만들기
maxV = 0
for i in range(1, 2 ** M): # 이진수 생성
for j in range(M): # 0, 1, 2번 비트
s = 0 # 부분집합의 합
ss = 0
if i & (1 << j) != 0 and s + arr[j] <= c: # i 의 j번 비트가 1이고, 제한량 이하면
s += arr[j]
s... | true |
ac9f882dc03bcbf725863f49e8a3078045da9d8f | Python | Solomonwisdom/BasicTask | /section_two/python/leetcode/hard/longestconsecutivesequence/Solution.py | UTF-8 | 594 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | """
Solution class
problemId 128
@author wanghaogang
@date 2018/6/29
"""
class Solution:
def longestConsecutive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
length = len(nums)
if not nums or length == 0:
return 0
s = set(nums)
... | true |
d151cda9176e7e77964d6597f603ec08d711f60e | Python | optirg-39/webflask | /1. mysqlconnector/DDL_Commands.py | UTF-8 | 945 | 3.03125 | 3 | [] | no_license | ## import library
import mysql.connector
## first crete a mysql server on your system or in cloud
## creating connection with credentials
conn = mysql.connector.connect(host="localhost", user="root", passwd="password")
## create the cursor
mycursor = conn.cursor()
## creating the database
mycursor.execute("CREATE DA... | true |
e4ce0443f2eb99953ac599eec36fa92173ddbfa4 | Python | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4352/codes/1649_2711.py | UTF-8 | 499 | 3.375 | 3 | [] | no_license | # dinheiro total
v_disp = int(input("digite seu saldo: "))
# para o RU
quant_ru = int(input("digite quantos tickets de ru ce quer: "))
# valor dos tickets do RU
v_ru = float(input("digite o valor do ticket do ru: "))
# para os passes de onibus
quant_p = int(input("digite quantos passes ce quer: "))
# valor dos passes
v... | true |
274fb7b3eab8d75ea265fea07bc96579c4b82fcf | Python | MarkHershey/SATSolver | /2-SAT-Problem/src/cnf_parser.py | UTF-8 | 1,573 | 3.15625 | 3 | [] | no_license | from pathlib import Path
from typing import List, Tuple
from dgraph import DirectedGraph
Literal = int
Clause = Tuple[Literal]
def construct_implication_graph(cnf: str) -> DirectedGraph:
cnf = Path(cnf)
assert cnf.is_file()
formula: List[Clause] = parse_cnf_to_list(cnf)
implication_graph = Directe... | true |
9ae3f4b43764e689fa633b341b8bbcc2ba18d74b | Python | sucman/Python100 | /21-30/21.py | UTF-8 | 514 | 3.890625 | 4 | [] | no_license | # -*- coding:utf-8 -*-
'''
猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,
又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。
以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,
见只剩下一个桃子了。求第一天共摘了多少。
程序分析:采取逆向思维的方法,从后往前推断。
'''
x = 1
for day in range(9, 0, -1):
a = (x + 1) * 2
x = a
print x
| true |
f0555a43a5f9832021a78819c4ca6e50f4a1eef0 | Python | gouthamgopal/Twitter-Bot | /bots/config.py | UTF-8 | 811 | 2.5625 | 3 | [] | no_license | import tweepy
import logging
import os
from auth import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_SECRET
logger = logging.getLogger()
"""
To run the config file succesfully you need to generate the below 4 keys from the twitter developer account for the app.
Just reuse the variables, or replace them with th... | true |
b0bd918c1717b3cdbc887868171bc3268419d3d1 | Python | yanx27/DeepLearning-Study | /Keras_learning/2.初识神经网络.py | UTF-8 | 1,850 | 3.6875 | 4 | [] | no_license | ''' 第一个神经网络示例'''
'''加载 Keras 中的 MNIST 数据集'''
from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
'''网络架构'''
from keras import models
from keras import layers
network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))... | true |
469e81f2995eac651b91f92d65b3fd2e954bc43c | Python | lilharry/project_euler | /python/problem4.py | UTF-8 | 574 | 4.25 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def ispalindrome(n):
stringy = str(n)
stringybackwards = stringy... | true |
94f89d40e78d7e393ebc046f680a72cb8e90c3bb | Python | alok-upadhyay/BITS-mail-relay | /bits-mail.py | UTF-8 | 1,256 | 2.6875 | 3 | [] | no_license | #!C:\Python27\python.exe -u
#!/usr/bin/env python
import smtplib
print "You can send mail from any BITS Student ID to any other Student ID of the form f20XXYYY.\n"
sndr = raw_input("Enter the sender's email ID (f20XXYYY): ")
print
rcpt = raw_input("Enter the recepient's email ID (f20XXYYY): ")
sndr = sndr.__add__("@... | true |
f623c00432e3de5df8a207f101230269c70ebfda | Python | freephys/blog_examples | /python_multiprocessing_zeromq_vs_queue/multiproc_with_queue.py | UTF-8 | 570 | 2.921875 | 3 | [] | no_license | import sys
import time
from multiprocessing import Process, Queue
def worker(q):
for task_nbr in range(10000000):
message = q.get()
sys.exit(1)
def main():
send_q = Queue()
Process(target=worker, args=(send_q,)).start()
for num in range(10000000):
send_q.put("MESSAGE")
if __nam... | true |
57936e2d62b0cea71572bee7719f36d95879a835 | Python | susan025/myproj01 | /day01/day1_strUpLow.py | UTF-8 | 316 | 3.9375 | 4 | [] | no_license | if __name__ == '__main__':
str = "Gud Lak"
#将准备好的字符串转换成大写字符串
upperStr = str.upper()
print(upperStr)
#将准备好的字符串转换成小写字符串
lowerStr = str.lower()
print(lowerStr)
#字符串大小写转换-首字母大写
print(str.title()) | true |
eea5f5622694e053ba7341420a6be776b0c3a556 | Python | mayankmikin/ds_algo_prep | /Python 2019/Basics/countOccurence.py | UTF-8 | 163 | 2.96875 | 3 | [] | no_license |
if __name__ == '__main__':
a=input();
Out={}
for i in a:
if i in Out:
Out[i]+=1
else:
Out[i]=1
print(Out) | true |
d803d62da5614db7df1427977922fd2bb0000ef3 | Python | AronZeng/Internet-Traffic | /Data-Mining/Minning.py | UTF-8 | 7,423 | 2.75 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import plot_tree
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.tree import export_graphviz
from sklearn.m... | true |
3d33333fa636668a62bdf09661994cca1b6ab48e | Python | jag-prabhakaran/genetic-algorithm-for-stock-prediction | /.ipynb_checkpoints/nn-checkpoint.py | UTF-8 | 165 | 2.6875 | 3 | [] | no_license | import tensorflow as tf
mnist = tf.keras.datasets.mnist # (dataset of 28x28 images of handwritten digits 0-9)
(x_train, y_train), (x_test, y_test) = mnist.load_data | true |
cb153534555e62d1ad773ec541823d1fc519c7cd | Python | amoliu/gpplib | /GliderDataPython/ReadGliderLogfiles.py | UTF-8 | 5,237 | 2.59375 | 3 | [
"MIT"
] | permissive | import gpplib
from gpplib.Utils import *
import re
class GliderConsoleLogFileReader(object):
def __init__(self,**kwargs):
self.LocPattern = re.compile("[ ]*(GPS|DR)[ ]*(TooFar|Location|Invalid)[ :]+([0-9\\.\\-]*) N ([0-9\\.\\-]*) E.*")
self.SensorPattern = re.compile("[ ]*sensor:[ ]*([a-z_]+)(?:\\(... | true |
d193c06ad6135d7989f4f3586d39db29734cb759 | Python | SecondToGod/machine-learning | /CV/cvthreshold.py | UTF-8 | 1,674 | 2.78125 | 3 | [] | no_license | import cv2
import matplotlib.pyplot as plt
import numpy as np
img = cv2.imread('./test.jpg',0)
ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)
ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)
ret,thresh3 = cv2.threshold(img,127,255,cv2.THRESH_TRUNC)
ret,thresh4 = cv2.threshold(img,127,255,cv... | true |
d1f80ebc890605a60df958f1678ad176c603a632 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_121/186.py | UTF-8 | 630 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python
n=int(raw_input())
def solver(fulle,e,r,n,v):
max=0
if n==1:
return e*v[0]
else:
tempi=0
for i in xrange(0,e+1):
if e-i+r>=fulle:
temp = solver(fulle,fulle,r,n-1,v[1:])+i*v[0]
else:
temp = s... | true |
1670c52ac96e3693011daf8e49b9d0a3971cd9fb | Python | Aasthaengg/IBMdataset | /Python_codes/p02260/s739885042.py | UTF-8 | 407 | 3.265625 | 3 | [] | no_license | def selection_sort(A):
swap = 0
for i in range(len(A)):
minj = i
for j in range(i,len(A)):
if A[j] < A[minj]:
minj = j
if minj != i:
A[i],A[minj] = A[minj],A[i]
swap += 1
return swap
if __name__=='__main__':
N=int(input())
A... | true |
e9c2222c8c584dabd6ce65202850ab91dbecd2a0 | Python | geoxliu/Python_Crash_Course_all | /part_2/name_cases.py | UTF-8 | 841 | 3.515625 | 4 | [] | no_license | full_name = "eric"
message = "Hello " + full_name + "," + "would you like to learn some Python today?"
print(message)
full_name = "eric"
message = "Hello " + full_name.title() + "," + "would you like to learn some Python today?"
print(message)
full_name = "eric"
message = "Hello " + full_name.upper() + "," + "would y... | true |
b8b251cf13b8fda630910dd4a531d38831c2460e | Python | TamNguyenVanTam/ReinforcementLearning | /source/models/framework/actor_critic.py | UTF-8 | 2,712 | 2.75 | 3 | [] | no_license | """
Defining Actor Critic Framework
Authors: TamNV
===============================
"""
import tensorflow as tf
import tensorflow.contrib.slim as slim
class ActorCritic:
"""
Actor Critic Framework
"""
def __init__(self,
num_obser_dim,
num_action_dim,
act_backbone,
cri_backbone):
"""
Initial Meth... | true |
855d11f7e9fd59425b0cb48dea2b53a859e40591 | Python | quinkennedy/generative-zine-invite | /script_zine/mixed_test.py | UTF-8 | 647 | 2.875 | 3 | [] | no_license | #!/usr/bin/env python
from xml.parsers import expat
generative = []
elem_stack = []
def start_element(name, attributes):
if name == 'var' and elem_stack[-1] == 'command':
generative[-1] += attributes['key'].upper()
elif name == 'command':
generative.append('')
elem_stack.append(name)
def end_element(name):
... | true |
dca53d7aef775786b56616b95e5747394f0dd738 | Python | jakkularamesh/Innomatics_Internship_APR_21 | /Day 2/Set .union() Operation.py | UTF-8 | 196 | 2.875 | 3 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
n1=set(input().split())
m=int(input())
m1=set(input().split())
u=n1.union(m1)
print(len(u))
| true |
8a42eae59a7871d231b3735a35f442dc565d9291 | Python | roadworrier/s_tools | /skyptool.py | UTF-8 | 5,034 | 2.640625 | 3 | [] | no_license | #!/usr/bin/python
#
# This started out as the code from
# https://pentesterscript.wordpress.com/2013/08/07/extract-contacts-call-log-message-from-skype-database/
# which required some indentation, and then some other snippets were added to make this do what I needed:
# List the date, time, duration of all skype c... | true |
1bed2c4c594e17a90f3fe5153affd68aee7f34d5 | Python | michael-lennox-wong/CS50W-Projects | /Project3/add_menu_items.py | UTF-8 | 3,251 | 2.625 | 3 | [] | no_license | from orders.models import Salad, Pasta, DinnerPlatter, Sub1, Sub2, Pizza
from orders.models import MenuItem
for x in Salad.SALAD_CHOICES:
f = Salad(salad_type=x[0])
f.save()
for x in Pasta.PASTA_CHOICES:
f = Pasta(pasta_type=x[0])
f.save()
for platter in DinnerPlatter.DINNER_PLATTER_CHOICES:
for s... | true |
a78b94962b0930abb59efdfeeaf85ad21acc86f6 | Python | doshmajhan/Xenoblast | /receiver.py | UTF-8 | 4,902 | 3.453125 | 3 | [] | no_license | import bitarray
import time
from unitcomp import unitcomp
THRESHOLD = 0.009
"""
Run unit comp 100 times to establish
the average amount of time it should take to run
returns the average time taken to run unitcomp
"""
def initialization():
count = 0
total_time = 0
while(count < 100):
... | true |
3f74bb7d27bc9d1b89aa57792042ea8de9e6f542 | Python | murali-kotakonda/PythonProgs | /PythonBasics1/exception1/TestEx22.py | UTF-8 | 182 | 2.875 | 3 | [] | no_license | a = False
try:
while not a:
f_n = input("Enter file name")
i_f = open(f_n, 'r')
except:
print("Input file not found")
print("Bye")
| true |
0aca5d152a04dbacf92d3507594764130f330e63 | Python | Chouffe/az | /services/data_handling.py | UTF-8 | 2,988 | 2.828125 | 3 | [] | no_license | import numpy as np
import utils
def api_preprocess_datapoint(data):
ddata = data.copy()
result = ddata.pop('result')
return result, ddata
# TODO: Test it
def dataset_to_matrix(schema, dataset):
"""Given a schema and a dataset, it returns the
training set and target set for the ml fitting
eg.... | true |
d6e8c69afc073014ce0cc1854ebf9139e3ee82a9 | Python | pighaddt/ITRI_BTconnect | /venv/TouchTaiwan_BT.py | UTF-8 | 878 | 2.734375 | 3 | [] | no_license | import bluetooth
###
target_name = "LAIRD BL654-CD8A74"
target_address = "f00f06cd8a74" # Touch Taiwan Device ()
nearby_devices = bluetooth.discover_devices()
print(nearby_devices)
print()
for bdaddr in nearby_devices:
if target_name == bluetooth.lookup_name(bdaddr):
target_address = bdaddr
break... | true |
00cbc7ad4f8a3c547408b7dc50d8c069e3c4054d | Python | tmajest/project-euler | /python/p41/prime_tools.py | UTF-8 | 469 | 3.921875 | 4 | [] | no_license | # Contains prime generator functions
import math
def primes_up_to(num):
""" Prime sieve: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Implementation """
primes = [True for i in xrange(num)]
primes[0] = False
primes[1] = False
for i in xrange(2, int(math.sqrt(num) + 1)):
if primes[i]... | true |
5538687b79e28796bbefa2671f70a872f23619b3 | Python | alaadhami/spmblackjack | /blackjack_gui.py | UTF-8 | 18,989 | 2.8125 | 3 | [] | no_license | import tkinter as tk
from tkinter import *
from cards import *
from gameplay import *
from player import *
import random
TITLE_FONT = ("Arial", 30, "bold")
class BlackJackUI(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.minsize(self, 400, ... | true |
e260d89de7f309ea34d9348e61acfce8cb6fc320 | Python | Jawmo/Hope | /engine/admin.py | UTF-8 | 7,479 | 2.75 | 3 | [
"MIT"
] | permissive | from engine.global_config import *
import psycopg2
from config import config
import json
class Admin_Commands():
def __init__(self, name):
self.name = name
def fill_db():
insert_item = """INSERT INTO items(uuid_id, name, item_desc, base_type, size, weight, capacity, can_attributes, room_targe... | true |
6aebe609a6acb0535a41418d3a1ba43cc937f1d9 | Python | fursovia/chatbot_game | /chatgame/classifiers/classifier.py | UTF-8 | 2,346 | 2.578125 | 3 | [] | no_license | from typing import Union, Optional, Tuple
import torch
DISCRIMINATOR_MODELS_PARAMS = {
"clickbait": {
"path": "models/clickbait_classifier_head.pt",
"class_size": 2,
"embed_size": 1024,
"class_vocab": {"non_clickbait": 0, "clickbait": 1},
"default_class": 1,
"pretra... | true |
98454d99e0284ae1c26a72e4d95e93bda4fb8298 | Python | fnsisdabast/nuc_bot_remote | /nuc_bot_remote/laser_scan_printer3.py | UTF-8 | 2,069 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
import rospy
import numpy as np
from std_msgs.msg import Float32MultiArray
from sensor_msgs.msg import LaserScan
def laser_callback(scan):
depths = []
for dist in scan.ranges: #get all of the depths from laser scanner
depths.append(dist)
depth_octants=[]
... | true |
7353b111bfa7b8510638b639d455a283669eeb04 | Python | 1224667889/ML_Task | /lesson_5/session_3.py | UTF-8 | 2,336 | 2.765625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.decomposition import PCA
from sklearn.model_selection import train_test_split
import utils
import time
from sklearn.neighbors import KNeighborsClassifier as KNN
if __name__ == '__... | true |
1d69c7c59c769d8d8fde5375cc574fbbfdc39eb3 | Python | zjhmale/bfx-hf-indicators-py | /bfxhfindicators/stochastic.py | UTF-8 | 1,966 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | from bfxhfindicators.indicator import Indicator
from bfxhfindicators.sma import SMA
class Stochastic(Indicator):
def __init__(self, period, smoothK, smoothD, cache_size=None):
self._p = period
self._buffer = []
self._kSMA = SMA(smoothK, cache_size)
self._dSMA = SMA(smoothD, cache_s... | true |
354af68311dc73f144ad529417f3d7db48b1fd61 | Python | kyrilkhaletsky/CA117-Programming | /Exercises/test.py | UTF-8 | 64 | 2.953125 | 3 | [] | no_license | n = list(range(15))
q = [c for c in n if c % 3 == 0]
print(q)
| true |
61e0608c9d518dfe4439e63901857a127fc59e70 | Python | smeets/thesis | /scripts/mdrparser.py | UTF-8 | 1,950 | 2.953125 | 3 | [] | no_license | from xml.dom import minidom
from datetime import datetime
def getText(nodelist):
rc = []
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc)
# 2019-01-17T14:33:21.738
# yyyy-mm-dd HH:MM:SS.N
class MdrParser:
""""""
def __init__(sel... | true |
3c45ff268112943fcefaf31bf191bdd90eb2f2ea | Python | lidongyin0212/be-atp | /public/database/mysql_api.py | UTF-8 | 3,475 | 2.8125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
# 导入mysql库
import pymysql
import os
class MySQLObj(object):
def __init__(self, host, port, user, password, db):
self.host = host
self.port = port
self.user = user
self.password = password
self.db = db
self.conn, self.cursor = None, None
... | true |
aa390b2e521d804333f94ea41b95fb5d02c8ce5a | Python | juantor16/Python | /Calculate_kinetic_energy.py | UTF-8 | 576 | 3.859375 | 4 | [] | no_license | # Calculate Kinetic Energy
print "this program calculates the kinetic energy of a moving object."
m_string = input ("Enter the object's mass in Kilograms: ")
m=float(m_string)
# m_string = input ("Enter the object's mass in Kilograms: ")
# m=float(m_string)
# is equal to:
#m_string = float(input ("Enter the object's m... | true |
b47eee704efddac2a0d6deb05a1273850b4bbe7c | Python | ryosuke0825/atcoder_python | /ABC_C/ABC172_C.py | UTF-8 | 611 | 2.5625 | 3 | [
"MIT"
] | permissive | import itertools
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
aa = [0] + list(itertools.accumulate(A))
bb = [0] + list(itertools.accumulate(B))
ans = bisect.bisect_left(aa, K)-1
ans = max(ans, bisect.bisect_left(bb, K)-1)
for i in reversed... | true |
f2e99d8b270e434aeb3cb242b37f511bb75a55bc | Python | madhavambati/Convolutional-Neural-Network-with-Numpy | /model/functions.py | UTF-8 | 9,440 | 3.234375 | 3 | [
"MIT"
] | permissive | import numpy as np
import gzip
'''
This file contains all the essential functions that are used in the network '''
''' Getting data '''
#Extract images by reading the file bytestream.
#Reshape the read values into a 2D matrix of dimensions [n, h*w]
def extract_data(filename, num_images, IMAGE_WIDTH):
... | true |
9b413b2d5b2d809e3f548ed780af84eaa831396e | Python | madhu74/deconst-openapi-preparer | /tests/test_tocbuilder.py | UTF-8 | 7,632 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
'''
test_tocbuilder
----------------------------------
Tests for `tocbuilder` module.
'''
import unittest
import subprocess
import sys
import os
import re
from os import path
from bs4 import BeautifulSoup
sys.path.append(path.join(path.dirname(__file__), '..'))
from openapipreparer.builders.t... | true |
577a9945956cbc1e29c668adbb1981d87afda2c5 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2445/60595/238455.py | UTF-8 | 777 | 3.171875 | 3 | [] | no_license | def Test():
s=input()
s=s.replace("s"," ")
s=s.replace("t"," ")
s=s.replace("\""," ")
s=s.replace("="," ")
s=s.replace(" ","")
q=s.split(",")
word1=q[0]
word2=q[1]
maps1=[]
maps2=[]
if(len(word1)!=len(word2)):
print("false")
else:
for i in range(0,128)... | true |
fea97795460b620cb401ec167efeaa90090bfff9 | Python | agentnova/LuminarPython | /Luminaarpython/Multitasking/pgm3.py | UTF-8 | 524 | 2.90625 | 3 | [] | no_license | from threading import *
class Mythread(Thread):
def run(self):
for i in range(1,10):
print(i)
print(current_thread().getName())
t=Mythread()
t.start()
for i in range(1,10):
print(i)
print(current_thread().getName())
# after connecting print connect:[clnt name]
# then message sen... | true |
fe0715726349b293c3053026901ba530b7ebfa6b | Python | HenryBalthier/digger | /MY_digger/riskctl.py | UTF-8 | 785 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import csv
class Riskctl(object):
def __init__(self):
self.cts = {
'code': 0,
'exchange': 1,
'name': 2,
'spell': 3,
'long_margin_ratio': 4,
'short_margin_ratio': 5,
'price_tick': 6,
'vo... | true |
734024bf4aca1ace692402d5968508fa39e5faba | Python | NatashaMiyaguti/Projeto5_Blue | /classes/personagemCao.py | UTF-8 | 3,227 | 3.46875 | 3 | [] | no_license | from sys import exit
from fases.fases import fase1
from auxiliar.funcoes_auxiliares import final
from classes.relogio import Relogio
from classes.carrocinha import Carrocinha
def gameOver():
print('Game Over!')
final()
reiniciar = input('Gostaria de jogar novamente (s/n)? ')
if reiniciar == 's':
... | true |
8fa77f4f3b4e6600a278839002f71355bbaa13c2 | Python | q-riku/algorithm | /19-3-1 Problem03-1.py | UTF-8 | 1,882 | 3.71875 | 4 | [] | no_license | """
#1 from LeetCode
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,... | true |
0d09c4aaf3a2e4d633e891e21f329bfdcf74c4bd | Python | irissooa/Algorithm-with-Python | /Baekjoon/스택큐/BOJ_10828_스택.py | UTF-8 | 1,021 | 4.15625 | 4 | [] | no_license | '''
정수를 저장하는 스택,
스택은 LIFO(마지막에 들어간것이 먼저나감)
push X : X를 스택에 넣는 연산
pop : 스택에서 가장 위에 있는 정수를 빼고, 그 수를 출력, 만약 스택에 들어있는 정수가 없는 경우 -1 출력
size : 스택에 들어있는 정수의 개수 출력
empty : 스택이 비어있으면 1, 아니면 0 출력
top : 스택의 가장 위에 있는 정수 출력, 만약 없으면 -1
'''
import sys
input = sys.stdin.readline
N = int(input())
stack = []
for _ in range(N):
orde... | true |
c09f6a251f15f790fab19bfb5184baccc7e69d62 | Python | sunsun1001/NASA_Weibull | /weibullDist.py | UTF-8 | 1,167 | 3.15625 | 3 | [] | no_license | import numpy as np
import pylab as pl
import scipy.special as ss
import matplotlib.pyplot as plt
# a=scale parameter b=shape parameter mew=x(variable)
def weib(a,b,mew):
e1 = (b/a)
e2 = ((mew/a)**(b-1))
e3 = np.exp((-(mew/a)**b))
return e1*e2*e3
def plot_weib(a,b,xmin,xmax):
Ly = []
... | true |
ae6f01ca2a94da6d1c2038c0e7f6263bf6c7a04b | Python | pythrick/drf-cli | /cookiecutters/project/{{cookiecutter.module_name}}/{{cookiecutter.module_name}}/apps/user/managers/user.py | UTF-8 | 652 | 2.75 | 3 | [
"MIT"
] | permissive | from django.contrib.auth.base_user import BaseUserManager
from django.db import transaction
class UserManager(BaseUserManager):
@transaction.atomic
def create_user(self, name: str, email: str, password: str, **kwargs):
user = self.model(name=name, email=email, **kwargs)
user.set_password(passw... | true |
b1e70af0bca989832f5ca113ca214cd18f2f9803 | Python | gshreve01/covid19-flask | /covid19/models.py | UTF-8 | 5,147 | 2.65625 | 3 | [] | no_license | from django.db import models
# Create your models here.
class State(models.Model):
geocodeid = models.IntegerField("Geographic Code Identifier",primary_key=True)
name = models.CharField("State Name", null=False, max_length=100, unique=True)
abbreviation = models.CharField("State Abbreviation", null=False,... | true |
5b4eb891a56836c7ed5187d4b8b3b0847519acc2 | Python | AlexKotl/stepik-python-lessons | /3/books_advanced.py | UTF-8 | 1,233 | 3.21875 | 3 | [] | no_license | from books import *
class AdvancedPerson(Person):
def __init__(self, name):
super().__init__(name)
def search(self, book, name_page):
return book.search(name_page)
def read(self, book, page):
if isinstance(page, int):
return super().read(book, page)
els... | true |
d77f13de00222d02eb4e53f873dc73e02b01f0e6 | Python | josemscnogueira/disparitypy | /disparitypy/__main__.py | UTF-8 | 592 | 2.796875 | 3 | [] | no_license | import argparse
import sys
from .comparators.comparator import UComparator
"""
Definition of the main function body
"""
def main():
"""
Argument parsing and initial test
"""
parser = argparse.ArgumentParser('disparity')
parser.add_argument('folder1')
parser.add_argument('folder2')
... | true |
8916213d2ad46dbb262c6ae1c921e60040c69d78 | Python | rajivs15/set_6 | /countKinlist.py | UTF-8 | 154 | 2.71875 | 3 | [] | no_license | N,K=map(int,(input().split()))
m=list(map(int,input().split()))
count=0
if len(m)==N:
for i in range (0,N):
if m[i]==K:
count=count+1
print (count)
| true |
19b3bf62ba0d7133bb8fc73838f360bd4bffb750 | Python | Kaitlyn0712/CS106A-Stanford | /lectures/21-Practice/raw/process.py | UTF-8 | 1,377 | 2.921875 | 3 | [
"MIT"
] | permissive | import csv
NUM_YEARS = 216
IGNORE = set([
'Dominica',
'Monaco',
'Andorra',
'Turks and Caicos Islands',
'San Marino',
'Bermuda',
'Nauru',
'Cayman Islands',
'Palau',
'Tuvalu',
'St. Kitts and Nevis',
'Marshall Islands',
'Martinique',
'Guam',
'French Polynesia',
'Western Sahara',
'Virgin Islands (U.S.)',
... | true |
c7dc0d5cf67878bcdd281f91b248c0341265dff5 | Python | ThomasWilshaw/edlReader | /edl_reader.py | UTF-8 | 3,694 | 2.890625 | 3 | [] | no_license | #TODO:
#Clean EDL
#Recognise EDL features
#
import helper, os, sys, getopt
import edl as edlImp
def isInt(s):
#suppresses vlue errors
try:
int(s)
return int(s)
except ValueError:
pass
def getPaths(path):
#gets path to all mov's in folder
paths = []
extensions = tuple... | true |
868f372e93cac47c257c7bf3fe809aba29a0a107 | Python | tlestang/PyBaMM | /pybamm/models/submodels/electrolyte_diffusion/leading_order_diffusion.py | UTF-8 | 3,698 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | #
# Class for leading-order electrolyte diffusion employing stefan-maxwell
#
import pybamm
from .base_electrolyte_diffusion import BaseElectrolyteDiffusion
class LeadingOrder(BaseElectrolyteDiffusion):
"""Class for conservation of mass in the electrolyte employing the
Stefan-Maxwell constitutive equations. (... | true |
dc69e45bae0c7e9cddd03aecaeebf76bc604296f | Python | mcsheehan/RobotChallenge | /test/robot/command_parser_tests.py | UTF-8 | 2,239 | 2.828125 | 3 | [] | no_license | import unittest
from robot_challenge import CommandParser
from robot_challenge.robot_direction import RobotDirection
class CommandParserTests(unittest.TestCase):
def test_empty_string_returns_nothing(self):
test_input = ""
expected_output = []
result = CommandParser.process_string(test_... | true |
28d6ae9b1bbdc8d1e16bc761db280ea0a88689e7 | Python | Rurril/IT-DA-3rd | /study/Ace/VCWeek4/BOJ_17144_권순규.py | UTF-8 | 2,448 | 2.65625 | 3 | [] | no_license | def spread():
global dust
tmp_dust = [[0] * C for _ in range(R)]
for y in range(R):
for x in range(C):
if dust[y][x] > 0:
n = 4
for i in range(4):
ny = y + dy1[i]
nx = x + dx1[i]
if ny < 0 or nx <... | true |
46c3c682a75a384dca193eb949901ed789814cb9 | Python | saurabhsood91/advent-of-code | /one.py | UTF-8 | 356 | 3.734375 | 4 | [] | no_license | from math import floor
def get_fuel_required(mass: int):
fuel = floor(mass / 3) - 2
if fuel <= 0:
return 0
return fuel + get_fuel_required(fuel)
if __name__ == '__main__':
total_fuel = 0
file = open('fuel.txt')
for line in file:
mass = int(line)
total_fuel += get_fuel_required(mass)
print("... | true |
dfb31c58548c3e6345d260d8e10090b63033361d | Python | ShwethaDeepak/Text_Summarization | /TEXt Summarization.py | UTF-8 | 2,075 | 3.25 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 5 15:43:49 2019
@author: swetu
"""
#creating an article summarization
import bs4 as bs
import urllib.request
import re
import nltk
nltk.download('stopwords')
import heapq
#Getting data
Source =urllib.request.urlopen('https://en.wikipedia.org/wiki... | true |
cf2a9f2a00518cdf39ed90b0a725a97bf72c8bbd | Python | Ragul-SV/Data-Structures-and-Algorithms | /Array/Easy II/Maximum No. of 1s (Sliding Window).py | UTF-8 | 483 | 2.828125 | 3 | [] | no_license | t = int(input())
for cases in range(t):
n = int(input())
arr = list(map(int,input().strip().split()))
m = int(input())
wL,wR = 0,0
res = 0
zero_count = 0
while wR<n:
if zero_count<=m:
if arr[wR]==0:
zero_count+=1
wR+=1
if zero_count>m:
... | true |
08c6a9d9701723c2e7a3a7af8bab76a33ffea630 | Python | 1allan/tower-of-bullets | /TowerofBullets/scenery/room.py | UTF-8 | 6,292 | 2.703125 | 3 | [] | no_license | import os
import pygame
from random import randint, choice
from util.functions import load_image
from .tile import Tile
from character.enemy import Enemy
from items.item import Item
class Room(pygame.sprite.Sprite):
def __init__(self, surface: pygame.Surface, position: tuple, size: tuple,
ar... | true |
9fea0bf00091806a8e2fe15da0008c1f95fa1421 | Python | Altison/code_1021 | /main.py | UTF-8 | 1,146 | 2.703125 | 3 | [] | no_license | k = 0
value = False
def on_button_pressed_a():
global k
for I in range(19):
k = min(18 - I, I)
for j in range(5):
if I == 9:
basic.pause(1000)
break
elif I < 9:
led.plot(4 - j, 4 - (k - j))
else:
... | true |
a88f0f9b1ca1566cdd45a7e3636c34f6f9e3d9e3 | Python | abandonsea/RandPerson | /generateCode/cc1_createCorlor.py | UTF-8 | 1,193 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | # *********************
# Generate 625 colors
# *********************
from PIL import Image
import math
def hsv2rgb(h, s, v):
h = float(h)
s = float(s)
v = float(v)
h60 = h / 60.0
h60f = math.floor(h60)
hi = int(h60f) % 6
f = h60 - h60f
p = v * (1 - s)
q = v * (1 - f * s)
t = v ... | true |
4d1c6dbfede5d835f47f80b8c28bb76e31d7cf53 | Python | dsteinmo/AdventOfCode-2020 | /day4/num_valid_passports.py | UTF-8 | 6,425 | 3.515625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/python3
class Passport:
# Props:
# byr (Birth Year)
# iyr (Issue Year)
# eyr (Expiration Year)
# hgt (Height)
# hcl (Hair Color)
# ecl (Eye Color)
# pid (Passport ID)
# cid (Country ID, optional)
def __init__(self, byr, iyr, eyr, hgt, hcl, ecl, pid, cid):
sel... | true |
65e9e434fb9c44e542e3cf7eb6bb3dcf6340437a | Python | kevinjycui/Competitive-Programming | /Python/DMOJ/art0.py | UTF-8 | 325 | 3.90625 | 4 | [] | no_license | n = int(input())
vowels = ['a', 'e', 'i', 'o', 'u']
words = ['Hi! ', 'Bye! ', 'How are you? ', 'Follow me! ', 'Help! ']
for i in range(n):
s = input().lower()
ans = ''
for c in s:
if c in vowels:
ans += words[vowels.index(c)]
elif c.isdigit():
ans += 'Yes! '
print... | true |
c6b9826a3907261e0f92935c0e9081405e6a250a | Python | Stefanh18/python_projects | /test/q3.py | UTF-8 | 256 | 3.6875 | 4 | [] | no_license | first = int(input("Initial value: "))
steps = int(input("Steps: "))
sum_of_series = 0
count2 = first
while count2 <= 100:
print(count2, end= ' ')
sum_of_series += count2
count2 += steps
print(" ")
print("Sum of series: ", sum_of_series)
| true |
8f7c4c7279a7c1b7293fe5a15ceaab07d93d35ae | Python | tea1013/google_brain_ventilator_pressure_prediction | /teads/util/params.py | UTF-8 | 291 | 2.78125 | 3 | [] | no_license | import pickle
from typing import Dict
class Params:
def dump_dict(d: Dict, path: str) -> None:
with open(path, "wb") as f:
pickle.dump(d, f)
def load_dict(path: str) -> Dict:
with open(path, "rb") as f:
d = pickle.load(f)
return d
| true |
8eb19b369146fb5ddefe563e5ff70985095fbbfb | Python | GavinAlison/python-learning | /requestss/fetch_qsbk2.py | UTF-8 | 6,210 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-01-03 22:46:00
# @Author : alison
# @File : fetch_qsbk2.py
# 备注: urllib2在python3.x版本里面,与urllib合并,以后导入urllib2,=import urllib.request
# 环境: python3.7.0
# 工具: pycharm2018.3
import urllib
import urllib.request
import re
## 设计面向对象模式
# page = 1
# ur... | true |
a9cb1f45b1a82647b65fcf04e0d07fb4870a7227 | Python | loerac/crypto-hodl | /hodl.py | UTF-8 | 5,153 | 2.6875 | 3 | [] | no_license | import config
import gspread
import json
import pandas as pd
import pickle
import redis
import streamlit as st
import validationNormalization as vnorm
import zlib
from crypto_api import IEX
from oauth2client.service_account import ServiceAccountCredentials
# Google Spreadsheets
scope =['https://spreadsheets.google.com... | true |
313eae700ef2d87f9d2bef4b8be3af5280b89787 | Python | gelizondomora/python_basico_2_2019 | /Semana 1/practica_2.py | UTF-8 | 298 | 3.546875 | 4 | [] | no_license | # Esta es al practica para escribir dos lineas
# en consola
"""
Comentario de multiples lineas
util para explicar mas detalles
"""
print("Hola a todos!")
print("buenos dias")
#Varias lineas en un solo print
print("mi primera linea \nmi segunda linea")
print("hola de nuevo") | true |
a866a5fa90c3a5a59abac228ca8e19a45f091af0 | Python | liupy525/Pythontip-OJ | /16_renminbi_example_ck.py | UTF-8 | 6,095 | 3.625 | 4 | [] | no_license | # !/usr/bin/env python
# -*- coding: utf-8 -*-
'''
注明:数据已于2013-11-19日加强,原来通过的代码可能不能再次通过。
注意:由于中文乱码问题,输出时请先decode("utf8"),例如你要输出ans = "零圆", print ans.decode("utf8").
银行在打印票据的时候,常常需要将阿拉伯数字表示的人民币金额转换为大写表示,现在请你来完成这样一个程序。
在中文大写方式中,0到10以及100、1000、10000被依次表示为:
零壹贰叁肆伍陆柒捌玖拾佰仟万
以下的例子示范了阿拉伯数字到人民币大写的转换规则:
1 壹圆
11 壹拾壹圆
111... | true |
cd7e3582f308d417b98d7b49a427c9011a8f2b42 | Python | ccnmtl/django-oembed | /oembed/tests.py | UTF-8 | 1,324 | 2.78125 | 3 | [
"BSD-3-Clause"
] | permissive | from __future__ import unicode_literals
from django.test import TestCase
from oembed.core import replace
class OEmbedTests(TestCase):
fixtures = ['initial_data.json']
noembed = r"This is text that should not match any regex."
end = r"There is this great photo at %s"
start = r"%s is a photo that I lik... | true |
a0658a310b2b5dd3159a9edc75e71171ea9275e2 | Python | in-toto/apt-transport-in-toto | /tests/measure_coverage.py | UTF-8 | 1,049 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python3
"""
<Program Name>
measure_coverage.py
<Author>
Lukas Puehringer <lukas.puehringer@nyu.edu>
<Started>
December 21, 2018.
<Purpose
Shim to setup code coverage measurement for a Python script executed
in a subprocess.
Requires an environment variable COVERAGE_PROCESS_START that points t... | true |
88f2c7b3c1191c9f23ff3865a4423692cb23eaeb | Python | mad3310/galera-manager | /galera-manager/utils/randbytes.py | UTF-8 | 284 | 2.875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import os
import binascii
from base64 import b64encode
def randbytes(bytes):
"""Return bits of random data as a hex string."""
return binascii.hexlify(os.urandom(bytes))
def randbytes2(bytes=16):
return b64encode(randbytes(bytes)).rstrip('=')
| true |
057c3a81241835dfc3feca40e5b30001a9638af8 | Python | muondu/Hotel-sytem | /tryal.py | UTF-8 | 312 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | from everything_db import *
def insert():
pass
# c.execute('INSERT INTO hotel_rooms VALUES(30)')
def delete():
num = 15
with conn:
c.execute('DELETE FROM hotel_rooms WHERE hotelnumber = ?',(num,))
c.execute('SELECT * FROM hotel_rooms')
print(c.fetchall())
delete() | true |
1aa6991bd1bc6b65215583e3b88a0fe46889649a | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_117/1412.py | UTF-8 | 1,920 | 2.578125 | 3 | [] | no_license | filename = "B-large.in" # change later
f = open(filename)
T = int(f.readline())
for case in range(1,T+1):
s = f.readline()
tmp = s.split()
N = int(tmp[0])
M = int(tmp[1])
lawn = {}
for i in range(N):
s = f.readline()
s = map(int, s.split())
for j in range(M):
... | true |
4d471084b71d4d07d9b1bc6f11a4e5ba65cf7d9b | Python | youfeng243/hackerearth | /Xsquare And Two Arrays/Xsquare And Two Arrays.py | GB18030 | 2,414 | 2.984375 | 3 | [] | no_license | #coding=utf-8
def SumA( startA, endA ):
if startA == endA:
return A[startA]
if startA > endA:
return 0
#ż
if startA % 2 == 0:
if startA == 0:
return eveA[endA]
return eveA[endA] - eveA[startA - 2]
if startA == 1:
return oddA[endA]
re... | true |
659038b1a71205ec2dae7e7f2487e9fc81edcef1 | Python | Kraming-linux/arnor | /com vison/class two.py | UTF-8 | 1,559 | 3.359375 | 3 | [] | no_license | import cv2
import numpy as np
def assess_pictutre(iamge): # 遍历数组的每个像素点
print(iamge.shape)
heigh = iamge.shape[0] # 形状的第一维度(高度)
width = iamge.shape[1] # 第二维度(宽度)
channel = iamge.shape[2] # 通道数
print("heigh", heigh)
print("width", width)
print("channel", channel)
def ... | true |
d8dfca241d4e289253da036500492b8d41900bf1 | Python | lk-greenbird/costar_plan | /costar_task_plan/tests/sampler_test.py | UTF-8 | 2,138 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
import unittest
import keras.losses as l
import keras.backend as K
import numpy as np
from costar_models import SamplerLoss
class SamplerLossTest(unittest.TestCase):
def test1(self):
A = np.array([[0,1,0],[1,0.7,0.5]]).T
B = np.array([[0.001, 1.002, 0.01],[0.001, 0.002, 2.0... | true |
a365db39d07fd7ba358d74ba59e9d21df8ff88f9 | Python | minrivertea/laowailai | /questions/split_search.py | UTF-8 | 1,208 | 3.203125 | 3 | [] | no_license | #-*- coding: iso-8859-1 -*
##
## Split search string - Useful when building advanced search application
## By: Peter Bengtsson, mail@peterbe.com
## May 2008
## ZPL
##
__version__='1.0'
"""
split_search(searchstring [str or unicode],
keywords [list or tuple])
Splits th... | true |
0f00c3ee7216ea806a61d16a9f77f481f8035c6e | Python | honzabilek4/artificial-intelligence-examples | /2.5.1_10.py | UTF-8 | 830 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env python
# encoding=utf-8 (pep 0263)
from linked_lists import LinkedList, Cons, Nil
def append(xs, ys):
if xs == Nil:
return ys
else:
return Cons(xs.head, append(xs.tail, ys))
def qsort(xs):
if xs == Nil:
return Nil
if xs.tail == Nil:
return xs
ms, vs ... | true |
d62d06b3205eafb58563670844cafe3bf9441a2f | Python | saurabh11308/aws-team3 | /lambda.py | UTF-8 | 1,225 | 4.5 | 4 | [] | no_license | #!/usr/bin/python
# Lambda function example
print("\nExample Program 1 - Anonymous Function Lambda\n")
total = lambda s1,s2,s3,s4,s5:s1+s2+s3+s4+s5
#Now call total as a function
print("Student1 total marks : ",total(90,70,85,80,67))
print("Student2 total marks : ",total(10,30,45,50,78))
def func_ref(list):
print... | true |
f13544dda3edb0ff7b44d2c294444f14df1be341 | Python | womogenes/AoC-2020-solutions | /01/1.2.py | UTF-8 | 711 | 3.53125 | 4 | [] | no_license | with open("1-input.txt") as fin:
data = fin.read()
numbers = [int(i) for i in data.split("\n")[:-1]]
print(len(numbers))
def naive():
for i in numbers:
for j in numbers:
for k in numbers:
if i + j + k == 2020:
print(i * j * k)
br... | true |
d9fe5e628635a98692685beddc48544b6b95cfb0 | Python | Enokisan/WeatherDatabase | /tendl.py | UTF-8 | 317 | 2.671875 | 3 | [] | no_license | import urllib.request as req
def download():
# URLや保存ファイル名を指定
url = 'https://www.jma.go.jp/bosai/forecast/data/forecast/010000.json'
filename = 'tenki.json'
# ダウンロード
req.urlretrieve(url, filename)
print("[Weather Database] tenki.json has been downloaded!\n") | true |
b5b1faf0565fa75e5d01d03001180e3d51f23472 | Python | NeerajK23/WeatherForecast | /application.py | UTF-8 | 2,344 | 2.78125 | 3 | [] | no_license | from flask import Flask,render_template, request,url_for
import pywapi
import requests
from bs4 import BeautifulSoup
app=Flask(__name__)
def get_city_name_list(city_name):
#this will give you a dictionary of all cities in the world with this city's name Be specific (city, country)!
lookup = pywapi.get_locati... | true |
446992f31bab0c0666d87944c995b2e73386d377 | Python | cermegno/Ansible-test | /web.py | UTF-8 | 400 | 2.671875 | 3 | [
"MIT"
] | permissive | import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def mainmenu():
return """
<html>
<body>
<center>
<h1>Hi there</h1>
<h2>You brought me here with <u>Ansible<u>!</h2><br>
</center>
</body>
</html>"""
if __name__ == "__main__":
... | true |
8f1ee243aec87332ae296ffe99ee08e231cebca2 | Python | fuksi/pyalgorithm | /merge_sort/tests.py | UTF-8 | 420 | 3.3125 | 3 | [] | no_license | import unittest
from main import merge_sort
class MainTest(unittest.TestCase):
def test_unordered_list(self):
result = merge_sort([1,5,3,4,1])
self.assertEqual([1,1,3,4,5], result)
def test_empty_list(self):
result = merge_sort([])
self.assertEqual([], result)
def test_sho... | true |
8d6b47b73adb2b7e22e7a75fc81266a77cefe4e0 | Python | kimjane7/numerical_linalg | /homework5/test.py | UTF-8 | 790 | 3.25 | 3 | [] | no_license | import os
import sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['font.family'] = "serif"
# 3
plt.figure(figsize=(8,6))
x = np.arange(1.920,2.081,0.001)
p = (x-2)**9
plt.plot(x,p,c='b',label=r'factorized $p(x)=(x-2)^9$')
p = x**9-18*x**8+144*x**7-672*x**6+2016*x**5-40... | true |
476b7cd985dffacaa302adb8f7f609fab057a3cd | Python | naorton/Advent-of-Code | /2015/Day 10/day10.py | UTF-8 | 814 | 3.421875 | 3 | [] | no_license | #data = [1113222113]
#1 = 11
#11 = 21
#21 = 1211
#1211 = 111221
#111221 = 312211
data = [1,1]
count = 0
temp = len(data) + 1
final = []
final.append(temp)
final += data
print(final)
def num_count(num_list):
temp_list = []
count = 1
temp_num = num_list[0]
i = 1
if len(num_list) == 1:
temp_list.append(count)... | true |
efa11152d0055ad60ed85c9132111c28994aed81 | Python | Nardri/trisixty-buys-API | /api/utilities/helpers/errors.py | UTF-8 | 377 | 2.75 | 3 | [
"MIT"
] | permissive | """Errors"""
# utilities
from api.utilities.validations.custom_validations_error import ValidationError
def raises(message, status_code):
"""A helper method for raising exceptions.
Args:
message (str): Message
status_code (int): Status code
Raises:
ValidationError
"""
r... | true |