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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e0b6e3a3f79cda8b3372ccbf2be160dd6ba5b63b | Python | ZixuanKe/deep-learning-note | /d2l/31_char_rnn_raw.py | UTF-8 | 13,239 | 2.765625 | 3 | [
"MIT"
] | permissive | import time
import math
import numpy as np
from torch import nn, optim
import torch.nn.functional as F
import utils
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('载入歌词数据')
(corpus_indices, char_to_idx, idx_to_char, vocab_size) = utils.load_data_jay_lyrics()
print('定义 one_ho... | true |
0ef58a9b16f54f3c6501e52235d9dd54d81f2f01 | Python | goyetc/power-gen-regression | /.ipynb_checkpoints/upload_to_S3-checkpoint.py | UTF-8 | 714 | 2.671875 | 3 | [] | no_license | # upload to S3
import boto3
from botocore.exceptions import NoCredentialsError
import os
def upload(local_file, bucket):
s3 = boto3.client('s3', aws_access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY'])
s3_file_name = '{}'.format(o... | true |
65f22d3f2d0830d47396eac35b3a6bd6bc52a119 | Python | leelasd/genopheno | /genopheno/models/random_forest.py | UTF-8 | 2,186 | 2.609375 | 3 | [
"MIT"
] | permissive | import common
import pandas as pd
import os
from sklearn.ensemble import RandomForestClassifier
def build_model(dataset, data_split, no_interactions, negative, max_snps, cross_validation, output_dir):
model_eval = {
'features': save_features
}
default_grid = {
'n_estimators': [1000],
... | true |
ecfa554e362c2a4e3cb9a9f1559af8bcdaffea20 | Python | maxerMU/bmstu | /sem_04/ca/lab_05/main.py | UTF-8 | 3,889 | 3.265625 | 3 | [] | no_license | import matplotlib.pyplot as plt
from math import sin, cos, pi, exp
from gauss import gauss
from simpson import simpson
def tao_func(tao):
sub_func = lambda phi, teta: 2 * cos(teta) / (1 - sin(teta) * sin(teta) * cos(phi) * cos(phi))
return lambda phi, teta: 4 / pi * (1 - exp(-tao * sub_func(phi, teta))) * cos(... | true |
375cc2da9c270156f8feecaf18b8597b90c77e3e | Python | mprisznyak/SSS | /trade.py | UTF-8 | 1,690 | 2.734375 | 3 | [
"Unlicense"
] | permissive | """
Trade data
"""
from datetime import datetime, timedelta
from traits.api import HasStrictTraits, Int, Dict, Enum, Float, BaseInstance, Instance
from traits.api import TraitError
from exchange import Exchange
# custom trait
TimeStamp = BaseInstance(datetime)
def create_GBCE():
""" load stock data """
... | true |
02e8ced1f1574667ad830cf1a8cede53b3edc879 | Python | samuelbarata/IRC | /server.py | UTF-8 | 10,474 | 2.6875 | 3 | [] | no_license | #!/bin/python3
import socket, sys, threading, signal, os
from threading import RLock
bind_address = ''
bind_port = 45080
# Comandos:
# HELP -- lista os comandos a usar
# REGISTER <nome> -- regista um novo user
# LIST -- lista todos os jogadores online
# ... | true |
1825c4e24d5df46a56fed62d644b8e88368ce2e7 | Python | donalosullivan/ay190 | /ws2/question1.py | UTF-8 | 853 | 3.234375 | 3 | [] | no_license | from matplotlib import pyplot as plt
import numpy as np
onethird = np.float32(1.0/3.0)
def x(n):
if n==0: return np.float32(1)
elif n==1: return onethird
else: return np.float32(13*onethird*x(n-1) - 4*onethird*x(n-2))
def x_analytic(n): return onethird**n
print "Absolute error values:"
print "%10s"%"n", "%8s"%"... | true |
16b34f1c470998dbbbabbb8a540d354705d45ff0 | Python | mdgrover/nes-keypress | /nes-keypress.py | UTF-8 | 3,334 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
Thanks to:
https://github.com/WiringPi/WiringPi/
http://little-scale.blogspot.ca/2007/07/nes-controller-to-arduino.html
http://blog.thestateofme.com/2012/08/10/raspberry-pi-gpio-joystick/
"""
import uinput
import time
import atexit
import sys
import os
import RPi.GPIO as GPIO
#Set pin n... | true |
99fba32c47d193548ce2751a34b99dad8e768405 | Python | codeJalisa/Ordoro | /src/CodeChallenege/processor.py | UTF-8 | 1,053 | 2.59375 | 3 | [] | no_license | import dateutil.parser
import pytz
def distinct_emails(user_logs):
emails = set()
for user_log in user_logs:
if user_log['email'] is not None:
emails.add(user_log['email'].strip())
return list(emails)
def domain_counts(emails):
domains = dict()
domains_with_multiple_users = dic... | true |
f4cf86c018323a55e79e36431f5597ef73610236 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2402/60649/259541.py | UTF-8 | 255 | 2.75 | 3 | [] | no_license | T=int(input())
bookings=[]
for k in range(T):
l=list(map(int,input().split(",")))
bookings.append(l)
n=int(input())
planes=[0 for i in range(n)]
for h in range(T):
a,b,k=bookings[h]
for i in range(a-1,b):
planes[i]+=k
print(planes) | true |
9baf0924b41fa5d7cbadde1371f5e0388eb9815f | Python | dkenward/libgf2 | /libgf2/util.py | UTF-8 | 6,553 | 3.421875 | 3 | [
"Apache-2.0"
] | permissive | '''
Utility functions and classes
Copyright 2013-2017 Jason M. Sachs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required ... | true |
2e87c972f3672bb617239709ad678998e6d4662c | Python | VLD62/PythonFundamentals | /00.EXAMS/10March2019/tempCodeRunnerFile.py | UTF-8 | 1,955 | 3.875 | 4 | [] | no_license | def _set(array):
return len(set(array)) == len(array)
def _filter(array, cmd):
if cmd == 'odd':
new_list = [el for el in array if el % 2 == 1]
if cmd == 'even':
new_list = [el for el in array if el % 2 == 0]
return new_list
def _multiply(array, n):
new_list = [el*n for el in arra... | true |
69ae962c6d03025a7115f39f33a259260cf32dac | Python | Kozea/WeasyPrint | /tests/layout/test_column.py | UTF-8 | 36,461 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | """Tests for multicolumn layout."""
import pytest
from ..testing_utils import assert_no_logs, render_pages
@assert_no_logs
@pytest.mark.parametrize('css', (
'columns: 4',
'columns: 100px',
'columns: 4 100px',
'columns: 100px 4',
'column-width: 100px',
'column-count: 4',
))
def test_columns(c... | true |
c4cc1c3bcd07a3a1cba1e854160ba18a1b95e939 | Python | bobrayEden/python-katas | /arrays.py | UTF-8 | 324 | 3.453125 | 3 | [] | no_license | """
Move zero to right
Avec une liste d'entiers L en entrée,
retourner une liste en bougeant les zéros vers la droite et sans altérer l'ordre original de la liste
"""
# Ma solution
def move_zeros(array):
filtered = list(filter(None, array))
zeros = [0] * (len(array) - len(filtered))
return filtered + zeros... | true |
da2658e1eb94d357ea03066984c3a8ea162ca9a9 | Python | actuino/unicorn-display | /display-client/local/Rainbow.py | UTF-8 | 1,170 | 2.5625 | 3 | [
"MIT"
] | permissive | import math
import time
import sys
sys.path.append("../classes" )
from AsyncWorker import AsyncWorker
Worker = None
Name = "Rainbow"
i = 0.0
offset = 30
def my_func(unicorn, param):
global i, offset
i = i + 0.3
for y in range(8):
for x in range(8):
r = 0
... | true |
e2da8140accbc60d7f755885ade33b1954ffcbed | Python | darkismus/mooc-ohjelmointi-21 | /osa04-21_kaikki_vaarinpain/src/kaikki_vaarinpain.py | UTF-8 | 313 | 3.171875 | 3 | [] | no_license | # tee ratkaisu tänne
def kaikki_vaarinpain(lista : list):
apulista = []
for i in lista:
apulista.append(i[::-1])
return apulista[::-1]
if __name__ == "__main__":
lista = ["Moi", "kaikki", "esimerkki", "vielä yksi"]
lista2 = kaikki_vaarinpain(lista)
print(lista2) | true |
48a9ee7d2e1cfd5185a4b12ab59f1d90cd2f451d | Python | slott56/HamCalc-2.1 | /python/hamcalc/stdio/speedtd.py | UTF-8 | 3,326 | 3.140625 | 3 | [] | no_license | """Speed/Time/Distance Calculations
"DISTANCE",", as a function of speed and time","","SPEEDTD"
"SPEED",", as a function of time and distance","","SPEEDTD"
"TIME",", as a function of speed and distance","","SPEEDTD"
"""
import hamcalc.math.equiv as equiv
import hamcalc.math.deciconv as deciconv
import hamcalc.math.spe... | true |
c78a629a21f136793f0bf922b1902d04fe9e6b6c | Python | Impavidity/relogic | /scripts/linearize_alignment.py | UTF-8 | 2,666 | 2.84375 | 3 | [
"MIT"
] | permissive | """Convert the fast_align
New York , 2-27 May 2005 ||| Nueva York , 2 a 27 de mayo de 2005
0-0 1-1 1-2 2-2 3-3 3-4 3-5 3-6 4-7 4-8 5-9
the expected output is
([0, 1, 3, 4, 5], [0, 1, 3, 7, 9])
The algorithm here is to use connect components.
"""
import argparse
from scipy.sparse import csr_matrix
from scipy.sparse.csg... | true |
ae2bb038ffaa9e885e1e5c46a0c10cc9003b61f3 | Python | edwhelan/DC-Python104 | /multiplication_table.py | UTF-8 | 233 | 3.671875 | 4 | [] | no_license | multiply = 1
while multiply < 11:
times_what = 1
while times_what < 11:
total_value = multiply * times_what
print('%d X %d = %d' % (multiply, times_what, total_value))
times_what += 1
multiply += 1 | true |
c98987034cc3cbd0a4ee43e1897929a242aa35e1 | Python | yuanshaohui/python-learn | /爬虫/爬虫基础/练习项目/request库_1get请求.py | UTF-8 | 685 | 2.53125 | 3 | [] | no_license | '''
@Author: your name
@Date: 2020-03-19 17:57:03
@LastEditTime: 2020-03-19 18:16:32
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \giee\learn_python\爬虫\爬虫基础\练习项目\request库.py
'''
import requests
from fake_useragent import UserAgent
def main():
# 构建url
url = "https://ww... | true |
bdf66b45ba35e5422f94e20e6ca76bd600fcc0d2 | Python | sanketRmeshram/ML-Assignments | /17CS30030_ML_A2/17CS30030_ML_A2/src/part1.py | UTF-8 | 1,712 | 2.84375 | 3 | [] | no_license | import pandas as pd
import math
#####################Dataset A################################
dataset_A=pd.read_csv("winequality-red.csv",sep=';')
m=len(dataset_A)
for i in range(m):
if dataset_A.at[i,"quality"]<=6:
dataset_A.at[i,"quality"]=0
else :
dataset_A.at[i,"quality"]=1
for i in d... | true |
a3df7e8d2ee3fc4162d90f6502eb2b89d9746aad | Python | thebreakcoder/HackerRank-ProblemSolving | /Staircase.py | UTF-8 | 490 | 2.96875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 21 12:49:26 2020
@author: lenovo
"""
import math
import os
import random
import re
import sys
# Complete the staircase function below.
def staircase(n):
result = ""
for i in range (n):
for k in range (n):
if k >= n - (i + 1):
... | true |
5d3eea8881bf37876d875f293fb034abb202c981 | Python | Aasthaengg/IBMdataset | /Python_codes/p03687/s047329299.py | UTF-8 | 324 | 2.578125 | 3 | [] | no_license | S = input().rstrip()
D = [[-1] for _ in range(26)]
E = [[0] for _ in range(26)]
for i, s in enumerate(S):
E[ord(s)-ord("a")].append(i-D[ord(s)-ord("a")][-1]-1)
D[ord(s)-ord("a")].append(i)
for i in range(26):
E[i].append(len(S)-1-D[i][-1])
res = []
for i in range(26):
res.append(max(E[i]))
print(min(res... | true |
8e2a5d71d72a48b89482ee02773e011cb424aebb | Python | BillionsRichard/pycharmWorkspace | /leetcode/graph/medium/keys_and_rooms_841/ks_and_rooms_841.py | UTF-8 | 1,008 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
"""
@version: v1.0
@author: Richard
@license: Apache Licence
@contact: billions.richard@qq.com
@site:https://github.com/BillionsRichard
@software: PyCharm
@time: 2020/1/5 12:17
"""
from typing import List
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
from c... | true |
5fbc50c274192ec1d19fa1217a33c356264d3f71 | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_1_2_neat/16_1_2_tyoptyop_A2.py | UTF-8 | 952 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
#
# >
import sys
h = file(sys.argv[1], "r")
flag = True
flag2 = True
nb_lines = 0
results = []
lines = []
for line in h.readlines():
if flag == True:
flag = False
continue ;
line = line[:-1]
if flag2 == True:
nb_lines = int(line) * 2 - 1
flag2 = F... | true |
1e4fee4a7a93ff764f90cf1b53a14cd37d3f3557 | Python | PratikshaBKamble/Learing | /Week 2/Sun Lecture/List Operations.py | UTF-8 | 589 | 3.9375 | 4 | [] | no_license | '''
name = str(input("Enter your name"))
Y = str(input("Enter the letters that you want to append"))
Z= int(input("Enter the no of initials to your nickname"))
nickname =name[0:Z] +Y
reverse=name[0:0:-1]
print("Your nickname is:",nickname)
print("Your reverse is:",reverse)
'''
List = ["Pratiksha","Ishika",... | true |
2917464080ca679c423e0ba519c8bbea4838be42 | Python | leoxstar5/python-projects | /degree_calculator.py | UTF-8 | 1,774 | 3.3125 | 3 | [] | no_license | from tkinter import *
root = Tk()
#----------root dimentions----------
width=300
height=150
s_width = root.winfo_screenwidth()
s_height = root.winfo_screenheight()
xpos = (s_width/2)-(width/2)
ypos = (s_height/2)-(height/2)
root.configure( bg='#088985') # set dimentions of window
root.resizable(width=False, height... | true |
4d663ea9e15c8f373aaadd2bdde12dc4d4cca98f | Python | timerickson/kmy | /tests/test_user_address.py | UTF-8 | 742 | 2.515625 | 3 | [
"MIT"
] | permissive | import unittest
from kmy.kmy import Kmy
file_name = 'Test.kmy'
class TestUserAddress(unittest.TestCase):
def setUp(self):
mm = Kmy.from_kmy_file(file_name)
self.useraddress = mm.user.address
def test_read_telephone(self):
self.assertEqual('Telephone', self.useraddress.telephone)
... | true |
f92beaffcd174c0903ef9cc110f4680a8910b38e | Python | chiwenheng/- | /cut_redbox/cut_redboxref.py | UTF-8 | 1,622 | 3.0625 | 3 | [] | no_license | import cv2
import numpy as np
def cut(img,box):
#裁剪轮廓
count = 0
for j in box:
for i in range(4):
j = np.sort(j)
x1 , y1 = j[0]
x2 , y2 = j[2]
img_cut = img[y1+10:y2-10 , x1+10:x2-10] #切片裁剪图片
cv2.imwrite(str(count) + "img.jpg" ,... | true |
94c2c4595460a45d5fe69a8af692ebed4df5ab9b | Python | melquizedecm/pythonProjects | /FundamentosProgramacion/MyRace_1_9/racegame_1,9_lenkung.py | UTF-8 | 9,223 | 2.515625 | 3 | [] | no_license | # debugged: angle, explosion
import pygame, sys, math, time
from shader import *
from light import *
from pygame.locals import *
pygame.init()
bg = (255, 255, 255)
red = (255, 0, 0)
blue = (0, 0, 255)
ww = pygame.display.Info().current_w
wh = pygame.display.Info().current_h
#pygame.mixer.music.load("engine_1.mp3")
... | true |
976750d31bb49a01d1e644d26fc1059b1e377107 | Python | 0ear/practice | /PycharmProjects/0121_new/圖像翻轉2.py | UTF-8 | 293 | 2.765625 | 3 | [] | no_license | from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
image=Image.open("../img/sample01a.jpg").convert('1')
image2=np.transpose(image)
plt.imshow(image2)
plt.axis('off')
plt.show()
plt.imshow(image2,cmap='gray') #灰階影像要加cmap='gray'
plt.axis('off')
plt.show()
| true |
cb6833366cc97c66a6f457b25bb64645c7a6363d | Python | hsinhuibiga/Python | /deck.py | UTF-8 | 1,864 | 4 | 4 | [] | no_license | from card import Card
from random import seed,randint
class Deck:
def __init__(self, valueStart, valueEnd, numSuits):
self.pile = []
self.size = 0
values = []
i = valueStart
while i <= valueEnd:
values.append(i)
i += 1
i = 0
whil... | true |
bb745507bb31e19fff7441445aa092d9a6423286 | Python | jgalanl/nlp | /nltk/stopwords.py | UTF-8 | 291 | 2.890625 | 3 | [] | no_license | import nltk
from nltk.corpus import stopwords
stop_words = set(stopwords.words("english"))
sentence = "Backgammon is one of the oldest known board games."
words = nltk.word_tokenize(sentence)
without_stop_words = [word for word in words if not word in stop_words]
print(without_stop_words) | true |
89c01b05049d6faec12cdcc6d401a54a97721ed7 | Python | cltl/BERT-WSD | /naf_utils.py | UTF-8 | 2,314 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | from lxml import etree
from collections import defaultdict
def add_wsd_header(doc, start_time, end_time):
"""
add WSD header to NAF
:param lxml.etree._ElementTree doc: NAF file loaded with etree.parse()
"""
naf_header = doc.find('nafHeader')
ling_proc = etree.SubElement(naf_header, "linguis... | true |
48066c27bb97b4944b9f6660f5b075c8b92238d1 | Python | arh0329/Machine-Learning | /Machine learning/Lectures_Update1/Lectures/sse.py | UTF-8 | 925 | 3.125 | 3 | [] | no_license | import numpy as np
# We start by definining X, y, and beta.
X = np.array([[12,4], [14,3], [16,6], [20,5], [24,2]])
y = np.array([50, 53, 67, 70, 63])
beta = np.array([12, 1.5, 5])
def find_sse(coeff):
beta = np.array(coeff)
# We start by definining X, y, and beta.
X2 ... | true |
1c2a59dbda5d760895d15ce0283503ee46cc118f | Python | yao23/Machine_Learning_Playground | /LeetCode/412_fizz_buzz.py | UTF-8 | 900 | 3.296875 | 3 | [] | no_license | class Solution(object):
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
https://leetcode.com/problems/fizz-buzz/discuss/90007/Python-1-line-solution
beats 60.57%
"""
return [('Fizz' if i % 3 == 0 else '') + ('Buzz' if i % 5 == 0 else '') +
... | true |
f996c7e2d40f9c31d8d71538fc32962250969200 | Python | cuffery/cs229fall2017 | /data_scripts/match_info/player_details.py | UTF-8 | 1,982 | 2.921875 | 3 | [] | no_license | import pandas as pd
import numpy as np
def importPlayerData():
player = pd.read_csv('../tennis_atp/atp_players.csv', delimiter=",",quoting=3, error_bad_lines=False, encoding = "ISO-8859-1",dtype = object)
print(list(player))
player.columns = ['player_id','player_fname','player_lname','player_hand','player... | true |
c0f9255488680a77115b60a9a4a9d37383340abc | Python | Nika-C/Bioinformatics_Genome-Answers | /bioinformatics_2_3.py | UTF-8 | 95 | 3.5 | 4 | [] | no_license | Str = raw_input('Enter a string: ')
num = input('How many times to repeat: ')
print Str * num
| true |
51ea8b2437800424d75c159b41a7f33a0051d42e | Python | danieman/knowit2020 | /19/stolleken.py | UTF-8 | 1,174 | 3.40625 | 3 | [] | no_license | from collections import defaultdict, Counter
import re
def parse_line(line):
rule = re.compile(r"(\d+) (\d+) (.*)")
a, b, c = re.match(rule, line).groups()
return (int(a), int(b), parse_list(c))
def parse_list(s):
return s[1:-1].split(", ")
def rotate(players, hops):
while hops > 0:
pl... | true |
bf85e90f3006aeedfa455a58c021ec4bb75d37c3 | Python | batmanbury/Coursera | /010-design-and-analysis-of-algorithms-i/programming-assignments/Week-01/countSplitInversions.py | UTF-8 | 4,969 | 3.78125 | 4 | [] | no_license | # countSplitInversions.py
# Coursera -- Design and Analysis of Algorithms, Part I
# Matthew T. Banbury
# matbanbury (at) gmail
"""
This file contains all of the 100,000 integers between 1 and
100,000 (inclusive) in some order, with no integer repeated.
Your task is to compute the number of inversions in the file
give... | true |
72332c4ee1075a53ae1539c81de54705962db1f4 | Python | SireeshaReyyi/Project | /code/Demo/demo.py | UTF-8 | 7,588 | 2.953125 | 3 | [] | no_license | import numpy as np
import pandas as pd
from keras.models import load_model
from keras.preprocessing.image import ImageDataGenerator
from skimage import morphology, io, color, exposure, img_as_float, transform
from matplotlib import pyplot as plt
def loadDataGeneral(df, path, im_shape):
X, y = [], []
for i, ite... | true |
abbc1feef3dc2e096de5a61ad412fc32956aefc3 | Python | PatrickKalkman/Advent-of-Code-2020 | /day14/memory.py | UTF-8 | 1,161 | 3.15625 | 3 | [
"MIT"
] | permissive | test_input = """mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
mem[8] = 11
mem[7] = 101
mem[8] = 0
"""
def execute_program(program):
memory = {}
mask = ""
for instr in program:
parts = instr.split("=")
if parts[0].strip() == "mask":
mask = parts[1].strip()
else:
... | true |
4d74924009a710bf5df67ca2d2b418fe0e916e5e | Python | AIXuMuK/test_ui | /2.4.8.py | UTF-8 | 1,005 | 2.734375 | 3 | [] | no_license | import math
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'... | true |
b21f02aa89de9de476656dd7df2f3e9bb01cba71 | Python | jtolle/aa-odds | /land_only_sim.py | UTF-8 | 3,267 | 3.375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# Now make a class that works for land battles - infantry, artillery, tanks
# import numpy as np
import dice_basics
class LandForce:
"still building up to real rules - just represent vanilla land units (no AA)"
def __init__(self, i = 0, a = 0, t = 0):
self.unit_counts = {... | true |
ca40fa34366e4b597ce131d23fc43c47b51b1140 | Python | qinguan/infolist | /Karrigell-2.3.5/webapps/demo/essaiModule.py | UTF-8 | 117 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | my_url = None
def set_url(url):
global my_url
my_url = url
def info():
return "The url is [%s]" %my_url | true |
2c33aaa1c138ce040e18012a76af45a0b214442f | Python | Galtvam/projeto-de-redes | /game/core/tools/print_tools.py | UTF-8 | 399 | 3.625 | 4 | [
"MIT"
] | permissive | #coding: utf-8
def beautifulPrintCandidates(listOfCandidates):
n = 0
print('Escolha o número do seu candidato: \n')
for candidate in listOfCandidates:
print('['+str(n)+'] - '+candidate + '\n')
n += 1
def beautifulTable(listOfAlivePlayers):
print('Jogadores ainda competindo: \n')
fo... | true |
c4c193baffd243c1e49629f3930a7def24b41108 | Python | kbatten/linkssd | /linkssd.py | UTF-8 | 2,902 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import time
import os
import sys
import ntfsutils.junction
def list_directories(base):
"""List directories in the base directory.
>>> list_directories(r"D:\SSD\Games")
["... | true |
31c2646b6a089535a2c0e21b1d3b9f2a2f7ea247 | Python | ywdhzxf/interesting | /bdtieba.py | UTF-8 | 2,405 | 2.921875 | 3 | [] | no_license | #coding:utf8
import urllib2,urllib
import re
import random
import os
# 搜索哪个贴吧
def tieba(wz):
base_url = 'http://tieba.baidu.com/f?'
#贴吧名字
tbmz = {
'kw':wz,
}
tbmz = urllib.urlencode(tbmz)
tb_url = base_url + tbmz
print tb_url
#根据贴吧名字建立一个文件夹
path = './' + w... | true |
92d45dd46e4bb53b69d8c1006a620e5da3a7f040 | Python | Williangalvani/groundstation_pi3d | /imageCache.py | UTF-8 | 1,869 | 2.703125 | 3 | [] | no_license | __author__ = 'Will'
import urllib
from os.path import abspath, dirname, join
import os
import pi3d
WHERE_AM_I = abspath(dirname(__file__))
cachedir = join(WHERE_AM_I, "cache")
def ensure_dir(d):
if not os.path.exists(d):
os.makedirs(d)
def try_to_remove(filename):
try:
os.remove(filename)
... | true |
bf16153f69ef0bb80f7d6a2db678378274600293 | Python | derbedhruv/csvFilePlotter | /plotFile.py | UTF-8 | 4,696 | 3.546875 | 4 | [] | no_license | # this is for reading in csv
# first, the import statemtnts
import numpy, scipy.signal
import matplotlib.pyplot as plt
def savitzky_golay( y, window_size, order, deriv = 0 ):
r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
The Savitzky-Golay filter removes high frequency noise fr... | true |
3c4dab9de4d74ad700d99c612ea0c4726745daa4 | Python | LucianoAlbanes/AyEDI | /TP1/Parte1/5/main.py | UTF-8 | 1,831 | 4.0625 | 4 | [] | no_license | from algo1 import *
# Ask length of inupt matrix and vector, and declare them
n = int(0)
m = int(0)
while (n < 1):
n = input_int('Ingrese la dimensión (n) de la matriz: ')
while (m < 1):
m = input_int('Ingrese la dimensión (m) de la matriz: ')
inputMatrix = Array(n, Array(m, 0.0))
# Check if the in... | true |
6abdde9b6fc25838a2e5c23ba9530847b427ed28 | Python | pongsak-s/djang_codechallenge | /src/django_main/justapp/services.py | UTF-8 | 1,352 | 2.84375 | 3 | [] | no_license | from django.shortcuts import render
from django.http import HttpResponse
import pika
import json
class Service1():
"""Represent service1 that may need to take queue """
def call(request):
sms_queue = ServiceQueue("localhost")
data = {
"phone": "+66-92-123-4567",
"message": "... | true |
061b66764ad12b4be21e4c9e607fc3bc20500bf8 | Python | RetailXP/3.14Modules | /DataBaseAccess/AdminTask/MessageParser.py | UTF-8 | 1,844 | 2.75 | 3 | [] | no_license | from AdminTask.MessageStruct import *
class MessageParser:
def __init__(self):
self.msgByte = 0 # variable used for communication
self.retVal = 0 # also used for communication
self.genFunc = self.internalParsing() # generator
def parseMsg(self, msgByte):
self.msgByte = msgByte
self.genFunc.__next__()... | true |
e5dc630c2baeec6a6e910b597f243ebad38352af | Python | fanyuyu/Know-your-fans | /Feature_engineering.py | UTF-8 | 9,198 | 2.875 | 3 | [] | no_license | # load all packages needed
import pandas as pd
import numpy as np
from scipy.linalg import solve
import networkx as nx
import itertools
import matplotlib.pyplot as plt
import matplotlib as mpl
get_ipython().magic(u'matplotlib inline')
from matplotlib_venn import venn3, venn3_circles
import seaborn as sns
sns.set()
fro... | true |
55dae7a945106bd5b8a314974d897e8ebfcdd0c1 | Python | emelynsoria/more_python | /activities/iter_month_bday.py | UTF-8 | 2,771 | 3.828125 | 4 | [] | no_license | """
Given a list of dictionaries, convert their birthdays in
Month Name Day, Year format (February 17, 2009) and group
the list by their birthday month using groupby() iterator.
Print the results
"""
from itertools import *
from datetime import datetime
bday_list = [
{
"name": "John Doe",... | true |
1ef6ab9cb346750682caf8be8a72363de1c52732 | Python | getjirat/Idle-Mine-Fight | /command-lists.py | UTF-8 | 270 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | class game():
class workspace():
class gameobjectstorage():
def addtoworkspace(object_name,x,y):
addsprite = ""
addsprite = pygame.image.load("assets/game/workspace/gameobjectstorage/",object_name,".png")
screen.blit(addsprite,(x,y))
| true |
39ea04f49cd6bd202313b56aaf581cca0c44f3dd | Python | Paramonov-Sergey/Tasks | /lucky ticket.py | UTF-8 | 1,381 | 3.921875 | 4 | [] | no_license | """
Паша очень любит кататься на общественном транспорте, а получая билет, сразу проверяет, счастливый ли ему попался.
Билет считается счастливым, если сумма первых трех цифр совпадает с суммой последних трех цифр номера билета.
Однако Паша очень плохо считает в уме, поэтому попросил вас написать программу, которая пр... | true |
5aa9868041805be98fc5e30c526f589100710323 | Python | wulfebw/algorithms | /scripts/graphs/bfs_dfs_revisted.py | UTF-8 | 2,967 | 3.578125 | 4 | [] | no_license |
import collections
class Graph(object):
def __init__(self):
self.adj = collections.defaultdict(list)
def add_edge(self, u, v):
if v not in self.adj[u]:
self.adj[u].append(v)
def bfs_iterative(self, s):
q = collections.deque()
q.append(s)
seen = set([s... | true |
e010a6590a79d7b850a3116cceb8b55e8a5f074b | Python | Elucidation/ChessDetect | /python/grid_ransac_partial.py | UTF-8 | 4,519 | 2.703125 | 3 | [] | no_license | import cv2
import numpy as np
from matplotlib import pyplot as plt
import chessdetect_helpers
np.set_printoptions(suppress=True)
# Ransac grid:
# Iterate up to k times:
# 1. Select 4 random points as hypothetical inlier (skip 4 points too close together, always order bottom-left top-left... based on cartesian coords... | true |
950a2d70d5f4b0d419ef8d7066fdb59406ca9b62 | Python | uccser/codewof | /codewof/programming/content/en/remove-bugs/solution.py | UTF-8 | 197 | 2.890625 | 3 | [
"MIT",
"AGPL-3.0-only",
"ISC",
"LGPL-2.1-or-later",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | def remove_bugs(buggy_code):
debugged_code = []
for i in range(len(buggy_code)):
if buggy_code[i] != 'bug':
debugged_code.append(buggy_code[i])
return debugged_code
| true |
509299cad4a239a9ba253f4d186f3d703fbd8bbe | Python | gat786/cbir | /qt_project/logic.py | UTF-8 | 608 | 2.5625 | 3 | [] | no_license | from qt_project.LSBSteg import LSBSteg as steganography
import cv2
from stegano import lsb
def checkIfDataIsHidden(imagePath):
text = lsb.reveal(imagePath)
return text
def addSecret(imagePath,data):
secret = lsb.hide(imagePath,data)
secret.save(imagePath)
# steg = steganography(cv2.imread('b... | true |
40d3df82af040c0c1fe383ec449dcb0bd222cfe0 | Python | Lykaos/Programming-Under-Pressure | /Python/Computational Arithmetic/Kemija/kemija.py | UTF-8 | 1,460 | 3.125 | 3 | [] | no_license | ############################################################
# #
# DD2458 Problem Solving and Programming Under Pressure #
# Hw 3 - Kemija #
# Eduardo Rodes Pastor (9406031931) #
# ... | true |
aeb585d83808769074fec10a219ee56ad65414a6 | Python | mddengo/TermProject | /ballnstepsz.py | UTF-8 | 47,289 | 2.921875 | 3 | [
"MIT"
] | permissive | # Michelle Deng
# fallDown.py
# Import modules:
import os, sys, random
import pygame
from pygame.locals import *
# Uploads an image file
# I did NOT write this function!
# Credits: http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html
def load_image(name, colorkey = None):
fullname = os.path.join('', name)
... | true |
59b146c4ac680fdb487b6a817792d50f84f3aff5 | Python | besmertn/Shop | /src/entities/product.py | UTF-8 | 2,060 | 2.59375 | 3 | [
"MIT"
] | permissive | from random import randint
from datetime import datetime
import enum
from werkzeug.security import generate_password_hash, check_password_hash
from marshmallow import Schema, fields, post_load
from flask import current_app
from src import db
class UnitEnum(enum.Enum):
gram = 'gram'
piece = 'piece'
litre... | true |
222107336a32abd0725ec1bfa4c49d0c631e11aa | Python | wyaadarsh/LeetCode-Solutions | /Python3/0386-Lexicographical-Numbers/soln.py | UTF-8 | 369 | 3.15625 | 3 | [
"MIT"
] | permissive | class Solution:
def lexicalOrder(self, n):
"""
:type n: int
:rtype: List[int]
"""
iters = []
i = 1
while 10 ** (i - 1) <= n:
iters.append(range(10 ** (i - 1), min(n + 1, 10 ** (i))))
i += 1
merged = heapq.merge(*iters, key=str)
... | true |
b02a1d3a051a80f7ccf5c9b0092787718cc77aa2 | Python | tyjo/dystruct-experiments | /msprime/format.py | UTF-8 | 750 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
# Converts sample files to .geno format for ADMIXTURE
import os
import numpy as np
from sys import argv
file = argv[1]
outfile = open(file + ".ped", "w")
genotypes = open(file, "r").readlines()
genotypes = [list(row.strip("\n")) for row in genotypes]
genotypes = np.array(genotypes).astype(int)... | true |
b79fd6d53dc69cdb01198de061f58f974c0f0363 | Python | anusha-yammanur/cloud-travel | /Heap.py | UTF-8 | 1,783 | 3.859375 | 4 | [] | no_license | from Item import Item
class Heap:
def __init__(self, heapType):
self.array = []
self.count = 0
self.heapType = heapType
"""
inserts an item in heap
"""
def insert(self, item):
self.count = self.count + 1
self.array.insert(0, item)
self.percolateDown(0)
"""
computes position of left child of ith e... | true |
cb993dcf361d87beb5fe1e69c831ae8ba79292d0 | Python | tqsclass/edX | /6002x/ps3/EstimatePi.py | UTF-8 | 1,514 | 3.421875 | 3 | [
"MIT"
] | permissive | # Estimate Pi problem - code used from class
import random, pylab
#set line width
pylab.rcParams['lines.linewidth'] = 6
#set font size for titles
pylab.rcParams['axes.titlesize'] = 20
#set font size for labels on axes
pylab.rcParams['axes.labelsize'] = 20
#set size of numbers on x-axis
pyl... | true |
61d25b392872ac61806b2fde9c682708c7999a4e | Python | jaideepmurkute/Multi-purpose-Disentangling-Variational-Autoencoders-for-ECG-data | /commonModels.py | UTF-8 | 2,329 | 2.609375 | 3 | [] | no_license | """
Common functions for all models
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import sys
import numpy as np
import pdb
from utils import *
SMALL = 1e-16
def init_weights(weights):
for layer in weights:
torch.nn.init.normal(layer.weight.data... | true |
71f95494ea383d15678542132b506a74b67658a8 | Python | Ashutoshrai14/hello-world | /reverse_name.py | UTF-8 | 120 | 3.875 | 4 | [] | no_license | x=int(input("enter the first number:"))
y=int(input("enter the second number:"))
x=x+y
y=x-y
x=x-y
print(x," ",y)
| true |
bb2c1dc5e72c4bd91a2b5013f4f3bd87a6ec0790 | Python | Camixxx/ML-Training | /music-generation/distin_old/rnn_demo_old.py | UTF-8 | 3,102 | 2.75 | 3 | [] | no_license | import sys
import mxnet as mx
import numpy as np
import rnn
import read_xml as read
sys.path.insert(0, "../../python")
"""
For music classification
"""
def drop_tail(X, seq_len,num_size):
shape = X.shape
# 得到的行数x.shape[0] ,在这个函数中还有进行按seq_len进行取模
# 使返回的X的行数可以被seq_len整除
print(sys.stdout, 'drop tail:shap... | true |
b10941626ac1d1affba54becfd06b2fd7bf89817 | Python | QinmengLUAN/Daily_Python_Coding | /wk4_smallerNumbersThanCurrent.py | UTF-8 | 1,426 | 4.0625 | 4 | [] | no_license | """
Leecode 1365. How Many Numbers Are Smaller Than the Current Number
"Moe doesn't like this question"
Given the array nums,
for each nums[i] find out how many numbers in the array are smaller than it.
That is, for each nums[i]
you have to count the number of valid j's such that j != i and nums[j] < nums[i].
Retur... | true |
feb0f861f1c006313a33470230b62a973355d9cc | Python | sabrinamamamia/search-engine | /ranking-and-retrieval/query_dynamic.py | UTF-8 | 7,029 | 2.953125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import preprocess_query as preprocess
import query as query_static
import os
import sys
import collections
import ast
import math
from time import time
def processQuery(query, indexType, index):
"""Processes and sends query to the BM25 retrieval model.
Logical flow is simi... | true |
d68c523d2670dd86f2b13aafb30e6a210cb14e09 | Python | JasonMuscles/MyDjango | /booktest/views.py | UTF-8 | 1,637 | 2.59375 | 3 | [] | no_license | from django.shortcuts import render
from django.http.response import HttpResponse
from django.template import loader, RequestContext
from booktest.models import BookInfo # 导入图书
# Create your views here.
# 1.定义一个视图,HttpResponse
# 2.进行url配置建立地址和视图的对应关系
# def my_render(request, template_path, context_dict={}):
# #... | true |
d899fa5e8ecf38c010fea12345025625ca39ff6d | Python | yeonjooyou/algorithm | /baekjoon/Python/8393.py | UTF-8 | 86 | 3.3125 | 3 | [] | no_license | # 합
n = int(input())
sum=0
for i in range(1,n+1):
sum += i
i += 1
print(sum) | true |
a6260484c522e7fac8bd119f8d7743c28c018c0d | Python | CSCfi/Kielipankki-utilities | /vrt-tools/vrt-redact-long | UTF-8 | 5,491 | 2.71875 | 3 | [] | no_license | #! /usr/bin/env python3
# -*- mode: Python; -*-
from itertools import groupby, chain
import os, re, sys, traceback
from vrtargslib import trans_args, trans_main
from vrtargslib import BadData, BadCode
from vrtnamelib import xname, isnames, namelist, nameindex
from vrtdatalib import asrecord, unescape, escape
def pa... | true |
3e6dfaac3472f2e9b2328cf0a15a5a0127179b9f | Python | andrebodo/lexis-sentiment-indexer | /tone_index.py | UTF-8 | 6,513 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""Article Count Sentiment Indexer
A script to create a sentiment index which is simply the number of news articles articles per month
"""
import os
import re
import sys
import pandas as pd
import numpy as np
import contextlib
from datetime import datetime
import sqlite3
from pathlib import Path... | true |
df565d5d4c0f7ff3f0cf94c6306f5d727f24937e | Python | mattgarner/Rosalind | /src/lcsm.py | UTF-8 | 1,582 | 3.453125 | 3 | [] | no_license | '''
Created on 4 May 2015
@author: matt
Given: A collection of k (k<=100) DNA strings of length
at most 1 kbp each in FASTA format.
Return: A longest common substring of the collection.
(If multiple solutions exist, you may return any single solution.)
'''
import sys
import os
from __builtin__ import reversed
def... | true |
c447097d406b8251d394392c86ad7e790117a8e7 | Python | BJUT2016SoftJunLu/TensorFlow | /tutorials/TensorFlowBasic/base3.py | UTF-8 | 1,537 | 3.171875 | 3 | [] | no_license | import tensorflow as tf
import numpy as np
"""
使用神经网络进行回归训练
"""
# np.linspace 返回间隔相同的数列
# [:, np.newaxis] 表示每一个数字一行,[np.newaxis,:] 表示所有数据一行
x_data = np.linspace(-1,1,300)[:,np.newaxis]
noise = np.random.normal(0, 0.05, x_data.shape)
y_data = np.square(x_data) - 0.5 + noise
# 定义一层网络
def add_layer(x_data,input_size,... | true |
b1a022bfd1800a03fe701a62a2c1a291da18d18e | Python | syauqylei/mytools | /parse_log/utils/ParseLog.py | UTF-8 | 2,553 | 2.8125 | 3 | [] | no_license | import json
class LogParser:
_arr_dict = []
_default_ext = 'txt'
_path = None
def __init__(self, filename):
self.filename = filename
self.parse()
def save(self, file_type=None, filename=None, output_path=''):
fname = self._extract_fname_path() if filename is None else fil... | true |
c4d9666fa03db08d9135888f9a87551cf9e41dfd | Python | robkegeenen/5SIA0 | /CGRA/tools/HardwareGenerator/DRC.py | UTF-8 | 15,167 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
import os
import re
from Config import Config
from collections import Counter
class DRC():
def __init__(self, fname, buildNW):
self.config = Config(fname)
#This class performs the following checks (generation without switchboxes):
#(1) check if all referen... | true |
22b6db06ab599bfccf17ff0a0596d58f2306617f | Python | swadipa123/Python-Examples | /delete_methods_list.py | UTF-8 | 334 | 4.15625 | 4 | [] | no_license | #delete methods for list----->pop,del,remove
fruits=["mango","banana","apple","apple","kiwi"]
#del
# del fruits[1] #delete banana
#pop
fruits.pop() #pop item from last i.e kiwi
#remove
#fruits.remove("mango") #remove perticular item from list
fruits.remove("apple") #remove from left if same items in list... | true |
51f480dd026089fee6c5ea3152def4fe02d5bde5 | Python | rashidisayev1525/visa-termin-master | /archive/fetch_value.py | UTF-8 | 241 | 2.71875 | 3 | [
"MIT"
] | permissive | import sys
import os
import re
import pprint
searchkey = sys.argv[1]
querygroups = sys.argv[2].split('&')
for group in querygroups:
tokens=group.split("=")
if(len(tokens) == 2 and tokens[0] == searchkey):
print(tokens[1])
| true |
9bc9265276cad79033a44cafa911c37accc24854 | Python | fil0o/git-repo | /backup_ver2.py | UTF-8 | 1,660 | 3.09375 | 3 | [] | no_license | import os
import time
# 1. Файлы и каталоги, которые необходимо скопировать, собираются в список.
source = ['"\\\\192.168.1.33\\ad\\base_backup"']
# Заметьте, что для имён, содержащих пробелы, необходимо использовать
# двойные кавычки внутри строки.
# 2. Резервные копии должны храниться в основном каталоге резерва.
... | true |
2f306807c7c246a88cc64bf08c80cddbbe5a1706 | Python | yuyttenhove/slab_mcrt | /plot.py | UTF-8 | 491 | 2.5625 | 3 | [] | no_license | import sys
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
def main():
fname = sys.argv[1]
basename = fname.split(".")[0]
output_dir = Path(__file__).parent / "output"
data = np.loadtxt(str(output_dir / fname))
mu = data[:, 0]
intensity = data[:, 1]
fig, ax = ... | true |
0f72ec3f14eca29ffc8f0a60673192d0b5475717 | Python | avshmelev/stepik-autotest | /module3_lesson_2_step12.py | UTF-8 | 2,015 | 2.734375 | 3 | [] | no_license | from selenium import webdriver
import time
import unittest
class RegistrationTestCase(unittest.TestCase):
def test_reg1(self):
link = "http://suninjuly.github.io/registration1.html"
browser = webdriver.Chrome()
browser.get(link)
first_name = browser.find_element_by_css_selector(".f... | true |
93cebf8e133a8c8f55216e618fa5d50949027ede | Python | MartinRooijackers/AmongUsImpostorDetection | /utils.py | UTF-8 | 7,725 | 2.796875 | 3 | [] | no_license | from colormath.color_objects import sRGBColor, LabColor
from colormath.color_conversions import convert_color
from colormath.color_diff import delta_e_cie2000
import numpy as np
import cv2
import math
def get_hue(r, g, b):
minimum = min(r, g, b)
maximum = max(r, g, b)
if min == max:
return 0
... | true |
d74541af529cf9fb1c74e3a6faaf66b483c10d3d | Python | RicardoEngComp/Meus-Projetos | /Exercícios Python/Python/Scripts/Aula 17/exc 078.py | UTF-8 | 589 | 4 | 4 | [
"MIT"
] | permissive | numeros = []
numerosOrdenados = []
for c in range (0,4):
numeros.append(input(f'Digite um valor na posição {c}: '))
maior = numeros[0]
menor = numeros[0]
for c in numeros:
if maior < c:
maior = c
for c in numeros:
if menor > c:
menor = c
print(f'O maior numero é {maior} e aparece nas posicoes:'... | true |
9ca33fd344ae32cfe811d8f2ef4b9319a5817625 | Python | minhthe/practice-algorithms-and-data-structures | /Explore/September 30 days/19_sequence_number.py | UTF-8 | 581 | 3.046875 | 3 | [] | no_license | class Solution:
def sequentialDigits(self, low: int, high: int) -> List[int]:
root = list('123456789')
str_low, str_high = str(low), str(high)
start, end = len(str_low), len(str_high)
rst = []
# print(root, start, end)
for l in range(start, end+1):
... | true |
954048bfba3f8c4d9a01d037d6720205f6a516bf | Python | Kadnikov1977/Udemy | /mydatabase.py | UTF-8 | 1,171 | 3.578125 | 4 | [] | no_license | import sqlite3
conn = sqlite3.connect('mybase_db.db') # если файла нет, то он создается
c = conn.cursor()
# c.execute('CREATE TABLE myfamely2 (first_name TEXT, last_name TEXT, age INTEGER);')
print("Для вставки данных в базу myfamely2 введите 1")
print("Для вывода всех данных базы myfamely2 введите 2")
select_y... | true |
1acd8b171f3dd196cb5abc7e2be269053aee238d | Python | lzr2006/PythonStudy | /Chapter2/Example6.py | UTF-8 | 52 | 2.703125 | 3 | [] | no_license | Chapter2/Example6.py
i = 2
t = 3
f = t - i
print(f)
| true |
701be34a6ba7d45fa2d9e964f2a92a210d3f081c | Python | mtyton/password_hasher | /test.py | UTF-8 | 187 | 2.828125 | 3 | [] | no_license | import unittest
from primal import Rabin_Miller
class TestRabinMiller(unittest.TestCase):
def test_check_number(self):
rab = Rabin_Miller(13, 20)
print(rab.check()) | true |
cd2ceda13f29d478187975e812188e72de5db05c | Python | institution/c3rush | /c3rush/engine/log.py | UTF-8 | 241 | 2.796875 | 3 | [] | no_license | import sys
class Log(object):
def __init__(self, debug=True):
self.debug = debug
def __call__(self, *xs):
if self.debug == True:
sys.stderr.write(''.join(str(x) for x in xs) + '\n')
log = Log()
| true |
d69897a2554ed0555db6211ece35b0e9fdaba98a | Python | Comp-Sci-Principles-2018-19/project-lanoflatfaceo | /Graphing.py | UTF-8 | 576 | 4.125 | 4 | [] | no_license | #first go to Tools > Manage Packages...
#Search for numpy and install,
#then search for matplotlib and install
import numpy as np
import matplotlib.pyplot as plt #sets up a pyplot graph as plt
def f(x):
"""function f takes in x then assigns y to x divided by 2 plus 3 """
y = x**2 / 4 + 3
return y
#sets ... | true |
2cc9d6ea2ea1dfd889b4feee65553e3905bb867d | Python | Bilguun1015/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | UTF-8 | 506 | 3.765625 | 4 | [] | no_license | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
pair = 'th'
if word:
first, *rest =... | true |
5f6d7b2e337f7bb34dfd833f3f7d2a5f81bb2b33 | Python | niemitee/mooc-ohjelmointi-21 | /osa06-11_paivakirja/src/paivakirja.py | UTF-8 | 702 | 3.4375 | 3 | [] | no_license | # tee ratkaisu tänne
def kirjoita():
with open('paivakirja.txt', 'a') as tiedosto:
merkinta = input('Anna merkintä: ')
tiedosto.write(f'{merkinta}\n')
print('Päiväkirja tallennettu')
def lue():
with open('paivakirja.txt') as tiedosto:
print('Merkinnät:')
for rivi in ti... | true |
74e826eda8214f145422daaf1e7214e7380f65f9 | Python | PRIBAN91/TrainTickets | /DeterministicModel/CheckIfOnTrack.py | UTF-8 | 1,663 | 2.640625 | 3 | [] | no_license | import Calculations.CalculateCorrelation as Coefficient
from DataAcess.CassandraConn import session
from Config.Constants import *
class OnTrack:
def __init__(self, station_code, time_series_lat, time_series_lon):
self.station_code = station_code
self.time_series_lat = time_series_lat
self... | true |
cfc74127d55d99125fddd27dc761d52ae302c526 | Python | komakim/python_training | /Python_Programming/chapter1/gui2.py | UTF-8 | 119 | 2.640625 | 3 | [] | no_license | from Tkinter import *
widget = Button(None,text='Hello widget world',command = 'exit')
widget.pack()
widget.mainloop()
| true |
ba0e800733750f4a8a8c426524dcdc78e9985d4f | Python | seanmoir/COMP151 | /mastery7/plots.py | UTF-8 | 2,196 | 3.28125 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10,0.1)
y = np.sin(x)
plt.plot(x, y)
plt.show()
y = 3 * np.sin(x*x) - 2 * np.cos(x*x*x)
plt.plot(x, y)
plt.show()
y = pow(2, ((-x)*2)/2)
plt.plot(x, y)
plt.show()
t = np.arange(0,2*np.pi,0.01)
x = t * np.cos(t)
y = t * np.sin(t)
plt.plot(x,y)
# th... | true |
e51c80750ef98303c32ccdd3766b71c7dcccd552 | Python | mhreza76/selenium_python | /SeleniumSessions/WebDrivrManagerCrossBrowser.py | UTF-8 | 1,655 | 2.515625 | 3 | [] | no_license | import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
brows... | true |