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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bcc19f7a10ba031740bbf674176f4414eaa094a1 | Python | jsbed/Design-III-Robot | /Robot/locators/contour/contours_finder.py | UTF-8 | 1,145 | 2.75 | 3 | [] | no_license | import cv2
import numpy
def find_extracted_shape_contour(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
contours = cv2.findContours(gray, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[1]
return contours
def find_cube_corners_contours(img):
gray = cv2.cvtColor(img, cv2.... | true |
58ef1d126b08ec8ff06432e444b111e3b564cfe3 | Python | ArnabBasak/PythonRepository | /python programs/python alphabetic order.py | UTF-8 | 144 | 3.8125 | 4 | [] | no_license | # python program for alphabetic order
my_string = input("enter any string")
words = my_string.split()
words.sort()
for i in words:
print(i) | true |
f6cbc2147e794e612c6242684dddecaf56b07b17 | Python | sestevez/HLT-Opt | /hltopt/utils.py | UTF-8 | 1,044 | 3.9375 | 4 | [
"MIT"
] | permissive | def pow2value(number):
"""Devuelve una lista de potencia de 2 hasta el número pasado"""
n = 1
while n<number:
n = 2*n
yield n
def pow2(exp):
"""Devuelve una lista de potencia de 2 con el exponente pasado"""
n = 1
e = 1
while e<=exp:
n = 2*n
e += 1
yie... | true |
88d98bde1d93fbd7d2201959355f1fa9f914a28a | Python | harshitpoddar09/InterviewBit-Solutions | /Programming/Math/Base Conversion/Excel Column Title.py | UTF-8 | 245 | 3.3125 | 3 | [] | no_license | class Solution:
# @param A : integer
# @return a strings
def convertToTitle(self, A):
ans=''
while A:
A=A-1
i=A%26
ans=chr(i+65)+ans
A=A//26
return ans | true |
f62641462600e9f84ad2307c1013c2dd80f7ae5f | Python | hangelwen/Bayesian-Optimization-with-Gaussian-Processes | /examples/visualization.py | UTF-8 | 9,190 | 2.84375 | 3 | [] | no_license | # Python 2.7 users.
from __future__ import print_function
from __future__ import division
import numpy
import matplotlib.pyplot as plt
from math import log, fabs, sqrt, exp
from bayes_opt.bo.bayes_opt import bayes_opt
from bayes_opt.bo.GP import GP
from bayes_opt.support.objects import acquisition
# ----------------... | true |
e51ea2b3da54ea5f978433febe002f116c6ee290 | Python | markgreene74/bitesofpy | /bytes/129/exercise_129.py | UTF-8 | 1,920 | 3.3125 | 3 | [] | no_license | import requests
from collections import defaultdict
STOCK_DATA = "https://bit.ly/2MzKAQg"
# pre-work: load JSON data into program
with requests.Session() as s:
data = s.get(STOCK_DATA).json()
# your turn:
def _cap_str_to_mln_float(cap):
"""If cap = 'n/a' return 0, else:
- strip off le... | true |
8833632354eef0f3f4eee1f256abf4f16afac8c7 | Python | forswj/TestPython | /forspider/do_five.py | UTF-8 | 1,258 | 3.109375 | 3 | [] | no_license | # coding:utf-8
'''
Created on 2016年10月14日
@author: Administrator
'''
import requests
import os
import re
#目录
def do_mkdir(dirth):
if not os.path.isdir(dirth):
os.mkdir(dirth)
print("不存在该目录")
else:
print("已存在该目录,可存储图片")
#获取url
def get_html(url):
html = r... | true |
98013fc523203ebbb1857c8cbd1ea529d25dc253 | Python | jiaxinr/ProjectOfDataScience | /其他代码/tf-idf/keywords-tfidf.py | UTF-8 | 6,470 | 3 | 3 | [] | no_license | import datetime
import math
import os
import sys
import jieba
import re
def segment(sentence, cut_all=True):
sentence = re.sub('[a-zA-Z0-9]', '', sentence.replace('\n', '')) # 过滤
sentence = sentence.replace('用户:', '')
sentence = sentence.replace('点赞数:', '')
return jieba.lcut(sentence, cut_all=cut_al... | true |
73a268c49c314a29ce7bf759bb1e729346584c4a | Python | Pandinosaurus/arsenal | /arsenal/maths/stats/permutation_test.py | UTF-8 | 2,980 | 3.390625 | 3 | [] | no_license | import numpy as np
def mc_perm_test(xs, ys, samples=10000, statistic=np.mean):
def effect(xs,ys): return np.abs(statistic(xs) - statistic(ys))
n, k = len(xs), 0.0
diff = np.abs(np.mean(xs) - np.mean(ys))
zs = np.concatenate([xs, ys])
for _ in range(samples):
np.random.shuffle(zs)
k... | true |
df63444dc4c919df68ae0715fef3d6a3592251a4 | Python | Mzleesir/lewin | /day13_面向对象/day1_面向对象_02属性.py | UTF-8 | 322 | 3.421875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2021/2/10 8:11 下午
# @Author : Lewin
# @FileName: day1_面向对象_02属性.py
# @Software: PyCharm
# 类和对象的特征数据称之为属性
class Point:
name = "点" # 定义一个类属性
"""
表达平面坐标系里的一个点
"""
print(Point.name)
| true |
bf87455a4696e7de5fb0a1ad18a0cb20ef182f9f | Python | SKO7OPENDRA/gb-algorithm | /hw/hw_4/hw_4_1_v3.py | UTF-8 | 583 | 2.8125 | 3 | [] | no_license | import cProfile
import timeit
from random import random
def m_array():
N = 15
arr = [] * N
for i in range(N):
arr.append(int(random() * 100))
print(arr[i], end=' ')
print()
imx = arr.index(max(arr))
imn = arr.index(min(arr))
min_m_array = min(arr)
max_m_array = max(arr... | true |
0eed2ee16cd334a8719a59f861e702b74f20e3a0 | Python | inverseTrig/leet_code | /1537_get_the_maximum_score.py | UTF-8 | 848 | 3.21875 | 3 | [] | no_license | from typing import List
class Solution:
def maxSum(self, nums1: List[int], nums2: List[int]) -> int:
intersection = list(set(nums1).intersection(nums2))
intersection.sort()
intersection = [0] + intersection + [0]
max_score = 0
for i in range(1, len(intersection)):
... | true |
632e3d1ef8b441a7a957b9962cae133e872f8660 | Python | zeroTwozeroTwo/MyNoteBook | /Python/Example/05_高级数据类型/ex_02_del关键字.py | UTF-8 | 454 | 4.4375 | 4 | [] | no_license | name_list = ["张三", "李四", "王五"]
# del 关键字 可以删除列表中的元素
# 提示: 在日常开发中,要从列表中删除数据,建议使用列表提供的方法
del name_list[1]
# del 关键字本质上的用来将一个变量从内存中删除的
name = "小明"
del name
# 注意: 如果使用 del 关键字将变量从内存中删除
# 后续的代码就不能再使用这个变量了
print(name)
print(name_list)
| true |
c861714375aff2d63beb0201b90153e1eb2f3fa5 | Python | joshsilverman/sk_analytics | /estimators/utils/imputer.py | UTF-8 | 1,886 | 2.90625 | 3 | [] | no_license | from IPython import embed
import numpy as np
from sklearn import preprocessing
import operator
class Imputer:
def __init__(self):
self._modes = None
def impute_continuous(self, training_features_cont, features_cont):
sklearn_imputer = preprocessing.Imputer(missing_values='NaN', strategy='mean'... | true |
18a65ada67939334e538f769e07f3a912c62176c | Python | jboegeholz/easypattern | /easy_pattern/easy_pattern.py | UTF-8 | 1,003 | 3.5 | 4 | [
"MIT"
] | permissive |
ANY_CHAR = '.'
DIGIT = '\d'
NON_DIGIT = '\D'
WHITESPACE = '\s'
NON_WHITESPACE = '\S'
ALPHA = '[a-zA-Z]'
ALPHANUM = '\w'
NON_ALPHANUM = '\W'
def zero_or_more(string):
return string + '*'
def zero_or_one(string):
return string + '?'
def one_or_more(string):
return string + '+'
def exactly(number, st... | true |
15fce279085f1704cdd011328541533190462605 | Python | 1040891015/PythonPractice | /matplotlib/test.py | UTF-8 | 100 | 2.796875 | 3 | [] | no_license | import numpy
num = 0
numpy.random.seed(5)
while(num<5):
print(numpy.random.random())
num+=1 | true |
307eb5fbe782d4dfcfcd7c8134ba2b9201185893 | Python | tohfaakib/python_playground | /coroutines/example.py | UTF-8 | 345 | 3.171875 | 3 | [] | no_license | def grep(pattern):
print("Searching for pattern: ", pattern)
while True:
line = (yield)
if pattern in line:
print(line)
search = grep('tin')
next(search)
search.send("How are you tintin?")
search.send("You like tantin?")
search.send("I don't know!")
search.send("You like corouti... | true |
67ac17f261c1ecbf173847b2cb30f68089b8c85a | Python | ameli/imate | /examples/plot_traceinv_ill_conditioned_cheb.py | UTF-8 | 14,845 | 2.59375 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #! /usr/bin/env python
# SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileType: SOURCE
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the license found in the LICENSE.txt file in the root
# d... | true |
e065325308e23ae69ac2a19fed8f519a0fd34f88 | Python | spiritdan/dingdingAutoClockIn | /dingding_V2/test_timer.py | UTF-8 | 1,678 | 2.609375 | 3 | [] | no_license | import schedule
import time
import holiday as holiday, DingDing as Ding
import configparser
import check_holiday
config = configparser.ConfigParser(allow_no_value=False)
config.read("dingding.cfg",encoding='utf-8')
directory = config.get("ADB","directory")
gowork_time=config.get("time","go_time")
offwork_time=config.g... | true |
50ebac5ae65233e4186c92333087b248f942eb35 | Python | vvthakral/Python_code_learn | /merge_sort.py | UTF-8 | 774 | 3.53125 | 4 | [] | no_license | def merge_sort(arr):
c = len(arr)//2
if c>=1:
l = arr[:c]
r = arr[c:]
l = merge_sort(l)
r = merge_sort(r)
else:
return arr
p_l,p_r = 0,0
arr = []
while True:
if p_l < len(l) and p_r < len(r):
if l[p_l]<r[p_r]:
... | true |
a2c5480439b2903c5127471273c0b6f4b2e238b0 | Python | cdcai/autism_surveillance | /src/stuff/metrics.py | UTF-8 | 4,642 | 2.828125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-us-govt-public-domain",
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | import pandas as pd
import numpy as np
from sklearn.metrics import f1_score, accuracy_score, confusion_matrix
from sklearn.metrics import precision_score, recall_score
from scipy.stats import chi2
# Quick function for thresholding probabilities
def threshold(probs, cutoff=.5):
return np.array(probs >= cutoff).ast... | true |
1032c4fd109a7421505dd910c16540ed384260e6 | Python | FredCox3/public-jss | /PSU 2015 Casper API Examples/Python/jss_DuplicateFromFilePSU.py | UTF-8 | 6,782 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/python3
import sys
import requests
import argparse
import time
import json
import csv
import xml.etree.cElementTree as ET
jssURL = "https://jssurl.com:8443"
class ArgParser(object):
def __init__(self):
parser = argparse.ArgumentParser(description="JSS Duplicate Cleanup.", epilog="You can... | true |
4fb9449998b845152867ffd7bfd9b68aeba4e21c | Python | NIKHILDUGAR/leetcodemonthlyQs | /August2020/Day 12.py | UTF-8 | 220 | 2.9375 | 3 | [] | no_license | class Solution:
def getRow(self, rowIndex: int) -> List[int]:
l = [1]*(rowIndex + 1)
for i in range(1, rowIndex):
for j in range(i, 0, -1):
l[j] += l[j-1]
return l
| true |
5f1d6ca2c180f106189d576ee4ad4b7e0a717e7d | Python | alephist/edabit-coding-challenges | /python/test/test_is_average_whole_number.py | UTF-8 | 634 | 3.203125 | 3 | [] | no_license | import unittest
from typing import List, Tuple
from is_average_whole_number import is_avg_whole
test_values: Tuple[Tuple[List[int], bool]] = (
([3, 5, 9], False),
([1, 1, 1, 1], True),
([1, 2, 3, 4, 5], True),
([5, 2, 4], False),
([11, 22], False),
([4, 1, 7, 9, 2, 5, 7, 2, 4], False)
)
cla... | true |
215d6834c9d427e767d5881218a52e53ebd47e75 | Python | jieya907/animal_head | /main.py | UTF-8 | 1,963 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | true |
e86dd9f64232ac107d3d19f689f82ccf3c3475b5 | Python | Pamtzo/GMM | /imagen.py | UTF-8 | 1,422 | 3.125 | 3 | [] | no_license | from PIL import Image
import os
data=open("dataset256.txt",'a')
data.write("RED,GREEN,BLUE,NUMERO,ESTILO\n")
data.close()
data=open("dataset512.txt",'a')
data.write("RED,GREEN,BLUE,NUMERO,ESTILO\n")
data.close()
def datagen(directory, etiqueta,size):
paso=0
for name in os.listdir(directory):
... | true |
604c1e332a798b4771421bef59dc175775767089 | Python | anushas123/spectral | /spectral-subtraction-master/ss1.py | UTF-8 | 1,875 | 2.921875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | # coding: utf-8
# spectral subtraction: one of noise reduction method
# This is a simple python script, is not advanced one.
#
# Usage:
# specify wav file names below,
# infile: input wav file including noise
# outfile: output wav file
# noisefile: noise only wav fil... | true |
193e1f4098abe5a47d17eecf10d22cc96a023816 | Python | parthoza08/python | /ch-9_prq2.py | UTF-8 | 447 | 3.125 | 3 | [] | no_license | def game ():
pass
usrscore = int(input("enter your score\n"))
with open("highscore.txt") as f:
hiscore=f.read()
if hiscore=="":
with open("highscore.txt", "w") as new:
new.write(str(usrscore))
print("congo got first highscore", usrscore)
elif usrscore>int(hiscore):
with open("highscore.tx... | true |
6456b0e649d38e2156abc260fd8c4876abb27d78 | Python | omer-goder/python-skillshare-beginner | /dictionary/looping_through_a_dictionary(2).py | UTF-8 | 377 | 4.09375 | 4 | [] | no_license | ### 24/04/2020
### Author: Omer Goder
### Other ways to loop through a dictionary
birthday_months = {
'tony' : 'november',
'pat' : 'june',
'mary' : 'may',
}
for name in birthday_months.keys():
print(name.title())
for month in birthday_months.values():
print(month)
print(birthday_months.keys())
... | true |
d83f6caeb742f2b199f74fac44de3ddb36f495be | Python | MoisesFreitas1/Algoritmos-e-Estrutura-de-Dados | /Q9.py | UTF-8 | 306 | 3.5625 | 4 | [] | no_license | num1 = [0,0]
num1[0] = float(input("1o. número: "))
num1[1] = float(input("2o. número: "))
aux = 0
for i in range(0,2):
for j in range(0,2):
if num1[i]<num1[j]:
aux = num1[i]
num1[i] = num1[j]
num1[j] = aux
sub = num1[1] - num1[0]
print("Subtracao: ",sub)
| true |
428870adc7cb3fe7fb28181ac3db9f0ae4124e49 | Python | Morvram/SingleTransferrableVote | /Single_Transferrable_Vote/VoterGenerationAlgorithm.py | UTF-8 | 4,404 | 3.546875 | 4 | [] | no_license | #Joshua Mandell
from District import *
def voterGenerationAlgorithm(districts, numVoters, candidatesPerDistrict, choiceVotesForCandidates): # first draft
#districts = a list (1d) of district names
#numVoters = a list (1d) of the number of voters in each district.
#candidatesPerDistrict = a list (2d) of... | true |
0a84fda111a4bd6bd61c485a7426956b8e5554d0 | Python | Creditas/messengerbot | /messengerbot/quick_replies.py | UTF-8 | 1,413 | 2.921875 | 3 | [] | no_license | class QuickReplyItem(object):
def __init__(self, content_type, title=None, payload=None, image_url=None):
if content_type == 'text':
if not title and not payload:
raise ValueError('<Message> must be set')
if len(title) > 20:
raise ValueError('Quick reply titl... | true |
5e595c282884dffcf84dc85895509c571d9369ff | Python | judyfun/python | /db-example/python2/Common.py | UTF-8 | 537 | 3.078125 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
import datetime
def formatDate(date, hour):
date = date.replace('-', '')
hour = hour[:2]
return date, hour
# 2019-11-12-18
def last_hour2():
last = (datetime.datetime.now() - datetime.timedelta(hours=1)).strftime("%Y-%m-%d-%H")
print(last)
return last
... | true |
270daebf61050d6b58031d8722550711dffe61e8 | Python | LucasAVasco/datalogger-tensao-de-rede | /interface/main.py | UTF-8 | 752 | 3.046875 | 3 | [] | no_license | #!/usr/bin/python3.8
# coding=UTF-8
"""
Código principal.
Lee o arquivo de configuração 'config.txt' e os dados do diretório 'data/'
e gera os gráficos no diretório 'interface/'.
"""
# Modules
import modules.readFile as readFile
import modules.configClass as configClass
import modules.interface as interface
# Op... | true |
01f9504efacdecbe205251ed55087e20a55f85f8 | Python | naponmeka/timeseries_final_project | /dba.py | UTF-8 | 2,899 | 2.609375 | 3 | [] | no_license | from math import *
from scipy.optimize import basinhopping
import sys
import time
import statistics
import matplotlib.pyplot as plt
from computeAccuracy import *
start = time.time()
train_filename = 'Trace_ALL'
test_filename = 'Beef_TEST'
f = open('ClassificationClusteringDatasets/' + train_filename)
data_train = []
t... | true |
23f04b52842ec6a6b33274989a0849dcebbdce3b | Python | dyrroth-11/Information-Technology-Workshop-I | /Python Programming Assignments/Final Assignment/4.py | UTF-8 | 956 | 4.53125 | 5 | [] | no_license | #!/usr/bin/env python3
"""
Created on Fri Jun 19 10:22:12 2020
@author: Ashish Patel
"""
"""
Question: Write a python program using a given string “S” and width “W” to wrap the string “S”
into a wordof width “W”. Also, print the first and last character of each word in a
string of two characters.
Example
I... | true |
ea4d4463e92b3c45398002737319c0fc9e46322a | Python | cpt-r3tr0/mathematics | /Number Theory/GCDProduct.py | UTF-8 | 381 | 2.828125 | 3 | [] | no_license | #!/bin/python3
N, M = map(int, input().split())
lim = min(N,M) + 1
mark = bytearray(lim >> 1)
primes = [2]
for i in range(3,lim,2):
if mark[i>>1]: continue
primes.append(i)
for j in range(3*i,lim,2*i):
mark[j>>1] = 1
mod = 10**9 + 7
prod = 1
for p in primes:
q = p
while q < lim:
prod = (prod... | true |
39e7089de5a8087be82547032fe96e20a7a0d0c5 | Python | enrikiko/Python | /9.Intermediate/Spyder/Artificial_Neural_Networks/4init.py | UTF-8 | 2,777 | 2.59375 | 3 | [] | no_license | from joke import save
from request import sendHttp
import time
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
startDate={ "Start" : time.time(),
"Version" : "4init.py" }
sendHttp(startDate)
# Importing the dataset
dataset = pd. read_csv('Churn_Modelling.csv')
x = dataset.iloc[:, 3:13].val... | true |
3ccc6e284b09e5bbd13b007f30ccd4c4b138bfb3 | Python | jorgemauricio/alermapweb | /algoritmos/generar_mapas.py | UTF-8 | 8,104 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
#######################################
# Script que permite la generación de mapas
# meteorológicos extremos
# Author: Jorge Mauricio
# Email: jorge.ernesto.mauricio@gmail.com
# Date: Created on Thu Sep 28 08:38:15 2017
# Version: 1.0
#################################... | true |
633471013c72a55c11a4e2a699ea212ecde87da9 | Python | alfredez/Half-Duplex | /File.py | UTF-8 | 898 | 3.328125 | 3 | [] | no_license | #!/usr/bin/python
class File:
def __init__(self, filename):
self.filename = filename
self.lines = []
self.dab_id = 0
self.message_type = 0
def set_lines(self, path):
my_lines = [] # Declare an empty list named mylines.
with open(str(path+self.filename), 'rt') a... | true |
b3a0380790ea947e2c3e87a3b474aff519f61857 | Python | Funcan/runonnode | /runonnodes.py | UTF-8 | 1,273 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python
from noderange import expand
from nodeutils import NodeConnection
import sys
import paramiko
from paramiko import SSHException
import getpass
import argparse
def runonnodes(nodespec, cmd, dshbak=False, verbose=False, user=None):
nodes = expand(nodespec)
if len(nodes) == 0:
print... | true |
72ade6dd938a3c0656e0bb46167212c6867267ef | Python | weishaodaren/ShamGod | /Basic/condition.py | UTF-8 | 610 | 3.71875 | 4 | [
"MIT"
] | permissive | username = input('请输入用户名:')
password = input('请输入密码:')
if username == 'admin' and password == '123456' :
print('Success')
else:
print('Fail')
x = float(input('x = '))
if x > 1:
y = 3 * x - 5
elif x>= -1:
y = x + 2
else:
y = 5 * x + 3
print('%.2f = %.2f' % (x, y))
a = float(input('a = '))
b = floa... | true |
254d58f4c2e635cf7d0f37ed669fa038fa628ab5 | Python | beevelop/corona-calculator | /models.py | UTF-8 | 5,279 | 3.171875 | 3 | [
"MIT"
] | permissive | import itertools
import pandas as pd
_STATUSES_TO_SHOW = ["Infected", "Dead", "Need Hospitalization"]
def get_predictions(
cases_estimator, sir_model, num_diagnosed, area_population, max_days
):
true_cases = cases_estimator.predict(num_diagnosed)
# For now assume removed starts at 0. Doesn't have a hu... | true |
4d7ffb70bb211e764e13e3d47d1d7c2aaa612669 | Python | kabirecon/econometrics_with_python | /econometrics/chunk.py | UTF-8 | 622 | 3.15625 | 3 | [] | no_license | # this loads the first file fully into memory
with open('G:\code\dta.csv', 'r') as f:
csvfile = f.readlines()
linesPerFile = 1000000
filename = 1
# this is better then your former loop, it loops in 1000000 lines a peice,
# instead of incrementing 1000000 times and only write on the millionth one
for i in r... | true |
f068bc50306950e55f23d8ec4f68e9f3a7524cd3 | Python | ctralie/GeometricBeatTracking | /TheoryValidation/CirculantGraphs.py | UTF-8 | 2,327 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
import matplotlib.pyplot as plt
import scipy.sparse as sparse
import sys
sys.path.append("..")
from Laplacian import *
def getCirculantAdj(N, lags):
#Setup circular parts
I = range(N)*(len(lags)+2)
J = range(1, N+1) + range(-1, N-1)
J[N-1] = 0
J[N] = N-1
for lag in lags:
... | true |
02770ec5d9b47f810ae2faa0839dc09d5c9b685b | Python | asmitbhantana/Insight-Workshop | /PythonProgrammingAssignmentsI/Data Types/q43.py | UTF-8 | 336 | 3.671875 | 4 | [] | no_license | """
43. Write a Python program to remove an item from a tuple.
"""
def remove_item(user_tuple: tuple, remove_item):
bake_tuple = ()
for item in user_tuple:
if item is not remove_item:
bake_tuple += (item,)
return bake_tuple
if __name__ == '__main__':
print(remove_item((1, 2, 3, ... | true |
fcbe5b762ef621d5a75041fcf433cd1edded6367 | Python | wangfeng351/Python-learning | /语法基础/practise/day02.py | UTF-8 | 178 | 3.53125 | 4 | [] | no_license | str = '''Hello Python
I have a dream
that's I want to be a good programmer'''
a = "10"
b = "20"
if a > b:
print("no")
else:
print(str)
print("yes") | true |
5322b98bf1e03fe35cf9dfc3d367194d26f83e4b | Python | robpedersendev/Computer-science-assessment | /uncover_spy-Robert_Pedersen/main.py3 | UTF-8 | 1,837 | 3.5 | 4 | [
"MIT"
] | permissive | def uncover_spy(n, trust):
# The spy, if it exists:
# Does not trust anyone else.
# Is trusted by everyone else (he's good at his job).
# Works alone; there are no other spies in the city-state.
# Create the trusted and not trusted containers
trusted = {}
not_trusted = set(... | true |
51b54d6946bd6608fb22fa513f2f279e921a3ad5 | Python | detcitty/100DaysOfCode | /python/unfinshed/dig_ng.py | UTF-8 | 959 | 3.875 | 4 | [] | no_license | # https://www.codewars.com/kata/566fc12495810954b1000030/train/python
'''
Take an integer n (n >= 0) and a digit d (0 <= d <= 9) as an integer.
Square all numbers k (0 <= k <= n) between 0 and n.
Count the numbers of digits d used in the writing of all the k**2.
Call nb_dig (or nbDig or ...) the function taking n an... | true |
27236a4da2d52a5f820be5ba150f1665d79fe906 | Python | unistra/eva | /mecc/apps/utils/docx.py | UTF-8 | 11,579 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | from django.db.models import Q
from docx import Document
from docx.shared import Cm
from bs4 import BeautifulSoup as bs
from mecc.apps.rules.models import Rule, Paragraph
from mecc.apps.training.models import Training, SpecificParagraph, AdditionalParagraph
def docx_gen(data):
"""
Microsoft Word docx documen... | true |
6a9a17f190aa454509f539897ed61c6f97039dbb | Python | strawsyz/straw | /my_cv/famous_netorks/Inceptionv3_pytorch/models.py | UTF-8 | 11,813 | 2.578125 | 3 | [
"MIT"
] | permissive | import torch
from torch import nn
from torch.nn import functional as F
# 参考torchvision中的实现
class Inception3(nn.Module):
def __init__(self, n_classes=1000, aux_logits=True, transform_input=False):
"""
:param n_classes: 输出的参数
:param aux_logits: 使用添加辅助输出层
:param transform_input: 是否需... | true |
14b2e7528f3fd85be391b1f2531143f621dd95c6 | Python | CFM-MSG/Code_JFSE | /losses.py | UTF-8 | 5,860 | 3.03125 | 3 | [] | no_license | # Copyright 2016 The TensorFlow Authors All Rights Reserved.
#
# 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 applicab... | true |
52869bfb0138a91d4f1d6f3f1d6ab8036e8cbcf2 | Python | CurtinCen/a-new-test-project | /src/test_script.py | UTF-8 | 230 | 2.546875 | 3 | [] | no_license | import math
import random
road_num = 686105
fname = 'result.txt'
with open(fname, 'w') as fout:
for i in range(road_num):
#r = random.randint(1, 3)
#fout.write("%d:%d\n"%(i+1, r))
fout.write("1\n")
| true |
2724092318d3e3f66a6cbf97ce26cf0e4d0b848e | Python | Aasthaengg/IBMdataset | /Python_codes/p03254/s155367407.py | UTF-8 | 243 | 2.703125 | 3 | [] | no_license | n, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
if sum(A) < x:
cnt = -1
else:
cnt = 0
for a in A:
x -= a
if x >= 0:
cnt += 1
if x <= 0:
print(cnt)
exit()
print(cnt) | true |
8c0dd9960eff76af733bcc3c9424001d0f3dd032 | Python | LawrenceGao0224/LeetCode | / Merge_Intervals.py | UTF-8 | 629 | 3.3125 | 3 | [] | no_license | # 56. Merge Intervals
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
temp = []
merge = []
intervals.sort()
merge = intervals[0]
for i in range(1, len(intervals)):
# [0,4], [2,3]
if merge[0] <= intervals[i][0] and merge[... | true |
b06172f684c812229ac8eecbee3385a3b01ff643 | Python | nauman-zahoor/imdb-data-dashboard | /wrangling_scripts/wrangle_data.py | UTF-8 | 3,513 | 3.4375 | 3 | [] | no_license | import pandas as pd
import plotly.graph_objs as go
# Use this file to read in your data and prepare the plotly visualizations. The path to the data files are in
# `data/file_name.csv`
def return_figures():
"""Creates four plotly visualizations
Args:
None
Returns:
list (dict): list contai... | true |
e4af571b01b525ed0d098c3178dafaa71bf32d64 | Python | 20c/confu | /src/confu/schema/inet.py | UTF-8 | 8,225 | 3.078125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | """
Attributes that deal with networking specific values such as emails, urls and ip addresses
These can be imported directly from `confu.schema`
## Requirements
- `ipaddress` for ip address validation
"""
from __future__ import annotations
import ipaddress
import re
from typing import Any
from urllib.parse import... | true |
e5889d814a222edc7b97b6c493b22255ada4c8bc | Python | Soumick-Pyne/Quant101 | /Getting Data/yahoofin_intro.py | UTF-8 | 307 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 15:07:24 2020
@author: User
"""
from yahoofinancials import YahooFinancials
ticker = "MSFT"
#creating object
yahoo_financials = YahooFinancials(ticker)
data = yahoo_financials.get_historical_price_data("2018-04-24","2020-04-24","daily")
| true |
ae60871ad12e71138a7a67bc236080bdf397e1d7 | Python | shubhamrocks888/python_oops | /class_vs_static_method.py | UTF-8 | 3,410 | 4.71875 | 5 | [] | no_license | ## class method vs static method in Python
'''Class Method'''
A class method receives the class as implicit first argument, just like an instance method receives the instance.
Syntax:
class C(object):
@classmethod
def fun(cls, arg1, arg2, ...):
... | true |
8b26a1720e11a851c8b9f1021b4fc93d0d65e82e | Python | sreejith-mq/prashantassignment | /training/training1.py | UTF-8 | 3,753 | 2.890625 | 3 | [] | no_license | import cv2
import numpy as np
import os
from random import shuffle
from tqdm import tqdm
import tflearn
import tensorflow as tf
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.es... | true |
a4d4b5114e4ddcd2f71b4e1526bc6734a188caf5 | Python | firemeadow/DL_Final | /stock_gan.py | UTF-8 | 2,922 | 2.546875 | 3 | [] | no_license | import torch
import torch.nn as nn
import torch.optim as optim
import pandas as pd
import numpy as np
import matplotlib as plt
from gen import Generator
from disc import Discriminator
from steig import *
def discriminator_loss(real_output, fake_output, loss):
real_target = torch.ones(np.shape(real_output))
fa... | true |
c83accc05097718a0ea4b6317433d85f51428dea | Python | wapor/euler | /42_coded_triangle_numbers.py | UTF-8 | 1,076 | 4.09375 | 4 | [] | no_license | #!/usr/bin/python
# The nth term of the sequence of triangle numbers is given by, t(n) = n(n+1)/2;
# so the first ten triangle numbers are:
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
# By converting each letter in a word to a number corresponding to its
# alphabetical position and adding these values we form a word ... | true |
3a6603bae888bed4314c550a8a169f9d7848d6e7 | Python | afsneto/Sispot | /le_arquivo_zw_lis_rev04.py | UTF-8 | 16,314 | 3.03125 | 3 | [] | no_license | """
Arquivo para leitura de saída do line constants do ATP quando solicitada Z_w da LT
revisão 04 - capturar modos para até 4 circuitos (há diferenças nas saídas .lis para T_i)
apresenta opções de escolha para o usuario após leitura do arquivo .lis
captura valores de resistência, indutânci... | true |
7b81288582f1f0ed2cf1756761aaff77115c180c | Python | millionszhang/spider | /总结/正则匹配.py | UTF-8 | 560 | 3.046875 | 3 | [] | no_license | import re
#匹配.com 或 .cn 的url 网址
pattern = "[a-zA-Z]+://[^\s]*[.com|.cn]"
string = "<a href='http://www.baidu.com'>"
result = re.search(pattern,string)
print(result)
#匹配电话号码
pattern = "\d{4}-\d{7}|\d{3}-\d{8}"
string = "021-6728263653682382265236"
result = re.search(pattern,string)
print(result)
#匹配电子邮件地址
pattern = "... | true |
f868adae2949c7b40bd900824f2edbad0ac0d832 | Python | TheWatcherI/TheWatcherI | /BetterROT13.py | UTF-8 | 1,830 | 3.546875 | 4 | [] | no_license | import string , sys
class ROT13:
"""docstring for ROT13"""
def __init__(self, Text:str) -> None:
self.alphabet_string = list(string.ascii_lowercase)
self.Text:str = Text
self.new_Text = [""] * len(self.Text)
self.index_list = []
self.Not_chars = []
self.new_charcters = []
self.Full = []
self.new_Str... | true |
709b7a52e8deff71aaf12b4529926ff6e166e56a | Python | linannn/LeetCode_Solution | /714.买卖股票的最佳时机含手续费.py | UTF-8 | 1,063 | 3.375 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=714 lang=python3
#
# [714] 买卖股票的最佳时机含手续费
#
# @lc code=start
from typing import List
class Solution:
def maxProfit(self, prices: List[int], fee: int) -> int:
size = len(prices)
if size < 2:
return 0
# dp[j] 表示 [0, i] 区间内,到第 i 天(从 0 开始)状态为 j 时的最大收益
... | true |
2bf5456c68732aec55db5e7dd8aa93e1879e0f90 | Python | Jyouya/ExtraMacros | /Macro.py | UTF-8 | 630 | 3.046875 | 3 | [] | no_license |
class Macro:
def __init__(self, modifier=None, key=None, command=None, text=None, x=None, y=None, color=None):
self.modifier = modifier
self.key = key
self.command = command
self.text = text
self.x = x
self.y = y
self.color = color
def move(self, x, y)... | true |
e1cbd7815615664eda7f7a7490dabf23b3171b2e | Python | EllieHachem/Some-projects | /Teaching-Others-day-1continuation-of-first-day/main.py | UTF-8 | 215 | 3.078125 | 3 | [] | no_license |
#print function is simple
#day 1 ali hachem python teaching
print("type anything inside quotation then hit run")
#just type print and between paraenthsis use quotations that includes words in it and that is it
| true |
6d6630f303f6d2829b0149a60db8e28d4f8f1a39 | Python | SamG97/AnthropometricsToday | /backend/restAPI/NearestNeigbour.py | UTF-8 | 1,906 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
from DataBaseScript import getAllMeasurements
def discardNone(a):
b = []
for i in range(len(a)):
isFull = True
for j in range(len(a[i])):
if a[i][j] == None:
isFull = False
if isFull:
b.append(a[i])
return b
studentList =... | true |
8999a672393dc3fb3c97555a1d2beac6051edd43 | Python | simone-campagna/dtcalc | /dt.py | UTF-8 | 9,633 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python3
import time
class MetaDT(type):
def __new__(cls, class_name, class_bases, class_dict):
t = super().__new__(cls, class_name, class_bases, class_dict)
t.P_INF = t(t.P_INF_VALUE)
t.M_INF = t(t.M_INF_VALUE)
t.P_INF_LABELS = set(t.P_INF_ADDITIONAL_LABELS)
... | true |
7f4d9c588810194d0e05b8795f285f138162d3cc | Python | pgasidlo/adventofcode2019 | /day10/main.py | UTF-8 | 2,362 | 2.890625 | 3 | [] | no_license | import sys
import copy
from fractions import gcd
from numpy import arctan
import math
import pprint
pp = pprint.PrettyPrinter(indent=4)
am = []
ams = None
for aml in open("input.txt"):
aml = aml.rstrip()
if (ams is None):
ams = len(aml)
am.append(list(aml))
def graph(am):
for aml in am:
print "".join... | true |
75124312e3d7fef2dd16433d10ab689b5f91ce74 | Python | shehryarbajwa/Algorithms--Datastructures | /recursion/*interview-question-is_palindrome_recursively.py | UTF-8 | 3,610 | 4.90625 | 5 | [] | no_license | # A palindrome is a word that is the reverse of itself—that is, it is the same word when read forwards and backwards.
# For example:
# "madam" is a palindrome
# "abba" is a palindrome
# "cat" is not
# "a" is a trivial case of a palindrome
# The goal of this exercise is to use recursion to write a function is_palindro... | true |
5ab5b22a14a517f105271e63716d21841839fd19 | Python | Mycroft0121/pyvolve | /src/matrix_builder.py | UTF-8 | 26,315 | 2.859375 | 3 | [] | no_license | #! /usr/bin/env python
##############################################################################
## pyvolve: Python platform for simulating evolutionary sequences.
##
## Written by Stephanie J. Spielman (stephanie.spielman@gmail.com)
#############################################################################... | true |
34c01e6f65cb8454847d99705e8dc1b9b95932fa | Python | twyunting/Algorithms-LeetCode | /Easy/String/0709. To Lower Case.py | UTF-8 | 109 | 3.21875 | 3 | [] | no_license | def toLowerCase(str):
"""
:type str: str
:rtype: str
"""
return str.lower()
print(toLowerCase("HeLLo")) | true |
669d04302e5e8971ed620d7aff7291f2c19ab74d | Python | ckallum/Daily-Coding-Problem | /solutions/#182.py | UTF-8 | 740 | 3.28125 | 3 | [
"MIT"
] | permissive | def minimally_connected(graph):
for v in graph:
for i, n in enumerate(graph[v]):
graph[v].remove(n)
graph[n].remove(v)
if is_connected(graph, v, n):
return False
graph[n].add(v)
graph[v].add(n)
return True
def is_connected(gra... | true |
f9eeb1eb5e48e5d84034273bce7bea4469e4de17 | Python | sodrian/codewars | /kt06_categorize_new_member.py | UTF-8 | 185 | 3.28125 | 3 | [] | no_license | def openOrSenior(data):
r = []
for item in data:
if item[0] >= 55 and item[1] > 7:
r.append('Senior')
else:
r.append('Open')
return r | true |
ea621e47dea7a47d0bf2a8ea65d6ced9e0a39b99 | Python | Jictyvoo/TEC502-2018.1--English-Dictionary-Game | /src/Server/models/value/Room.py | UTF-8 | 1,841 | 3.03125 | 3 | [
"MIT"
] | permissive | class Room:
def __init__(self, multicast_ip=None, name="Pseudo-Room", coordinator_player_address=None, limit_players=2,
password="", coordinator_name="Pseudo-Name"):
self.__room_ip = multicast_ip
self.__name = name
self.__coordinator_player_address = coordinator_player_addre... | true |
a8e65c7576a6a75de37be4a5cfd0fc9a21689909 | Python | chacham/learn-algorithm | /leetcode.com/jump-game/solve.py | UTF-8 | 260 | 2.640625 | 3 | [] | no_license | class Solution:
def canJump(self, nums: 'List[int]') -> 'bool':
maxFromHere = nums[0]
for num in nums:
if maxFromHere < 0:
return False
maxFromHere = max(num - 1, maxFromHere - 1)
return True
| true |
d1760324bbf45bfdf9239121b1c0219935075742 | Python | ObadiahBoda/Obadiah-Boda-Projects | /Misc Coding projects/Sudoku/Sudoku.py | UTF-8 | 1,796 | 2.84375 | 3 | [] | no_license | # draw grid
board = [[0, 7, 0, 0, 2, 0, 0, 0, 5],
[0, 6, 0, 0, 0, 0, 7, 0, 0],
[5, 0, 0, 0, 4, 0, 0, 0, 0],
[0, 1, 3, 0, 0, 0, 0, 0, 0],
[6, 0, 0, 0, 5, 0, 0, 0, 2],
[2, 5, 0, 0, 3, 6, 1, 9, 0],
[0, 4, 0, 0, 0, 0, 0, 0, 6],
[7, 2, 0, 4, 9, 0, 0,... | true |
4a38c32329c142bf29ee71b3ba51e0c0ad27d213 | Python | BlackNaygas/Info-Schule | /Teilbarkeit (11.052020)/Für Schnelle (11.05.2020).py | UTF-8 | 164 | 3.515625 | 4 | [] | no_license | zahl = int(input("Bitte Zahl eingeben:"))
if (zahl % 3 == 0 and zahl % 7 == 0):
print("Die Zahl", zahl, "ist durch 3 und 7 teilbar.")
else:
print("Nix da") | true |
53f2a641953ca8100501a66753e87377ab9bf26e | Python | sjblim/population-based-rnn-optimisation | /libs/losses.py | UTF-8 | 1,092 | 2.984375 | 3 | [] | no_license | """
losses.py
Created by limsi on 03/04/2019
"""
from enum import IntEnum
import tensorflow as tf
class LossTypes(IntEnum):
MSE = 1,
BINARY = 2
class LossFunctionHelper:
_loss_name_map = {LossTypes.BINARY: 'binary',
LossTypes.MSE: "mse"}
@classmethod
def get_valid_los... | true |
526e284ec314f21d5b9d10c92975316d2c5c7ece | Python | EricCacciavillani/Python_Stats_Class | /Stats_Exam_Python/stats_conf_no_sigma.py | UTF-8 | 851 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 28 11:41:13 2017
@author: ericcacciavillani
"""
import math
#------------------------------------
given_val = 90
sample_size = 30
critical_val = 2.575
#------------------------------------
point_estimate = given_val/ sample_size;
q_of_p = 1 - poin... | true |
3ffc7ef299dea4988b5cc4a643eadc26842a189c | Python | Carryours/algorithm004-03 | /Week 01/id_118/LeetCode_189_118.py | UTF-8 | 1,911 | 4.28125 | 4 | [] | no_license | from typing import List
class Solution1:
"""
First solution is brute force
"""
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
Time complexity: O(n * k)
"""
for _ in range(k):
# the slice ... | true |
052564dda05c5f0b5a2f640412d1cd713d615820 | Python | Auto4C/sqlite4dummy-project | /sqlite4dummy/tests/sqlite3_in_python/syntax/advance/test_INSDATE.py | UTF-8 | 4,043 | 3.375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
INSERT AND UPDATE (INSDATE)简介
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
尝试进行insert, 如果数据主键冲突, 那么则update除主键以外的其他数据。
问题: 当被insert的不是所有的列时, 只会更新insert的相关列, 其他列的值会被保留。
如果被update的值跟constrain有冲突, 则会抛出异常。
与之相似的是UPSERT:
尝试进行update, 如果数... | true |
17697ce37db41dc0cedd59fbed39b8d1009e45da | Python | oyl1998/MLL | /Linear_Regression.py | UTF-8 | 1,348 | 3.15625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
'''
Name: Linear_Regression.py
Auth: long_ouyang
Time: 2020/10/5 15:00
'''
import torch
x_data = torch.Tensor([ [1.0], [2.0], [3.0] ])
y_data = torch.Tensor([ [2.0], [4.0], [6.0] ])
class LinearModel(torch.nn.Module):
def __init__(self):
super(LinearModel, self).__in... | true |
ba03f0487b0871914d6d6a3a525243e16534ece1 | Python | pcsfilho/ross_biprob | /src/biprob_gazebo/src/biprob_gazebo/biprob.py | UTF-8 | 3,374 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python
"""
Author: Paulo Cezar dos Santos Filho
version: 2.0
Class name: Biprob
"""
import random
from threading import Thread
import math
import rospy
import time
from std_msgs.msg import Float64
from sensor_msgs.msg import JointState
from geometry_msgs.msg import Twist
"""
Esta classe
"""
class Bipro... | true |
d619ea223435a35bdf4bd24bf2863eda882a0700 | Python | johnnynode/python-spider | /contents/code/selenium/5.py | UTF-8 | 706 | 2.75 | 3 | [
"MIT"
] | permissive | from selenium import webdriver
from selenium.webdriver import ActionChains
import time
#创建浏览器对象
driver = webdriver.Chrome()
#加载指定url地址
url = 'http://www.runoob.com/try/try.php?filename=jqueryui-api-droppable'
driver.get(url)
# 切换Frame窗口
driver.switch_to.frame('iframeResult')
#获取两个div节点对象
source = driver.find_eleme... | true |
a7a3b9fd6347f37c33763be8c4566c846fc189b4 | Python | italo-batista/problems-solving | /storm/dp_LIS.py | UTF-8 | 285 | 2.953125 | 3 | [
"MIT"
] | permissive | # coding: utf-8
sequence = map(int, raw_input().split())
N = len(sequence)
dp = [1] * (N+1)
ans = 0
for i in xrange(N):
dp[i] = 1
for j in xrange(i):
if (sequence[j] < sequence[i] and dp[i] <= dp[j]):
dp[i] = dp[j] + 1
if (ans < dp[i]):
ans = dp[i]
print ans
| true |
12f7e624da1eb36a5266d5c6c3505d1e3cf3becb | Python | syunnashun/self_taught | /3.intro_charange.py | UTF-8 | 511 | 3.65625 | 4 | [] | no_license | # 第3章のチャレンジ
# http://tinyurl.com/zx7o2v9
print('ジオブレイク70S', 'ジオブレイク80S', 'Fレーザー7S')
x = 7
if x < 10:
print('伸びしろですね')
elif 10 <= x <= 25:
print('もっとできるはずさ')
else:
print('慢心ではなく自信を持て!')
print(2020 % 825)
print(2020 // 825)
barth_year = 2000
age = 2020 - barth_year
if age >= 20:
print... | true |
49f3338d1eabc0944b8148020a580752bdb6c009 | Python | Leputa/Leetcode | /python/725.Split Linked List in Parts.py | UTF-8 | 1,053 | 3.375 | 3 | [] | no_license | import math
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def splitListToParts(self, root, k):
"""
:type root: ListNode
:type k: int
:rtype: List[ListNode]
"""
length=0
... | true |
958d9dd1bedf0dcd3c1023875b1406869c42ec9f | Python | jeongmin-seo/two-stream-pytorch | /data_loader/3d_loader.py | UTF-8 | 5,231 | 2.75 | 3 | [] | no_license | import random
import os
from PIL import Image
from torch.utils.data import Dataset, DataLoader
import torchvision.transforms as transforms
import torch
class OneCubeDataset(Dataset):
def __init__(self, dic, in_channel, root_dir, mode, transform=None):
# Generate a 16 Frame clip
self.keys = list(di... | true |
73a3e1e7275b3276d4f6ec3d1b67cd92213656bd | Python | JohnDoe1996/bysj | /python/camera.py | UTF-8 | 2,954 | 2.984375 | 3 | [] | no_license | import cv2
import os
class Frame:
@staticmethod
def BGR2RGB(frame):
newFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # 颜色由BGR转为RGB
return newFrame
@staticmethod
def BGR2Gray(frame):
newFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # 颜色由BGR转为灰度
return newFrame
... | true |
f0874e47b7854ea1799657c96f9b3b58b96b816b | Python | ankssri/Utilities | /DTMetricJsonUtility.py | UTF-8 | 1,508 | 2.8125 | 3 | [] | no_license |
import json
import requests
#DT Tenant
tenant = "https://<your tenant>.live.dynatrace.com"
#DT API Token
ApiTokenValue = "<Your DT API Token>"
#Step 1 GET json directly from DT server. This example is for only 1 metric
querystring = {'resolution':'10m','Api-Token':ApiTokenValue, 'metricSelector':'builtin:h... | true |
ff48d69784668a1165f36ace08e150d16424502d | Python | msh0576/RL_WCPS | /DeepWNCS/pytorch-gym-master/base/paraenv2.py | UTF-8 | 1,830 | 2.9375 | 3 | [] | no_license | # Qin Yongliang
# start multiple environment in parallel
from llll import PythonInstance
slave_code = '''
from llll import sbc
sbc = sbc()
import numpy
import gym
# import everything relevant here
envname = sbc.recv()
env = gym.make(envname)
print('environment instantiated:', envname)
while True:
obj = sbc.re... | true |
9c068eb08e7e947950978ba519795ff18b9165f1 | Python | philippreiners/Masterarbeit2 | /Validierung_Python/create_emi_station_file.py | UTF-8 | 1,193 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 11 10:30:05 2018
@author: Pille
"""
path_in = 'D:/Uni/Masterarbeit/Emissivity_stations/Changed2/'
path_out = 'D:/Uni/Masterarbeit/Emissivity_stations/Changed2/station_emis/'
items = os.listdir(path_in)
newlist = []
for names in items:
if names.endswith(".txt"):
... | true |
e09f1abf437a62d3e03202aaa46a3ab07baa5195 | Python | InfiniteCuriosity/Pandas-for-Everyone | /2. Pandas Data Structures.py | UTF-8 | 2,774 | 3.921875 | 4 | [] | no_license | #### Pandas Data Structures ####
import pandas as pd
s = pd.Series(['banana', 42])
print(s)
# manually assign index values to row names to a series by passing in a Python list
# 2.2.1 Creating a series
s1 = pd.Series(['Wes McKinney', 'Creator of Pandas'],index = ['Person', 'Who'])
print(s1)
# 2.2.2 Create a data fr... | true |
3ecf1235ff528ba4b15e43eb278f500e906b311e | Python | victoriaogomes/Unicorn.io | /semantic_analyzer/semantic_analyzer.py | UTF-8 | 438 | 2.9375 | 3 | [] | no_license | from semantic_analyzer import visitor as vt
class SemanticAnalyzer:
def __init__(self, symbol_table, ast, tokens_list):
self.symbol_table = symbol_table
self.ast = ast
self.tokens_list = tokens_list
self.visitor = vt.Visitor(self.symbol_table, tokens_list)
def analyze(self):
... | true |
acb48b8d2099488cf00814348e6b755ae22bb819 | Python | SaiNithin96/pythonfile | /datahiding.py | UTF-8 | 872 | 3.828125 | 4 | [] | no_license | # Datahiding or Encapsulation --- Restricting the acces to variables or methods..
# class Student:
# a=56 #(Public variables) # Those which can be accessed in or outside of class with out any restrictions.
# __b=76 #Private Varibales # Those cannot be accessed outside of the class.
# def add(self): #public
# r... | true |
7af398f25c5b4c4c969d9db84456b2ee5c68487b | Python | yotamshadmon/puzzle | /src/puzzle.py | UTF-8 | 2,941 | 3.21875 | 3 | [] | no_license | import random
class pos:
def __init__(self, i, j):
self.i = i
self.j = j
class puzzle:
def __init__(self, n, m, level):
self.n = n
self.m = m
self.board = [[j*n+i+1 for i in range(0, n)] for j in range(0, m)]
self.board[m-1][n-1] = 0
self.blank = pos(n-1, m-1)
self.shuffle(level)
def validDi... | true |
4bd60c0c52ddfbd7e40df588968ead8781626917 | Python | xiaogengchen/di_ai_mu | /05/str_unicode.py | UTF-8 | 608 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env python
#-*-coding:utf-8-*-
'''
普通字符串与unicode字符串之间的转换
'''
# import
__author__='XiaoGengchen'
__version__='1.0'
def strToUnicode(plainString=''):
'''普通字符串向unicode字符串的转换用decode'''
temp_str = plainString.decode("utf-8")
print temp_str,type(temp_str)
def unicodeToStr(unicodeString=u'') :
''... | true |