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
d848497e2725038e7c5c3c27a5a34c1c10f46a9e
Python
danerlt/leetcode
/Python3/剑指Offer05.替换空格.py
UTF-8
780
3.53125
4
[]
no_license
# 请实现一个函数,把字符串 s 中的每个空格替换成"%20"。 # # # # 示例 1: # # 输入:s = "We are happy." # 输出:"We.are%20happy." # # # # 限制: # # 0 <= s 的长度 <= 10000 # # Related Topics 字符串 👍 360 👎 0 # leetcode submit region begin(Prohibit modification and deletion) class Solution: def replaceSpace(self, s: str) -> str: ...
true
6358917bdddb2fddd9cecada2b4568692d195e01
Python
msschambach/pythonbdd
/djangotodo/features/steps/api_create_todolist.py
UTF-8
2,634
2.859375
3
[]
no_license
import json from behave import given, when, then @given(u'an endpoint for creating a list exists') def step_impl(context): response = context.test.client.post('/api/lists/', data={}) response_content = response.content.decode('utf-8') assert response_content == '{"name":["This field is required."],"descri...
true
a3b0a205b212336c5efd269b34824d6198645d32
Python
gonzalob24/Learning_Central
/Python_Programming/PythonUhcl/Scripting/babynames.py
UTF-8
4,698
4.15625
4
[]
no_license
""" In python: Using the TXBabyNames.txt file. Write code to read it into a list. How many female records are there? Done How many male records are there? Done How many female records are there in 1910? Done How many male records are there in 1910? Done How many female records are there in 2012? Done How many male r...
true
65d6a24181482ea120d0ab6caa9dc122e1f527f8
Python
leizhen10000/crawler
/demo/selenium/locate_element/__init__.py
UTF-8
2,813
3.5
4
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- """ # @Time : 2018/8/27 10:13 # @Author : Lei Zhen # @Contract: leizhen8080@gmail.com # @File : __init__.py.py # @Software: PyCharm # code is far away from bugs with the god animal protecting I love animals. They taste delicious. ┏┓ ┏┓ ...
true
a67af1f0027ef4bcf74805907d60dc1c609d7a64
Python
vstiern/wsb-hype-alert
/data_collector/src/aux_functions.py
UTF-8
810
3.359375
3
[]
no_license
"""Aux functions""" from pathlib import Path from configparser import ConfigParser # read file def get_config_section(section, file_name="config.ini"): """ Parse config file. :param section_name: Section header name as string. :param file_name: File name of config file. Defualt name provided. :...
true
9ad79d451ea71a61a26be9ba137208493ba2cbee
Python
narahahn/continuous_measurement
/example/IRs_image_source_model.py
UTF-8
3,424
2.875
3
[ "MIT" ]
permissive
""" Computes the impulse responses in a rectangular room using the mirror image sources model * frequency-independent reflection coefficients * fractional delay interpolation using the Lagrange polynomial """ import numpy as np import sfs import matplotlib.pyplot as plt import sounddevice as sd import soun...
true
d15c10073dd452d8f4c7b999bc526f5e85fb4ab4
Python
chrisleewoo/soundbug
/iter_recurs.py
UTF-8
319
4.0625
4
[]
no_license
""" n! iterator vs recursively """ def factorial_iterative(n): for x in range(n): x *= x-n return x def factorial_recursive(n): # Base case: 1! = 1 if n == 1: return 1 # Recursive case: n! = n * (n-1)! else: return n * factorial_recursive(n-1)
true
714fcef9bda55ea216587cbd75ff696b37d74945
Python
change1q2/Learn
/pyweb/web_12_framework_v4/common/base_page.py
UTF-8
2,130
2.8125
3
[]
no_license
#!/usr/bin/env python3 #-*- coding:utf-8 -*- # email: wagyu2016@163.com # wechat: shoubian01 # author: 王雨泽 import logging import os from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import ex...
true
09727b253a93d91c09e2e2d206ff554b1c7c95a6
Python
kevin-ci/advent-of-code-2020
/chris/day-3/p2.py
UTF-8
383
3.21875
3
[ "MIT" ]
permissive
import functools from p1 import count_trees slopes = [ {'x': 1, 'y': 1}, {'x': 3, 'y': 1}, {'x': 5, 'y': 1}, {'x': 7, 'y': 1}, {'x': 1, 'y': 2}, ] with open('input.txt') as f: lines = f.read() all_trees = [] for slope in slopes: start = (0, 0) all_trees.append(count_trees(lines, start, slope)) total ...
true
144d07d7dce9f1777382b356eafea8ef2d1db955
Python
yy19970618/apriori
/genindex.py
UTF-8
4,677
2.59375
3
[]
no_license
import tensorflow.python as tf from tensorflow.python import keras from tensorflow.python.keras import layers from tensorflow.python.keras import models from tensorflow.python.keras.preprocessing.sequence import pad_sequences import os import numpy as np import sklearn.preprocessing as sp import matplotlib.pyplot as p...
true
6e2cd085d423d8062fdcdb3837adfbe2d5524bea
Python
AnnaPopovych/Automation
/lesson_3/DZ_3_1.py
UTF-8
149
3.25
3
[]
no_license
c = [-1, 2, -1, -1] def my_new_function(a): b = [] for i in a: b.append(abs(i)) b.sort() return b print(my_new_function())
true
54e60e4cac88c5037c545172ee0cdf3f92b35681
Python
lookfwd/bottlemem
/1.simple_server.py
UTF-8
3,217
2.625
3
[]
no_license
#!/usr/bin/env python3 import socket from time import sleep APP_PORT = 50000 LISTEN_BACKLOG = 1000000 LOGIN_SERVER = '52.17.32.15' LOGIN_PORT = 50001 def login(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((LOGIN_SERVER, LOGIN_PORT)) s.sendall(('login').encode()) data = s.recv(...
true
3433dbfc4cd79b584c7d56cc199f53ca2f18bca4
Python
kkristof200/py_dependencies
/kdependencies/models/installed_package.py
UTF-8
3,219
2.546875
3
[]
no_license
# --------------------------------------------------------------- Imports ---------------------------------------------------------------- # # System from typing import Optional, List # Local from .package import Package from .core import Utils # ----------------------------------------------------------------------...
true
ae6a37eb234dc865c0599488930334fcdf3eb9ac
Python
dotcs/doimgr
/lib/validator.py
UTF-8
4,463
2.578125
3
[ "MIT" ]
permissive
import os import sys import logging import re class Validator(object): UNKNOWN = 0 BOOLEAN = 1 INTEGER = 2 STRING = 3 DATE = 4 FUNDER_ID = 5 MEMBER_ID = 6 URL = 7 MIME_TYPE = 8 ORCID = 9 ISSN = 10 TYPE = 11 DIRECTORY = 12 DOI ...
true
44436bb8af3c5ecb6bad5bac4d6028a4fd9bebbf
Python
stijncoelus/python-diematic
/version2/test/read-regs.py
UTF-8
146
2.546875
3
[]
no_license
import json with open('reg-dump2.json') as data_file: data = json.loads(data_file.read()) print data for idx in data: print(data[idx])
true
b56bd5f33b41da1e0c5a168726191962cf3a49c6
Python
RiteshBhola/Assignment2_apr20
/q2.py
UTF-8
616
3.390625
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt h=0.1 x=np.arange(1,2+h,h) print(x) n=np.size(x) print(n) y=np.zeros(n) y[0]=1 def solution(t): return(t/(1+np.log(t))) def fun(y): return((y/t) - (y/t)**2) for i in range(0,n-1,1): t=x[i] y[i+1]=y[i]+h*fun(y[i]) abs_err=np.abs(y-solution(x)) rel_err=a...
true
dfc77c81543d39ddafcfeb7c7628a5ca237a705f
Python
radRares1/AI
/lab4/UI.py
UTF-8
2,920
3.078125
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Wed Mar 25 22:06:06 2020 @author: Rares2 """ from Controller import Controller,PSO from Repo import Repo from hillClimb import HillController def main(): print("1.EA") print("2.Hill") print("3.PSO") choice = int(input("Choose a method")) ...
true
82da346a6f651892c930b722b3826732537ae90e
Python
foobarna/play-gae
/main.py
UTF-8
1,292
2.65625
3
[]
no_license
from blog import * class MainPage(webapp2.RequestHandler): def get(self): self.response.out.write("Hello ma'friend!") self.response.out.write("""<br><a href="/blog">Blog</a>""") self.response.out.write("""<br><a href="/rot13">Rot13</a>""") class Rot13Handler(BaseHandler): def render_str2(self, template, **pa...
true
a973846e7719135ef78bc769e774fef87c66ef20
Python
ansayyad/Python_scripts
/getthePhoneNumberfromstring.py
UTF-8
149
2.96875
3
[]
no_license
import re phonenumregex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') mo = phonenumregex.search("My phone number is 704-048-9515") print(mo.group())
true
46b1d73348f44ff4cb00393c96576aa5b94a4d7d
Python
MaureenZOU/ECS277
/project1/config.py
UTF-8
1,674
2.609375
3
[]
no_license
import os import cv2 import numpy as np class Config(object): """ Holds the configuration for anything you want it to. To get the currently active config, call get_cfg(). To use, just do cfg.x instead of cfg['x']. I made this because doing cfg['x'] all the time is dumb. """ def __init__(se...
true
63692876e2ffd9cb2f454f010237571e5dccb5d4
Python
timvass/pyladies-ntk-praha
/lekce2-prvni-program/prvni-program-promenne.py
UTF-8
106
3.359375
3
[]
no_license
print(1) print(1 * 8) print('*' * 8) print('Soucet cisel 2 a 3 je', 2 + 3) print('Mama ma misu.' + ' Rej')
true
ca30c421ff3e9adc2fce634f06ca4d7b8647b987
Python
oliverdippel/Codewars
/Skyscraper7x7/Solver/Solution.py
UTF-8
5,799
3.3125
3
[]
no_license
class Solution: def __init__(self, boardsize): """The pure intent of this class is to sample problems""" self.boardsize = boardsize self.__board = self.sample_board(boardsize) self.clues = self.parse_clues_from_board(self.__board) def sample_board(self, problemsize): # T...
true
82dcb51aa8b8be3839406817919c45a25059c11f
Python
dadatomisin/cam2021
/mgrid/util_crc.py
UTF-8
5,513
2.78125
3
[]
no_license
import math from scipy import special import numpy as np from scipy.stats import poisson from collections.abc import Iterable # PI controller that takes as input kp, ki, current error and previous integral error def PI(Kp, Ki, err, prev_i_err): i_err = prev_i_err + err u = Kp*err + Ki*i_err return u, i_err...
true
8537c53e8ef82e7e5c80b4bfa1e27c7b0ff15e7b
Python
ckloppers/PythonTraining
/exercises/day3/dice.py
UTF-8
552
4.1875
4
[]
no_license
import random # stats data structure stats = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0} # method to roll dice def rollDice(): return random.randint(1, 6) # rolling the dice print 'Now rolling the die...' for roll in range(1, 10): currentRoll = rollDice() currentRollValueI...
true
e2479da6c35b2bf981144418f47b73126d946d7a
Python
diego2097/Retos_Programacion_3_CNYT
/src/main/BarPlot.py
UTF-8
349
3.1875
3
[]
no_license
import matplotlib.pyplot as plt import numpy as np def graficarProba(vector): print(vector) x = [] y = [] for i in range(len(vector)): x.append("Estado " + str(i+1)) for i in range(len(vector)): y.append(vector[i]) xx = np.array(x) yy = np.array(y) plt.bar(xx,yy,ali...
true
88495c33f3649022f8f4c78f6cbe20b124c08c13
Python
ymahajan98/CS771-Project
/hf_opt.py
UTF-8
28,747
2.78125
3
[]
no_license
""" Hessian Free Optimizer. Original Author: MoonLight, 2018 Modified by: rharish, 2018 """ import tensorflow as tf try: import colored_traceback.auto except ImportError: pass class clr: """Used for color debug output to console.""" OKGREEN = "\033[92m" WARNING = "\033[93m" FAIL = "\033[91...
true
c8286647c0781a4c8f8a8b3498f964443db5bb95
Python
lonesloane/Python-Snippets
/scripts_and_streams/commandline.py
UTF-8
472
3.03125
3
[]
no_license
__author__ = 'stephane' import sys class CommandLine(object): def __init__(self): pass @staticmethod def test_argv(): print('\n**********************') print( "sys.argv :") print('**********************') for argv in sys.argv: print(argv) def main()...
true
1155c29909a8b37ddc4e9cf6ea7848b0e319fca5
Python
fonsecguilherme/Exercicios
/Lista_2/10.nPerfeitos.py
UTF-8
324
4.0625
4
[]
no_license
num = int(input("Digite o número a ser verificado: ")) divisor = 1 lista = [] while num > divisor: if num % divisor == 0: lista.append(divisor) divisor += 1 print("Divisores: " +str(lista)) resultado = sum(lista) if resultado == num: print("É n perfeito.") else: print("Não é n perfeito. ")
true
989f867d88442e2bd2018921a63d077e0f090ee3
Python
amolsawant844/SEM-4
/Python-basic-programs/Inheritance and polymorphism/use_of_super.py
UTF-8
410
3.953125
4
[]
no_license
class square: def __init__(self,x): self.x=x def area(self): print("area of square=",self.x*self.x) class rectangle(square): def __init__(self,x,y): super().__init__(x) self.y=y def area(self): super().area() print("area of rectangle",self.x*sel...
true
529036edfadc357e3844ad532b7a172c24c815a0
Python
mjgpy3/CoopDataManager
/Source/Model/schema.py
UTF-8
4,133
2.828125
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
#!/usr/bin/env python # Created by Michael Gilliland # Date: Wed Aug 22 10:32:15 EDT 2012 # # """ Represents the database's structure """ import model_abstraction as m def build_model_structure(model_structure): """ This is where the model's structure is coded using abstractions from the model_abs...
true
5122d8ee3230c2b065eb22731d55b0e0616df91e
Python
kmsmith137/ch_frb_l1
/rpc_server_async.py
UTF-8
5,354
2.671875
3
[]
no_license
from __future__ import print_function import sys import threading import time import random import zmq import msgpack ''' A python prototype of how an async version of the RPC server might work. One desired property is that the server respond to client requests quickly, because we don't want requested data to drop o...
true
de87c0ad3d901c823b69a2734c3940b5c18d25d0
Python
ScottLiao920/SAUVC2019_MECATRON
/pass_gate.py
UTF-8
1,861
2.734375
3
[]
no_license
import time import cv2 import movement import localizer from camera_module import camera_thread import gesture_detection camera_front = camera_thread(0) camera_front.start() camera_down = camera_thread(1) camera_down.start() def pass_gate(pos): fwd_count = 25 find_count = 25 while True: t1 = time...
true
0b7e60cf314c6285990cc57201e058920f096b5f
Python
qicst23/Daily
/Others/brute_force_1.py
UTF-8
718
3.8125
4
[ "MIT" ]
permissive
""" 输入正整数n,按照从小到大顺序输出所有形如abcde/fghij=n的表达式,其中a~j恰好是数字0~9的一个排列,2<=n<=79 样例输入:62 样例输出: 79546/01283=62 94736/01528=62 """ def brute_force_1(n): a = 01234 while a * n <= 98765: if validate(a, a * n): # print result as required print '%05d' % (a*n) + '/' + '%05d' % a + '=' + str...
true
a2fffb4e728c3441d3293c1153c1fd7905b3698f
Python
amangour30/BINC
/motiondetect.py
UTF-8
5,337
2.96875
3
[ "BSD-2-Clause" ]
permissive
# import the necessary packages import argparse import datetime import imutils import time import cv2 import RPi.GPIO as GPIO import pigpio from PIL import Image import numpy as np from activation_functions import sigmoid_function, tanh_function from cost_functions import sum_squared_error from neuralnet import NeuralN...
true
2ff8713bfa650b1ca0c0ee6f6bd67b0bd4b03e03
Python
SoapClancy/Python_Project_common_package
/Ploting/adjust_Func.py
UTF-8
3,107
2.65625
3
[]
no_license
from matplotlib import pyplot as plt from typing import Sequence, Iterable LINESTYLE_STR = [ ('solid', 'solid'), # Same as (0, ()) or '-' ('dotted', 'dotted'), # Same as (0, (1, 1)) or '.' ('dashed', 'dashed'), # Same as '--' ('dashdot', 'dashdot')] # Same as '-.' LINESTYLE_TUPLE = [ ('solid',...
true
204ec6aed1f3198f7b4cb5fcb10b1f64b958f6d7
Python
youki-cao/Gomoku-AI
/Code_AI_Gomoku/gomoku.py
UTF-8
2,491
3.046875
3
[]
no_license
# encoding: utf-8 import os,sys curPath = os.path.abspath(os.path.dirname(__file__)) sys.path.append(curPath) import numpy, pygame import Chessboard class Gomoku(): def __init__(self): self.screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("五子棋") self.cloc...
true
657983693374ed1338cab92efc041e937a8a2e32
Python
Nedgang/adt_project
/analysis.py
UTF-8
5,853
2.984375
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Usage: Options: Authors: MARIJON Pierre, PICARD DRUET David, PIVERT Jérome. """ ########## # IMPORT # ########## # EXISTANT LIBRARY import glob import sys # SPECIFIC LIBRARY # Our command line analyser/checker import cli_parser # Our tool to split text import...
true
15e26548f03dae2020a0ec1fdd1174d17ee66eba
Python
deekew33/bogged-again
/polls/boggedagain/tensorclassifier.py
UTF-8
3,368
2.734375
3
[]
no_license
from __future__ import absolute_import, division, print_function, unicode_literals import numpy as np import tensorflow as tf import os, pickle, random, nltk, math, sqlite3, time import matplotlib.pyplot as plt def get_num_words_per_sample(sample_texts): """Returns the median number of words per sample given corp...
true
faea34a9bed62284ec2c8c946b6d34effece9935
Python
clouds56/binary_reader
/app/sqlite3_file.py
UTF-8
5,900
2.625
3
[]
no_license
import binary_reader.sqlite3_schema as sqlite3 class SQLiteFile: def __init__(self, file): self.file = file self.pages = {} self.load() def load(self): self.file.seek(0) self.config = self.readbin("header_schema", self.file.read(100)) self.tables = self.load_btr...
true
d09eb4876bbbb4b04b05aa2feaddd1ab429b9dda
Python
aliabbas1987/python-practice
/practice/functions/myMath.py
UTF-8
105
2.671875
3
[]
no_license
''' Created on Apr 2, 2020 @author: Ali Abbas ''' def sum(x,y): return x+y def sub(x,y): return x-y
true
e396ecdd25e23b59be46310bf8220793f6a2f5da
Python
YilinWphysics/Assignments
/Nbody_project/ThirdPart_Periodic.py
UTF-8
1,235
2.578125
3
[]
no_license
from functions import * ############## Periodic B.C's ################## summary = open("Summary.txt", "a") Q3_periodic_E = open("Q3_periodic_E.txt", "w") n=int(2e5) # now use hundreds of thousands of particles grid_size = 500 soften = 10 mass = 1/n v_x = 0 # initial v in x-direction v_y = 0 # initial v in y-di...
true
9384bf6881753dc361f7abe62fdde109534d45e8
Python
StopTheCCP/CCP-Database-Leak
/TranslateCSV.py
UTF-8
1,353
2.921875
3
[]
no_license
import os import time # https://pypi.org/project/google-trans-new/ from google_trans_new import google_translator def TranslateCnToEn(textCn:str) -> str: # ref https://github.com/lushan88a/google_trans_new translator = google_translator(url_suffix='us') textEn = translator.translate(textCn.strip(), lang_sr...
true
4d2a5b2449e57a71c6c9b0142d9a38287d50424a
Python
BitKnitting/FitHome_EDA
/test_find_dates.py
UTF-8
612
2.8125
3
[]
no_license
########################################################### # test_find_dates.py # Simple test that validates we can connect to the mongo db # and read records. It returns the dates in the mongo db # where there are power readings in ISODate format. ########################################################### from error...
true
fd65ee8237801ecbcf6616866eb9f5fcbc8cabe2
Python
efaguy27/engg-3130-final
/autonomous-learning-library-master/all/approximation/approximation.py
UTF-8
4,822
2.84375
3
[ "MIT" ]
permissive
import os import torch from torch.nn import utils from all.logging import DummyWriter from .target import TrivialTarget from .checkpointer import PeriodicCheckpointer DEFAULT_CHECKPOINT_FREQUENCY = 200 class Approximation(): ''' Base function approximation object. This defines a Pytorch-based function ap...
true
66c4576055eb6d6cdeb90a47765fa5c9d39c3d32
Python
springdew84/my-test-py
/zookeeper/main.py
UTF-8
1,524
2.59375
3
[]
no_license
# -*- coding:utf-8 -*- import sys #from kazoo.client import KazooClient import logging logging.basicConfig(level=logging.ERROR) # local service dir LOCAL_SERVICE = '/services/local-service' class PyZooConn(object): # init function include connection method def __init__(self): #self.zk = KazooClient...
true
ab5278dad18421b0282ffa17476bbd8fc0983994
Python
hzcheng/wikipedia-like-web-search-engine
/hadoop/mapreduce/map1.py
UTF-8
805
3.390625
3
[]
no_license
#!/usr/bin/python3 ''' Map file to read each document and and get the term frequency of each word. output: word docid ''' import sys, re # get the set of stop words. stopwords = set() with open('./stopwords.txt','r') as f: for line in f: stopwords.add(line.strip()) line_counter = -1 for line in sys....
true
d5511012cba12e11a29148b694d9ace3023be3ff
Python
tatsumanu/Mc_Gyver
/main.py
UTF-8
3,245
3.234375
3
[]
no_license
import pygame import os from pygame.locals import * from fonctions import load_image, create_a_text_object, message, victory from classes import Player, Map, Object pygame.init() # variables name = '' menu = 1 sprite = 32 play_game = True # creating the screen game window window = pygame.display.set_mode((480, 480))...
true
a037e286ed68afa9a83056bd334cf235235d959f
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_199/1798.py
UTF-8
1,178
2.9375
3
[]
no_license
class TestCase: def __init__(self, n, data, f): self.n = n self.data = data self.flip = f self.result = conv(self.data, self.flip) def p(self): return 'Case #{}: {}\n'.format(self.n,self.result) def map(strarry): v = strarry.split(' ') r = [] for u in v:...
true
6baa9f7403a1e35b71bd96f8d1aaa062e074fffa
Python
guoweiyu/NinaTools
/ninapro_example.py
UTF-8
1,232
2.546875
3
[]
no_license
from ninaeval.config import config_parser, config_setup from ninaeval.utils.nina_data import NinaDataParser DATA_PATH = "all_data/" MODEL_PATH = "all_models/" def main(): # Reads JSON file via --json, or command line arguments: config_param = config_parser.parse_config() feat_extractor = config_setup.g...
true
1224da19d1f36dc206f4e34ef17fdf69c93db33a
Python
Aasthaengg/IBMdataset
/Python_codes/p04044/s238246335.py
UTF-8
79
2.953125
3
[]
no_license
n,l=map(int,input().split());print(*sorted([input() for _ in range(n)]),sep='')
true
2676c72e15e3bf83670f74d910e48981ad88e4ae
Python
neu-vi/ezflow
/ezflow/functional/criterion/sequence.py
UTF-8
1,446
2.734375
3
[ "MIT" ]
permissive
import torch import torch.nn as nn from ...config import configurable from ..registry import FUNCTIONAL_REGISTRY @FUNCTIONAL_REGISTRY.register() class SequenceLoss(nn.Module): """ Sequence loss for optical flow estimation. Used in **RAFT** (https://arxiv.org/abs/2003.12039) Parameters ----------...
true
22cdb807dc1dd63bc932174edb664cad72ea3b26
Python
guard1000/2018_SKKU_Problem-Solving-Algorithms
/11주차_함수_코드.py
UTF-8
2,861
4.25
4
[]
no_license
#1 def ormchasun(x,y,z): if x>y: x,y = y,x if y>z: y,z = z,y if x>y: x,y = y,x print(x,y,z) a = int(input('첫번째 정수 : ')) b = int(input('두번째 정수 : ')) c = int(input('세번째 정수 : ')) print('입력:',a,b,c) print('오름차순:', end=' ') ormchasun(a,b,c) #2 버블정렬 def bubble_sort(data): ...
true
5c483e217fdf7695a57918289a605142c247bf92
Python
mossbanay/Codeeval-solutions
/swap-case.py
UTF-8
129
3.234375
3
[ "MIT" ]
permissive
import sys with open(sys.argv[1]) as input_file: for line in input_file.readlines(): print(line.strip().swapcase())
true
c0cb45f081a0dd765b30d3f77aa64a5506fc7db1
Python
RajanaGoutham/Python
/Natural Language Interface Database/Query.py
UTF-8
2,444
2.78125
3
[]
no_license
class Query: import pymysql f=open("StopWords.txt","r") list1=[] for k in f: k=k.replace('"','') list1.append(k.strip()) #print(list1) q=input("Enter Question:\n") arr=[] qn=q.split(" ") for i in qn: #print(i) if i not in list1: arr.appen...
true
3bff4959e123dacd5922127ff96480f51469ffdd
Python
jakudapi/aoc2016
/day08-1.py
UTF-8
3,792
4.1875
4
[]
no_license
""" --- Day 8: Two-Factor Authentication --- You come across a door implementing what you can only assume is an implementation of two-factor authentication after a long game of requirements telephone. To get past the door, you first swipe a keycard (no problem; there was one on a nearby desk). Then, it displays a cod...
true
923ca8285e370c66dbcc7b211f094f2c0589725c
Python
Sayak09/IPL_Powerplay_ScorePrediction
/predictor.py
UTF-8
3,474
2.546875
3
[]
no_license
def predictRuns(testInput): prediction = 0 import tensorflow as tf import pandas as pd model = tf.keras.models.load_model("model.h5",compile=False) df2=pd.read_csv(testInput) ven=df2.iloc[:,0].values inn=df2.iloc[:,1].values bat_team=df2.iloc[:,2].values bowl_te...
true
5dc8faa80f3118cb685f25c6b60f573e25f2e9eb
Python
lemonade512/DotFiles
/cli/system_info.py
UTF-8
869
2.84375
3
[]
no_license
""" Tools for retrieving information about user's system. The install script in this repository aims to support as many environments as possible, and each environment has its own tools for package management and configuration. The tools in this file are meant to detect information about the current system in a portabl...
true
5395b967f59fe2531d62f9b55389e19ae8e1f32b
Python
karolmikolajczuk/Hackerrank-Python
/merge_the_tools.py
UTF-8
1,491
3.765625
4
[]
no_license
#split string into groups def get_substrings(text, nr_of_substr, k): #create a list with precised size list_of_strings = [] #iterate through whole string for index in range(0, nr_of_substr*k, k): list_of_strings.append(text[index:index+k]) #return the list return list_of_strings #dist...
true
0ce6b06bcfe644b5eb3ae501121141fda74b8034
Python
adrianstaniec/advent_of_code
/10/sol.py
UTF-8
878
3.375
3
[]
no_license
from collections import Counter adapters = [] while True: try: adapters.append(int(input())) except Exception as e: break print(adapters) adapters.sort() adapters = [0] + adapters + [adapters[-1] + 3] print(adapters) diffs = [adapters[i + 1] - adapters[i] for i in range(len(adapters) - 1)] # ...
true
dfbaae8eaa94b21495e8861ffcb641699cc3f194
Python
gkaframanis/roommates-bill
/reports.py
UTF-8
1,686
3.375
3
[]
no_license
import webbrowser from fpdf import FPDF import os class PdfReport: """ Creates a Pdf file that contains data about the flatmates such as their names, their due amount and the period of the bill. """ def __init__(self, filename): self.filename = filename def generate(self, bil...
true
28b61fe2976dac91882bd5ec26cb8f2f9173abc8
Python
aletcherhartman/pong.py
/Old Files/paddel.py
UTF-8
818
3.078125
3
[]
no_license
VIPERimport pygame import math class paddel(object): """docstring for paddel""" def __init__(self, arg): self.X = 30 self.Y = 30 self.change_x = 0 self.change_y = 0 def makePaddel(self): paddel = paddel() # Hide the mouse cursor pygame.mou...
true
f8923e83f1b39622aa29a578535efbf72f79ba10
Python
suzySun345/algorithm011-class02
/Week_02/589.n叉树的前序遍历.py
UTF-8
640
3.28125
3
[]
no_license
# # @lc app=leetcode.cn id=589 lang=python # # [589] N叉树的前序遍历 # # @lc code=start """ # Definition for a Node. class Node(object): def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution(object): def preorder(self, root): """ :type...
true
690875d333af22341eafc7f466fe7a048d383b42
Python
ritesh-deshmukh/Algorithms-and-Data-Structures
/180Geeks/Arrays/Kadane's Algorithm.py
UTF-8
472
4.40625
4
[]
no_license
# Given an array containing both negative and positive integers. Find the contiguous sub-array with maximum sum. # arr = [1,2,3] arr = [-1,-2,-3,-4] size = len(arr) def max_subarray(arr, size): max_arr = arr[0] curr_max = arr[0] for i in range(1,size): curr_max = max(arr[i], curr_max + arr[i]) ...
true
d184ee8c4a3efedb1f76eb88b3b1eff928a30e0f
Python
pshevade/Udacity_project_2
/tournament.py
UTF-8
19,354
3.3125
3
[]
no_license
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 import random import math import bleach def connect(): """Connect to the PostgreSQL database. Returns a database connection.""" DB = psycopg2.connect("dbname=swiss_style") return DB, DB.cursor() def...
true
1fec056289fb0e90174ab903bc40bc546e70bda7
Python
junyang10734/leetcode-python
/713.py
UTF-8
566
3.359375
3
[]
no_license
# 713. Subarray Product Less Than K # Two pointers (sliding window) # https://blog.csdn.net/fuxuemingzhu/article/details/83047699 # running time: faster than 63.76% class Solution: def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int: N = len(nums) prod = 1 l, r = 0, 0 ...
true
f8bbcea5255c7796fa2552f2481dc2df2171b9c3
Python
adambemski/Python-Snake-Game
/conf.py
UTF-8
472
2.765625
3
[]
no_license
import configparser config = configparser.ConfigParser() config.read('config.ini') display_horizontal_size_x = int(config['display']['horizontal_size_x']) display_vertical_size_y = int(config['display']['vertical_size_y']) x1 = int(config['snake']['start_point_x']) y1 = int(config['snake']['start_point_y']) snake_si...
true
6faaffb98e148510c93f045a379622d7925d62bb
Python
moritzschaefer/unsupervised-text-detection
/src/predict_test_img.py
UTF-8
6,902
2.875
3
[]
no_license
#!/usr/bin/env python3 ''' This is the central main file combining all the prediction functionality. It fetches images from config.TEST_IMAGE_PATH and predicts the parts with text contained and the characters contained. TODO: integrate better character_recognition from notebook TODO2: save outputs as: for each input i...
true
627f206ab368c13e5fe88654fee79007ee5dcc31
Python
JuneKim/algorithm
/ProblemSolving/LeetCode/1935_Maximum Number of Words You Can Type.py
UTF-8
891
3.359375
3
[]
no_license
# runtime: 93.91%, memory: 56.52% class Solution: def canBeTypedWords(self, text: str, brokenLetters: str) -> int: li_txt = text.split(" ") myCnt = 0 for txt in li_txt: is_found = False for broken in brokenLetters: if broken in txt: ...
true
1e3764a9f3c93441200d68821f85546165e6d58b
Python
CodeTest-StudyGroup/Code-Test-Study
/JangWoojin/[5]백준/2014_소수의 곱.py
UTF-8
354
2.90625
3
[]
no_license
import sys from heapq import heappush, heappop, heapify input = sys.stdin.readline k, n = map(int, input().split()) primes = list(map(int, input().split())) hq = primes.copy() heapify(hq) num = 0 for _ in range(n): num = heappop(hq) for prime in primes: heappush(hq, prime * num) if num % prime =...
true
0916f474067ac371f65f4f46279de8176a141a7e
Python
2q45/Python-crash-course
/2-12.py
UTF-8
277
4
4
[]
no_license
bicycles = [1,2,3,4] print(f"My first bicycle was a {bicycles[1]}") print(f"{bicycles}") print(bicycles[1]) print(bicycles[3]) print(bicycles[0]) names = ["faiz","Akshat","Avi","Dhruv","Krishna"] print(f"\n{names[0]},\n{names[1]},\n{names[2]},\n{names[3]},\n{names[4]},\n")
true
c95bd9f3627aa0128458a805c0c085c0b4ad3359
Python
BoChenGroup/EnsLM
/mATM/losses/LossFunctions.py
UTF-8
4,434
3.484375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """ --------------------------------------------------------------------- -- Author: Jhosimar George Arias Figueroa --------------------------------------------------------------------- Loss functions used for training our model """ import math import torch import numpy as np from torch import...
true
2309c6c9ad2b06b974aa744de3dae14d93af98be
Python
mkebrahimpour/DataStructures_Python
/thinkpython/functions.py
UTF-8
304
3.765625
4
[]
no_license
# Math Functions import math print math print math.sqrt(4) # New Functions def print_lyrics(bruce): print "--------------------------------" print "I'm a lumberjack, and I'm okay." print "I sleep all night and I work all day." print "Printing Argument:",bruce print_lyrics('Spam\t' * 4)
true
e1ad8077724054a52c0a4b2c321b202a7b095488
Python
JMass1/curso_python
/desafios/DESAFIO 70.py
UTF-8
904
3.921875
4
[]
no_license
#PROGRAMA PARA CADASTRAR PRODUTOS E PREÇOS preco = soma = count = mpreco = 0 nome = saida = nbarato = '' while True: print('-'*20) print('CADASTRE UM PRODUTO') print('-'*20) nome = str(input('Nome do Produto: ')).strip() preco = int(input('Preço do Produto: ')) print('-'*20) soma += preco ...
true
b10684eb18ffd376faa3187343e1632913ec1b8d
Python
Spirent/cf-netsecopen-tests
/cf_common/CfRunTest.py
UTF-8
102,933
2.703125
3
[ "MIT" ]
permissive
import json import logging import time import sys import os import numpy as np import pandas as pd import pathlib import sys import math from dataclasses import dataclass script_version = 1.80 project_dir = pathlib.Path().absolute().parent sys.path.append(str(project_dir)) from cf_common.CfClient import * class R...
true
5ec5a4bc6491d2c8a251413bbd10bf7801777cfd
Python
barcern/python-crash-course
/chapter4/4-12_more_loops.py
UTF-8
534
4.15625
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Wed May 6 09:10:41 2020 @author: barbora """ # Choose a version of foods.py from the book and print using for loops. # Using foods.py from the book my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] my_foods.append('cannoli') friend_foods.append('ice-cre...
true
6742277e91826ea4a7b2be9957a372c18730623d
Python
NathanZorndorf/cheat-sheets
/Modules/Numpy/Numpy Cheat Sheet.py
UTF-8
333
3.34375
3
[]
no_license
#----------------------- NUMPY CHEAT SHEET -------------------------# import numpy as np #--------- 2D ----------# # Create 2D array a = np.array([[1,2,3], [4,5,6]]) # index to reference entire first row a[0] # output => array([1, 2, 3]) a[1, -2:] # output => index to reference last two column values i...
true
afed8508ee701b8b414e91d4a6428fbb9eeac579
Python
tachyon77/flat-resnet
/dataset.py
UTF-8
1,564
2.75
3
[]
no_license
"""Dataset class. Author: Mohammad Mahbubuzzaman (tachyon77@gmail.com) """ import logging import torch.nn.functional as F import torch.utils.data as data from torch.utils.data import dataset import torch import ujson as json from collections import Counter class ImageDataset(data.Dataset): """Random Dataset....
true
44ce1b0e8ce2e634d6bb04690b3d3b4f6d9a36f9
Python
artificialsoph/py_prac
/tests/test_pymat.py
UTF-8
2,101
2.78125
3
[]
no_license
from click.testing import CliRunner from pymatrix import main def assert_sub_out(command, output): runner = CliRunner() result = runner.invoke(main, command) assert result.exit_code == 0 assert result.output == output def test_import(): """ test all the input types using the sample data ...
true
80f9be7b604809dc0f596b085c578fcf74277755
Python
Dennysro/Python_DROP
/9.0_List_Comprehension.py
UTF-8
1,448
4.46875
4
[]
no_license
""" List Comprehension: - Utilizando list comprehension nós podemos gerar novas listas com dados processados a partir de outro iterável. # Sintaxe da List Comprehension [dado for dado in iterável] # Exemplos: # 1 numeros = [1, 2, 3, 4, 5] res = [numero*10 for numero in numeros] print(res) ...
true
abb619392a2595a6398247604ba9aec573884e2c
Python
Erich6917/python_littlespider
/demo/beautiful/youku/YoukuDemo.py
UTF-8
2,087
2.625
3
[]
no_license
# -*- coding: utf-8 -*- # @Time : 2018/3/26 # @Author : LIYUAN134 # @File : YoukuDemo.py # @Commment: # import urllib, urllib2, sys, os from bs4 import BeautifulSoup import itertools, re url_i = 1 pic_num = 1 # 自己定义的引号格式转换函数 def _en_to_cn(str): obj = itertools.cycle(['“', '”']) _obj = la...
true
0a8d01f90e6011b865ae553be8b3c79c0d8abe51
Python
sourcepirate/tailow
/tailow/fields/reference.py
UTF-8
941
2.640625
3
[ "MIT" ]
permissive
""" reference field """ from bson.objectid import ObjectId from .base import BaseField class ReferenceField(BaseField): """ Reference field property """ def __init__(self, kls, *args, **kwargs): self.kls = kls self._is_reference = True self._partialy_loaded = kwargs.pop("_is_partialy...
true
8dfdebe0945f30602b50053435da8871f5e0fc89
Python
SoufianLabed/serverUDP-TCP
/tcpclient.py
UTF-8
1,266
3.09375
3
[]
no_license
import socket import sys class tcpclient: def __init__(self): self.PORT=int(sys.argv[1]) # initialise le port et l'IP (broadcast) self.IP = sys.argv[2] self.sock = socket.socket(socket.AF_INET, # création du s...
true
dfe7602410da308d1ad8da255c62fd9932d1a00d
Python
wangfin/QAsystem
/QAManagement/question_generalization/similarity_test.py
UTF-8
672
2.75
3
[]
no_license
# -*- coding: utf-8 -*- # @Time : 2018/8/15 15:25 # @Author : wb # @File : similarity_test.py # 相似度计算的测试 from QAManagement.question_generalization.similarity import Similarity import time similarity = Similarity() question = '入党 积极分子 的 培养 联系人 什么时候 确定 ?' model_list = ['入党 积极分子 的 培养 联系人 什么时候 确定 ?','护卫队 到底 什么时候...
true
fddb339d9106262b651186884a85cfe73ddd71ae
Python
Gi1ia/TechNoteBook
/Algorithm/051_N_Queens.py
UTF-8
1,754
3.5
4
[]
no_license
class Solution: def solveNQueens(self, n): """ :type n: int :rtype: List[List[str]] """ if not n or n < 1: return [[]] arrangements = [] self.dfs([], arrangements, n) summary = [] # draw summary of boards for arrangement i...
true
625d2a1e13ae6c7ddadcdb587d55968babdd6a29
Python
LeoTheMighty/beginner_python_exercises
/ReverseWordOrder.py
UTF-8
169
3.890625
4
[]
no_license
sentence = input("Give me a cool sentence and I'll reverse it...\n") sent_list = sentence.split(" ") reverse_sent = reversed(sent_list) print(" ".join(reverse_sent))
true
15295d523b8ecde68a6293610bc196a03d445e0c
Python
sajidamohammad/hackerearths
/sherlocknnum.py
UTF-8
289
2.515625
3
[]
no_license
test=int(raw_input()) for i in range(test): nkp=map(int,raw_input().split(" ")) remove=map(int, raw_input().split(" ")) final=range(1,6)-remove print sorted(final)[] ''' out.append(int(raw_input())) for j in range(len(out)): if out[j] in arr: print "YES" else: print "NO"'''
true
056b5583ef5619d9ef8cca646374281f08ee14a3
Python
gschen/sctu-ds-2020
/1906101074-王泓苏/Day0303/test07.py
UTF-8
315
3.28125
3
[]
no_license
class Test01(): def __init__(self): self.t1='我是父类' def f(self): return '爸爸' class Test02(): def __init__(self): self.t2='我是子类' def f(self,object): print(object.f()) a=Test01() def main(object): print(object.f()) return '123' print(main(a))
true
234f9d0be069bd885e1b1e25db82bd2eb4e0e97e
Python
EliasFarhan/CompNet
/rdt/rdt21.py
UTF-8
2,839
2.765625
3
[]
no_license
from rdt.base import * from rdt.rdt20 import ChannelRdt20 class SenderRdt21(Sender): last_packet = "" sequence_nmb = 1 msg_lock = threading.Lock() def send_data(self, data, resend=False): if not resend: self.msg_lock.acquire() self.last_packet = data text_data = da...
true
9ecc4638f0729aa433de14f071ad253d523109e3
Python
aydan08/Python-Kursu-15.02.21
/HAFTA-3/DERS-7/FOR_DÖNGÜSÜ/for_2.py
UTF-8
359
3.921875
4
[ "MIT" ]
permissive
#1 den 100 e kadar olan tek sayıların toplamı toplam = 0 for tek_sayi in range(1,100,2): #(1 DAHİLDİR,100 DAHİL DEĞİLDİR,+2 ARTIŞ MİKTARIDIR) toplam = toplam + tek_sayi else: print("...Döngü Bitti...") print("Tek Sayıların Toplamı: ", toplam) #yerine alttaki de kullanılıyorr print(f"Tek Sayıların T...
true
110efd1c0795ca3ac85e696270fb8a487df37694
Python
skvrd/leetcode.py
/problems/1267/solution.py
UTF-8
534
2.59375
3
[ "MIT" ]
permissive
from typing import List class Solution: def countServers(self, grid: List[List[int]]) -> int: connected = 0 n = [0] * len(grid) m = [0] * len(grid[0]) for i in range(len(n)): for j in range(len(m)): if grid[i][j] == 1: n[i] += 1 ...
true
c5c5fdde707822de21042076b397011c51543709
Python
bioless/Xenocrates
/xenocrates-update-2018.py
UTF-8
9,057
2.984375
3
[]
no_license
#!/usr/bin/python import sqlite3 as sql import sys import operator import re import cgi import time import csv from collections import OrderedDict #Global Variables tablename = "SANS575_index" index = [] #Reads the CVS file into Index List filename = sys.argv[1] with open(filename, 'rU') as f: ...
true
5afaa636bb63cf51d4ccb115808547b30adb6ab2
Python
wdan/territories
/territories/models/dblp_io.py
UTF-8
9,183
2.59375
3
[]
no_license
__author__ = 'wenbin' import igraph as ig import scipy.io as sio class DBLP(object): def __init__(self, venue_id_list, fileName, type='paper', path='territories/data/dblp/'): venue_id_list.sort() self.venue_id_list = venue_id_list self.path = path self.file_name = fileName+'_'+ty...
true
27df8c7d87eea29d1cfc381b72c896df1217a0cf
Python
olgashemagina/Milk_Data
/crossval.py
UTF-8
1,322
2.53125
3
[]
no_license
import os import random import sys import shutil path = sys.argv[1] enroll_part = 0.3 #sys.argv[2] classes_part = 0.5 os.chdir(path) if os.path.exists(os.path.join(path, 'database')): shutil.rmtree(os.path.join(path, 'database')) os.mkdir(os.path.join(path, 'database')) os.mkdir(os.path.join(path, 'database',...
true
17acc2ff8cc6b0a7298b9b5af834415597b2e550
Python
dumbman/epicf
/SpatialMesh.py
UTF-8
14,128
2.625
3
[ "MIT" ]
permissive
import sys from math import ceil import numpy as np from Vec3d import Vec3d class SpatialMesh(): def __init__(self): self.x_volume_size = None self.y_volume_size = None self.z_volume_size = None self.x_cell_size = None self.y_cell_size = None self.z_cell_size = None...
true
e2c51958600316315a9c2fa4990a545931bafe11
Python
AdrianJohnston/ShapeNetRender
/Emitter.py
UTF-8
1,967
2.890625
3
[]
no_license
from __future__ import print_function from mitsuba.core import * class EmitterType: SUN_SKY = 'sunsky' SKY = 'sky' SUN = 'sun' DIRECTIONAL = 'directional' CONSTANT = 'constant' class Emitter: def __init__(self, emitter_type, sample_weight=1.0, to_world=Transform()): self.type = emitt...
true
e1ac1670fc2847f09106f53b025921bdfc9f96a9
Python
e185725/atcoder_practice
/180/c.py
UTF-8
292
3.0625
3
[]
no_license
import math N = int(input()) d = int(math.sqrt(N)) + 1 ans = [] ans_2 = [] #print(d) for i in range(1,d): if (N % i == 0): ans.append(i) if(i != int(N/i)): ans_2.append(int(N/i)) for ans in ans: print(ans) for ans_2 in reversed(ans_2): print(ans_2)
true
8ac8b294fc55b931978a8e0a1f901a0f89f03940
Python
heldersepu/hs-scripts
/Python/pyGTK.py
UTF-8
795
2.703125
3
[]
no_license
#!/usr/bin/env python ## pyGTK template import pygtk pygtk.require('2.0') import gtk class MyProgram: def __init__(self): # create a new window app_window = gtk.Window(gtk.WINDOW_TOPLEVEL) app_window.set_size_request(500, 350) app_window.set_border_width(10) ...
true
5105a26484b10537574bb5734e1e91580683ab47
Python
Shubhamsm/youtube-auto-comments
/youtube.py
UTF-8
1,662
2.90625
3
[]
no_license
import pyautogui import time from bs4 import BeautifulSoup import requests Keywords=["Neural Networks","data Science"] # keywords it search to get list of urls msg="hello" # message to comment Can def Links_list(keywords): ''' give a list of urls which bot will commen...
true
cf4b4566357aa3d036ceec834ee4438b45825c81
Python
Brain-0ut/Vielit_Python_HW
/Abto_CV_AI_2022_Camp_var_B/test2.py
UTF-8
1,324
3.375
3
[]
no_license
from typing import List import random as r def task1(x: List[int]) -> bool: ### """Write your code here""" ### lenght = len(x) if lenght < 2: return False elif lenght == 2: if x[0] == x[1]: return True else: return False x.sort() print(x)...
true
bbfde0d9d4b496aaa72d20ff643f6e8fd82fb218
Python
Debdeep1998/Backtracking_rush
/gray_code.py
UTF-8
303
2.890625
3
[]
no_license
n=int(input()) a=list() for i in range(n): a.append('0') print (a) def gray(i): if(i==n-1): print("".join(a)) a[i]='1' if(a[i]=='0')else('0') print("".join(a)) return c=1 while (c<=2): gray(i+1) if(c!=2): a[i]='1' if(a[i]=='0')else('0') c+=1 gray(0)
true