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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3f214bf68dad4e09b209464c408542c7c390d85a | Python | bk-ikram/Data-Wrangling-with-MongoDB | /audit.py | UTF-8 | 4,830 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 13 15:09:13 2017
@author: IKRAM
"""
import xml.etree.cElementTree as ET
from collections import defaultdict
import re
import json
import codecs
FILENAME="doha_qatar.osm"
problem_words=["school","district","compound","office","schule","mall","mart","cen... | true |
87e4a9a56a0b5dc68c2517d459ba93da6f16e576 | Python | zaccaromatias/AlgoritmosGeneticos | /Ejercicio3/ProgramView.py | UTF-8 | 1,045 | 2.984375 | 3 | [] | no_license | from tkinter import *
from Ejercicio3.AlgoritmoGeneticoView import AlgoritmoGeneticoView
from Ejercicio3.HeuristicaView import HeuristicaView
class ProgramView:
def __init__(self):
self.top = Tk()
self.top.wm_title("Ejercicio 3 - Viajante")
self.top.wm_geometry("370x250")
self.top.... | true |
d887c96c4df906dc658f65b6ded2d598ca34ca04 | Python | chasecolford/Leetcode | /problems/1482.py | UTF-8 | 3,123 | 3.53125 | 4 | [] | no_license | # def minDays(bloomDay, mBouquets, kAdjacent):
# # we can never make them if we need more than the total flowers
# if mBouquets * kAdjacent > len(bloomDay): return -1
# checker = [0] * kAdjacent # this will be what we need for a range to be value (i.e. 0 represents its bloomed)
# day = 0
# ba... | true |
0ba6a3493d78b10ad13bc64eb4cd6d16058d9fd7 | Python | loalberto/Springboard-Capstone3 | /Preprocessing_Modeling.py | UTF-8 | 6,015 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# # Preprocessing
# In[1]:
import os
from tensorflow.keras.preprocessing import image
import numpy as np
import multiprocessing
import random
import pandas as pd
import multiprocessing
import gc
from keras.models import Sequential
from keras.layers import Dense, Conv2D, Flatte... | true |
a372c4c11a934561ab228e2eefc744be1c48e8b8 | Python | IfYouThenTrue/Simple-Programs-in-Python | /RockPaperScissors.py | UTF-8 | 928 | 3.453125 | 3 | [] | no_license | #!/bin/python3
from random import randint
def rps():
playerCh = input('Choose rock, paper or scissors')
print('You chose '+playerCh)
computerCh = randint(1,3)
if computerCh == 1:
computerCh = 'rock'
print('Computer chose '+ computerCh )
elif computerCh == 2:
computerCh = ... | true |
e5bfb6b63fc0ab0438256d87b719b72b57ad309b | Python | betadayz/Task-3 | /Task==3.py | UTF-8 | 577 | 3.671875 | 4 | [] | no_license | from math import sqrt
def primeCount(arr, n):
max_val = arr[0];
for i in range(len(arr)):
if(arr[i] > max_val):
max_val = arr[i]
prime =[ True for i in range(max_val + 1)]
prime[0] = False
prime[1] = False
k = int(sqrt(max_val)) + 1
for p in range(2, k, 1):
if (prime[p] == True):
... | true |
816354722f886068bbaec107b78d092fc6680998 | Python | ravisjoshi/python_snippets | /Array/Pascal'sTriangleII.py | UTF-8 | 942 | 3.765625 | 4 | [] | no_license | """
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.
Note that the row index starts from 0.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
Input: 3 / Output: [1,3,3,1]
"""
class Solution:
def getRow(self, rowIndex):
if rowI... | true |
1b92404bee8b471dd5add7dcbdc8f7b6c7459c94 | Python | BayoAdepegba/Python | /ex13.py | UTF-8 | 592 | 3.5625 | 4 | [] | no_license | #Import = add features to script from python feature set
#argv is the argument variable = holds the arguments you pass
#to your python script when you run it
from sys import argv
#Unpacks argv- assigns to four variables
script, first, second, third = argv
print "The script is called:", script
print "Your first variabl... | true |
d19b23eea7cdc05c8c18a68d67562dc3ea5253c7 | Python | diegoshakan/curso-em-video-python | /Desafio56M02.py | UTF-8 | 1,014 | 4.5 | 4 | [] | no_license | '''Crie um programa que leia o nome de quatro pessoas, idade e o sexo e mostre:
1- A média de idade do grupo:
2 - Qual é o nome do homem mais velho
3 - Quantas mulheres tem menos de 20 anos.
'''
soma = 0
cont = 0
contm = 0
velhonome = ''
velhoidade = 0
for c in range(1, 5):
nome = input('Digite um nome: ')
id... | true |
db92a2676f4311b6ab733a95609783ea2a89b346 | Python | Aasthaengg/IBMdataset | /Python_codes/p02903/s073062547.py | UTF-8 | 260 | 3.3125 | 3 | [] | no_license | h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
for i in range(h):
if i >= h-b:
for j in range(w-a,w):
ans[i][j] = 1
else:
for j in range(w-a):
ans[i][j] = 1
for i in ans:
print(*i,sep="") | true |
561c826629f3cbb742bb3e738a6407a04919b15b | Python | cyclopsprotel/Jamming_Detection | /Capacity_Estimation/plot_MI.py | UTF-8 | 437 | 2.984375 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('MIs.csv')
df = df.sort_values(['Prob'])
print(df)
snrs = np.unique(df['SNR'].values)
for i in snrs:
temp = df.loc[df['SNR'] == i]
lab = "True MI - SNR=" + str(i)
plt.plot(temp['Prob'], 0.5*temp['Iy1'] + 0.5*temp['Iy1y2'], label... | true |
72d7fcb584754750d97e568ef2130573d1b381ec | Python | fdkz/libaniplot | /example/qaniplot.py | UTF-8 | 4,090 | 2.6875 | 3 | [
"MIT"
] | permissive | import sys
import math
import time
from PySide import QtCore, QtGui
sys.path.append('..')
from aniplot import AniplotWidget
class SignalGenerator(object):
''' This can be used for testing purposes '''
seed = 0
def __init__(self):
SignalGenerator.seed += 1
self.i = sel... | true |
c455662616f193278a3f6551f0e41c64cbda83ef | Python | mskailash/myexercise | /myexercise/s_scan_duplicates.py | UTF-8 | 881 | 3.203125 | 3 | [] | no_license | #!/usr/bin/python
#Description: This Program displays all the duplicate files in the given Directory
#Author: Kailash.M.S
#Date: April 2018
#Version: 1.0
__author__ = "M.S.Kailash"
import os, argparse
from m_duplicates_in_dir import duplicates_in_dir
# To Get the directory name from command line argument
# Check th... | true |
bceb970f8a08c9c7f93df8850707aa0bacc270e1 | Python | shannon112/DLCVizsla | /hw3_dcgan_acgan_dann/gta/pre_dataset.py | UTF-8 | 779 | 2.796875 | 3 | [] | no_license | import torch.utils.data as data
from PIL import Image
import os
import glob
class GetLoader(data.Dataset):
def __init__(self, img_root, transform=None):
self.img_root = img_root
self.transform = transform
self.img_paths = sorted(glob.glob(os.path.join(img_root, '*.png')))
self.len =... | true |
4790cdf79cee470128e7507da2c3253a4de041a9 | Python | Brian-Tomasik/python-utilities | /replace_Google_Docs_urls_with_redirects.py | UTF-8 | 1,796 | 3 | 3 | [] | no_license | import requests
from lxml.html import fromstring
import argparse
import re
parser = argparse.ArgumentParser(description='Replace Google-Docs urls with the urls they redirect to.')
parser.add_argument('infile', help='input HTML file')
parser.add_argument('outfile', help='output HTML file')
args = parser.parse_args()
n... | true |
9973427aee958e1ab5335097650b71c6e584ad4b | Python | sureshbvn/nlpProject | /nGramModel/evaluate.py | UTF-8 | 3,595 | 2.75 | 3 | [
"MIT"
] | permissive | from __future__ import division
import re
import numpy as np
import sklearn.metrics as grading_metrics
import utility as util
import string
fw=open("tempout.txt","w+")
def transform(line):
if len(line)==0:
return
if line[-1] is not '.' and line[-1] is not ',':
line = line + '.'
... | true |
a78c924de8d8bc04d5bdb9143d911c9315de75d5 | Python | Thirumurugan-12/Python-programs-11th | /0 22 4444 666.py | UTF-8 | 99 | 3.375 | 3 | [] | no_license | #pgm 2
for r in range(0,4):
for c in range(0,r+1):
print(2*r,end=" ")
print()
| true |
40739eb8d05c77759155a46f9af55c354c9d8ea0 | Python | yangyangmei/fisher | /app/web/book.py | UTF-8 | 3,694 | 2.65625 | 3 | [] | no_license | """
created by yangyang on 2018/9/29.
"""
from flask import jsonify, request, render_template, flash
from app.libs.helper import is_isbn_or_key
from app.models.gift import Gift
from app.models.wish import Wish
from app.spider.yushu_book import YuShuBook
from app.view_models.trade import TradeViewModel
from . impor... | true |
73ac6b557967e5a203b25518ffee52e2c8199989 | Python | pfuntner/toys | /bin/cols.py | UTF-8 | 2,690 | 3.046875 | 3 | [] | no_license | #! /usr/bin/env python3
"""
Print lines to identify the columns, keyed off the width of the screen. Useful to know how long lines are, what column a character/field is in, etc.
"""
import re
import sys
import math
import getopt
import subprocess
def syntax(msg=None):
if msg:
sys.stderr.write('{msg}\n'.form... | true |
86d8d21ec522f7ea0df2e6d4e360d90af1a243a7 | Python | TarasRudnyk/Students_health_records | /data_processing.py | UTF-8 | 11,273 | 2.6875 | 3 | [] | no_license | import cx_Oracle
def get_configuration():
with open("config", encoding='utf-8') as config_file:
parameters = {}
for line in config_file:
parameter, value = line.split(": ")
parameter = parameter.rstrip()
value = value.strip()
parameters[parameter] = ... | true |
8fc3f99def3895cf6849f21996a81100f5082ca5 | Python | jakejg/WTforms-adoption | /forms.py | UTF-8 | 1,135 | 2.84375 | 3 | [] | no_license | from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, SelectField, BooleanField
from wtforms.validators import InputRequired, URL, AnyOf, NumberRange, Optional
class AddPet(FlaskForm):
name = StringField("Name of Pet", validators=[InputRequired()])
species = StringField("Type of Anima... | true |
22370cf8fa86a6bea03aff090c9113d300be18a9 | Python | lpk-py/pymodes | /pymodes/tests/test_eigenfrequencies.py | UTF-8 | 6,999 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Tests for the eigenfrequency rootfinding functions.
:copyright:
Martin van Driel (Martin@vanDriel.de), 2016
:license:
None
'''
import inspect
import numpy as np
import os
import pymesher
from .. import eigenfrequencies
# Most generic way to get the data dire... | true |
7397d7ad5d5b00498bc67a3a10338a99e13a4359 | Python | Joserra13/TFG | /Web App IoT/encender.py | UTF-8 | 202 | 3.078125 | 3 | [] | no_license | import serial
arduino = serial.Serial('/dev/ttyACM0', 9600)
comando = 'H' #Input
arduino.write(comando) #Send the command to Arduino
print("LED ON")
arduino.close() #End the communication | true |
c0bdebdddc273da113c0ae4d5901dcc71bbd95d6 | Python | redvasily/lighttpdrecipe | /lighttpdrecipe/recipe.py | UTF-8 | 2,402 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | import re
import os
from os.path import join, dirname, abspath
import logging
import zc.buildout
import buildoutjinja
hostname_regexp = re.compile(r'^[-a-z\.0-9]*$', re.I)
def is_simple_host(s):
return not ((len(s.splitlines()) > 1) or (not hostname_regexp.match(s)))
def is_true(s):
if s.lower() in set(['ye... | true |
2e74f7a6ca18020b944bc583373c142c747c8c24 | Python | leequant761/Fluent-python | /02-array-seq/bisect_demo.py | UTF-8 | 1,373 | 3.609375 | 4 | [
"MIT"
] | permissive | # BEGIN BISECT_DEMO
import bisect
import sys
HAYSTACK = [1, 4, 5, 6, 8, 12, 15, 20, 21, 23, 23, 26, 29, 30] # 정렬된 시퀀스에
NEEDLES = [0, 1, 2, 5, 8, 10, 22, 23, 29, 30, 31] # 정렬을 유지한 채 니들 추가하고 싶다.
ROW_FMT = '{0:2d} @ {1:2d} {2}{0:<2d}'
def demo(bisect_fn):
for needle in reversed(NEEDLES):
position = bisec... | true |
6d873405e6bb2d7602b29ae94d80f34dc982cf17 | Python | AlfredZuo/PythonTest | /myTest.01/leet_code_94_二叉树的中序遍历_DFS.py | UTF-8 | 1,053 | 4.03125 | 4 | [] | no_license | '''
94. 二叉树的中序遍历 DFS
给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。
示例 1:
输入:root = [1,null,2,3]
输出:[1,3,2]
示例 2:
输入:root = []
输出:[]
示例 3:
输入:root = [1]
输出:[1]
提示:
树中节点数目在范围 [0, 100] 内
-100 <= Node.val <= 100
'''
# 节点类
class TreeNode(object):
def __init__(self, x):
... | true |
04ecc97fe9cdb5e928c7cc069a8d11e183776f52 | Python | alltej/kb-python | /tests/coding_challenge/test_working_hours.py | UTF-8 | 1,458 | 3.046875 | 3 | [] | no_license | from nose.tools import assert_equal
import working_hours
class TestWorkingHours(object):
def is_working_hours_func(self, func):
assert_equal(func(9), True)
assert_equal(func(11), True)
assert_equal(func(13), True)
assert_equal(func(15), True)
assert_equal(func(18), True)
... | true |
6ee9d78a9573f99a984f0ff9d524fead5f5278d7 | Python | ConfickerVik/home_work | /laba13/mission13_2/CreateXML.py | UTF-8 | 1,226 | 2.75 | 3 | [] | no_license | from xml.dom import minidom
class CreateXml:
def create_xml(self, mas):
doc = minidom.Document()
# Создание основного тега 'soap:Envelope'
root = doc.createElement('soap:Envelope')
root.setAttribute('xmlns:soap', 'http://example.schemas.xmlsoap.org/soap/envelope/')
doc.ap... | true |
c80b26a41d86ec4f2f702aab0922b86eec368e84 | Python | Brucehanyf/python_tutorial | /file_and_exception/file_reader.py | UTF-8 | 917 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | # 读取圆周率
# 读取整个文件
# with open('pi_digits.txt') as file_object:
# contents = file_object.read()
# print(contents)
# file_path = 'pi_digits.txt';
# \f要转义
# 按行读取
file_path = "D:\PycharmProjects\practise\\file_and_exception\pi_digits.txt";
# with open(file_path) as file_object:
# for line in file_object:
# ... | true |
a52e403dc724e2ace4d4a45c4158425487f7bfe3 | Python | blengerich/Personalized_Regression_ISMB18 | /distance_matching.py | UTF-8 | 18,791 | 2.859375 | 3 | [
"MIT"
] | permissive | # Personalized Regression with Distance Matching Regularization
import numpy as np
np.set_printoptions(precision=4)
import time
from utils import *
from sklearn.preprocessing import normalize
from multiprocessing.pool import ThreadPool
class DistanceMatching():
def __init__(self, init_beta,
f, f_... | true |
ae5e2cefa70f885a61f0ed905f4e0683ae0fe134 | Python | bkgoksel/squid | /test/test_predictor.py | UTF-8 | 4,770 | 2.90625 | 3 | [] | no_license | """
Module for testing predictor model utilities
"""
import unittest
from unittest.mock import Mock
import numpy as np
import torch as t
import torch.nn as nn
from torch.nn.utils.rnn import (
PackedSequence,
pack_padded_sequence,
pad_packed_sequence,
pad_sequence,
)
from model.predictor import DocQAC... | true |
6dfbc741f7a56ffb3604202c52d7312d8f4ef611 | Python | prodProject/WorkkerAndConsumerServer | /Enums/passwordEnum.py | UTF-8 | 252 | 2.59375 | 3 | [
"MIT"
] | permissive | from enum import Enum
class PasswordMode(Enum):
UNKNOWN_PASSWORD = 0;
GENERATE_PASSWORD = 1;
VERIFY_PASSWORD = 2;
GENEREATE_NEW_PASSWORD = 3;
@staticmethod
def getEnum(name):
return PasswordMode.__getattr__(name=name)
| true |
cffc4e258e730169d3bfcf52b8012fb7c4c9bed5 | Python | monalan/myGitProject | /tryforPython/drawPic/world_population.py | UTF-8 | 1,533 | 3.296875 | 3 | [] | no_license | import json
import pygal
from pygal_maps_world.i18n import COUNTRIES
# 将数据加载到一个列表中
filename = 'population_data.json'
with open(filename) as f:
pop_data = json.load(f)
"""# 打印每个国家 2010 年的人口数量
for pop_dict in pop_data:
if pop_dict['Year'] == '2010':
country_name = pop_dict['Country Name']
population = pop_dict['V... | true |
43c16f27d22d5d28b09211143d3a4a4ef55e953c | Python | qibolun/DryVR | /Thermostats/Thermostats_ODE.py | UTF-8 | 851 | 2.734375 | 3 | [] | no_license |
from scipy.integrate import odeint
import numpy as np
def thermo_dynamic(y,t,rate):
dydt = rate*y
return dydt
def TC_Simulate(Mode,initialCondition,time_bound):
time_step = 0.05;
time_bound = float(time_bound)
initial = [float(tmp) for tmp in initialCondition]
number_points = int(np.ceil(time_bound/time_step... | true |
803c5743bde21d2baf97f3b4e7b1589b3a1037a5 | Python | crt379/sift | /ttss/vvvvvfff.py | UTF-8 | 2,600 | 2.859375 | 3 | [] | no_license | import sys
import os
from PyQt5.Qt import * # noqa
class DirectoryTreeWidget(QTreeView):
def __init__(self, path=QDir.currentPath(), *args, **kwargs):
super().__init__(*args, **kwargs)
self.init_model(path)
self.expandsOnDoubleClick = False
self.header().setSectionResizeMode(0,... | true |
4efa3f0724a2eebcf25e4f9e1b0ae78566d0aaf8 | Python | thkoeln/dlaproject | /src/datasets/music_dataset.py | UTF-8 | 6,683 | 2.59375 | 3 | [] | no_license | import tensorflow as tf
import matplotlib as mpl
import numpy as np
import os
import pandas as pd
basepath = "src/datasets/arrays/"
mpl.rcParams['figure.figsize'] = (8, 6)
mpl.rcParams['axes.grid'] = False
BASE_BPM = 100.0
BPM_MODIFIER = 100.0
# input/output size (for us=(88)*3 + 1 = 265)
FEATURE_SIZE = 177
# Is... | true |
1ef43fb524b4aae783f34b0c24032e3010795a1d | Python | RazvanRotari/iaP | /services/utils/new.py | UTF-8 | 6,589 | 2.859375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
from __future__ import print_function
import yaml
import sys
import re
import pprint
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
#GOD = General Object Description
DEFAULT_URI = "http://razvanrotari.me/terms/"
DEFAULT_URI_PREFIX = "rr"
FUNCTION_TEMPLATE... | true |
57bd7ade32e05e3730d561b3e4b5a7b8a9f37f37 | Python | jimtin/CryptoTradingPlatform_python | /Trading/TradingSettings.py | UTF-8 | 4,223 | 3.515625 | 4 | [
"MIT"
] | permissive |
# Class to set up settings for trading
class TradeSettings:
def __init__(self, BaselineToken, BaselinePercentageHold, PercentageTrade):
self.BaselineToken = BaselineToken
self.BaselinePercentageHold = BaselinePercentageHold
self.PercentageTrade = PercentageTrade
print(f'Trade sett... | true |
ad01db5644e216dfcfc3ca6aec67e1dca3b3bfcc | Python | ashkankzme/QAforMisinformation | /data_preparation/data_cleaning.py | UTF-8 | 4,280 | 2.671875 | 3 | [] | no_license | import json
import math
import random
import sys
import numpy as np
sys.path.insert(1, '../paragraph_ranking')
from utils import get_paragraphs, get_bert_marked_text, tokenizer
with open('../data/news.json') as news_file:
news = json.load(news_file)
with open('../data/stories.json') as story_file:
stories = ... | true |
d48b0361c3d8df8174b198a721231f04f199cb0a | Python | suryatmodulus/stock-pickz | /stockpicker.py | UTF-8 | 6,804 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env python3
import argparse
import pathlib
import csv
import typing as T
import difflib
from datetime import datetime,timedelta,date
import statistics
from sys import maxsize
stock_codes = []
min_date = None
max_date = None
stock_data = {}
stock_dates = []
stock_prices = []
start_date = None
end_date = No... | true |
7ee6a48e8387a0d45ea82cf44b3e7b679dfcc503 | Python | kongxilong/python | /mine/chaptr3/readfile.py | UTF-8 | 341 | 3.59375 | 4 | [] | no_license | #!/usr/bin/python3
'readTextFile.py--read and display text file'
#get file name
fname = input('please input the file to read:')
try:
fobj = open(fname,'r')
except:
print("*** file open error" ,e)
else:
#display the contents of the file to the screen.
for eachline in fobj:
print(eachline,)... | true |
159381f399c7295e1892bdf3012d40c547b47d59 | Python | TianhengZhao/LeetCode | /[2]两数相加.py | UTF-8 | 1,476 | 3.875 | 4 | [] | no_license | # 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。
#
# 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。
#
# 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。
#
# 示例:
#
# 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)
# 输出:7 -> 0 -> 8
# 原因:342 + 465 = 807
#
# Related Topics 链表 数学
# leetcode submit region begin(Prohibit modification a... | true |
3249f954b1dd55d10a478aad5fafbf44576bc207 | Python | ContinuumIO/PyTables | /tables/undoredo.py | UTF-8 | 4,165 | 3.0625 | 3 | [
"BSD-3-Clause"
] | permissive | ########################################################################
#
# License: BSD
# Created: February 15, 2005
# Author: Ivan Vilata - reverse:net.selidor@ivan
#
# $Source$
# $Id$
#
########################################################################
"""
Support for undoing a... | true |
e88a6e32174c2425599a12c33565e4ff379c90f0 | Python | skriser/pythonlearn | /Day28/04trya.py | UTF-8 | 405 | 2.5625 | 3 | [] | no_license | #!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@time: 2018/06/04 15:21
@author: 柴顺进
@file: 04trya.py
@software:rongda
@note:
"""
import urllib2
req = urllib2.Request('https://blog.csdn.net/cecrel')
try:
res = urllib2.urlopen(req)
except urllib2.HTTPError,e:
print dir(e)
print e.code
print e.ms... | true |
3b5544ed46a4aa5000f0f9d324ad77dbc8f3f9b1 | Python | MrDaGree/linuxtks | /gui/modules/filewatch.py | UTF-8 | 8,684 | 2.90625 | 3 | [] | no_license | import os
import platform
from datetime import *
import imgui
import threading
import json
from modules import logger
from modules import LTKSModule
log = logger.Logger()
class FileWatch(LTKSModule.LTKSModule):
alerts = []
alertsData = {}
watchLoopTime = 30.0
started = False
interfaceActive = Fal... | true |
1a2217844053e650af54530ba1a549f238c771bd | Python | steinbergs-python-packages/spycery | /spycery/basics/const.py | UTF-8 | 2,907 | 3.71875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This module provides a Const type to be used to define readonly attributes."""
class Const(type):
"""
Basic const type implementation.
Use it as the metaclass, when implementing a class containing readonly attributes.
Example:
class MyClass(m... | true |
a8d1c0cb7aa1eeebd18ea392d40d39ec16adc9dd | Python | arfu2016/nlp | /nlp_models/spacy/property2.py | UTF-8 | 626 | 3.296875 | 3 | [] | no_license | """
@Project : text-classification-cnn-rnn
@Module : property2.py
@Author : Deco [deco@cubee.com]
@Created : 6/5/18 4:05 PM
@Desc : https://www.python-course.eu/python3_properties.php
"""
class P:
def __init__(self,x):
self.x = x
# 调用.x赋值时,实际是使用 @x.setter
@property
def x(s... | true |
f3789a93d3b90e7c6b7d7319573270d1144543c3 | Python | ErichBSchulz/PIRDS-respiration-data-standard | /pirds_library/examples/PythonToArduino/Measurement_PythonToArduino.py | UTF-8 | 1,740 | 2.921875 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | #! /usr/bin/env python
#################################################################################
# File Name : Measurement_PythonToArduino.py
# Created By : lauriaclarke
# Creation Date : [2020-04-08 09:05]
# Last Modified : [2020-04-09 09:14]
# ... | true |
fd43f6af2fec8d52bb60102a2366733395c948bd | Python | goldphoenix90/Project3_WineQuality | /model.py | UTF-8 | 1,944 | 2.734375 | 3 | [] | no_license | # Importing the libraries
from numpy.random import seed
seed(1)
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import keras
import pickle
survey = pd.read_csv('Resources/winequality-red.csv')
X = survey.drop("quality", axis=1)
y = survey["quality"]
from sklearn.model_selection import train_... | true |
93241f3342733195517e3a0aa34e95a56d57b17d | Python | hewhocannotbetamed/HandyBeam | /build/lib/handybeam/cl_py_ref_code/hbk_lamb_grid_sampler.py | UTF-8 | 2,352 | 2.875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | ## This is python reference code for the opencl kernel _hbk_lamb_grid_sampler.
## Imports
import numpy as np
root_2 = 1.4142135623730951
tau = 6.283185307179586
medium_wavelength = 0.008575
def hbk_lamb_grid_sampler_ref(
required_resolution,
radius,
N,
x0,
y0,
z0
):
... | true |
a891e386a22ec869cfba6bd6c0944fc9336d9665 | Python | dtrckd/simplon_tssr_2021 | /exo5.py | UTF-8 | 559 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | #!/bin/python
import sys
#
# Add a SEP at the end of each line
#
path = sys.argv[1]
sep = sys.argv[2] # RFTM
def alter_file(path, sep):
f = open(path)
content = f.read()
f.close()
content = content.split("\n") # "salut ca va" -> ["salut", "ca", "va]
for i in range(len(content)):
content[i] = co... | true |
14ec2008be0eaa7c9be0156475245f17cd1ca140 | Python | tirhelen/ohtu-2021-viikko1 | /src/tests/varasto_test.py | UTF-8 | 2,508 | 3.171875 | 3 | [] | no_license | import unittest
from varasto import Varasto
class TestVarasto(unittest.TestCase):
def setUp(self):
self.varasto = Varasto(10)
def test_konstruktori_luo_tyhjan_varaston(self):
# https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual
self.assertAlmostEqual(s... | true |
dc638e1f808e5a178c5d96662735b9631ca9eb9a | Python | hehehexdd/Super-Ganio | /game_data/engine/entities/enemies.py | UTF-8 | 1,412 | 2.734375 | 3 | [
"CC0-1.0"
] | permissive | from game_data.engine.entities.base.entity import *
from game_data.engine.base.collisioninfo import *
class Enemy(Entity):
def __init__(self, hp, x, y, level_instance, images: dict, speed_x, initial_move_dir: int):
super().__init__(hp, x, y, level_instance, images, images['move'], speed_x)
self.scale_all_images_... | true |
d1ffdaf89f0b8861dec174cd8d50f6bb94ed66eb | Python | zhubinQAQ/CPM-R-CNN | /pet/utils/data/transforms/transforms_instance.py | UTF-8 | 3,350 | 2.515625 | 3 | [] | no_license | import cv2
import random
import torch
import torchvision
from torchvision.transforms import functional as F
class Box2CS(object):
def __init__(self, aspect_ratio, pixel_std):
self.aspect_ratio = aspect_ratio
self.pixel_std = pixel_std
def __call__(self, image, target):
target.box2cs(... | true |
45a7eb48f29e16609a8b8c7bc5ab2ef5de80f278 | Python | Aravindh15/FaceRecognition_In_RaspberryPi | /Code/face_IO.py | UTF-8 | 1,826 | 3.03125 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
# define the gpio
all_pin = [11,12,13,15]
buzzer = 12 # GPIO.1 (pin 12)
led_red = 11 # GPIO.0 (pin 11)
led_yellow = 13 # GPIO.2 (pin 13)
led_green = 15 # GPIO.3 (pin 15)
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(all_pin, GPIO.OUT)
GPIO.... | true |
fec1da7b7251652a3e0e23b7643ecf2527a31f37 | Python | sunilsm7/django_resto | /restaurants/validators.py | UTF-8 | 689 | 2.59375 | 3 | [
"MIT"
] | permissive | from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
def validate_even(value):
if value % 2 != 0:
raise ValidationError(
_('%(value)s is not an even number'),
params={'value': value},
)
def clean_email(self):
email = s... | true |
0369510f87d5785bbc12795e4cead99b0e167c5f | Python | LucDoh/CrowdRank | /scripts/crowdrank_simple.py | UTF-8 | 417 | 2.765625 | 3 | [
"MIT"
] | permissive | import sys
sys.path.append("..")
import os.path
import time
import pandas as pd
from crowdrank import ranker
def main():
'''Script to call crowdrank as simply as possible
python crowdrank_simple.py "keyword"'''
keyword = sys.argv[1]
skip = not (len(sys.argv) > 2 and sys.arg[2] == 0)
ranking_df = ... | true |
f00dd6772ef2cf5a2ad1f86e355549962f15d87d | Python | npkhanhh/codeforces | /python/round712/1504A.py | UTF-8 | 308 | 3.203125 | 3 | [] | no_license | from sys import stdin
for _ in range(int(stdin.readline())):
s = list(input().strip())
n = len(s)
res = 'NO'
for i in range(n):
if s[n-i-1] != 'a':
res = 'YES'
s.insert(i, 'a')
break
print(res)
if res == 'YES':
print(''.join(s))
| true |
215579d6d4a11d7f522b3e99826ab422660e706f | Python | ghleokim/codeTestProblems | /swExpertAcademy/q2056_calendar.py | UTF-8 | 577 | 3.28125 | 3 | [] | no_license | #q2056
num = int(input())
dayChart = {
31: [1,3,5,7,8,10,12],
30: [4,6,9,11],
28: [2]
}
def checkDate(year, month, day):
if int(month) > 12 or int(month) < 1 or int(day) < 1:
return -1
else:
for d, m in dayChart.items():
if (int(month) in m) and (int(day) <= d):
... | true |
fbd085e8d66fdfb4ee0822cf8ace50238e22b40c | Python | whyj107/Algorithm | /Programmers/20200807_가장 큰 수.py | UTF-8 | 1,176 | 3.9375 | 4 | [] | no_license | # 문제
# 가장 큰 수
# https://programmers.co.kr/learn/courses/30/lessons/42746?language=python3
# 나의 풀이
# 시간 초과
from itertools import permutations
def solution0(numbers):
tmp = [''.join(list(map(str, i))) for i in list(permutations(numbers, len(numbers)))]
tmp.sort()
return tmp[-1]
# string 비교 문제 풀이
def solutio... | true |
c02208e183ffad708e59d1a9dd37bc391d5bba6b | Python | ExperimentalHypothesis/flask-restful-web-api | /section13/tests/integration/test_user.py | UTF-8 | 1,156 | 2.53125 | 3 | [] | no_license | from models.user import UserModel
import pytest
from app import app
from db import db
@pytest.fixture(autouse=True)
def test_client_db():
# set up
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///"
with app.app_context():
db.init_app(app)
db.create_all()
testing_client = app.test_c... | true |
cf6b016d5360b6408c9b0955a22dd4e6604df4dd | Python | kayscott/Ch_9_Exercises | /using in to search.py | UTF-8 | 195 | 2.53125 | 3 | [] | no_license | # USING IN TO SEARCH
import os
f = open(os.path.expanduser('~/Desktop/*Filename*.txt'))
for line in f:
line = line.rstrip()
if not ' *keyword*' in line:
continue
print line | true |
2b3f38e20378b89a310b19f96e7a002ef1921611 | Python | Gengj/MNIST_LEARNING_CLASS | /MNIST_1.py | UTF-8 | 14,350 | 2.75 | 3 | [] | no_license | # -*- coding:utf-8 -*-
"""
-------------------------------------------------
@Author: GengJia
@Contact: 35285770@qq.com
@Site: https://github.com/Gengj
-------------------------------------------------
@Version: 1.0
@License: (C) Copyright 2013-2020
@File: ... | true |
deade78b2736a2d2090f1c71ea75c9d242f96746 | Python | lamine2000/ZCasino | /ZCasino.py | UTF-8 | 1,522 | 3.453125 | 3 | [] | no_license | from random import randrange
from math import ceil
from os import system, name
def clear():
# for windows
_ = system('cls') if name == 'nt' else system('clear')
if __name__ == '__main__':
continuer = 'o'
argent = 1000
while continuer == 'o':
print(f'Vous avez {argent}$')
miseAr... | true |
c46ccf4aacacbe46fd11578f1ed1177bda6d845d | Python | tobeeeelite/success | /tool.py | UTF-8 | 1,017 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/10/10 9:54
# @Author : zyg
# @Site :
# @File : tool.py
# @Software: PyCharm
import os
import shutil
def get_files(in_dir):
#print('get train_data files from '+exts)
files = []
if not os.path.exists(in_dir):
Va... | true |
2a2f2b87dc0411047a47a5e7b19186e6b29020f4 | Python | kiic-hub/MLDL | /Get_data.py | UTF-8 | 1,425 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# <a href="https://colab.research.google.com/github/minkh93/MLDL/blob/master/Get_data.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
import cv2
import numpy as np
import pandas as pd
import os
from sklearn.pr... | true |
8706cc1055eeadc3e6dbb82fb235465808146938 | Python | raphaelaffinito/rawPy | /RawPy/bayes.py | UTF-8 | 10,133 | 2.734375 | 3 | [] | no_license |
import gzip
import os
import sys
from time import time
import emcee
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import numpy as np
from matplotlib import gridspec
from scipy.stats import pearsonr
from six.moves import cPickle as pickle
class bayes_framework:
"""
API for the Bayesian in... | true |
28f981d366ecf9e4393fa71145ee27e1ce7f471a | Python | Kpavicic00/FDR | /apps/login_pages/league_apps/BFPD.py | UTF-8 | 14,046 | 2.53125 | 3 | [] | no_license | import streamlit as st
import pandas as pd
import numpy as np
from functions import *
from League_functions.BFPD_func import BFPD_base
from database import *
import altair as alt
from html_temp import *
import os
import time
def app():
create_BFPD()
st.title('1. function IFPA process function')
st.write('... | true |
3eae24814131168ae2489dbf20f26a7c282e313c | Python | Python3pkg/Cerebrum | /cerebrum/neuralnet/elements/neuron.py | UTF-8 | 3,203 | 2.546875 | 3 | [
"MIT"
] | permissive | import random
import itertools
import time
import signal
from threading import Thread
from multiprocessing import Pool
import multiprocessing
POTENTIAL_RANGE = 110000 # Resting potential: -70 mV Membrane potential range: +40 mV to -70 mV --- Difference: 110 mV = 110000 microVolt --- https://en.wikipedia.org/wiki/Membr... | true |
e44652d0e4e85676aea95ec8c2f6e3ab07d1d5bc | Python | JonnyCBB/RADDOSE-3D_GUI | /RaddoseInputWriter.py | UTF-8 | 3,682 | 2.59375 | 3 | [] | no_license | # these functions are designed to write RADDOSE-3D input files
# from the GUI output parameters
def writeCRYSTALBLOCK(currentCrystal):
raddose3dinputCRYSTALBLOCK = """
##############################################################################
# Crystal Block ... | true |
62bf756643693a58d0bb44b89296d373d70e20d9 | Python | ns-rokuyon/pytorch-webdataset-utils | /webdatasetutils/distributed.py | UTF-8 | 3,244 | 2.890625 | 3 | [
"MIT"
] | permissive | import torch
import random
import webdataset as wds
import warnings
from dataclasses import dataclass
from typing import Callable, List, Optional, Set
@dataclass
class DistributedShardInfo:
unavailable_urls: Set[str]
use_size_in_cluster: int
use_size_in_dataloader: int
n_urls_per_rank: int
n_urls_... | true |
ce2a84f84ba02677721f02bbce1628cc9df256b1 | Python | nralex/Python | /5-ExerciciosFuncoes/exercício05.py | UTF-8 | 868 | 4.03125 | 4 | [] | no_license | #####################################################################################################################
# Faça um programa com uma função chamada somaImposto. A função possui dois parâmetros formais: taxaImposto, que é #
# a quantia de imposto sobre vendas expressa em porcentagem e custo, que é o custo d... | true |
9fc7a44789523ad1d1edac8768f2445ee44789d5 | Python | tiangexiao/neural_network_code | /low_level_api/simple_linear_model.py | UTF-8 | 932 | 3.171875 | 3 | [] | no_license | """
定义两个可以更新的Variable:W和b
定义损失函数loss
使用迭代器更新loss
copy: https://github.com/MorvanZhou/tutorials/blob/master/tensorflowTUT/tf5_example2/full_code.py
"""
import numpy as np
import tensorflow as tf
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data * 0.1 + 0.3
Weights = tf.Variable(tf.random_uniform([1], -1.... | true |
048db1a1882d50906556d458e366ec4ebb2a0a12 | Python | johnisawkward/VRoidBones | /util.py | UTF-8 | 1,695 | 2.578125 | 3 | [
"Unlicense"
] | permissive | import bpy
def unique_constraint(bone, t):
for constraint in bone.constraints:
if constraint.type == t:
return constraint
constraint = bone.constraints.new(type=t)
return constraint
def get_children(parent):
l = []
for obj in bpy.context.scene.objects:
if obj.name == p... | true |
3d8a8582a7790488009cbe153942eb2e669c51cd | Python | apoorvaish/mujoco-rl | /evolutionary-strategies/dl.py | UTF-8 | 1,567 | 2.90625 | 3 | [
"MIT"
] | permissive | import numpy as np
class Network:
def __init__(self, D, M, K, action_max):
self.D = D
self.M = M
self.K = K
self.action_max = action_max
def init(self):
D, M, K = self.D, self.M, self.K
self.W1 = np.random.randn(D, M) / np.sqrt(D)
# self.W1 = np.... | true |
15831f5f23fa51836b6a577e864f34ab6c90a1c2 | Python | jaimetorresl/ProyectoProgramacion | /ECG.py | UTF-8 | 10,784 | 2.796875 | 3 | [] | no_license | # Importamos las librerías necesarias
import numpy as np
from scipy.signal import find_peaks
import matplotlib.pyplot as plt
import scipy.optimize as opt
import scipy.integrate as inte
# Definimos la función F1
def F1(y1,y2,Trr):
alpha = 1 - np.sqrt(y1**2 + y2**2)
return alpha * y1 - ((2.0*np.pi)/Trr)*y2
# D... | true |
4916e6c3d63b567e2492c46a4f563c02d94e3c21 | Python | DPBayes/DP-HMC-experiments | /metrics.py | UTF-8 | 3,480 | 2.890625 | 3 | [
"MIT"
] | permissive | import numpy as np
import numba
import timeit
def total_mean_error(samples, true_samples):
"""
Return the Euclidean distance between the means of two given samples.
"""
return np.sqrt(np.sum(component_mean_error(samples, true_samples)**2, axis=0))
def component_mean_error(samples, true_samples):
"... | true |
d9cfba658a2fbffe1ce616ac170ef4cba97f0178 | Python | frotaur/SmartFish | /Vect2D/unit2DVect.py | UTF-8 | 1,161 | 2.859375 | 3 | [] | no_license | import unittest
import Vect2D as v
class testVect(unittest.TestCase):
def testStr(self):
a = v.Vect2D((1,2))
self.assertEqual("(1,2)",str(a))
def testAddandEqual(self):
a = v.Vect2D((1,2))
b = v.Vect2D((2,6))
self.assertEqual(v.Vect2D((3,8)),a+b)
def testDot(self):
a = v.Vect2D((1,2))
b = v.Vect2D... | true |
65cd65a8e0fe21143247b3fa7764a5ce0ce7029d | Python | priteshmehta/automation_framework | /helpers/element.py | UTF-8 | 1,698 | 2.625 | 3 | [] | no_license | from selenium import webdriver
from selenium.common.exceptions import (InvalidElementStateException,
NoSuchElementException,
StaleElementReferenceException,
TimeoutException)
from selenium.webdriver.... | true |
6133573bf90afaf0980a9fb44e533731a202e7f9 | Python | jaraco/calendra | /calendra/america/el_salvador.py | UTF-8 | 576 | 2.734375 | 3 | [
"MIT"
] | permissive | from ..core import WesternCalendar
from ..registry_tools import iso_register
@iso_register('SV')
class ElSalvador(WesternCalendar):
"El Salvador"
# Civil holidays
include_labour_day = True
# Christian holidays
include_holy_thursday = True
include_good_friday = True
include_easter_saturday ... | true |
3572bcf71c21890c329436f91463020127e6692b | Python | avhirupc/LeetCode | /problems/Pattern : String/ZigZag Conversion.py | UTF-8 | 1,268 | 2.90625 | 3 | [] | no_license | from collections import deque
from itertools import cycle
class Solution(object):
def convert(self, s, numRows):
rows = deque([])
level = cycle(list(range(numRows))+list(range(numRows-2,0,-1)))
itr=0
while(itr<len(s)):
rows.append((s[itr],next(level)))
itr+=1... | true |
ba94de1f5da424d4c4d6f3e49dc4b9262e1ff79c | Python | PrajaktaSelukar/Sorting-Visualizer | /Quick Sort/sortingAlgorithms_new.py | UTF-8 | 3,878 | 3.328125 | 3 | [] | no_license | #Tkinter is used for developing GUI
from tkinter import *
from tkinter import ttk
import random
from BubbleSort import bubble_sort
from QuickSort import quick_sort
#create a random new array
#root is the name of the main window object
root = Tk()
root.title('Sorting Algorithm Visualizer')
#setting the mi... | true |
ec308cb6daaa212787cf93f7654c4aba4074b8c9 | Python | calazans10/algorithms.py | /data structs/using_tuple.py | UTF-8 | 392 | 3.546875 | 4 | [] | no_license | # -*- coding: utf-8
zoo = ('lobo', 'elefante', 'pinguim',)
print('O número de animais no zoo é', len(zoo))
novo_zoo = ('macaco', 'golfinho', zoo,)
print('O número de animais no novo zoo é', len(novo_zoo))
print('Todos os animais no novo zoo são', novo_zoo)
print('Os animais trazidos do antigo zoo são', novo_zoo[2])
p... | true |
c1bdc033889db970aa4ef1adff36cfe3604fda61 | Python | chaneyzorn/LeetCode-Python | /src/0070-climbing-stairs.py | UTF-8 | 559 | 2.921875 | 3 | [] | no_license | class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
prev, prev_prev, ans = 1, 1, 1
for i in range(2, n + 1):
ans = prev_prev + prev
prev, prev_prev = ans, prev
return ans
# def climbStairs(self, n):
... | true |
39e4c483a9ebca4b76758fe43b2e69fdfd23a4f7 | Python | gomerudo/auto-ml | /automl/createconfigspacepipeline/base.py | UTF-8 | 11,551 | 2.96875 | 3 | [] | no_license | from smac.configspace import ConfigurationSpace
from automl.utl import json_utils
class ConfigSpacePipeline:
"""This class deals with the creation and manipulation of configuration space from the given input pipeline.
In addition to getting the configuration spaces from the predefined json files, it a... | true |
ca593200019d08597eec5b1afed324d0112176c1 | Python | frankShih/LeetCodePractice | /870-advantageShuffle/solution.py | UTF-8 | 1,395 | 3.171875 | 3 | [] | no_license | class Solution:
def advantageCount(self, A, B):
"""
:type A: List[int]
:type B: List[int]
:rtype: List[int]
"""
A = sorted(A)
'''
# naive O(N^2), timeout
result=[None]*len(A)
visit = set()
for i in range(len(B)):
for... | true |
82d95379bd78b89514bd61b0b5d68f813bd4b8d7 | Python | sbthegreat/BrushSmart | /views/confirmScreen.py | UTF-8 | 1,518 | 3.515625 | 4 | [] | no_license | from tkinter import *
import constants
"""
This is a screen that draws the text "Are you sure?" which is used for the user to confirm if they wish to quit the program.
Down ⯆ - Yes, exit the program
Up ⯅ - No, return to the home screen
"""
def Draw(state):
state.canvas.create_text(constants.UP_NAV, text="NO", fill="... | true |
8e1280da4209164a6d438885b50dc13d033891b5 | Python | morenopep/inter-server | /interServer.py | UTF-8 | 450 | 3.109375 | 3 | [] | no_license | #!/usr/bin/python
import socket
print "Interagindo com FTP SERVER!"
ip = raw_input("Digite o IP: ")
porta = 21
meusocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
meusocket.connect((ip,porta))
banner = meusocket.recv(1024)
print banner
print "Enviando usuario"
meusocket.send("USER teste\r\n")
banner = meu... | true |
4eaee5e5a2c2bc0e560dfc9dce61221c9bb7c6d3 | Python | killswitchh/Leetcode-Problems | /Easy/valid-palindrome-II.py | UTF-8 | 347 | 3.15625 | 3 | [] | no_license | '''
https://leetcode.com/problems/valid-palindrome-ii/
'''
class Solution:
def validPalindrome(self, s: str) -> bool:
for i in range(len(s)//2):
if s[i] != s[len(s)-i-1]:
return s[:i]+s[i+1:] == (s[:i]+s[i+1:])[::-1] or s[:len(s)-i-1]+s[len(s)-i:] == (s[:len(s)-i-1]+s[len(s)-i:]... | true |
be647f5d248813bd03a348099fb373ed891643cc | Python | agk29/HandyScripts | /merge_tiff.py | UTF-8 | 1,067 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 12 10:14:26 2021
@author: akenny
Merge a selection of tiff files all in one folder
"""
import os, glob, rasterio
from rasterio.merge import merge
def merge_tiff(directory='', output_folder='', output_f='merged.tif'):
search_criteria = '*.tif'
q = os.path.join(di... | true |
e4d1f8747559c62e993fbb7e9d748443a81370f7 | Python | crempp/mdweb | /mdweb/Page.py | UTF-8 | 3,042 | 2.984375 | 3 | [
"MIT"
] | permissive | """MDWeb Page Objects."""
import codecs
import os
import re
import markdown
from mdweb.BaseObjects import NavigationBaseItem, MetaInfParser
from mdweb.Exceptions import (
ContentException,
PageParseException,
)
#: A regex to extract the url path from the file path
URL_PATH_REGEX = r'^%s(?P<path>[^\0]*?)(inde... | true |
db9413b90435c69113f9267f01fe50929fffe0a1 | Python | lyz05/Sources | /北理珠/python/《深度学习入门:基于Python的理论与实现》/深度学习入门:基于Python的理论与实现-源代码/test/test_load_mnist.py | UTF-8 | 386 | 2.53125 | 3 | [
"MIT"
] | permissive | import sys,os
sys.path.append(os.pardir)
from dataset.mnist import load_mnist
# 第一次调用会花费几分钟......
(x_train, t_train), (x_test, t_test) = load_mnist(flatten=True,normalize=False,one_hot_label=False)
# 输出各个数据的形状
print(x_train.shape) # (60000, 784)
print(t_train.shape) # (60000,)
print(x_test.shape) # (10000, 784)
print... | true |
206ac444a7f54282aea563d3a4449d43a28fabc4 | Python | jasonyjong/cs224u-wiki-generator | /pu_files/kmeans.py | UTF-8 | 767 | 2.609375 | 3 | [] | no_license | from sklearn import cluster
import evaluation as evaluation
def kmeansFunction(rawX, rawY, rawXTesting, rawYTesting):
X = [elem[0:1] for elem in rawX]
Y = rawY
senses = [elem[2] for elem in rawX]
words = [elem[3] for elem in rawX]
modelk = cluster.KMeans(n_clusters = 2)
modelk.fit(X)
# This pa... | true |
913d702aad2d2836d2263d15231a3ad3fa7ade4c | Python | Ram-N/Drop7 | /grid_utils.py | UTF-8 | 6,767 | 3.171875 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random
import cfg
def grid_of_ones(size=cfg._SIZE):
return np.ones((size,size), dtype=np.int)
def apply_gravity_to_column(column):
'''
An entire column is adjusted for 'gravity.' All the zeros float to the top.
All the ... | true |
b6762f57e56c1ba7a3dbfc4c50a6f55b8880f5a9 | Python | gagaspbahar/prak-pengkom-20 | /P04_16520289/P04_16520289_03.py | UTF-8 | 3,390 | 4.0625 | 4 | [] | no_license | # NIM/Nama : 16520289/Gagas Praharsa Bahar
# Tanggal : 2 Desember 2020
# Deskripsi: Problem 3 - Simetri Lipat dan Simetri Putar
# Kamus
# cekLipatVertikal = cek sb.vertikal
# cekLipatHorizontal = cek sb. horizontal
# cekDiagonalAtas = cek lipat diagonal yang arahnya keatas
# cekDiagonalBawah = cek lipat diagonal yang... | true |
b883867190ef9a24693e2b816c3d2d7e4985cafc | Python | futureimperfect/games | /hangman.py | UTF-8 | 2,343 | 3.796875 | 4 | [] | no_license | #!/usr/bin/env python
import urllib2
from random import randint
MAX_WRONG_GUESSES = 6
class Words(object):
def __init__(self):
self.url = 'http://www.mieliestronk.com/corncob_lowercase.txt'
self.words = self.httpGet(self.url).splitlines()
def httpGet(self, url):
r = urllib2.urlope... | true |
c0b5cf76ebc852b5345ea93b97b7bad2243ab588 | Python | kaka-lin/pyqt-image-recognition | /models/binarized_utils.py | UTF-8 | 3,354 | 2.859375 | 3 | [
"MIT"
] | permissive | import warnings
warnings.filterwarnings("ignore")
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable, Function, gradcheck
import numpy as np
def Binarize(tensor, quantization_model='deterministic'):
if quantization_model == 'deterministic':
return tensor... | true |
2812b122cb5acdeeab460bfef319b37fb3f333ea | Python | zhanggong0564/TF2-YOLOV4 | /utils__/show_box.py | UTF-8 | 3,906 | 2.59375 | 3 | [] | no_license | import numpy as np
import cv2
from utils__.utils import get_aim
from utils__.viduslizer import *
'''
1.得到了 image, boxes, labels, probs, class_labels
2.根据probs的高低阈值筛选
返回box和scores和每个框的类别
3.opencv将box和分数和类别画到image上并且返回物体的box和分数
'''
'''
果子类别对应区间
[1-100]苹果
[101-200]橙子
[201-300]梨子
[301-400]青苹果
'''
colors = [
(0,255,... | true |
7e3ccf52be37215adac3b07dd15f46a1a162106e | Python | cdpetty/one | /logger.py | UTF-8 | 280 | 3.1875 | 3 | [] | no_license | import sys
def log(*statements):
phrase = ' '.join(map(str, statements)) + '\n'
sys.stdout.write(phrase)
sys.stdout.flush()
def die(statement):
sys.stderr.write('One: error: ' + statement + '\n')
sys.exit(1)
def end(statement):
log(statement + '\n')
sys.exit(0)
| true |
1d8c5708ed9a11e976f1ddb1ef80313ad2e75d7d | Python | saurabhkulkarni77/Echo-updated | /sentiment_analysis.py | UTF-8 | 1,159 | 2.71875 | 3 | [] | no_license | from flask import Flask, render_template, request, jsonify
from lib.classifier import Classifier
from lib.examples import Examples
import threading
print(" - Starting up application")
lock = threading.Lock()
app = Flask(__name__)
class App:
__shared_state = {}
def __init__(self):
self.__dict__ = self.... | true |