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 |
|---|---|---|---|---|---|---|---|---|---|---|
49dac2ae9ac53e37e9cc73984eb4e89c561c27a3 | DrasticScroll48/WildThingProgram | /BluedotTest.py | UTF-8 | 1,657 | 2.859375 | 3 | [] | no_license | import os
import time
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
import RPi.GPIO as GPIO
from bluedot import BlueDot
from signal import pause
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
cs = digitalio.Digital... | true |
1bdaca836337ca44deb29e904c33c4b3b2fa1d86 | samuelrince/newt | /src/processing.py | UTF-8 | 2,151 | 3.453125 | 3 | [] | no_license | import re
from typing import Union
from bs4 import BeautifulSoup
def preprocess_text(text: str) -> str:
"""Basic text pre-processing."""
text = re.sub(r'(^[\n]+)', '', text) # Remove \n at the beginning
text = re.sub(r'([\n]+$)', '', text) # Remove \n at the end
text = re.sub(r'([\n]{2,... | true |
30882f024ed3c0991496fa7f921fe4766f9cba5d | HalfMoonFatty/Interview-Questions | /356. Line Reflection.py | UTF-8 | 1,147 | 3.8125 | 4 | [] | no_license | '''
Problem:
Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points.
Example 1:
Given points = [[1,1],[-1,1]], return true.
Example 2:
Given points = [[1,1],[-1,-1]], return false.
Follow up: Could you do better than O(n2)?
Hint:
Find ... | true |
bacf686ce16c378c5eea2ac80aea3b6bb55baa2d | ruslan-rv-ua/python-starter | /docs/loop_while/problems/problems_loops/problem_loops_mult_table.py | UTF-8 | 658 | 3.609375 | 4 | [] | no_license | '''
"Табличка множення"
Напишіть програму яка виводила би табличку множення як подано нижче.
Зверніть увагу на кількість пробілів біля кожного числа.
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 ... | true |
2e90d67b05139100af5253b1eb293befe792cc25 | Ran-oops/python | /1python基础/01 Python基础/05/func1.py | UTF-8 | 396 | 3.890625 | 4 | [] | no_license |
#声明一个函数
def girl():
print('姑娘们真可耐~')
print('五朵小金花~')
#调用一个函数
#girl()#第一次调用
#girl()#第二次调用
#print(girl)
#print(type(girl))
#print(id(girl))
#定义函数type s使用自定义的type函数替换了系统提供type函数
def type():
print('这是俺定义的type函数')
#使用函数type
type()
type(10)
| true |
4bab1d66e7799dc45caa66f43c1d3572e61449d4 | richnakasato/epi-py | /10.3.sort_almost_sorted_array.0.py | UTF-8 | 812 | 2.96875 | 3 | [] | no_license | from test_framework import generic_test
import heapq
def sort_approximately_sorted_array(sequence, k):
# TODO - you fill in here.
minheap = list()
for item in sequence:
heapq.heappush(minheap, item)
if len(minheap) == k:
break
result = list()
for item in sequence:
... | true |
d02331c5dd2a4034455ed03d3c5f19e203c3b3d8 | RithikBanerjee/iris-detector | /IrisDetector.py | UTF-8 | 4,818 | 2.90625 | 3 | [] | no_license |
import os
import cv2
import numpy
from math import hypot
#global variables
eye_images = []
image_names = []
#storing all eye images from folder "DemoData" in a collection
for filename in os.listdir("DemoData"):
if filename is not None:
image = cv2.imread(os.path.join("DemoData", filename), 1)
eye... | true |
8875adcc0f8295a2437d449b458c3706f6f926f1 | ggonzalez1808/GastonGonzalezParcial | /fib.py | UTF-8 | 113 | 3 | 3 | [] | no_license | def gaston12(n)
a,b=0,1
while a<n:
print(a, end='')
a,b=b,a+b
print()
gaston12(1000)
| true |
3caae138606416baabff2fa08501daa85de2f378 | stonegithubs/spiders | /project/diaoyan/美团/meituan.py | UTF-8 | 1,314 | 2.671875 | 3 | [] | no_license | import requests
from lxml import etree
import re
import json
class Spiders(object):
def __init__(self ):
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
}
def requests_url(self,url... | true |
9c519642d5e7c3f94d9a9320bbe4400c057c060c | SW-CSA/sonic-mgmt | /ansible/library/lldp_facts.py | UTF-8 | 9,218 | 2.609375 | 3 | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | #!/usr/bin/env python
DOCUMENTATION = '''
---
module: lldp_facts
version_added: "1.9"
author: "Samir Jamkhande (samirja@microsoft.com)
short_description: Retrive LLDP facts for a device using SNMP.
description:
- Retrieve LLDP facts for a device using SNMP, the facts will be
inserted to the ansible_facts key... | true |
4d2caa3cc4f4c0abe02a3a6123f5e9b611d67924 | johnnyflame/advent-of-code-2020 | /src/day_11.py | UTF-8 | 3,632 | 3.28125 | 3 | [] | no_license | import itertools
from aocd import get_data
test_input = """L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
LLLLLLLLLL
L.LLLLLL.L
L.LLLLL.LL
"""
def adjacent_neighbours(row, col, arr):
X = len(arr)
Y = len(arr[0])
neighbors = lambda x, y: [
(x2, y2)
for x2 in... | true |
8fbc73313c42698287443dabd5d19777d2420c03 | modavoodi/paint-shop-optimization | /car_paint_shop.py | UTF-8 | 8,489 | 2.828125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Copyright 2021 D-Wave Systems Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | true |
675dd16be845fb631e4cd56a1a05cf920c408c99 | mollerhoj/Data-Mining-a-questionnaire | /Preprocesser_spec.py | UTF-8 | 298 | 2.78125 | 3 | [
"WTFPL"
] | permissive | import unittest
from Preprocesser import Preprocesser
class Preprocesser_spec(unittest.TestCase):
def setUp(self):
self.p = Preprocesser()
def test_should_clean_float(self):
text = '2,34'
number = self.p.clean_float(text)
self.assertEqual(2.34,number)
unittest.main()
| true |
1a2461341aabb0722800fe70ed52201310db2807 | himanshishrish/python_practice | /func.py | UTF-8 | 65 | 3.109375 | 3 | [] | no_license | def function(a,b):
sum=a+b
print(sum)
function(10,20) | true |
0748a0eb0f2aac58d9b0235d11dc3a8eada6dd0f | dannyjew/Data21Notes | /AdventDay4/Animal.py | UTF-8 | 355 | 3.40625 | 3 | [] | no_license | class Animal:
def __init__(self):
self.alive = True
self.spine = True
self.eyes = True
self.lungs = True
def breathe(self):
print("one breath in and one out")
def eating(self):
print("nom nom nom")
def moving(self):
print("Forwards, Backwards a... | true |
f8dc791be4d6ff727c3d9d29e0694561a714143b | ChulwooKim-AI/ctci-6th-edition | /Chapter7_ObjectOrientedDesign/04.ParkingLot.py | UTF-8 | 5,624 | 3.6875 | 4 | [] | no_license | """Parking Lot
Design a parking lot using object-oriented principles.
Hints:
#258
Does the parking lot have multiple levels? What "features" does it support? Is it paid?
What types of vehicles?
"""
from abc import ABC, abstractmethod
class Vehicle(ABC):
def __init__(self):
self.parking_spot = list()
... | true |
c3ee4edd10cdeae985b16fe7cc3c46838d24c669 | p3ngwen/open-notes | /Intro to CS with Python/src/homework/listing1302.py | UTF-8 | 217 | 2.703125 | 3 | [] | no_license | fruitbasket = { "apple":3, "banana":5, "cherry":50 }
fruitbasketalias = fruitbasket
fruitbasketcopy = fruitbasket.copy()
print( id( fruitbasket ) )
print( id( fruitbasketalias ) )
print( id( fruitbasketcopy ) ) | true |
17c7a0aee24c1e3bec9ba59063b4f366ae6b352c | guiaiy/pythonstudy | /day06/dict.py | UTF-8 | 1,036 | 3.1875 | 3 | [] | no_license | adict = {'name': 'bob', 'age': 22}
cdict = dict()
ddict = dict(['ab', ('name', 'alice'), ['age', 18]])
edict = {}.fromkeys(['tom', 'jerry'], 10)
# print('%s\n%s\n%s' % (adict,ddict,edict))
#
# for key in ddict:
# print('%s : %s' % (key,ddict[key]))
#
# print('%(name)s : %(age)s' % ddict)
#
# for key,val in ddict.i... | true |
e495048ccfbc787665fa7dafd139d41bef43b83b | rmartind/ctci | /ctci/chapter1/permutation.py | UTF-8 | 727 | 4.21875 | 4 | [
"MIT"
] | permissive | """Solution to 1.2: Check Permutation."""
def check_perm(string_one, string_two):
"""Determines if one string is a permutation of another.
Args:
string_one: any string of characters.
string_two: any string of characters.
Returns:
True: the strings are permutations.
Fal... | true |
fff540bf09e96a1419db4392c28131e34ccd50cb | malyvsen/snippeteer | /snippeteer/parse/imports.py | UTF-8 | 2,495 | 2.71875 | 3 | [
"MIT"
] | permissive | from typing import FrozenSet, Dict
from dataclasses import dataclass, field
import ast
from .ast_utils import descend
@dataclass(frozen=True)
class Imports:
@dataclass(frozen=True)
class Alias:
original: str
renamed: str
@classmethod
def from_ast(cls, ast_node: ast.alias):
... | true |
805e726bcf8a82f07fe3d536093f890f0b3c29a8 | Barth2501/hat_classifier | /data/utils.py | UTF-8 | 3,049 | 3.015625 | 3 | [] | no_license | import os
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
# dataset from tensorflow-datasets: https://www.tensorflow.org/datasets
def load(data_dir, batch_size=1):
# Get the filenames and label of our data
image_filenames = []
image_labels = []
for label, category in enu... | true |
cd0eee81192faac5f0b703855ea35a6ad203b923 | utisss/ctf | /2018/ctf-security-day-2018/crypto-not-truly-random/generatefile.py | UTF-8 | 393 | 3.015625 | 3 | [] | no_license | import os
def random_1():
return ord(os.urandom(1)) % 2
length = 4384
def generate_random_bitstring():
string = ""
for i in range(0, 4384):
if random_1() == 1:
string += '0'
else:
string += '1'
return string
output = open('file.txt', 'w')
for i in range(0, 9999... | true |
04f872e4eb3e83aeb91c2adb3f961bcdb805dc3a | rajatkashyap/Python | /covertFloat.py | UTF-8 | 966 | 3.484375 | 3 | [] | no_license | import string
symbols = string.digits + string.uppercase
def convert(number, original_base, new_base, precision=None):
#from original_base
integral, point, fractional = number.strip().partition('.')
num = int(integral + fractional, original_base) * original_base ** -len(fractional)
#to new_bas... | true |
ab2c7394317c06db79e03b8d5d99211ad79104ef | armaango/Learning-python | /Python Fundamentals 2.7/Hackerrank 30 days of code Dicts and Maps.py | UTF-8 | 378 | 3.234375 | 3 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
cases = long(raw_input())
phoneBook = dict()
for i in range(0,cases):
x,y = raw_input().split()
phoneBook[x]=y
while True:
try:
inp = raw_input()
if inp in phoneBook:
print(inp+"="+phoneBook[inp])
els... | true |
31eeb73ba46c55396ef10e86e37936969427ec82 | nforesperance/Tensorflow-Keras | /mlp/mlp_muilticlass.py | UTF-8 | 1,635 | 3.453125 | 3 | [
"MIT"
] | permissive | # mlp for multiclass classification
# This problem involves predicting the species of iris flower given measures of the flower.
from numpy import argmax
from pandas import read_csv
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from tensorflow.keras import Sequentia... | true |
e77b0a9e3d1a41b3e0a469daa3bfd3478a1ac28f | NWU-NISL-BugDetection/river | /River2/MTA_testing/sims/main.py | UTF-8 | 604 | 2.859375 | 3 | [
"MIT"
] | permissive | import json
def read_file(filename):
with open(filename, 'r') as f:
lines = f.read()
sims = lines.split('\n\n')
sims = sims[:-1]
results = {
'Okay': 0,
'app_error': 0,
'overflow': 0,
'lock': 0
}
for sim in sims:
sim_no, sim_det = sim.split... | true |
c1ebe37bb1f46e1e4951faaf3fc34a714524dc1e | tejaswisunitha/teja | /89.py | UTF-8 | 256 | 3.21875 | 3 | [] | no_license | def sort(values):
for m range(len(values)):
for n in range(m,len(values)):
if (values[m] > values[n]):
temp = values[m]
values[m] = values[n]
values[n] = temp
h= raw_input().rstrip()
yList = list(h)
sort(yList)
print("".join(yList))
| true |
a4519f1d2120c4b0cead2a08c919034f2559926d | JaeCoding/keepPying | /foo/lc/leetcode/editor/cn/[841]钥匙和房间.py | UTF-8 | 2,184 | 3.953125 | 4 | [
"MIT"
] | permissive | # 有 N 个房间,开始时你位于 0 号房间。每个房间有不同的号码:0,1,2,...,N-1,并且房间里可能有一些钥匙能使你进入下一个房间。
#
# 在形式上,对于每个房间 i 都有一个钥匙列表 rooms[i],每个钥匙 rooms[i][j] 由 [0,1,...,N-1] 中的一个整数表示,其中
# N = rooms.length。 钥匙 rooms[i][j] = v 可以打开编号为 v 的房间。
#
# 最初,除 0 号房间外的其余所有房间都被锁住。
#
# 你可以自由地在房间之间来回走动。
#
# 如果能进入每个房间返回 true,否则返回 false。
#
#
#
#
# ... | true |
71a95970dff15d87f4a6acc4c8668f0098898dce | mashenlyl/liaopython | /2.io.py | UTF-8 | 68 | 3.1875 | 3 | [] | no_license | name = input('please input you name: \n')
print('you name:\n', name) | true |
c0590385565c41b174a20c4746708b152ab673b1 | pagsamo/google-tech-dev-guide | /70_question/linked_list/double_linked_list.py | UTF-8 | 4,513 | 3.9375 | 4 | [
"Apache-2.0"
] | permissive | class Node:
"""
Node class
"""
def __init__(self, value):
"""
to initalize
"""
self.prev = None
self.next = None
self.value = value
def __str__(self):
"""
str
"""
return "Node({})".format(self.value)
# Feel free to add... | true |
43e7b133de598f84b10b5c4e011bc0c5b426f3d5 | SamProkopchuk/Puzzles | /nqueens/nqueens.py | UTF-8 | 956 | 3.953125 | 4 | [] | no_license | """
This solution is based upon code from the following series:
https://www.coursera.org/specializations/discrete-mathematics
Creates an nxn board of n queens where none are attacking each other.
Apparently it's always possible to construct such a board for n>=4
"""
def can_be_extended_to_solution(perm):
i = len... | true |
6d87bdedecf47e140af1f03430591da4946bf5b1 | smcdonald248/pfr-stats | /statsbasic.py | UTF-8 | 1,975 | 3.609375 | 4 | [] | no_license | '''
statsbasic.py
Performs basic analysis against databases populated by getstats.py
1/7/2020 -- Progress so far:
High Level things To Do:
Print top 10 Players by stat
Print sum of a stat for all players or a configurable subset
...?
'''
import sqlite3
import pandas as pd
conn = sqlite3.connect('stats.sqlite')
co... | true |
136571ff4319c0b8124730cb8674d3ac3de6967c | tonylixu/Python-002 | /week04/homework1/utilities/DBConnector.py | UTF-8 | 6,110 | 3.03125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""Database utility helper"""
import pymysql
import random
import string
class DBConnector(object):
def __init__(self, db_info):
self.host = db_info['DATABASE_HOST']
self.port = db_info['DATABASE_PORT']
self.user = db_info['DATABASE_USER']
self.password = db... | true |
1ce9917bbd216d6c6f7f3299cb79b205d1156658 | b2220333/grid-leader | /highscoreoverlay.py | UTF-8 | 2,840 | 3.109375 | 3 | [] | no_license | from textoverlay import TextOverlay
from colours import Colours
class HighScoreOverlay(TextOverlay):
headersRow=13
def __init__(self):
super(HighScoreOverlay, self).__init__()
self.cyclingColours=Colours.getCyclingColours()
self.cyclingRow=None
self.rowReferences=[]
y=self.getHeadersRow()
self.addRo... | true |
1bb882598b909d9fc2f524b3484b20e1e05ac62d | CJH0220/PyQt_practice | /02-QObject/09-PyQt事件机制.py | UTF-8 | 878 | 3.171875 | 3 | [] | no_license | import sys
from PyQt5.Qt import *
class APP(QApplication):
"""重写了QApplication类,捕捉并显示事件"""
def notify(self, receiver, evt):
if receiver.inherits("QPushButton") and evt.type() == QEvent.MouseButtonPress:
print(receiver, evt)
return super().notify(receiver, evt) # 负责分发
class Btn(QP... | true |
23c005b3d348cca1ef239a7ef16c97a6f11e491f | nuria/study | /EPI/meeting_planner.py | UTF-8 | 1,824 | 3.875 | 4 | [] | no_license | #/usr/local/bin/python
# coding: utf-8
"""
Implement a function meetingPlanner that given the availability,
slotsA and slotsB, of
two people and a meeting duration
dur, returns the earliest time slot that works for both of them and is of duration dur
Times are disjointed, taht is intervals for 1 person do not overlap
... | true |
061c449ac1e69dffb3b64346c1db4f965c3eb91f | APwhitehat/NumericalMethods | /Methods/Integrate.py | UTF-8 | 4,368 | 3.0625 | 3 | [
"MIT"
] | permissive | from __future__ import division
import numpy as np
from utils import Grapher, memoize, SafeEval
class Romberg():
def __init__(self, func, a, b, err):
self.f = SafeEval.functionize(func)
self.a = a
self.b = b
self.err = err
self.intervals = None
self.integral = None
... | true |
71e8c6e7f6bde5b15a614b6d124dca5dde039d73 | artespankov/python-30-days | /Day 8/practice_problem_iterator.py | UTF-8 | 597 | 3.953125 | 4 | [] | no_license | class Sentence:
def __init__(self, string: str):
self.string = string
self.index = 0
self.words = self.string.split()
def __iter__(self):
return self
def __next__(self):
if self.index >= len(self.words):
raise StopIteration
i = self.index
... | true |
33ccebb556943b2e34da6983522dcb99f42a16fc | Pyk017/Competetive-Programming | /Interview_Preparation_Questions/The_Manipulator.py | UTF-8 | 1,382 | 3.15625 | 3 | [] | no_license | # import string
# d = {string.ascii_uppercase[i]: i for i in range(len(string.ascii_uppercase))}
# t = dict(enumerate(string.ascii_uppercase))
# # print(d)
# # print(t)
# def manipulate(s):
# st = []
# for i in s:
# if i == '#':
# temp = st.pop()
# ind = (d[temp] + 1) % 26
# ... | true |
4211a9ccc3f5e8c8113247b6341eec5da41389f9 | aodarc/Galileo | /SolarSystem.py | UTF-8 | 1,717 | 3.40625 | 3 | [] | no_license | from tkinter import *
from time import sleep
from math import sqrt, pi, sin, cos
class Element(object):
_x = int()
_y = int()
_mass = float()
_is_movable = False
speed = 1.
img = 'atom50x50.png'
def __init__(self, root, mass=0.):
self._mass = mass
self._root = root
... | true |
83ed9160f6799ac5adcb3acb606061bcf798f3cf | BenSchr/Bikesharing-Geoanalysis | /processes.py | UTF-8 | 6,112 | 2.734375 | 3 | [] | no_license | def transform(df):
import pandas
from _datetime import datetime
listofbikes = df["number"].unique()
df["date"] = df["time"].apply(lambda t: datetime.strptime(t.split(".")[0], "%Y-%m-%d %H:%M:%S").date())
df["timestamp"] = df["time"].apply(lambda t: datetime.strptime(t.split(".")[0], "%Y-%m-%d %H:%M... | true |
d33bb1ff8f6aee6066383920ba73ffe9df91fd22 | phamtuanduc1803/python | /Python/bt25.py | UTF-8 | 171 | 3.1875 | 3 | [] | no_license | count={}
s=input("Nhap chuoi:")
for i in s.split(" "):
if i in count:
count[i]+=1
else:
count[i]=1
for i in count:
print("%s %s"%(i,count[i]))
| true |
1c09e2bf7aecf8a6afad9bd5cf1554cfef2634f6 | isotomurillo/Programacion | /Python/Cola/orden lista isaias ind.py | UTF-8 | 476 | 3.265625 | 3 | [] | no_license | def ordenar (lis):
if isinstance (lis,list):
return orden(lis,0,0)
else:
return "Error"
def orden (lis,ind1,ind2):
if ind2==len(lis)-1:
return lis
elif ind1==len(lis)-1:
return orden(lis,0,ind2+1)
elif lis[ind1]>lis[ind1+1]:
aux=lis[ind1]
... | true |
09133968d8e5481a5cf145b4af430361050bfc96 | Amulet-Team/Amulet-cli | /src/amulet/command_line/commands/demo.py | UTF-8 | 1,742 | 2.96875 | 3 | [
"MIT"
] | permissive | from typing import List
from .. import SimpleCommand, Mode, command
raise NotImplementedError()
@command("test")
class TestCommand(SimpleCommand):
def short_help(self) -> str:
return "Test Command"
def run(self, args: List[str]):
print("This is a test command that doesn't do anything!")
... | true |
68f75431b3658cf7d938448bf83df9c0dbb385e6 | Aquarius2020/kitorch | /optim/sgd.py | UTF-8 | 2,260 | 3.078125 | 3 | [] | no_license | from .optimizer import Optimizer, learn_rate
import numpy as np
class SGD(Optimizer):
"""
带有动量的SGD
parameters: 模型参数
lr: 学习率, float 或者分段参数 [(5,0.02),(10,0.01),(15,0.005),(20,0.001)]
如果使用分段参数, 第一个代表 epoch, 第二个代表学习率
比如(5,0.02) 代表 1-5 epoch 学习率为0.02
(10,0.01... | true |
36bded1777cfa870cac5f8866083df2db4f3c55a | jimmy-academia/ADF_studies | /projects/reproductions/Attention/module/datafunc.py | UTF-8 | 1,685 | 2.765625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""Function for data preparation
__author__ = '{Jimmy Yeh}'
__email__ = '{marrch30@gmail.com}'
"""
from torch.utils import data
from torchvision import datasets
from torchvision import transforms
#main function to be called
def make_dataloader(data_dir_root, datatype, img_size, batch_size... | true |
5acf05664a5fdc2a25b8693a7240af60cb4d20e1 | harsha-illuri/named_entity_recognition | /NER_EVENTS.py | UTF-8 | 3,447 | 2.53125 | 3 | [] | no_license | # imports
from dataPreProcessing import get_tagged_sentences, get_labels_words, addCharInformatioin, create_word_index,createMatrices, padding, defineBatches, fetch_minibatch
from keras_contrib.layers import CRF
import numpy as np
from keras.models import Model
from keras.layers import TimeDistributed,Conv1D,Den... | true |
d83822a1b80986b0de110facb2d7db746ecfe14f | RatnadeepYSVS/Algorithms | /pair_sum.py | UTF-8 | 2,321 | 3.671875 | 4 | [] | no_license | """
Question:-
You Are Given A List Containing N Elements and A Value X
Your Task is to Find a pair Such that PairSum equals Value X
Print Yes If A Pair Exists Else Print -1
I/p:- O/p:-
6 16 Yes
1 2 3 4 10 6
I/p:- O/p:-
6 20 -1
1 2 3 4 5 7
Constraints:-
1<=N<=10**4
1<=K<... | true |
1dd11e5982c315fe847118cd5c443e1f15e8f9bd | anianruoss/LDABNN | /ex02/tests/public/lib/test_backprop_functions.py | UTF-8 | 8,020 | 2.859375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# Copyright 2020 Christian Henning
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | true |
9345a649d1d6ec574789a494dc56fbbd29b70cf0 | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/97_12.py | UTF-8 | 2,838 | 4.1875 | 4 | [] | no_license | Python | Average of two lists
The problem of finding a average values in a list is quite common. But
sometimes this problem can be extended in two lists and hence becomes a
modified problem. This article discusses shorthands by which this task can be
performed easily. Let’s discuss certain ways in which this ... | true |
2547014de22094339274c43b259f9ba98f019bfd | krystianmichon/interview | /loginTest.py | UTF-8 | 933 | 2.625 | 3 | [] | no_license | from selenium import webdriver
login = "krystian.michon90@gmail.com"
password = "oHeu6qo6WY"
driver = webdriver.Chrome(executable_path=r"C:\Users\Hiro\PycharmProjects\Test_interview\chromedriver\chromedriver.exe")
driver.implicitly_wait(10)
driver.get(r'https://www.rossmann.pl/')
driver.find_element_by_xpat... | true |
c3b80bea636bcc1ea185d683d99bcff118d58cf6 | AndreMiras/PyWallet | /src/pywallet/send.py | UTF-8 | 3,798 | 2.515625 | 3 | [
"MIT"
] | permissive | import re
from eth_utils import to_checksum_address
from kivy.app import App
from kivy.logger import Logger
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivymd.textfields import MDTextField
from pywalib import InsufficientFundsException, UnknownEtherscanException
from pywal... | true |
28b853536973e84ff7fbac524b139d8e2061044b | fbattaglin/hangman | /score.py | UTF-8 | 1,300 | 4.15625 | 4 | [] | no_license | def score(word, f):
"""
word, a string of length > 1 of alphabetical
characters (upper and lowercase)
f, a function that takes in two int arguments and returns an int
Returns the score of word as defined by the method:
1) Score for each letter is its location in the alphabet... | true |
48f6a4d27f7ad57caed7cd2db1b93995bf72d209 | parasnaren/AI-Traffic-Light-Control | /DDQN/agent.py | UTF-8 | 3,091 | 2.875 | 3 | [] | no_license | import sys
import numpy as np
import keras.backend as K
import os
import logging
logging.basicConfig(level=logging.INFO)
from keras.optimizers import Adam
from keras.models import Model, Sequential, load_model
from keras.layers import Dense, LSTM, Lambda
from keras.regularizers import l2
class Agent:
""" Agent Cl... | true |
f52874f5628a2672c0585e30d3944fbb09490599 | pscx142857/python | /作业/Python基础第五天/第三题.py | UTF-8 | 321 | 3.78125 | 4 | [] | no_license | #3.封装函数,实现返回三个数的最小值
def min_3(a,b,c):
"""
返回三个数的最小值
:param a: 第一个数字
:param b: 第二个数字
:param c: 第三个数字
:return: 返回三个中最小的数字
"""
ls = [a,b,c]
mi = min(ls)
return mi
print(min_3(101,2,99)) | true |
81e945af25acddc710f6b0417b2a1ef2351c117d | nishu959/pepcodingbitmanipulation | /utf8encoding.py | UTF-8 | 481 | 2.875 | 3 | [] | no_license | n = int(input())
l = list(map(int, input().split()))
def fun(l):
rbytes= 0
for i in l:
if rbytes==0:
if((i>>7)==0):
rbytes= 0
elif((i>>5)==6):
rbytes= 1
elif((i>>4)==14):
rbytes= 2
elif((i>>3)==30):
rbytes= 3
else:
return False
else:
... | true |
ba8c407d578186dd026e8d6588c74b6b062eae58 | miismail007/Machine_Learning_practice | /Part 1 - Data Preprocessing/Section 2 -------------------- Part 1 - Data Preprocessing --------------------/my_practice.py | UTF-8 | 1,316 | 3.0625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 17:18:04 2020
@author: Ismail
"""
#importing libraries
import numpy as np # mathematical calculations
import matplotlib.pyplot as plt # to plot graphs
import pandas as pd # for handling datasets
#reading dataset
dataset = pd.read_csv('Data.csv')
# separating dep... | true |
4e23709c5333d1e71fafa15547ee9d41e70d730a | oma707/pp2 | /leetcode/3.py | UTF-8 | 373 | 2.765625 | 3 | [] | no_license | class Solution:
def numIdenticalPairs(self, a):
c=0
i=0
j=i+1
n=len(a)
while i<j and j<n+1:
if j==n:
i=i+1
j=i+1
if i==n-1:
break
if a[i]==a[j]:
c=c+1
j=j+1
... | true |
18e5467db80e2660d2d8dfacdfdb55d7ac40ef1c | M-Jawad-Malik/Python | /Python_Fundamentals/34.Continue.py | UTF-8 | 148 | 3.5 | 4 | [] | no_license | # continue statement continues the loop in which it written#
for l in 'string':
if l == 'r':
continue
print(l)
print('The end') | true |
8f114420ba0f58bc3a3b725e0ae40f0e8d5daeb0 | peeyush20/HackerRank | /RadioTransmitter.py | UTF-8 | 888 | 3.03125 | 3 | [] | no_license | #!/bin/python3
import sys
def hackerlandRadioTransmitters(x, k):
# Complete this function
#x = [2,4,5,6,7,9,11,12]
y = list(range(max(x) +1))
#y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
left = 0
for i in range(len(y)):
if i in x:
coverage = []
... | true |
21aaca817294c29ac3a5b2e8d47900ac2dc7b32f | jeevanpillai/ES | /main.py | UTF-8 | 4,667 | 2.84375 | 3 | [] | no_license | import json
import enchant
import sys
#spell-checker.py
with open('jsonFiles/master.json') as file:
data = json.load(file)
f = open("object_dict.txt", "w")
f.write("algorithm\n")
for s in data.keys():
f.write(s+"\n")
f.close()
att_list = []
for obj in data:
for s in data.get(obj):
if (s not in att_list):
... | true |
9b940729606aa05561aac0ddac592e8ec1116a2f | a-coles/fast-accent-detector | /fast_accent_detector/utils/dataset.py | UTF-8 | 1,140 | 2.625 | 3 | [
"MIT"
] | permissive | '''
Data loading
'''
import math
import numpy as np
import os
import random
import torch
from torch.utils.data import Dataset
class AccentDataset(Dataset):
def __init__(self, us_dir, uk_dir, transform=None):
random.seed(0)
us_files = [os.path.join(us_dir, f) for f in os.listdir(u... | true |
b5ab7ab131208e4cdf790ce7b28cc85854a1f84f | hector81/Aprendiendo_Python | /Archivos/pdf/GenerarPDFimagen.py | UTF-8 | 286 | 2.78125 | 3 | [] | no_license | #Importamos los modulos necesarios
from reportlab.pdfgen import canvas
doc = canvas.Canvas("Hola Mundo.pdf")
#Inseratmos la imagen en el documento
doc.drawImage("https://udemy-images.udemy.com/course/750x422/433798_1de9_4.jpg", -50, 500)
#Guardamos el documento
doc.save()
| true |
dbd3da26835e5889f062bb7c820324bf9e9b95f8 | bsllee/coding-for-economists | /data_set_prep.py | UTF-8 | 3,601 | 2.859375 | 3 | [
"MIT"
] | permissive | import pandas as pd
import os
from bs4 import BeautifulSoup
from bs4.element import Comment
import urllib.request
import geopandas as gpd
import shapely.geometry
def star_wars_data():
""" Saves star wars character data with set
datatypes and in pickle format.
"""
df = pd.read_csv(os.path.join('dat... | true |
32d1a060d704406c7ea55ff5db4ea84d42e47deb | ldman751/j2g | /j2g/json_graph.py | UTF-8 | 1,197 | 2.859375 | 3 | [] | no_license | import functools
from graphviz import Digraph
from .misc import TableHelper
def node_name(parent):
return f'{parent.replace(":", "_")}' if ':' in parent else f'{parent}_0'
@functools.singledispatch
def js_graph(js, g, parent):
node = node_name(parent)
g.node(node, label=str(js))
g.edge(parent, node)... | true |
0d0bb25778aa9e928b562e63b2d143999ea679a3 | BROjohnny/Python-A-Z-and-BasicPrograms- | /14 Math Library/math library.py | UTF-8 | 337 | 3.578125 | 4 | [] | no_license | import math
print(math.pi)
print(math.pow(2,3))
print(math.sin(math.pi/2))
import math as m #we assign m for math name
print(m.pi)
print(m.pow(2,3))
print(m.sin(m.pi/2))
from math import sqrt #we do not need call whole math library, just import sqrt part
print(sqrt(4)) # we do not need call as math.sqrt because we... | true |
204bc70838db2c02ad3bae176a2a8d9277b36aa0 | josooik/Opencv | /OpenCV 03일차/실습/opencv_38.py | UTF-8 | 2,539 | 3.09375 | 3 | [] | no_license | # OpenCV sobel
# 소벨 함수(cv2.Sobel)로 입력 이미지에서 가장자리를 검출할 수 있습니다.
# 미분 값을 구할 때 가장 많이 사용되는 연산자이며, 인접한 픽셀들의 차이로 기울기(Gradient)의 크기를 구합니다.
# 이때 인접한 픽셀들의 기울기를 계산하기 위해 컨벌루션 연산을 수행합니다.
# dst = cv2.Sobel(src, ddepth, dx, dy, ksize, scale, delta, borderType)은 입력 이미지(src)에 출력 이미지 정밀도(ddepth)를 설정하고 dx(X 방향 미분 차수), dy(Y 방향 미분 차수), 커널 ... | true |
44501ddcadbdc567b15a3758175e51d1b057faeb | Python-aryan/Hacktoberfest2020 | /Python/minion-game.py | UTF-8 | 275 | 3.640625 | 4 | [] | permissive | s = input()
st,kv = 0,0
v = ['A','E','I','O','U']
for i in range(len(s)):
if (s[i] not in v):
st += (len(s) - i)
elif (s[i] in v):
kv += (len(s) - i)
if(st > kv):
print("Stuart", st)
elif(st < kv):
print("Kevin", kv)
else:
print("Draw")
| true |
85dcf4185f0cdf8415231229ef618d099bedd1ed | r-azh/TestProject | /TestPython/test_file_directory/test_file_directory_compare/test_file_compare.py | UTF-8 | 6,553 | 2.78125 | 3 | [] | no_license | from __future__ import with_statement
__author__ = 'R.Azh'
import os
import filecmp
from pprint import pprint
def mkfile(filename, body=None):
with open(filename, 'w') as f:
f.write(body or filename)
return
def make_example_dir(top):
if not os.path.exists(top):
os.mkdir(top)
curdir ... | true |
eb04fb50f58c17d20253ce5b737a22e7cf27a388 | mattfenwick/SparkyExtensions | /Contents/Resources/python/sparky/align.py | UTF-8 | 4,928 | 2.625 | 3 | [
"LicenseRef-scancode-sparky",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | # -----------------------------------------------------------------------------
# Shift the ppm scales of a spectrum so that a selected peak in this spectrum
# aligns with a selected peak in another spectrum.
#
import Tkinter
import axes
import pyutil
import sparky
import sputil
import tkutil
# ----------------------... | true |
caaebfcf9fe8e0e42a16d464ece9c773e9f67b9a | iangpi/work_one | /py2/mytest/test0011.py | UTF-8 | 261 | 2.90625 | 3 | [] | no_license | #-*-coding:utf-8
print 123
for i in ['任','娜']:
print i
print '-----------插入分割线-------------'
a='If Miss Ren miss the badminton'
if type(a)==type('b'):
print 'there must be something wrong with the racket'
else:
print '一定是球网有问题' | true |
10d984cbf95c84ad9905da479aa57b6da5a63d73 | strangesast/numerical_project_site | /bottle_app.py | UTF-8 | 2,043 | 2.5625 | 3 | [] | no_license | import os
from bottle import default_app, route, static_file, request
import linear_algebra_project.plotting as plotting
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fignames = plotting.figurenames
absolute_path = os.path.dirname(os.path.realpath(__file__))
@route('/')
def hello_world():
... | true |
c78e1b8299a61e2f237b986f95bb81e732ec4866 | seahrh/kaggle-coleridge-initiative | /src/mylib/__init__.py | UTF-8 | 5,124 | 2.71875 | 3 | [
"MIT"
] | permissive | from collections import deque
import json
import re
import numpy as np
import torch
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
from typing import List, Deque, Iterable, Callable
from scml import nlp as snlp
__all__ = ["jaccard", "clean_text", "fbeta", "qa_predict"]
def jaccard(... | true |
8adde6195d4584a203ad6b6a53af451b2a207a07 | tienluils1996/practice-python | /oop/ldtt/143.py | UTF-8 | 158 | 3.234375 | 3 | [] | no_license | n = int(input("nhap n: "))
S = 0
i = 1
while(i < n):
if (n % i == 0):
S = S+i
i = i+1
if(S == n):
print("HT")
else:
print("khong HT")
| true |
a0f7083ac6c41c2dc127e8722d7da3c14b65ef7b | dtrimina/py_DSA | /sort_alg/selection_sort.py | UTF-8 | 876 | 3.65625 | 4 | [] | no_license | #coding:utf8
'''selection sort algorithm with python3'''
from data import data1, data2, data3
def selection_sort(arr):
'''遍历数组每次将未排序部分的最小值放到已排序部分的最后面,直到所有数排序完成'''
if len(arr) <= 1: return arr
for i in range(len(arr) - 1):
smallest_index = i
for j in range(i + 1, len(arr)):
if... | true |
847403faefa8829dcde287afdef06aa9b045f368 | sudoom/Python_study | /IT-Academy/Lesson 5/5.3.py | UTF-8 | 1,088 | 3.25 | 3 | [] | no_license | student_db = [
{'surname': 'Ivanov', 'name': 'Ivan', 'gender': 'male', 'age': '21'},
{'surname': 'Petrov', 'name': 'Ivan', 'gender': 'male', 'age': '31'},
{'surname': 'Sidorov', 'name': 'Pavel', 'gender': 'male', 'age': '25'},
{'surname': 'Prokova', 'name': 'Alyona', 'gender': 'female', 'age': '21'},
... | true |
c35a102c4cc1bf8db1d002b3df2a962a262e4933 | devonrojas/SDHacks-Python | /generate_data.py | UTF-8 | 2,534 | 3.078125 | 3 | [] | no_license | import random
from app import *
users = []
def generate_users(amount):
for i in range(amount):
user = {
"id": f"{i}",
"displayname": f"displayname{i}",
"username": f"username{i}",
"email": f"email{i}",
"password": f"password{i}"
}
... | true |
d9398449a8ba92c3a780741ef19c00887bcc6d74 | NathanNNguyen/challenges | /leetcode/target_rotated_array.py | UTF-8 | 902 | 4.28125 | 4 | [
"MIT"
] | permissive | # Given an integer array nums sorted in ascending order, and an integer target.
# Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
# You should search for target in nums and if you found return its index, otherwise return -1.
# Example 1:
# ... | true |
a34f54608244bc08028708e8e4331feaaeccf39d | kimutaiRop/traffic | /trafic_controler.py | UTF-8 | 414 | 2.875 | 3 | [] | no_license | def check_road_join(road, side):
light = road.get_light(side)
return light.get_color()
def get_next_road(road, side):
if side == "left":
side = 0
else:
side = 1
join_roads = road.get_road()['entering'][:-2]
entry_side_ind = road.get_road()
entry_side_ind = entry_side_ind['s... | true |
3cdeebafb9311a9b484ac79d2f90b1d7dae038b8 | Chenlei-Fu/Interview-Preperation | /Lc_solution_in_python/0498.py | UTF-8 | 536 | 3.015625 | 3 | [] | no_license | import collections
class Solution:
def findDiagonalOrder(self, matrix: List[List[int]]) -> List[int]:
if not matrix or not matrix[0]:
return []
d = collections.defaultdict(list)
n, m = len(matrix), len(matrix[0])
for i in range(n):
for j in range(m):
... | true |
3c1c101ea6bcae25dd0c6b9207f611ab0ecdcd96 | konanast/KanPyScripts | /gene/percentage.py | UTF-8 | 4,296 | 2.71875 | 3 | [] | no_license | #Calculate the percentage per columns
import pandas as pd
import numpy as np
import csv
#import matplotlib.pyplot as plt
#Fortosi dedomenon
in_data = open('data2.txt', 'r')
df = pd.read_csv(in_data, encoding='utf-8', quoting=csv.QUOTE_NONE, header = None)
#Aferesi ton gramon pou ksekinanen me '>' p.x.: >c... | true |
a132dfb49a287b4e10313b1f90669dc5fd05c834 | eaugeas/hilo-tfx | /hilo_rpc/hilo_rpc/serialize/directive.py | UTF-8 | 2,801 | 3.421875 | 3 | [] | no_license | from typing import Any, Dict, Text, Type
class Directive(object):
"""Directive is a base class for directives that can be
executed in specifications"""
def __init__(self, command: Text, *args, **kwargs):
pass
def execute(self) -> Text:
raise NotImplementedError()
class EnvironDirect... | true |
624a6850772f27c2f9e76a74dc0c36536204cd32 | davinci1997/Projekt | /Galerie/Galerieprojekt/bildspeichern.py | UTF-8 | 725 | 2.640625 | 3 | [] | no_license | import os
import shutil
from werkzeug.utils import secure_filename
def takebild(request, app, bildupload):
app.config['bildupload'] = bildupload # erweitern
bild_unsave = request.files['bild'] # file von bild wird hervorgerufen
bild_save = secure_filename(bild_unsave.filename) # Bild sichern / Never tr... | true |
9a3721f6e3a76319cc3e163cd75d8b0c87c0a0c4 | binshi/DL4CV | /starter/ch12/shallownet_animals.py | UTF-8 | 2,014 | 2.609375 | 3 | [] | no_license | from imutils import paths
from keras.optimizers import SGD
import numpy as np
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
import matplotlib.pyplot as plt
from ch07.utilities.datasets import SimpleDatasetLoader
fr... | true |
44fb3f1d8b0ab2bd013f747facf6521f4ff4dc64 | Na3r94/Practice3-S2 | /B.M.M.py | UTF-8 | 228 | 3.71875 | 4 | [] | no_license | Num1 = int(input())
Num2 = int(input())
A = []
B = []
if Num1 > Num2:
Num3 = Num1
else:
Num3 = Num2
for i in range(1,Num3+1):
if Num1 % i == 0 and Num2 % i == 0:
A.append(i)
print(A[len(A) - 1])
| true |
a3bbec6daf96da8df794d6ea3b58e5508602e696 | kkwteh/job_salary | /model_training.py | UTF-8 | 5,939 | 2.796875 | 3 | [] | no_license | import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from collections import Counter
from collections import defaultdict
import hashlib
import datetime
import pickle
df = pd.read_csv('job_salary_data/job_salary_data.csv')
df.shape
df.head()
# Mis... | true |
736ee2af4d6864859799d5fe9b8b0d0fef71e015 | DheerajAlwala/LeetCode | /isSameTree.py | UTF-8 | 725 | 3.546875 | 4 | [] | no_license | # 100. Same Tree
#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 checker(self, t1, t2):
if(t1 is not None and t2 is not None):
if(t1.... | true |
377b47e14cc9e6af76f484abef7e392881736009 | rajasgs/dl_utils | /text/os_walk.py | UTF-8 | 423 | 3.078125 | 3 | [] | no_license | # Taken from https://stackoverflow.com/a/36898903/3776827
# Iterate in the current directory to list sub-dir and files
import os
def list_files(dir):
r = []
for root, dirs, files in os.walk(dir):
for filename in files:
if filename.endswith(".asm") or filename.endswith(".py"):
# pr... | true |
4f91fc2d02767f9a8387bfefcb16bac2400694b0 | noobcoder99/automatetheboringstuff | /fivetimes.py | UTF-8 | 86 | 3.5 | 4 | [] | no_license | print('My name is')
for i in range(5):
print ('Tommy Five Times (' + str(i) +')')
| true |
c3e3121f0d08bdf8b097114f5933d52b02d23fe3 | caro-oviedo/LearningPython | /dictionaries.py | UTF-8 | 579 | 3.578125 | 4 | [] | no_license | glossary = {
'table': 'piece of wood with four legs',
'chair': 'piece of wood used to sit on ',
'cofee maker': 'machine used to make coffee',
}
for word,definition in glossary.items():
print (word)
print (definition.title() + "\n")
rivers ={
'Amazon': 'Peru',
'Ob': 'Russia',
'Mississippi': 'United St... | true |
9bb715809d677d46cf20060e67138803ce44dddd | computerSciencePrestige/pr-2 | /main.py | UTF-8 | 488 | 2.96875 | 3 | [] | no_license | def on_button_pressed_a():
global counter
counter += -1
if counter < 0:
counter = 10
basic.show_number(counter)
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_button_pressed_b():
global counter
counter += 1
if counter > 10:
counter = 0
basic.show_number(co... | true |
5b396587a8e38d2f4fb9641a2728bad7377da5d2 | benywon/Coling2016 | /RNN.py | UTF-8 | 6,150 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
__author__ = 'Bingning Wang'
__mail__ = 'research@bingning.wang'
import numpy as np
import tensorflow as tf
class RNN:
def __init__(self, hidden_size, input_size, init_scale=0.5, return_all_hidden_states=True, back_wards=False,
return_method='ave',
activa... | true |
7186c0d15cd83d0482cf78496817a2c109677d2e | inthescales/lyres-dictionary | /src/diachron/phoneme.py | UTF-8 | 1,736 | 3.703125 | 4 | [
"MIT"
] | permissive | class Letter:
def __init__(self, string):
self.value = string
def __eq__(self, other):
return self.value == other.value
class Phoneme:
def __init__(self, string, stressed=False):
self.value = string
self.stressed = stressed
def __eq__(self, other):
return other... | true |
3f23926eea361cbabb5f2a3ec50f8973e3ac02d2 | Gaurav-20/Blockchain | /blockchain.py | UTF-8 | 8,409 | 3.046875 | 3 | [] | no_license | from time import time
from hashlib import sha256
import json
from uuid import uuid4
from flask import Flask, jsonify, request
import requests
from urllib.parse import urlparse
class Blockchain:
def __init__(self):
'''
Initializes the following -
current_transactions: List of the transactions to be mined in t... | true |
0e61e90669e1daade5b359d02cbdc2714677c282 | brython-dev/brython | /www/src/Lib/test/test_metaclass.py | UTF-8 | 6,342 | 3.484375 | 3 | [
"BSD-3-Clause"
] | permissive | import doctest
import unittest
doctests = """
Basic class construction.
>>> class C:
... def meth(self): print("Hello")
...
>>> C.__class__ is type
True
>>> a = C()
>>> a.__class__ is C
True
>>> a.meth()
Hello
>>>
Use *args notation for the bases.
>>> class A: p... | true |
3fb3a260a5c9b62c105690596373b870f036f5cf | ctc316/algorithm-python | /Lintcode/G_Practice/Tag_TwoPointers/1737. Fruit Into Baskets.py | UTF-8 | 477 | 3.421875 | 3 | [
"MIT"
] | permissive | class Solution:
"""
@param tree: The type of fruit
@return: The total amount of fruit you can collect.
"""
def totalFruit(self, tree):
res = cur = _1st = _2nd = basket2 = 0
for t in tree:
cur = cur + 1 if t in (_1st, _2nd) else basket2 + 1
if t == _2nd:
... | true |
83af9ef69cbea6b4456432dae3e459fb08b8b31b | yfwz100/collaborative-filtering | /src/cf.py | UTF-8 | 3,555 | 3.234375 | 3 | [] | no_license | # coding: utf-8
"""
Collaborative Filtering model.
main usage:
>>> prediction = cf(
>>> pairs,
>>> train_matrix,
>>> ii_sim,
>>> agg_topk(k)
>>> )
The prediction is indexed same as pairs.
author: yfwz100
"""
from numpy import *
## Evaluation Metrics
# Mean Absolute Error (MAE)
def mae(p, r):
... | true |
567049d3b7571f4e5f90f36e08a2f052dc6e5d92 | IlFrenk/Social-Network-Analysis | /gz2csv.py | UTF-8 | 1,990 | 2.671875 | 3 | [] | no_license | import fileinput
import sys
import os
import time
from tqdm import tqdm
""""
python3 gz2csv.py <nome file di origine, io ho il "data"> <parole da cercare separate da spazio>
"""
path = os.path.dirname(os.path.abspath(__file__)) #
noself = False
keys = []
q1 = len(sys.argv)
for k in range(q1):
if k > 1:
if sys.... | true |
63f4096ee4948889ac46f0ac5c4b3e3a285ba6d5 | SAWilding/cse210-student-team-challenges | /06-mastermind/mastermind/game/guess.py | UTF-8 | 391 | 3.234375 | 3 | [] | no_license | #called once at start
class Guess():
def __init__(self):
self.current_guess = 0
#sets the guess
def set_guess(self, user_guess):
self.current_guess = user_guess
def get_guess(self):
return self.current_guess
def check_guess(self, code):
if self.current_guess ... | true |
1464b577f064e108cb6f24933acaaf28bbdc212c | smisiewicz/ios-secure-enclave-test | /secure-enclave-test.py | UTF-8 | 8,858 | 2.859375 | 3 | [] | no_license | #
# Demonstrating kSecKeyAlgorithmECIESEncryptionCofactorX963SHA256AESGCM
#
# David Schuetz (@DarthNull)
# May 2018
#
# see also: https://darthnull.org/security/2018/05/31/secure-enclave-ecies
#
###############################################################
message = 'The Magic Words are still Squeamish Ossifrage'
... | true |