blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
02ede3948313deb143daccadb98e4320e0753621 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2339/60606/241120.py | UTF-8 | 297 | 3.15625 | 3 | [] | no_license | test_num = int(input())
for i in range(test_num):
sum = 0
n = int(input())
array = input().split(" ")
array = [int(x) for x in array]
for j in range(len(array)):
for k in range(j+1,len(array)):
if array[j] > array[k]:
sum += 1
print(sum) | true |
4fe4c92e33d43030ac5a7405992a27d8af37b52a | Python | Ryctorius/Curso-de-Python | /PycharmProjects/CursoExercicios/ex022.py | UTF-8 | 264 | 3.765625 | 4 | [] | no_license | NOME =str(input('Digite seu nome completo:'))
print(NOME.upper())
print(NOME.lower())
Q = len(NOME)
T = NOME.count(' ')
print('Há um total de {} letras no seu nome completo'.format(Q-T))
F = NOME.split()
print('Seu primeiro nome tem {} letras'.format(len(F[0])))
| true |
dd29526a9dae1264e000b645d0399f67e32d8c6e | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2899/60640/247074.py | UTF-8 | 353 | 3.546875 | 4 | [] | no_license | def is_power(n):
if n < 4:
if n == 1:
return 1
else:
return 0
else:
if n % 4 != 0:
return 0
else:
n = n // 4
return is_power(n)
inp = int(input())
if inp < 0:
inp = -inp
res = is_power(inp)
if res == 1:
print("... | true |
611d7ce6fdd46276ed6158ed826755e969b5db1b | Python | shrikumaran/Transfi-NITT | /pyserial.py | UTF-8 | 273 | 3.140625 | 3 | [] | no_license |
from time import sleep
import serial
ser = serial.Serial('/dev/ttyACM0') # open serial port
num1 = '1'
num2 = '0'
num3 = '1'
num4 = '0'
#time.sleep(2)
while True:
s = str(num1) + '\t' + str(num2) + '\t' + str(num3) + '\t' + str(num4) + '\n'
ser.write(s.encode()) | true |
a411d050ca97c139ba64a19cef69ed997e9d306a | Python | tjmlandi/CS-Coursework | /Analysis of Algorithms/a4q2.py | UTF-8 | 962 | 3.75 | 4 | [] | no_license | class Solution(object):
def exploreMatrixWithPits(self, matrix):
#Check if the upper left corner is a pit, if so, return 0
if matrix[0][0] == 1:
return 0
else:
#Otherwise, initialize it to 1
matrix[0][0] = 1
m = len(matrix)
n = len(matrix[0])
#Loop through the matrix, from left to right a... | true |
4033adfda2424b5aed7f9c8bac90231de5e3f2c3 | Python | LadislavVasina1/PythonStudy | /ProgramFlow/ranges.py | UTF-8 | 122 | 3.546875 | 4 | [] | no_license | for i in range(1, 21):
print(f"i is now {i}")
print("*" * 50)
for i in range(0, 21, 2):
print(f"i is now {i}")
| true |
3176b2476b7cf70c8a9d195117cb0876f6b01d9c | Python | dv3/ai_algos | /naive_bayes.py | UTF-8 | 24,135 | 2.84375 | 3 | [] | no_license | #histograms, gaussians, or mixtures
import sys,math
numofclasses = 0
###################
# This is all histograms
###################
def histogramming(someExample,attributes,binnes):
classData,totalRows = classCounts(someExample)
#print 'attributes',attributes
baapAtributes=[]
for col in at... | true |
615bf4aee0b9e08695fa7bb1098953a6dd5c79cb | Python | mbilab/ML-tutorial | /unit/data_preprocessing/.prepared/ex1_np.py | UTF-8 | 278 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python3
import numpy as np
data_matrix = np.loadtxt('../ex1.csv', delimiter = ',')
label, other = np.hsplit(data_matrix, [1])
label = np.reshape(label, [-1]).astype(int)
one_hot = np.eye(4)[label]
data_matrix = np.hstack([one_hot, other])
print(data_matrix)
| true |
9c59efbf2a59e62aaefb17606211473dee9ebc4b | Python | Yorwxue/PytorchMnist | /train.py | UTF-8 | 2,181 | 2.640625 | 3 | [] | no_license | import os
import torch
from tqdm import tqdm
from model_architecture import mnist_model
from dataset import mnist_dataset
if __name__ == "__main__":
model_dir = "weights/mnist/"
model_name = "mnist_model"
display_freq = 100
num_epoch = 5
if not os.path.exists(model_dir):
os.makedirs(mode... | true |
cf5309fe6d61397b889dd1c7adc73d20fba93dc9 | Python | dbehrlich/KerasCog | /ID_removed_Fixation.py | UTF-8 | 10,326 | 2.5625 | 3 | [
"MIT"
] | permissive | import numpy as np
from keras.layers.core import Dense
from keras.layers.recurrent import Recurrent, time_distributed_dense
from keras import backend as K
from keras import activations, initializations, regularizers
from keras.models import Model
from keras.layers import Input
from keras.optimizers import Adam
from ker... | true |
9c42c956310f71589a8fd4930db5c99a290bd711 | Python | srdmdev8/logs-analysis-project | /newsdb.py | UTF-8 | 2,573 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python
import psycopg2
DBNAME = "news"
def logs_analysis_queries():
"""Pull the 3 most popular articles"""
db = psycopg2.connect(database=DBNAME)
c = db.cursor()
c.execute("""SELECT articles.title, count(log.path)
FROM log
JOIN articles on log.path = '/... | true |
779beb521ef96dbc08d457f9194e70944b595e6b | Python | connor-makowski/AnagramSolver | /anagram.py | UTF-8 | 1,499 | 3.5 | 4 | [] | no_license | import json
dictionarylocation=r'.\words.json'
with open(dictionarylocation, 'r') as f:
dictionary = json.load(f)
def find(input):
letters=[]
for i in input:
letters.append(i)
consider=[]
found=[]
for i in list(set(letters)):
for j in dictionary[i]:
consider.append(j... | true |
0450814a6f666498d585439f52c4335bcfa3980e | Python | Nain-05/PractiseAssignment | /PractiseQ21.py | UTF-8 | 391 | 4.21875 | 4 | [] | no_license | #21. Write a Python program to convert seconds to day, hour, minutes and seconds.
Time = int(input('\nEnter Time in Seconds:\n'))
Days = int(Time / (24*3600))
Time = Time % (24*3600)
Hours = int(Time / 3600)
Time %= 3600
Minutes = int(Time / 60)
Time %= 60
Seconds = int(Time)
print('\n\t\td:h:m:s')
print("\n\t\t" + ... | true |
186ed303c47f1cd37dc233990f686787e2356b25 | Python | bu-cms/monox_fit | /makeWorkspace/utils/jes_utils.py | UTF-8 | 1,380 | 2.53125 | 3 | [] | no_license | # ==============================
# Helper functions regarding JES/JER uncertainties
# ==============================
import ROOT as r
import re
from general import get_nuisance_name
def get_jes_variations(fjes, year, proc='qcd'):
'''Given the JES file, get the list of JES variations.'''
jet_variations = set()... | true |
3449ecce7d84c6f4f07ea9f90d85ea9b7d15e633 | Python | matiasezequielsilva/repositorio | /python/RedefinirOperadores.py | UTF-8 | 935 | 4.125 | 4 | [] | no_license | class Lista:
def __init__(self, lista):
self.lista=lista
def imprimir(self):
print(self.lista)
def __add__(self,entero):
nueva=[]
for x in range(len(self.lista)):
nueva.append(self.lista[x]+entero)
return nueva
def __sub__(self,entero... | true |
711f1425bc2bb96ec0e8bf663b1485fd040ed478 | Python | dawidwelna/2017sum_wiet_kol3 | /diaryTest.py | UTF-8 | 2,381 | 2.65625 | 3 | [] | no_license | import diaryprogram as dp
import unittest
diary = dp.Diary()
class testOpener(unittest.TestCase):
def testOpenerRaise(self):
"""Opener should fail given incorrect path to file."""
self.assertRaises(IOError, dp.opener, 'corrupted/path')
class ChooseStudentBadInput(unittest.TestCase):
def testNotInteger(self):... | true |
b708a7b6d506e9ed8c5766803726ff9fd7abba20 | Python | Alex-zhai/learn_practise | /tf_learn/mnist_nn.py | UTF-8 | 2,133 | 2.84375 | 3 | [] | no_license | import tensorflow as tf
import random
from tensorflow.examples.tutorials.mnist import input_data
batch_size = 128
learning_rate = 0.001
epoches = 50
mnist = input_data.read_data_sets("mnist_data/", one_hot=True)
# set placeholder
x = tf.placeholder(tf.float32, [None, 28*28])
y = tf.placeholder(tf.float32... | true |
fd9c6f67f115058c91cb279a2139a58578a34369 | Python | Darkwing42/home_app | /todo/models.py | UTF-8 | 2,475 | 2.578125 | 3 | [
"MIT"
] | permissive | from app import db
from datetime import datetime
from sqlalchemy.dialects.postgresql import UUID
import uuid
from app.utils.uuid_converter import str2uuid
from user.models import User
class Task(db.Model):
__tablename__ = 'tasks'
id = db.Column(UUID(as_uuid=True), default=lambda: uuid.uuid4(), unique=True... | true |
5b0a1a357500d0d6b742534dc94f997526a500d2 | Python | nlp-tlp/redcoat-annotations-processing | /process_annotations.py | UTF-8 | 822 | 2.59375 | 3 | [] | no_license | import json, csv
INPUT_FILE = "example_annotations.json"
OUTPUT_FILE_JSON = "output.json"
OUTPUT_FILE_CSV = "output.csv"
lines = []
with open(INPUT_FILE, 'r') as f:
for line in f:
lines.append(json.loads(line.strip()))
with open(OUTPUT_FILE_JSON, 'w') as f:
json.dump(lines, f)
with open(OUTPUT_FILE_CSV, 'w', ne... | true |
ea5d0a3189a67a790957dea33bea4d50d738c199 | Python | pf981/project-euler | /060_prime_pair_sets.py | UTF-8 | 2,160 | 3.71875 | 4 | [] | no_license | import collections
import sympy
from sympy.ntheory.primetest import isprime
MAX_PRIMES = 10000
TARGET_PAIRS = 5
def generate_valid_paths(tree):
"""
This generates paths from a depth-first tree traversal such that the path
is TARGET_PAIRS long and every element is adjacent to every other element
"""
... | true |
c4fab90f2e24b704d7f8b904c224a87a6a86b4ec | Python | ToddDiFronzo/bwcs | /datasets/clean_master_hockey.py | UTF-8 | 790 | 2.96875 | 3 | [] | no_license | import numpy as np
import pandas as pd
import csv
# import matplotlib.pyplot as plt
df = pd.read_csv(r'C:/Users/Todd/Desktop/python_learn/python_data_analytics/buildweek/datasets/Master_hockey.csv')
print(df.head())
print(df.columns)
df1 = (df[['weight', 'height', 'gender', 'sport']].copy())
print(df1.head())
p... | true |
0315c76e4c31426f5a48e3772f32791001cfd249 | Python | CTSHEN/sciencedates | /sciencedates/__init__.py | UTF-8 | 7,825 | 3.09375 | 3 | [
"MIT"
] | permissive | from __future__ import division
import datetime
from pytz import UTC
import numpy as np
from dateutil.parser import parse
import calendar
import random
def datetime2yd(T):
"""
Inputs:
T: Numpy 1-D array of datetime.datetime OR string suitable for dateutil.parser.parse
Outputs:
yd: yyyyddd four di... | true |
487af4212b4291128432dc2f48192cc3703f4831 | Python | huangyingw/fastai_fastai | /dev_nbs/course/lesson4-tabular.py | UTF-8 | 1,247 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # ---
# jupyter:
# jupytext:
# formats: ipynb,py
# split_at_heading: true
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.6.0
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# ... | true |
e78800afc57578caf9c95b1124828454b72dbe56 | Python | gilgameshzzz/learn | /day10Python_pygame/day10-管理系统/system/04-显示图形.py | UTF-8 | 1,667 | 3.578125 | 4 | [] | no_license | """__author__ = 余婷"""
import pygame
if __name__ == '__main__':
pygame.init()
screen = pygame.display.set_mode((600, 400))
screen.fill((255, 255, 255))
"""
1.画直线
line(Surface, color, start_pos, end_pos, width=1)
Surface -> 画在哪个地方
color -> 线的颜色
start_pos -> 起点
end_pos -> 终点
w... | true |
756464381ee3fbafc1f9cf72f06a22961f1e4746 | Python | heiimzy/zhihuspider | /Zhihuspider.py | UTF-8 | 1,009 | 2.953125 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
class spider():
def get_url(url):
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' }
r = requests.get(url,headers=headers)
return r.text
... | true |
02f80e996e5628c0935e6e873f1a2b837b6b0f04 | Python | tx2016/Self-Driving_Car-Nanodegree-Projects | /CarND-Advanced-Lane-Lines/thresh.py | UTF-8 | 4,726 | 2.953125 | 3 | [] | no_license | import pickle
import cv2
import glob
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
# Read in the saved camera matrix and distortion coefficients
# These are the arrays you calculated using cv2.calibrateCamera()
dist_pickle = pickle.load(open("camera_cal/wide_dist_pickle.p", "rb")... | true |
79fdf9566f700bc67e4317dcb53772c565a28316 | Python | spoorthi33/computer-networks_assign-2 | /server.py | UTF-8 | 3,343 | 2.546875 | 3 | [] | no_license | import os
import time
import pickle
import socket
from library import *
server_hostname = socket.gethostname()
server_ip = socket.gethostbyname(server_hostname)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((server_ip, SERVER_PORT))
print(f'server started listening on {server_ip} at port {SERVER_P... | true |
ce46f73a0611dc2cbe997b7d73eb3be4841232e0 | Python | Nehajha99/Python | /loop.py/loop_18.py | UTF-8 | 64 | 2.578125 | 3 | [] | no_license | c=156
while c<=10:
if c-155:
print(z)
c=c+1
| true |
2d59003405c494c0e72f2a55009033595dc8b2a4 | Python | harishramuk/python-handson-exercises | /382.read data from txt file.py | UTF-8 | 75 | 2.640625 | 3 | [] | no_license | file = open('GSP.txt','r')
data = file.read(-1)
print(data)
file.close() | true |
411aa64ba4e667315026ecdb7150ee8907b820fa | Python | madhuprakash19/python | /even_odds_new.py | UTF-8 | 212 | 2.875 | 3 | [] | no_license | import math
a=[int(i) for i in input().split()]
#print(a)
n=a[0]
k=a[1]
if k<=math.ceil(n/2):
print((k*2)-1)
else:
if n%2==0:
print(n-((n-k)*2))
else:
print((n-((n-k)*2))-1)
| true |
238e4481c6dadce5d4f3bdf4888bd4cfc233d936 | Python | yinccc/leetcodeEveryDay | /221-20190523-Maximal Square.py | UTF-8 | 1,762 | 3.015625 | 3 | [] | no_license | matrix=[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
dp=[[0 for x in range(len(matrix[0]))] for y in range(len(matrix))]
print(len(matrix),len(matrix[0]))
print(len(dp),len(dp[0]))
maxNumber=0
def ThreeMin(i, j, k):
return min(min(int(i), int(j)), int(k))
for i in range... | true |
1c4d641edb41403aba4094d23a3fb691b4c7504e | Python | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/leetcode/416_partition_equal_subset_sum.py | UTF-8 | 649 | 3 | 3 | [] | no_license | """
REF: https://leetcode.com/problems/partition-equal-subset-sum/discuss/90592
`dp[s]` means the specific sum `s` can be gotten from the sum of subset in `nums`
"""
c_ Solution:
___ canPartition nums
"""
:type nums: List[int]
:rtype: bool
"""
__ n.. nums:
r.... | true |
6590285aa049fd205fdbfb2086a26af194082538 | Python | wxx17395/Leetcode | /python code/题库/2. 两数相加.py | UTF-8 | 1,485 | 3.046875 | 3 | [] | no_license | class Solution(object):
def addTwoNumbers(self, l1, l2):
rList = l1
addflag = 0
returnflag = 0
while 1:
if not l1.next or not l2.next:
returnflag = 1
addresult = l1.val + l2.val
if addflag:
addresult += 1
... | true |
b191a7bcadb345cb6c16fa9885b6b8898dd34a1b | Python | GabrielEstevam/icpc_contest_training | /uri/uri_python/string/p2174.py | UTF-8 | 146 | 3.0625 | 3 | [] | no_license | N = int(input())
lista = []
for n in range(N):
lista.append(input())
lista = list(set(lista))
print("Falta(m)", 151-len(lista), "pomekon(s).") | true |
ea403d95e331a6bb942ffbf6ff6d9075325b7628 | Python | scoriiu/doc_parser | /tests/test_doc_parser.py | UTF-8 | 1,633 | 2.65625 | 3 | [] | no_license | import json
import os
import pytest
import hashlib
from parser.parser import parse_nb_patients, convert_pdf_to_txt, match_area_of_interest, parse_study_year_range
script_dir = os.path.dirname(os.path.realpath(__file__))
@pytest.fixture(scope='module')
def reference_text():
text = open(f'{script_dir}/data/text.... | true |
1e822f185bf6094ff6ed9555975146af1da2feb4 | Python | bkersteter/cloud-native-demo | /cloud-native-demo/python/tweet_loader.py | UTF-8 | 2,632 | 3.0625 | 3 | [] | no_license | # tweet_loader.py
#
# Demo python scipt to read tweets from Kafka and load them
# into a local Postgres database
#
#
# Bart Kersteter - bkersteter@gmail.com
#
# 03/11/2018 Initial
#
from kafka import KafkaConsumer, KafkaClient
import psycopg2
import json
from io import StringIO
######################... | true |
355d59bb7a5b323c9e4da8aad4ad7747aac097e7 | Python | MaximeDaigle/Low-Resource-Machine-Translation | /evaluator.py | UTF-8 | 4,845 | 2.828125 | 3 | [] | no_license | import argparse
import subprocess
import tempfile
import sentencepiece as spm
import tensorflow as tf
import os
import itertools
from nmt.nmt_seq2seq import predict, load_ids, Encoder, DecoderNetwork, max_len
def generate_predictions(input_file_path: str, pred_file_path: str):
"""Generates predictions for the m... | true |
f32f9eba11bbed22b55f934876e14a38c20a76fe | Python | thaolinhnp/Python_Advanced | /Bai1_DEMO_OOP/Bai3.py | UTF-8 | 786 | 3.40625 | 3 | [] | no_license | class QuanLyCD():
def __init__(self, tenCD, caSy, soBH, giaThanh):
self.tenCD = tenCD
self.caSy = caSy
self.soBH = soBH
self.giaThanh = giaThanh
if __name__ == "__main__":
dsCD = []
tt = 1
while tt == 1:
tenCD = str(input('Ten CD:'))
caSy = str(input('Ca ... | true |
99d2b682f34cb2c3c1f430271a869b2b5b33a4fa | Python | ISISComputingGroup/ibex_utils | /installation_and_upgrade/ibex_install_utils/logger.py | UTF-8 | 1,049 | 2.9375 | 3 | [] | no_license | import os
import sys
import time
class Logger:
"""
Logger class used to capture output and input to a log file.
"""
def __init__(self):
CURRENT_DATE = time.strftime("%Y%m%d")
LOG_FILE = f"DEPLOY-{CURRENT_DATE}.log"
LOG_DIRECTORY = os.path.join("C:\\", "Instrument", "var", "logs... | true |
d0baec1bbd2c2c15e9a73918a1ab9ff840f740ca | Python | seboldt/ListaDeExercicios | /EstruturaDeDecisao/25-assassinato.py | UTF-8 | 656 | 3.609375 | 4 | [] | no_license | print('Depoimento \nResponda apenas s ou n')
r1 = input('Telefonou p/ a vitima ? \n')
classificacao = 0
if r1 == 's':
classificacao += 1
r2 = input('Esteve no local do crime ?\n')
if r2 == 's':
classificacao += 1
r3 = input('Mora perto da Vitima ? \n')
if r3 == 's':
classificacao += 1
r4 = input('Devia... | true |
921ec85c5832fa915558a3602e96c98136d6546e | Python | solomonchild/pascal_mini_compiler | /pascal_parser/parser.py | UTF-8 | 2,806 | 3.078125 | 3 | [] | no_license | from .lexer import *
#<G> ::= <S>
#<S> ::= if <E> then <S> | <ID> := <STRING> ;
#<E> ::= <ID> <OP> <ID> | <ID> <OP> <STRING> | (<E>) and (<E>)
#<ID> ::= [a-zA-Z_][a-zA-Z0-9_]*
#<OP> ::= - | + | * | /
class Parser:
def __init__(self, lexer):
self.lexer = lexer
self.tokens = None
self.tok... | true |
252cab38dd2dda364cf381f6f7a3ff3a14cbae96 | Python | stellarnode/python_steps | /codewars/fit_schedules.py | UTF-8 | 12,431 | 3.359375 | 3 | [] | no_license | def get_start_time(schedules, duration):
def convert_to_decimal(time):
hm = time.split(":")
return int(hm[0]) * 60 + int(hm[1])
def convert_to_time_string(time):
if time == None:
return None
else:
h = int(time) / 60
m = int(time) % 60
... | true |
fc413a8ddac43d64144d69ae8ccec0a5e9e59237 | Python | ayenque/Python | /01.Pensamiento Computacional/rangos.py | UTF-8 | 573 | 3.359375 | 3 | [] | no_license | #range(comienzo, fin , pasos)
mi_rango = range(1,5)
type(mi_rango)
for i in mi_rango:
print(i)
mi_rango = range(0,7,2)
mi_otro_rango = range(0,8,2)
print(mi_rango == mi_otro_rango)
for i in mi_rango:
print(i)
for i in mi_otro_rango:
print(i)
print(id(mi_rango))
print(id(mi_otro_rango))
print(mi_... | true |
a4334fbe19a085d30345705bd370afcac0f9938b | Python | tom-3266/Name_Error | /part A/calculator.py | UTF-8 | 3,326 | 4.15625 | 4 | [] | no_license | #Design a user interactive Calculator .( sum , subtraction , multiplication , division , Distance , speed , Intrest)
#defining functions for calculator
def sumi(a,b): #addition
return a+b
def subs(a,b): #difference
return a-b
def mult(a,b): #multiplication
return a*b
def div(a,b): #division
return a/b... | true |
e043bc3f657250a2bcf1cad0b53bc020f1888019 | Python | Aasthaengg/IBMdataset | /Python_codes/p03730/s766307658.py | UTF-8 | 152 | 2.703125 | 3 | [] | no_license | from fractions import gcd
def check():
A, B, C = map(int, input().split())
if C%gcd(A,B)==0:
return 'YES'
return 'NO'
print(check()) | true |
cdd6887b9db44c1a54f571acb3160d4503cfc98d | Python | prateekpm123/Prateek-s-Competitve-Coding-Repo | /Love Babbar sheet/to reverse an array or string/Reverse of a string.py | UTF-8 | 700 | 3.78125 | 4 | [] | no_license | # to find the reverse of the string or array
arr = [4, 2,1,3,6, 8, 9, 10, 11, 12,13,14]
# arr = 'hello there'
# arr = []
# num = int(input("Enter the number of elements you want in an array "))
# for i in range(num):
# val = input()
# arr.append(val)
start = 0
# if(len(arr)%==0):
for i in range(len(arr)-1, in... | true |
66c3aa274e092b7fa0a732fb57bd6844733fc12d | Python | redmage123/deep_learning_tensorflow | /examples/module1/simple_numpy_program.py | UTF-8 | 501 | 3.96875 | 4 | [] | no_license | #!/usr/bin/env python3
import numpy as np
# Create an array 'a' as a 2 by 2 dimensional array initialized to zeros.
a = np.zeros((2,2))
# Create an array 'b' as a 2 by 2 dimensional array initialized to ones.
b = np.ones((2,2))
# Add the two up. The axis parameter refers to columsn vs. rows. Axis=0
# refers aggr... | true |
e3264f707ea93bed16d96ac564a680d9c3c763ca | Python | conrad-strughold/GamestonkTerminal | /openbb_terminal/portfolio/brokers/robinhood/robinhood_model.py | UTF-8 | 3,002 | 2.671875 | 3 | [
"MIT"
] | permissive | """Robinhood Model"""
__docformat__ = "numpy"
import logging
from datetime import datetime, timedelta
import numpy as np
import pandas as pd
from robin_stocks import robinhood
from openbb_terminal.core.session.current_user import get_current_user
from openbb_terminal.decorators import log_start_end
from openbb_termi... | true |
376cb6a720e889a2227e618684d98b3fa218e255 | Python | MoMolive/MoMolive.gethub.io | /跳过验证码/。。。.py | UTF-8 | 265 | 3.296875 | 3 | [] | no_license | # coding = utf - 8
import random
ver = random.randint(1000,9999)
print(u'生成验证码:%d'%ver)
num = (u'请输入数值:')
print(num)
if num == 0:
print(u'登陆成功')
elif num == 999999:
print(u'登陆成功')
else:
print(u'验证码错误')
| true |
563b382bc0261fe31406f76b1723a6df32617c2c | Python | sergelab/yustina | /src/contrib/data/attachment.py | UTF-8 | 9,192 | 2.65625 | 3 | [] | no_license | # coding: utf-8
from __future__ import absolute_import
import logging
import os
import sys
from contrib.utils.file import add_postfix_to_filename
class ValidationError(Exception):
def __init__(self, errors, path=None):
if not isinstance(errors, list):
errors = [TypeError(errors)]
msg... | true |
be60444d0596552984220938e3dccdf3b0bff194 | Python | Fay321/leetcode-exercise | /solution/problem 23.py | UTF-8 | 877 | 3.8125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# 最简单直接的思路
class Solution1(object):
def countBits(self, num):
"""
:type num: int
:rtype: List[int]
"""
lst = []
for i in range(0,num+1):
s = 0
for j in bin(i).split('b')[1]:
if j=='1... | true |
9451bcb1299377bae1cd2c6cbb2039e41ebec214 | Python | jlyu26/Python-Data-Structures-and-Algorithms | /Problems Notebook/230. Kth Smallest Element in a BST.py | UTF-8 | 1,758 | 4.09375 | 4 | [] | no_license | # 230. Kth Smallest Element in a BST
# Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
# Note:
# You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
# Example 1:
# Input: root = [3,1,4,null,2], k = 1
# 3
# / \
# 1 4
# \
# 2
# Output: 1
# Exam... | true |
5a2fc4a00a1c5bb839658ef35fbc08d419b64d54 | Python | hankumin/NewsCycle | /allVowels2.py | UTF-8 | 756 | 3.4375 | 3 | [] | no_license | #!usr/bin/python
import gzip
import re
import os
#returns true when word has aeiou in this order
def vowelWord(word,vowels):
return vowels.search(word)
def main():
theDict = open('/usr/share/dict/words')
#Expressions for words with pattern AEIOU in them
theWordexp = re.compile('^((?![aei... | true |
191287006fcb832399677af0a049a9badf4c0aec | Python | sungwooHa/python_dummy | /helloWorld.py | UTF-8 | 80 | 3.078125 | 3 | [] | no_license | i, hap = 0, 0
for i in range(1, 11, 3) :
hap += i
print("%d %d" % (hap, i))
| true |
4ee9715dbda4a0865567fbf6861d6d7a0a552490 | Python | jonnycrunch/pypeerdid | /peerdid/tests/file_test.py | UTF-8 | 289 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | import os
from ..delta import Delta
def test_is_iterable(scratch_file):
for item in scratch_file:
return
def test_file_io(scratch_file):
assert not os.path.exists(scratch_file.path)
scratch_file.append(Delta("abc", []))
assert os.path.exists(scratch_file.path) | true |
69e8343b808f0ca7d4769bcd9e31bb7ba64e0437 | Python | Neroal/TQC-python- | /TQC309.py | UTF-8 | 578 | 3.890625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
請使用迴圈敘述撰寫一程式,提示使用者輸入金額
(如10,000)、年收益率(如5.75),以及經過的月
份數(如5),接著顯示每個月的存款總額。
提示:四捨五入,輸出浮點數到小數點後第二位
"""
amount = eval(input())
rate = eval(input())
period = eval(input())
#change to percent
rate/=100
print('%s\t%s'%('Month','Amount'))
for month in range(1,period+1):
tota... | true |
8977b272860bb2312e7872872d269ccc3b2d4c51 | Python | 15csmonk/computing_method | /计算方法_作业二/Gauss-Legendre.py | UTF-8 | 467 | 3.296875 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import math
def fun(x):
return 1/(1+x**2)
def main():
GauFive={0.9061798459:0.2369268851,0.5384693101:0.4786286705,0:0.5688888889}
GauSum=0.0
a=0.0
b=1.0
for key,value in GauFive.items():
GauSum+=fun(((b-a)*key+a+b)/2)*value ... | true |
944de9bcb03ba7b8c28a5b603a94724b1124b701 | Python | Maria105/python_lab | /lab7_14.py | UTF-8 | 402 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- codding:utf-8 -*-
def input_email() -> str:
"""Input email"""
email = input('Enter your email: ')
return (email)
def valid_check(email: str) -> bool:
"""Check is valid your email"""
separation = email.split('@')[1].split('.')
return len(separation[-1]) > 1 and ema... | true |
7027754c13bed24d0abb2c54fd3617e784ff3173 | Python | DoomPI/ABC_03 | /cartoon.py | UTF-8 | 2,647 | 3.53125 | 4 | [] | no_license | # --------------------------------------------
from film import Film
from type import DrawingType
from rnd import RandomInt
from rnd import RandomString
class Cartoon(Film):
def __init__(self):
super().__init__()
self.type = 0
def ReadStrArray(self, strArray, i):
# Провер... | true |
7111f8f6799b1aa48daebdbfc44a4002fed7014e | Python | EZevan/Conver_Excel_to_XML | /convert.py | UTF-8 | 8,709 | 2.546875 | 3 | [] | no_license | # coding:utf-8
import os
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from excelConfig import ExcelConfig
from enums import Significance
from enums import ExecMode
class Convert():
def __init__(self, ExcelFileName, SheetName):
self.excelFile = ExcelFileName + '.xlsx'
self.excelSheet = S... | true |
fdef6916234797d9f27f3336db3a54dc7925c34f | Python | theoneandonlywoj/ML-DL-AI | /Supervised Learning/Image Recognition/SimpleParallelCNN/network.py | UTF-8 | 2,614 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import tflearn
import numpy as np
from tqdm import tqdm
from tflearn.layers.merge_ops import merge
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
from tflearn.data_utils import to_categorical
from... | true |
92bff5144e114d31a41248b8f5536f69e2770471 | Python | elyerandio/linux_python | /user.py | UTF-8 | 848 | 2.765625 | 3 | [] | no_license | #!/usr/bin/python
import os, crypt, sys
from datetime import date, timedelta
import logging
logging.basicConfig(filename=sys.argv[0] + 'log', level=logging.DEBUG,
filemode='w')
if len(sys.argv) == 1:
logging.critical("Needs root privileges!")
sys.exit("\nYou need to specify the username to create!\n")
logging... | true |
92db68860995b574a264117514a63c539c1b446a | Python | nhichan/hachaubaonhi-fundamental-c4e16 | /session2/bài tập/print2.py | UTF-8 | 73 | 2.984375 | 3 | [] | no_license | num=int(input('nhap 1 so: '))
for i in range(num):
print(i, end=' ')
| true |
aa760691e781381e79d2834bf33012b93c41e6ef | Python | CodeBunny09/Codewars-Writeups | /greed_is_good.py | UTF-8 | 2,100 | 4.5 | 4 | [] | no_license | """
Question:
Greed is a dice game played with five six-sided dice. Your mission, should you choose to accept it, is to score a throw according to these rules. You will always be given an array with five six-sided dice values.
Three 1's => 1000 points
Three 6's => 600 points
Three 5's => 500 points
Three 4's => ... | true |
56f478793b5815232b12e6166867c6ca8f500666 | Python | muhammadskhattak/image_recognition | /my_digits.py | UTF-8 | 1,292 | 3.484375 | 3 | [] | no_license | """ Muhammad Khattak
2018-04-12
Version 1.0
"""
from typing import Tuple, List
from vector import Vector
import csv, random, math
import numpy as np
class Network:
def __init__(self, sizes: List[int]) -> None:
""" Create a new network with layers of the specified size."""
self.... | true |
09407621cc24ef05ad58c0cc2f6e9c806ebbc3f6 | Python | akshay2742/Coding-Problems | /Coding/python/fastPow.py | UTF-8 | 356 | 3.4375 | 3 | [] | no_license | def fastPow(a,b):
result=1
while b:
if(b&1):
result=(result*a)%1000000007
a=a*a%1000000007
b>>=1
return result%1000000007
def main():
t=raw_input()
t=int(t)
while(t):
a=raw_input().split()
print(fastPow(int(a[0]),int(a[1]))... | true |
072bc7e516766f9307228a362a3cdfc058e546a0 | Python | Arusharma/FailureTimePrediction | /flask/auto_arima.py | UTF-8 | 4,918 | 3.0625 | 3 | [] | no_license | #Before implementing ARIMA, you need to make the series stationary, and determine the values of p and q
#using the plots we discussed above. Auto ARIMA makes this task really simple for us as it eliminates
#Making series stationary,determining the values of p,d,q and creating the ACF and PACF plots.
import panda... | true |
6e41313e182748e28682667da26852f683e12649 | Python | VachelHU/HEBR | /data_factory/dataloader.py | UTF-8 | 1,587 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
import numpy as np
class BatchLoader():
def __init__(self, batch_size):
self.batch_size = batch_size
self.x = None
self.y = None
self.pointer = 0
self.num_batch = 0
# Shuffle the data
def Shuffle(self, datalength):
shuffle_indices ... | true |
1677a8e61f41b92b08fa77df9d3dff473c8b7023 | Python | Manas2909/Python-Stuff | /re7.py | UTF-8 | 454 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 21 12:22:05 2019
@author: Manas
"""
import re
print(re.sub('ub', '~*' , 'Subject has Uber booked already', flags = re.IGNORECASE))
print(re.sub('ub', '~*' , 'Subject has Uber booked already'))
print(re.sub('ub', '~*' , 'Subject has Uber bo... | true |
ee4eb48a5f1f4020236396a1a40f1c83a0610eb7 | Python | edyarm/pokemonapi | /apps/evolution/serializers.py | UTF-8 | 772 | 2.515625 | 3 | [] | no_license | from rest_framework import serializers
from .models import Pokemon, Stat
class StatSerializer(serializers.ModelSerializer):
class Meta:
model = Stat
fields = ('name', 'effort', 'base_stat')
ordering = ('name', 'effort', 'base_stat')
class EvolutonSerializer(serializers.BaseSerializer):
... | true |
6b1469ae527b4df3694f8521fcca1d7d9bb0238d | Python | thelastdark99/becasdigitalizadas2020 | /Script-RouterCSR1000V/NO_ES_NECESARIO_VER/Delete_Interfaces_Restconf.py | UTF-8 | 927 | 3.140625 | 3 | [] | no_license | #Importamos los modulos para realizar consultas http (request) y el modulo para convertirlo a formato json(json)
import requests,urllib3
#Quitamos las advertencias SSL
urllib3.disable_warnings()
while True:
interfaz=int(input("Indica el numero de interfaz que desea borrar: "))
URL="https://192.168.1.202/r... | true |
c9ef23b64f83d39665ccf7579c6c22ff556fb75d | Python | pereirfe/Osciloscope | /gpio.py | UTF-8 | 298 | 2.78125 | 3 | [] | no_license | import RPi.GPIO as GPIO
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
last = 0
act = 1
while True:
sys.stdout.flush()
act = GPIO.input(23)
if(act<>last):
if(act == 1):
sys.stdout.write('*')
last = 1
else:
sys.stdout.write('_')
last = 0
| true |
04e66e4ce10ae4663e2c81fbea4a34494a487eb3 | Python | ZhihaoZhu/Advanced-Neural-Networks-for-Recognition | /python/run_q5.py | UTF-8 | 3,635 | 2.875 | 3 | [] | no_license | import numpy as np
import scipy.io
from nn import *
from collections import Counter
train_data = scipy.io.loadmat('../data/nist36_train.mat')
valid_data = scipy.io.loadmat('../data/nist36_valid.mat')
# we don't need labels now!
train_x = train_data['train_data']
valid_x = valid_data['valid_data']
print(valid_x.shape)... | true |
0d979c0d8efed38b53991316096e8546d874603d | Python | Dking155/1codesAndOthrStuff | /stringsAndThings.py | UTF-8 | 1,282 | 4.375 | 4 | [] | no_license | # strings
# data that falls within" " marks
# Concatenation
# Put 2 or more strings together
firstname = "Fred"
lastname = "Flintstone"
fullname = firstname + " " + lastname
print(fullname)
# Repetition
# repetition operator: *
print("Hip " * 2 + "Hooray!")
def rowyourboat():
print("Row, " * 3 + 'your boat... | true |
26a538aa45b1e929b1d5e37fe8a4ea2c4cbff33b | Python | mahmoudheshmat/DS_py | /treetraverse.py | UTF-8 | 771 | 3.21875 | 3 | [] | no_license | import operator
from BinaryTree import BinaryTree
def preorder(tree):
if tree:
print(tree.getRootVal())
preorder(tree.getLeftChild())
preorder(tree.getRightChild())
def postorder(tree):
if tree != None:
postorder(tree.getLeftChild())
postorder(tree.getRightChild())
print(tree.getRootVal())
def postorde... | true |
4231ea733aa1b81f59c519b3e3571107a8705610 | Python | pizza2u/Python | /exemplos_basicos/python/nome.py | UTF-8 | 151 | 3.953125 | 4 | [] | no_license | nome = input("Seu nome: ")
sobrenome = input("Sobrenome: ")
print('Oi {} {}'.format(nome,sobrenome))
print('BY: {1}, {0}'.format(nome, sobrenome)) | true |
7ca1f4a38fa6fcd8b510b40343440bcf48065cb5 | Python | j-vent/data-collector | /colour_detection.py | UTF-8 | 5,420 | 2.765625 | 3 | [] | no_license | import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
# TODO: maybe make into a class ...
def find_element_centroid(img, colour, coord):
y,x = np.where(np.all(img == colour, axis=2))
pairs = []
for i in range(len(x)):
pairs.append([x[i],y[i]])
if(len(x) != 0 and len(y) !... | true |
7a2b03a12f22ac1b3bc1d2760c7a08e1a9c43129 | Python | dpmittal/competitive_programming | /codechef/FEB19B/p2.py | UTF-8 | 330 | 3.28125 | 3 | [] | no_license | from math import floor
itr = int(input())
for i in range(itr):
l = int(input())
s = set(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
for j in range(l):
k = set(list(input()))
s = s.intersection(k)
prin... | true |
6ec2e21e277acd0b18a98c0bb6b120301b71838f | Python | millu94/joshuas_weekend_hw_01 | /src/pet_shop.py | UTF-8 | 2,182 | 3.359375 | 3 | [] | no_license | # WRITE YOUR FUNCTIONS HERE
import pdb
#1 find the name of the pet shop
def get_pet_shop_name(pet_shop_info):
name = pet_shop_info["name"]
return name
#2 find the total cash
def get_total_cash(pet_shop_info):
total_cash = pet_shop_info["admin"]["total_cash"]
return total_cash
#3 + #4 add or remove ca... | true |
69ebca76491b013f7cc0864d9a95741ea0bf8e52 | Python | bmazey/python_nlp | /application.py | UTF-8 | 663 | 2.53125 | 3 | [
"MIT"
] | permissive | from flask import Flask
from flask_restplus import Resource, Api
# welcome to flask: http://flask.pocoo.org/
# working with sqlalchemy & swagger:
# http://michal.karzynski.pl/blog/2016/06/19/building-beautiful-restful-apis-using-flask-swagger-ui-flask-restplus/
application = Flask(__name__)
api = Api(application)
@... | true |
485d904036f1cc3b029c4aa6b5d2d3eb06283c82 | Python | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/word-count/d09d149ca1254da2b70cfb25d74f2a6c.py | UTF-8 | 609 | 3.0625 | 3 | [] | no_license | '''
The solution that I am posting is not own.
I found two different solutions that work
and I am putting them here.
Solution A belongs to @mnorbury and @ThomasZumsteg
I have read about the Counter container and I
understand how to use it.
http://pymotw.com/2/collections/counter.html
Solution B belongs to @abeger
... | true |
9104fce2fb76e5a9d773f6b8c9b73161bd1f2789 | Python | MakingMexico/CursoPythonArduino | /functions/functions.py | UTF-8 | 200 | 3.875 | 4 | [] | no_license | def suma(a, b):
return a + b
def suma_tres(a, b=3):
return a + b
"""a = float(input("Ingrese el primer valor: "))
b = float(input("Ingrese el segundo valor: "))
print(suma_tres(a, b))"""
| true |
243206e5626df72107475e9e319bca9113f54b0b | Python | deefunkt/machineLearning | /stockPrediction/sentiment analysis.py | UTF-8 | 5,741 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 17 13:18:37 2019
@author: A-Sha
"""
import time
import datetime as dt
import pandas as pd
from glob import glob
import re
import matplotlib.pyplot as plt
from matplotlib import style
import matplotlib.dates as mdates
from textblob import TextBlob
########################... | true |
4628f6d0b37eacf721feb709def060abbf461f38 | Python | sagasurvey/saga | /SAGA/objects/calc_sfr.py | UTF-8 | 2,172 | 2.609375 | 3 | [
"MIT"
] | permissive | """
From Marla 03/07/2023
"""
import numpy as np
__all__ = ["calc_SFR_NUV", "calc_SFR_Halpha"]
def calc_SFR_NUV(NUV_mag, NUV_mag_err, dist_mpc, internal_ext=0.7):
"""
Convert NUV magnitudes into a SFR
Based on Iglesias-Paramo (2006), Eq 3
https://ui.adsabs.harvard.edu/abs/2006ApJS..164...38I/abstract... | true |
c7b48a6ec3999d13d2be31e375df37cc1fad636a | Python | enricozf/energy-consumption-forecast | /Code/utils/metrics.py | UTF-8 | 3,387 | 3.109375 | 3 | [] | no_license | import numpy as np
import pandas as pd
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
from tensorflow.keras.losses import MeanSquaredError, MeanAbsoluteError
def last_timestep_mse(y_true, y_pred):
return MeanSquaredError()(y_true[:,-1,:], y_pred[:,-1,:])
def last_timestep_mae(y_true... | true |
839a9170eb8104469a4ead50abbf36e78d1b5a5d | Python | podhmo/individual-sandbox | /daily/20171123/example_dict/00rounddict.py | UTF-8 | 735 | 3.625 | 4 | [] | no_license | # https://stackoverflow.com/questions/32434112/round-off-floating-point-values-in-dict
# My dictionary is:
d = [
{
'A': 0.700000000,
'B': 0.255555555
}, {
'B': 0.55555555,
'C': 0.55555555
}, {
'A': 0.255555555,
'B': 0.210000000,
'C': 0.2400000000
... | true |
2448128db6b2e2ff2f8b3e4ed2fe21e2520672a3 | Python | mbgarciaarcija/python-_- | /ejercicios/clase5/funciones/filtrar.py | UTF-8 | 1,659 | 3.0625 | 3 | [] | no_license | import unicodedata
from functools import reduce
from Levenshtein import ratio
def to_canonico(string):
return ''.join((c for c in unicodedata.normalize('NFD', string.lower()) if unicodedata.category(c) != 'Mn'))
def inicio_func(anio):
def _inicio(reg):
return reg.anio >= anio
return _inicio
def ... | true |
3b9d120fff0f03080cf08f424cee9da3d24a108a | Python | lukaszgolojuch/Obliczanie-diety-python-obiektowo | /main.py | UTF-8 | 9,972 | 3.78125 | 4 | [] | no_license |
#------------------------------------------------------
# Nazwa programu: Obliczanie diety
# Jezyk programowania: Python
# Srodowisko programistyczne: Visual Studio Code
#
# Autor: Lukasz Golojuch
#------------------------------------------------------
class User:
#inicjacja zmiennych
imie = ""
wiek ... | true |
c51f829cd988670d04fb481a7934e05fffe740c4 | Python | Carlisle345748/leetcode | /136.只出现一次的数字.py | UTF-8 | 2,232 | 3.90625 | 4 | [] | no_license | import time
from functools import reduce
class Solution1:
def singleNumber(self, nums: list) -> int:
"""
用hash-table记录每个数字出现的次数,最后遍历一次hash-table找到只出现一次的数字
"""
memo = {}
for i in nums:
if i not in memo:
memo[i] = 1
elif memo[i] == 1:
... | true |
7b766ed15f7c64a21ddc0896ca1bc514d6e0b0b3 | Python | amalsom10/datastructure | /class/related_objects_in_multiple_classes.py | UTF-8 | 1,448 | 3.671875 | 4 | [] | no_license | class Students:
def __init__(self, name, classdivision, rollnumber):
self.name = name
self.classdivision = classdivision
self.rollnumber = rollnumber
def studentdetails(self):
print ("------------\nStudent info\n----------------\nName: {}\nclassdivision: {}\nrollnumber: {}". for... | true |
2734d14a79e2d80e7b234d6079c82a63a021c00a | Python | Dhawgupta/RLDS | /svm/nn.py | UTF-8 | 4,578 | 2.515625 | 3 | [
"MIT"
] | permissive | import numpy
import pandas
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD, Adam, RMSprop
from keras.utils import np_utils
from keras.wrappers.scikit_learn import KerasClassifier
from sklea... | true |
7f8e8b70a608ece78b08e695fdd50ca27c613cb4 | Python | rahaahmadi/LinearAlgebra-Projects | /Least Squares - Denoising/LeastSquares.py | UTF-8 | 739 | 2.953125 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
data = np.load('btc_price.npy')
plt.plot(data)
plt.show()
y = data.reshape(data.size, 1)
D = np.zeros(((data.size - 1), data.size))
for i in range(D.shape[0]):
D[i][i] = 1
D[i][i + 1] = -1
def denoise(D, y, lambdaa):
x = np.linalg.inv(np.ey... | true |
ea6f2316aa9f6c25177fc013b6171db3e75ee509 | Python | ColinWilder/pythonBasics | /slicing-practice-2.py | UTF-8 | 108 | 2.578125 | 3 | [] | no_license | lr=("r","t","ch","tv","db","sf")
apt=[]
apt.extend(lr)
first_thing=apt.pop(0)
print(apt)
print(first_thing)
| true |
5a7359ccbe6e28afb732dba348ca0b8971c98c26 | Python | vertica/vertica-python | /vertica_python/tests/integration_tests/test_transfer_format.py | UTF-8 | 5,411 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Copyright (c) 2022-2023 Open Text.
#
# 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 wr... | true |
31f13150b08a2359df0c747c8d967e127f3fe76e | Python | aKarm1905/PythonMSC | /samples/make2dparameters.py | UTF-8 | 1,177 | 2.953125 | 3 | [] | no_license | # coding=utf-8
"""Butterfly make2d Parameters.
Parameters to convert a 3d OpenFOAM case to 2d.
"""
from copy import deepcopy
# TODO(): Add check for input values.
class Make2dParameters(object):
"""Make2d parameters.
Attributes:
origin: Plane origin as (x, y, z).
normal: Plane ... | true |
221f241b5286c0372420bed8108a3d8c340f11c6 | Python | P1ping/mass-dataset | /scripts/clean-raw-txt.py | UTF-8 | 1,685 | 3.015625 | 3 | [
"MIT"
] | permissive | import sys, codecs, glob
def clean_punct(line):
punctuation_swap = [ ('“', '"'),
('”', '"'),
('’', ' '),
('“', '"'),
('‘', ' ')
]
for pct_b, pct_a in punctu... | true |
a879d9ef4e83ae4c1591ba189d256a071ec2bbe2 | Python | sunjerry019/adventOfCode | /2018/day_11/11_2.py | UTF-8 | 1,193 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import numpy as np
gridID = 6303
#gridID = 7672
#gridID = 18
powerLevel = np.zeros((301,301), dtype=int)
pLNxN = np.zeros((301,301,301), dtype=int)
# the coordinates need to be 1-indexed
def getPL(X, Y):
rackID = (X + 10)
return int(((((rackID * Y) + gridID) * rackID)/100)%10) - 5
f... | true |
27eafe6643b7f7d957454b2c66e485fc22e509a0 | Python | MatanelAbayof/Wikishield | /wiki_api/base_api.py | UTF-8 | 1,436 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | import time
from abc import ABC
import requests
from requests import ConnectionError
class BaseApi(ABC):
"""
this is a generic class with helpful functions for API
"""
_MAX_TRIES = 10
_TIMEOUT = 40
_SLEEP_COEFFICIENT = 5
def __init__(self):
"""
initialize the class
... | true |
dcd35c87aac8dd8c740dd0b87d8a38b2294078e0 | Python | geohotweb/programing | /ecuaciones/segu_primer_grado.py | UTF-8 | 658 | 4.125 | 4 | [] | no_license | #Programa para la resolucion de dos tipos de ecuacuiones, una de primer grado y otra de segundo grado.
from math import sqrt
print('Programa para la resolucion de la ecuacion a x*x + b x + c= 0.')
a = float(input('Valor de a: '))
b = float(input('Valor de b: '))
c = float(input('Valor de c: '))
if a == 0:
if b == ... | true |
631b85bfc933cbc682f7a6446d9ec915f4831b44 | Python | burevol/wow_discord_news | /wd_generators.py | UTF-8 | 3,822 | 2.734375 | 3 | [] | no_license | import requests
class WowData():
def __init__(self, cf):
self.cf = cf
self.token = None
if cf.auth_mode == 'oauth2':
path_oauth = 'https://us.battle.net/oauth/token?grant_type=client_credentials' \
'&client_id=%s&client_secret=%s' % (cf.client_id,cf.cli... | true |