blob_id 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 |
|---|---|---|---|---|---|---|---|---|---|---|
3b324c920e0b0b06c1c1acf68251a24d2482f5f5 | luliyucoordinate/Leetcode | /src/0934-Shortest-Bridge/0934.py | UTF-8 | 2,073 | 3 | 3 | [] | no_license | class Solution:
def shortestBridge(self, A):
"""
:type A: List[List[int]]
:rtype: int
"""
x, y, r, c = 0, 0, len(A), len(A[0])
for i in range(r):
for j in range(c):
if A[i][j] == 1:
x, y = i, j
break
... | true |
4924bbc97e29b10e96703cad55d20f89d682102f | Scaremonger/sandbox | /miot_mqtt_tts.py | UTF-8 | 3,483 | 2.640625 | 3 | [] | no_license | # Modular Internet of Things, MQTT TTS interface
#
# FILE: miot_mqtt_tts.py
# AUTHOR: (c) Copyright Si.Dunford, 2019
# VERSION: 1.3
# DATE: 26 March 2019
# STATE: BETA
# LICENSE: MIT License
#
# PURPOSE:
# Listen on MQTT topic for speech instructions.
# The module allows you to control volume and speech ... | true |
4afd32cbd1866abd1506df6917f9ffa36459abaf | hrheydarian/libkeops | /pykeops/examples/generic_syntax_pytorch.py | UTF-8 | 4,358 | 3.5625 | 4 | [
"MIT"
] | permissive | """
Example of KeOps reduction using the generic syntax. This example corresponds
to the one described in the documentation file generic_syntax.md.
# this example computes the following tensor operation :
# inputs :
# p : a scalar (antered as a 1x1 tensor)
# a : a 5000x1 tensor, with entries denoted a_j
# ... | true |
ab933107e34e4a695bb4f746d7cfb1993b89a4af | husman/Computer-Science-Projects | /python/tablesort/tablesort.numbers.py | UTF-8 | 555 | 3.5625 | 4 | [] | no_license | import time
def tablesort(items):
start_time = time.time()
table = {}
for item in items:
if not isinstance(table.get(item), list):
table[item] = [item]
else:
table[item].append(item)
result = []
for items in table.itervalues():
for item in items:
... | true |
8a0ef6ff6d0cf03b62db36df426af8fed3d02b99 | Jeff-Chen-Daguan/MLB_analysis | /MLB_contract_scrapy.py | UTF-8 | 2,983 | 2.9375 | 3 | [] | no_license | # MLB合約資料爬蟲 2021.01.19
from tqdm import tqdm
import calendar
import time
from polib.CsvEngn import *
import concurrent.futures
# def mlb_contract_scrapy_year_loop(star_year, end_year=2020):
# start_time = time.time()
# result_df = pd.DataFrame(columns=range(0,4+1))
# for year in tqdm(range(star_year,... | true |
f7286d1025f1035ed69a801add4f85a15cf3bc7f | liuzijing2014/Robotics | /Intro_Robotics/labs/lab5/p_controller.py | UTF-8 | 1,352 | 3.453125 | 3 | [] | no_license | """
Robot P-Contoller for following the wall
"""
class PController:
def __init__(self, rotation_costant):
"""
Constructor
Args:
forward_constant: the default forward speed
rotation_costant: the default of turning speed (relative)
"""
self.turning_con... | true |
3cfcfb447040851dbfbb816cafe779f661212c9b | ikaros274556330/my_code | /python_1000phone/语言基础/day15-面向对象1/code/02-对象方法.py | UTF-8 | 834 | 4.53125 | 5 | [] | no_license | """__author__=吴佩隆"""
# 1.类中的方法 - 就是类中共同的功能
"""
方法 - 声明在类中的函数
类中的方法分为三种:对象方法、类方法、静态方法
"""
# 2.对象方法
"""
1)怎么声明 - 直接声明在类中的函数就是对象方法
2)怎么调用:需要对象来调用;以'对象.对象方法()'的形式来调用
3)特点:有个自带参数self,参数self在通过对象调用的时候不用传参
系统会自动将当前对象给self传参
当前对象 - 当前调用这个方法的对象
当前类的对象能做的事情,self都可以做
"""
class Dod:
# eat就是对象方法
... | true |
dc2b373f0d3dbae2c1607948b93c4f822ba7599f | praveen-oak/nyc-taxi-fare-predict | /online_regression.py | UTF-8 | 4,178 | 2.796875 | 3 | [] | no_license | import statistics
import numpy as np
import os
import math
from math import sqrt
from create_data_files import create_train_test
from sklearn.metrics import mean_squared_error
test_file = "test.vw"
prediction_file = "prediction.vw"
model_file = "model.vw"
test_command_string = "vw -t -d test.vw -i model.vw -p predicti... | true |
d9266dea0d505558a8610d74a733b6ce397be7b4 | darencard/software_carpentry_2017 | /day2/python_day2_jupyter_notebook.py | UTF-8 | 13,330 | 3.984375 | 4 | [] | no_license |
# coding: utf-8
# In[4]:
# create a new function to calculate fahrenheit by celsius
def celsius_fahrenheit():
# F = (C * 9/5) + 32
fahrenheit = (22 * (9 / 5)) + 32
print(fahrenheit)
return fahrenheit
# In[6]:
# call our new function
celsius_fahrenheit()
# In[7]:
# create a more flexible functio... | true |
e9fd5bf58588aa020cbe053989e12b48c509b33b | fari-zma/python | /ImageGallery/main.py | UTF-8 | 2,947 | 3.359375 | 3 | [
"MIT"
] | permissive | import tkinter as tk
from PIL import Image, ImageTk
# create instance
window = tk.Tk()
# set default window size
window.geometry("500x500")
# set min window size
window.minsize(300, 200)
# set max window size
window.maxsize(700, 600)
# add a title
window.title("ImageGallery")
# widget classes -> Label, Entry, Text, B... | true |
5bdc09105953003096a24a50802a62eb7500b55f | ricardoserra/intercom_challenge | /test/test_io.py | UTF-8 | 2,023 | 3.015625 | 3 | [
"MIT"
] | permissive | import json
import os
import urllib
from pytest import raises
from src.io import bytes_to_json, read_customers, write_to_file
def test_simple_bytes_to_json():
result = bytes_to_json(b'{"a":1}')
assert 'a' in result
assert result['a'] == 1
def test_customer_bytes_to_json():
customer = bytes_to_json... | true |
db06f9172f0aac169479e32139b93a1ad4fbea86 | weis999/Python2017 | /Les02/Opdracht 2.1.py | UTF-8 | 249 | 3.15625 | 3 | [] | no_license | letters = ( 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'C','C','C','C','C' )
print (letters.count('A'), letters.count('B'), letters.count('C'))
print (letters [0], letters [5], letters [8])
#Dit zijn strings die geordend zijn met behulp van de index nummer. | true |
655ca857867228c3ddf75da36aba20ed9fca771a | Aasthaengg/IBMdataset | /Python_codes/p02873/s802461150.py | UTF-8 | 965 | 2.875 | 3 | [] | no_license | s = input()
a = 0
l = []
for i in s:
if a == 0:
if i == "<":
a = 1
else:
a = -1
elif ((a > 0) and i == "<"):
a += 1
elif ((a < 0) and i == ">"):
a -= 1
elif i == "<":
l.append(a)
a = 1
else:
l.append(a)
a = -1
... | true |
49f557be36b80dcaff227673b1b6a64aa07cce3e | zhyhy/Pytorch | /Task_2.py | UTF-8 | 4,466 | 3.0625 | 3 | [] | no_license | # # import numpy as np
# #
# #
# # def func(x, y):
# # return (1 - x) ** 2 + 100 * (y - x ** 2) ** 2
# #
# #
# # # 函数对x求导
# # def dz_dx(x, y):
# # return 2 * x - 400 * (y - x ** 2) * x - 2
# #
# #
# # # 函数对y求导
# # def dz_dy(x, y):
# # return 200 * (y - x ** 2)
# #
# #
# # value = np.zeros(2)
# # learinng_ra... | true |
720e0b715e0c522ea7a5caf1f517fbada09045e8 | Codingforru/pythoncodes | /oop11.py | UTF-8 | 998 | 3.84375 | 4 | [] | no_license | # concept of inheritence in oops
# class inherit a class #{ single level inheritence]
class A: # A is the constructor
def feature1(self):
print("feature 1 is working")
def feature2(self):
print("feature 2 is working")
class... | true |
1d1f3ca76d136762b1425a5df8260295acc1b92c | mariachacko93/luminarDjano | /luminarproject/functional programming/fuctional.py | UTF-8 | 294 | 3.609375 | 4 | [] | no_license | # def add(num1,num2)
# return num1+num2
#
# print(add(10,20))
f=lambda num1,num2:num1+num2
print(f(10,20))
f1=lambda num1,num2:num1-num2
print(f1(10,20))
f2=lambda num1,num2:num1*num2
print(f2(10,20))
f3=lambda num1,num2:num1//num2
print(f3(100,20))
cube=lambda num:num**3
print(cube(3))
| true |
509b3205a4a24c7b130b12095de55ba46d47aa3b | CircularWorld/Python_exercise | /month_01/day_02/exercise_02.py | UTF-8 | 597 | 3.296875 | 3 | [] | no_license | '''
I kill you
'''
# print('输入I kill you 句子成分')
# sub = input('请输入I kill you主语:')
# verb = input('请输入I kill you谓语:')
# obj = input('请输入I kill you宾语:')
# print('主语是:' + sub + '动词是:' + verb + '宾语是:' + obj)
# print(sub + ' ' + verb + ' ' + obj+'.')
'''
画出下列代码内存图,说出终端显示结果
name_of_hubei_province = "湖北"
name_of_hunan_... | true |
6481be5f2ae4cdd0b971419a0fb3c30ae6065431 | hyukhunkoh-ai/ai_platform_demo | /version/api/sql/EngineLive_sql.py | UTF-8 | 2,397 | 2.546875 | 3 | [] | no_license | import argparse
import json
from version.api.sql import conn, cursor
# str_json = {'0': '<table class="engine-table" width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#7134bf"> <tbody><tr><td width="100"><img src="/static/engine.png" border="0" class="decision_train" ondrop="drop(event)" ondragover="al... | true |
6abef3ef4dd7afa60bc77ef4e618e22b845bcc2d | radeklos/django-social-tools | /socialtool/loading.py | UTF-8 | 7,780 | 2.640625 | 3 | [] | permissive | import sys
import traceback
from django.conf import settings
from django.db.models import get_model as django_get_model
from socialtool.exceptions import (ModuleNotFoundError, ClassNotFoundError,
AppNotFoundError)
def get_class(module_label, classname):
"""
Dynamically import a sin... | true |
8c252cad7a848e28d51244ad1b4c55276bd38a58 | wmylxmj/machine-learning-kNN | /data_normalize.py | UTF-8 | 1,391 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 21:02:03 2018
@author: wmy
"""
import numpy
def NormalizeData(dataset):
minvalues=dataset.min(0)
maxvalues=dataset.max(0)
dataranges=maxvalues-minvalues
normalizeddataset=numpy.zeros(numpy.shape(dataset))
m=dataset.shape[0]
normalizeddataset=da... | true |
07c15fe1197b56c00b50e91430a7ab6fdf5d7cb3 | SunmoonSan/PythonDaily | /maple/cookbook/chapter02/2.4.py | UTF-8 | 752 | 3.6875 | 4 | [] | no_license | text = 'yeah, but no, but yeah, but no, but yeah'
print(text == 'yeah')
print(text.startswith('yeah'))
print(text.endswith('no'))
print(text.find('no')) # 返回查到的字符串第一个字符的索引
text1 = '11/27/2012'
text2 = 'Nov 27, 2012'
import re
if re.match('\d+/\d+/\d+', text1):
print('yes')
else:
print('no')
if re.match('\d+... | true |
efda23cf2e7a70302f644fd375841ef966567689 | feridkerim/-Covid1903-Foundation-Code-Task-01- | /app.py | UTF-8 | 863 | 3.09375 | 3 | [] | no_license | from db import products
from db import firms
from db import categories
firma = ["Nike","Gucci","Lacoste"]
kategoriya = ["Sport-ayaqqabi","Canta","Saat","Ayaqqabi","Aksessuar","T-Shirt","Jeans","Parfum",]
print("Firmalar: ",firma)
print("Kategoriyalar: ",kategoriya)
def firmalarAxtar(_firma_name):
for Firm in firm... | true |
f54e61b3eabc15f36de93b23aa09e9e603c49587 | zengfy2017/flask-dialogflow | /flask_dialogflow/messages.py | UTF-8 | 3,725 | 2.953125 | 3 | [
"MIT"
] | permissive | from enum import Enum
import json
class Platform(Enum):
"""Possible values of platform that Google DialogFlow (formerly Api.ai) supports
"""
FACEBOOK = "facebook"
KIK = "kik"
LINE = "line"
SKYPE = "skype"
SLACK = "slack"
TELEGRAM = "telegram"
VIBER = "viber"
class MessageType(Enum... | true |
9aeba235b82b826300830eea9e3d6c8a84b70f3f | 240302975/study_to_dead | /面向对象/14 抽象类.py | UTF-8 | 780 | 3.6875 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time :2019/12/31 20:47
import abc
class Animal(metaclass=abc.ABCMeta): # 只能被继承,不能被实例化
all_type = 'animal'
@abc.abstractmethod
def run(self):
pass
@abc.abstractmethod
def eat(self):
pass
# animal = Animal
class People(Animal... | true |
6ba7a622a68f0ec2bde220c8f4ffc763e11922c7 | zolagz/Video_Maker | /utils.py | UTF-8 | 8,962 | 2.828125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import os
import shutil
from moviepy.editor import ImageClip
from PIL import Image, ImageDraw, ImageFont
from rich.console import Console
from rich.progress import track
from pydub import AudioSegment
import moviepy.video.fx.all as vfx
import uuid
console = Console()
def check_dirs(images_dir... | true |
0c34809a8b814a64421f00bfcf0ad92482cf2316 | PandaWhoCodes/adventofcode | /2018/puzzle2/part1/solution.py | UTF-8 | 803 | 3.5625 | 4 | [
"Apache-2.0"
] | permissive | def return_count(word):
d = {}
for alpha in word:
if alpha in d:
d[alpha] += 1
else:
d[alpha] = 1
return d
def do_the_math(counts, twos_and_threes):
two = 0
three = 0
for alpha in counts:
if counts[alpha] == 2:
two = 1
if coun... | true |
57bb2d608c5cb0d399aa7b3bda52c47b83226f3b | DongONNS/security | /courses/ossec/experiment_instruction/rwidget.py | UTF-8 | 1,345 | 2.84375 | 3 | [] | no_license | import os
import re
#pattern = re.compile('^- [\u4e00-\u9fa5]+')
#或用pattern = re.compile([^\x00-xff])匹配双字节字符
pattern = re.compile('^- [^\x00-\xff]+')
def findAll(pattern,targetfile):
"""find all strings which match the pattern in the targetfile. """
with open(targetfile,'r',encoding='utf-8') as f:
for ... | true |
70aa34314987971d2ee20023498271e73872a8c6 | seungsu3579/Algorithm_Study | /programmers/dfs_bfs/여행경로.py | UTF-8 | 1,912 | 3.265625 | 3 | [] | no_license | # 여행경로
class Node:
def __init__(self, port):
self.port = port
self.edges = []
self.size = 0
self.check = dict()
def addEdge(self, node):
self.edges.append(node)
self.check[node.port] = self.check.get(node.port, [])
self.check[node.port].app... | true |
1eee6326318c0f536643036cf0a729458ce4c361 | shayansaha85/automation-project | /save_csv.py | UTF-8 | 265 | 3.484375 | 3 | [] | no_license | def save_sheet(list_of_lines, name, folder):
data = ""
for lines in list_of_lines:
data += lines + "\n"
file = open(f"{folder}/{name}", "w")
file.write(data)
file.close()
print(f"Saved in {name} file inside the directory : {folder}") | true |
868947ed4cf64450329829314d1e3bc089175b45 | adipandas/multi-object-tracker | /motrackers/utils/misc.py | UTF-8 | 8,978 | 3.140625 | 3 | [
"MIT"
] | permissive | import numpy as np
import cv2 as cv
def get_centroid(bboxes):
"""
Calculate centroids for multiple bounding boxes.
Args:
bboxes (numpy.ndarray): Array of shape `(n, 4)` or of shape `(4,)` where
each row contains `(xmin, ymin, width, height)`.
Returns:
numpy.ndarray: Centr... | true |
cf4ff9e4f47d4f74d67205fc9fc97657a5005776 | mattstirling/ProEuler | /ProEuler/pe019_num_sundays.py | UTF-8 | 1,785 | 3.640625 | 4 | [] | no_license | '''
Created on Nov 22, 2015
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
@author: Trader
'''
def is_leap_year(yyyy):
if yyyy%4==0:
if yyyy%100==0:
if yyyy%400==0:
return True
else:
... | true |
36314ff534756d47556604536b988e9363e58567 | agoetz/MB-Fit | /mbfit/database/database.py | UTF-8 | 50,274 | 2.828125 | 3 | [] | no_license | # external package imports
import itertools, numpy as np, copy, sys, os
# absolute module imports
from mbfit.molecule import Atom, Fragment, Molecule
from mbfit.exceptions import PotentialFittingError, NoSuchMoleculeError, DatabaseOperationError, \
DatabaseInitializationError, DatabaseNotEmptyError, DatabaseCo... | true |
f07cc467188bee9ecb636863b74e45b0c2d8a301 | Steven-Chavez/self-study | /python/io/str-repr.py | UTF-8 | 483 | 4.09375 | 4 | [] | no_license | # Author: Steven Chavez
# Email: steven@stevenscode.com
# Date: 10/4/2017
# File: str-repr.py
# Resource: https://docs.python.org/3/tutorial/inputoutput.html
# str() and repr()
'''str() returns a human-readable representation of the
values. repr() returns an interpreter-readable representation
of the values.'''
# Di... | true |
51339f81fe4c111f1811a5cc31b32d1e0ee68816 | shuttle1987/stencil | /stencil.py | UTF-8 | 15,964 | 2.65625 | 3 | [
"MIT"
] | permissive | import importlib
import re
import tokenize
from io import StringIO
from pathlib import Path
from collections import defaultdict, deque, namedtuple, ChainMap
TOK_COMMENT = 'comment'
TOK_TEXT = 'text'
TOK_VAR = 'var'
TOK_BLOCK = 'block'
tag_re = re.compile(r'{%\s*(?P<block>.+?)\s*%}|{{\s*(?P<var>.+?)\s*}}|{#\s*(?P<comm... | true |
27285a6a866e6883136593229ed8bcd1fa10e679 | sathyainfotech/Function-Argument-Types | /Function Argument Types.py | UTF-8 | 323 | 3.703125 | 4 | [] | no_license | """
*args
**kwargs
Name="Ram" Keyword:Value
"""
def fun(**kwargs):
for key,val in kwargs.items():
print("%s:%s"%(key,val))
fun(Name="Sathya",Age=26,Address="Chennai")
# def fun(*args):
# sum = 0
# for data in args:
# sum+=data
# print("Sum:",sum)
#
# fun(10,20,30,40)... | true |
d466870c3896025abdcd63e711ffa5fcf2e417bd | inivikrant/python_getting_started_project | /q06_bowled_players/build.py | UTF-8 | 655 | 2.78125 | 3 | [] | no_license | # Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# Your Solution
def bowled_out(data=data):
bowled_players = []
innings = data ['innings'][1]
second_innings = innings['2nd innings']
deliveries = second_innings['deliveries']
counter = ... | true |
660e2b80c8299b35bd1de53bcbdd4c2506a0b4da | carldunham/jackson | /test or practice/testone.py | UTF-8 | 1,648 | 2.671875 | 3 | [] | no_license | #!/usr/bin/python
##----------------------------------------------------------------------
## Copyright (c) 2013 Jackson Dunham, All Rights Reserved
##----------------------------------------------------------------------
##
## testone.py
##
## Created: 2013-10-15 by jackson
##
##--------------------------------------... | true |
e8769bfbea7b3d627b9b3e3f9ad2ad20d82c8c5d | trainto/Problem-Solving | /algospot/xhaeneung.py | UTF-8 | 1,783 | 3.625 | 4 | [] | no_license | testCases = []
for i in range(int(input())):
testCases.append(input())
def convert(number):
if number == 'zero':
return 0
elif number == 'one':
return 1
elif number == 'two':
return 2
elif number == 'three':
return 3
elif number == 'four':
return 4
el... | true |
e7ab375f46c87457af2c9606450343e306372086 | opencv/opencv | /samples/python/kmeans.py | UTF-8 | 1,244 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
'''
K-means clusterization sample.
Usage:
kmeans.py
Keyboard shortcuts:
ESC - exit
space - generate new distribution
'''
# Python 2/3 compatibility
from __future__ import print_function
import numpy as np
import cv2 as cv
from gaussian_mix import make_gaussians
def main():
clu... | true |
f3ba8aa3720139b1a29e1ec9e3a31c47551288ca | asarm/etsy-scrapper | /app/app.py | UTF-8 | 3,826 | 3.15625 | 3 | [] | no_license | '''
name: Mert Arda Asar
date: 17.08.2021
A Flask web app to scrape data from etsy.com using product url.
Fetches and saves to database desired product's main image, name and price.
This application can be used as an api or on the web with an user interface.
app.py file contains the main functions that able t... | true |
e5ba6aa59d1c4084026ad13ad333c2cbbe4f572a | sergio-cl/PointCloudLabeler | /src/Annotator3D.py | UTF-8 | 6,773 | 2.65625 | 3 | [
"MIT"
] | permissive | import numpy as np
import pptk
import laspy
import tkinter
from tkinter import ttk
import tkinter.filedialog
import multiprocessing
import time
import csv
# TODO leyenda con colores
# TODO Cerrar adecuadamente el programa
# Variable to share memory between processes
button_state = multiprocessing.Valu... | true |
7fb979deb934faa6b100a521687ce90f8caaa83f | Kingsford-Group/rlforlqh | /Reinforcement Learning/build/lib/continual_rl/experiments/tasks/minigrid_task.py | UTF-8 | 3,093 | 2.671875 | 3 | [
"MIT"
] | permissive | import torch
import numpy as np
import gym_minigrid # Needed for Utils.make_env
import gym
from continual_rl.experiments.tasks.task_base import TaskBase
from continual_rl.experiments.tasks.preprocessor_base import PreprocessorBase
from continual_rl.utils.utils import Utils
from continual_rl.utils.env_wrappers import F... | true |
ab476a32cddd79c299a461d98a32057a2825e040 | DataONEorg/onto-dataonepython | /corpusFetcher/removeUpper.py | UTF-8 | 364 | 2.84375 | 3 | [] | no_license | #! /usr/bin/env python
import os
import codecs
import string
os.chdir(os.pardir+ "/data")
copy = open("nopunct_1.txt", "r")
newfile = open("noupper_2.txt", "w+")
for line in copy:
#line_nopunct = line.translate(None, string.punctuation)
line_noUpper = line.lower()
print line_noUpper
newfile.write(l... | true |
52c8c4ab9a1062f44f7fde27b3de7581da46f2f8 | PiPot/pipot-server | /pipot/notifications/NotificationLoader.py | UTF-8 | 3,286 | 2.828125 | 3 | [
"ISC"
] | permissive | import importlib
import os
from traceback import print_exc
import pipot.notifications as main
import pipot.notifications.temp as temp
from pipot.notifications.INotification import INotification
class NotificationLoaderException(Exception):
def __init__(self, value):
self.value = value
def __str__(se... | true |
99ad95bcd362c6a51a1553963661f05f6cbbad7f | johnsroy/python_Snippets | /shift_n_letters.py | UTF-8 | 682 | 4.03125 | 4 | [] | no_license | def shift_1_letter(letter):
letter_index = ord(letter) - ord('a') # one of 0, 1, 2, ..., 25
shifted_index = (letter_index+1) % 26 # still one of 0, 1, 2, ..., 25
return chr(ord('a') + shifted_index)
def shift_n_letters(letter, n):
letter_index = ord(letter) - ord('a') # one of 0, 1, 2, ..., 25
sh... | true |
97bebad0170a1f3b46a94ff40d02c0d707d4c937 | rostyslav02/epam | /models.py | UTF-8 | 1,031 | 2.875 | 3 | [] | no_license | from main import db
class Employee(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100))
surname = db.Column(db.String(100))
email = db.Column(db.String(100), unique=True)
department_id = db.Column(db.Integer, db.ForeignKey('department.id'), nullable=Fals... | true |
945c0089569d912436e040b04a5fc9cb143898f0 | zaicevairina/Deep-Python | /HW2/Task2_Money.py | UTF-8 | 1,819 | 3.6875 | 4 | [] | no_license | class Money():
currency_common = {'RUB': 1, 'EU': 70, 'DOLLAR': 60, 'FK': 50, 'F': 1 / 30}
__slots__ = ('value', 'currency', '__weakref__')
def __init__(self, value, currency=''):
self.value = value
self.currency = currency
def __add__(self, other):
if isinstance(other, Money):... | true |
348ce7b0a5300b57a7d0594ed8dbb44675e239be | apolonio/mundo-python | /ex64-tratando-valores.py | UTF-8 | 201 | 4.0625 | 4 | [] | no_license |
### Digitar 3 valores e depois sair
'''
for c in range(0,3):
n = int(input("Digite um valor: "))
print("FIM")
'''
### Imprimir de tras para frente
for d in range(1,6,1):
print(d)
print("FIM") | true |
f7a5a74cae870a0a6c59ef0814ac8743e090148f | nascarsayan/lintcode | /1716.py | UTF-8 | 544 | 2.984375 | 3 | [] | no_license | class Solution:
"""
@param S: a string
@return: the minimum number
"""
def minFlipsMonoIncr(self, S):
# Write your code here.
size = len(S)
if size == 0:
return 0
mp = {'0': 0, '1': 1}
mpr = {'0': 1, '1': 0}
n0, n1 = list(map(lambda x: mpr[x], S)), list(map(lambda x: mp[x], S))
... | true |
dac0402b40bdeab300a04294dc5c6335349f6ca5 | albornet/ntds_2019_team_32 | /scholar_main.py | UTF-8 | 2,433 | 2.75 | 3 | [
"MIT"
] | permissive | import pandas
import time
import csv
from scholar_scraper import get_citation_statistics
from http.client import RemoteDisconnected, IncompleteRead
from urllib.error import URLError
# Check whether the generated files already exist
try:
output_file = open('./citations.tsv', 'r')
len_output_file = len([1 fo... | true |
925271a8026106cbc6562064c226197f8181725f | nighelles/Not-Enough-Time | /test.py | UTF-8 | 3,861 | 3.21875 | 3 | [] | no_license | import time
import random
import pygame
def getreactiontime():
a = 1
nop = 1
s = 0
clock = pygame.time.Clock()
print "This is the first time you're running the game."
print "Please press enter, then press enter again as"
print "fast as you can after each block of text is displayed"
wait = raw_input()
for i i... | true |
a13635b91dd7259ded2127fe3ee5f123aaee4fab | jedestep/atlantic | /src/levelbuilder.py | UTF-8 | 10,102 | 2.703125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import obstacle
import platform
import player
import enemy
import fishEnemy
import lasercannon
import pygame as PG
import pygame.sprite
import pygame.image
import pygame.mixer
import camera
import weapon
import jetpack
import cutscene
import color
import intro
import soundtrigger
import savepoint
import boss
import cut... | true |
b7f8f9402a7d1794833eac2aae4cc618ac28d176 | eldojk/Workspace | /WS/G4G/Problems/dp/partition_set_to_minimise_difference_in_sum.py | UTF-8 | 2,276 | 4.03125 | 4 | [] | no_license | """
amzn
#tricky
http://www.geeksforgeeks.org/partition-a-set-into-two-subsets-such-that-the-difference-of-subset-sums-is-minimum/
Input: arr[] = {1, 6, 11, 5}
Output: 1
Explanation:
Subset1 = {1, 5, 6}, sum of Subset1 = 12
Subset2 = {11}, sum of Subset2 = 11
The task is to divide the set into two parts.
We will co... | true |
98c95a30dc3da8472dd3375587df11db6c4f49f0 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_1/461.py | UTF-8 | 756 | 2.84375 | 3 | [] | no_license | def main():
infile = open("A-large.in","rU")
outfile = open("outputalarge.txt","w")
testcases = int(infile.readline())
# print testcases
for i in xrange(testcases):
engines = {}
switches = 0
numengines = int(infile.readline())
for j in xrange(numengines):
inline = infile.readline()
engines[inline] = 0... | true |
ac9dc42fa3354872421063340454ca16466f8aa2 | IvanYangYangXi/pyqt_study | /study/TableView_spinbox.py | UTF-8 | 2,364 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# TableView_spinbox.py
# @Author : ()
# @Link :
# @Date : 2/13/2019, 9:26:06 AM
import sys
from PyQt5 import QtCore, QtGui, QtWidgets, uic
# Item class
class SpinBoxDelegate(QtWidgets.QStyledItemDelegate):
'''
'''
# createEditor 返回用于更改模型数据的小部件,可以重新实现以... | true |
29460c347df9a973bafc57a8e6d5f32c3ae8929a | muskaanisrani/CECS451-Artificial-Intelligence | /algorithms.py | UTF-8 | 5,422 | 3.703125 | 4 | [] | no_license | """
Algorithms class contains the implementation of DFS and BFS algorithms
Date: 20th July 2020
Authors: Muskan Israni & Keval Varia
Student ID: 017537908, 017834282
Class: CECS 451- Artificial Intelligence
"""
import Graph as Node
class Algorithms:
# constructor: initializes and assigns the board, the start an... | true |
b79625e562b14a8677b18af115c52c86d1d2319a | maradude/aps-code | /turtle_sort/turtle_sort.py | UTF-8 | 1,090 | 3.421875 | 3 | [] | no_license | def count_turtle_sort_steps(not_sorted, is_sorted, turtle_count):
# find how many turtles don't need to be moved, return the difference
expected_turtle = actual_turtle = turtle_count - 1
need_to_move = 0
while actual_turtle >= 0:
if is_sorted[expected_turtle] == not_sorted[actual_turtle]:
... | true |
e050218fb09e1f57e9fd4d731441a78fbb2c5b60 | Krieglied/Assignments | /PythonProjects/mecha/mecha_game_v2.py | UTF-8 | 8,781 | 3.78125 | 4 | [] | no_license | # mecha_game.py
# Robert John Graham III
# September 14 2018
"""
This mecha game is a translation of a C++ project to python, to show the
difference and similiarites between C++ objects/classes and Python's.
This is a two player game that allows each player to select a mech, and
then take pot shots at... | true |
77faa33bb39b840c6e034331c3e77324637f681b | chunweiliu/leetcode | /problems/subsets-ii/subsets_ii.py | UTF-8 | 391 | 2.921875 | 3 | [] | no_license | class Solution(object):
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
subsets = [[]]
for n in sorted(nums):
subsets += [s + [n] for s in subsets if s + [n] not in subsets]
return subsets
if __name__ == '__m... | true |
6b17141e6edb574a9694dd5b49d46574cffaf41a | IvaPetrovicc/Zadace | /zadaca8.IP.py | UTF-8 | 788 | 4.40625 | 4 | [] | no_license | '''Definirati dvije funkcije koje kao parametar primaju ime ali vraćaju različitu poruku dobrodošlice.
Jedna neka ispisuje “Pozdrav {ime}!”, a druga “Dobrodošao {ime}!”
Jedna od funkcija neka bude definirana lambda izrazom, a druga standardnim načinom.
Zatim definiraj treću funkciju koja kao parametar prima naziv fu... | true |
6c92c35a75a901cbe962b2795429c34553954c68 | RomaMol/MFTI | /DirMFTI/Lectory7/mod-pack.py | UTF-8 | 454 | 2.90625 | 3 | [] | no_license | import numpy as np
import numpy
import house1
def print_hi():
print(f" np.cos(1) {np.cos(1)}") # import numpy as np
print(f" numpy.cos(1) {numpy.cos(1)}") # import numpy
print(house1.main())
print(f" house1.house(10,20,20,20) {house1.house(10,20,20,20)}") #import house1
# Press the green button in t... | true |
36501fe5f3ec9114de5602d053ac6cc93aa81936 | zhanghe06/bearing_project | /app_common/libs/sms_chuanglan.py | UTF-8 | 1,384 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# encoding: utf-8
"""
@author: zhanghe
@software: PyCharm
@file: sms_chuanglan.py
@time: 2020-04-12 16:55
"""
import requests
# 服务地址
host = "sms.253.com"
# 端口号
port = 80
# 版本号
version = "v1.1"
# 查账户信息的URI
balance_get_uri = "/msg/balance"
# 智能匹配模版短信接口的URI
sms_send_uri = "/msg/send"
# 创蓝账号
u... | true |
a6737c492eb9a198aec0fac1d123380bad72644e | GilmendezCR/Python_Fundamentals | /Condiciones compuestas con operadores lógicos/Ejercicio_4.py | UTF-8 | 532 | 4.28125 | 4 | [] | no_license | #Se ingresan tres valores por teclado,
#si todos son iguales se imprime la suma del primero con el segundo
#y a este resultado se lo multiplica por el tercero.
nmr1 = int(input('Favor ingresar el valor:'))
nmr2 = int(input('Favor ingresar el valor:'))
nmr3 = int(input('Favor ingresar el valor:'))
if nmr1 == nmr2 and... | true |
7d257810fbb1915ac91e475645af612de94e3051 | igwb/Spiel | /spiel.py | UTF-8 | 8,429 | 2.921875 | 3 | [] | no_license | import tkinter
import random
import time
import zielObjekt
import spieler
import spielfeld
import statistik
# FPS (frames per second) - Aufrufe der Hauptschleife pro Sekunde
FPS = 40
FENSTER_HOEHE = 310
FENSTER_BREITE = 600
PUNKTE_PRO_FRAME = 1 / FPS
SPIELER_TREIBSTOFFVERBRAUCH = 1.8 / FPS
WELLEN_ABSTAND = 0.9
WELL... | true |
d8dd5b5b5eeadf05e0d9cf79d761fd5d641c98b0 | beingzy/ds_product_api | /predict_api.py | UTF-8 | 1,533 | 2.890625 | 3 | [] | no_license | """ serve KNN model via API
Author: Yi Zhang <beingzy@gmail.com>
Date: 2016/04/11
"""
from flask import Flask
from flask_restful import Resource, Api
from flask_restful import reqparse
from utils import knn_predict
import numpy as np
app = Flask(__name__)
api = Api(app)
class HelloPage(Resource):
def ge... | true |
b0828a8d5f4c800334180798c1d735a89eb1f756 | rmmasc/Image-Processing-and-CNNs | /Texture-Analysis-and-Segmentation/texture_classification.py | UTF-8 | 12,283 | 2.875 | 3 | [] | no_license |
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 9 12:25:22 2019
@author: Royston M M
"""
import numpy as np
from matplotlib import pyplot as plt
#function to read images
def read_image(ipath,height1,width1,display_flag):
Img1 = open(ipath,'rb').read()
Img1 = np.frombuffer(Img1,np.uint8)
ImageP1 = Img1[0... | true |
e99b34b2652c7e9ed9f7735173a576f48f553922 | emzatos/Random-Coding | /test.py | UTF-8 | 153 | 3.328125 | 3 | [] | no_license | def fun(nums):
total = 0
for i in nums:
if i == 6:
while i != 7:
continue
else:
total += i
return total
print(fun([2,3,4,6,5,4,3,7,8])) | true |
7dd758eae2a4d9f088c956ab1c1d1695996407b6 | datasnakes/OrthoEvolution | /OrthoEvol/Tools/pbs/qsub.py | UTF-8 | 21,370 | 2.625 | 3 | [] | no_license | import getpass
import os
import random
import shutil
import string
import subprocess as sp
from collections import OrderedDict
from datetime import datetime as d
from pathlib import Path
from time import sleep
from pkg_resources import resource_filename
from OrthoEvol.Manager.config import templates
from OrthoEvol.To... | true |
0b052a8b4f7a31e743fe986f6640dffaaa079d52 | nasyrovdp/helloworldpythonbook | /chapter 15 time.py | UTF-8 | 277 | 2.984375 | 3 | [] | no_license | from time import sleep
print("How ", end="")
sleep(2)
print("are ", end="")
sleep(2)
print("you ", end="")
sleep(2)
print("today?")
'''
import time
print("How ", end="")
time.sleep(2)
print("are ", end="")
time.sleep(2)
print("you ", end="")
time.sleep(2)
print("today?")
'''
| true |
02c9bb6a44b5025f84f32d83dc4aca8e3ad577cf | rolycore/Python_Source | /ejercicios python/CannyLineasFunciona5.py | UTF-8 | 837 | 2.9375 | 3 | [] | no_license | import numpy as np
import cv2
origm = cv2.imread('images/taco.jpg')
#cv2.imshow('origm30', origm)
#Colocar en Gris
gris = cv2.cvtColor(origm, cv2.COLOR_BGR2GRAY)
#cv2.imshow('origm31', gris)
#uso de Gaussiano
gauss = cv2.GaussianBlur(gris, (1,1), 0)
#cv2.imshow('origm32', gauss)
#Uso de Canny para c... | true |
f194959b420c1c8774114b227d30dd2431ca95cd | stupidfritz/Sanctus-Anguis | /main.py | UTF-8 | 6,537 | 2.5625 | 3 | [] | no_license | import pygame, sys, random, time
from pygame.locals import *
import pipe, menu
import snek
from Button import *
pygame.init()
class Scene:
scene = "menu"
# create the window
global window, window_width, window_height
window_width, window_height = 800, 600
window = pygame.display.set_mode((window_widt... | true |
5e25dd801523758a287fe44d1582e59c21513ee1 | daniel-stockhausen/adventofcode2020 | /aoc/day04/day04.py | UTF-8 | 2,089 | 3.15625 | 3 | [
"MIT"
] | permissive | import re
validations = {
'hcl': lambda x: re.compile("^#[0-9a-f]{6}$").match(x),
'byr': lambda x: 1920 <= int(x) <= 2002,
'iyr': lambda x: 2010 <= int(x) <= 2020,
'eyr': lambda x: 2020 <= int(x) <= 2030,
'ecl': lambda x: x in ['amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'],
'hgt': lambda x: ... | true |
92b65820ec15fac651242a5531deaf7c053e469c | BherePradip/CODING-FOR-PLACEMENT | /reverse_num.py | UTF-8 | 134 | 3.296875 | 3 | [] | no_license | a=int(input())
b=a
rev=0
rem=0
while(a!=0):
rem=a%10
rev=rev*10+rem
a=a//10
print(rev)
c=str(b)
print(c[::-1])
| true |
9c49e9bd2b2399d230e156cb86b5de20f478407d | raphael-group/structured-anomalies | /src/gmm_line.py | UTF-8 | 743 | 2.734375 | 3 | [] | no_license | import numpy as np
import scipy as sp
from common import single_em, compute_responsibilities
# find GMM subinterval: max sum subarray of length l
def find_subint(arr, l):
n = len(arr)
max_sum = -np.inf
max_left_end = -1
max_right_end = -1
for i in range(n-l):
s = np.sum(arr[i:i+l])
... | true |
d09e5647f02c8c90a300410c4d1a3b75777e10b8 | Kawser-nerd/CLCDSA | /Source Codes/CodeJamData/15/23/8.py | UTF-8 | 1,178 | 2.953125 | 3 | [] | no_license | from collections import deque
INF=1e50
EPS=1e-9
def tinter(x,y):
a=list(x)
b=list(y)
if(a[1]==b[1]):
return -1
if(a[1]>b[1]):
a,b=b,a
if(b[0]>=a[0]-EPS):
b[0]-=360
return (a[0]-b[0])/(b[1]-a[1])
def evolve(x,t):
ans =x[0]+t*x[1]
return (ans,x[1])
def reduce(l):
... | true |
d051e7c474e91ac32eb84f7fcfa98775fdd7a471 | sarae17/2019-T-111-PROG | /assignments/lists/email_addresses.py | UTF-8 | 620 | 3.578125 | 4 | [] | no_license | def get_names_and_domains(list_of_emails):
result_list = []
for address in list_of_emails:
uname, domain = address.split('@')
result_list.append((uname,domain))
return result_list
def get_emails():
done = False
email_list = []
while not done:
email = input('Email addres... | true |
3f7140d32dafffd65e0bd73a59c4eb235e4ba231 | VeRNen9/metadl | /starting_kit/zip_utils.py | UTF-8 | 1,494 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | """ This document contains utility functions to help create a valid submission
for CodaLab.
"""
import os
from contextlib import closing
from zipfile import ZipFile, ZIP_DEFLATED
from absl import app
from absl import flags
from absl import logging
FLAGS = flags.FLAGS
flags.DEFINE_string('directory', 'baselines/zer... | true |
556e71ef68c6c887192b91be71feba440cac2d05 | monrubi/PM-Practica-1 | /Practica5/roscir.py | UTF-8 | 3,103 | 2.671875 | 3 | [] | no_license | #! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from turtlesim.msg import Pose
import math
import time
from std_srvs.srv import Empty
x = 0
y = 0
z = 0
theta = 0
def poseCallback(pose_message):
global x
global y
global z
global theta
x = pose_message.x
y = pose_me... | true |
a1900b401a214ffd07089b5228929a33cc00c2ea | MariamMahfuz/pythonProject1 | /repeating_name.py | UTF-8 | 194 | 3.0625 | 3 | [] | no_license | def circle(r):
area=3.1416*r*r
print(area)
circle(25)
# def student(firstname,lastname):
# fullname=firstname + " "+ lastname
# print(fullname)
# student("Zahed","Hasan")
task1
| true |
0043ec7b8bca4c6816d04c856d8d10d5e0700b93 | darkfennertrader/mlfinlab | /mlfinlab/backtest_statistics/statistics.py | UTF-8 | 14,533 | 3.578125 | 4 | [
"BSD-3-Clause"
] | permissive | """
Implements statistics related to:
- flattening and flips
- average period of position holding
- concentration of bets
- drawdowns
- various Sharpe ratios
- minimum track record length
"""
import pandas as pd
import scipy.stats as ss
import numpy as np
def timing_of_flattening_and_flips(target_positions: pd.Serie... | true |
acd4741bcc2941641d3ecbcb8b2dc1b80e0e6981 | Zhouxiaonnan/paper_studynotes_and_noted_codes | /Deep NMT noted codes/2 Deep NMT model.py | UTF-8 | 4,236 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[2]:
import torch
import torch.nn as nn
import numpy as np
# In[3]:
class Deep_NMT(nn.Module):
def __init__(self,source_vocab_size,target_vocab_size,embedding_size,
source_length,target_length,lstm_size):
super(Deep_NMT,self).__init__()
... | true |
c7ea2a9026e800af3a43190adf4e086b3f42d2df | jjc521/E-book-Collection | /Python/Python编程实践gwpy2-code/code/gui/menu.py | UTF-8 | 703 | 2.90625 | 3 | [
"MIT"
] | permissive | import tkinter
import tkinter.filedialog as dialog
def save(root, text):
data = text.get('0.0', tkinter.END)
filename = dialog.asksaveasfilename(
parent=root,
filetypes=[('Text', '*.txt')],
title='Save as...')
writer = open(filename, 'w')
writer.write(data)
writer.close()
def quit(root):
... | true |
e94303c1bc9e579ef6462cc0646e3d42e1281e1d | kotsurnazariy/HW_soft | /ClassWork3.py | UTF-8 | 596 | 3.671875 | 4 | [] | no_license | #1
def fl(lst):
s = 0
i = 0
for i in lst:
s += i
return print(s / len(lst))
fl([2, 4, 6])
#2
# def modul (b):
# """Modul number"""
# if b >= 0:
# return print(b)
# else:
# return print(-b)
# modul(10)
#3
# def max_num (g, k):
# """
# Print max number
# """
... | true |
768f15059898eaf1ca51213a70d872603f0f2fb5 | robalonsor/raw-data-to-graphml | /Utilities/merge_results.py | UTF-8 | 2,836 | 2.578125 | 3 | [] | no_license | #!/usr/bin python3
# Delete after use
import numpy as np
def get_data(f_name_d):
global quality
global size
global visited_nodes
global time
file_dim1 = open(f_name_d)
for line in file_dim1:
if 'dimensions' not in line and 'visited' not in line and 'cluster' not in line and \
... | true |
6a51a71e731bae7bf8bb803c35b983a3ded0ca41 | LamLauChiu/DjangoReact-Boilerplate | /project/project/basicOpencv.py | UTF-8 | 1,775 | 3.40625 | 3 | [
"MIT"
] | permissive | import numpy as np
import cv2
from matplotlib import pyplot as plt
# sources: https://blog.gtwang.org/programming/opencv-basic-image-read-and-write-tutorial/
# 讀取圖檔
img = cv2.imread('/Users/Ivan.lam/Projects/DjangoReact-Boilerplate/project/project/human-20180303-01-1024x683.jpg')
# 查看資料型態
#type(img)
#img.shape
# 以... | true |
c804c230b9f891e97f49bb0343476efdb1c29de5 | zch0423/leetcode | /409.最长回文串.py | UTF-8 | 1,073 | 3.390625 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=409 lang=python3
#
# [409] 最长回文串
#
# @lc code=start
class Solution:
def longestPalindrome(self, s: str) -> int:
# 偶数字符数+1
table = dict()
for ch in s:
if table.get(ch, -1)>0:
table[ch] += 1
else:
table[ch] = 1... | true |
0ed37fe428b8e23dab3993e3c0438474df57d81d | HYOSEONJIN/inflearn | /python/Python_Basic/Chapter02_01.py | UTF-8 | 1,621 | 4.1875 | 4 | [] | no_license | #chapter02-1
#파이썬 완전 기초
#print 사용법
#기본출력
print('Python Start')
print("Python Start")
print()
print()
print('''Python Start''')
print("""Python Start""")
print()
#seperator 옵션
print('p','y','t','h','o','n',sep='')
print('010','1111','7777',sep='-')
print('python','google.com',sep='@')
print()
#end옵션
print('welcome ... | true |
bdca8732471c487f70075caf7f422ba35f0f5659 | s177437/uptime_challenge | /workers/purser_worker.py | UTF-8 | 4,118 | 2.65625 | 3 | [] | no_license | import sys
# sys.path.insert(0, '/root/uptime_challenge_master/testscript')
from purser import *
import pika
import ast
import subprocess
import time
import StringIO
__author__ = 'Stian Stroem Anderssen'
class PurserWorker():
"""
This is the purser-worker class.
"""
groupname = ""
def fetch_job_... | true |
191819313a4dbc052d8996a5dfff424f35dc7de5 | PaulSorenson/aurorapv | /pyaurora/cozmq.py | UTF-8 | 771 | 2.765625 | 3 | [] | no_license |
'''
:mod:`cozmq` - coroutines for zeromq
====================================
Note that we are using send_string(), recv_string(). Since the data is
a JSON string this should be fine but a more general solution would send/recv
bytes and encode/decode as necessary.
:mod:`zmq` has send_json() and recv_json() however... | true |
25f069528f53b258931a772f32774353aa30850d | dsy401/LeetCodeAlgorithm | /Easy/N-ary Tree Preorder Traversal/index.py | UTF-8 | 490 | 3.34375 | 3 | [] | no_license | """
# 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):
if root is None:
return []
elif not root.children:
return [root.va... | true |
19d6b8abce15fbfeb36c74069a59db47147e6a6c | donsheehy/greedypermutation | /greedypermutation/generic_balltree.py | UTF-8 | 2,203 | 3.046875 | 3 | [
"MIT"
] | permissive | from balltree import Ball
class GenericBallTree(Ball):
def generic_search(self, candidate, viable, update):
H = self.heap()
for ball in H:
candidate = update(candidate, ball)
if not ball.isleaf():
if viable(ball.left):
H.insert(ball.left)
... | true |
de2f007b6d5ee6efe6eb8381b40d239940702ba0 | duymanh96w/BDSP | /src/model2.py | UTF-8 | 11,950 | 2.765625 | 3 | [] | no_license | import random
from tqdm import tqdm
class Shift:
def __init__(self, _id, pieces_of_work: list) -> None:
self._id = _id
self.pieces_of_work = pieces_of_work
def __str__(self) -> str:
return str(self._id) + ': ' + str(self.pieces_of_work)
class Node:
def __init__(self, _id, c... | true |
3a43b779cfad4191e1a65b199e56a6d98041ba53 | darwinuzcategui/pruebaMVCpYTHON | /vistas/main_dialogo.py | UTF-8 | 1,152 | 2.578125 | 3 | [] | no_license | import sys # El módulo sys es el encargado de proveer variables y funcionalidades, directamente relacionadas con el intérprete
from PyQt5.QtWidgets import QApplication, QDialog # Nos Permite cargar la ventana .uic
from PyQt5 import uic # Nos permite cargar el .ui
sys.path.append("../controladores")
from validarControla... | true |
520cb854f95b50a4d3d6da42fd90cfdbd3efdb9b | jhuang2012/mixmogam | /examples.py | UTF-8 | 4,702 | 3.046875 | 3 | [] | no_license | """
Examples for how to perform GWAS using mixed models, and stepwise mixed models.
"""
def load_a_thaliana_genotypes():
"""
Loads A. thaliana genotypes (Horton et al., 2012) and returns a snps_data object
"""
import dataParsers as dp
sd = dp.parse_snp_data('at_data/all_chromosomes_binary.csv')
... | true |
0d42730dd7cafa37d4f612e5e8bb54950507008b | danenigma/Traditional-Computer-Vision | /Homographies-Feature-Descriptors-RANSAC/code/panoramas.py | UTF-8 | 2,920 | 2.53125 | 3 | [
"MIT"
] | permissive | import cv2
import os
import numpy as np
from scipy.ndimage.morphology import distance_transform_edt
from planarH import ransacH, computeH
from BRIEF import briefLite,briefMatch,plotMatches
def getMask(im):
mask = np.zeros((im.shape[0], im.shape[1]))
mask[0,:] = 1
mask[-1,:] = 1
mask[:,0] = 1
mask[:,-1] = 1
mas... | true |
758ca85514fe109d9a6a29740cb4b52b096fa7a3 | EDU-FRANCK-JUBIN/exercices-sur-python-Nummytincan | /Ex07.py | UTF-8 | 333 | 3.75 | 4 | [] | no_license | def calcfonction(fct, borneinf, bornesup, pas):
if borneinf < bornesup:
for i in range(borneinf, bornesup, pas):
print(fct(i))
else:
print("il faut que la Borne Inférieur soit strictement inférieur à la barne supérieur")
def fct(x):
f = 2*x**3+x-5
return f
calcfonction(fct, ... | true |
510dc3737b5e58d3594a86a7e306950c6283809a | jnafolayan/root-seeker | /main.py | UTF-8 | 3,632 | 3.9375 | 4 | [
"MIT"
] | permissive | import re
import time
# computes the value of a function at x
def get_function_value(eqn, x):
return sum([coeff * (x ** power)
for coeff, power in eqn])
# computes the value of the first derivative of a function
# at x
def get_derivative_value(eqn, x):
return sum([coeff * power * (x ** max(power - 1... | true |
b8385eb6142c1d5890354fd6974ee46c80f81829 | cmccandless/stunning-pancake | /0/1/0.py | UTF-8 | 535 | 3.109375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# https://projecteuler.net/problem=10
import unittest
def answer():
total = 2
limit = 2000000
np = set()
for x in range(3, limit, 2):
if x in np:
continue
total += x
np.update(range(x + x, limit, x))
return total
def run(... | true |
e28aa3db3c313e5c03d2feaf9dcfa8ee8ed8be6d | phl-microsat-dpad/python-fridays1 | /tutorial.py | UTF-8 | 4,715 | 4.09375 | 4 | [] | no_license | # Reference: http://www.tutorialspoint.com/python/index.htm
# http://victorlin.me/posts/2012/08/26/good-logging-practice-in-python
###########################################################
# Two modes: Interactive and Script Programming
###########################################################
########... | true |
f8e6b71edffe6e190f332e626321d6ffb0340094 | Ulysses-WJL/python_database_test | /demo/redis_demo/demo_list.py | UTF-8 | 1,831 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Date : 2018-11-25 11:08:02
# @Author : Your Name (you@example.org)
# @Link : http://example.org
import redis
from ..password import redis_passwd
r = redis.Redis(host='localhost', port=6379, db=0, password=redis_passwd)
if r.exists('l1'):
r.delete('l1')
l1 = [0, 1, 2, 3, 4, 5, 6, 7... | true |