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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
08aac6b57fa3e93a18d35461f93ee7bf95e5ec62 | Python | bcrafton/muri | /logistic_regression/collect_results.py | UTF-8 | 1,955 | 2.5625 | 3 | [] | no_license |
import numpy as np
import os
import threading
################################################
epochs = [10]
alphas = [0.0005] # alphas = [0.0005, 0.001, 0.005]
scales = [2., 4., 8., 16., 32.]
lows = np.linspace(0.005, 0.1, 10)
pcas = [100, 150, 200, 250, 300, 350, 400]
#############################################... | true |
debbb7da2bc9a79a3ac7c1ce7fccaa5921cbed3e | Python | ihalage/MetaZero | /test.py | UTF-8 | 1,582 | 2.75 | 3 | [] | no_license | import numpy as np
import pandas as pd
# width = 8
# height = 8
# # print("{0:4}".format(''), end='')
# # for x in range(width):
# # print("{0:8}".format(x), end='')
# # print('\r\n')
# # for i in range(height - 1, -1, -1):
# # print("{0:4d}".format(i), end='')
# # for j in range(width):
# # # print("{0:8}".forma... | true |
370a3441ea42408c58ad23142162ae16fd80cd10 | Python | werobot-france/eurobot2020-red | /driver/src/WebsocketManager.py | UTF-8 | 2,820 | 2.515625 | 3 | [] | no_license | from threading import Thread
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from bottle import request, Bottle, abort
from geventwebsocket import WebSocketServer, WebSocketApplication, Resource, WebSocketError
from collections import OrderedDict
import json
class InputExecuto... | true |
a95452ad639708b003b983f3a26dd525eae89e1b | Python | mayorhao/EMG-open-dataset-deeplearning | /prepare_data/gen_stft_samples.py | UTF-8 | 3,290 | 2.515625 | 3 | [] | no_license | # prepare training data for CNN models
# step 1: data downsampling, from 2048 hz to 1024 hz
# step 2: data segmentation: signals were split to segmentations of 200 ms with 50% overlap
# step 3: save training data, orgnized as subj/session/sample, each sample was reshaped as time_points *16 * 16
import numpy as np
impor... | true |
73d3f4c9ce38480fb8ff0491b2c3460bc1ba62d1 | Python | FlyBoy8869/LWTest | /LWTest/common/flags/flags.py | UTF-8 | 1,577 | 2.78125 | 3 | [] | no_license | from dataclasses import dataclass
import functools
from enum import Enum
from typing import List, Optional
class FlagsEnum(Enum):
SERIALS: str = "serials"
ADVANCED: str = "advanced"
CALIBRATE: str = "calibrate"
CORRECTION: str = "correction"
def __eq__(self, other):
assert type(other) == ... | true |
030d0700843e5d738c4681da0095eff95de73d1a | Python | way2arun/datastructures_algorithms | /src/arrays/wordSubsets.py | UTF-8 | 2,940 | 4.09375 | 4 | [
"CC0-1.0"
] | permissive | """
Word Subsets
We are given two arrays A and B of words. Each word is a string of lowercase letters.
Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity. For example, "wrr" is a subset of "warrior", but is not a subset of "world".
Now say a word a from A is universa... | true |
d3c13043693d7ba7fa2cf14fab4928c1cefc04cc | Python | phmduytin/PythonStart | /Control Structure/IfThenElse.py | UTF-8 | 351 | 3.828125 | 4 | [] | no_license | for i in range(0, 10):
if i % 2 == 0:
print(i, end=', ')
print()
workday = ['Monday', 'Tuesday', 'Wednesday', 'Thusday', 'Friday']
weekend = ['Saturday', 'Sunday']
holiday = ['30/04', '01/05', '02/09']
day = 'Monday'
date = '30/05'
if day in weekend or date in holiday:
print('Let\'s fun')
else:
... | true |
c6c2072d345892a1cdcdd0dd4f98bec468104447 | Python | clinestanford/scientific_computing | /notes/lec07/py/approx_slopes.py | UTF-8 | 1,103 | 4.25 | 4 | [] | no_license | #!/usr/bin/python
#################################################
# module: approx_slopes.py
# description: approximating slopes of
# various exponential functions on slides 15-17, 20.
# bugs to vladimir kulyukin via canvas.
#################################################
import math
def slope_of_b_to_x(b):
fo... | true |
c2cff0ac52efe26bfa944a626fea923d0524091d | Python | wwwwodddd/Zukunft | /PE/115.py | UTF-8 | 143 | 2.921875 | 3 | [] | no_license | f=[0]*220
f[0]=1
for i in range(1,200):
f[i]=f[i-1]
for j in range(51,i+1):
f[i]+=f[i-j]
if f[i]>=10**6:
print i-1
break
| true |
72a1433327bbcb589b84425c37986cb37c8a5f12 | Python | Digit112/Colors | /sinWalk.py | UTF-8 | 1,826 | 2.9375 | 3 | [] | no_license | import sys
import time
import os
import random
import math
def regulate(tup):
lis = list(tup)
for i in range(0, len(tup)):
if lis[i] > 255:
lis[i] = 255
elif lis[i] < 0:
lis[i] = 0
return tuple(lis)
sta = 145
mod = 4
if len(sys.argv) > 1:
if sys.argv[1] == "help" or sys.argv[1] == "-help" or sys.argv[1]... | true |
a432c988204b55d505833f684160b6333b0a1660 | Python | Wing-ka-king/ModelPredictiveControl | /Assignments/Assignment3/dlqr.py | UTF-8 | 5,187 | 2.890625 | 3 | [] | no_license | import casadi as ca
import numpy as np
import scipy.linalg
from control.matlab import lqr
class DLQR(object):
def __init__(self, A, B, C,
Q=ca.DM.eye(4), R=ca.DM.ones(1,1)):
"""
Discrete-time LQR class.
"""
# System matrices
self.A = A
self.... | true |
873ff5a3d4d47244898e1797f224a7c9861155de | Python | garvit97/data-preprocessing | /cleanweb.py | UTF-8 | 1,097 | 2.921875 | 3 | [] | no_license | import nltk
from nltk.tokenize import word_tokenize
import sys
reload(sys)
sys.setdefaultencoding('utf8')
filename=sys.argv[1]#raw_input("Enter filename: ")
outFileName=sys.argv[2]
f2=open(str(filename),'r')
f3=open(str(outFileName),'w')
for line in f2:
t=word_tokenize(str(line))
for i in range(len(t)):
f3.write... | true |
b8ec25908cd4cdb2325843aadacc936187a1b019 | Python | clarencejh/copy_fisher | /app/libs/helper.py | UTF-8 | 450 | 3.28125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
def is_isbn_or_key(word):
"""isbn
13
个0 - 9
的数字组成
也有
10
个数字组成的, 中间包含
'-'
字符
"""
isbn_or_key = 'key'
if len(word) == 13 and word.isdigit():
isbn_or_key = 'isbn'
short_q = word.replace('-', '')
if '-' in word and len(sho... | true |
0e8602a8c38f230a47bc2306a12b8b324e8303a3 | Python | clubofcodes/python_codes | /Ass 3.6 Operation using Pandas/TempValues.py | UTF-8 | 141 | 3.046875 | 3 | [] | no_license | import pandas as pd
df=pd.read_csv('forestfires.csv')
month = df['month']=='oct'
print("Temp values of oct month :\n",df.loc[month,['temp']]) | true |
7926bb32974ccddc4b8b11a1205601c53981fce3 | Python | dev7hka/HUPROG-studies | /week2/RemoveAdjacentDuplicates.py | UTF-8 | 1,053 | 3.828125 | 4 | [] | no_license | class Stack: # array-based stack
def __init__(self):
self.lis = []
self.top = 0
def push(self, item):
self.lis.append(item)
self.top += 1
def pop(self):
if self.top == 0:
return None
item = self.lis.pop()
self.top -=1
return item... | true |
38e2cae0ad890f58f725f255deb1b55481ab00a5 | Python | deep-in-the-pc/Monitoring_Interface_Pavnext | /GUI/MIP_GUI.py | UTF-8 | 7,438 | 2.53125 | 3 | [] | no_license | #for serial comms
import serial.tools.list_ports
import serial
import sys
from time import sleep
from util import *
from math import ceil
#for UI
from PyQt5 import QtWidgets, QtGui, QtCore
from gui.MI_GUI_01 import Ui_MainWindow
#for plots
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanva... | true |
72e7ac197bef8defa5657cbcb412c0aba9bdea52 | Python | talentlei/leetcode | /python/111-120/Path Sum.py | UTF-8 | 633 | 3.15625 | 3 | [] | no_license | # @param root, a tree node
# @param sum, an integer
# @return a boolean
def hasPathSum(self, root, sum):
if root==None:
return False
if root.left==None and root.right==None:
if sum==root.val:
return True
else:
return Fal... | true |
d8340273f3a5edd3f1669d7355e067b5199aa6a3 | Python | Hau-Hau/tntd | /src/tntd/src/main/boilerplate_mixins/hash_mixin.py | UTF-8 | 103 | 2.65625 | 3 | [] | no_license | class HashMixin:
def __hash__(self) -> int:
return hash(tuple(sorted(vars(self).items())))
| true |
9b93aab89a0834e706b67d7892d061fef9e7a92e | Python | phyokolwin/pythonworkshop | /01/01E18.py | UTF-8 | 369 | 4.28125 | 4 | [] | no_license | print('Enter a number to see if it\'s a perfect square.')
number = input()
number = eval(number)
square = False
i = -1
while number >= 0 and number%1 ==0 and i <= number**(0.5) :
i += 1
if i*i == number:
square = True
break
if square:
print('The square root of', number, 'is', i, '.')
else:
... | true |
c5c92734db9d2327563feb02f1d395dcac565cb5 | Python | PKhuang-TW/NCTU_Computer-Vision | /HW2/code/Colorizing the Russian Empire/pyramid_colorize.py | UTF-8 | 2,725 | 2.953125 | 3 | [] | no_license | import numpy as np
import cv2
import matplotlib.pyplot as plt
from utils import *
def pyramid_colorize(img, show=True):
# compute the height of each channel of image (1/3 of total height)
height = int(np.floor(img.shape[0] / 3.0))
if show:
print("img shape", img.shape)
print('he... | true |
9d48a1c58c6f86b1ae26c6679396e1b65fda718a | Python | aod1310/DataMiningTermp2 | /test.py | UTF-8 | 796 | 2.65625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import os
import pickle
from apyori import apriori
import time
path = './ml-25m/'
# data cleaning
import pickle
with open('rating_movie_mapping_cleaning.data', 'rb') as f:
data = pickle.load(f)
data = data.drop(data.loc[data['is_provocative']==-1].index, axis=0)
... | true |
5d9f2bdb8bf830697999431042c282d5f41354ba | Python | klintan/ros2_rotary_encoder | /src/rotary_encoder_driver/driver.py | UTF-8 | 2,328 | 2.671875 | 3 | [
"MIT"
] | permissive | import re
import sys
import serial
import rclpy
from rclpy.node import Node
from std_msgs.msg import Int32
class RotaryEncoderDriver(Node):
def __init__(self):
super().__init__('rotary_encoder_driver')
self.left_tick = self.create_publisher(Int32, 'wheel_left_tick', 50)
self.right_tick =... | true |
09333444b003d4a1a22fa13ca28ee9e7d40b0401 | Python | emplam27/Python-Algorithm | /백준/백준_17406_배열돌리기4.py | UTF-8 | 1,617 | 2.984375 | 3 | [] | no_license | import sys
sys.stdin = open('input.txt', 'r')
from itertools import permutations
def rotate(board, n, m, k):
for i in range(1, k + 1):
# 배열 가져오기
r, c, d = (n - 1) - i, (m - 1) - i, 0
numbers = []
while len(numbers) < 8*i:
numbers.append(board[r][c])
if r... | true |
a4b04dcbfd1d84821f42f6da3acfa6bd85780a50 | Python | rajat1994/AlzheimersML | /ridge/alpha_ridge.py | UTF-8 | 994 | 3.265625 | 3 | [] | no_license | #!/usr/local/bin/python
import sys
import csv
from sklearn import linear_model
from sklearn import grid_search
def frange(x, y, jump):
while x < y:
yield x
x += jump
# open the training data and read into arrays
f = open(sys.argv[1], 'rt')
data_rows = csv.reader(f)
x_values = []
y_values = []
for i,row in e... | true |
c4e36b86b737459d20cca7fe79b87dab9083aa75 | Python | rronakk/Python-3-exercies | /ATBSWP/randomQuizGenerator.py | UTF-8 | 1,852 | 3.8125 | 4 | [] | no_license | """
Create a 35 different quizzes
Create 50 multiple choice quesrions for each quiz
Provide 1 correct answer, and 3 incorrect answer for each question in random order.
Write quiz in 35 test files.
Write answer keys to 35 test files
"""
import random
capitals = {
'Alabama': 'Montgomery', 'Montana': 'Helena',
'... | true |
296b86ba300df68aeea2ca84e05154d031a389fd | Python | yoonah95/Python_practice | /python8/ex09.py | UTF-8 | 199 | 2.9375 | 3 | [] | no_license |
import StringIO
s = '''
Python is a cool little language,
It is well designed,compact,easy to learn and fun to program in.
Python strongly
'''
f = StringIO.StringIO(s)
print(f.read().upper())
| true |
af1ac933f61af3785b628a32dffb6e864c159c7c | Python | nk-shruti/handwriting_calculator | /draw.py | UTF-8 | 910 | 2.84375 | 3 | [] | no_license | import cv2
import numpy as np
drawing = False
ix,iy = -1,-1
def draw_circle(event,x,y,flags,param):
global ix,iy,drawing,mode,px,py
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
ix,iy = x,y
px,py=x,y
elif event == cv2.EVENT_MOUSEMOVE:
if drawing == True:
c... | true |
5893e87dac602a7ad6a45b712df0e1a325d7ff2d | Python | lixing0810/SeqMRI | /activemri/baselines/loupe_codes/reconstructors.py | UTF-8 | 4,323 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """
Portion of this code is from fastmri(https://github.com/facebookresearch/fastMRI)
Copyright (c) Facebook, Inc. and its affiliates.
Licensed under the MIT License.
"""
import torch
from torch import nn
from torch.nn import functional as F
from activemri.baselines.loupe_codes.transforms import *
from activemri.ba... | true |
390b3e6878a3f05dbe61381fd2d1fcfc124ab6f3 | Python | daniel-s-ingram/full_stack_foundations | /Lesson2/restaurant_web_server.py | UTF-8 | 6,530 | 2.578125 | 3 | [] | no_license | import cgi
from http.server import BaseHTTPRequestHandler, HTTPServer
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from db.database_setup import Base, Restaurant, MenuItem
class WebServerHandler(BaseHTTPRequestHandler):
edit_html = b"""
<form method='POST' enctype='multipart... | true |
ee23bd7354c1d9253b3cb685bcbaf88abcb19712 | Python | ScottSko/Python---Pearson---Third-Edition---Chapter-5 | /Random Number Functions.py | UTF-8 | 195 | 2.78125 | 3 | [] | no_license | import random
rand = random.randrange(0, 1)
rand_2 = random.randint(0, 1)
rand_3 = random.random()
rand_4 = random.uniform(0, 10)
print(rand)
print(rand_2)
print(rand_3)
print(rand_4) | true |
9f434dbd82b10be0efc632170f8c85489659ab41 | Python | weizhixiaoyi/leetcode | /nowcoder/company/0831-58/02.py | UTF-8 | 317 | 3.3125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
def solve(a, b):
square = [i * i for i in range(1, 501)]
for i in range(1, 501):
if i + a in square and i + b in square:
return i
if __name__ == '__main__':
line = input().split(',')
a, b = int(line[0]), int(line[1])
ans = solve(a, b)
print(ans)
| true |
f8500747868264ae1320295728ff9f5348faafbf | Python | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/paul_jurek/lesson10/Donor.py | UTF-8 | 2,270 | 3.375 | 3 | [] | no_license | """donor class controlling donor behavior"""
from collections import namedtuple
import datetime
Donation = namedtuple('Donation', ['amount', 'date', 'id'])
# TODO: add email validation https://www.pythoncentral.io/how-to-validate-an-email-address-using-python/
class Donor:
"""donor giving to organization"""
... | true |
597bda14535fb4739fcbc2b16ba74a3c98d35726 | Python | albertestevan/GarudaHacks-mobile-app | /backend/api/randomizer.py | UTF-8 | 213 | 2.515625 | 3 | [] | no_license | from base64 import b32encode
from hashlib import sha1
from random import randint
def pkgen():
first = str(randint(100, 999))
second = str(randint(1000, 9999))
pk = first + '-' + second
return pk | true |
b08f22396205ba502bb74a8668a8ad3e574d43f2 | Python | marco-buttu/pybook2nd | /ch12/myfile_01.py | UTF-8 | 217 | 3.03125 | 3 | [] | no_license | # Commento che precede la definizione della funzione
def myfunc(a, b, c=10, *varargs, d=99, **kwargs):
"""Fai qualcosa di apparentemente poco utile..."""
print(e) # Stampa l'etichetta libera e
f = [1, 2]
| true |
226c15239441a446628e38d757c63e160dc05ae1 | Python | xgrau/rdl-Agam-evolution | /scripts_hapclust/zcache.py | UTF-8 | 7,210 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
import itertools
import operator
import hashlib
import pickle
import sys
import zarr
import numpy as np
def log(*msg):
"""Simple logging function that flushes immediately to stdout."""
s = ' '.join(map(str, msg))
pr... | true |
50ab696d311801c6c4b9b5fd99def81f5df19575 | Python | iontrapimperial2/XCon_02 | /library/f_image.py | UTF-8 | 593 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 30 22:59:35 2016
@author: JohannesMHeinrich
"""
import matplotlib.pyplot as plt
from PIL import Image
def get_image(file_name):
fig_01 = plt.figure()
fig_01.patch.set_facecolor('white')
fig_01.patch.set_alpha(0)
ax = fig... | true |
03bacd7edda4d43a3f28a56fde6779e2282a0d5e | Python | dayalaPal/Unidad-4 | /Real Applications_git/4_-_Python_and_Tkinter/PY_LotteryNumbers.py | UTF-8 | 2,346 | 3.1875 | 3 | [] | no_license | """Autores: David Alejandro Ayala Palacios, Efren Santiago Landeros"""
"""Descripccion: se muestra un generador de números de lotería"""
import random
from tkinter import *
def Lotto_No():
x = random.randint(1, 49);
q = random.randint(1, 49);
w = random.randint(1, 49);
e = random.randint(1,... | true |
c9785e706f5de5078a5fe1097fdbc102e1f97a00 | Python | warelle/rdft | /givens.py | UTF-8 | 1,030 | 2.6875 | 3 | [] | no_license | #coding: UTF-8
import math
import cmath
import random
import scipy.linalg as slinalg
import numpy.linalg as linalg
import numpy as np
import lu
#------------------------------------
# function definition
#------------------------------------
def one_givens_rotation(size,i,j,theta):
r = np.identity(size, dtype=np.... | true |
5773a6bc6f2c4404548d622ec6df960f44561f52 | Python | jmery24/python | /ippython/matrices_creacion_1.py | UTF-8 | 329 | 3.453125 | 3 | [] | no_license | # programa: matrices_creacion_1.py
# dos maneras de crear matrices
lista = [1, 2, 3]
print 'Lista: ', lista
matriz = [lista, lista]
print 'Matriz: ', matriz
lista[0] = 2
print 'Lista modificada: ', lista
print 'Matriz modificada: ', matriz
lista = [3]
print 'Lista version final: ', lista
print 'Matriz cersion final: '... | true |
7cf89f57862caca1097a41b4d8243d624ec91ade | Python | shen931205/caffeDL | /tools/python/getlabel.py | UTF-8 | 921 | 2.78125 | 3 | [] | no_license | '''
@author: Dean
2016-3-25
'''
import sys
import os
import argparse
##Get the argument from user.
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument(
'input_path',
help = 'the path of input file folders.'
)
parser.add_argument(
'output_file',
default = './output.txt',
help = 'the p... | true |
bb05bfc444a5a3f91491be55b7830dc840b11828 | Python | attacker-codeninja/tokenScanner | /tokenScanner.py | UTF-8 | 994 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python3
# Developer By Abdulrahman Kamel
# Github: github.com/Abdulrahman-Kamel
from colorama import Fore
from sys import stdin, exit , argv
from yaml import load, FullLoader
from re import match as match_re
arg_1 = argv[1] if len(argv) > 1 else 'empty'
def readYaml(file):
return load(open(file), Loade... | true |
420b72024e187c240b2fb75782d0ad4132b2b67d | Python | LiKevin/python | /working_relative/Property_03_ObjectAttributes.py | UTF-8 | 2,765 | 4.90625 | 5 | [] | no_license | # -*- coding: utf-8 -*-
"""
同一个对象的不同属性之间可能存在依赖关系。
当某个属性被修改时,我们希望依赖于该属性的其他属性也同时变化。
这时,我们不能通过__dict__的方式来静态的储存属性。Python提供了多种即时生成属性的方法。
其中一种称为特性(property)。特性是特殊的属性
"""
# example 1
"""
上面的num为一个数字,而neg为一个特性,用来表示数字的负数。当一个数字确定的时候,它的负数总是确定的;而当我们修改一个数的负数时,它本身的值也应该变化。
这两点由getNeg和setNeg来实现。而delNeg表示的是,如果删除特性neg,那么应该执行的操作是删除属性v... | true |
81265cd66d1104eb80a2cf178394f86ba5efe19c | Python | INNOMIGHT/searching-and-sorting | /Sorting/BubbleSort.py | UTF-8 | 312 | 3.65625 | 4 | [] | no_license | def bubble_sort(arr):
for numbers in range(len(arr)-1, 0, -1):
for times in range(numbers):
if arr[times] > arr[times + 1]:
tmp = arr[times]
arr[times] = arr[times + 1]
arr[times+1] = tmp
arr = [5, 4, 2, 7, 8]
bubble_sort(arr)
print(arr)
| true |
38fe16e7c9f21eee5ebab1f9f07cd9bfd4a61d22 | Python | PrideLee/img2tab-Chineses-character | /code/Option B/code&materials/table_analysis.py | UTF-8 | 25,161 | 2.578125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Analysis and recognize the table in the specific image.
Jan. 2020, CISSDATA, https://www.cissdata.com/
@author: Zihao Li <poderlee@outlook.com>
"""
import os
import img_obj
import cv2
import numpy as np
OUTPUTPATH = 'generated_output/'
DIRECTION_HORIZONTAL = 'h'
DIRECTIO... | true |
a7da1352107a3a3d511a39b22dfece7352b16af3 | Python | jbochi/sandals | /sandals/sandals.py | UTF-8 | 7,438 | 2.796875 | 3 | [
"MIT"
] | permissive | import sqlparse
import numpy as np
class STATES():
SELECT = 0
COLUMNS = 1
FROM = 2
TABLE = 3
GROUP = 4
ORDER = 5
LIMIT = 6
END = 7
def sql(query, tables):
statement = sqlparse.parse(query)[0]
state = STATES.SELECT
df = None
columns = None
functions = []
for ... | true |
d1cfb94104e52383a7ee4131a05a52bce33659d1 | Python | zbeck008/PyPractice | /CalcPi.py | UTF-8 | 658 | 3.5625 | 4 | [] | no_license | import math
import sys
def main(argv):
if len(argv) != 1:
sys.exit('Usage: calc_pi.py <n>')
print('\nComputing Pi v.01\n')
a = 1.0
b = 1.0 / math.sqrt(2)
t = 1.0 / 4.0
p = 1.0
for i in range(int(sys.argv[1])):
at = (a + b) / 2
bt = math.sqrt(a * b)
tt = t... | true |
09a7fc205c282a1e694a883f943d49afc5d409b3 | Python | ramalamadingdong/Drifitng-Autonomously-Torcs | /torcs-client-master/torcs-client-master/models/basicnetwork.py | UTF-8 | 4,250 | 2.796875 | 3 | [
"MIT"
] | permissive | from abc import abstractmethod
from typing import Callable
import json
import datetime
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
from torch.autograd import Variable
from torch.utils.data import DataLoader
from models.data import SteeringTrainingData, TrainingData
class Net(torch.n... | true |
82a4a499d1f3dde47c119acc307863284f25b906 | Python | bambrow/python-programming-notes | /io_basics/03_os.py | UTF-8 | 1,100 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python
# coding:utf-8
import os
import shutil
print(os.name) # posix: Linux, OS X, Unix; nt: windows
print(os.uname()) # detailed system information
print(os.environ) # environment variables
print(os.environ.get('PATH'))
print(os.path.abspath('.')) # absolute path
print(os.path.join(os.path.abspath('.... | true |
9b689ff737d85b91d5274ce1340b3a0d94038086 | Python | NataliaZar/lab6_django | /lab6/ex1.py | UTF-8 | 861 | 2.96875 | 3 | [] | no_license | import MySQLdb
#! Открытие соединение с базой данных
db = MySQLdb.connect(
host="localhost",
user="dbuser",
passwd="123",
db="lab_db"
)
db.set_character_set('utf8')
#! Получить курсор для работы с базой данных
c=db.cursor()
#! Выполнить вставку
c.execute("insert into prodact (prodact_nam... | true |
d7994c1220ca737ed9da81d696a833632f9fa3e6 | Python | rdrachenberg/hashing-funcs | /aes-test.py | UTF-8 | 524 | 2.828125 | 3 | [] | no_license | import pyaes, pbkdf2, binascii, os, secrets
plaintext = "Here is my super secret message!"
password = "ThisIsAnAwesomePassword"
key = pbkdf2.PBKDF2(password, 'some salt').read(16)
print('AES encryption key:', binascii.hexlify(key))
iv = secrets.randbelow(2 << 128)
aes = pyaes.AESModeOfOperationCTR(key, pyaes.Counter(... | true |
8fd96bba241ded1fb41526bbe4eca0d11ff723b7 | Python | deraj331/pdsnd_github | /Bikeshare_final.py | UTF-8 | 10,362 | 3.953125 | 4 | [] | no_license | def main():
import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
days_of_week = {0:'Sunday', 1:'Monday',
2:'Tuesday', 3:'Wednesday',
... | true |
ea2bafb00ff02bf8642f4a2db43a04b9554b894e | Python | Rafi993/Imdb-simple-movie-scraper | /imdbMovieScraper/spiders/imdbList.py | UTF-8 | 3,015 | 2.859375 | 3 | [
"MIT"
] | permissive | import scrapy
from bs4 import BeautifulSoup
import re
import csv
class Imdblist(scrapy.Spider):
name = "imdblist"
def start_requests(self):
urls = [
"http://www.imdb.com/list/ls053536561/"
]
for url in urls:
yield scrapy.Request(url=url, callback=self.... | true |
a5eb25969ec8b59f128b64790059552b6ae087ed | Python | shonihei/road-to-mastery | /leetcode/merge-sorted-array.py | UTF-8 | 635 | 3.859375 | 4 | [] | no_license | """
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively.
"""
def mer... | true |
98bdfc839d8439b5fa20a013f28436119fdd0a10 | Python | Atichat43/HMS_project | /Employee/Roommanager/RoomSystemClass.py | UTF-8 | 901 | 2.609375 | 3 | [] | no_license | from PySide.QtGui import QMessageBox
from Employee.Roommanager import RoomClass
class RoomSystem:
def __init__(self):
self.numberOfRoom = 13
self.allRoom = []
self.initRoom()
def initRoom(self):
for i in range(self.numberOfRoom):
self.allRoom.append(RoomClass.Room... | true |
a8c2d3ebacdb91ca5fcef32307ee6644e4181adb | Python | ornevirardi/test | /loops_practica.py | UTF-8 | 1,048 | 3.65625 | 4 | [] | no_license | part_max = int(input ("Por favor ingrese la cantidad de participantes -> "))
print ("")
print ("El sistema ha sido configurado para aceptar",part_max, "participantes")
print("")
cant_part = 0
while (cant_part < part_max):
nombre = input ("Ingrese su nombre ->")
print("")
email = input ("ingrese su email -... | true |
908cde53ad960bdb035ab6e15d0baf8e038a050a | Python | 82488059/PyTest | /game/算法/a_star.py | UTF-8 | 2,601 | 3.25 | 3 | [] | no_license | # -*- coding:utf-8 -*-
from random import randint
import pygame
from pygame.locals import *
MAZE_MAX = 50
MOVE_RIGHT = (1, 0)
MOVE_LEFT = (-1, 0)
MOVE_UP = (0, -1)
MOVE_DOWN = (0, 1)
direction = {0: {0: 0, 1: 1}, 1: {0: 1, 1: 0}, 2: {0: 0, 1: -1}, 3: {0: -1, 1: 0}}
class Node(object):
def __init__(self, x, y):
... | true |
bf196c21f86ca9e91524b4948ec43fc0df7072ca | Python | ajfite/simf-python-gui | /SimfPythonGUI/filehandlers.py | UTF-8 | 2,439 | 2.65625 | 3 | [
"MIT"
] | permissive | import os
from PyQt5.QtCore import QThread, pyqtSignal
from watchdog.events import PatternMatchingEventHandler
from datetime import datetime
from .config import Config
from watchdog.observers import Observer
# Computes where the lepton grabber is currently dumping output
class FileHandlerUtils:
@staticmethod
... | true |
1ac916c01bc05e16134e53bf9567116e58d079d9 | Python | NguyenHungThuong/Deeplearning.AI | /C2-Improve Deep Learning/Gradient_Checking.py | UTF-8 | 22,603 | 4 | 4 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# # Gradient Checking
#
# Welcome to the final assignment for this week! In this assignment you'll be implementing gradient checking.
#
# By the end of this notebook, you'll be able to:
#
# Implement gradient checking to verify the accuracy of your backprop implementation
# ##... | true |
cb2fc71254071769afa700fbdf6485224daa3067 | Python | WN1695173791/molecules-deprecated | /molecules/utils/TSNE_density_contour/TSNE_2D.py | UTF-8 | 3,817 | 2.59375 | 3 | [
"MIT"
] | permissive | from __future__ import print_function
import numpy as np
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
from scipy.stats.kde import gaussian_kde
class TSNE_2D(object):
def __init__(self):
pass
... | true |
b7a15f7a8fd9c688e2f63296cc8e859205e415bd | Python | oorahduc/alfred-cal | /src/format.py | UTF-8 | 1,842 | 2.859375 | 3 | [
"CC-BY-NC-4.0",
"MIT"
] | permissive | #!/usr/bin/python
# encoding: utf-8
import tkFont
import plistlib
import Tkinter as tk
plist = "/preferences/appearance/prefs.plist"
theme = "theme.plist"
DEFAULT_FONT = "Helvetica Neue"
DEFAULT_SIZE = 16
class Format(object):
def __init__(self, key, path):
t = tk.Tk()
self.font = self._load_fon... | true |
d18b9ad7be1b0eed4f16bcc3d7f0b6c51f56b3fc | Python | Soblev515/Python-Firebase-Admin | /RealTimeFirebase.py | UTF-8 | 816 | 2.6875 | 3 | [] | no_license | import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
# Ссылка на Сервисный ключ от БД на Firebase
cred = credentials.Certificate('D:/fe/smart-library-1-firebase-adminsdk-g8x7r-2d069f053c.json')
# Подключаемся к БД
firebase_admin.initialize_app(cred)
# Подключае... | true |
6c3c9366c1c5e41c4661472529f29b52b9cd2983 | Python | siddharththakur26/data-science | /Core/Languages/python/techgig/hello.py | UTF-8 | 741 | 3.859375 | 4 | [] | no_license | def main():
inn = input()
alpha_flag =numeric_flag=dot_flag=negative_flag=0
ty=""
for i in inn:
if i.isalpha():
alpha_flag +=1
elif i.isnumeric():
numeric_flag +=1
elif i == '.':
dot_flag +=1
elif i == '-':
negative_flag +=1... | true |
18d49d0ba4291ad720f515b376c49630147bc37f | Python | bentd/think-python | /9.7.8.py | UTF-8 | 1,421 | 4.03125 | 4 | [] | no_license | # Finds Number On Odometer from CarTalk Puzzle
def test_number(number, a=None, b=None):
number=str(number)
if len(number)<6: number='0'*(6-len(number))+number
number=number[a:b]
return number==number[::-1]
def test_range():
list1=range(1,1000000)
for i in list1:
if test_... | true |
b986b40a82e7f16931ee77ae33ce778e18b55f40 | Python | lucas992x/advent-of-code | /2020/07.py | UTF-8 | 2,687 | 2.984375 | 3 | [
"MIT"
] | permissive | import re
from collections import Counter
# Part 1
def RecCheck(mybag, father, containers, contdict, choices, checked):
if mybag != father:
if containers == []:
containers = contdict[father]
if mybag in containers:
choices.append(father)
else:
for contain... | true |
235a3c08ba07be7ae4337847c547d4faff8205b8 | Python | Inolas/python | /edX(MIT)/ProblemSets/problemSet2-2.py | UTF-8 | 541 | 2.59375 | 3 | [] | no_license | balance = 3926
annualInterestRate = 0.2
totalPaid=0
previousBalance=balance
for fixedMonthlyPayment in range(0,balance,10):
previousBalance=balance
monthCount=0
while(monthCount<12):
monthlyInterestRate=annualInterestRate/12.0
monthlyUnpaidBalance=previousBalance-fixedMonthlyPayment
... | true |
f1fa884b28eb9149667849c836a2bcc803a5b0f4 | Python | awnonbhowmik/Gram-Schmidt-Orthogonalization-Process | /gs.py | UTF-8 | 475 | 2.859375 | 3 | [] | no_license | import numpy as np
def normalize(v):
return v / np.sqrt(v.dot(v))
def gs(u):
v = [normalize(u[0])]
for i in range(1, len(u)):
s = u[i]
for j in range(i):
s = s - np.dot(u[i], v[j]) * v[j]
v.append(normalize(s))
return v
coeffs_1 = np.array([1, 1, 0, 0])
coeffs_2... | true |
6734c909ace94b71965a6d33f5b331c69aa6f7bd | Python | ctlnwtkns/itc_110 | /abs_hw/ch9/renameTarot.py | UTF-8 | 2,068 | 2.6875 | 3 | [] | no_license | #rename majorArcana files
import shutil, os, re
os.chdir('/Users/caitlin/Documents/school/itc_110/abs_hw/ch9/waiteSmith/majorArcana')
# Create a regex that matches part of filename to be substituted
nameRegex = re.compile(r'^(\d)(\d)?(.-.)(T|W\w*)?(\W)?(\w*.)?(\w*.)?(\w*)(.jpg)')
#TODO: Loop over the files in the wo... | true |
e4085d1585e9716fee2be22a594d11d31fa340b8 | Python | wisstock/voltAP | /a.py | UTF-8 | 244 | 2.859375 | 3 | [] | no_license | from scipy import integrate
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-2, 2, num=20)
y = x
print(x)
print(y)
y_int = integrate.cumtrapz(y, x, initial=0)
plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
plt.show() | true |
337cb507a932d50506d33173c5df3a2784370672 | Python | Rosa-Phoebe/MachineLearning | /JAX_Trivial_NNs_Advanced.py | UTF-8 | 12,828 | 3.5 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 23 21:14:40 2022
Reference:
https://github.com/gordicaleksa/get-started-with-JAX
Build fully fledged Neural Networks.
Gain knowledge necessary to build complex ML models(NNs) and train them in
parallel on multiple devices.
@author:
"""
import j... | true |
86229dbd3b97bdeb68e3fc7118b13086e2031368 | Python | chrysrod/Emporio-Serrana-API | /application/controllers/auth.py | UTF-8 | 1,604 | 2.640625 | 3 | [] | no_license | from base64 import b64encode, urlsafe_b64encode
from datetime import datetime, timedelta
from hashlib import sha512
from jwt import encode as jwt_encode, decode as jwt_decode
from application.controllers.users import Users
from application.models.database import Firestore
class Auth:
def __init__(self):
... | true |
b40da96769712fc429a9e86345d24d22a0aca20e | Python | turbulent/substance | /substance/path.py | UTF-8 | 1,976 | 2.515625 | 3 | [
"Apache-2.0",
"GPL-1.0-or-later"
] | permissive | import sys
import platform
import os
import re
from substance.shell import (Shell)
from subprocess import check_output
from substance.utils import Memoized
from pathlib import (PureWindowsPath, PurePosixPath)
from substance.platform import (isWSL, isCygwin)
@Memoized
def inner(path):
if isCygwin():
path ... | true |
8df92b884cf9c9e0a7162d06b27e6e437a17be37 | Python | Tilapiatsu/blender-custom_config | /scripts/addon_library/local/context_browser/utils/collection_utils.py | UTF-8 | 7,206 | 2.828125 | 3 | [
"MIT"
] | permissive | import bpy
from ..addon import ic
def sort_collection(collection, key, idx_data=None, idx_prop=None):
if idx_data is not None and idx_prop is not None:
cur_name = collection[getattr(idx_data, idx_prop)].name
items = [item for item in collection]
items.sort(key=key)
items = [item.name for item... | true |
46594ab280d530889b77d52eb24f3b3d39fdb935 | Python | kiesslim/lacerta | /lacerta-app/crawler/parse.py | UTF-8 | 6,464 | 3.296875 | 3 | [] | no_license | #!/usr/bin/python3.6
import logging
from lxml import etree, html
from lxml.html.clean import Cleaner
from random import shuffle
import requests
from urllib.parse import urldefrag, urlparse, urlsplit, urljoin, urlunsplit
class Web:
""" Web object stores parses a webpage and stores relevant webpage contents.
... | true |
1445b9696ac93815db65c404ef7d9cf4cd677fbf | Python | zopcuk/Plata_Recognation_Python | /test8.py | UTF-8 | 6,954 | 2.671875 | 3 | [] | no_license | import cv2
import imutils
import numpy as np
import pytesseract
from pyimagesearch.transform import four_point_transform
from collections import Counter
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
#cap = cv2.VideoCapture("2.mp4")
cap = cv2.VideoCapture("9102_Trim.mp4")
pla... | true |
6b50ab0bc81547f72ca2e57141529469e47298a3 | Python | danjonweb/DataVis-Team88Project | /DataCollection/FlightPriceHistory/insert_into_db.py | UTF-8 | 1,423 | 2.765625 | 3 | [] | no_license | import sqlite3
import json
conn = sqlite3.connect('../cityDB.sqlite')
c = conn.cursor()
c.execute("""CREATE TABLE flight_price_history (src text, dst text, yearmonth text, month text, price real)""")
mapping = {
'Jan': '01',
'Feb': '02',
'Mar': '03',
'Apr': '04',
'May': '05',
'Jun': '06',
... | true |
6700289d75ae780c1b5dd8852c511475ff1a36c2 | Python | colorfield/drupal-earth | /data/fetch/get_projects_usage_by_type.py | UTF-8 | 2,882 | 2.625 | 3 | [] | no_license | import os, sys, getopt, urllib.request, urllib.parse, json, requests, lxml.html as lh
#-------------------------------------------------------------------
# Constants and initialization
#-------------------------------------------------------------------
# Limit by default to 100 pages (5000 most downloaded projects)... | true |
d8d7902bd3144d85d114bb9e95571aba8dc3dc8b | Python | lbrndnr/inf581-proj | /agent_RL.py | UTF-8 | 7,454 | 3.234375 | 3 | [] | no_license | import numpy as np
from environment_3d import *
from geometry_3d import *
import time
np.random.seed(int(time.time()))
#a function that takes the state of the environment into account in order to
#return a "smaller" state the algorithm can use to learn
def compress1(env, state):
maze, head, tail, direction = stat... | true |
098093798f86b4448ef7fe25b3295b4598b9f010 | Python | IanShi1996/IWLatentODE | /src/utils.py | UTF-8 | 2,386 | 3.0625 | 3 | [] | no_license | import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def reshape_by_args(t, args, repeat=False):
"""Reshapes tensor into form specified by training arguments.
Assumes tensor is of shape (BMK x L x D) or (BMK x H) where:
B = batch size, M = number of ELBO samples, K = ... | true |
088a84112b4c7a2bf841d1b4e5f0035ec9b04fd6 | Python | GrishaAdamyan/All_Exercises | /To read and print the table #2.py | UTF-8 | 431 | 3.0625 | 3 | [] | no_license | row = int(input())
col = int(input())
table = [[input() for j in range(col)] for i in range(row)]
for i in range(row):
for j in range(col):
print(table[i][j], end = '\t')
print()
print()
for i in range(col):
for j in range(row):
print(table[j][i], end = '\t')
print()
#3
#2
#three
#club... | true |
7936e0839695659be61469e0eb0cb9be80d0510f | Python | fagan2888/DFZQ | /quant_engine/Factor/Iliquidity/amihud.py | UTF-8 | 2,780 | 2.609375 | 3 | [] | no_license | # 非流动性因子 amihud_20 的计算
from factor_base import FactorBase
import pandas as pd
import numpy as np
from influxdb_data import influxdbData
import dateutil.parser as dtparser
from joblib import Parallel, delayed, parallel_backend
from dateutil.relativedelta import relativedelta
import math
from global_constant import N_J... | true |
8daeb36f008686e617218ab5df8720ed5a9bded2 | Python | DrNightmare/ciml | /knn/knn_predict.py | UTF-8 | 1,320 | 3.28125 | 3 | [] | no_license | import heapq
from math import sqrt
from collections import Counter
from sklearn import datasets
def get_euclidean_distance(example_1, example_2):
return sqrt(sum((a - b)**2 for a, b in zip(example_1, example_2)))
def _distance_key(example):
return example[0]
# Implementation of Algorithm 3 - KNN-Predict
... | true |
d7e6c9ccd057dab9fd4173d327832d76516affa8 | Python | JPalijado/Assign_5 | /part1.py | UTF-8 | 1,284 | 4.21875 | 4 | [] | no_license | import math
def InputGrade():
grade = float(input("Enter Grade: "))
return grade
def RoundOffGrade(grade):
if (grade % 1) >= 0.5:
rGrade = math.ceil(grade)
else:
rGrade = math.floor(grade)
return rGrade
def DisplayOutput(rGrade):
if rGrade >= 97 and rGrade <= 100:
prin... | true |
f033d3b92ca7e11baeb25b0fa706cccead657e90 | Python | jingnanzh/pythonCases | /xiaoxiang_projects/python_in_16_days/day3_saveFileNames.py | UTF-8 | 637 | 3.09375 | 3 | [] | no_license | # Practice python in 16 days
# https://clock.kaiwenba.com/clock/course?sn=ExhvY&course_id=71
'''
Day 3 批量处理文件名称(下)
筛选PDF和doc文档,将结果写入文件。
'''
import os
import pandas
path=r'C:\Users\Maggie\Desktop\Udemy-desktop\xiaoxiangxueyuan'
name=os.listdir(path)
print(name)
result = []
for i in name:
if i.endswith('.docx'... | true |
d454e50eb15b9a9e7e15074bafca0a80875a58d8 | Python | ashariati/occamsam | /occamsam/equivalence.py | UTF-8 | 3,374 | 2.921875 | 3 | [
"MIT"
] | permissive | import numpy as np
import scipy as sp
import scipy.sparse
from itertools import combinations
class Identity(object):
def __call__(self, mi, mj):
return 1
class ExpDistance(object):
def __init__(self, sigma):
self._sigma = sigma
def __call__(self, mi, mj):
return np.exp(-(np.li... | true |
217d25fc7142b7176c21e7c3bbdc0aa5302b07a5 | Python | RajkumarVerma4124/FellowshipPythonPrograms | /PythonDataStructures/Lists/SplitList.py | UTF-8 | 680 | 3.90625 | 4 | [] | no_license | from itertools import groupby
from operator import itemgetter
class SplitList:
def tosplitList(self, listOfStr):
for char, gorupwords in groupby(sorted(listOfStr), key=itemgetter(0)):
print("First Charater : ",char)
for singleword in gorupwords:
print("Word Belongs T... | true |
7cf94d6db26b8dec35ff3a31a1a994d55c0b1446 | Python | HomingYuan/machine_learning | /ML_by_zhouzhihua/knn.py | UTF-8 | 3,546 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 21 11:49:16 2017
@author: user
"""
import pandas as pd
import math
import numpy as np
import random
import matplotlib.pyplot as plt
def dist(num1, num2):
t = (num1 - num2) ** 2
return float(t ** 0.5)
def cenPoint(dataSet,k):
oriPoint = random.sample(dataS... | true |
04343603b0a8308eae08dbf39710061f10e03cc8 | Python | Zkoogan/Specialization_Planner | /Setup/scraper.py | UTF-8 | 4,495 | 2.71875 | 3 | [] | no_license | from bs4 import BeautifulSoup
import requests
import numpy as np
import pymongo
import os
import sqlite3 as sq
class Course:
def __init__(self, code, points, pointType, name, description, representative, study_periods, table_index):
self.code = code
self.points = points
self.po... | true |
fb500040bfb1157299c27dff07be9aab29c6cdc4 | Python | vincy0320/School_Intro_to_ML | /Project7/rl_model_free.py | UTF-8 | 8,552 | 3.03125 | 3 | [] | no_license | #!/usr/bin/python3
import random
import rl_base
SEPARATOR = "_"
DISCOUNT_RATE = 0.7
class ReinformacementLearning(rl_base.RLBase):
def __init__(self, simulator, epsiodes = 100):
"""
Constructor of a model based reinforcement learning
"""
rl_base.RLBase.__init__(self, simulator)
... | true |
cec3b1ef7eefc3e48d7a5c524d626b4109d1a211 | Python | ongbo/Artificial-Intelligence-Machine-Learning | /test/Homework/work2/lgScipt.py | UTF-8 | 2,612 | 2.96875 | 3 | [] | no_license | from io import StringIO
from urllib import request
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import ssl
import pandas as pd
import numpy as np
import linearRegression as lg
ssl._create_default_https_context = ssl._create_unverified_context
names =["mpg","cylin... | true |
ec9b09a3853e487dd8d1898e9ba7dc17bf92ea5c | Python | umairqadir97/Human-Face-Detection-HOG- | /hog.py | UTF-8 | 518 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 21:08:24 2017
@author: umair
"""
import cv2
import numpy as np
# Python gradient calculation
# Read image
im = cv2.imread('screw.bmp')
img = np.float32(im) / 255.0
# Calculate gradient
gx = cv2.Sobel(img, cv2.CV_32F, 1, 0, ksize=1)
gy = cv2.Sobe... | true |
2dadf1f9e182ae6b39232e3de3aac557e1818ca2 | Python | taozhenting/python_introductory | /6-1/alien.py | UTF-8 | 1,189 | 4 | 4 | [] | no_license | #创建字典
alien_0 = {'color':'green','points':5}
print(alien_0['color'])
print(alien_0['points'])
new_points = alien_0['points']
print("You just earned " + str(new_points) + " points!")
#增加字典的键和值
alien_0['x_position'] = 0
alien_0['y_position'] = 25
print(alien_0)
#创建空字典
alien_0 = {}
alien_0['color'] = 'green'
alien_0['po... | true |
654183a576a5b3a96d818bf4d57ec1cf04938ca3 | Python | ebarnard/carproject | /vision_python/car_detection_opencv_background_subtraction.py | UTF-8 | 2,214 | 2.65625 | 3 | [] | no_license | from PIL import Image
from timeit import default_timer as timer
import cv2
import numpy as np
import math
import PyCapture2
from PyCapture2 import Camera, BusManager
# Read video
video = cv2.VideoCapture("../video/car_drive_demo.avi")
bgrm = cv2.createBackgroundSubtractorMOG2(history=200, detectShadows=False)
for i... | true |
2273dc1645af1614c06fa269c9de76c7c6085896 | Python | powderluv/edgetpu | /edgetpu/learn/backprop/softmax_regression.py | UTF-8 | 10,987 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | true |
65294767f2d37d979bcd8bf8f19c15dbdcf775e5 | Python | irhadSaric/Instrukcije | /z9.3.py | UTF-8 | 411 | 3.09375 | 3 | [] | no_license | fajl = open('test03.in', 'r')
kurs1 = []
kurs2 = []
kurs3 = []
red = fajl.readline()
while red != '':
podaci = red.split()
if podaci[2] == '1':
kurs1.append(podaci[0]+" "+podaci[1])
elif podaci[2] == '2':
kurs2.append(podaci[0]+" "+podaci[1])
elif podaci[2] == '3':
kurs3.append... | true |
ebddeb8796bde54a9cd2ae0d7db24792ce51b7e9 | Python | munifico/ko-stock-assistant | /kostock/plot.py | UTF-8 | 4,985 | 2.75 | 3 | [
"MIT"
] | permissive | import mplfinance as mpf
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
from matplotlib import gridspec
import math
import os
class Plot:
color = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
'#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
def __init__(se... | true |
46c6897596482b346ad6c177f5c3cb83f8017a55 | Python | SunshineJunFu/Pytorch-RL | /DQN/src/utils.py | UTF-8 | 681 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2018-06-23 11:40:18
# @Author : Jun Fu (fujun@mail.ustc.edu.cn)
# @Version : $Id$
import torch
import copy
import numpy as np
def cvtTensor(data):
""" summary the function of cvtTensor
add batch size, convert data into torch and t... | true |
2b4762efc33af326e0600880ceb9d8c9a2ccae8e | Python | ivarhaugerud/INF1100 | /innleveringer/uke 2/uferdige/sum_while.py | UTF-8 | 310 | 3.4375 | 3 | [] | no_license | s = 0.0
k = 1
M = 100
while k <= M: # Changed the "<" with "<=" beacause i wanted to include the value for M
s += (1.0/k) # Here i changed it from INT to Float by using decimals
k += 1 # it was an error here, because the value k did not increase, therefor the while loop lasted forever
print s
| true |
d864d8aeb6cc64dd34a004c7caea9c8eee86e382 | Python | nickovic/rtamt | /rtamt/syntax/node/ltl/eventually.py | UTF-8 | 514 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | from rtamt.syntax.node.unary_node import UnaryNode
class Eventually(UnaryNode):
"""A class for storing STL Eventually nodes
Inherits TemporalNode
"""
def __init__(self, child):
"""Constructor for Eventually node
Parameters:
child : stl.Node
bound : Inter... | true |
ecb4039d2d2d78bc3cfbde336136328022521379 | Python | Critteros/DzwoneczekBOT-old | /app/Cogs/AdminCommands.py | UTF-8 | 2,522 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | # Just for testing
#########################################################################################
# Library includes
from discord.ext import commands
from discord.ext.commands.context import Context
#########################################################################################
# App includes
fr... | true |
28cbc65f9b970f963bef3ed2f0e6602d68bca917 | Python | eneDd/projects | /TSP Genetic Algorithm/RecombinationStrategies.py | UTF-8 | 4,956 | 3.359375 | 3 | [] | no_license | import random
from collections import Counter
from MutationStrategies import MutationStrategies
crossover_rate = 0.75
# CROSSOVER STRATEGIES
# - ORDER_1 CROSSOVER
# - CYCLE CROSSOVER
# P.S WITH THE DEACTIVATED #PRINTS IN THE CODE; YOU CAN CHECK THE PROCESSES OF THE ALGORITHM BY GETTNG ACTIVATED
class Recombinatio... | true |