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
7a5db1942a33fd0923d49fa8eb9f3c38f927e76b
Python
lockbro/Python-Crash-Course
/6-2.py
UTF-8
291
4.3125
4
[]
no_license
"""6-2 用一个字典存5个人的名字以及他们喜欢的数字,最后打印成一句话。 """ favorite_number = { "Tom": 5, "Jay": 34, "Mike": 13, "Halen": 54, "Paul": 40, } for person, number in favorite_number.items(): print(person + "'s favorite color is " + str(number))
true
fbadff420eaca955ac3bc8f078d2a5ed14058734
Python
mariaserena/EasyPark-Polito
/central_server/db.py
UTF-8
4,748
2.9375
3
[ "MIT" ]
permissive
''' Created on May 18, 2015 @author: mariaserena ''' import sqlite3 import json # 0 libero 1 occupato def prepare_all(cur, conn): #create users table cur.execute("CREATE TABLE USERS (NAME text NOT NULL, SURNAME text NOT NULL, USERNAME text PRIMARY KEY NOT NULL, PASSWORD text NOT NULL, NPLATE text NOT NULL)")...
true
a95f381c30ca70a0ae54dcee1520f7778eb71433
Python
elliterate/capybara.py
/capybara/tests/session/test_unselect.py
UTF-8
3,680
2.515625
3
[ "MIT" ]
permissive
import pytest from capybara.exceptions import ElementNotFound, UnselectNotAllowed from capybara.tests.helpers import extract_results class TestUnselect: @pytest.fixture(autouse=True) def setup_session(self, session): session.visit("/form") def test_raises_an_error_with_single_select(self, sessio...
true
242ddf80719932b97404b0e481ba8df70705378b
Python
QuantumMisaka/GLUE
/scglue/graph.py
UTF-8
2,637
2.921875
3
[ "MIT" ]
permissive
r""" Graph-related functions """ from itertools import chain from typing import Any, Callable, Iterable, Mapping, Optional, Set import networkx as nx from .utils import smart_tqdm def compose_multigraph(*graphs: nx.Graph) -> nx.MultiGraph: r""" Compose multi-graph from multiple graphs with no edge collisio...
true
b468ef4016e2c7d11f4c8324412d1295cbfebd3a
Python
EkantBajaj/leetcode-Questions
/int-2-roman.py
UTF-8
829
4.0625
4
[]
no_license
#Given an integer, convert it to a roman numeral. #Input is guaranteed to be within the range from 1 to 3999. class Solution(object): def intToRoman(self,int): a=[] while(int>=1000): int-=1000 a.append('M') while(int>=900): int-=900 a.append('CM') while(int>=500): int-=500 a.append...
true
a5676a3fc685cdbdb954dbb2d6c6fe82645c97c0
Python
siddharthcurious/Pythonic3-Feel
/LeetCode/202.py
UTF-8
583
3.25
3
[]
no_license
class Solution(object): def isHappy(self, n): """ :type n: int :rtype: bool """ if n == 1: return True num_set = set() while n > 1: num = 0 for d in str(n): num += (int(d) * int(d)) if num in num...
true
ac002e885abb8b21b395a7c57040a0961599ca06
Python
0Blanck0/ShooterGame
/Shooter/ShooterGame/player.py
UTF-8
4,091
3.453125
3
[]
no_license
import pygame import constant # Player class (all function for all player) class Player(pygame.sprite.Sprite): def __init__(self, game): super().__init__() self.game = game # Basic and max health point self.health = 100 self.max_health = 100 # Basic attack point ...
true
06721d4aa983f280ba59ff524e72e72d716200e6
Python
nhespe/leetcode_practice
/boomerang.py
UTF-8
1,085
3.90625
4
[]
no_license
""" 1037. Valid Boomerang A boomerang is a set of 3 points that are all distinct and not in a straight line. Given a list of three points in the plane, return whether these points are a boomerang. Example 1: Input: [[1,1],[2,3],[3,2]] Output: true Example 2: Input: [[1,1],[2,2],[3,3]] Output: false Note: poi...
true
349cd3b77f9d00f627880d395ccc5fb67725fbcf
Python
mp5maker/library
/python/tutorial/20. download_image.py
UTF-8
289
3.125
3
[ "MIT" ]
permissive
import urllib.request def dl_jpg(url, file_path, file_name): full_path = file_path + file_name + '.jpg' urllib.request.urlretrieve(url, full_path) url = input('Enter img URL to download: ') file_name = input('Enter the file name to save as: ') dl_jpg(url, 'images/', file_name)
true
f0a241b153fb70d6e103f9533c5170c2ef6474ec
Python
gauravk268/Competitive_Coding
/Python Competitive Program/remove duplicate charcter in string.py
UTF-8
281
3.890625
4
[]
no_license
def duplicate(string): duplicatestring = "" for i in string: if i not in duplicatestring: duplicatestring += i return duplicatestring string = input("Enter the string : ") print("After removing the duplicates , the string is : ", duplicate(string))
true
a2813f03eb400dd8d37738620b806eb35ec5e31b
Python
daydreamer2023/vampyre
/test/test_trans/test_wavelet.py
UTF-8
2,045
3
3
[ "MIT" ]
permissive
""" test_wavelet.py: Test suite for the wavelet module """ from __future__ import print_function, division import unittest import numpy as np # Add the path to the vampyre package and import it import env env.add_vp_path() import vampyre as vp def wavelet2d_test(nrow=256,ncol=256,verbose=False,tol=1e-8): """ ...
true
aabd1816957fe4fd05d0a24290328bc4be94ff79
Python
RusonWong/wimg
/scripts/monitor.py
UTF-8
324
2.765625
3
[]
no_license
import time import threading def getLocalFile(fileName): path = fileName f = open(path,"r") content = f.read() f.close() return content last_proccess = "" while True: new_proccess = getLocalFile("proccess.txt") if new_proccess != last_proccess: print new_proccess last_proccess = new_proccess time.sleep(1...
true
ceefd6cc5551cfce0ba12bb3f3ab2dfae991d17f
Python
aaron0215/Projects
/Python/HW4/primes.py
UTF-8
970
4.09375
4
[]
no_license
#Aaron Zhang #CS021 Green group #This is a program to check whether input number is prime #Lead user to input a number is more than 1 #Use modulus symbol to defind whether a number is prime #When finding the number is not prime, the calculation will be terminated #If there is no number can be divided, output prim...
true
c169232153343e2a7009cb8f8c3b5ec5575cfb0b
Python
waltercoan/ALPCBES2016
/calcsalprof.py
ISO-8859-1
806
3.96875
4
[]
no_license
__author__ = 'Walter' '''Construir um programa que efetue o clculo do salrio lquido de um professor. Para fazer este programa, voc dever possuir alguns dados, tais como: valor da hora aula, nmero de horas trabalhadas no ms e percentual de desconto do INSS. Em primeiro lugar, deve-se estabelecer qual ser o seu salrio br...
true
80627b09d8868a48015eb322e898d0fa5da5ddf1
Python
wangzb-001/nnga_jxf
/GAs/strategy/Select.py
UTF-8
276
2.515625
3
[]
no_license
import numpy as np def Sl_pop_by_roulette(self, pop): probility = self.fitness / self.fitness.sum() idx = np.random.choice(np.arange(self.test_func.pop_size), size=self.test_func.pop_size, replace=True, p=probility) return pop[:, idx]
true
6895c58620bf5b95b21ea208cefafa79a1b77d6f
Python
Flashweb14/PyGameRPG
/RPG/scripts/gui/inventory/inventory.py
UTF-8
5,604
2.984375
3
[ "MIT" ]
permissive
import pygame from scripts.consts import INVENTORY_IMAGE from scripts.game_objects.game_object import GameObject from scripts.gui.inventory.cell import Cell from scripts.gui.button import Button from scripts.game_objects.armor import Armor from scripts.game_objects.weapon import Weapon from scripts.gui.error import Err...
true
25189dac669a3b7e7f5d3a21a02dfef3acaa4fc3
Python
ItsSwixel/Week5PasswordAnalyser
/app/policy_checker.py
UTF-8
1,564
3.984375
4
[]
no_license
""" Policy guidelines: - Password must be over 8 characters long - Password must contain at least 1 uppercase letter - Password must contain at least 1 number - Password must contain at least 1 special character - Password must not have 3 consecutive duplicate values """ import string """ Takes a string as a parameter...
true
8dd77afd99a7b78defd414693fbe0d28a9c5ec8d
Python
ddempsey/ENGSCI263_2019
/wairakei/wk263.py
UTF-8
21,521
2.53125
3
[ "MIT" ]
permissive
########################################################################## ########################################################################## ## ## What are you doing looking at this file? ## ########################################################################## ##############################...
true
b0243d3f1110f9d8cd5b3268f8b72cf6d7cfb84e
Python
tjcuddihy/AdventOfCode
/2020/05/five.py
UTF-8
1,506
3.25
3
[]
no_license
from math import ceil, floor with open("five.txt", "r") as f: passes = [row.strip() for row in f.read().splitlines()] def parse(code, dir_setter, start=0, end=127): if len(code) == 1: if code == dir_setter: return end else: return start mid_point = (start + end) / ...
true
1af79fd8ceddd05610ab685dbe81df7a5a2b9d71
Python
ofhasirci/swe-573
/backend/app/wikiData.py
UTF-8
2,183
2.78125
3
[]
no_license
import requests class WikiData: def __init__(self, id): wiki = requests.get('https://www.wikidata.org/w/api.php?action=wbgetentities&ids=' + id + '&languages=en&format=json') self.wikiData = wiki.json().get('entities').get(id) def getDescription(self): if self.wikiData.get('descri...
true
d8f0430251f356571be8846133aad5eff20e8d75
Python
PegasusWang/collection_python
/z42/z42/lib/jsob.py
UTF-8
1,379
3.09375
3
[]
no_license
#!/usr/bin/env python #coding:utf-8 from yajl import dumps class JsOb(object): def __init__(self, *args, **kwds): for i in args: self.__dict__.update(args) self.__dict__.update(kwds) def __getattr__(self, name): return self.__dict__.get(name, '') def __setattr__(self,...
true
18ba404cf29708596816d86e122b475eea535bed
Python
spritezl/Learning
/PythonLearn/src/Perf/log_analyse.py
UTF-8
3,084
2.75
3
[]
no_license
''' Created on Sep 14, 2016 This is a little utility to analyze LogWriterLog for user activities by minute. @author: fzhang ''' from datetime import datetime def calcActivity(logentities): import sqlite3 # from datetime import datetime # logentities = [(datetime.strptime('Tue Sep 13 12:00:10 20...
true
7e4ce5d957b362c211b8a2af02d1bd5a5e64b7cb
Python
weddy3/TPP
/07_gashlycrumb/phonebook.py
UTF-8
307
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 from pprint import pprint as pp def main(): my_phonebook = {} with open('phonebook.txt') as fh: for line in fh: my_phonebook.update({line.split(', ')[0]: line.split(', ')[1]}) pp(my_phonebook) if __name__ == '__main__': main()
true
be9cee05dc3b30e86b191d7e320ebb58c20ccb70
Python
JuanMPerezM/AlgoritmosyProgramacion_Talleres
/taller de estructuras de control de repeticion/ejercicio2.py
UTF-8
106
3.328125
3
[ "MIT" ]
permissive
""" Entradas Salidas Impares-->int-->a """ a=0 while(a<100): if(a%2!=0 and a%7!=0): print(a) a=a+1
true
8bcf01dcfb0184bf27b38e05c3122d7aa06b0e93
Python
tjdrb63/Python
/BaekJoon/Problem1302.py
UTF-8
301
3.390625
3
[]
no_license
Str = {} outPut = [] for i in range(int(input())): cnt = 0 Key=input() if(Key in Str): cnt=Str[Key] cnt+=1 Str[Key] = cnt maxValue = max(Str.values()) for s in Str.keys(): if(Str[s] == maxValue): outPut.append(s) outPut.sort() print(outPut[0])
true
ac6c63e145729052806522cb49ace58c5ca0b479
Python
kizombaciao/Python_Snippets
/__call__.py
UTF-8
281
3.34375
3
[]
no_license
class Pay: def __init__(self, hourly_wage): self.hourly_wage = hourly_wage def __call__(self, hours_worked): #print(hours_worked) return hours_worked pay_test = Pay(15) print(pay_test(8)) # the instantiated object becomes a function effectively !
true
ca94a87bdf1123cb21096347328fcc774d55c6ed
Python
jwang151/CS115
/lab4.py
ISO-8859-1
1,049
3.75
4
[]
no_license
''' Created on Sep 28, 2017 @author: jwang151 Pledge: I pledge my honor that I have abided by the Stevens Honor System. ''' def knapsack(capacity, itemList): if capacity == 0: return [0,[]] if itemList== []: return [0,[]] if itemList[0][0] > capacity: return knapsack(ca...
true
45ba085d53daa8d9d5f01553dce026b2a65cb2e7
Python
adamswater/xfuse
/xfuse/utility/core.py
UTF-8
3,453
2.953125
3
[]
no_license
import itertools as it from typing import ( Any, ContextManager, Iterable, List, Protocol, Tuple, TypeVar, Sequence, Union, ) import warnings import numpy as np from PIL import Image __all__ = [ "center_crop", "chunks_of", "rescale", "resize", "temp_attr", ] ...
true
d545de99aff9641674588058049f1d37812182fd
Python
paddydoyle/exercism-python
/largest-series-product/largest_series_product.py
UTF-8
1,177
3.796875
4
[]
no_license
from functools import reduce def largest_product(series, size): # Corner case: not entirely sure why this is a valid answer but ok if size == 0: return 1 # Test for failure inputs if not series: raise ValueError("The input string cannot be empty") if len(series) < size: r...
true
7ee6076630a157f7f21e217625cdf92b827fd298
Python
parky83/python0209
/st01.Python기초/py08반복문/py08_13_3단구구단.py
UTF-8
81
3.0625
3
[]
no_license
i=0 while i<9: i=i+1 x=3*i str=("%s * %s = %s" %(3,i,x)) print(str)
true
88b8ee8300b7d2d7937e6f4af3667ec471ce6460
Python
fossabot/leetcode-2
/4. Median of Two Sorted Arrays.py
UTF-8
286
2.75
3
[ "MIT" ]
permissive
class Solution: def findMedianSortedArrays(self, nums1, nums2): num=nums1+nums2 num=sorted(num) n=len(num) if n%2==0: mid=n//2 return (num[mid-1]+num[mid])/2 else: mid=(n+1)//2 return num[mid-1]
true
dfdbbbdf80ff3a131f9a789153624a55f21f9c20
Python
ratularora/python_code
/python/list/list_max.py
UTF-8
145
3.078125
3
[]
no_license
list1, list2 = [123, 565654, 'A','Z','gdgf'], [456, 700, 200] print "Max value element : ", max(list1) print "Max value element : ", max(list2)
true
bdf31f45a28f15d8aa618e3e8364e7018d591957
Python
Infinidrix/competitive-programming
/Day 19/search.py
UTF-8
665
3.640625
4
[]
no_license
# https://leetcode.com/problems/binary-search/submissions/ class Solution: def bin_search(self, nums, index_min, index_max, target): if index_min != index_max: index_mid = (index_min + index_max)//2 if nums[index_mid] == target: return index_mid ...
true
e2e2e71f605c25a3247753f91b79392c2f9ad9e7
Python
dgod1028/hazard_model
/Utils/topwords.py
UTF-8
3,361
2.515625
3
[]
no_license
from tqdm import tqdm import pickle as pk from random import seed import numpy as np import pandas as pd from statsmodels.distributions.empirical_distribution import ECDF import copy from gensim.models.ldamulticore import LdaMulticore def ecdf(data): # create a sorted series of unique data cdfx = np.sort(data...
true
a175a8f219e97e564ec80870a6ab2a8bd69a5d06
Python
jacquev6/DrawTurksHead
/DrawTurksHead/color.py
UTF-8
1,425
2.546875
3
[ "MIT" ]
permissive
# coding: utf8 # Copyright 2015-2018 Vincent Jacques <vincent@vincent-jacques.net> import unittest from ._turkshead import hsv_to_rgb class HsvToRgbTestCase(unittest.TestCase): def test_red(self): self.assertEqual(hsv_to_rgb(0., 1., 1.), (1, 0, 0)) def test_yellow(self): self.assertEqual(h...
true
fd0427eab34ae3506201488402fa61b65de59285
Python
leoisl/pandora_paper_roc
/evaluate/vcf_filters.py
UTF-8
972
2.59375
3
[ "MIT" ]
permissive
from .vcf import VCF from collections import UserList from .coverage_filter import CoverageFilter from .strand_bias_filter import StrandBiasFilter from .gaps_filter import GapsFilter class VCF_Filters(UserList): def record_should_be_filtered_out(self, vcf_record: VCF) -> bool: return any( vcf_...
true
9acc49d90f1b3792ed8e1cf8396ba065faa30ddd
Python
18501955449/hexin_Week4Homework_Mnist
/week4_lbp_mlp_mnist.py
UTF-8
3,719
2.703125
3
[]
no_license
#coding:utf-8 import torch from torchvision import datasets,transforms from skimage.feature import local_binary_pattern import torch.utils.data as Data import numpy as np import torch.nn as nn def get_feature(x): '''提取LBP特征 params:x为灰度图像 return:x的LBP特征''' radius = 1 # LBP算法中范围半径的取值 n_po...
true
41d311e307bfbeb324e5120f9333ee846e940651
Python
dennis1219/baekjoon_code
/math1/2775.py
UTF-8
127
3.046875
3
[]
no_license
import math t = int(input()) for i in range(t): k = int(input()) n = int(input()) c = math.comb(n+k,n-1) print(c)
true
7b3fb3d613c6cff886fdedb8f148fadcd3028bfa
Python
lfdebrux/n_bodies
/util/coroutines.py
UTF-8
2,148
3.078125
3
[]
no_license
def coroutine(func): """coroutine decorator""" def start(*args,**kwargs): cr = func(*args,**kwargs) cr.next() return cr return start @coroutine def printer(): import sys try: while 1: p = [] while 1: buf = (yield) if buf == None: break p.extend(buf) sys.stderr.write('\r') sys.std...
true
319e257c3f7631dcec4d9ed5ffead275899d5016
Python
sam78640/DodgeThat
/images/new_bars/fix_png.py
UTF-8
490
2.65625
3
[]
no_license
import os import subprocess def system_call(args, cwd=""): print("Running"+'{}' "in" +'{}'+format(str(args), cwd)) subprocess.call(args, cwd=cwd) print ("Fixing") pass def fix_image_files(root=os.curdir): for path, dirs, files in os.walk(os.path.abspath(root)): # sys.stdout.writ...
true
e07925111fbd7be0e03ab5f1baacc1a2a780d1c1
Python
malshaCSE14/IEEEXtreme10.0-InvalidSyntax
/unreliable.py
UTF-8
269
2.578125
3
[]
no_license
T = input() for t in range(T): questions, lies = map(int,raw_input()) rawOutput = ["rgb"] * 10 rawOutput = ["rgb"]*10 for q in range(questions): questions = raw_input().split() answer = raw_input() for l in range(lies):
true
5a681d4fd0377b412ab50cecf12f23d9d06471a4
Python
shen777/SSPBB
/lb.py
UTF-8
6,697
2.953125
3
[]
no_license
import instance import KTNS import DynamicHungarianAlgorithm import copy import pickle inf = 1000 class Edge : def __init__(self, arg_src, arg_dst, arg_weight) : self.src = arg_src self.dst = arg_dst self.weight = arg_weight class Graph : def __init__(self, arg_num_nodes, arg_edgelist,i) : ...
true
5f32256695bf13b14e2aee18c670dd88b68e1233
Python
abirmoy/Python-Practice
/More Practice/6.String Lists-plaindrome.py
UTF-8
323
3
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri May 24 00:27:16 2019 @author: Abirmoy """ # -*- coding: utf-8 -*- """ Created on Tue May 21 20:38:01 2019 @author: Abirmoy """ string = 'heeh' if string[:]==string[::-1]: print("Plaindrome") else: print("Normal") ...
true
d888fb6d40715c2d43c193f0e5e9e16ad593eda2
Python
martin-majlis/Wikipedia-API
/tests/langlinks_test.py
UTF-8
1,962
2.609375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- import unittest from tests.mock_data import user_agent from tests.mock_data import wikipedia_api_request import wikipediaapi class TestLangLinks(unittest.TestCase): def setUp(self): self.wiki = wikipediaapi.Wikipedia(user_agent, "en") self.wiki._query = wikipedia_api_reque...
true
d8c6d615f1c4514bf960a3700f0203dd3cc4edff
Python
aleman844/Fama-French-3-Factor-Model-Implementation
/FF3factor.py
UTF-8
20,264
3.53125
4
[]
no_license
""" Fama-French-Three-Factor-Model Implementation ---------------------------------------------------------------------------------------------------------------- Here is the workflow of the model realization in this file: 1) Get data (ticker pool, S&P500, risk free rate, close price, market cap and book-to-market ...
true
8b5db5fc50254cc86496d8565f84e4b1b156718a
Python
cicihou/LearningProject
/sql/sqlzoo_09_quiz.py
UTF-8
1,029
3.140625
3
[]
no_license
''' QUIZ Self join Quiz SELF JOIN quiz https://sqlzoo.net/wiki/Self_join_Quiz ''' ''' 1. Select the code that would show it is possible to get from Craiglockhart to Haymarket SELECT DISTINCT a.name, b.name FROM stops a JOIN route z ON a.id=z.stop JOIN route y ON y.num = z.num JOIN stops b ON y.stop=b.id WH...
true
2aac70f3c6d5f55fc2099f2fe80db59f45407b0f
Python
becerratello/mido
/mido/backends/_common.py
UTF-8
4,362
2.859375
3
[ "MIT" ]
permissive
""" These classes will be made publicly available once their API is settled. For now they should only be used inside this package. """ import time from .. import ports from ..parser import Parser from ..py2 import PY2 if PY2: import Queue as queue else: import queue class ParserQueue: """ Thread safe...
true
eed60ec257f6cfbe0640d2a5ca2a40ba5204cacb
Python
pierrotpetitpot/COMP472_A2
/main.py
UTF-8
375
3.25
3
[]
no_license
from depthFirst import depthFirstAlgorithm from iterativeDeepening import iterativeDeepeningAlgorithm from aStar import aStarBoth # initial state of the puzzle initial_state = [1, 2, 7, 4, 5, 6, 3, 8, 9] # calls the different algorithm with the specified initial state depthFirstAlgorithm(initial_state) iterativeDeep...
true
302938e4c7246f056f16eca13b5e8c9049a46eaf
Python
aaronLinLu/GTFS_navigationTool
/CreateNetworkDataset - HoMing.py
UTF-8
10,966
2.578125
3
[]
no_license
# Name: Generate Transit Lines and Stops # Author: Lin # Description: Create a feature dataset # Import system modules import arcpy from arcpy import env from operator import itemgetter import sqlize_csv import hms import sqlite3, os, operator, itertools, csv, re from sets import Set # enable file ov...
true
c8e64ef5914cb3c0386abf5e9e81ba15bf83988a
Python
rbarbioni/python-flask-api
/tests/unit/dao/test_user.py
UTF-8
2,971
2.578125
3
[ "Apache-2.0" ]
permissive
from alchemy_mock.mocking import AlchemyMagicMock from unittest import TestCase from unittest.mock import MagicMock, patch from app.dao import user class TestDaoUser(TestCase): user_mock = { 'id': 1, 'name': 'User 1', 'email': 'user1@email.com' } def setUp(self): self.ses...
true
359f51f47e6720d93f5113d676824d362f655da7
Python
hyteer/work
/Python/Test/Process/Test/first.py
UTF-8
150
2.59375
3
[]
no_license
from multiprocessing import Pool list = range(1,20,3) def f(x): return x*x if __name__ == '__main__': p = Pool(5) print(p.map(f, list))
true
3ff7a7f40e5b600fb50bc23908a2912203962fb3
Python
manikos/EDX
/6.00x Files/W2_L4_P5_function_without_if.py
UTF-8
377
2.84375
3
[]
no_license
x=1 lo=2 hi=3 z=min(max(x,lo),max(lo,hi)) print 'z=', z ##x=5 ##lo=2 ##hi=3 ## ##z=min(max(x,lo),max(lo,hi)) ##print 'z=', z ## ##x=2 ##lo=2 ##hi=3 ## ##z=min(max(x,lo),max(lo,hi)) ##print 'z=', z ## ##x=3 ##lo=2 ##hi=3 ## ##z=min(max(x,lo),max(lo,hi)) ##print 'z=', z ## ##x=4 ##lo=3 ##h...
true
e1c33e0c84899a295cf8809ba5176412cad74f5d
Python
imagilex/tereapps
/app_reports/templatetags/app_reports_tags.py
UTF-8
2,242
2.53125
3
[]
no_license
from django import template from app_reports.models import Esfera register = template.Library() @register.inclusion_tag('app_reports/esfera/card.html') def esfera_card(user, context, include_title="no"): """ Inclusion tag: {% esfera_card user %} """ esferas = [] for esfera in Esfera.objects.all(...
true
c192c233ba68e230ac7fa33329bb07488c62aa59
Python
gistable/gistable
/dockerized-gists/3787790/snippet.py
UTF-8
4,877
2.609375
3
[ "MIT" ]
permissive
#Retrive old website from Google Cache. Optimized with sleep time, and avoid 504 error (Google block Ip send many request). #Programmer: Kien Nguyen - QTPros http://qtpros.info/kiennguyen #change search_site and search_term to match your requirement #Original: http://www.guyrutenberg.com/2008/10/02/retrieving-googles-c...
true
e1899d183cee46bd15c7f65b64140d01321246e6
Python
Ellissquires/k-color-image
/kconvert.py
UTF-8
784
2.703125
3
[]
no_license
import os,sys from PIL import Image from sklearn.cluster import KMeans import numpy as np filename = sys.argv[1:][0] img = Image.open(filename).convert('RGB') width, height = img.size pixel_colors = [] for x in range(width): for y in range(height): r,g,b = img.getpixel((x,y)) color = [r,g,b] ...
true
014d8f94cc9bbcba3ffc551892c50426102b21a5
Python
jfidelia/python_master
/exercises/12-Last_two_digits/app.py
UTF-8
216
4.15625
4
[]
no_license
#Complete the function to print the last two digits of an interger greater than 9. def last_two_digits(num): print(num % 100) #Invoke the function with any interger greater than 9. last_two_digits(32344224789)
true
bc714b0a9309061cc13e3fb35be4af31367da720
Python
TalRodin/leetcode_design
/ZigZagIterator.py
UTF-8
768
3.484375
3
[]
no_license
class ZigZagIterator(): def __init__(self, v1, v2): if len(v1)==0: v1,v2=v2,v1 self.currVec=v1 self.nextVec=v2 self.currIdx=0 self.nextIdx=0 def next(self): ret = self.currVec[self.currIdx] self.currIdx+=1 if self.nextIdx<len(self.nextV...
true
97d1ab750b6d0a97195ef19b9c3298d293ce211a
Python
best-doctor/flake8-adjustable-complexity
/tests/test_config.py
UTF-8
2,278
2.515625
3
[ "MIT" ]
permissive
import pytest from flake8.exceptions import ExecutionError from flake8_adjustable_complexity.config import DEFAULT_CONFIG @pytest.mark.parametrize( ('args', 'max_mccabe_complexity'), [ (['--max-mccabe-complexity=5'], 5), (['--max-adjustable-complexity=10'], 10), ([], DEFAULT_CONFIG.ma...
true
d429b7dee4658726a5b4c21a17339e8366166ca0
Python
jdeepee/biglegal-model-loading-prototyping
/test_model.py
UTF-8
1,503
2.75
3
[]
no_license
#!/usr/bin/env python from model import Model import numpy as np import pickle as pkl import tensorflow as tf import sys def to_list(prediction, length): list_location = [[], [], [], [], [], [], [], [], []] current_line = 0 prediction = np.argmax(prediction, 2) print prediction.shape print length.s...
true
bd078d74505a660456db749deff1eddbf29992f5
Python
NatGr/annotate_audio
/split.py
UTF-8
7,096
2.6875
3
[]
no_license
import argparse import os import pandas as pd from tqdm import tqdm from pydub import AudioSegment import subprocess import re if __name__ == "__main__": parser = argparse.ArgumentParser("""Extracts audio, and splits it into smaller files""") parser.add_argument("--input", help="big audio file", required=True...
true
cc7635164037a9e33ea465c3e93841aa7033d488
Python
LukaszMajkut/codewars-katas
/[5kyu]Prime number decompositions.py
UTF-8
1,735
3.515625
4
[]
no_license
''' https://www.codewars.com/kata/53c93982689f84e321000d62 ''' def getAllPrimeFactors(n): if isinstance(n, int) is False or n <= 0: return [] elif n == 1: return [1] else: result = [] divider = 2 while n != 1: if n % divider == 0: result.append(divider) ...
true
c601d04fa1260a1864dae1e6535d661a6614954a
Python
googoles/pytorch_Practice
/Tutorials/neural_network.py
UTF-8
1,843
3.328125
3
[]
no_license
# 숫자이미지 분류 ''' 신경망의 일반적인 학습 과정은 다음과 같습니다: 학습 가능한 매개변수(또는 가중치(weight))를 갖는 신경망을 정의합니다. 데이터셋(dataset) 입력을 반복합니다. 입력을 신경망에서 전파(process)합니다. 손실(loss; 출력이 정답으로부터 얼마나 떨어져있는지)을 계산합니다. 변화도(gradient)를 신경망의 매개변수들에 역으로 전파합니다. 신경망의 가중치를 갱신합니다. 일반적으로 다음과 같은 간단한 규칙을 사용합니다: 새로운 가중치(weight) = 가중치(weight) - 학습률(learning rate) * ...
true
34cb4fb2f8726095ca508893b5e896e59df5f479
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_199/1622.py
UTF-8
954
3.328125
3
[]
no_license
# input() reads a string with a line of input, stripping the '\n' (newline) at the end. # This is all you need for most Google Code Jam problems. import sys def runtest(case, k): s = [x for x in case] count = 0 for i in range(0,len(s)-(k-1)): if s[i]=='-': count+=1 for m in range(k): s[i+m]= '+' if s...
true
d74050823f7d88b9d49143cf4e91a592d5b3104f
Python
edu-athensoft/ceit4101python
/stem1400_modules/module_10_gui/s07_event/s072_keyboard/kbd_focus_2.py
UTF-8
1,119
3.859375
4
[]
no_license
""" Event handling Keyboard event <FocusIn> <FocusOut> """ from tkinter import * def handle_focusin(widget): # print(f"FocusIn event came from {widget} - {eval(widget).focus_get()}") print(f"FocusIn event came from {widget}") print(type(widget.focus_get())) def handle_focusout(widget): # print(f"Fo...
true
e8df8c330ec533f1c1f6f25d1641ae9522a96361
Python
Sujitha03/python-programming
/palindrome.py
UTF-8
78
3.28125
3
[]
no_license
n=int(input()) b=str(n)[::-1] if(b==str(n)): print("yes") else: print("no")
true
93858290ad1f8cca989c3cf99f83d1d3b8441a36
Python
imxyu/PyTorch-Fashion-MNIST
/Fashion-MNIST_conv.py
UTF-8
4,726
2.71875
3
[]
no_license
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torchvision import matplotlib.pyplot as plt NUM_TRAINING_SAMPLES = 50000 EPOCHS = 100 learning_rate = 0.001 device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") # device = torch.device("cpu") dataset = tor...
true
bbeb4abf9e9256fbcaac333390d65ea2ebd4fad7
Python
JJ-learning/Introduccion-a-los-Modelos-Computacionales
/Practicas/P3/rbf2.py
UTF-8
10,640
3.171875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on Wed Oct 28 12:37:04 2016 @author: pagutierrez """ # TODO Incluir todos los import necesarios import click import numpy as np import pandas as pd import sklearn @click.command() @click.option('--train_file', '-t', default=None, required=True, ...
true
cd8316afdc91eb0ef1c74ac0ac3bf0283ee6ff2f
Python
joeriking/project-euler
/p002.py
UTF-8
338
3.28125
3
[]
no_license
# # Solution to problem 2 of Project Euler # Copyright (c) 2021 Joeri King. All rights reserved. # https://github.com/joeriking/project-euler # fibonacci = [1] i = 2 while i < 4000000: fibonacci.append(i) i += fibonacci[-2] even = [] for j in fibonacci: if j % 2 == 0: even.append(j)...
true
07d66f3f5d97352f2478c654965669cee9a5be65
Python
sivaneshl/python_data_analysis
/stack/62414149/search-values-from-a-list-in-dataframe-cell-list-and-add-another-column-with-res.py
UTF-8
242
2.921875
3
[]
no_license
import pandas as pd df = pd.DataFrame({'A': [['KB4525236', 'KB4485447', 'KB4520724', 'KB3192137', 'KB4509091']], 'B': [['a', 'b']]}) findKBs = ['KB4525236','KB4525202'] df['C'] = [[x for x in findKBs if x not in df['A'][0]]] print(df)
true
8f3ef54bc0f79b3dd89555626c3e9a33d26f831a
Python
shiraWeiss/NYC-MLProject
/Data/BuildingAge/BuildingAge.py
UTF-8
598
2.859375
3
[]
no_license
from Data.Apartments.Apartments import * class BuildingAge: def __init__(self): self.apts = Apartments.getInstance() self.addAgeToApts() def calcAgeOfApartment(self, apt_row_from_table): year_built = apt_row_from_table[1] return 2017 - year_built def addAgeToApts(self): ...
true
3d979026af51d1b207568df4aaf68e03b4b6c368
Python
DestinyofYeet/antonstechbot
/cogs/earth2.py
UTF-8
997
2.75
3
[ "MIT" ]
permissive
from discord.ext import commands import discord import requests class Earth2(commands.Cog): def __init__(self, client): self.client = client @commands.command(name="earth2") async def earth2_command(self, ctx): url = "https://earth2stats.net/api/get_countries/199" response = reque...
true
926f9885ce86ad903da8d0aa57ce0ab05493d8e3
Python
albertoseabra/project_github
/visual.py
UTF-8
2,634
3.234375
3
[]
no_license
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import folium import os import re os.chdir('c:\\precourse\project\project_github\data') data_file = pd.read_csv('new_comparison.csv', encoding='latin1') columns = ['average_area', 'average_rent', 'average_rent_per_m2', 'number_contracts'] leg...
true
a1f051b03c4a3d164bc46d9b3f7bfef1c80af95e
Python
McGeeForest/grpc_w2m_framework_m
/test/t.py
UTF-8
142
2.640625
3
[]
no_license
import threading def run(): for t in threading.enumerate(): print(t) print(t.name) if __name__ == '__main__': run()
true
fa5a26b030ac63fc67ddd1837600f259e08b94ff
Python
zzzchangezzz/dnd_help
/data/spells.py
UTF-8
1,158
2.65625
3
[]
no_license
import sqlalchemy from sqlalchemy import orm from .db_session import SqlAlchemyBase class Magic(SqlAlchemyBase): __tablename__ = 'magic' id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, autoincrement=True) title = sqlalchemy.Column(sqlalchemy.String, nullable=Fals...
true
cbaea7f4e033b3c75eea1a4bf89485bb70a75bb4
Python
yangyang-li/6.854-project
/src/test.py
UTF-8
3,603
3.25
3
[]
no_license
import networkx as nx from networkx import min_cost_flow_cost as min_cost_flow from max_concurrent_flow import * ''' Test suite for max concurrent flow algorithms Types of test cases we want to build: -Easy test case with one commodity, solvable by hand -Easy test case with more than one commodity,...
true
bf47fea292e85b014fcb9aaaee8012a8bcdec76a
Python
sometimescasey/csc2515-411
/hw1/work/verbose/hw1_code_verbose.py
UTF-8
4,099
2.671875
3
[]
no_license
import warnings # conda installed sklearn 0.19.2 # https://github.com/scikit-learn/scikit-learn/pull/11431/files # Suppress warning for now, manually upgrade to 0.21 later with warnings.catch_warnings(): warnings.filterwarnings("ignore",category=DeprecationWarning) from collections import Mapping, defaultdict imp...
true
b99df2e1f5a09fab099c126ac9e8fa4cd3ef7f5c
Python
jmocay/solving_problems
/binary_tree_find_nodes_with_sum_k.py
UTF-8
1,660
4.34375
4
[]
no_license
""" Given the root of a binary search tree, and a target k, return two nodes in the tree whose sum equals k. For example, given the following tree and k of 20 10 / \ 5 15 / \ 11 15 Return the nodes 5 and 15 """ from collections import deque """ Runs ...
true
089060a274d1b09a32d26d9eecdf96cf39f14bb6
Python
ArbelRivitz/Four-in-a-row-game
/runner.py
UTF-8
4,114
3.1875
3
[]
no_license
############################################################# # FILE : runner.py # WRITER : arbelr, noamiel,207904632, 314734302,Arbel Rivitz, Noa Amiel # EXERCISE : intro2cs ex12 2017-2018 # DESCRIPTION: # In this excercise we made the game four in a row. This game is moduled to different parts. There is some par...
true
dcc23b0f2ba1f769483ac2591b2b7d94b415a98f
Python
daniel-reich/turbo-robot
/87YxyfFJ4cw4DsrvB_15.py
UTF-8
1,417
3.78125
4
[]
no_license
""" Create a function that takes in parameter `n` and generates an `n x n` (where `n` is odd) **concentric rug**. The center of a concentric rug is `0`, and the rug "fans-out", as show in the examples below. ### Examples generate_rug(1) ➞ [ [0] ] generate_rug(3) ➞ [ [1, 1, 1], [...
true
e4cd6674f7f91a93af64e7a394ab384e256a3087
Python
gistable/gistable
/all-gists/3522314/snippet.py
UTF-8
2,230
3.125
3
[ "MIT" ]
permissive
class Accessor(object): def __init__(self, wrapper, d): self.wrapper = wrapper self.d = d def __repr__(self): return repr(self.d) def _get_failback(self, k): chained = self.wrapper.chained if chained: return chained.data[k] def __getitem__(self, k):...
true
3d8344fca13cd573741ad09a1b96fa6a55f28dcb
Python
sanskrit-lexicon/PWK
/pwkvn/step0/page299/addnum.py
UTF-8
715
2.734375
3
[]
no_license
#-*- coding:utf-8 -*- """addnum.py """ import sys,re,codecs def addnum(lines): recs = [] n0 = 172000 for iline,line in enumerate(lines): num = n0 + iline + 1 ident = '%07d' %num newline = re.sub('<p pc=','<p n="%s" pc=' %ident,line) recs.append(newline) return recs def write(fileout,lines): with codecs...
true
5e44dcecd772d92c9769e299ecbd101cc08ee6e8
Python
IvanaH/PyTest
/Py_ChatDemo/ChatClient.py
UTF-8
335
2.5625
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on 2017/10/19 @author:Ivana ''' # Echo client program import socket,time HOST = '10.1.80.209' PORT = 43502 a = (HOST,PORT) s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(a) s.sendall("Hello World") data = s.recv(1024) s.close() print"Rec...
true
b65f86fe3ecdba9c95fee59426c58447372d15b7
Python
kbharathala/ProjectEuler
/Question 24.py
UTF-8
513
3.515625
4
[]
no_license
def fact(num): ans = 1 for n in range(num,1,-1): ans = ans * n return ans def perm(number): list = [0,1,2,3,4,5,6,7,8,9] ans = [] hold = number for n in range(9,-1,-1): residue = int(hold/fact(n)) #print(residue) ans.append(list[residue]) list.pop(res...
true
2d87d3933cf381a5acfd2f32a6a57639754b228b
Python
idow09/follow_up
/data_structures.py
UTF-8
3,478
2.90625
3
[]
no_license
import math from utils.utils import * @auto_str class SampleData: """ A class to bundle all data for a single image (image_path, labels, predictions, stats, etc.) """ def __init__(self, path, labels, preds, time, scale, algo_id): self.path = path self.labels = labels self.pre...
true
5d926632a1e63f82ef08795a7d5a1ca707e6f9ca
Python
kentaro7214/programs
/for_chords.py
UTF-8
6,026
2.84375
3
[]
no_license
#%% 引数1にBPM,引数2にループ回数をとってる。 import random import os import numpy from scipy.io import wavfile import pyaudio import wave import sys import fcntl import time import pandas as pd import math import threading #%% コードと度数と周波数の定義。key_frequencyにキーと周波数の辞書として格納 tone = ["Ab","A","A#","Bb","B","C","C#","Db","D","D#","Eb","E","F",...
true
88ec8cff2274a35a0679a87a5f961fae65ce4974
Python
LnC-Study/Acmicpc-net
/Dynamic Programming/2011 암호코드/sdk_python.py
UTF-8
804
3.109375
3
[]
no_license
MOD = 1000000 def data_in(): return input() def isAlpha( prev, ch2): return 10 <= int( prev['ch'] + ch2) <= 26 \ if prev['ch'] != None else False def solution( code): prev = [{'ch': None, 'count': 1} for _ in range(2)] for ch in code: try: int(ch) except: return 0...
true
01b6dd6d7c334187a3daed7210f51cff2b65ad37
Python
bak-minsu/geditdone
/geditdone/stories/US23.py
UTF-8
917
3.0625
3
[]
no_license
from geditdone.error_objects import GedcomError, ErrorType def unique_names_and_birth_date(parser): """Returns errors for individuals sharing a name and a birth date""" individuals = parser.individuals errors = [] indivs_by_name_birthdate = {} for indi in individuals.values(): # If name or...
true
e64e774b10694402fad2d039ba7b759dc6eea992
Python
alphasaft/werewolf_bot
/bot/devtools.py
UTF-8
15,885
2.75
3
[]
no_license
import discord from discord.ext.commands import has_permissions import asyncio import datetime import time import re import random from assets.constants import PREFIX, TIMEZONE # Exceptions class DevCommandNotFound(discord.DiscordException): def __init__(self, command): self._msg = "The dev command %s co...
true
43db991ba3f3d5618254787c4ed9e2acc670ee43
Python
akashsengupta1997/continuous_optimisation
/evolution_strategy.py
UTF-8
16,534
3.3125
3
[]
no_license
import numpy as np import math import time class EvolutionStrategy: """ Contains all methods for evolutionary strategy optimisation. """ def __init__(self, objective_func, num_control_vars, elitist=False, full_discrete_recombination=False, global_recombination=False): """ ...
true
fdf2084b20910b1c9903c7ad39f52d601858b794
Python
dilshod/python-sitemap
/tests/test_urlset.py
UTF-8
1,747
2.796875
3
[ "BSD-2-Clause" ]
permissive
import unittest import os from urlparse import urlparse from sitemap import * class TestUrlSet(unittest.TestCase): def setUp(self): self.base = os.path.dirname(os.path.abspath(__file__)) self.fixtures = os.path.join(self.base, 'fixtures') self.small_sitemap = os.path.join(self.fix...
true
c5cacdd2bd2361330d50a963468c4b18b8445c93
Python
ravenkls/Blob-Climbers
/main.py
UTF-8
6,129
2.703125
3
[]
no_license
import pygame from pygame.locals import * import os import entities import json import random pygame.init() class GridLayout: def __init__(self, tile_width, tile_height): self.tile_width = tile_width self.tile_height = tile_height self.window_w, self.window_h = pygame.display.get_surface().get_size() self.gr...
true
775f424d4ad8b46a74074dc65561fadfbb2eca4c
Python
elpiankova/oxwall_tests
/oxwall_helper.py
UTF-8
2,959
2.53125
3
[]
no_license
from selenium.webdriver import ActionChains from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.common.by import By from custom_wait_conditions import presence_of_N_elements_located from page_objects.locators import InternalPag...
true
4ebbe5aa44f9c4de69b8639ac1418dfdabde7fa7
Python
miguepoloc/Mercury
/test/tiraled_test.py
UTF-8
813
3.609375
4
[]
no_license
# -*- coding: utf-8 -*- #Librería de tiempo import time #Librería de los GPIO import RPi.GPIO as GPIO #Variable que controla el ciclo infinito de la vizualización de la tira led tira_led = True #Ponemos los pines en modo Board GPIO.setmode(GPIO.BCM) red = 25 green = 10 blue = 9 colores = ("000", "011", "001", "101", "...
true
a511de44bbf6862bb7672f66f4515f71b5b46ecc
Python
diavy/twitter-science
/scripts/track_retweet_relation.py
UTF-8
4,334
2.65625
3
[]
no_license
#! /usr/bin/python # coding: utf-8 #######################################################################################################build up retweeting relation############################################################################################################# from parse_tweet import * import sys, os fro...
true
a61c24b094d021586225d5f11967c2cea3b2d954
Python
jin14/CS3245
/HW3/index.py
UTF-8
3,635
2.71875
3
[]
no_license
from nltk.stem.porter import PorterStemmer from nltk.corpus import stopwords as sw import os import string import nltk from collections import OrderedDict import json import math from util import tf,L2norm import sys import getopt import time stemmer = PorterStemmer() def make_dictionary(directory,dictionary_file,pos...
true
04718b8597c25ac5573b943cf66bd5e474e461c2
Python
MatteRubbiani/peach-protein
/Models/WeightModel.py
UTF-8
2,196
2.859375
3
[]
no_license
import operator from db import db from Models.SheetModel import SheetModel from Models.ExerciseModel import ExerciseModel import time class WeightModel(db.Model): __table_name__ = "weights" id = db.Column(db.Integer, primary_key=True) exercise_id = db.Column(db.Integer) weight = db.Column(db.Integer)...
true
ca794f355aa7c9da8e9a5f8feea93370544e2cea
Python
PatForAll/training_python
/basics/10-regular_expressions.py
UTF-8
2,209
3.578125
4
[]
no_license
import re ## RE MATCHES # patterns = ['term1','term2'] # # text = 'This is a string with term1, not the other!' # print('Text to be searched: "' + text + '"') # # for pattern in patterns: # print("I'm searching for: " + pattern) # # if re.search(pattern, text): # print('MATCH!') # else: # p...
true
55e8afa503f765657086d7849e72b700b520db6a
Python
matheus-bernat/Visual1ze
/server/dbtest.py
UTF-8
4,880
2.703125
3
[ "MIT" ]
permissive
import unittest from datetime import datetime from visualize import create_app from visualize.models import * app = create_app() from visualize.models import db # database is created in models module app.app_context().push() # make all test use this context db.drop_all() # make sure first test starts with empty d...
true
373a1a96cfe07abf17783489b46e08c25294e375
Python
cp-helsinge/2020-attack
/common/dashboard.py
UTF-8
3,069
3.328125
3
[]
permissive
"""============================================================================ Dashboard Show game and player status ============================================================================""" import pygame from common import globals from game_objects import setting class Dashboard: def __init__(self):...
true
6fa52af369ee4838e13a613512e941b874b1ec1a
Python
wangjcStrive/PYLeetCode
/LongestSubstringWithoutRepeatingCharacters.py
UTF-8
713
3.546875
4
[]
no_license
# -*- coding: utf-8 -*- # @Time : 5/22/2018 9:02 AM # @FileName: LongestSubstringWithoutRepeatingCharacters.py # Info: LCode 3. # solution: Hash class Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ head = 0 dic = {} res ...
true