blob_id large_string | language large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|---|
7b646127f63715a7bb5d00dfd3b76f38fdf6ea0f | Python | sma36/Dxc | /Python assessment/classSortAssessment.py | UTF-8 | 1,027 | 3.21875 | 3 | [] | no_license | temp='''Name={0}
Category={1}
Brand={2}
Cost={3}
Rating={4}
Discount={5}'''
class products:
def __init__(self,pid,name,category,brand,cost,rating,discount):
self.pid=pid
self.name=name
self.category=category
self.brand=brand
self.cost=cost
self.rating=rating
... | true |
cffe9a4b0aa5420d18141f1d5174e08b46209fa9 | Python | LintangWisesa/OpenCV-Basic | /5_faceDetection2.py | UTF-8 | 983 | 3 | 3 | [] | no_license | # Face Detection using Cascade Classifier
import cv2
# https://github.com/opencv/opencv/tree/master/data/haarcascades
face_cascade = cv2.CascadeClassifier("./methods/haarcascades/haarcascade_frontalface_default.xml")
img = cv2.imread('5_grup.jpg')
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
wajah = face_casca... | true |
a8b0ce0322e5f3632b9b168959a0a8d05027265f | Python | nvanheuverzwijn/awss3 | /awss3/factory.py | UTF-8 | 1,960 | 2.875 | 3 | [] | no_license | from awss3.dto import Bucket, ObjectMetadata
class Factory:
pass
class BucketFactory(Factory):
object_metadata_factory = None
def __init__(self, object_metadata_factory):
"""constructor
Args:
object_metadata_factory: An awss3.factory.ObjectMetadataFactory
"""
self.object_metadata_fact... | true |
895c3b0d29d0463397aab5a01280182071b7c2ba | Python | NJCvdMolen/EfQRM | /student_t_regression_test1.py | UTF-8 | 11,663 | 3 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
estnorm.py
Purpose:
Estimate a normal regression model, using lambda function
Version:
1 Following estnorm.ox, using 1d parameter vectors
Date:
2017/8/21
@author: cbs310
"""
###########################################################
### Imports
i... | true |
cc4b4d3870ca9c850c46b3f9ad2c740e1f63ad7b | Python | jingmouren/hrp | /pyhrp/cluster.py | UTF-8 | 2,488 | 3.125 | 3 | [
"MIT"
] | permissive | # pylint: disable=too-many-arguments, missing-module-docstring, missing-function-docstring
import numpy as np
import pandas as pd
from typing import Dict
from dataclasses import dataclass
def risk_parity(cluster_left, cluster_right, cov, node=None):
# combine two clusters
def parity(v_left, v_right):
... | true |
5f85f2feabf1456bad4184d1c3383e4ff07de867 | Python | lagadic/romeo_mc | /scripts/helper_scripts/gain_interpolator.py | UTF-8 | 1,871 | 3.609375 | 4 | [] | no_license | '''
Interpolator for the gains
Implements linear interpolation for the current and desired gains
within the defined number of iterations
TODO: maybe another smoothing function is better
'''
class GainInterpolator(object):
def __init__(self, ordered_list, numIters):
self.numIters = numIters
self.iter = 0
s... | true |
e3b34b47c558588416a529f02fc6f8eb8a84b250 | Python | mani098/wordpress-easy-install | /wordpress-easy-install.py | UTF-8 | 2,941 | 2.53125 | 3 | [] | no_license | #!/usr/bin/python
import commands, os, MySQLdb, random
def cmd(str):
return commands.getoutput(str)
if cmd('whoami')== 'root':
print "checking with root privilegies"
l=[]
a='sudo yum install'
print "checking necessary packages...."
if 'httpd' in cmd('rpm -qa httpd'): #checking apache installation
print "Apac... | true |
fe974eb288ac1ead91a1285c6529c068aae4b058 | Python | buhijs/meterstick | /meterstick/core.py | UTF-8 | 9,338 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
#
# Copyright 2016 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 or a... | true |
5509ef41f7dcf9e99acf3a2b0e9cd8fd173d73f2 | Python | AlexisHuvier/PGGUI | /examples/widgets/checkbox.py | UTF-8 | 414 | 2.59375 | 3 | [] | no_license | from pggui import Window
from pggui.widgets import Checkbox
from pggui.utils import Vec2, Color, Font
window = Window(Vec2(60, 150), debug=True)
window.add_widget(Checkbox(Vec2(10, 10), "Check 1"))
window.add_widget(Checkbox(Vec2(10, 40), "Check 2", font=Font(size=20)))
window.add_widget(Checkbox(Vec2(10, 70), "Check ... | true |
41a609b3864d2b74ae12302edc81e7ad38ad82e5 | Python | sunjerry019/RandomCodes | /Self-Learn/python/photos_archiver_v0.1.py | UTF-8 | 2,459 | 3.015625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python3
import os
import platform
import sys
import shutil
ppwd = input("Enter location of files to be archived: ")
dest = input("Enter archive location: ")
syst = platform.system()
if syst == "Windows":
ppwd = ppwd if ppwd else "D:\Photos"
dest = dest if dest else "D:\Photos\Archive"
d... | true |
3e2632de4ff86150ae3afd02f6c935329236536e | Python | otverskoj/First-steps-in-Data-Analysis | /my_implementations/multilayer perceptron/layers.py | UTF-8 | 1,257 | 2.796875 | 3 | [] | no_license | import numpy as np
from activation_functions import ActivationFunction, ActivationFunctionDerivative
class Layer:
def __init__(self, neurons_num, prev_layer_neurons_num, activation_func, inputs_size):
self.neurons_number = neurons_num
self.prev_layer_neurons_num = prev_layer_neurons_num
se... | true |
d19e6ccadbd66d0912a48a776b599a85ff92ab83 | Python | Prathameshshenoy/Python-Projects | /code for editing excel spreadsheets.py | UTF-8 | 326 | 2.71875 | 3 | [] | no_license | import openpyxl as xl
wb = xl.load_workbook('Book1.xlsx')
sheet= wb['Sheet1']
cell = sheet.cell(1,1)
for row in range(2,sheet.max_row +1):
cell = sheet.cell(row,3)
mul = cell.value * 0.9
corrected_price_cell =sheet.cell(row, 4)
corrected_price_cell.value = mul
wb.save('test to see if exel code works.x... | true |
ac9490d73f27ce1048827b5e00a388b9e90c74d1 | Python | okaxaki/objc2swift | /spec/blocks.spec | UTF-8 | 944 | 3.703125 | 4 | [
"ISC"
] | permissive | # Blocks
## Blocks as Variable
```
void (^blk)(int) = ^(int a) {
// ...
};
```
```
let blk:(Int)->Void = { (a:Int) in
// ...
}
```
## Blocks as Property
```
@interface Foo
@property void(^blk)(NSString *);
@end
@implementation Foo
-(void)method {
blk = ^(NSString *msg){
NSLog(@"In block: %@", ... | true |
6da60c51d7260137dc101b75e10970df1f9f7443 | Python | betairylia/UniversalCLI | /CLI.py | UTF-8 | 3,567 | 2.875 | 3 | [] | no_license | import colorama
from termcolor import colored, cprint
from colorama import Cursor, Fore, Back, Style
from time import sleep
from Components import *
import random
import os
class CLIClass():
def init(self, components = [], width = 80, title = ' Untitled ', footer = None, borderstyle = ('grey', None, ['bold'])):
... | true |
6b3fce952393bd7f1de2d89be977f5178cdb99be | Python | Deepshikhasinha/CTCI | /leetcode/valid_paran.py | UTF-8 | 481 | 3.328125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 17 12:58:44 2018
@author: dsinha1
"""
#921. Minimum Add to Make Parentheses Valid
stack = []
def valid_paran(S):
for i in range(len(S)):
stack.append(S[i])
j = 0
while j < len(stack)-1:
if stack[j] == "(" and stack[j+1] == ")":... | true |
8eddb5d66996e418f1d66c7ba5633ee709ccec4b | Python | lcsouzamenezes/deepstar | /deepstar/models/frame_set_model.py | UTF-8 | 2,036 | 2.609375 | 3 | [
"BSD-3-Clause-Clear"
] | permissive | from deepstar.models.model import Model
class FrameSetModel(Model):
"""
This class implements the FrameSetModel class.
"""
@classmethod
def init(cls):
"""
This method initializes the model.
:rtype: None
"""
query = """
CREATE TABLE IF NOT ... | true |
80c02a63138c0bf809355b3586b64c5e2ce59d0d | Python | xiaoKuanRueiRuei/Python-Introduce | /HW/20161125/405402211_3.py | UTF-8 | 1,712 | 3.71875 | 4 | [] | no_license | #5.3
print("kilograms Pounds")
for x in range(1,200,2):
print("%-9d %6.1f"%(x,x*2.2))
#5.4
print("Miles Kilometers")
for x in range(1,11,1):
print("%-2d %2.3f"%(x,x*1.609))
#5.12
i=int(input("100到1000區間:"))
b=1
c=0
while b in range(1,i):
if b%5==0 or b%6==0 :
... | true |
134b354cfca09203edeccfa607602c3b5e1bfd1a | Python | tylerneylon/math | /ml_notes/cs229/hw/ps1/problem1_1b.py | UTF-8 | 1,119 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python
import numpy as np
from numpy import linalg as la
# Define the J function.
def J(Z, theta):
m, _ = Z.shape
g = 1 / (1 + np.exp(Z.dot(theta)))
return -sum(np.log(g)) / m
# Load data.
X = np.loadtxt('logistic_x.txt')
m, n = X.shape
X = np.insert(X, 0, 1, axis=1) # Prefix an all-1... | true |
e3687202583d5886fc9362cb3e34b156f39cd32b | Python | cuikaibin/pythonlearn | /crawler/gitCookie.py | UTF-8 | 909 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import cookielib
cookie = cookielib.CookieJar()
handler = urllib2.HTTPCookieProcessor(cookie)
opener = urllib2.build_opener(handler)
response = opener.open("http://www.baidu.com")
print cookie
for x in cookie:
print "name = "+x.name
print "valu... | true |
e63170484d5940c0819de1435ad3fcfcf71afd44 | Python | Alyusha-modi/AITPL2113 | /tuple_prac.py | UTF-8 | 2,090 | 4.5625 | 5 | [] | no_license | #Tuple creation
t = () #empty tuple
#tuple having integers
t = (1, 2, 3)
print(t)
#tuple with mixed datatypes
t = (1, 'xyz', 28, 'abc')
print(t)
#nested tuple
t = (1, (2, 3, 4), [1, 'xyz', 28, 'abc'])
print(t)
#only parenthesis is not enough
a = ('alyusha')
print(type(a))
#need a comma at the end
b = ('alyusha',)
pri... | true |
37e9e478598cc62a785cd9221423205aa3bd0d6d | Python | B173930-2020/Assignment2 | /species_loop.py | UTF-8 | 377 | 3.03125 | 3 | [] | no_license | import re
from collections import Counter
# Pick up the species names in pro_fam.fasta(all sequences document) and count their amounts.
with open('pro_fam.fasta', 'r') as f:
tmp = f.read()
tax_result = re.findall('\[(.*?)\]', tmp)
tmp = Counter(tax_result)
# top10 species names
for i in tmp.most_common(10):
... | true |
893b306a462e2b8e21122bdc61d73ccfb67357eb | Python | SafonovMikhail/python_000577 | /000562HeadFirstPy/000562_01_01_p062_loopForRange_20200224.py | UTF-8 | 156 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | for num in range(5):
print("Hi!")
print(" ")
for num in range(5):
print("Hi!", end="")
# вариант вывода, в одну строку
| true |
72a92441e04184cc9fe571c1dc4058bd878d94f0 | Python | kitsmart/pythonbooklet | /Chapter 5/Practice Exercise/10 Print even up to.py | UTF-8 | 208 | 3.625 | 4 | [] | no_license | zero = 0
num1 = int(input("What number would you like to count up to?: "))
def print_upto(num):
global zero
while zero < num + 1:
print(zero)
zero = zero + 2
print(print_upto(num1))
| true |
eae43ace1cf31a7c47174902e1e91c4067b565ea | Python | aweir12/intake-sql-adapter | /intake_sql_adapter/intake_sql_adapter.py | UTF-8 | 2,186 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | from intake.source import base
from . import __version__
class SQLTable(base.DataSource):
"""
Class to query a single SQL table or view.
Parameters
----------
uri: str or None
Full connection string in sqlalchemy syntax
sql_table: str
Table or view to query
sql_num_rows: in... | true |
9eecc6943d41d1d825b1adf62b167814bfc506f4 | Python | pablitocalvo/4CLAB_TEP | /py/gtk/03.terzo_ter.py | UTF-8 | 934 | 3.09375 | 3 | [] | no_license | import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="media dei voti")
# demo per un campo di testo
self.voti = Gtk.Entry()
self.add(self.voti)
#bottone
... | true |
b1861a244765d0603a3d9b242bf9e1b6cacf120b | Python | Mustafa-Muhibullah/MaDCoWS | /flat_p_optimizer.py | UTF-8 | 3,072 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[3]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import chisquare
from scipy.optimize import curve_fit
from scipy.stats.distributions import chi2
def flat_p_optimizer(xdata,ydata,yerr,bmin=-5,bmax=10):
"""
This subroutine fits a zero slope li... | true |
db1bcaa2f97f01228752920632227b4f5f4b787e | Python | bentrevett/blib | /blib/metrics/metrics.py | UTF-8 | 3,350 | 3.515625 | 4 | [] | no_license | class CategoricalAccuracy:
"""
Categorical top-k accuracy.
Assuming integer labels with each item classified by a single class.
Predictions is a tensor [batch_size, n_classes]
Targets is a tensor sized [batch_size] NOT [batch_size, 1]
"""
def __init__(self, top_k = 1):
self... | true |
8bfbffcc5adb87eaaee0cb75e931cc1baf937d62 | Python | rjmacleod/math134 | /gcdeqn.py | UTF-8 | 1,075 | 4.09375 | 4 | [] | no_license | # Computes gcd(a,b) in the form of g = u * a + v * b
# where u,v are integers, u > 0 and u is smallest possible
# int satisfying this.
# ref: An Intro. to Math. Crypt., 2nd ed, Hoffstein p.50
def dwr(a, b):
# Takes natural numb a and b, returns (q,r) such that
# a = qb + r where q,r are integers and 0 <= r <... | true |
8327bf5eeaa490505cbbbf6475c9cae389acb01b | Python | lmarianocampos/Desarrollo-de-Aplicaciones-Sobre-Sist.-Operativo-de-Pro-sito-General | /clase 7 - teoría/resueltos (1)/ej3/ControllerDevices.py | UTF-8 | 703 | 2.796875 | 3 | [] | no_license | import json
from DeviceDAO import DeviceDAO
from Device import Device
class ControllerDevices:
def __init__(self,app,request,db):
self.app = app
self.request = request
self.db = db
def get(self):
#Creo DAO
dev_dao = DeviceDAO(self.db)
#Obtengo lista d... | true |
a65d6600734d22f390f582c0d47a8962d8929c39 | Python | drshar79/hello-world | /hello.py | UTF-8 | 718 | 3.296875 | 3 | [] | no_license | password = input("Enter your password:")
if password=="turtle":
print("Welcome, Divyesh")
else:
forgot_pw=input("Incorrect password. type in 'Forgot Password'")
if forgot_pw=="Forgot Password":
email=input("Type in your email for the login code: ")
if email=="1234d":
print("Here... | true |
69dd86a6bfb3c7bd878faaeccf03be036c411e2f | Python | supramolecular-toolkit/stk | /tests/molecular/topology_graphs/construction_state/with_placement_results/check_edge_functional_groups.py | UTF-8 | 2,488 | 2.609375 | 3 | [
"MIT"
] | permissive | from collections import defaultdict
import stk
def check_edge_functional_groups(
old_state,
new_state,
building_blocks,
placement_results,
):
expected = get_expected_edge_functional_groups(
old_state=old_state,
building_blocks=building_blocks,
placement_results=placement_r... | true |
13c0729cb69a0a54224ce6d9f47bdaac157cd4d0 | Python | seanchen513/dcp | /dcp377 - given int arr and window of size k, print out median of each window.py | UTF-8 | 4,000 | 4.71875 | 5 | [] | no_license | """
dcp#377
LC#480
"Sliding Window Median"
This problem was asked by Microsoft.
Given an array of numbers arr and a window of size k, print out the median of each window of size k starting from the left and moving right by one position each time.
For example, given the following array and k = 3:
[-1, 5, 13, 8, 2, 3... | true |
9d96abc77e85649498a601fa5de0e9ad34cf7ad8 | Python | kunci115/ProgrammingChallange | /LCDDisplay.py | UTF-8 | 175 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 22 23:30:10 2017
@author: root
"""
a = raw_input().strip().split()
b = int(a[0])
c = int(a[1])
print i | true |
5edbdb66122b15afc950babba32e572df65e21dc | Python | FelipeCortez/sincronizacao | /locks.py | UTF-8 | 833 | 2.8125 | 3 | [] | no_license | from common import *
import random
from time import sleep
from threading import Lock
class LockStrategy:
def __init__(self, limit):
self.toilet_limit = limit
self.toilet_lock = Lock()
self.toilet = Toilet(self.toilet_limit)
def personThread(self):
person = Person()
whi... | true |
bc31021f4480b38054f32b4c85e3f57f15f40142 | Python | ArunPrasad017/python-play | /Phase2/Arrays/CompressString.py | UTF-8 | 423 | 3.0625 | 3 | [] | no_license | def compress(s):
idx, count = 0, 1
res = [0] * len(s)
if not s:
return idx
for i in range(1, len(s) + 1):
if i < len(s) and s[i - 1] == s[i]:
count += 1
else:
res[idx] = s[i - 1]
idx += 1
for c in str(count):
res[idx... | true |
581f02daabbca5ba0c3a23cf1c3e55976c6b448b | Python | Tskatom/twitter_finance | /create_hourly_matrix.py | UTF-8 | 1,780 | 2.96875 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = "Wei Wang"
__email__ = "tskatom@vt.edu"
import pandas as pd
import re
from dateutil.parser import parse
from datetime import timedelta
import os
import sys
def create_matrix(tweet_file, out_dir):
"""
construct a word date dictinary
"""
current_... | true |
385f8a601234b4b7d02ef721c8a8744d9dc327ab | Python | famasu/texasHolDem | /Texas_Hol_Dem.py | UTF-8 | 5,611 | 3.703125 | 4 | [] | no_license | from random import shuffle
def getDeck():
suits = ["Spades","Hearts","Clubs","Diamonds"]
deckOfCards = []
for i in suits: # Go through suits and numbers to make deck
for n in range(1,14):
deckOfCards.append((i,n))
shuffle(deckOfCards)
return deckOfCards
def getP... | true |
35cf6bc61104876c919de65a81fc81d8571752fd | Python | sujayvkumar/LISF | /lis/utils/usaf/s2s/s2s_modules/bcsd_fcst/bcsd_library/calc_and_write_nmme_forecast_climatology.py | UTF-8 | 4,974 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
"""
# Author: Shrad Shukla
# Usage: This is a module for the BCSD code that calculates and writes climatolgy of forecasts data.
# Output file will contain total LEAD + 1 column where LEAD can be provided as input (e.g. 6 months
# or 9 months). First column is sorted quantiles ranging from about 0 ... | true |
98b387fae04b2052772a92d4b8320b6b1d3bfade | Python | sezisoro/18500-D7 | /panorama/panorama.py | UTF-8 | 705 | 3.03125 | 3 | [
"MIT"
] | permissive | import numpy as np
import cv2
def panorama(base_mat, to_be_merged_mat, degree = 0):
"""Computational pipeline example
----------
base_mat: cv::Mat
A base image
to_be_merged_mat: cv::Mat
An image that will be merged with the original
degree: int
Kinda like the number of times... | true |
38f6112264040aab440da241c7cc6ffab1d595a2 | Python | Aasthaengg/IBMdataset | /Python_codes/p02594/s896486907.py | UTF-8 | 42 | 3 | 3 | [] | no_license | x=int(input())
print("Yes"if x>29else"No") | true |
ad553c037d2df8529deac8fa9ad85a0e428aab80 | Python | group-1-project-1/london-power-analysis | /scripts/clean-weather-data.py | UTF-8 | 1,895 | 3.34375 | 3 | [] | no_license | # imports ######################################################################
import os, sys, json
import pandas as pd
import numpy as np
# variables ####################################################################
# file holding historical weather data
datapath = os.path.join('.', 'raw', 'openweather-london-... | true |
55e279f5121e00539a948d33c6e51cec39c3a094 | Python | jasperhajonides/NLP_data_extraction | /functions/spacy_model.py | UTF-8 | 4,538 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env python3
# spacy_model.py
"""
Created on Thu Aug 26 12:21:54 2021
@author: corp\isabel_e
contains functions used in custom text classification in spaCy,
here, using an underlying simple CNN architecture
"""
import random
import spacy
from spacy.util import minibatch, compounding
def get_textcat_pipe... | true |
baab4b4a7cca0be75f0cfc974f61a71cc8892ca2 | Python | jarotter/progra-lineal | /segundo-parcial/1-3-g.py | UTF-8 | 621 | 2.609375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import numpy as np
from src import simplex_upto_p2 as simplex
from src import printer
#Actividad 1: 3.g)
print('Actividad 1: 3.g)')
c = np.array([300, 200])
A = np.array([[6,4], [8,4], [3,3]])
b1 = [35, 37, 39, 41, 43, 45]
b3 = [15, 17, 19, 21, 23, 25]
for x in b1 :
b = np.array([x, 40, 20... | true |
12e1bfdcf55a83a6d9d0398fc213eb51181c327b | Python | karandeepbhardwaj/Data-Science-Crash-Course | /Crash course/Probability/plot_pdf.py | UTF-8 | 516 | 2.921875 | 3 | [] | no_license | import matplotlib.pyplot as plt
from normal_distribution import *
xs = [x / 10.0 for x in range(-50, 50)]
plt.plot(xs,[normal_pdf(x, sigma=1) for x in xs],
'-',label='mu=0,sigma=1')
plt.plot(xs,[normal_pdf(x, sigma=2) for x in xs],
'--',label='mu=0,sigma=2')
plt.plot(xs,[normal_pdf(x, sigma=0.5... | true |
d8cf02caf642fccad1592bbdb18518d4b8d427d6 | Python | eronekogin/leetcode | /2020/longest_repeating_character_replacement.py | UTF-8 | 1,632 | 3.96875 | 4 | [] | no_license | """
https://leetcode.com/problems/longest-repeating-character-replacement/
"""
class Solution:
def characterReplacement(self, s: str, k: int) -> int:
"""
Using sliding window solution:
1. maxOccurrences hold the maximum occurrences among the unique chars
in the current window.... | true |
e3fce8fc118c96828637ce23b2a37124462d5e28 | Python | E-bi/Blog | /wiki/tools/login_check.py | UTF-8 | 2,002 | 2.5625 | 3 | [] | no_license | import jwt
from django.http import JsonResponse
from user.models import UserProfile
TOKEN_KEY = '1234567ab'
def login_check(*methods):
def _login_check(func):
def wrapper(request, *args, **kwargs):
# 逻辑判断
# 1.取出token
# 2.判断当前请求是否需要校验
# 3.如果需要检验token,如何校验
... | true |
33e8b79a64109b01373fa9242db23bb04906317c | Python | haolongjie/MXNet-GAN | /DCGAN/core/visualize.py | UTF-8 | 1,839 | 3.265625 | 3 | [] | no_license | # Visualize training
import numpy as np
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
# Takes the images in our batch and arranges them in an array so that they can be
# Plotted using matplotlib
def fill_buf(buf, num_images, img, shape):
width = buf.shape[0] / shape[1]
height = ... | true |
0ec7866046c4ca317d6687c18c1d9892fc99abac | Python | cnspaulding/PFB_problemsets | /kmer_counter.py | UTF-8 | 932 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env python3
from Bio import SeqIO
import sys
#can type in the length of the kmer you want on the command lien
length = sys.argv[1]
kmer_len = int(length)
num_toprint = sys.argv[2]
num_toprint = int(num_toprint)
kmer_dict = {}
for seq_record in SeqIO.parse('reads.fq', 'fastq'):
seq = str(seq_record.seq)
# ... | true |
16ea846269ab7e9078e5b44947fb44890340f7c5 | Python | Nur99/yandex_lyceum | /2nd_year/1/homework/2.py | UTF-8 | 461 | 3.34375 | 3 | [] | no_license | x, y = [], []
for i in range(int(input())):
a = input().split()
a = [int(a[0]), int(a[1])]
if (a[0] != a[1]) and (a[0] != - 1 * a[1]):
if abs(a[1]) < abs(a[0]):
print('(' + str(a[0]) + ', ' + str(a[1]) + ')')
x.append(a[0])
y.append(a[1])
print('left:', (min(x), y[x.index(min(x))... | true |
09892ac06bc217b3041a6927166375ede33d95ac | Python | jiayu2B/Leetcode_py | /216_Combination Sum III.py | UTF-8 | 845 | 3.078125 | 3 | [] | no_license | class Solution(object):
def combinationSum3(self, k, n):
"""
:type k: int
:type n: int
:rtype: List[List[int]]
"""
sub = [1,2,3,4,5,6,7,8,9]
Solution.res = []
Solution.ref = k
self.DFS(sub, n, 0, 0, [])
return Solution.res
#深度优先搜索
... | true |
8236f73e87403664deb4a1f9b59ed8ac243e3bb7 | Python | AmbryTheBlue/RPH-SPAM-FILTER | /utils_analyzer.py | UTF-8 | 3,475 | 3.21875 | 3 | [
"MIT"
] | permissive | from collections import Counter
def count_href(array):
words = array.lower().split()
counter = 0
for word in words:
if ("href" in word):
counter += 1
return counter
def counter_from_array(array):
# useless function, remains for compatibility
c = Counter(array)
ret... | true |
b2e69d8ac5ee523e23ef9291cb8d3dafd435eb06 | Python | WangDongDong1234/python_code | /classroom/homework4/3_3.py | UTF-8 | 942 | 2.78125 | 3 | [] | no_license | n = int(input())
result = []
for i in range(0, n):
huajia_muban=input().strip()
huajia=huajia_muban.split(" ")[0]
muban=huajia_muban.split(" ")[1]
# huajia = int(input())
# muban = int(input())
str_muban = input()
lst_muban = []
tmp_muban = str_muban.strip().split(" ")
for item in tm... | true |
9fcc15bee64aa01298bc57114de72962e991f6b0 | Python | sery270/Algorithm | /BinarySearch/[LeetCode] 530. Minimum Absolute Difference in BST.py | UTF-8 | 2,459 | 3.84375 | 4 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def min(self, a, b) -> int:
if a > b:
return b
else:
return a
d... | true |
f4222f76782603b6fca4c88777d80811bd9d4c78 | Python | YangLiyli131/Leetcode2020 | /in_Python/0190 Reverse Bits.py | UTF-8 | 278 | 3.09375 | 3 | [] | no_license | class Solution:
# @param n, an integer
# @return an integer
def reverseBits(self, n):
res = 0
p = 0
while n != 0:
c = n % 2
n /= 2
res += c * pow(2, 31 - p)
p += 1
return res | true |
854129f3f4a7e61be09e454ad44d0b583481b84c | Python | yashjha123/ethersat | /rearranging-elements.py | UTF-8 | 1,616 | 2.734375 | 3 | [] | no_license | """
import numpy as np
a = np.array([x+1 for x in range(25)])
b = np.array([[0 for x in range(25)] for x in range(25)])
shift = -2
for g in range(25):
b[g][(g+shift)%25]=1
# b[24][0]=1
print(np.sum(a*b,axis=1))
# print(b)
"""
import torch
# a = torch.LongTensor([x+1 for x in range(25))
batch = 50
a = torch.ones((25,... | true |
6c6393d9212f357ae60ac429fc39c56cc5b8b0da | Python | kokotonev/deepspeech2-en-bg | /preprocess_librispeech.py | UTF-8 | 3,081 | 2.796875 | 3 | [] | no_license | # Script for preprocessing the raw flac files and their corresponding transcriptions
# from LibriSpeech to '.npy' format files suitable for the model to read.
#
# Author: Nikola Tonev
# Date: March 2019
import soundfile as sf
import os
import numpy as np
import argparse
import utils
from tqdm import tqdm
def prep... | true |
adf29dc8a4f0a8d4420fc2aae9bd33412882db61 | Python | OliviaFortuneUCD/pythonProject68 | /Python2.py | UTF-8 | 247 | 3.03125 | 3 | [] | no_license | import pandas as pd
netflix_data= pd.read_csv("netflix_titles.csv")
netflix_data.drop(['cast','description', 'director'], axis=1, inplace=True)
print(netflix_data)
missing_values_count = netflix_data.isnull().sum()
print(missing_values_count[0:5]) | true |
5741118b7b1d460d206dd306556ae6821d4ab636 | Python | Nyandams/text-mining | /textmining.py | UTF-8 | 3,943 | 2.796875 | 3 | [] | no_license | import pandas as pd
import nltk
from wordcloud import WordCloud
import matplotlib.pyplot as plt
from collections import Counter
import seaborn as sns
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.collocations import *
from sklearn.feature_extraction.text import TfidfVectorizer
try:... | true |
34c04f0f1b6a0a589ac0cdcdf2a41e3d78c72a58 | Python | aarondewindt/cw | /cw/special_print.py | UTF-8 | 2,259 | 3.28125 | 3 | [
"MIT"
] | permissive | from io import StringIO
import numpy as np
import inspect
import yaml
def code_print(code: str, file=None, print_function=None):
"""
Print function used print out code with line numbers.
:param code: String containing the code to print.
:param file:
:param print_function: Print function to use. B... | true |
9d852f9fc3c3a4e8516adb24b9f29eade9d3c132 | Python | kumarlokesh2194/hacker-rank-solutions-python- | /problem_solving/warmup/plus_minus.py | UTF-8 | 650 | 3.21875 | 3 | [] | no_license |
import math
import os
import random
import re
import sys
# Complete the plusMinus function below.
def plusMinus(arr):
positive = 0
negative = 0
zero = 0
for i in range(0,len(arr),1):
if(arr[i]>0):
positive+=1
elif(arr[i]<0):
negative+=1
elif(arr[i]==0):... | true |
40dfebac57f95cc9dd6f6f486c290cdb4c4004ae | Python | anagrahari/Coding-Problems | /albert_and_kuna.py | UTF-8 | 2,959 | 3.875 | 4 | [] | no_license | '''
Albert is stranded on a frozen lake. He wants to know if he can make it back to shore. He is currently on a snowbank that gives him some traction,
but once he steps on the ice, he will slide in the same direction until he hits another snowbank.
There are also treacherous holes in the ice that he must avoid. As a cr... | true |
87cf8237af8985b8b4d58f09318f32ed8dba9e56 | Python | kvedula/The-Tim-s-Checker-s-AI | /src/checkers-python/StudentAI.py | UTF-8 | 11,494 | 3.40625 | 3 | [] | no_license | from random import randint
from BoardClasses import Move
from BoardClasses import Board
#The following part should be completed by students.
#Students can modify anything except the class name and exisiting functions and varibles.
class StudentAI():
DEPTH_LIMIT = 4
EARLY_GAME_TURNS = 5
TURN_COLOR_MAP = {1 ... | true |
334f81f2543ed533da21916df85f10de591973d4 | Python | Fredkiss3/kge | /kge/core/logger.py | UTF-8 | 1,193 | 2.8125 | 3 | [
"CC0-1.0"
] | permissive | import logging
import sys
# Dictionary mapping file names -> module names
_module_file_index = {}
def _build_index():
"""
Rebuild _module_file_index from sys.modules
"""
global _module_file_index
_module_file_index = {
mod.__file__: mod.__name__
for mod in sys.mo... | true |
2c06930a05958aa640e259ffaaafd6acf3bc4853 | Python | vladimercury/SiteParser | /main.py | UTF-8 | 634 | 2.546875 | 3 | [] | no_license | from html_getter import HTMLGetterUtil
from html_parser import HTMLParserUtil
from word_parser import WordParserUtil
sites = open('sites.list', 'r').read().splitlines()
sites_links = open('sites_links.txt', 'w')
sites_words = open('sites_words.txt', 'w')
for site in sites:
html = HTMLGetterUtil.get(site)
if htm... | true |
bcdbf87321c69258eab7c9be96bb7028dee83074 | Python | jgfouca/baal | /code/game/deprecated-python-code/baal_math.py | UTF-8 | 2,252 | 2.875 | 3 | [] | no_license | #! /usr/bin/env python
"""
This file contains some simple mathematical functions
"""
import math, itertools
from baal_common import prequire
###############################################################################
def exp_growth(base, value, threshold=0, diminishing_returns=None):
###########################... | true |
8a1c03aeaeb12d8bc29cc1ea5b47b344e6b2c5a7 | Python | ayang818/LeetCode | /easy/leetcode26.py | UTF-8 | 653 | 3.109375 | 3 | [
"MIT"
] | permissive | class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
lenth = len(nums)
d = {}
k = []
# 这里找到了所有重复的下标,列成列表k
for i in range(lenth):
if nums[i] in d:
k.append(i... | true |
deb338091ee9f9c61294efdd05191fb56301802a | Python | HamzaMungadi/MyApps | /DinCalendar.py | UTF-8 | 527 | 3.078125 | 3 | [] | no_license | from p1 import *
class DinPrograms:
def __init__(self, pName, startDay, startMonth, endDay, endMonth):
self.startProgram=Date(startDay, startMonth)
self.endProgram=Date(endDay, endMonth)
self.pName=pName
def Details(self):
print "Program title:\n{}".format(self.pNam... | true |
923fe6173a29b01604d9af983b860e7a8d9aceb5 | Python | fredtoh/uDacity | /P3-Wrangle-OpenStreetMap/Python_Codes/1_output_xml.py | UTF-8 | 3,960 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
There are 7 main scripts for this project:
Script #1: 1_output_xml.py
Script #2: 2_screen.py
Script #3: 3_update_problem_entries.py
Script #4: 4_audit.py
Script #5: 5_mapping_dryrun.py
Script #6: 6_clean_data.py
Script #7: 7_data_mongo.py
... | true |
fdeeb05aad0b15604246f555d92c5b2d398e6c08 | Python | 18502992073/tarena | /Handsome/month01/day03/task1.py | UTF-8 | 1,210 | 4.25 | 4 | [] | no_license | # 1.输入一个季度,打印该季度的月份
quarter = input("请输入季度,例如:第一季度")
if quarter == "第一季度":
print("该季度的月份为:1,2,3")
elif quarter == "第二季度":
print("该季度的月份为:4,5,6")
elif quarter == "第三季度":
print("该季度的月份为:7,8,9")
elif quarter == "第四季度":
print("该季度的月份为:10,11,12")
else:
print("输入错误!")
"""一个球从100m的高度落下,
每次弹回原高度的一半。
计算:1. 总... | true |
ad7cc7dfdd1a568dcc828231ba70a9fddbf20f87 | Python | kennethchn/VLAD | /VLADtoproto.py | UTF-8 | 3,251 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
#-*-coding:utf-8 -*-
import os
import numpy as np
from VLADlib import VLAD
from RWoperation import rwOperation
import itertools
from sklearn.cluster import KMeans
from sklearn.neighbors import BallTree
from sklearn.externals import joblib
import pickle
import glob
import cv2
def getDescript... | true |
d387b6813fa605984e7e9e1d4e3e7e25d1907374 | Python | framontb/Cryptography-I | /week4-progAssign.py | UTF-8 | 2,550 | 3.53125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
'''
Decrypt last block of cypher text
For decrypt one to last, some tweeks are needed:
- mensage9 = ''
- indice = 1
- delete c[2]
- for i in range(1,17):
'''
import urllib2
import sys
from lib.encrypt import strxor
c = [
'f20bdba6ff29eed7b046d1df9fb70000',
'58b1ffb4210... | true |
59e411ae25a8c1abe2b34b63e74ddb5dd6faebab | Python | lukasHD/adventofcode2019 | /Day2/day2.py | UTF-8 | 2,976 | 3.171875 | 3 | [
"MIT"
] | permissive | # https://adventofcode.com/2019/day/2
#
# --- Day 2: 1202 Program Alarm ---
#
#
#
def readOpCode(op):
if op == 1:
print("add")
return
elif op == 2:
print("mul")
elif op == 99:
print("break")
intInput = [1,9,10,3,2,3,11,0,99,30,40,50]
def loadintCode(fname='input'):
... | true |
97c30174ba87aa0dad39d0e2f2727e67a61c1a9b | Python | MichelleLochner/supernova-machine | /max_grid_search.py | UTF-8 | 9,469 | 3.234375 | 3 | [] | no_license | import max_ml_algorithms as ml_algorithms
import numpy as np
import time
def KNN_optimiser(X_train, Y_train, X_test, Y_test, param_dict):
"""
Implements a grid search parameter optimisation of the KNN classifier with respect
to ROC AUC.
INPUTS:
X_train - An array containing the features of th... | true |
52bf859eb78f20e37bc0929bbd29118af5cddb37 | Python | HellLive/Quest-o2 | /produtos.py | UTF-8 | 3,596 | 3.1875 | 3 | [
"MIT"
] | permissive | import os
tam = 5
lista = {}
class hash:
chave = None;
livre = "L";
class Controle:
def __init__(self, tam=8):
self.tam = tam
self.tabela = [hash() for _ in range(self.tam)]
def funcao_hashing(self, num):
return num % self.tam
def mostrar_hash(self):
for i in range(self.tam):
if self.... | true |
22c65cbc8fae0e2df8e65e691cb2d8f490d40368 | Python | grehujt/leetcode | /68. Text Justification/sol.py | UTF-8 | 649 | 3.34375 | 3 | [
"MIT"
] | permissive | class Solution(object):
def fullJustify(self, words, maxWidth):
ret, row, rowLen = [], [], 0
for w in words:
if rowLen + len(row) + len(w) > maxWidth:
for i in range(maxWidth-rowLen):
row[i % (len(row)-1 or 1)] += ' '
ret.append(''.join... | true |
2f3598feef47708b81d57587444f0fd59f95325f | Python | tariqrahiman/pyComPro | /leetcode/google/457/l457.py | UTF-8 | 569 | 2.65625 | 3 | [] | no_license | class Solution(object):
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
mmin,mmax=1e9,0
for num in nums:
if num > 0:
mmax = max(mmax, num)
mmin = min(mmin, num)
if mmin > 1:
... | true |
e0b0d96609fd7dae22c90b255af2287e82b35226 | Python | jessewritescode/sensorReporter-lite | /configLoader.py | UTF-8 | 4,886 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | """
Script: configLoader.py
Author: Sascha Sambale
Date: June 7th, 2016
Purpose: Loads all configurations (sensors, mqtt & rest connection, logger,...)
from the given config file (which is being passed as argument)
"""
import ConfigParser
import logging
import logging.handlers
try:
from restConn im... | true |
3d1b42038cf0bb2a04a0b3735ba025e2160fb9e9 | Python | Jeffery-Zhou/algorithm_summary | /2.company_question/stock.py | UTF-8 | 565 | 3.6875 | 4 | [] | no_license | # coding:utf-8
"""
在股市的交易日中,假设最多可进行两次买卖(即买和卖的次数均小于等于2),规则是必须一笔成交后进行另一笔(即买-卖-买-卖的顺序进行)。给出一天中的股票变化序列,请写一个程序计算一天可以获得的最大收益。请采用实践复杂度低的方法实现。
给定价格序列prices及它的长度n,请返回最大收益。保证长度小于等于500。
测试样例:
[10,22,5,75,65,80],6
返回:87
"""
class Stock:
def maxProfit(self, prices, n):
pass
| true |
213e0ac146f4ee474c9967ba8a1505b913b0ffe4 | Python | nakamura999/pyworks | /words_sort.py | UTF-8 | 361 | 3.671875 | 4 | [] | no_license | # 単語並べ替えプログラム
# (例)ターミナルで python word_sort.py 単語 単語 単語
import sys
# コマンドライン引数を使う為のモジュール
input_list = sys.argv[1:]
# 1番目の要素を取り出して別のリストにする
input_list.sort()
# sort 新しく作ったリストを並べ替える
print(input_list)
| true |
60ae8318886090a69c9e11233f835187bd8dc6e9 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_116/667.py | UTF-8 | 1,133 | 3 | 3 | [] | no_license | nb_tc = input()
def verify_won2(c, i, j, t, di, dj, n):
if n == 3:
return True
i += di
j += dj
if 0 <= i < 4 and 0 <= j < 4 and (t[i][j] == c or t[i][j] == 'T'):
return verify_won2(c, i, j, t, di, dj, n+1)
else:
return False
def verify_won(c, i, j, t):
return verify_won2(c,i,j,t,1,1,0) or \
ve... | true |
72530724bd212880fb7e99e441afd4f05342e963 | Python | hanearl/transformer | /model/encoder.py | UTF-8 | 2,442 | 2.609375 | 3 | [] | no_license | import tensorflow as tf
from tensorflow import keras
import numpy as np
from model.ffnn import PointWiseFeedForwardNetwork
from model.attention import MultiHeadAttention
from model.embedding import positional_encoding
class EncoderLayer(keras.layers.Layer):
def __init__(self, num_heads, d_model, dff, rate=0.1):
... | true |
c7768df0da8e79aa59242f43a241ab16340d4913 | Python | galdauber1/Python-Projects | /FourInArow/ex12/ai.py | UTF-8 | 562 | 3.203125 | 3 | [] | no_license | import random
class AI:
def __init__(self, game, player):
self.__game = game
self.__player = player
def find_legal_move(self, timeout=None):
"""this func return the column of the legal move"""
rand_lst=[]
for col in range(7):
if self.__game.ge... | true |
5f1a21de38c12efba0b70d0dad4e1201beb4b9a9 | Python | yodaos-project/llsdn | /test/test_enum32.py | UTF-8 | 575 | 2.859375 | 3 | [] | no_license | import unittest
from llsdn.enum32 import Enum
class Foobar(Enum):
Foo = 1
Bar = 3
class EnumTest(unittest.TestCase):
def test_new_value(self):
foo = Foobar(1)
try:
Foobar(2)
except Exception as e:
assert(isinstance(e, TypeError))
def test_eq(self):
... | true |
4eb8c057b4bba83df273a73af8a135420209844d | Python | yoshihiroo/programming-workshop | /rpi_ai_handson/digit_recognition_NN.py | UTF-8 | 1,689 | 2.75 | 3 | [] | no_license | # coding: utf-8
# ch03ディレクトリに置く
import sys, os, time, subprocess, pickle
sys.path.append(os.pardir)
import numpy as np
from dataset.mnist import load_mnist
from common.functions import sigmoid, softmax
from PIL import Image
# 学習済パラメータの読み込み
with open("sample_weight.pkl", 'rb') as f:
network = pickle.load(f)
W1, W2,... | true |
46aad0ebd05d92c79ed60541a0c8d2e90090d257 | Python | Aasthaengg/IBMdataset | /Python_codes/p03439/s198585365.py | UTF-8 | 709 | 3.3125 | 3 | [] | no_license | # https://atcoder.jp/contests/apc001/tasks/apc001_c
# nが奇数かつ同性がとなりに座ることはないので、男女は交互である。
# 制限回数が20回のところから、おそらくLogで求められる。
n = int(input())
# 0番についてクエリを投げ、結果を受け取る
q = 0
print(q)
zero = input()
if zero == "Vacant":
exit()
left = 1
right = n - 1
for _ in range(19):
q = (left + right) // 2
print(q)
s = in... | true |
b1e1488565c18c4b45757210dcd0f39a2f0d9dec | Python | preks04/netflix-rating-prediction | /data_preparation.py | UTF-8 | 1,153 | 2.75 | 3 | [] | no_license | """Convierte a un csv como la gente... Netflix te odio!.
Nuevo formato:
currentMovieID, userID, rating, rating_date
1,1488844,3,2005-09-06
1,822109,5,2005-05-13
1,885013,4,2005-10-19
1,30878,4,2005-12-26
1,823519,3,2004-05-03
1,893988,3,2005-11-17
1,124105,4,2004-08-05
1,1248029,3,2004-04-22
1,1842128,4,2004-05-09
1,2... | true |
61337b4501d3d13bb259097e2712f38403817327 | Python | johntron/johntron | /projects/gnuradio-companion-web/gnuradio-agent/server.py | UTF-8 | 1,342 | 2.546875 | 3 | [] | no_license | print 'running'
from flask import Flask, request
from .agent.runner import Runner
from json import dumps
app = Flask(__name__)
running = {}
@app.route('/', methods=['POST'])
def run():
xml = request.json['grc']
runner = Runner()
runner.run(xml)
running[str(runner.id)] = runner
message = "started ... | true |
41697da700ab9f8f83489b17e156899640092ef3 | Python | Liuxiao-0515/data-study-google-scholar | /analytics/test.py | UTF-8 | 2,028 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 29 12:10:31 2020
@author: duyen
"""
import pandas as pd
import os
dirname = os.path.dirname(__file__)
path = os.path.join(dirname, '../data', 'field_based_summary/')
ml_cit = pd.read_csv(path + 'summary_ml_top_citations.csv')
ml_hind = pd.read_csv(path + ... | true |
4c15b82ba2f6b916f0cf309f9313904e0869d14c | Python | estebanech/TallerPatrones | /TipoItem.py | UTF-8 | 515 | 3.125 | 3 | [] | no_license | class TipoItem:
def __init__ (self, descripcion, id = 0):
self.__id = id
self.__descripcion = descripcion
def __str__(self):
struct ="Id = %(Id)d, Descripcion = %(descripcion)s"
data = {'Id':self.__id, 'descripcion': self.__descripcion}
return struct % data
... | true |
760a6a1a0c4a9d9e07974c3cc38dbe7bc5b5f9c5 | Python | tonningp/linkbot-tutorials | /getting_started/driveangle.py | UTF-8 | 274 | 2.765625 | 3 | [] | no_license | import linkbot
robot = linkbot.CLinkbot("ABCD") # change to your Id
radius = 1.75 # if you are using the blue wheels, 2.0 if using the teal wheels
trackwidth = 3.69
robot.driveAngle(720)
robot.turnLeft(90,radius)
robot.driveDistance(6,radius)
robot.turnRight(90,radius)
| true |
2c12f22556205a73423561d00a685987f5f6e7d8 | Python | Petryanin/py-algorithms | /sort/heap_sort.py | UTF-8 | 322 | 3.328125 | 3 | [] | no_license | def heapify(A, last):
for i in range(last, 0, - 1):
parent = (i - 1) // 2
if A[i] > A[parent]:
A[i], A[parent] = A[parent], A[i]
def heap_sort(A):
last = len(A) - 1
heapify(A, last)
while last:
A[0], A[last] = A[last], A[0]
last -= 1
heapify(A, last... | true |
814963a816c2ea60a06b26d5df8e2b3339348d5e | Python | smartnikocj/wechaty | /features/response_message.py | UTF-8 | 1,360 | 2.703125 | 3 | [
"MIT"
] | permissive | import json
class ResponseMessage:
message_types = ['null', 'text', 'image']
def __init__(self, message_type='null', content='empty', recipients=None, mentions=None):
self.message_type = message_type
self.content = content
self.recipients = recipients
self.mentions... | true |
4b65890acf939166b7ae3158ac4c7be43c541c52 | Python | Mopolino8/thetis | /test/slopelimiter/test_slopelimiter.py | UTF-8 | 2,866 | 3.046875 | 3 | [
"MIT"
] | permissive | """
Tests slope limiters
"""
from thetis import *
from thetis.limiter import VertexBasedP1DGLimiter
import pytest
def vertex_limiter_test(dim=3, type='linear', direction='x', export=False):
"""
type == 'linear': Tests that a linear field is not altered by the limiter.
Tracer is a linear field in x|y|z... | true |
e535dccca7b9b46cef0b53ecc82dd3226b2e590d | Python | MPh-py/MPh | /mph/node.py | UTF-8 | 38,058 | 3.09375 | 3 | [
"MIT"
] | permissive | """Provides the wrapper class for a model node."""
########################################
# Dependencies #
########################################
from numpy import array, ndarray # numerical array
from jpype import JBoolean # Java boolean
from jpype import JInt ... | true |
5ca124d9fbd8b9a686932e4c7f25bad6c02b7a79 | Python | rcaneill/xnemogcm | /xnemogcm/arakawa_points.py | UTF-8 | 1,300 | 3.453125 | 3 | [
"MIT"
] | permissive | # Needs to start with variables that have 2 letters for regex
ALL_POINTS = ["UW", "VW", "FW", "T", "U", "V", "F", "W"]
class Point:
"""
Point types
TODO
"""
def __init__(self, point_type):
"""
point_type : 'T', 'U', 'V', 'F', 'W', 'UW', 'VW', 'FW'
"""
if point_typ... | true |
1b7125cc7ae30a5573fa8e883b6bf053f3b8c335 | Python | Weeeeeeeest/cnn_tensorflow | /vgg16.py | UTF-8 | 6,972 | 2.640625 | 3 | [] | no_license | import tensorflow as tf
import config as cf
import numpy as np
"""
def conv2d(x, ksize=3, in_num=1, out_num=32, stride=1, bias=False, acti='relu'):
W = tf.Variable(tf.random_normal([ksize, ksize, in_num, out_num]))
x = tf.nn.conv2d(x, W, strides=[1, stride, stride, 1], padding='SAME')
if bias:
b = ... | true |
517b095a39bf95a05e5994b5edc51fe04f769bc9 | Python | alexandraback/datacollection | /solutions_5639104758808576_1/Python/mediocrates/gcj_2015_q-1-standing-ovation.py | UTF-8 | 375 | 2.65625 | 3 | [] | no_license | g = open('A-large.in', 'r+b')
T = int(g.readline().strip())
for t in range(1,T+1):
S_max, data = g.readline().strip().split()
S_max = int(S_max)
retval = 0
total = 0
for i in range(len(data)):
total += int(data[i])
if total < i+1:
total += 1
retval ... | true |
63ad13fe4c70a92f4b0c1335bb9414c760ffc9d1 | Python | rockysays/tunasync-scripts | /helpers/tf-gen-index.py | UTF-8 | 1,827 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env python3
import json
import re
def version(v: str):
return tuple(map(int, v.split('.')))
def generate_fileindex(filelist):
fname_re = re.compile(
r'''
(?P<tensorflow>[a-z_]+?)- # match tensorflow and tensorflow_gpu
(?P<tfver>[\d.]+?)- # match version
(?P... | true |
08fbe6dfb5533f07499921f7138b81c462f4b333 | Python | singhrajat21098/reddit-image-scrapper | /reddit_image_scrapper.py | UTF-8 | 4,193 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[2]:
print("Importing Libraries...")
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup as bs
import os.path
import time
import urllib.request
import re
from datetime import date
import random
import unicodecsv as csv... | true |
47148cd8b3962d7a3bb5c8b1d66758319215b6ae | Python | e-heller/fastavro | /tests/benchmark.py | UTF-8 | 1,078 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #!/usr/bin/env python
import sys
from time import time
def timeit(name, reader):
start = time()
num_records = sum(1 for record in reader)
duration = time() - start
print('{0}: {1} [{2} records]'.format(name, duration, num_records))
def main(argv=None):
from argparse import ArgumentParser
... | true |