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 |
|---|---|---|---|---|---|---|---|---|---|---|
1f6638c69c1884419917ffae1333933ee960cc1a | resetii/Capstone-MedicationBlockchain | /app.py | UTF-8 | 5,443 | 2.78125 | 3 | [] | no_license | import logging
import os
import sys
from Blockchain import *
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
# Call to sqlalchemy library
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL').replace("://", "ql://", 1)
# ini... | true |
1a13df07f855f7f8298fe3e473bea2932b6b1990 | chencoyote/know_quiz | /spider.py | UTF-8 | 4,847 | 2.578125 | 3 | [] | no_license |
# -*- coding: utf-8 -*-
'''
__auth__ = coyote
主要入口功能函数, 解析选项, 启动任务
'''
from optparse import OptionParser
from knowquiz.tpool import ThreadPool
import logging
import sys
import time
import os
logger = logging.getLogger("spider")
def handler_logger(level, logfile, screen=True):
level_map = {
1: "%(messa... | true |
68e7cf5b54d4085ab60ad38a20316d67bc64bb57 | Dwarf-Community/Dwarf | /core/strings.py | UTF-8 | 843 | 2.6875 | 3 | [
"MIT"
] | permissive | """Externalized strings for better structure and easier localization"""
failed_to_install = "Failed to install '**{}**'."
failed_to_update = "Failed to update '**{}**'."
specify_extension_name = "Please specify a name for this extension (must be a valid Python package name)."
skipping_this_extension = "Not install... | true |
2ee70f94c980c0ca6ca50c65d674a37db354e98a | frackleton/SoftDesSp15 | /toolbox/face_detect.py | UTF-8 | 711 | 2.6875 | 3 | [] | no_license | import numpy as np
import cv2
cap =cv2.VideoCapture(0)
face_cascade= cv2.CascadeClassifier('/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml')
kernel = np.ones((40,40),'uint8')
while(True):
#capture frame by frame
ret, frame = cap.read()
faces = face_cascade.detectMultiScale(frame, scaleFactor=1.2,... | true |
fdd9095e40fc1e0016537c036723b8ae0ca0de87 | xiangz201/Learning-Notes | /python/algorithm/queue.py | UTF-8 | 2,539 | 4.375 | 4 | [] | no_license | # -*-coding:utf-8-*-
"""
自己实现队列
建立头结点类和节点类
队列有一个头结点,头结点左边指向最后一个元素,头结点右边指向第一个元素
节点类有一个指针指向下一个元素,一个指针指向value
实例化操作为a = Queue()
=============================
isEmpty() 判断是否为空,空则返回True,不空则返回False
enqueue(object) 入队
dequeue(object) 出队
top() 返回最顶层元素,但不删除它
size() 返回队列内元素的个数
============... | true |
c9e17ec99da64d2fd6418dc7d2d99de182975e21 | smurphy2230/CSC-121-lab12 | /manage_course_new/course.py | UTF-8 | 1,436 | 3.8125 | 4 | [] | no_license | class Course:
def __init__(self, course_code, max_class_size):
""" constructor for class Course """
self.__course_code = course_code
self.__max_class_size = max_class_size
self.__enrollment = 0
def add_student(self):
enrollment = 1
if self.__enrollment >= self... | true |
60f67ee430e87d147b400745551a043ec5516833 | Srheft/desispec | /py/desispec/io/xytraceset.py | UTF-8 | 5,132 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | """
desispec.io.xytraceset
=================
I/O routines for XYTraceSet objects
"""
import os.path
import numpy as np
from astropy.io import fits
from ..xytraceset import XYTraceSet
from desiutil.log import get_logger
def _traceset_from_image(wavemin,wavemax,hdu,label=None) :
log=get_logger()
head=hdu.hea... | true |
6c809749a0b7e5eb77576b8f9364aded6a4a64d9 | nuprl/retic_performance | /benchmarks/Espionage/typed/union_find.py | UTF-8 | 861 | 2.875 | 3 | [
"MIT"
] | permissive | from retic import fields, Dict, Int, Void, Tuple
@fields({'my_dict': Dict(Int, Tuple(Int, Int))})
class UnionFind:
def __init__(self:UnionFind, my_dict:Dict(Int, Tuple(Int, Int)))->Void:
self.my_dict = my_dict
def add_node(self:UnionFind, n:Int)->Void:
self.my_dict[n] = (n, 0)
def find(s... | true |
26d0581fc3e8162cf3573d7bb4d84afd63170167 | Nayheli/PracticandoF | /Exercise1.py | UTF-8 | 831 | 3.4375 | 3 | [] | no_license | def main():
nombresP=[]
edadP=[]
generoP=[]
N=-1
while N<=0 or N>30:
N = int(input("Ingrese numero de personas: "))
for i in range(N):
nombre=input("Nombre "+str(i+1)+" : ")
nombresP.append(nombre)
ed=-1
while ed<=0 or ed>99:
ed=int(input(... | true |
8239636fd2ad7a2f093dfa5042c72d22f363adbc | liuhadong/7.12 | /18.py | UTF-8 | 446 | 3.59375 | 4 | [] | no_license | name = 123
passwd = 123456
money = 666
name2 = int(input('输入账号:'))
passwd2 = int(input('输入密码:'))
if(name2 == name)and(passwd2 == passwd):
print('开始取钱')
money2 = float(input('请输入取钱金额:'))
if money2 > money:
print('没钱取毛线')
elif money2 <= money:
money3 = 666-money2
print('取了%s钱'%... | true |
8f80edec0e14f14a99fd1540b1a9dcf6b654a6fb | Abimaelh/lpthw | /ex6.py | UTF-8 | 1,158 | 4.71875 | 5 | [] | no_license | types_of_people = 10
#assign the variable the value of int 10
x = f"there are {types_of_people} types of people."
#assign x the f-string with the value of type of people in it.
binary = "binary"
do_not = "don't"
#creates two strings
y = f"Those who know {binary} and those who {do_not}"
#assigns y an f-string va... | true |
41343672c64e3fb2e3bcdd24efe440ae40e7908c | sgelias/kmer-generator | /KmerGenerator/kmerGenerator.py | UTF-8 | 4,194 | 3.28125 | 3 | [] | no_license | import argparse
import itertools
import re
from enum import Enum
from typing import Dict, List
class BaseSet(Enum):
"""
Enum for Base set types.
"""
Pure: str = 'pure'
Dubious2: str = 'dubious2'
Dubious3: str = 'dubious3'
Full: str = 'full'
class KmerGenerator:
__bases_pure = {
... | true |
bf4cd286a127c26cb8092ed8b469dd5fe8f69696 | medviediev/game_server | /map_vision.py | UTF-8 | 3,524 | 3.546875 | 4 | [] | no_license | """
Module for working with visible area on the map.
"""
import time
import threading
import app
import logging_master
class MapVision:
"""
Class for working with visible area on the map.
"""
# Logging trigger attribute
_logging_thread = False
def visible_area_logging(self, area, db_colle... | true |
c357b539e0b67d5137f8a8098bf6249c1d2a9018 | TomAugspurger/dolo | /dolo/compiler/compiler_python.py | UTF-8 | 4,665 | 2.546875 | 3 | [
"BSD-2-Clause"
] | permissive |
class GModel(object):
'''Generic compiled model'''
def __init__(self, model, model_type=None, recipes=None, compiler=None):
# this part is actually common to all compilers
if model_type is None:
model_type = model['original_data']['model_type']
self.model = model
... | true |
75789cfa89f1e68cafc6fb0daf595e2fe6489b1d | pe5/Usein-kysytyt-kysymykset | /application/tasks/models.py | UTF-8 | 1,205 | 2.640625 | 3 | [] | no_license | from application import db
from application.models import Base
from sqlalchemy.sql import text
class Task(Base):
name = db.Column(db.String(144), nullable=False)
done = db.Column(db.String(144), nullable=False)
account_id = db.Column(db.Integer, db.ForeignKey('account.id'),
nul... | true |
c035fb4ced1c4c9d166630ce2ecd1bc801370005 | Jokotoye18/bincom | /bincom_test.py | UTF-8 | 4,722 | 3.109375 | 3 | [] | no_license | import random
import psycopg2
monday_colors = [
"GREEN",
"YELLOW",
"GREEN",
"BROWN",
"BLUE",
"PINK",
"BLUE",
"YELLOW",
"ORANGE",
"CREAM",
"ORANGE",
"RED",
"WHITE",
"BLUE",
"WHITE",
"BLUE",
"BLUE",
"BLUE",
"GREEN",
]
tuesday_colors = [
"AR... | true |
fb13c6f6d71f96a87f4d04eee9bb2dafdd0cb5d7 | nanfeng729/code-for-test | /python/python_course/pythonStudy4/ExceptExample.py | UTF-8 | 1,008 | 3.546875 | 4 | [] | no_license |
def printlistbyInidex(list1, a, b):
try:
for i in range(a, b):
print(list1[i])
except:
print("我被执行了")
def printlistbyInidex2(list1, a, b):
try:
for i in range(a, b):
print(list1[i])
except Exception as e:
print(e)
print("... | true |
2e6405f12efbbcc5e325ae7e2778265c9abd2c4d | Hyeongmin-Kim/algorithm-test | /greedy/s4_1758.py | UTF-8 | 311 | 3.078125 | 3 | [] | no_license | import sys
input = sys.stdin.readline
n = int(input())
tips = [0] * 100001
for i in range(n):
tips[int(input())] += 1
m = 0
res = 0
for i in range(100000, 0, -1):
while tips[i] > 0:
if i - m >= 0:
res += i - m
m += 1
tips[i] -= 1
sys.stdout.write('{}'.format(res)) | true |
78516d1bf96abfc9be86daa251ca32649da93e7a | panbogdan/privatbank-transactions | /demo_privat24.py | UTF-8 | 4,715 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from requests import post
from hashlib import sha1, md5
from string import Template
import datetime
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import xml.etree.ElementTree as ET
class GetTX:
# API endpoint
url = "h... | true |
d9d2af05b705c1fa9c84168d5acd731c1322e247 | GuilhermeEsdras/Mamba-3 | /Exercícios Resolvidos/The Huxley/322 - Menor Valor e Posição.py | UTF-8 | 220 | 3.671875 | 4 | [
"MIT"
] | permissive | N = int(input())
lista = list()
for x in range(0, N):
lista.append(input())
print("Menor valor: {}".format(min(lista)))
for i, v in enumerate(lista):
if v == (min(lista)):
print("Posicao: {}".format(i)) | true |
3ae055fca0083bc59789712a44d292a0b63d5c99 | karpov78/rosalind-algo | /python/perm.py | UTF-8 | 486 | 2.828125 | 3 | [] | no_license | from python.util import printList
def perm(h, t):
if len(t) == 0:
print(printList(h))
return 1
result = 0
for i in range(0, len(t)):
a = t[i]
new_tail = list(t)
del new_tail[i]
result += perm(h + [-1 * a], new_tail) + perm(h + [a], new_tail)
... | true |
e8bbe5321540502ca566437ca6b4e9950c41c223 | poneil1/final-project | /Final_project.py | UTF-8 | 2,919 | 3.109375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 10:49:30 2018
"""
#Code to visulaize changes in the LV and RM models through the use of ggplot
#Library imports
import pandas
import numpy as np
import matplotlib.pyplot as plt
import scipy
import scipy.integrate as spint
from plotnine import *
# Lotka-Volterra mod... | true |
d7386809fe4ee1e837216fa1bfbff330ea66ccdd | jschavem/facial-expression-classification | /source/classification/rfecv.py | UTF-8 | 2,180 | 2.90625 | 3 | [
"MIT"
] | permissive | from sklearn.feature_selection import RFECV
from sklearn.svm import LinearSVC
import csv
import random
import glob
from sklearn.cross_validation import StratifiedKFold
from sklearn import preprocessing
import sys
def load_dataset(dataset, num_files):
data = []
list = glob.glob('../output/%s/*.csv' % dataset)
... | true |
786028ef27ad9cdfddec96463f4bb746242e1e50 | geophysics-ubonn/crtomo_tools | /examples/01_modelling/plot_00_sensitivity.py | UTF-8 | 1,583 | 2.75 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# *-* coding: utf-8 *-*
"""
Plotting sensitivities
^^^^^^^^^^^^^^^^^^^^^^
Sensitivity distributions can be easily plotted using the tdMan class:
"""
###############################################################################
# imports
import numpy as np
import crtomo
# is only used for reda.C... | true |
4b338b6f7b725cdcef55f54e8aebe068591b8b2e | MrHamdulay/csc3-capstone | /examples/data/Assignment_6/gndvah001/question1.py | UTF-8 | 570 | 3.984375 | 4 | [] | no_license | """right align a list of strings
Vahin Gounden
22-04-14"""
#get input
names = input("Enter strings (end with DONE):\n")
#make lists
namelst = []
if names != "DONE":
namelst = [names]
x = 0
#set up sentiniel and add to list
while names != "DONE":
names = input()
if names != "DONE":
... | true |
579c955289d2d8904eb90dc4a80b4cfaad74c405 | yorick76ee/leetcode | /301.py | UTF-8 | 1,673 | 3.1875 | 3 | [] | no_license | class Solution(object):
def replace(self,index,point,now_point):
if now_point < 0:
return
if index >= len(self.s_list):
if point == 0 and now_point == 0:
ee = ''.join(self.s_list)
self.result[ee] = 1
return
if self.s_list[... | true |
fbb013eed6b18f0b7002163672b19a181642b4dc | WajeehAtrash/Alpha_quadratic | /Plot.py | UTF-8 | 730 | 2.984375 | 3 | [] | no_license | # used to see the cloud point plot
from matplotlib import pyplot as plt
def show_Plot(xPoints,zPoints,title='chart'): # shows a plot for the givin points
fig = plt.figure()
plt.plot(xPoints, zPoints, 'o', color='black')
plt.title(title)
plt.ylabel('Y axis')
plt.xlabel('X axis')
plt.show()
d... | true |
b4e3bbff827cd9f1d4a5476b89f84dc68df72271 | shuxinzhang/nltk-learning | /exercises/Chapter 01/01-13.py | UTF-8 | 314 | 3.21875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import matplotlib
matplotlib.use('TkAgg')
import nltk
'''
☼ We have seen how to represent a sentence as a list of words, where
each word is a sequence of characters. What does sent1[2][2] do?
Why? Experiment with other index values.
'''
'''
The third character in the third word.
''' | true |
431b67606dcb9374b19ccb5e0fc60d95353a5f81 | nguyentu1602/pyexp | /pyexp/tcp_client.py | UTF-8 | 523 | 2.9375 | 3 | [
"MIT"
] | permissive | """
tcp_client.py
"""
import socket
import json
client_s = socket.socket()
host = socket.gethostname()
port = 12345
print("about to connect")
client_s.connect((host, port))
message = json.loads(client_s.recv(1024).decode("utf-8"))
print(message)
lst = [1, 4, 4]
client_s.send(json.dumps(lst).encode("utf-8"))
# chat prog... | true |
daebf9aa6fb3dfb1fdc2c64d7d301e65507422be | mdevenish15/SOP3e | /5-27_rectangle.py | UTF-8 | 416 | 3.609375 | 4 | [] | no_license | # the rectangle module has functions that perform calculations related to rectangles
# the area function accepts a rectangles width and length as arguments and returns the rectangles area
def area(width, length):
return width * length
# the perimeter function accepts a rectangles width and length as arguments and... | true |
4acd5d351be40fbde454953281f1a83e20daf526 | nazhimkalam/Machine-Learning | /03. Logistic Regression/Lecture_04 (Logistic Regression Practice Question).py | UTF-8 | 4,084 | 3.90625 | 4 | [] | no_license | # Logistic Regression Practice Question
# ======================================================================================================================
# In this project we will be working with a fake advertising data set, indicating"""" whether or not"""" a particular internet
# user clicked on an Advertisem... | true |
38c02227b1b6d35f7d6b7349f5c4495243ce0ba4 | DavidArmendariz/data-structures-hse | /week4/probability_not_angry.py | UTF-8 | 164 | 3.21875 | 3 | [] | no_license | def not_angry(n):
tbl = [1] * (n + 1)
if n > 0:
tbl[1] = 2
for i in range(2, n + 1):
tbl[i] = tbl[i - 1] + tbl[i - 2]
return tbl[n]
| true |
968e5c0d1de73843b2a1b20f9adba153db003e8c | ysyesilyurt/escalate-the-priviliges | /saldir.py | UTF-8 | 2,046 | 3.625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
#
# This is an example of famous privilege escalation attack.
#
# This script exploits a program running on a remote machine to gain a root access.
#
# Program running on the remote machine is given as 'overwrite' and it is compiled with
# gcc -m32 -o overwrite overwrite.c which means it has all... | true |
6670f55da28deb0e612e97d3b6147787c61ceb24 | tyronehou/boston-traffic-ml | /traci_tls/readtripinfo.py | UTF-8 | 2,131 | 3.1875 | 3 | [] | no_license | import xml.etree.ElementTree as ET
import argparse
def get_arguments():
argParser = argparse.ArgumentParser()
argParser.add_argument("fname")
args = argParser.parse_args()
return args
def parse_xml(fname):
with open(fname) as f:
output_xml = f.read()
# Sumo seems to write inc... | true |
de43a0d217aba42413438a5904c5fb97392eb905 | heraldjose10/Youtube-Spotify-playlist-migrator | /spotify_to_youtube.py | UTF-8 | 5,324 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed May 13 22:10:46 2020
@author: herald jose
"""
import requests
import json
#Input refresh token to get refresh access token
def GetYTAccessToken():
url1='https://accounts.google.com/o/oauth2/token'
data1={
'client_id' : '[YT_CLIENT_ID]',
'cli... | true |
cd3c9a3c0d7b48c7a43183fc929711888c3fea81 | capuanob/Uchat | /Uchat/helper/validators.py | UTF-8 | 715 | 3.515625 | 4 | [] | no_license | """
Functions that can be used throughout the program for validating user input
"""
def is_valid_ipv4(txt: str):
"""
Determines whether the given input is a valid IPv4 address (0-255.0-255.0-255.0-255)
:param txt: A possible IPv4
:return: whether or not the txt is a valid IPv4
"""
ip_bytes = t... | true |
4c0e68381e404e20517373a0e8a53f8ac68a5b4a | quantmind/lux | /lux/ext/auth/commands/create_superuser.py | UTF-8 | 2,980 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | """Management utility to create superusers."""
import getpass
import json
from pulsar.api import UnprocessableEntity
from lux.core import LuxCommand, Setting, CommandError
def get_def_username():
# Try to determine the current system user's username to use as a default.
try:
def_username = getpass.g... | true |
f7087dfd55bf250b127a46c2e59f384be82c7e70 | jonbos/RomanNumerals | /src/numeral_mapping.py | UTF-8 | 512 | 3.296875 | 3 | [] | no_license | number_to_numeral = {
1: "I",
5: "V",
10: "X",
50: "L",
100: "C",
500: "D",
1000: "M"
}
def get_decimal_value_from_numeral(numeral):
return [dec for dec, numer in number_to_numeral.items() if numer == numeral][0]
def get_numeral_from_decimal_value(decimal):
return number_to_numer... | true |
8f8e053bea769f679e07adce948de91981a7675b | r-malon/python-code | /OLD/tintaria.py | UTF-8 | 372 | 3.75 | 4 | [] | no_license | area= float(input("Digite a área: "))
tinta=area/6
lata=tinta//18
gal=tinta/4#não lembro como era o problema original
if 12 <= tinta <= 18:
print("Você usou 1 lata e vai pagar R$ 80!!!")
elif tinta%18 <= 12:
print("Você usou",lata,"latas, 3 galões e vai pagar R$",(lata*80)+(gal*25))
elif tinta <= 4:
pri... | true |
55dd233f9431b1993ab69f9e173741a69c80c29c | frumiousbandersnatch/cobe | /tests/test_utils.py | UTF-8 | 1,524 | 3.375 | 3 | [
"MIT"
] | permissive | # Copyright (C) 2012 Peter Teichman
# coding=utf8
import time
import unittest2 as unittest
from cobe import utils
class ITimeTest(unittest.TestCase):
def test_itime(self):
seq = ["one", "two", "three"]
# Surely the unit test harness can yield the three above items in 1s
self.assertSeque... | true |
71ee1e0319f72c4bc472d6cc38688c72fd516b25 | zxc19990331/MyPythonWeb | /www/_site/apis.py | UTF-8 | 1,456 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'Json API definition'
__author__ = 'Engine'
import json
import logging
import inspect # the module provides several useful functions to help get information about live objects, such as modules, classes, methods, functions.
import functools # 该模块提供有用的高阶函数.总的来说,任何callabl... | true |
76327bf1e971d92dbf8a3bfb62402bdc097e5ae9 | alephic/RogueQuestAdventure | /RQA.py | UTF-8 | 22,840 | 2.578125 | 3 | [] | no_license | import libtcodpy as libtcod
import random
import math
import RQA_lists as lists
vowels = ['a','e','i','o','u']
MAP_WIDTH = 80
MAP_HEIGHT = 50
PANEL_HEIGHT = 15
STATS_WIDTH = 20
INVENTORY_WIDTH = 25
SCREEN_WIDTH = MAP_WIDTH
SCREEN_HEIGHT = MAP_HEIGHT + PANEL_HEIGHT
ROOM_MAX_SIZE = 15
ROOM_MIN_SIZE = 5
MAX_ROOMS =... | true |
2df05235e11b4f969f147ffa6dcde19ceb0c0dec | VB-Cloudboy/PythonCodes | /10-Tuples/02_Access-Tuple.py | UTF-8 | 403 | 4 | 4 | [] | no_license | mytuple = (100,200,300,400,500,600,700,800,900)
#1. Print specific postion of the tuples starting from Right
print(mytuple[2])
print(mytuple[4])
print(mytuple[5])
#2. Print specific postion of the tuples starting from Left
print(mytuple[-3])
print(mytuple[-5])
print(mytuple[-4])
#3. Slicing (Start: Stop: Stepsize)
... | true |
ee797cee5ae487aef59cc57a63eb08b1e7180c9c | perrygeo/python-rasterstats | /examples/multiproc.py | UTF-8 | 927 | 2.578125 | 3 | [] | permissive | #!/usr/bin/env python
import itertools
import multiprocessing
import fiona
from rasterstats import zonal_stats
shp = "benchmark_data/ne_50m_admin_0_countries.shp"
tif = "benchmark_data/srtm.tif"
def chunks(data, n):
"""Yield successive n-sized chunks from a slice-able iterable."""
for i in range(0, len(dat... | true |
1e25c7a5db4fd826bd5642c54ed566bfebfe6d8d | zaher-aa/Python-Projects | /class.py | UTF-8 | 1,513 | 3.84375 | 4 | [] | no_license | from abc import ABC, abstractmethod
class Vehicle(ABC):
def __init__(self, name, color):
self.__name = name
self.__color = color
def get_color(self):
return self.__color
def get_name(self):
return self.__name
def __str__(self):
return f"I am a {self.__name}"
... | true |
d21f0aa7fb166c45202a13029de2cecb4741d412 | shitterlmj2016/95888_Data_Focused_Python | /A1-2/assignment01_student.py | UTF-8 | 5,628 | 3.1875 | 3 | [] | no_license | import os
import json
import csv
import argparse
import fhirclient.models.bundle as bu
import fhirclient.models.claim as cl
"""In this assignment you will generate a set of synthetic healthcare data
using the synthea tool discussed in class. For the purposes of the assignment
you can generate as few or as many patien... | true |
089d82644a84b284d7f45ff2e9671daee598e35f | YaChenW/MachineLearning | /SimpleLinearRegression.py | UTF-8 | 1,535 | 3.28125 | 3 | [] | no_license | import numpy as np
from .metrics import r2_score
class SimpleLinearRegression:
def __init__(self):
self.a_ = None
self.b_ = None
def fit(self,x_train,y_train):
'''根据x_train,y_train训练simpleLinearRegression训练模型'''
assert x_train.ndim == 1,\
'simpleLinearRegression ca... | true |
ad0698cbb15f06d97bb32a3a3a3cf76a52268bb1 | Borillion/CSUMBMasterMind | /Labs/Lab_16.py | UTF-8 | 1,412 | 2.671875 | 3 | [] | no_license | import re
import urllib
## Using CNN.COM
def makePage():
file = open("/home/babak/superweb.html", "wt")
file.write("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transition//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>I made this page with Python!</title>
</head>
<body>""")
... | true |
d2cff36c466ea5e4e9d6a36acaacf7040efda350 | extraridder/Checkio | /Hidden word.py | UTF-8 | 1,118 | 3.171875 | 3 | [] | no_license | def checkio(text, word):
#print(text,word,sep="\n\n")
a = text.replace(" ","").lower().split("\n")
print(a)
print(a[0],word[0],word[0] in a[0],(a[1].index(str(word[0])) + 1) if word[0] in a[1] else "not found")
for each in a:
i = a.index(each)+1
if word[0] in a[i-1]:
pass... | true |
5f4aef7f3dd7c865dfad858cf966fb8991592423 | mikejqzhang/FakeNewsChallenge | /TfidfFeature.py | UTF-8 | 2,816 | 2.96875 | 3 | [] | no_license | from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import numpy as np
import file_handling as fh
import re
import pickle
from tqdm import tqdm
# (1)preprocess the text and separately extract headlines, bodies, stances, and pairs of headlines+bodies
def ex... | true |
3b2c0e00092e3a65a35e128b35c8618270890bfd | sunshinedude/practice | /leetcode/1025_divisor_game.py | UTF-8 | 1,273 | 4.375 | 4 | [] | no_license | # Problem
# Alice and Bob take turns playing a game, with Alice starting first.
#
# Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of:
#
# Choosing any x with 0 < x < N and N % x == 0.
# Replacing the number N on the chalkboard with N - x.
# Also, if a pla... | true |
6cb4461241f60feed22d79ab646bf2a0beee6227 | ssongkim2/algorithm | /1234-비밀번호/sol2.py | UTF-8 | 414 | 3.171875 | 3 | [] | no_license | T = 10
for tc in range(1, T + 1):
n, password = input().split()
stack = []
idx = 0
while idx < int(n):
if not stack:
stack.append(password[idx])
else:
if stack[-1] != password[idx]:
stack.append(password[idx])
else:
sta... | true |
5f6c7454abf72d9be59c16e523f0de89b561d196 | Nicolanz/AirBnB_clone_v2 | /models/state.py | UTF-8 | 670 | 2.703125 | 3 | [] | no_license | #!/usr/bin/python3
""" State Module for HBNB project """
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from models.base_model import BaseModel, Base
from models.city import City
class State(BaseModel, Base):
""" The city class, contains state ID and name """
... | true |
c9baf158f392c327b3311e34c3ff7dbb7f89aa47 | Okiii-lh/to_offer_note | /python/斐波那契数列2.py | UTF-8 | 201 | 3.3125 | 3 | [] | no_license | # encoding=utf-8
#
def fib(N):
if N < 0 :
return 0
if N == 1 or N == 2:
return 1
res = []
res[1] = res[2] = 1
for i in range(3, N+1):
res[i] = res[i-1] + res[i-2]
return res[N]
fib(5) | true |
cbeea98a6046388a9a53b7e25bb066e04e78c063 | yangyuxin325/SmartNew | /SmartNew/Device/device.py | UTF-8 | 3,309 | 2.65625 | 3 | [] | no_license | #coding=utf-8
#!/usr/bin/env python
'''
Created on 2015年7月8日
@author: sanhe
'''
device_Dict = {}
class device():
def __init__(self, dev_id, dev_type):
self._dev_id = dev_id
self._dev_type = dev_type
self._datadict = {
}
self._otherkeys = {}
self._c... | true |
f3f3e41a89b0fdfefbb240d909a7117a17a7ad4e | shifalik/practice | /shifali/classes.py | UTF-8 | 8,220 | 3.90625 | 4 | [] | no_license | '''
Created on Feb 14, 2018
@author: shifa
'''
# CLASSES
#---------------------------------------------------------
# creating a class format
# class ClassName:
# 'Optional class documentation string'
# class_suite
#---------------------------------------------------------
class Employee:
'Common bas... | true |
c4f50ba1ed6ac01866e8028dd40afecb67c68bec | B05901022/ML2018FALL | /hw2/train_best.py | UTF-8 | 11,379 | 2.8125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 19 09:40:24 2018
@author: Austin Hsu
"""
#######################
## ##
##Logistic Regression##
## ##
#######################
import pandas as pd
import numpy as np
#np.set_printoptions(suppress=True)
x_train = pd.read_csv('train_x.c... | true |
2db63459ec93f0a23fff9a17742977598daff8cf | gemxx/swfpack | /lzma.py | UTF-8 | 2,179 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
import os
import pylzma
import sys
import struct
import zlib
def check(test, msg):
test or exit(msg)
def convert(infile, outfile):
fi = open(infile, "rb")
swf_size = os.path.getsize(infile)
swf_data = fi.read()
fi.close()
check((swf_data[1] == 'W') and (swf_data[2] == 'S'),... | true |
bbd3c28e5868d091aae2030cc0780d4beeed7c32 | OpenImaging/miqa-web | /mriqc/mriqc/model.py | UTF-8 | 2,433 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 25 17:37:09 2019
@author: dhruv.sharma
"""
from sklearn.ensemble import RandomForestClassifier
from sklearn.externals import joblib
from datetime import datetime
import os
import glob
class Model():
'''
This class defines the model that w... | true |
4e0ca78d6332f3757d981c8d39573a5e5d56a524 | tomkf/python | /louchebem.py | UTF-8 | 1,616 | 3.53125 | 4 | [] | no_license | import random
# first consonant group (letters before the first vowel), and replace it with an "L".
# Then, you put that first consonant group at the end of the word, followed by one of the louchebem suffixes
# So "PATRON" becomes "LATRONPEM"
#words beginning with consonants ("chat", "trou"), you'll have to take t... | true |
1df2d26ccf234b03dc91ac26e806018927c1360c | renidantass/learning_python | /exercises/webscrap.py | UTF-8 | 781 | 3 | 3 | [] | no_license | # coding:utf-8
"""
Exercícios de: https://github.com/pythoneiros/Exercicios#lista-de-exercícios-já-propostos
"""
from bs4 import BeautifulSoup
import requests
class Scrapping(object):
def __init__(self, link):
self.response = None
self.link = link
self.__get()
self.getting_li... | true |
f1a497a585c592f75251f9fbc37090698bcca62e | DTDevelop/board-game | /main/test/character_class_test.py | UTF-8 | 842 | 3.453125 | 3 | [] | no_license | """
Testing creation and features of character object
"""
import character_class as char
#creation
print('--TESTING CREATION--')
person_1 = char.Character(25)
print('calculated:', person_1)
print('expected: Character(25, set(), [], [])')
print('')
#cash features
print('--TESTING CASH FEATURES--')
pers... | true |
e35daa0a9ece7c70cec19fb8c7590836cf767f8e | team-cardo/CardoLibs | /CardoLibs/Cleansing/FormatTypesToString/TypeFormatters/BinaryFormatter.py | UTF-8 | 513 | 2.546875 | 3 | [] | no_license | from CardoLibs.Cleansing.FormatTypesToString.ITypeFormatter import ITypeFormatter
from pyspark.sql.functions import udf
from pyspark.sql.types import BinaryType
class BinaryFormatter(ITypeFormatter):
def __init__(self):
self.__convert_udf = udf(BinaryFormatter.__convert)
def is_type(self, spark_type):
return t... | true |
be612758056175cd32eec359fe081b4490a322c9 | aukeman/pygame_thing | /object_pool.py | UTF-8 | 422 | 3.078125 | 3 | [] | no_license | class ObjectPool:
def __init__(self, size, pooled_type, *init_args):
self.pool=[ pooled_type(*init_args) for i in range(0,size) ]
self.current_idx=0
def __call__(self,*args):
result=self.pool[ self.current_idx ]
self.current_idx += 1
if self.current_idx == len(self... | true |
d8654c14818e45fb61d5a6ef50c3589bf3a1e906 | zhengyu19921215/image_gen | /gen/alphabet.py | UTF-8 | 3,991 | 2.546875 | 3 | [] | no_license | import random
# import matplotlib.pyplot as plt
import xlrd
import datetime
from PIL import Image,ImageDraw,ImageFont,ImageFilter
#字体的位置,不同版本的系统会有不同BuxtonSketch.ttf
# font_path = 'Fonts/HiraMinPro-W3.otf'
#font_path = 'C:/Windows/Fonts/默陌肥圆手写体.ttf'
#背景颜色,默认为白色
#bgcolor = (255,255,255)
#字体颜色,默认为蓝色
fontcolor = (105,10... | true |
61fa19ef0c6743cf63fc8c3b7e18686facabe4a5 | Tavaresl95/Learning-Python | /ex02.py | UTF-8 | 1,090 | 4.15625 | 4 | [] | no_license | #Um Programa que calcula equações do 2o grau
'''
Formula de Baskara
x * * 2 + x + nun = 0
delt = B * * 2 + 4ac
x = -(b) + -{raiz delta} / 2a
author: Victor D.C.C
'''
#Imports
# Variables and Execution
a = int(input('Digite o Elemento A da equação: '))
b = int(input('Digite o Elemento B da equação: '))
c = int(inpu... | true |
8a9fef4240fce8360d4e40db96ec5bb35a94df9d | eric-yyjau/DreamBook | /src/pdf/pdf2img.py | UTF-8 | 1,757 | 2.90625 | 3 | [] | no_license | from pdf2image import convert_from_path
import cv2
import numpy as np
import time
class PdfFile:
def __init__(self):
self.pages = []
self.totalPgs = 0
pass
def readFile(self, filename):
self.pages = convert_from_path(filename)
self.totalPgs = len(self.pages)
se... | true |
316ad39df9b8203b1b2b04d6f5d7a68561f70f72 | u3aftab/Project-Euler | /Euler31.py | UTF-8 | 749 | 3.546875 | 4 | [] | no_license | ## How many different ways can $2 be made using any number of coins?
## 1p, 2p, 5p, 10p, 20p, 50p, $1 (100p) and $2 (200p).
def not_in(l1, l2): ##l2 is a list of lists
for x in l1:
l2=filter(lambda y: x not in y, l2)
return l2
coins=[1, 2, 5, 10, 20, 50, 100, 200];
combs=[[], [[1]], [[2], [1, 1]]]
i=3... | true |
cb23249e8ab9c330c1e70be3039686a694720d1a | dorbodwolf/OpenSatelliteImageFusion | /src/cover.py | UTF-8 | 8,750 | 2.71875 | 3 | [] | no_license | from filter import Filter
from GeoMetDemo import dumps as dumpWKT
from shapely import wkt
import numpy as np
import copy
from setting import INTERSECT_AREA_PARTION
class Cover:
"""
指定空间范围、时间范围和分辨率范围的最优影像覆盖分析
"""
items = []
def __init__(self, itemList):
self.items = itemList
def _round_... | true |
77b2fc9cc3a4bfc22ec85b584d231d66517889f5 | hiten2/Project | /db/db.py | UTF-8 | 8,792 | 2.828125 | 3 | [] | no_license | # Copyright (C) 2018 Bailey Defino
# <https://bdefino.github.io>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Thi... | true |
d98d7163262cb6d6cab51aacddb16837ddf1ab49 | liu-yunfei/COMP1002GroupProject | /DirectReport.py | UTF-8 | 912 | 3.046875 | 3 | [] | no_license | """This function is used to return the direct report
it receives a post title and return a list of direct report, return an empty list when no report
Written by Yunfei LIU
Edit log:
Oct 29, 2020 created"""
def DirectReport(anchor):
import os
postFileList = os.listdir("post")
reportList = []
for postFi... | true |
7a618bdcfeb2d607152def346e7dd80e1d41a632 | zaxliu/emc-sjtu | /log_user_trade.py | UTF-8 | 1,440 | 3.0625 | 3 | [] | no_license | #coding=utf-8
import os
import csv
dictionary = {}
def addtrade(cardID, amount):
if not dictionary.has_key(cardID):
dictionary[cardID] = amount
else:
dictionary[cardID] += amount
# pick up each user's total amount of consumption. return dictionary = {cardID: amount}
def tradePick(net_trade_pa... | true |
b1bc0cd5104719ecc39ea676e30eacb4757c4fd0 | nawww83/generator_idz | /gen_idz_02.py | UTF-8 | 2,990 | 3.015625 | 3 | [] | no_license | # Модуль генерирует файл с Заданием № 02
from openpyxl import Workbook
from openpyxl.styles import Font
import linear_codes as lc
import sys
from pprint import pprint as pp
import numpy as np
import pytils.translit
import re
def has_numbers(s):
return re.search('\d', s)
def generator(group, student, task_code):
... | true |
581635fae25e099d6012b135f79fc6b53c412218 | typemegan/Python | /CorePythonProgramming_2nd/ch13_classes/initDel.py | UTF-8 | 437 | 2.890625 | 3 | [] | no_license | #!usr/bin/python
class P(object):
def __init__(self):
print 'P init'
def __del__(self):
print 'P del'
class C(P):
def __init__(self):
print 'C init'
def __del__(self):
P.__del__(self) # 1
print 'C del'
mc = C()
mv = mk = mc
print '1:',
del mc
print '2:',
del mk
print '3:',
del mv
print 'end... | true |
6ef3482274839b78700204792566583840439d5a | gsandova03/taller3_int_computacional | /punto7.py | UTF-8 | 372 | 3.453125 | 3 | [] | no_license | def total_compra():
articulos = []
total_compra = 0
for n in range( 1, 5+1 ):
precio = float( input(f'Precio articulo { n }: ') )
articulos.append( precio )
for articulo in articulos:
cantidad = int( input(f'Cantidad del articulo { articulo }: ') )
total = articulo * cantidad
total_compra ... | true |
2e3e8bea8797487480bcad9acb60ea9e8771e019 | Eric-Z0/SOEN487_A1 | /models.py | UTF-8 | 1,992 | 2.65625 | 3 | [] | no_license | from sqlalchemy import event
from sqlalchemy.engine import Engine
from sqlite3 import Connection as SQLite3Connection
from database import db
@event.listens_for(Engine, "connect")
def _set_sqlite_pragma(dbapi_connection, connection_record):
if isinstance(dbapi_connection, SQLite3Connection):
cursor = dbap... | true |
501bfbc57259fb4280bc852c2be7e31e93178dcc | desihub/desispec | /py/desispec/scripts/archive_tilenight.py | UTF-8 | 14,154 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
"""
Utility script to remove archive tiles for the merged target list (MTL).
"""
import os, sys, glob
import argparse
import subprocess
import shutil
import stat
import datetime
import numpy as np
from astropy.table import Table
from astropy.io import fits
from desiutil.log import get_logger
f... | true |
0f41976e142037c6c56920abe66c470c4a097e2b | inderdevkumar/2020-Python-Projects | /December_2020/December_2020/14_dec_2020/vowels.py | UTF-8 | 1,289 | 3.796875 | 4 | [] | no_license | # ================= Function Defination ===========================
def no_vowels(input_file, output_file):
try:
with open(input_file,'r') as file: #Opening my input file in read mode
lines= file.readlines() #Reading contents of text as list
my_string= ""
... | true |
a1bafd5d5ac8724e5c354469c063a5517c78f4f5 | krishjadhwani/python | /hourglass.py | UTF-8 | 852 | 3.0625 | 3 | [] | no_license | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the hourglassSum function below.
def hourglassSum(arr):
max = 0
index = (0, 0)
for i in range(len(arr) - 2):
for j in range(len(arr[i]) -2):
candidate = arr[i][j] + arr[i][j+1] + arr[i][j+2] + arr[i+1][j+1] + arr[i+2][j] + arr[... | true |
bafab293984e17e45a9d034ec304a9422b708970 | hallgrimur1471/programming | /python_experiments/fibo.py | UTF-8 | 508 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env python3
# Fibonacci numbers module
BOLTZMANN_CONSTANT = 8.6173303 * 10**-5
# write Fibonacci series up to n
def fib(n):
a, b = 0, 1
while b < n:
print(b, end=' ')
a, b = b, a+b
print()
# return Fibonacci serios up to n
def fib2(n):
result = []
a, b = 0, 1
while... | true |
68919c4fac28b9113286378ec41564a3f5a6d708 | Jackiu1997/gcransac-python | /estimator/estimator_fundamental.py | UTF-8 | 8,491 | 2.796875 | 3 | [] | no_license | import math as m
import sys
import numpy as np
import numpy.linalg as linalg
from gcransac.gcransac import GCRANSAC
from model import *
from sampler import UniformSampler
from solver import (SolverFundamentalMatrixEightPoint,
SolverFundamentalMatrixPlaneParallax,
SolverFundamen... | true |
dcff0051a70d700226e4ec10ef60970923d2ebc9 | anirudhya1978/micro_create_customer | /create_customer_api.py | UTF-8 | 689 | 2.671875 | 3 | [] | no_license | #this is the api wrapper for create customers to be deployed in a container
from flask import Flask, jsonify, request
from create_customer import create_customer
app= Flask(__name__)
@app.route('/')
def hello():
return "API for Create Customers !"
@app.route('/create_customer', methods=['POST'])
def create_custo... | true |
0c00b71559b58f7e98e0beb33f5dcb6f3b15159a | MariaRigaki/pmtk3-python | /demos/bernoulliEntropyFig.py | UTF-8 | 265 | 2.78125 | 3 | [] | no_license | from scipy import stats
import pylab as plt
import numpy as np
x = np.arange(0.0001, 1.0, 0.0001)
H = -(x*np.log2(x) + (1-x)*np.log2(1-x))
plt.plot(x, H)
plt.xlabel('p(X = 1)')
plt.ylabel('H(X)')
plt.xticks([0.0, 0.5, 1.0])
plt.yticks([0.0, 0.5, 1.0])
plt.show() | true |
f5de1f10dc456a0b93a83e68af9e5273b02caff5 | qorzj/py-daily | /2017-04-06_10000-days-after/zhangji/solution.py | UTF-8 | 896 | 3.03125 | 3 | [] | no_license | from datetime import datetime, timedelta
import re
def calc_date_delta(query):
"""
>>> calc_date_delta('1 days after 2017-04-30')
'2017-05-01'
>>> calc_date_delta('2 days before 2017/5/1')
'2017-04-29'
>>> calc_date_delta('10000 days after 1993/3/6')
'2020-07-22'
"""
segs = query.lo... | true |
1bd4fc155ff5547ca71c07b348a6e7cabcd579bb | prateekmehrotra/HackerRank-Algorithms | /LibraryFine.py | UTF-8 | 703 | 3.015625 | 3 | [] | no_license | __author__ = 'PrateekMehrotra'
import sys
from datetime import date
d1 = input()
d2 = input()
d1Split = d1.split(' ')
d2Split = d2.split(' ')
if (d1Split[0] <= d2Split[0] and d1Split[1] <= d2Split[1] and d1Split[2] <= d2Split[2]) or (d1Split[1] < d2Split[1] and d1Split[2] <= d2Split[2]) or (d1Split[2] < d2Split[2]):
... | true |
fbbff6a174903472cdfc8474d040b098e8bb629e | Mirocle007/Reinforcement_Learning | /2Qtable_2d_env/maze_env.py | UTF-8 | 8,078 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | """
Maze environment for reinforcement learning, with the python package tkinter.
Red rectangle: explorer.
Black rectangle: hells [reward = -1]
Yellow bin circle: paradise [reward = +1]
All other state: ground [reward = 0]
Alse referenced the tutorial of morvanzhou: https://morvanzhou.github.i... | true |
4163ca16610a1bff8935f52c150b47d3f26fa8ca | Gabriel-Gutic/Minecraftable | /Minecraftable/recipes/smelting_recipe.py | UTF-8 | 2,943 | 3.09375 | 3 | [] | no_license | from .recipe import RawRecipe
from Minecraftable.printer import print_error
class SmeltingRecipe(RawRecipe):
def __init__(self):
super().__init__()
self.ingredients = []
self.experience = 0
self.cooking_time = 200
def type(self):
return 'smelting'
def add_ingre... | true |
87aa51bc47ed26d0d1a6285ab6f8f2f27b399e9d | YK135915/mmfashion | /mmfashion/core/evaluation/cate_predict_eval.py | UTF-8 | 3,034 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
import torch
class CateCalculator(object):
"""Calculate Category prediction top-k recall rate
"""
def __init__(self, cfg, topns=[1, 3]):
self.collector = dict()
self.num_cate = cfg.category_num
self.topns = topns
# true positive
for topi in topns... | true |
c889d30cd5fc1e49ef2a329344d983dd93e7b9da | goulet-coder/Cryptography | /SimpleSubstitution.py | UTF-8 | 1,004 | 4.15625 | 4 | [] | no_license | # The following code is from:
# https://stackoverflow.com/questions/36188226/substitution-cipher-python
import random
#Normal Alphabet list to compare to.
alphabet = 'abcdefghijklmnopqrstuvwxyz.,! '
#Substitution values
key = 'nu.t!iyvxqfl,bcjrodhkaew spzgm'
# The message we want to encrypt or decrypt
plaintext = "... | true |
1a88760f9f826f60f2a8f921ff517b4d116b201a | xfxf/video-scripts | /carl/ansible-misc/mk-hosts.py | UTF-8 | 2,598 | 2.796875 | 3 | [] | no_license | #!/usr/bin/python
# mk-hosts.py - Makes /etc/hosts entries from ips found in juju status
import argparse
import json
import subprocess
def get_status():
p=subprocess.Popen(['juju', 'status', '--format', 'json'], stdout=subprocess.PIPE)
sout,serr = p.communicate()
return sout
def parse_status(s):... | true |
82a9886a3e398e41566c8cf1a61c09d978a7a4e1 | satra/nipype | /examples/howto_caching_example.py | UTF-8 | 1,454 | 2.890625 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | """
===========================================
HOWTO: Using caching without using Workflow
===========================================
Using nipype in an imperative way: caching without workflow
Note that in the following example, we are calling command-lines with
disk I/O that persists across runs, but we never hav... | true |
2c5dedaf84dd16309ed8110a3450dc15db701b0e | okada-datasign/segment-expression | /main.py | UTF-8 | 1,402 | 3.28125 | 3 | [] | no_license | import yaml
from expression import compile, compiles, evaluate
user_attributes = {
'first_name': 'foo',
'last_name': 'bar',
'gender': 'Cis Female',
'age': 40,
}
bank = [
{
'name': 'MUFJ',
'branch': 'Shibuya',
'amount': 1000000,
},
{
'name': 'MIZUHO',
... | true |
420c2597a6482587be6120a4715b63577957fe2e | y-xue/Exercises-of-Intro-to-AI | /Ex4-SentimentAnalysis/freq_bigram.py | UTF-8 | 5,197 | 3.046875 | 3 | [] | no_license | # Name:
# Date:
# Description:
#
#
import math, os, pickle, re
class Bayes_Classifier:
def __init__(self, eval = False):
"""This method initializes and trains the Naive Bayes Sentiment Classifier. If a
cache of a trained classifier has been stored, it loads this cache. Otherwise,
the system wi... | true |
5da36ca8982619be49e9168ddbe5054704d3decd | MarcoMontevechiFilho/Solucao | /piramide.py | UTF-8 | 268 | 3.453125 | 3 | [] | no_license |
def piramide(n):
comp = 2*n-1;
for k in range(0,n):
for i in range(0,comp):
if abs(i+1-n) > k:
print('_',end='')
elif abs(i+1-n) <= k:
print('*',end='')
print('\n')
| true |
45d7d819d748f1e3c8f5d6aaede4e79d9f9e3133 | chelo26/models_from_scratch | /nesterov.py | UTF-8 | 2,603 | 2.890625 | 3 | [] | no_license | from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import os
from sklearn.datasets import load_iris
from sklearn import preprocessing
#from tensorflow.examples.tutorials.mnist import input_data
# Scaling the function
def scaling(x):
x=x-np.mean(x,0)
x=x/np.std(x,0)
return x... | true |
40840213025a87ee21485225a441ecd8b4398ed1 | rain567/liupanshui_job | /second_time/selecatJob01.py | UTF-8 | 83 | 3.34375 | 3 | [] | no_license | list_a = [5,2,10,6,8,13,7]
list_a.reverse()
# print(list_a[2])
print(list_a[-1]) | true |
6544c03db30c59df21794b9f5018883f1e3facac | SpacemanSpiff7/kmer_data | /ref_var_dict/results_30Oct2019-1154/fixheader.py | UTF-8 | 448 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env python3
import os
import shutil
import sys
def fix_bad_header(filep):
from_file = open(filep, 'r')
line = from_file.readline()
to_file = open(filep, 'w')
nline = line.split('REF_vcf')
to_file.write(line[:-len(nline[1])] + '\n')
to_file.write(nline[1])
shutil.copyfileobj(from... | true |
d767b828864bbc99e55e0bd0161e3d44a7f9bee5 | 42esoulard/42AI_PythonBootcamp | /day00/ex07/filterwords.py | UTF-8 | 399 | 3.015625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import string
if len(sys.argv) is 3 and sys.argv[1].isnumeric() is False:
try:
inp = sys.argv[1].split()
min = int(sys.argv[2])
res = list()
for a in inp:
for b in a:
if b in string.punctuation:
a = a.replace(b, '')
if int(len(a)) > min:... | true |
bc3c8ac4a81cb09e09a278f403c23f7abf5cf3c5 | yuu-eguci/line-messaging-api-py | /my_flask_script.py | UTF-8 | 4,832 | 2.546875 | 3 | [] | no_license | """
line-bot-sdk v3 にちゃんと対応してるよ!
NOTE: このへん↓が参考になるよ!
https://github.com/line/line-bot-sdk-python/blob/master/examples/flask-echo/app_with_handler.py
"""
from flask import Flask, request, abort
from linebot.v3 import (
WebhookHandler
)
from linebot.v3.exceptions import (
InvalidSignatureError
)
from line... | true |
7de9e1500c67109f96df6435cc662607a53cdb89 | Bernardomrf/SmartLighting-Gateway | /modules/converter.py | UTF-8 | 837 | 2.6875 | 3 | [] | no_license | class Converter:
def get_converter(_type, max_lux=None):
if _type == 'lux_to_percentage':
return LuxToPercent(max_lux)
elif _type == 'set_to_1':
return SetTo1()
elif _type == 'set_to_0':
return SetTo0()
else:
return None
def na... | true |