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 |
|---|---|---|---|---|---|---|---|---|---|---|
4c55dff779456b9ec887ec7fd2aaed110fe6003b | love-adela/algorithm-ps | /acmicpc/2161/solution-tail-recursion.py | UTF-8 | 626 | 3.65625 | 4 | [
"MIT"
] | permissive | from sys import setrecursionlimit
"""
1. N번 동안 맨 위에 있는 카드 버리고 출력하기
2. 제일 위의 카드 맨 밑으로 옮기기
"""
def move_top_to_bottom(num_lst:list)->list:
return num_lst[1:] + [num_lst[0]]
def discard_top_card(num_lst:list)->list:
return num_lst[1:]
def main(numbers):
print(numbers[0], end=' ')
if len(numbers) == 1:... | true |
882719c148d55ee96ac1b03d8026bd267b1c8bd2 | wangjunxiao/privacy-transaction | /evaluate/external/ari.py | UTF-8 | 479 | 2.75 | 3 | [
"MIT"
] | permissive | import numpy as np
from sklearn.metrics import adjusted_rand_score
'''
ari in [-1,1], clustering is better when closing to 1
'''
#Adjusted Rand Index
def eval_ari(labels, assignments):
result_ARI = adjusted_rand_score(labels, assignments)
return result_ARI
def test():
labels_true = np.array([0, 0, 0,... | true |
250e46d555e0872ec80bb7bc376f879177e0692a | BarisATAK/NetworkProgrammingProjects | /ChatRoom/ChatApp-Client.py | UTF-8 | 3,141 | 2.84375 | 3 | [] | no_license | from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
from tkinter import*
from PIL import ImageTk, Image
from PIL import ImageTk as itk
def Receive():
while True:
try:
message = clientSocket.recv(BufSize).decode("utf8")
messageList.insert(END, message)
except OSError: # Possibly clie... | true |
4e0cb9f73e404d5253c823a136865a491afff346 | lcwspr/Python | /999_test/python复习/python 基础/8 python 函数/10 递归函数.py | UTF-8 | 728 | 3.734375 | 4 | [] | no_license | """
递归函数
体现
函数A内部 继续调用函数A
概念 传递 回归
注意事项
案例
"""
# 递归求取阶乘
# 功能 如果是不直接知道结果的数据 就进行分解 (递归调用)
# 如果是知道结果的数据 就直接返回
def get_num(num):
if num < 0:
print("error")
elif num <= 1:
return 1
else:
return num * get_num(num - 1)
l = [... | true |
79f718f3b21e74494c07c021fabdbfc330f03d27 | stare-star/qqbot | /awesome/plugins/num/__init__.py | UTF-8 | 2,089 | 2.921875 | 3 | [
"MIT"
] | permissive | from awesome.plugins.num.number import search
from nonebot import on_command, CommandSession
# on_command 装饰器将函数声明为一个命令处理器
# 这里为命令的名字,同时允许使用别名
__plugin_name__ = '查学号'
__plugin_usage__ = r'''
xh 姓名
'''
@on_command('xh', aliases=('学号','查学号'))
async def xh(session: CommandSession):
# 从会话状态(session.state)中获取name,如果... | true |
1f4b66ca2985825e4395bb3f74d1c24985533f1a | hemanth171/Predict_Battery_Life_Of_Laptop | /Hackerrank_submission.py | UTF-8 | 1,098 | 3.015625 | 3 | [] | no_license | import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
timeCharged = float(input().strip())
with open("battery_trainingdata.txt") as f:
content = f.readlines()
content = [x.strip() for x in content]
content_split = [s.split(',') for s in content]
col1 = []
col2 = []
for val in... | true |
3f984b1921d63aefeef70899466cecc398788b83 | cash2one/xai | /xai/brain/wordbase/adjectives/_fabled.py | UTF-8 | 492 | 2.765625 | 3 | [
"MIT"
] | permissive |
#calss header
class _FABLED():
def __init__(self,):
self.name = "FABLED"
self.definitions = [u'used to refer to something or someone who has been made very famous, especially by having many stories written about it, him, or her: ']
self.parents = []
self.childen = []
self.properties = []
self.jsondata ... | true |
cc0d45bed4cf5684208705443e985b4ceb1fe639 | jhee514/Algorithms | /01_class/2383_점심시간2.py | UTF-8 | 3,623 | 3.3125 | 3 | [] | no_license | import sys
sys.stdin = open("2383_input.txt", "r")
"""
계단에는 동시에 3명까지만 올라갈 수 있다
계단은 2개
조합으로 사람을 2 그룹으로 나눈다.
people_idx = [idx, dist]
각 조합에서 이동시간을 구하는데.....
1. 계단에 도착하는 순서 구하기 => distance 구해서 sort
도착하서 1분 기다리고 계단 이동 시작
2. 모두가 이동을 완료할 시간 잡기
2-1. if len(group) < 4: 제일 큰 distance + 계단 크기
... | true |
f01fa12cfcd140304a7a361577f1a46e6e78f95f | savourylie/cracking_the_code_interview | /ch2/2_5_sum_lists.py | UTF-8 | 1,443 | 3.84375 | 4 | [] | no_license | from linkedlist import Node, create_linkedlist, linkedlist_equal, print_linkedlist
def sum_lists(ll1, ll2, reverse=True):
if reverse:
head1 = ll1
head2 = ll2
current1 = head1
current2 = head2
carry = 0
prev = None
while current1 is not None:
if current2 is not None:
sm = current1.value + current... | true |
9241cf4f46471a780635b9cda45d2b441573d6fa | borntofrappe/python-scripts | /time-series-visualizer/visualizer.py | UTF-8 | 2,292 | 3.03125 | 3 | [] | no_license | import os
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
dir = os.path.dirname(__file__)
# Import data and clean data
df = pd.read_csv(dir + "/data.csv", parse_dates=["date"], index_col="date")
lowe... | true |
7ff552b80486bc00059ee089ab4b2cd847fa9df5 | noamrubin22/dataprocessing | /homework/week_1/scraper/tvscraper.py | UTF-8 | 4,282 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env python
# Name: Noam Rubin
# Student number: 10800565
"""
This script scrapes IMDB and outputs a CSV file with highest rated tv series.
"""
import csv
import re
from requests import get
from requests.exceptions import RequestException
from contextlib import closing
from bs4 import BeautifulSoup
TARGET_U... | true |
f7f76eeb9fd41fdb1696a4140bb2694056446edd | RodneyMarumo/recipes | /list.py | UTF-8 | 9,334 | 2.796875 | 3 | [] | no_license | from .iter import flatiter
import collections as coll
import functools
##########################################################################################################################################
# List methods
##############################################################################################... | true |
6343851c997c01c817e8b52817c44830a09312a6 | hiwatt456/SWIM-R | /SW/Python/VideoStreaming/old_versions/video_multithread.py | UTF-8 | 2,505 | 2.75 | 3 | [] | no_license | import cv, cv2
import sys
import threading
def get_frame():
global camcapture
if not camcapture:
print "Error opening WebCAM"
sys.exit(1)
while True:
valid,frame_mat = camcapture.read()
if frame_mat is None or valid is False:
break
... | true |
6c5dfdec0eceb72ea93604216d2bf6dca905d4ce | proton1602/atcoder | /abc131/f.py | UTF-8 | 4,328 | 2.875 | 3 | [] | no_license | import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print(... | true |
c1b8806e6dde948c6f3b6df695787239b7258653 | jack456054/leetcode | /leetcode107.py | UTF-8 | 736 | 3.421875 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrderBottom(self, root):
result = []
level = 0
if root:
Solution._levelOrderBottom(root, le... | true |
c141134c2989e8c9d665655f576cc599f4bd0d3a | sialar/Interpolation-Multilin-aire | /Tucker/With_Analytical_Functions/multiDimensionOrthoNormalL2.py | UTF-8 | 1,947 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import numpy as np
import warnings
from numpy import linalg as LA
import scipy
import multiDimensIntegralMethods as M
import copy
###=====================================
###=====================================
### This class is used to orthonormalize a set of vecteurs with norm L2
###=======... | true |
391d3302223d5a6e7f614b07baf7731724125720 | kannanmavila/coding-interview-questions | /topological_sort.py | UTF-8 | 867 | 3.5625 | 4 | [] | no_license | def topological_sort(dag):
n = len(dag)
visited = [False] * n
order = []
# Utility method for DFS
def _trace(i):
if visited[i]:
return
visited[i] = True
for j in xrange(n):
if dag[i][j] != 0: # Edge exists
_trace(j)
order.append(i)
# Start from each node
for i in xrange(n):
... | true |
5524fa6bcc53218b02a24657dd9a3ad67b7bab88 | sweverett/Balrog-GalSim | /scripts/det-add-gold.py | UTF-8 | 2,174 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
Add FLAGS_GOLD to detection catalog.
Spencer Everett
"""
import sys
import fitsio
from astropy.table import Table, join
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument(
'detfile',
type=str,
help='Detection catalog filename'
)
parser.add_argument... | true |
451ae592b79df955a3038e4fe0360de0c3e633e3 | alading241/MoDeng | /Experiment/Test/CubicTest.py | UTF-8 | 1,654 | 2.71875 | 3 | [] | no_license | import wx
import wx.adv
import wx.adv
import time
def create_splash():
# create a welcome screen
screen = wx.Image("file.png").ConvertToBitmap()
wx.adv.SplashScreen(screen, wx.adv.SPLASH_CENTRE_ON_SCREEN | wx.adv.SPLASH_TIMEOUT, 1000, None, -1)
time.sleep(1)
class TaskBarIcon(wx.adv.TaskBarIcon):
... | true |
9a4132a1e0b0216f03054bdbe08b64d128ed3220 | eddiejessup/agaro | /agaro/runner.py | UTF-8 | 6,157 | 3.140625 | 3 | [
"BSD-3-Clause"
] | permissive | from __future__ import print_function, division
from os.path import join, isdir
import os
from agaro import output_utils
class Runner(object):
"""Wrapper for loading and iterating model objects, and saving their output.
There are several ways to initialise the object.
- If no output directory is provid... | true |
4e0a6e417250a195e20d90fc6597b4949db0c4cc | yangyang5214/note | /bricks/1672.py | UTF-8 | 404 | 3.359375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# https://leetcode-cn.com/problems/richest-customer-wealth/
from typing import List
def maximumWealth(accounts: List[List[int]]) -> int:
return max([sum(item) for item in accounts])
if __name__ == '__main__':
accounts = [[1, 2, 3], [3, 2, 1]]
accounts = [[1, 5], [7, 3], [3, 5]]
... | true |
d86d814485ba5d7caec1530e4298b7fd8f135901 | rishamsidhu/scholar-reader | /data-processing/common/colorize_tex.py | UTF-8 | 20,462 | 2.53125 | 3 | [
"GPL-1.0-or-later",
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | import colorsys
import logging
import os
import re
from dataclasses import dataclass
from typing import (Any, Callable, Dict, Iterator, List, NamedTuple, Optional,
Sequence, Set, Tuple)
import numpy as np
from common.parse_tex import BeginDocumentExtractor, DocumentclassExtractor
from common.types... | true |
2b8b5189ab0330bcde491f57312778e9bb5fdcec | Deepak483/codewithharry | /05_pr_02.py | UTF-8 | 403 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | empty_dict = {}
p1 = input("Enter your name: \n")
v1 = input("Enter your favourite language:\n")
p2 = input("Enter your name: \n")
v2 = input("Enter your favourite language:\n")
p3 = input("Enter your name: \n")
v3 = input("Enter your favourite language:\n")
p4 = input("Enter your name: \n")
v4 = input... | true |
4f1401c0c10e58c6d9034f08a6da9c41959f59ee | Durgasaieswar/AssignI | /flask_app/models.py | UTF-8 | 1,386 | 2.890625 | 3 | [] | no_license | from datetime import datetime
from . import db
# CategoryMaster table
class CategoryMaster(db.Model):
"""category_master table in database
Args:
db (object): SQLAlchemy class object
"""
id = db.Column(db.Integer, primary_key=True)
category = db.Column(db.String(25), nullable=False)
... | true |
96d02566ff69d7b39985f4de8c543eaf469f122b | tomdotorg/docker-weewx | /dist/weewx-3.6.1/weewx-3.6.1/bin/weewx/wxformulas.py | UTF-8 | 17,726 | 3.34375 | 3 | [
"GPL-1.0-or-later",
"GPL-3.0-only",
"Apache-2.0"
] | permissive | #
# Copyright (c) 2009-2015 Tom Keffer <tkeffer@gmail.com>
#
# See the file LICENSE.txt for your full rights.
#
"""Various weather related formulas and utilities."""
import math
import time
import weewx.uwxutils
from weewx.units import INHG_PER_MBAR, METER_PER_FOOT, METER_PER_MILE, MM_PER_INCH
from weewx.unit... | true |
a817994720e862ae860ee40594b61b773a0a11f7 | silphire/training-with-books | /math-and-algorithm/065.py | UTF-8 | 114 | 2.953125 | 3 | [
"MIT"
] | permissive | import math
h, w = map(int, input().split())
if min(h, w) == 1:
print(1)
else:
print(math.ceil(h * w / 2)) | true |
3564b515f901c435747de4bb2b2c9b836c65b5ec | Aasthaengg/IBMdataset | /Python_codes/p03610/s854313984.py | UTF-8 | 31 | 2.859375 | 3 | [] | no_license | s = input()
a = s[::2]
print(a) | true |
910e7e22f5da8574941729c2e88cf33a2f38d81f | gucci-j/cond-vae | /utility_load_dataset/utils.py | UTF-8 | 2,628 | 2.71875 | 3 | [
"MIT"
] | permissive | # coding: utf-8
import numpy as np
import sys
import os
import cv2
from sklearn.model_selection import train_test_split
from keras.utils import np_utils
def load_dataset(root_dir, folders, test_size=0.10, img_size=(28, 28, 3)):
IMG_COLS, IMG_ROWS, IMG_CH = img_size[0], img_size[1], img_size[2]
print('Acquiring ima... | true |
28e3e57baa2198adcf4ec12fe2682854fce095aa | emersonccf/projeto_mozilla | /catalog/models/genre.py | UTF-8 | 469 | 2.96875 | 3 | [] | no_license | from catalog.models import *
class Genre(models.Model):
""" Modelo que representa um genero de um livro """
name = models.CharField(
"Nome",
max_length=200,
help_text="Informe o genero do livro do livro (ex. Ficção Científica)",
)
class Meta:
verbose_name = "Gênero"
... | true |
9ffd9ed13143fed53af25f4951129eefa5aa488d | Shimpa11/PythonTutorial | /session24regexp1.py | UTF-8 | 523 | 3.03125 | 3 | [] | no_license | import re
# number=input("enter the number: ")
email=input("Enter the email: ")
# result=re.search("([A-Z]{2})(\d{2})([A-Z]{2})(\d{4})",number)
# result=re.search("\b[a-zA-Z 0-9_.%]@ [a-zA-Z 0-9_.%]+\.[a-zA-Z 0-9_ .%]",email)
# result=re.search("^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",email)
# result=r... | true |
7722e109d3754f4d67c5503ec099cf9c14acef3e | cpa-bayarea/fabricasite-backend | /content/models.py | UTF-8 | 2,789 | 2.578125 | 3 | [] | no_license | from django.db import models
class Feature(models.Model):
"""
Model responsável por abstrair os serviços oferecidos pela fábrica.
"""
class Meta:
verbose_name = 'Serviço'
verbose_name_plural = 'Serviços'
icon_class = models.CharField(
max_length=30,
null=False,
... | true |
c679cd847b9b8e1ba0da1038267651b30024032d | LeihuaYe/ufc_fight_predictor | /fight_predictor/models.py | UTF-8 | 3,095 | 2.5625 | 3 | [] | no_license | import sys
import os
import datetime
import sys
import numpy as np
import tensorflow as tf
import tensorflow._api.v1.keras.backend as K
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.regularizers import l2
from utils import r2, random_data_shuffle, get_train_test_data
def winner_model():
... | true |
6216997b0c929f2b340de2ce14df4354d79d9adb | Volvagia356/os-scheduler-assignment | /algorithms/2_varquant_roundrobin.py | UTF-8 | 1,113 | 2.84375 | 3 | [] | no_license | import cpuschedule
import misc
from collections import deque
name="Variable Quantum Round Robin"
quantum_assignment={
1: 5,
2: 4,
3: 3,
4: 2,
5: 1,
}
class Algorithm(cpuschedule.Algorithm):
def __init__(self):
cpuschedule.Algorithm.__init__(self)
self.current_quantum=0
... | true |
85e0224daa5c22316ffc520cdb2f665c9c97349e | pyro-team/pyro-demo | /installer/helper.py | UTF-8 | 548 | 2.71875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import ctypes
import os
def is_admin():
#test for admin
try:
return os.getuid() == 0
except AttributeError:
return ctypes.windll.shell32.IsUserAnAdmin() != 0
def yes_no_question(question):
reply = str(raw_input(question + ' (y/n): ')).lower().strip()
if re... | true |
f0576e4585e1eabf40964254963a9a01204af574 | shahidul2k9/problem-solution | /leetcode/508. Most Frequent Subtree Sum.py | UTF-8 | 1,027 | 3.296875 | 3 | [] | 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
class Solution:
def findFrequentTreeSum(self, root: Optional[TreeNode]) -> List[int]:
frequency = collections.defaul... | true |
567e60d076ad20c66489773eef86a777f4a6d925 | IRON-HAN/spider-python-2020 | /暑假爬虫/数据分析/test.py | UTF-8 | 401 | 2.90625 | 3 | [] | no_license | import numpy as np
import pandas as pd
if __name__ == '__main__':
s = pd.Series([1, 3, 6, np.nan, 44, 1])
# print(s)
dates = pd.date_range('20200820', periods = 6)
# print(dates)
df = pd.DataFrame(np.random.randn(6, 4), index = dates, columns = ['a', 'b', 'c', 'd'])
# print(df)
df2 = pd.... | true |
c5df4189968bc4971b51991d156b1554386f9fff | prashantgonga/python-practice | /course2/dictionary/filereader.py | UTF-8 | 602 | 3.90625 | 4 | [] | no_license | # Read contents of a text file, make a histogram and print the word which appeared the most along with the count
fileName = input('Enter the file name: ')
try :
fileHandle = open(fileName, 'r')
except :
print(fileHandle, 'is the wrong filenames')
histogram = dict()
for words in fileHandle :
words = words... | true |
ecefd61812253a92f80d93c03590b68177f79a71 | BibianaC/async-web-app | /async_web_app.py | UTF-8 | 2,175 | 2.828125 | 3 | [] | no_license | from collections import Counter
import os
import re
from bs4 import BeautifulSoup
import requests
import tornado.httpserver
import tornado.ioloop
import tornado.web
from wordcloud import WordCloud
def get_html_text(url):
response = requests.get(url)
html = BeautifulSoup(response.text, 'lxml')
# Delete e... | true |
f829532d068c73eb0840a36075478c1913ed9f69 | hachira/algbootcamp2020 | /lab9-2/lab.py | UTF-8 | 768 | 2.984375 | 3 | [] | no_license | import queue
import math
INF = 1000000000
def distance(a, b):
return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
n = int(input())
adjList = [[] for _ in range(n+1)]
v = [(0, 0)]
for i in range(1, n+1):
a, b = map(int, input().split())
v.append((a, b))
k = int(input())
for _ in range(k):
a, b = map(int, input().s... | true |
d064216221bdab2fde631038b00f59eb55727b15 | martinriis/Python-Twitter-API | /GET.py | UTF-8 | 1,988 | 3.5 | 4 | [
"MIT"
] | permissive | import json # For processing the data returned by the API in an effective way
import requests # For making the request to the API
def log(data):
dataFile = open("data.txt", "a") # Opens data.txt and prepares to append it
dataFile.write(data) # Writes data to the file
dataFile.close() # Closes the fil... | true |
cc78ab2b7714e991e35d8d3436a53af7268caf8f | jedzej/tietopythontraining-basic | /students/sendecki_andrzej/lesson_01_basics/total_cost.py | UTF-8 | 601 | 4.6875 | 5 | [] | no_license | # lesson_01_basics
# Total cost
#
# Statement
# A cupcake costs A dollars and B cents. Determine, how many dollars and cents
# should one pay for N cupcakes. A program gets three numbers: A, B, N.
# It should print two numbers: total cost in dollars and cents.
print("Enter cupcake price: dollars")
A = int(input())
pri... | true |
cb7464dde832c409b4ce64c2b1266e36bdfc5f86 | fpavanetti/python_lista_de_exercicios | /aula10_ex36.py | UTF-8 | 444 | 4.625 | 5 | [] | no_license | '''
Desenvolva um programa que leia o comprimento de
três retas e diga ao usuário se elas podem ou não
formar um triângulo.
'''
ab = float(input("Digite o valor do primeiro segmento de reta: "))
cd = float(input("Digite o valor do segundo segmento de reta: "))
ef = float(input("Digite o valor do terceiro seg... | true |
e3b0927f019bfc67554ee30bf295c31319bc23eb | google-research/xtreme | /third_party/ud-conversion-tools/lib/conll.py | UTF-8 | 16,821 | 2.859375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | import networkx as nx
from collections import Counter
import re
#TODO make these parse functions static methods of ConllReder
def parse_id(id_str):
if id_str == '_':
return None
if "." in id_str:
return None
ids = tuple(map(int, id_str.split("-")))
if len(ids) == 1:
return ids[... | true |
a2e74c42178b83495e917eb5687dcb6ed71ceceb | skisy/robopy-detect | /application.py | UTF-8 | 16,491 | 2.53125 | 3 | [] | no_license | from Tkinter import *
import cv2
import helper as h
import tkFileDialog
import tkMessageBox
import tkFont
import shutil
from os import path as osp
import os
import objDetect
import socket
import py_websockets_bot
def setListboxItems(objects, listbox):
listbox.delete(0,END)
for x in range(0, len(objects)):
... | true |
6e552c3cb6b0d801ff2c43c83b3aefc3d29dc9d1 | frizwankhan/airline_sentiment | /preprocess.py | UTF-8 | 5,435 | 2.796875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import re
import string
from collections import Counter
from nltk.corpus import stopwords
import nltk
from nltk.stem import PorterStemmer, WordNetLemmatizer
nltk.download('punkt')
nltk.download('wordnet')
nltk.download('stopwords')
stop_words = se... | true |
f378e8f877d0d71c039cbdb016e1db4641b25124 | saisudheer123/sudheer3python | /prime2.py | UTF-8 | 131 | 3.4375 | 3 | [] | no_license | nm=int(input())
count=0
for i in range(1,nm+1):
if (nm%i)==0:
count+=1
if(count==2):
print("yes")
else:print("no")
| true |
82ff2e503869fd14a899d4cab9ae0262481be04e | sindyjlee/rest-api | /tweetthis/tests/stores/test_user_store.py | UTF-8 | 2,669 | 2.8125 | 3 | [] | no_license | """
User persistence tests.
Tests cover model-specific constraints under the assumption that framework
conventions handle most boilerplate.
"""
from hamcrest import (
assert_that,
calling,
equal_to,
is_,
raises,
)
from microcosm_postgres.context import SessionContext, transaction
from microcosm_po... | true |
e93beec81d79f97ac3290036b0f5903ba0def9bd | PH111P/powerline | /powerline/segments/vim/plugin/ale.py | UTF-8 | 1,631 | 2.53125 | 3 | [
"MIT"
] | permissive | try:
import vim
except ImportError:
vim = object()
from powerline.bindings.vim import vim_global_exists
from powerline.theme import requires_segment_info
@requires_segment_info
def ale(segment_info, pl, err_format='ERR: ln {first_line} ({num}) ', warn_format='WARN: ln {first_line} ({num}) '):
'''Show whe... | true |
4086378c489b068428408df32b0ac1164dc8a56c | jackmallet/1707gittest | /去重/JY_csv.py | UTF-8 | 3,021 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-\
import xlrd,re,xlwt,csv,requests
from xlutils.copy import copy
import time
import eventlet
class JY_csv(object):
def __init__(self):
# 打开excel表格
self.data = xlrd.open_workbook(r'总数据源2019.8.08.xlsx')
# 复制excel表并不改变属性
self.newWb = copy(self.data)
#取sheet为总列表的表
self.newW... | true |
120b2904719e531a0978ac96adc1669950b328f3 | IgorGoryainov/ATS_AutoBot | /TestRGB_fromImages.py | UTF-8 | 2,109 | 2.578125 | 3 | [] | no_license | import cv2 as cv
def nothing(x):
pass
#cap = cv.VideoCapture(0)
cv.namedWindow('result')
cv.createTrackbar('Blur', 'result', 1, 29, nothing)
cv.createTrackbar('minH', 'result', 0, 179, nothing)
cv.createTrackbar('minS', 'result', 7, 255, nothing)
cv.createTrackbar('minV', 'result', 171, 255, nothing)
cv.creat... | true |
e5052535b122386705252fee74ecccc8a4bd8565 | thomasdouenne/beliefs_climate_policies | /test_prediction_functions.py | UTF-8 | 4,835 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# We select a subsample of households from BdF, and apply our different methods to determine the feedbacks to give
# We will then compare the goodness of fit of these methods.
# There is a very large downward bias in our regression, we clearly overestimate the losses
from __future__ import div... | true |
478e636a804c65a9c71db4a33c906dcf0f4c6a59 | deep-machine-learning/web-vision | /utils.py | UTF-8 | 3,557 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
import cv2
import glob
import itertools
import re
import time
#dir = os.path.dirname(os.path.realpath(__file__))
#FLAGS = tf.app.flags.FLAGS
#tf.app.flags.DEFINE_integer('image_size', 299,
# """Provid... | true |
9771b86171b667ebe797076284bbfa3e4146d40b | latecomer04/codeforces-solutions-in-python | /Registration System.py | UTF-8 | 188 | 3.328125 | 3 | [] | no_license | n=int(input())
dict={}
for i in range(n):
s=input()
if s not in dict:
dict[s]=1
print("OK")
else:
a=dict[s]
dict[s]=a+1
print(s+str(a))
| true |
a6f0e936b3f4eea26e6695a6bcd359c190d069e2 | AnTznimalz/python_prepro | /sce.py | UTF-8 | 831 | 3.5 | 4 | [] | no_license | """SceneSwitch I"""
def switch():
"""Switch Function"""
status = "Off"
warm = 0
start = input()
data1 = 0
if start == "End":
status = start
else:
status = "On"
data1 = float(start)
while status != "End":
time = input()
if time == "End":
... | true |
79cf1665e47fe89ed013a75ea0b4268be5876cbc | gustavo-mota/programming_fundamentals | /7_Sexta_lista/1.9_cc/1.9.py | UTF-8 | 285 | 3.75 | 4 | [] | no_license | def fibonacci(lista, ordem):
x = 1
y = 1
lista.append(x)
lista.append(y)
for i in range(2,ordem):
num = x + y
y = x
x = num
lista.append(num)
return lista
vetor = []
ordem = int(input("Digite quantos valores de fibonacci deseja: "))
fibonacci(vetor,ordem)
print(vetor) | true |
1afd637b5ee4ea74df8d4739eaa59ca93e13b1e2 | kingasiedu/Python | /message_class.py | UTF-8 | 529 | 3.34375 | 3 | [] | no_license | class Messaging:
def __init__(self, phone_number):
self.message_log = []
self.call_log = []
def make_message(self, phone_number):
self.call_log.append(phone_number)
def show_message_log(self):
print(self.call_log)
def clear_message_log(self):
print(self.call_lo... | true |
68f35eea7bcff4ac73a9df04006c98ee74971e67 | ioxuy/tsee | /mpeg2psi/pat.py | UTF-8 | 4,762 | 3.046875 | 3 | [
"Unlicense"
] | permissive | """Program Association Table module
Provides a set of functions and a PAT Section class to parse and encapsulate information about a
MPEG2-TS Program Association Table section
"""
from section import Section
def get_program_map(data=None):
"""Returns the program map contained in the PAT section data
Given an a... | true |
1caa7d6406786528fe4d359a0e5c366c352c0d22 | ericmotleybytes/motleytestpython | /src/motleytestpython/tester.py | UTF-8 | 16,954 | 3.15625 | 3 | [
"MIT"
] | permissive | """Simple and quick sanity check that Python is working correctly."""
import unittest
import sys
import operator
import datetime
import random
import math
import decimal
import json
import re
class Tester(unittest.TestCase):
def assert_equal(self,expected,actual,message=None):
# assert exactly equal
... | true |
5960b2442751cd57475025dc36ac3d15ab095609 | neild0/5490-PowerUp2018 | /Powerup5490/2019FRC/src/main/java/frc/robot/Turning-Alek.py | UTF-8 | 335 | 3 | 3 | [] | no_license | public List Turn(double x_object) '''Returns how much robot should turn'''{
private static double perc_error = x_object/160
private Bool Positive_direction = True
if perc_error < 0 {
Positive_direction = False
}
private static ret = new ArrayList(perc_error, Positive_direction)
... | true |
571db67964974ff31b4a8386654dac5c10a70603 | erickkkt/scikit-practice | /Dequeue.py | UTF-8 | 762 | 3.8125 | 4 | [] | no_license | class Dequeue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def addFront(self, item):
self.items.append(item)
def addRear(self, item):
self.items.insert(0, item)
def removeFront(self):
return self.items.pop()
def rem... | true |
e42ef53f9f3a86a4453d910a563f235658af1ba3 | phavekes/sommentelefoon | /draaischijftest.py | UTF-8 | 1,146 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import RPi.GPIO as GPIO
import sys
import os
import time
import random
import pygame
#import urllib2
#import requests
#vars hierzo
SCHIJFPIN = 25
AARDPIN = 23
HOORNPIN = 24
GPIO.setmode(GPIO.BCM)
GPIO.setup(SCHIJFPIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(HOORNPIN, GPIO.IN, pull_up_d... | true |
4694a4528f92f00156ba88f367b1db67086a251f | FengDushuo/Visualization-of-network-attack | /methods/setdb.py | UTF-8 | 1,003 | 2.515625 | 3 | [] | no_license | import pymysql
mysqluser="root"
mysqlpassword="*****" #这里填自己的mysql帐号和密码
logindatabase="login_db"
hostsrc="localhost"
conn = pymysql.connect(host=hostsrc,port=3306,user=mysqluser,password=mysqlpassword,charset='utf8')
cursor = conn.cursor()
createloginsql="CREATE DATABASE IF NOT EXISTS "+logindatabase
cursor.execute... | true |
7c87bf3594047297287cb829f1ed430ed63ca82b | prateek951/General-python-with-DSA | /files.py | UTF-8 | 7,301 | 4.28125 | 4 | [] | no_license | """
You have already seen exceptions in previous code.
They occur when something goes wrong, due to incorrect code or input.
When an exception occurs, the program immediately stops.
The following code produces the ZeroDivisionError
exception by trying to divide 7 by 0.
"""
num1 = 5
num2 = 0
print(num1/num... | true |
3503fee68626c23a0b96a5e4f696319df158b772 | Qupiee/DiceBot | /bot.py | UTF-8 | 3,363 | 2.8125 | 3 | [] | no_license | import telebot
import config
import dice
from telebot import types # keyboard
bot = telebot.TeleBot(config.TOKEN) # bot import
range_more = 0 # for global var use
range_less = 0
@bot.message_handler(commands=['start']) # trigger for '/start' command
def begin(message):
markup = types.ReplyKey... | true |
ff3bbd90285b32920993f635fd31cc97d33bff28 | bakerj32/blackjack | /client.py | UTF-8 | 3,882 | 2.859375 | 3 | [] | no_license | import sys, time, signal
from socket import *
from player import *
from select import select
global player
class AlarmException(Exception):
pass
def alarmHandler(signum, frame):
raise AlarmException
def nonBlockingRawInput(prompt='', timeout=20):
signal.signal(signal.SIGALRM, alarmHandler)
signal... | true |
488473c7fd787f4cf99c4d65e29f6967a67612f9 | farhadrgh/python-course | /Project_1/sample-mid/file/pickle.py | UTF-8 | 332 | 2.8125 | 3 | [] | no_license | import sys, cPickle
file = open( "users.dat", "w" )
print "Enter the user name, name and date of birth."
print "Enter end-of-file to end input."
inputList = []
while 1:
try:
accountLine = raw_input( "? " )
except EOFError:
break
else:
inputList.append( accountLine.split() )
cPickle.dump( inputList, file )
fi... | true |
f9336ca53f31443a8293bad439df9bb2bc4316bf | edwinstudy/covariance_calculator | /src/covariance_calculator/covariance_calculator.py | UTF-8 | 2,811 | 2.890625 | 3 | [
"MIT"
] | permissive | import numpy
import collections
from nav_msgs.msg import Odometry
from geometry_msgs.msg import Twist
from sensor_msgs.msg import Imu
from sensor_msgs.msg import NavSatFix
class CovarianceCollector():
def __init__(self, col_type):
self.covariance_data = collections.defaultdict(list)
self.type = co... | true |
00f0b42745b93f2872c76bf588cfaf788178d5a0 | eebmagic/points_in_triangle | /points_in_triangle.py | UTF-8 | 4,101 | 3.71875 | 4 | [] | no_license | def x_min_max(verts):
MIN, MAX = float('inf'), -float('inf')
for vert in verts:
if vert[0] < MIN:
MIN = vert[0]
if vert[0] > MAX:
MAX = vert[0]
return MIN, MAX
def y_min_max(verts):
MIN, MAX = float('inf'), -float('inf')
for vert in verts:
if vert... | true |
86f6dcbd5507d5f2525a1a933994c828ebf35f7c | 443ki/ProRob_Code | /chapter5/mcl2.py | SHIFT_JIS | 1,041 | 2.90625 | 3 | [
"MIT"
] | permissive | import sys
sys.path.append('../scripts/')
from robot import *
# In[]:
class Particle:
def __init__(self, init_pose):
self.pose = init_pose
# In[]:
class Mcl:
def __init__(self, init_pose, num):
self.particles = [Particle(init_pose) for i in range(num)]
# In[]:
class EstimationAgent(Agent):
... | true |
c13fe38a5fb9448652108e239cfa10b33cb3a786 | brucenielson/Jira | /JiraAutomator.py | UTF-8 | 6,272 | 2.609375 | 3 | [] | no_license | # https://mborgerson.com/creating-an-executable-from-a-python-script
# pyinstaller JiraAutomator.py
# C:\Users\BNielson\Anaconda2\envs\Jira\Scripts\pyinstaller JiraAutomator.py
from jira import JIRA
import logging
import getpass
import os
import time
#os.path.dirname(os.path.realpath(__file__))
filename=os.getcwd()+... | true |
2202ca8b3fb6ca36c59f0b7a272aa2ada6c8c526 | BillmanH/learn-azureml | /pipes/get_iris/get_iris.py | UTF-8 | 811 | 2.96875 | 3 | [] | no_license | # %%
# import libraries
import pandas as pd
import yaml
import argparse
from sklearn import datasets
import os
# %%
# Parse the arguments
parser = argparse.ArgumentParser(
description="getting inputs from the pipeline setup")
parser.add_argument("--output_dir", dest="output_dir")
args = parser.parse_args()
# %%
#... | true |
c4ba457dab465ba3539c028bf6c6b32d3c158ee2 | chuck1/python | /Modules/gen_reg/gen_reg/test.py | UTF-8 | 1,256 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env python3
import gen_reg
import numpy
import matplotlib.pyplot as plt
def func(x,c):
return c[0] * numpy.power(x[0],c[1]) * numpy.power(x[1], c[2] * numpy.power(x[0],c[3]))
def func_jac(x,c):
y = c[0] * numpy.power(x[0],c[1]) * numpy.power(x[1], c[2] * numpy.power(x[0],c[3]))
return [
... | true |
347781a81bb68146bc096bc8096035d198099d8c | Quang-Vinh/Kaggle-Digit-Recognizer | /src/optimizers.py | UTF-8 | 4,395 | 3 | 3 | [] | no_license | import numpy as np
def gradientDescentStep(parameters: dict, costFunc, alpha: int = 0):
cost, dParameters = costFunc(parameters)
parameters["Theta"] -= alpha * dParameters["dTheta"]
parameters["B"] -= alpha * dParameters["dB"]
return cost, parameters
def gradientDescent(parameters: dict, costFunc, al... | true |
93563573685c6497d7599f148e859f61ec85fe02 | jbitton/ml-project | /conditional_probability/nb.py | UTF-8 | 1,471 | 2.734375 | 3 | [] | no_license | from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import roc_auc_score
from util import roc_results, results
from base_model import BaseModel
class NB(BaseModel):
def __init__(self, dataset, params):
"""
:param dataset: contains, x_train, y_train, x_test, y_test (in that order)
... | true |
2d8eb5928609c16a1e96e0b42ff128d058fb64d3 | FoysalNibir/Python-BD-Newspaper-Scraping | /independent - Copy (2)/test.py | UTF-8 | 2,016 | 2.765625 | 3 | [] | no_license | import os
import urllib
import urllib2
import pymysql
from bs4 import BeautifulSoup
from dateutil.parser import parse
from datetime import datetime, timedelta
def getNews(url):
news_page = urllib2.urlopen(url)
soup = BeautifulSoup(news_page, 'html.parser')
full_news_box = soup.find("div", {"id": "newsDtl"... | true |
3a91414c4087adc3c72c496053aec231f8ef6bad | thurstonzk2008/Python004 | /FinalHomeWork/finale_spider/final_spider/spiders/smzdm.py | UTF-8 | 6,633 | 2.671875 | 3 | [] | no_license | import scrapy
from scrapy.selector import Selector
import re
from datetime import datetime
import time
from finale_spider.items import FinaleSpiderItem
from finale_spider.pipelines import skulist, lock
class SmzdmSpider(scrapy.Spider):
name = 'smzdm'
allowed_domains = ['smzdm.com']
# 需要运行两次,第一次抓取sku信息,第... | true |
44482c788e59d0a7fd5acb5479f34a7d58f9a73a | hadi-M/Graphs | /projects/adventure/my_code.py | UTF-8 | 2,286 | 2.8125 | 3 | [] | no_license | from ipdb import set_trace as st
def get_empty_map(room_graph):
traversed_map = dict()
for k, v in room_graph.items():
traversed_map[k] = {k:False for k, _ in v[1].items()}
return traversed_map
def is_rooms_remaining(visited, room_graph):
visited_set = set(visited)
all_rooms_set = set(r... | true |
7bd26b02b3358fb0e180bf1b774c51355aa0b7b9 | vasco989k/python_ml4nlp | /day4_hmm_tagger/shortestpath/hmm_pos_tagger/hmm.py | UTF-8 | 1,219 | 3.15625 | 3 | [] | no_license | class TrainedHMM:
"""Usage
--------
transition = {
('Noun', 'Josa'): 0.7,
('Noun', 'Noun'): 0.3,
('Verb', 'Eomi'): 0.5,
('Verb', 'Noun'): 0.5,
('Verb', 'Josa'): -0.1,
}
generation = {
'Noun': {
'아이오아이': 0.5,
'청하': 0.2,
}... | true |
dc4dfeb63c9e660c2b37a8a21c19dce11064d947 | Robin-Wujw/leetcode_py | /1672.最富有客户的资产总量.py | UTF-8 | 372 | 2.765625 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=1672 lang=python3
#
# [1672] 最富有客户的资产总量
#
# @lc code=start
class Solution:
def maximumWealth(self, accounts: List[List[int]]) -> int:
# max = 0
# for i in accounts:
# if(sum(i)>max):
# max = sum(i)
# return max
return max(map(... | true |
1ed04e67540c7289c6bc002ec1e02106fc928979 | ismail-a/projecteuler | /0010.py | UTF-8 | 483 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env python3
# __author__ = 'ismail'
import math
limit = 2000000
sieveBound = (limit - 1) / 2
sieve = [False] * sieveBound
crossLimit = int((math.sqrt(limit) - 1) / 2)
for i in range(1, crossLimit):
if not sieve[i]:
for j in range(2 * i * (i + 1), sieveBound, 2 * i + 1):
sieve[j] = T... | true |
dd6cdb6be30a3f082c9abef21c12beacce9ccc4c | ridhof/library-procurement-v2 | /app/mod_matakuliah/forms.py | UTF-8 | 1,339 | 2.84375 | 3 | [
"MIT"
] | permissive | """
Matakuliah Module's Forms
"""
import datetime
from flask_wtf import FlaskForm
from wtforms import HiddenField, SelectField, TextAreaField, TextField
from wtforms.validators import Required
def get_tahun_ajaran():
now = datetime.datetime.now()
tahun = now.year + 3
list_tahun_ajaran = []
for i in ran... | true |
cd4e7e021e7bef3e8694fb26c652c083603ff064 | xiaoguangjj/leetcode | /Numbers/695.maxAreaOfIsland.py | UTF-8 | 3,133 | 3.625 | 4 | [] | no_license | """
剑指 Offer II 105. 岛屿的最大面积
695. 岛屿的最大面积
给定一个由 0 和 1 组成的非空二维数组 grid ,用来表示海洋岛屿地图。
一个 岛屿 是由一些相邻的 1 (代表土地) 构成的组合,这里的「相邻」要求两个 1 必须在水平或者竖直方向上相邻。你可以假设 grid 的四个边缘都被 0(代表水)包围着。
找到给定的二维数组中最大的岛屿面积。如果没有岛屿,则返回面积为 0 。
输入: grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,... | true |
4df981026c782dd1e88c57d82695301c123b4cdf | iamsoroush/cryptosignal | /src/database.py | UTF-8 | 3,518 | 2.515625 | 3 | [
"MIT"
] | permissive | from datetime import datetime
import pytz
from peewee import SqliteDatabase, Model, DateTimeField, CharField
from src.utils import get_logger
logger = get_logger(name=__name__, write_logs=True)
class DBHandler:
db = SqliteDatabase('saita_bot.db')
def __init__(self):
# if logger:
# sel... | true |
a715f9453bc8fc305b3519ec94ce28b3cdc4c6af | mithun-mathew/MP_Codes | /Assignment 1/1/1-rgb.py | UTF-8 | 1,072 | 3.3125 | 3 | [] | no_license | import cv2 #imports cv2 package
import numpy as np #imports numpy package
import matplotlib.pyplot as plt #imports matplotlib.pyplot package
img = cv2.imread('rgbflag.jpg') #reads the image
blue, green, red = cv2.split(img) #splits the image into component channels
orig = cv2.cvtColor(img, cv2.C... | true |
7b85bed4d75b0a7eb1ead6b5064f6ab5e97b2ee8 | nfarnan/cs001X_examples | /oo/MW/06_inheritance2.py | UTF-8 | 150 | 2.765625 | 3 | [] | no_license | from student import Student
a = Student("Alice", 30)
a.display()
print()
a.addClass("CS001X")
a.display()
print()
# testing
print(a)
print(repr(a))
| true |
67d89436021939d3dde33b7eed49ada280679520 | deepshig/Digitalization-of-Offline-Handdrawn-Flow-Diagrams | /calFeature.py | UTF-8 | 1,775 | 2.75 | 3 | [] | no_license | # -*-coding:utf-8 -*-
'''
author: hrwhipser
date : Jun 5, 2015
function : calculate feature and save in ./data/feature.txt ./data/tag.txt
'''
import os
import numpy as np
from handwriting_tools import read_image, to_the_same_size
sameSize = 16
def get_train_data(dataPath):
train_input, desired_output = [], [... | true |
a86f1c6ce1c93e9749445247d1f81c40f0ddc73b | kenhktsui/Utility | /hash.py | UTF-8 | 3,487 | 2.84375 | 3 | [] | no_license | import numpy as np
from numba import jitclass
from numba import int64
import random
spec = [('hash_table_length',int64),
('table',int64[:,:]),
('string',int64[:]),
('num',int64)]
@jitclass(spec)
class dual_hash():
def __init__(self, hash_table_length):
self.hash_table_length = hash_table_length
self.table ... | true |
e316e6b156633d00638a4bcd87b49bc705bccc6a | Hesham-Elsherbieny/Mp3-Player-Buildroot | /mp3-overlay/mp3Files/checkingStorageDevices.py | UTF-8 | 6,060 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python3
import subprocess
import re
import time
memoryCardFlag = 0
usbFlashFlag = 0
existedMountDevices = []
existedDevices = []
memoryCardRegex = r'(mmcblk\d\w\d)'
usbFlashRegex = r'(sd\w\d)'
folderPreNaming = "mount_"
def mountFunction(deviceName):
folder = folderPreNaming + deviceName
... | true |
c07137a00885428aa6048c2fade7aa923e17f497 | rbroberg/uccs.edu | /mcmc/src/mcmc-metropolis-hastings-bayesian-posterior.py | UTF-8 | 5,215 | 3 | 3 | [] | no_license | # METROPOLIS-HASTINGS BAYESIAN POSTERIOR
import numpy as np
#import scipy.stats as stats
import matplotlib.pyplot as plt
from matplotlib import gridspec
import pylab
from math import gamma
# INITIALIZE
np.random.seed(271828)
# PRIOR OVER SCALE PARAMETERS
B = 1.;
# DEFINE LIKELIHOOD
# likelihood = inline('(B.^A/ga... | true |
d85c614a3691e16dabfe8063f5a9498da04aa200 | tiduswr/Algoritimos_P1_UEPB_CCEA_CAMPUS_VII | /Lista 06/lista06ex09.py | UTF-8 | 1,055 | 3.5 | 4 | [] | no_license | lin = 5
col = 10
matriz = []
gabarito = [0] * col
acertos = [0] * lin
for i in range(lin):
matriz.append([0] * col)
print('=' * 56)
print('{:^56}'.format('Insira o Gabarito'))
print('=' * 56)
for i in range(col):
gabarito[i] = input('Por Favor Insira a Resposta da Questão {}: '.format(i+1)).upper()
print('=... | true |
21960bf4c551b005331d30c7b53231a235d88f20 | hkxIron/hkx_tf_practice | /test_numpy/nn_scratch/rnn/rnn-from-scratch-master/rnnlm.py | UTF-8 | 357 | 2.53125 | 3 | [] | no_license | import numpy as np
from preprocessing import getSentenceData
from rnn import Model
word_dim = 8000
hidden_dim = 100
X_train, y_train = getSentenceData('data/reddit-comments-2015-08.csv', word_dim)
np.random.seed(10)
rnn = Model(word_dim, hidden_dim)
losses = rnn.train(X_train[:100], y_train[:100], learning_rate=0.0... | true |
9cb0a5a689a0ad25f6c2355ea930a33759b1d348 | Learning-and-Intelligent-Systems/stacking | /learning/experiments/how_big_should_my_ensemble_be.py | UTF-8 | 5,506 | 2.6875 | 3 | [] | no_license | from matplotlib import pyplot as plt
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from learning.dropout_gn import DropoutFCGN
from learning.gn import FCGN
from learning.train_graph_net import load_dataset, train, test
from learning.ac... | true |
6d1bc9609242ceeee11517e31e09e97b7a9a1b88 | hirokitnk/python_online_judge | /abc188_c.py | UTF-8 | 316 | 2.6875 | 3 | [] | no_license | N = int(input())
A = list(map(int,input().split()))
B = A
tempA = []
for i in range(N,0,-1):
#print('-----')
#print(i)
if i == 1:
break
for j in range(0,2 ** i,2):
tempA.append(max(A [j], A[j+1] ))
A = []
A = tempA
#print(A)
tempA = []
print( B.index(min(A)) + 1 ) | true |
53fddf019e7bfe129fe109a53f1b923720a37861 | lgalicki/Fun-with-Python | /prime_number_generator.py | UTF-8 | 797 | 3.84375 | 4 | [] | no_license | def prime_list(qt_asked):
'''
Returns a list of primes.
INPUT: quantity of primes to be returnes
OUTPUT: list with prime numbers
'''
plist = list() #list of prime numbers discovered
tested_number = 2 #number which will be tested to see if it's prime
while len(plist) < int(qt_asked)... | true |
344edcd9d58fe76358ac7feeb2f51ac4bb3ac2b4 | baraileesuraj/python-concepts | /Debugger/complex.py | UTF-8 | 965 | 3.1875 | 3 | [] | no_license | import pdb
import json
def pathtodict(path):
"""Open file at path and return dictionary."""
with open(path) as jsonfile:
diction = json.load(jsonfile)
return diction
def printer(inputdict):
"""Loop through dictionary and print values."""
for x, y in inputdict.items():
pdb.set_tra... | true |
c533c2ab23b12524edf355706f916a5b67ba3253 | Shreeyak/pytorch-lightning-segmentation-template | /seg_lapa/loss_func.py | UTF-8 | 1,583 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | import torch
import torch.nn as nn
import torch.nn.functional as F
class CrossEntropy2D(nn.CrossEntropyLoss):
"""Use the torch.nn.CrossEntropyLoss loss to calculate mean loss per image or per pixel.
Deeplab models calculate mean loss per image.
Inputs:
- inputs (Tensor): Raw output of network (wi... | true |
595d9e0b2cc40f99ffc845cb3e12d35b7f51dd72 | Justin-Carey/Insurance_Prediction_Model_XGBoost | /xgboost_main.py | UTF-8 | 2,376 | 3.203125 | 3 | [] | no_license | import pandas as pd
import numpy as np
import xgboost as xgb
import winsound
from sklearn.metrics import mean_absolute_error
from sklearn.metrics import f1_score
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
from timeit import default_timer as timer
# Using... | true |
805b9d9608b0c1249575c5057cb0b387c3d97306 | Kangnos/MUSICFLEX | /px calculator.py | UTF-8 | 78 | 2.96875 | 3 | [] | no_license | pixel = int(input())
pt = pixel // 0.75
# print((pt*100)/12)
print(pt/12,"em") | true |
47b2dd76be8fa4d009ec8e3590263f3e9e767616 | outsidethetacobox/pythonprojgame | /completeReq.py | UTF-8 | 1,085 | 4.15625 | 4 | [] | no_license | # This file is fulfill the remaining requirements in this project.
# Made by Sultan fw7888
# Inheritance req:
class drink:
def __init__(self):
self.name = ''
def setName(self, n):
self.name = n
class junk(drink):
def __init__(self):
super().__init__()
sel... | true |
bff723714c57dcdb1b4020ee94e7322d01df06d8 | pmjoniak/popy | /c5/p2.py | UTF-8 | 809 | 3.234375 | 3 | [] | no_license | import turtle
import random
import math
def mieszaj(k1, k2, a):
return (k1[0] * a + k2[0] * (1 - a), k1[1] * a + k2[1] * (1 - a), k1[2] * a + k2[2] * (1 - a))
def kwadra(x, y, size, k):
turtle.pu()
turtle.goto(x, y)
turtle.pd()
turtle.fillcolor(k)
turtle.begin_fill()
for i in range(4):
turtle.forward(size)... | true |