blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4248ae07c3fef6fe774a0a34072cfb181221b424 | Python | YeungJonathan/Project_Euler | /14.py | UTF-8 | 433 | 2.921875 | 3 | [] | no_license | def collatz(num):
if num % 2 == 1:
num = 3 * num + 1
else:
num = num // 2
return num
check = {1:1}
maxValue = 1
maxNum = 1
for num in range(2,2000001):
item = num
count = 1
final = 0
while item != 1:
if item in check.keys():
count = count + check[item]
break
else:
item = collatz(item)
count... | true |
1efe56618600ecbcd0d36d9f44957671db306d27 | Python | gaoyucai/Python_Project | /Python_day2/login.py | UTF-8 | 1,538 | 3.421875 | 3 | [] | no_license | # Author:GaoYuCai
#导入第三方库时,自动在里进行查找
#默认第三方库存放在site-packags中
#Python解释性语言
#数据类型初识
#1.数字
#2.type()查看数据的数据类型
#bool类型 1表示True 0 表示 False
#三元运算
#例子: result= 值1 if 条件 else 值2
#进制 二进制 八进制 十进制 十六进制
#bytes 数据类型 字节数据类型不同于字符串
#把二级制 转换成字符串 --> decode
#把字符串 转换成 二进制 --> encode
#masg="我爱北京天安门"
#print(masg.encode(encoding="... | true |
95587d872deb31cc6bf15ec5fb99d25407bc9370 | Python | jonfelix1/alegov2 | /src/main.py | UTF-8 | 3,175 | 2.921875 | 3 | [] | no_license | import cv2
import glob
import numpy as np
import multiprocessing
import time
from numba import jit
# import matplotlib.pyplot as plt
from tempfile import TemporaryFile
arrV = TemporaryFile()
# Operators
@jit(nopython = True)
def euclidean_distance(arrVector1, arrVector2):
# Besar dari arrVector1 dan arrVector2 har... | true |
506752f0c19db816ccaa14e2d20e3e8e30dc9df0 | Python | syp0000/ooowah | /hard.py | UTF-8 | 463 | 3.765625 | 4 | [] | no_license | #### input: list
#### [1,4,5,2,3,4,2,4,6,6,2,5]
#### output:
# Odd Number: 5
# Even Numnber:
####
def o(l):
even = 0
odd = 0
for x in l:
if x % 2 == 0:
even = even + 1
else:
odd = odd + 1
print("even: " + str(even))
print("odd: " + str(odd))
p... | true |
74dcc17308c27ea58c66d1bf835e279a7186b704 | Python | CptIdea/labs6 | /lab9/n1.py | UTF-8 | 1,780 | 3.328125 | 3 | [] | no_license | import io
import PySimpleGUI as sg
def getPretty(students):
return '\n'.join([x[0] + ' - ' + ' '.join(x[1]) for x in students.items()])
def addStudent(students):
layout = [
[sg.Text("#"), sg.Input(default_text=f'{len(students) + 1}', key='num', size=(0, 10))],
[sg.Text("ФИО:"), sg.Input(ke... | true |
63cb632e0c3e7c6a35f43725fad0d693422c55f3 | Python | crcrpar/chainer | /chainer/distributions/chisquare.py | UTF-8 | 2,110 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import numpy
import chainer
from chainer.backends import cuda
from chainer import distribution
from chainer.functions.math import digamma
from chainer.functions.math import exponential
from chainer.functions.math import lgamma
from chainer.utils import cache
class Chisquare(distribution.Distribution):
"""Chi-Sq... | true |
dd43e3451ac55a5e4b6fcaab887cf2cee7a933e6 | Python | hinderling/CIED | /library/functions.py | UTF-8 | 5,372 | 2.5625 | 3 | [] | no_license | from glob import glob
from os.path import basename
from PIL import Image
import numpy as np
from skimage import exposure
from skimage.filters.rank import enhance_contrast
from matplotlib import pyplot as plt
from skimage.morphology import disk, binary_opening, skeletonize
from skimage.filters.rank import mean_bilateral... | true |
86f04f224946268518810a98814b83f08fe30366 | Python | iqeeingh/chat | /r2.py | UTF-8 | 1,698 | 3.296875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 13 10:39:29 2021
@author: wayne
count person speak workd number
tip: 前3 n[:3]=0~2、中間2~4 n[2:4]、結尾 n[-2:]
"""
def read_file (filename):
lines = [] #宣告清單
with open (filename , 'r', encoding = 'utf-8-sig') as f:
for line in f:
lines.append(lin... | true |
280aa6565176d17d77e7b89ae231b30316850f1b | Python | sandeep82945/opiniondigest | /src/beam_search.py | UTF-8 | 9,824 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
class Search(object):
def __init__(self, vocab_size, pad, unk, eos):
self.pad = pad
self.unk ... | true |
e91fa52674ae5970108580a8359fc2f7106ffeb1 | Python | hwhehr/zhouzhi | /zhouzhi/zhou/smt.py | UTF-8 | 1,045 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
def send_email(msg_to,url):
smtp_ssl_port = 465
smtp_server = "smtp.qq.com"
msg_from = "549537094@qq.com"
smtp_password = "poltxmcsfqgkbcig"
subject = "周知绑定邮箱"
content=u""""
<p>用户您好,您的用户正在绑定周知邮箱,如果是您的用户请点击此链接,如果不是您的账户请不要... | true |
bcdca92900dfc8144cdb0554321c72c52f68ba99 | Python | swarajd/WebAssemblyDisassembler | /scripts/parsemd.py | UTF-8 | 378 | 2.96875 | 3 | [] | no_license | md = """| `i32.reinterpret/f32` | `0xbc` | | |
| `i64.reinterpret/f64` | `0xbd` | | |
| `f32.reinterpret/i32` | `0xbe` | | |
| `f64.reinterpret/i64` | `0xbf` | | |""".split("\n")
for line in md:
parts = line.split("|")
hex_ = parts[2].replace(' ', '').replace('`', '')
name_ = parts[1].replace(' ', '').repl... | true |
362af75df5ba55c5bda79d4443ba4ebc8bbfbaad | Python | allanedgard/Cloud-Energy-Saver | /header.py | UTF-8 | 1,640 | 2.515625 | 3 | [
"MIT"
] | permissive | #coding: utf-8
import requests, ast, os, time
def get():
domain = 'Default'
login = 'admin'
password = '123456'
project = 'admin'
headers = {'Content-Type':'application/json'}
body = """
{
"auth": {
"identity": {
"methods": [
"password"
],
"pa... | true |
6f82315f7b0f0f9f5ce1a1d308b8af60500a0f77 | Python | YWithT/PAT | /乙/1006.py | UTF-8 | 463 | 3.734375 | 4 | [] | no_license | def printS(x):
for i in range(0, x):
print("S", end="")
def printB(x):
for i in range(0, x):
print("B", end="")
def printG(x):
for i in range(0, x):
print(i + 1, end="")
a = input()
if len(a) == 1:
x = int(a)
printG(x)
if len(a) == 2:
S = int(a[0])
G = int(a[1]... | true |
10029dcc9bfe6b0204d932503ccc0da792eeae36 | Python | gidona18/hashcode | /2019/main.py | UTF-8 | 1,815 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | from collections import namedtuple
Pic = namedtuple('Pic', ['idx','type','tags'])
def read_file(path):
lines = []
with open(path, 'r') as f:
lines = f.read().splitlines()
lines = [line.split() for line in lines[1:]]
pics = [Pic(idx, pic[0], pic[2:]) for idx, pic in enumerate(lines)]
return... | true |
c342c82214c3c9086f7e24e0105731064e2ddd60 | Python | Drsncnzdmr/myprojects | /House Pricing/data_prep.py | UTF-8 | 5,199 | 3.21875 | 3 | [] | no_license | # Data Preprocessing Functions
import numpy as np
import pandas as pd
from sklearn import preprocessing
def outlier_thresholds(dataframe, col_name):
# thresholdsları bulmak için yazdığımız fonksiyon.
quartile1 = dataframe[col_name].quantile(0.05)
quartile3 = dataframe[col_name].quantile(0.95)
interq... | true |
c93f5f997bb64e55106aced7bddc85c8eecf0ca7 | Python | sum008/python-backup | /kinematics/inverse_kinematics_3degree_of_freedom.py | UTF-8 | 2,920 | 3.0625 | 3 | [] | no_license | '''
Created on Jun 17, 2020
@author: Sumit
'''
import pygame as p
import math
p.init()
window=(600,600)
display=p.display.set_mode(window)
points=[[300,300],[350,300],[400,300],[450,300]]
fps=30
run=True
length=50
fix=(300,300)
count=0
while run:
display.fill((255,255,255))
for ev... | true |
8273924019d7f3467728ba2a1837f48fe2459f80 | Python | leogiraldimg/DP1 | /Lista03/e.py | UTF-8 | 111 | 3.28125 | 3 | [] | no_license | n = int(input())
result = 0
k = 0
while (k < n):
result += (k + 1) * (n - k) - k
k += 1
print(result) | true |
b302ba9d4aecfe9056bb7bb4ac9a766548a154a5 | Python | ChenJing0204/plinth-test-suite | /ci_interface/if/start_remake.py | UTF-8 | 486 | 2.625 | 3 | [] | no_license | #! /usr/bin/env python
import os
import sys
#para [1]: the path of target table place
#get the current path
pwd = os.path.split(os.path.realpath(__file__))[0]
targetdir = sys.argv[1]
if targetdir == '':
print("target path is not provide!exit")
sys.exit(0)
os.chdir(pwd)
#cp table_remake.py to target dir
os.s... | true |
852725042a4b88ae949fd12b7d84c97ad706d886 | Python | nareshmuthyala/Assignment_2.3 | /Assignment_2.3.py | UTF-8 | 68 | 3.46875 | 3 | [] | no_license | word = input("Enter the word")
print("Reverse word is :"+word[::-1]) | true |
cd7cff504c798f28666b537cbd8191d72203e9c2 | Python | markriedl/gaige | /rl/Controller.py | UTF-8 | 3,973 | 3.34375 | 3 | [
"MIT"
] | permissive | import sys
from Observation import *
from Reward import *
from Action import *
from Agent import *
from Environment import *
import numpy
# Training episodes
episodes = 500
# how often to report training results
trainingReportRate = 100
# play the interactive game?
# 0: human does not play
# 1: human plays as the b... | true |
c5a02aca63370575ed5463fb4c6fe4affccd6a9a | Python | fanxingzhang/leetcode-grind | /find-all-duplicates-in-an-array.py | UTF-8 | 371 | 3.03125 | 3 | [] | no_license | class Solution(object):
def findDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
ret = []
for i in range(len(nums)):
n = abs(nums[i]) - 1
if nums[n] < 0:
ret.append(n + 1)
else:
... | true |
9f1e4e4568d4456aa76a5e0a5b940f329d17c2fe | Python | JuBagnoli/mypythoncode | /isbn2.py | UTF-8 | 200 | 2.921875 | 3 | [] | no_license | ISBN = input("enter ISBN")
ISBN_odd = 0
ISBN_even = 0
for float in range_odd (0,10,2):
print(total(float*3))
for float in range_even (1,12,2):
print(total)
print(range_odd + range_even)/10 | true |
3dc445bc6719b55c408e35870841035386484dc6 | Python | Steven4869/Simple-Python-Projects | /excercise19.py | UTF-8 | 897 | 4.21875 | 4 | [] | no_license | #Matrix addition
rows1 = int(input("Enter the Number of rows : "))
column1 = int(input("Enter the Number of Columns: "))
rows2 = int(input("Enter the Number of rows : "))
column2 = int(input("Enter the Number of Columns: "))
if(rows1==rows2 and column1==column2):
print("Enter the elements of First Matrix:")
A =... | true |
9deb370637ce3bbe5d8b492843260c93b280c67d | Python | meialbiol/python-library | /library/forms.py | UTF-8 | 1,107 | 2.609375 | 3 | [] | no_license | from django import forms
from django.core.exceptions import ValidationError
from .models import Book
import datetime
class BookForm(forms.ModelForm):
class Meta:
model = Book
fields = ['author', 'title', 'description', 'isbn', 'year']
widgets = {
'description': forms.Textarea... | true |
46fc08b45cb95b1daa9e4db9820ddc2ef94d8c16 | Python | welikepig/YahooMusic | /resultGet.py | UTF-8 | 1,390 | 2.546875 | 3 | [] | no_license | import numpy
dataDir='/Users/zhiyuanchen/Documents/python/'
file_name_test=dataDir + 'out2.txt'
output_file= dataDir + 'new1.txt'
fTest= open(file_name_test, 'r')
fOut = open(output_file, 'w')
ii=0
outstr=''
su_vec=[0]*6
pt=numpy.zeros(shape=(6,1))
for line in fTest:
arr_test=line.strip()
s... | true |
e67acca4ad9403403c223d71e7c448483faa5d8a | Python | SubhamoySengupta/iron-worker-uploads | /resize_watermarks/hyve/input_params.py | UTF-8 | 1,713 | 2.578125 | 3 | [] | no_license | import sys, json
def get_data_from_payload(code):
#return trim_payload('//hyve-users/12345/photos/__w-160-240-360-480-720-1080__/1.png')
payload_file = None
payload = None
for i in range(len(code)):
if code[i] == "-payload" and (i + 1) < len(code):
payload_file = code[i + 1]
with open(payloa... | true |
d56e988c97f1fb831a2cf6b8f40c31fa58a819af | Python | bpramod123/imdb_review | /imdb_analysis.py | UTF-8 | 1,730 | 3.171875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[4]:
conda install matplotlib
# In[14]:
import pandas as pd
import matplotlib
from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
df=pd.read_csv(r'C:\Users\gunda\Desktop\projs\movies.csv')
# In[8]:
df
# In[41]:
#dropping null value rows
... | true |
5c72412dac960bfae453a0fcbe7122b7f69a16b4 | Python | jakeisnt/philosofound | /flaskr/queries.py | UTF-8 | 4,986 | 2.671875 | 3 | [] | no_license | # answer.answer_id -> [question.question_id, question.text]
# Accesses the question data associated with an Answer ID
def get_question(db, answerId):
question = db.execute(
'SELECT q.question_id, q.text'
' FROM question q JOIN answer a on(q.question_id = a.question_id)'
' WHERE a.answer_id =... | true |
c6dd4f6eaeedccd18d4018bd09419b6b258a8e40 | Python | Velasko/Hackaton-da-Nasa | /04 - boolean.py | UTF-8 | 226 | 3.921875 | 4 | [] | no_license |
x = 27
y = 16
#x, y = 27, 16
print("x == 47:", x == 47 )
print("x == y :", x == y)
print("x binario: ", bin(x))
print("y binario: ", bin(y))
print("x and y:", x and y, bin(x and y))
print("x or y:", x or y, bin(x or y)) | true |
c8494cd91256c5fc78167a00d13df445837d67bf | Python | ajithkmr2/Assignments | /MVC/controller.py | UTF-8 | 426 | 2.890625 | 3 | [] | no_license | from model import Currency
import view
def showPrice(query_value):
#gets list of all Currency objects
currency_price = Currency.getCurrencyData(query_value)
#calls view
return view.showData(currency_price)
def start():
view.startView()
input_option = input('Enter [INR / EUR / CAD / AUD / JPY / ALL] ... | true |
cb54d949dc8beea59ab723cd11503f61a18b57a2 | Python | kh7160/algorithm | /BOJ/11650.py | UTF-8 | 150 | 3.15625 | 3 | [] | no_license | n = int(input())
num_lst = [list(map(int, input().split())) for _ in range(n)]
num_lst.sort(key=lambda x:(x[0], x[1]))
for _ in num_lst:
print(*_) | true |
f6cea9ee777ead2c81219d0f2536713b8e490f80 | Python | nicolekenig/Search_Engine | /indexer.py | UTF-8 | 7,302 | 2.90625 | 3 | [] | no_license | import utils
from parser_module import Parse
from stemmer import Stemmer
# DO NOT MODIFY CLASS NAME
class Indexer:
# DO NOT MODIFY THIS SIGNATURE
# You can change the internal implementation as you see fit.
def __init__(self, config):
self.inverted_idx = {}
self.postingDict = {}
se... | true |
26d09bb65b10dd9d9c54f759a2f433608061a91b | Python | HyunminKo/Algorithm | /Python-Algorithm/kakao/Round2_4.py | UTF-8 | 1,503 | 2.796875 | 3 | [] | no_license | N=0
M=0
matrixA = []
matrixB = []
dx = [-1,0,1,0]
dy = [0,1,0,-1]
visited = [[0 for i in range(101)] for j in range(101)]
def bfs(row,col):
global N, M, visited
visited[row][col] = 1
q = [(row,col)]
count = 0
if matrixA[row][col] != matrixB[row][col]:
count = - 1
flag = True
while q... | true |
a95fb8a6eafa736692ecb93cc01e935591017d95 | Python | NearJiang/Python-route | /多重继承.py | UTF-8 | 473 | 2.890625 | 3 | [] | no_license | Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> class Base1:
def foo1(self):
print('我是foo1,我为Base1带盐')
>>> class Base2:
def foo2(self):
print('我是foo2,我为Base2带盐')
>>> class a(Base1, Ba... | true |
6fae8dddf94194b28f8d4883b16af9ee778c32fd | Python | darcyknox/COSC326 | /etude-1/etude-1.py | UTF-8 | 7,284 | 3.5 | 4 | [] | no_license | import re
import sys
# Etude-1 Email Addresses
# Author: Darcy Knox
# Date: March 2020
# The program takes string input(s) from the user, and determines whether the
# string is a valid email address according to the specifications outlined in
# the Etude 1 Problem Description
# Function to match the mailbox part of ... | true |
1267e60553bc50bcf04659e3fedff549a274537f | Python | disa-mhembere/Guided-Assembler | /src/csc_matrix2.py | UTF-8 | 1,396 | 3.125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #!/usr/bin/python
# csc_matrix2.py
# Created by Disa Mhembere on 2013-11-21.
# Email: disa@jhu.edu
# Copyright (c) 2013. All rights reserved.
import scipy
from scipy.sparse.csc import csc_matrix
import numpy as np
from exceptions import IndexError
class csc_matrix2(csc_matrix):
"""
Sub-class of lil_matrix that a... | true |
49f16a8c5eda49bb6e1d464e98bdb94d5b6d60c0 | Python | MathieuSoul/PhyStat_Project | /Test/simulationWolrd.py | UTF-8 | 9,465 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Éditeur de Spyder
Ceci est un script temporaire.
"""
import networkx as nx
import random
from math import sqrt
from networkx.readwrite import json_graph
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
import imageio
import seaborn
import forceatlas
themeC... | true |
fcaab9c86cd7a73ef14ec77b38698ad894136899 | Python | csc202summer19/lectures | /02_recursion/recursive_functions.py | UTF-8 | 398 | 4.0625 | 4 | [] | no_license | def power(a, n):
""" Compute a^n. """
# NOTE: a^n = a * a * a * ... * a
# a^n = a * a^(n - 1)
if n == 0:
return 1
else:
return a * power(a, n - 1)
def factorial(n):
""" Compute n!. """
# NOTE: n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1
# n! = n * (n - 1)!
... | true |
5da006e536bc9c8fbc23c2ae35079caab874e3b5 | Python | AlexanderHeimann-EH/Testautomation | /CiCDTMstudioTest/Source/Demos/pytools-186e88affa1d/pytools_186e88affa1d/Python/Tests/TestData/ProfileTest/Program.py | UTF-8 | 88 | 2.59375 | 3 | [] | no_license | import time
def f():
for i in xrange(10000):
time.sleep(0)
f() | true |
78bfe27d36067b049e6f34e0d0851dbe6c60a70d | Python | arkadiuszpasek/wuwuzela | /src/types/string.py | UTF-8 | 129 | 3.234375 | 3 | [] | no_license | class String():
def __init__(self, input):
self.value = str(input)
def __str__(self):
return self.value
| true |
6fe31ea47a5bd68551d259c7ffe3431b52c1e0c3 | Python | analyticd/FlowTradingTools | /testpanel.py | UTF-8 | 1,642 | 2.578125 | 3 | [] | no_license | import wx
class TestNoteBook(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(600, 500))
panel = wx.Panel(self)
vsizer = wx.BoxSizer(wx.VERTICAL)
toppanel = wx.Panel(panel)
bottompanel = wx.Panel(panel)
not... | true |
33eaf01f9ee0867587573eb1924f3bf73c901bb2 | Python | jeromepan/Timus-Online-Judge-Solution | /1280.py | UTF-8 | 984 | 3.328125 | 3 | [] | no_license | def main():
before = [None]*(100000 + 1)
after = [None]*(100000 + 1)
orders = [None]*(1000 + 1)
numOfSubjects, numOfLimitations = input().split()
numOfSubjects = int(numOfSubjects)
numOfLimitations = int(numOfLimitations)
for indexOfLimitation in range(1, numOfLimitations+1):
befor... | true |
555ac88ddebbdd5a5c05d65094eaf5d6eae17ee4 | Python | PietroMelzi/potion | /potion/meta/smoothing_constants.py | UTF-8 | 1,326 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 12 14:09:49 2019
@author: matteo
"""
import math
def gauss_smooth_const(max_feat, std):
psi = 2 * max_feat / (math.sqrt(2 * math.pi) * std)
kappa = max_feat**2 / std**2
xi = max_feat**2 / std**2
return psi, kappa, xi
def std_smooth... | true |
dd69c5966a6c1accd15acb41fa3fa4af9895e572 | Python | ProditorMagnus/WML_tree_tools | /py_files/wmlparser3.py | UTF-8 | 27,576 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python3
# encoding: utf-8
"""
This parser uses the --preprocess option of wesnoth so a working
wesnoth executable must be available at runtime if the WML to parse
contains preprocessing directives.
Pure WML can be parsed as is.
For example:
wml = ""
[unit]
id=elve
name=Elve
... | true |
f0188e0b79e7f0c78c063117163f7fdce50986c9 | Python | KristineYW/DS-Unit-3-Sprint-2-SQL-and-Databases | /module2-sql-for-analysis/insert_rpg_char_inv.py | UTF-8 | 2,719 | 3.015625 | 3 | [
"MIT"
] | permissive | import os
from dotenv import load_dotenv
import sqlite3
import psycopg2
from psycopg2.extras import execute_values
load_dotenv() # looks inside the .env file for some env vars
# passes env var values to python var
DB_HOST = os.getenv("DB_HOST", default="OOPS")
DB_NAME = os.getenv("DB_NAME", default="OOPS")
DB_USER = ... | true |
6a4978de579271cbac24749266e89b97e9b3afde | Python | MichelleZ/leetcode | /algorithms/python/countVowelsPermutation/countVowelsPermutation.py | UTF-8 | 616 | 3.078125 | 3 | [] | no_license | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# Source: https://leetcode.com/problems/count-vowels-permutation/
# Author: Miao Zhang
# Date: 2021-04-17
class Solution:
def countVowelPermutation(self, n: int) -> int:
kMod = 10 ** 9 + 7
a, e, i, o, u = 1, 1, 1, 1, 1
for k in range(2, n +... | true |
f90349b5a46e46574072c30246b0cb99e23159b0 | Python | emilyvroth/cs1 | /lecture/lecture6/boolean.py | UTF-8 | 169 | 3.25 | 3 | [] | no_license | x = 15
y = -15
z = 32
print(x == y and y < z)
print(x == y or y < z)
print(x == abs(y) and y <z)
print(x == abs(y) or y <z)
print(not x == abs(y))
print(not x != abs(y)) | true |
43a71c40490275763712a79f64ba54ff7af3e294 | Python | mathminds/csci-utils | /src/csci_utils/file/tests.py | UTF-8 | 2,562 | 3.25 | 3 | [] | no_license | import os
from csci_utils.io.enhancedwrite import atomic_write
from csci_utils.file.parquet import (
get_parquet_column,
get_parquet_file_name,
convert_xls_to_parquet,
)
from tempfile import TemporaryDirectory
from unittest import TestCase
from pandas import DataFrame
class ParquetTests(TestCase):
def... | true |
0dbaea791805310e9b9e4dd342ab7da747f891fd | Python | lizhao0211/HtmlManipulate | /designer/RunMainWinHorLayout.py | UTF-8 | 437 | 2.53125 | 3 | [] | no_license | import sys
import MainWinHorLayout
from PyQt5.QtWidgets import QApplication, QMainWindow
if __name__ == '__main__':
# 创建QApplication类的实例
app = QApplication(sys.argv)
# 创建一个窗口
mainWindow = QMainWindow()
ui = MainWinHorLayout.UI_MainWindow
ui.setupUi(mainWindow)
mainWindow.show()
# 进入程序的主... | true |
28a0311befca9e7db2d0d8a2ab785e71e92b7c76 | Python | DoctorLai/ACM | /binarysearch/Candy-Race/Candy-Race.py | UTF-8 | 538 | 3.03125 | 3 | [] | no_license | # https://helloacm.com/teaching-kids-programming-minmax-dynamic-programming-algorithm-game-of-picking-numbers-at-two-ends/
# https://binarysearch.com/problems/Candy-Race
# HARD, DP
class Solution:
def solve(self, P):
n = len(P)
dp = [[0] * n for _ in range(n)]
for i in range(n):
... | true |
ff701233d551181b183b9bc39b4f01b19d62d26e | Python | CVanchieri/CS-Unit5-HashTables | /applications/histo/histo.py | UTF-8 | 569 | 3.28125 | 3 | [] | no_license | # Your code here
import re
store = {}
def printHistogram(word, count):
print(f"{word}:{' ' * (16 - len(word))}{'#' * count}")
with open('./robin.txt', 'r') as file:
for line in file:
for word in line.split():
word = re.sub('\W+', '', word.lower())
if not word.isalpha():
continue
... | true |
651c15a6f7053e7fca86b5e08604d651bae6bc4d | Python | Francesco-Ghizzo/TCC | /Script/Console QGIS/Non Commentati/Spectral_Radiance_L5.py | UTF-8 | 2,220 | 2.671875 | 3 | [] | no_license | ## Spectral Radiance (L) landsat 5
from qgis.core import *
from PyQt4.QtGui import QInputDialog
import os
from osgeo import gdal
def get_landsat_dir():
landsat_dir = QInputDialog.getText(None, '',
'Insira o caminho da pasta com as imagens Landsat 5:\n')[0]
return land... | true |
0337d9aebbaa780fd76d8c5b482d6e40e72b3e22 | Python | TheTacoScott/stormcity | /lib/worker.py | UTF-8 | 2,260 | 2.59375 | 3 | [] | no_license | import threading
import time
import lib
try:
from urlparse import urlparse as urlparse
except:
from urllib.parse import urlparse
try:
import Queue as queue
except:
import queue
class Fetcher(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.stop = threading.Event()
self... | true |
49b170388d2c3c5c8b27ec98f00158a6b91fa467 | Python | zhahang0/caffe-luolongqiang | /python/deepFashion/get_category10_images.py | UTF-8 | 1,712 | 2.796875 | 3 | [
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause"
] | permissive | import numpy as np
from numpy import array
import os, sys, time, argparse, shutil
def get_category_images(input_txt, output_dir):
fi = open(input_txt, 'r')
cls_name_list = ['3-Blouse', '6-Cardigan', '11-Jacket', '16-Sweater', '17-Tank', '18-Tee', '19-Top', '32-Shorts', '33-Skirt', '41-Dress']
# output_d... | true |
576a9b04335a2d98931fb8b9f941e88ffeb1ae38 | Python | afhuertass/santander | /scripts/nn/model.py | UTF-8 | 967 | 2.53125 | 3 | [] | no_license |
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.layers import BatchNormalization
from keras.layers import Dropout
def get_model( input_features , nhidden ):
model = Sequential()
model.add( Dense( nhidden , input_dim = input_features ) )
model.add( Activation("elu" , n... | true |
eda1da79874631d55b7fda5ddf6053fd27ee5087 | Python | UWPCE-PythonCert-ClassRepos/py220-online-201904-V2 | /students/elaine_x/lesson06/assignment/src/expand_records.py | UTF-8 | 2,461 | 3.1875 | 3 | [] | no_license | '''
expand records to one million records and assign unique id to them
'''
import logging
import csv
import uuid
import random
#global CCNUMBER_LIST, DATA_LIST, SENTENCE_LIST
logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger(__name__)
def read_csv(filename):
'''read data from csv'''
with op... | true |
193be8f6ff7593438f3d12d8e8c480dbd33adee5 | Python | waddling/adventofcode-2019 | /day04/part1.py | UTF-8 | 750 | 3.6875 | 4 | [] | no_license | #!/usr/bin/env python3
import sys
def check_adjacent_digits(n):
n = str(n)
for i in range(len(n) - 1):
if int(n[i]) == int(n[i+1]):
return True
return False
def check_increasing_digits(n):
n = str(n)
for i in range(len(n) - 1):
if int(n[i]) > int(n[i+1]):
... | true |
6ced24ae8c47ec64aa9cef59475582bcb49cfe84 | Python | Richiewong07/Python-Exercises | /python-assignments/list/sum_the_numbers.py | UTF-8 | 288 | 4.625 | 5 | [] | no_license |
# 1. Sum the Numbers
# Given an list of numbers, print their sum. When I say given something, just make something up and store it in a variable.
num_list = [1, 2, 3, 4, 5]
def sum(numbers):
total = 0
for num in numbers:
total += num
print(total)
sum(num_list)
| true |
43486f5bf01e869830e3d47fe3774d29b2f3ecd4 | Python | AK-1121/code_extraction | /python/python_1641.py | UTF-8 | 184 | 2.71875 | 3 | [] | no_license | # How can I declare a 5x5 grid of numbers in Python?
boardPieces = [["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"]]
| true |
931f24b9b8925a9838c52d7eca339a11f15de36e | Python | thetaprimeio/flyingking-checkers | /MachineLearningModules/PerformanceSystem.py | UTF-8 | 41,535 | 3.28125 | 3 | [
"MIT"
] | permissive | #######################################################################
# File name: PerformanceSystem.py #
# Author: PhilipBasaric #
# #
# Description: Performance Syste... | true |
a5de5b8629b94bb6cc55750202e7b230c6d8d8b1 | Python | IgnacioSallaberry/RICS | /histogramas monomeros y oligomeros.py | UTF-8 | 5,276 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 9 20:25:06 2019
@author: Ignacio Sallaberry
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import re
guardar_imagenes = True
#==============================================================================
# ... | true |
a4771a0fdfcc7fcb247892a4bda2943ca2ae1ea2 | Python | ash/amazing_python3 | /166-filter.py | UTF-8 | 256 | 4.625 | 5 | [] | no_license | # Using "filter" to select items
# bases on some condition
# Here's the condition:
def is_odd(x):
return x % 2
data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
data = filter(is_odd, data)
# Object of the "filter" type
data = list(data) # a list again
print(data) | true |
cb3a778c81a05268a4a93ab4487f4f88b0fef2a8 | Python | lucaspsimpson/IndividualProject | /python/QuadTree.py | UTF-8 | 3,124 | 3.21875 | 3 | [] | no_license | import numpy as np
from matplotlib import pyplot as plt
#----------------------------------------------------------------------
# This function adjusts matplotlib settings for a uniform feel in the textbook.
# Note that with usetex=True, fonts are rendered with LaTeX. This may
# result in an error if LaTeX is not ins... | true |
365282b11461190ca825f1143b2d17dfb13c8b4e | Python | tomato-pan/Aim_to_offer | /useAlgorothms/isSymmetric.py | UTF-8 | 1,647 | 3.796875 | 4 | [] | no_license | # Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
from collections import deque
class Solution:
# 递归
def isSymmetric(self, root: TreeNode) -> bool:
if root is None: return... | true |
208d65cc41059e5ad3b49ca6138f1c27d1df4b44 | Python | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/42_5.py | UTF-8 | 2,779 | 4.09375 | 4 | [] | no_license | Python – Remove after substring in String
Given a String, remove all characters after particular substring.
> **Input** : test_str = ‘geeksforgeeks is best for geeks’, sub_str = “for”
> **Output** : geeksforgeeks is best for
> **Explanation** : everything removed after for.
>
> **Input** : test_st... | true |
40670baacf0b5f95bc382fa63657997b1e171c28 | Python | MegumiDavid/python-projects | /turtle_python/angulos.py | UTF-8 | 1,080 | 3.4375 | 3 | [] | no_license | from turtle import Turtle, Screen
turtle = Turtle()
turtle.shape("turtle")
turtle.color("light salmon")
#turtle.dot(size=5)
#for c in range (50):
# turtle.pendown()
# turtle.forward(10)
# turtle.penup()
# turtle.forward(10)
#def the_beauty_of_simetric()
pen_color = ['dark orange','firebrick','medium violet red... | true |
57b3b7ee8abb12ededc518bfd4ee21a32f3664f1 | Python | Cvmaggio/ReinforcementLearningSutton-Barto | /examples/Example4-9GamblersProblem.py | UTF-8 | 1,576 | 2.875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from copy import deepcopy
maxCapital = 128
theta = .00000000000001
gamma = 1
pH = .4
largestAvailableBet = {}
for s in range(0,maxCapital+1):
largestAvailableBet[s] = min(s,maxCapital-s)
V = np.zeros(maxCapital + 1)
R = np.zeros(maxCapital + 1)
V[maxCapital] = 1... | true |
fd2949b19e83963d3704256e063f532f4433639d | Python | StyvenSoft/degree-python | /Lesson7_ChallengeLoops/3-Greetings.py | UTF-8 | 296 | 4.28125 | 4 | [
"MIT"
] | permissive | #Write your function here
def add_greetings(names):
new_list = []
for name in names:
new_list.append("Hello, " + name)
return new_list
#Uncomment the line below when your function is done
print(add_greetings(["Owen", "Max", "Sophie"]))
# ['Hello, Owen', 'Hello, Max', 'Hello, Sophie'] | true |
89fb9a8aee44e7bbeb6f36c0ed2319d4fc6d74bf | Python | IlkoAng/Python-Advanced-Softuni | /Exercise 4 Comprehensions/02. Words Lengths.py | UTF-8 | 90 | 3.75 | 4 | [] | no_license | text = input().split(", ")
print(f', '.join([f"{name} -> {len(name)}" for name in text])) | true |
8cacaa0353b8c4ae7a3972a3743728dd3434bdae | Python | yanigisawa/coffee-scale | /test_coffee_scale.py | UTF-8 | 3,846 | 2.71875 | 3 | [
"MIT"
] | permissive | import unittest
import coffee_scale as cs
from datetime import datetime, timedelta
class CoffeeTest(unittest.TestCase):
def setUp(self):
self.scale = cs.CoffeeScale()
def test_whenValueChangesLessThanThreshold_LogIsNotWritten(self):
self.scale._currentWeight = 20
self.scale._threshold ... | true |
b638357308fe417c8ba59736e8e9f680564435ff | Python | MikhailKaraganov/Repos1 | /invest.py | UTF-8 | 265 | 3.09375 | 3 | [] | no_license |
START_SUM = 400000
NDS = 0.13
RATE = 0.07
nds = START_SUM * NDS
def invest(start_sum, years):
if (years >= 1):
return start_sum + start_sum*RATE + invest(start_sum + start_sum*RATE, years - 1)
else:
return 0
print(invest(400000,30))
| true |
b9758bd6543997fedf63ac7cc00be09d1b898f81 | Python | RameshOswal/forensic-audio-analysis | /audio.py | UTF-8 | 982 | 2.71875 | 3 | [] | no_license | import librosa
import numpy as np
import matplotlib.pyplot as plt
from subprocess import run
# Parameters
sampling_rate = 44100 # All clips will be converted to this rate
duration = None # Clips will be trimmed to this length (seconds)
def import_wav(file, plot=False):
# Import raw data
try:
raw_data ... | true |
a4aa9255757bbf1d37bda2f9abcbe2e32cb52f49 | Python | Faydiamond/tablesfrec | /tablefrecuency.py | UTF-8 | 3,732 | 3.234375 | 3 | [] | no_license | class table:
def __init__(self):
self.valores = []
self.xi =[]
self.frabsoluta= []
self.frabsolutaacum =[]
self.frerel =[]
self.frerelper =[]
self.frerelacumm =[]
self.frerelacummper =[]
self.muestra = int(input('por favor digite el numero to... | true |
7389c8ed64825a3dfe62bd7094175ad9b341bb41 | Python | bahattin-urganci/python-training | /tuple.py | UTF-8 | 1,571 | 4.28125 | 4 | [
"MIT"
] | permissive | def returntwo(v1,v2):
c1=v1**v2
c2=v2*v1
#tuple üretmek aşağıdaki kadar basit parantez içerisinde ne döndürmek istiyorsan bas geç
return (c1,c2)
values = returntwo(2,4)
print(values)
# Define shout_all with parameters word1 and word2
def shout_all(word1,word2):
# Concatenate word1 with '!!... | true |
74d98e8359734e5ab434b63a9f396b124f42a8b6 | Python | gviejo/Gohal | /run/Keramati/ReScience/Selection.py | UTF-8 | 6,365 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Selection.py
Class of for model selection when training
first model <- Keramati et al, 2011
Copyright (c) 2013 Guillaume VIEJO. All rights reserved.
"""
import sys
import os
import numpy as np
from fonctions import *
class Keramati():
"""Class that implement Kera... | true |
a95896c066efac96cc2969e2ba56d97855be5958 | Python | zekeriyasari/optimization | /optimize/tools.py | UTF-8 | 4,503 | 3.375 | 3 | [] | no_license | from optimize.constants import *
import numpy as np
import matplotlib.pyplot as plt
def estimate_gradient(f, x, h=DERIV_TOL):
n = x.size
df = np.zeros(n)
for k in range(n):
delta = np.zeros(n)
delta[k] = h
df[k] = (f(x + delta) - f(x - delta)) / (2 * h)
return df
def line_alo... | true |
600cd78514a9e8041ca92f388b7497afa31615f7 | Python | TheLordBaski/adbmirror | /adbmirror/glue.py | UTF-8 | 682 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | import threading
from multiprocessing import Pipe
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.pipe_ext, self.pipe_int = Pipe()
def read(self):
msgs = []
while self.pipe_ext.poll():
msgs.append(self.pipe_ext.... | true |
30b8eb26653988fc91932897cdffc697031d9f66 | Python | mprinc/NLP | /nlangp-001-coursera/src/nlp/TaggingPreprocessing.py | UTF-8 | 7,721 | 2.625 | 3 | [] | no_license | import sys
import re
from collections import defaultdict
from TaggingCountsUnigram import TaggingCountsUnigram
from TaggingCountsViterbi import TaggingCountsViterbi
from nlp.TaggingCountsViterbi import TaggingCountsViterbi
def defaultTree():
return defaultdict(defaultTree);
class TaggingPreprocessing(object):
... | true |
a714c29fa0baeec212a0f2eed841a3b7183b1d21 | Python | brunobstoll/LA-Sist-Completo | /LA-Intervencao/model/PreProcessamentoDB.py | UTF-8 | 3,762 | 2.671875 | 3 | [] | no_license | import model.dataBase as db
import model.MetaDadosDB as meta
import model.ImportacaoDB as imp
def RetornarValoresColuna(idTabela, idColuna):
tabela = imp.ObterTabela(idTabela)
coluna = meta.ObterColuna(idColuna)
sql_table = tabela.nome
if not (tabela.sql_destino == None or tabela.sql_destino == ''):
... | true |
2d7bdb70a3a9cde06012f0de32bf342d2c6b2bd7 | Python | kingssafy/til | /ps/codeforces/1144/1144B.py | UTF-8 | 282 | 2.78125 | 3 | [] | no_license | N = int(input())
arr = list(map(int, input().split()))
arr.sort()
flag = 1
before = N;
k = arr[-1]%2
odd = []
even = []
for a in arr:
if a % 2:
odd.append(a)
else:
even.append(a)
if len(odd) == len(even):
print(0)
else:
print(min(odd[0], even[0]))
| true |
f4a4301af449e7d2901fea7dadfcf96f1cc596a7 | Python | prashant-repo-test/python_data_science | /Abstract class.py | UTF-8 | 338 | 3.984375 | 4 | [] | no_license | from abc import ABC, abstractmethod
class Employee(ABC):
@abstractmethod
def calculate_salary(self,sal):
pass
class Developer(Employee):
def calculate_salary(self,sal):
final_salary = sal * 1.1
return final_salary
emp_1 = Developer()
print(emp_1.calcul... | true |
bb5b49e8c343e07a57ae55232a81b60729b8c6ec | Python | nwinds/jugar | /algo_I_py/path_compression_qu.py | UTF-8 | 817 | 3.5 | 4 | [] | no_license | # inspired by union find demo
identity = []
for i in range(10):
identity.append(i)
# root of number
#I made an understandable ver
def root(you):
while identity[you] != you:
dad = identity[you]
oldman = identity[dad]
identity[you] = oldman
you = identity[you]
# shorter:
... | true |
1b9d9991cc8596764420d5392cc85958a3b8454f | Python | SeaWar741/ITC | /1er_Semestre/stark.py | UTF-8 | 2,818 | 3.609375 | 4 | [] | no_license | clave= 23412
totaladul=0
totalnin= 0
saldotarjeta=1000
validar = int(input("ingrese clave de acceso >"))
print("Bienvenido a restaurate ABC")
while validar != 23412:
print ("Clave incorrecta")
validar = int(input("ingrese clave de acceso >"))
print("MENU PRINCIPAL")
print("Ingrese la opcion que de... | true |
b6e984fae15a2a3ae64e2823b2b3252623ac7b78 | Python | deeuu/supriya | /supriya/ugens/Rand.py | UTF-8 | 450 | 2.546875 | 3 | [
"MIT"
] | permissive | import collections
from supriya import CalculationRate
from supriya.synthdefs import UGen
class Rand(UGen):
"""
A uniform random distribution.
::
>>> supriya.ugens.Rand.ir()
Rand.ir()
"""
### CLASS VARIABLES ###
__documentation_section__ = "Noise UGens"
_ordered_inpu... | true |
2e86bd083112f6d161bc5b67dd1b1586d39c9caf | Python | SindreSvendby/pgnToFen | /pgnToFen.py | UTF-8 | 30,292 | 2.75 | 3 | [
"MIT"
] | permissive | #!/bin/python
# coding=utf8
from __future__ import print_function
from __future__ import division
from functools import partial
import math
import re
import os
class PgnToFen:
fen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR'
whiteToMove = True
internalChessBoard = [
'R','N','B','Q... | true |
56af3fa98729a14a6c12a805457f6f213b7ab8b1 | Python | cash2one/xai | /xai/brain/wordbase/adjectives/_tidy.py | UTF-8 | 483 | 2.703125 | 3 | [
"MIT"
] | permissive |
#calss header
class _TIDY():
def __init__(self,):
self.name = "TIDY"
self.definitions = [u'having everything ordered and arranged in the right place, or liking to keep things like this: ', u'(of amounts of money) large: ']
self.parents = []
self.childen = []
self.properties = []
self.jsondata = {}
... | true |
1ec927e2750a3b8ac90625ff40b562f87afb7004 | Python | PilKvas/BootCamp | /code_wars/Century From Year.py | UTF-8 | 268 | 2.9375 | 3 | [] | no_license | """The first century spans from the year 1 up to and including the year 100, The second - from the year 101 up to and including the year 200, etc.
"""
def century(year):
century = year // 100
if year % 100 == 0:
return century
return century + 1 | true |
d759340f3dc453c9cec22269f128c5971c4603f3 | Python | 777GE90/pokedex | /tests/test_server.py | UTF-8 | 5,348 | 2.671875 | 3 | [] | no_license | import unittest
from unittest.mock import patch
from server import app
class PokemonTests(unittest.TestCase):
def setUp(self):
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
self.app = app.test_client()
@patch("modules.pokeapi.PokeAPIWrapper.get_pokemon_species_b... | true |
a6ca972b598d4aad177c5874d3415cba3e79cca5 | Python | adam-lim1/MarchMadnessML | /mmml/mmml/game_results.py | UTF-8 | 9,711 | 3.125 | 3 | [] | no_license | import pandas as pd
import numpy as np
import math
import sys
def win_probs(*, home_elo, road_elo, hca_elo):
"""
Home and road team win probabilities implied by Elo ratings and home court adjustment.
"""
h = math.pow(10, home_elo/400)
r = math.pow(10, road_elo/400)
a = math.pow(10, hca_elo/400)... | true |
97745a79bfc41e7713cf81f5359aea1d1014b605 | Python | Laxmivadekar/file | /from xyz file .py | UTF-8 | 2,601 | 3.34375 | 3 | [] | no_license | f=open('xyz.txt')
content=f.read()
print(content)
f.close()
print('_____________________________________________________________________')
#=================================================================================
# f=open('xyz.txt','r')
# f.read()
# f.close()
print('____________________________no. of charactes... | true |
448784979c9edc5a47e210b51f3eb317f81dad70 | Python | rajeshpandey2053/Python_assignment_3 | /merge_sort.py | UTF-8 | 939 | 3.78125 | 4 | [] | no_license | def merge(left, right, arr):
i = 0
j =0
k = 0
while ( i < len(left) and j < len(right)):
if (left[i] <= right[j]):
arr[k] = left[i]
i = i + 1
else:
arr[k] = right[j]
j = j + 1
k = k + 1
# if remaining in left
while(i ... | true |
0cac4b6446a187c980d92ab66ac51b79b7317841 | Python | pujanthakrar/ECON-425-Machine-Learning | /dataTrans.py | UTF-8 | 1,436 | 3.28125 | 3 | [] | no_license |
import numpy as np
from pandas import read_csv
#### functions
##### Function1: import data
def download_data(fileLocation, fields):
'''
Downloads the data for this script into a pandas DataFrame. Uses columns indices provided
'''
frame = read_csv(
fileLocation,
# Specify ... | true |
1e0c2f6d0ce9a2b280b7a24ba4b8d60b78c63090 | Python | dollcg24/diab_risk | /backend/server/apps/ml/tests.py | UTF-8 | 1,794 | 2.578125 | 3 | [
"MIT"
] | permissive | from django.test import TestCase
from apps.ml.registry import MLRegistry
from apps.ml.risk_classifier.random_forest import RandomForestClassifier
class MLTests(TestCase):
def test_rf_algorithm(self):
input_data = {
"gender": "f",
"age": "B",
"bmi": "overweight",
... | true |
55993b7622919e184c954442a55898667fe06988 | Python | maheel/aws-security-hub-automated-response-and-remediation | /source/LambdaLayers/utils.py | UTF-8 | 4,675 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-2-Clause",
"MIT"
] | permissive | #!/usr/bin/python
###############################################################################
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License Version 2.0 (the "License... | true |
90bba9cc0edc8b8c652c0e9a8f567a057209605f | Python | L-avender/AID1905 | /PycharmProjects/python_file/month2/day13/flags.py | UTF-8 | 378 | 3.15625 | 3 | [] | no_license | """
flags.py
flags 扩展功能
"""
import re
s="""Hello
北京"""
#只能匹配ASCII编码
# regex=re.compile(r"\w+",flags=re.ASCII)
#不区分大小写
#regex=re.compile(r'[a-z]+',flags=re.IGNORECASE)
#可以匹配换行
#regex=re.compile(r".+",flags=re.S)
#^,$匹配每一行的开头结尾位置
regex=re.compile(r"^北京",flags=re.M)
l=regex.findall(s)
print(l) | true |
4c16f2c3fe79ba66b280599fb509243d5b0414b5 | Python | raviverma2791747/Hacktober-DSA | /ELLIPSE.PY | UTF-8 | 1,887 | 4.125 | 4 | [] | no_license | # Mid-Point Ellipse Algorithm C019322
def midptellipse(rx, ry, xc, yc):
x = 0
y = ry
# Initial decision parameter of region 1
d1 = ((ry * ry) - (rx * rx * ry) + (0.25 * rx * rx))
dx = 2 * ry * ry * x
dy = 2 * rx * rx * y
# For region 1
while (dx < dy):
# Using... | true |
2f514794f1a5dcb74aa6421f3d192276b65f6444 | Python | guard1000/Everyday-coding | /190113_더 맵게.py | UTF-8 | 470 | 3.296875 | 3 | [] | no_license | import heapq
def solution(scoville, K):
answer = 0
heapq.heapify(scoville)
while len(scoville) >1:
if scoville[0] >= K:
return answer
answer += 1
tmp = scoville[0]
heapq.heappop(scoville)
tmp += (scoville[0]*2)
heapq.heappop(scoville)
heap... | true |
7156f25014ad728695f24543ba25b922ab8789ce | Python | beader/tianchi-3rd_security | /models/cnn.py | UTF-8 | 797 | 2.5625 | 3 | [] | no_license | import tensorflow as tf
from tensorflow.keras.layers import Input, MaxPool1D, Conv1D, GlobalMaxPool1D, Concatenate, Dense
def build_cnn_model(num_classes, feat_size, name='cnn'):
input_seq = Input(shape=(None, feat_size), dtype='float32')
x = MaxPool1D(5, strides=2)(input_seq)
conv1 = Conv1D(64, kernel_s... | true |
630eb253b214d7844b49c5defc0f69f68dfb0aaf | Python | moret/sparse-rdf | /tests/test_path_index.py | UTF-8 | 1,002 | 3 | 3 | [] | no_license | from app.persistance import db
def test_exist():
from app.persistance import pi
assert pi
def test_replace_all_paths_with_two_paths():
paths = [['nod1', 'edge1', 'nod2'], ['nod2', 'edge2', 'nod3']]
db.replace_all_paths(paths)
assert 2 == db.count_paths()
def test_replace_all_paths_doesnt_chang... | true |
985c4c9e3cb951cdc39ba58611de5fb99e598f24 | Python | tylerauerbeck/poolboy | /operator/gpte/util.py | UTF-8 | 3,472 | 2.890625 | 3 | [] | no_license | import collections
import copy
import datetime
import jinja2
import json
class TimeStamp(object):
def __init__(self, set_datetime=None):
if isinstance(set_datetime, datetime.datetime):
self.datetime = set_datetime
elif isinstance(set_datetime, str):
self.datetime = datetime.... | true |