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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8e3cf43e1d62308b1feeb537e76b3faca235f5c3 | Python | TheCodingHacker/SMSScare | /SmsScareV.7.py | UTF-8 | 11,713 | 2.859375 | 3 | [] | no_license | from twilio.rest import Client
from datetime import date
import random
import time
def main():
print("""
Welcome to Coder's and Geral's SMS Scare Software
1) Send an SMS
2) Credits
3) Exit
""")
choice=input("Enter a number: ")
if(choice == "1"):
sms()
if(c... | true |
efd92e25f77eed42337fb4c272eab521c1d8de3b | Python | SylvainDeker/Distributed-Systems | /draft/pytest/test_fixture.py | UTF-8 | 1,101 | 2.546875 | 3 | [] | no_license | import os
import pytest
import numpy as np
import cv2 as cv
# pytest test_fixture.py
def test_needsfiles(tmpdir):
# provide a temporary directory unique to the test invocation
print(tmpdir)
assert True
def test_create_file(tmp_path):
# The tmp_path_factory is a session-scoped fixture which can be
... | true |
ded6caae87a5072f00699e30d68548ddfc8d808b | Python | leonardobc52/edd_1310_2021 | /ADTS/Laberinto/Backtracking.py | UTF-8 | 2,737 | 3.25 | 3 | [] | no_license | from Array2D import Array2D
from stack import Stack
class LaberintoADT:
"""
0 pasillo , 1 pared, S salida y E entrada
pasillo es una tupla ((2,1),(2,2),(2,3),(2,4),(3,2)(4,2))
Entrada en una tupla(5,1)
salida(2,5)
"""
def __init__( self , rens , cols , pasillos , entrada , salida ):
... | true |
4b268f19cdfba36db05a7be7efb74785f5a48b40 | Python | oliewalcp/WeChat | /SourceCode/Assist/Saver.py | UTF-8 | 3,146 | 2.703125 | 3 | [] | no_license | from Assist.GlobalVariable import *
"""
保存朋友信息
param[friend_id]:朋友id号
param[sender]:发送者
param[receiver]:接收者
param[nick_name]:朋友昵称
param[friend_remark_name]:朋友备注
"""
def save_friend_info(friend_id, nick_name, remark_name):
mem_file = QSettings(GlobalVariable.PersonalMsgFile, QSettings.IniFormat)
n... | true |
48495f29ced6cc67cfa9531c7eedb2eaca2bbcb3 | Python | 827983519/recommend_algorithm | /ICF_topN_class.py | UTF-8 | 5,296 | 2.625 | 3 | [] | no_license | from sklearn.metrics import pairwise_distances
import copy
class ICF_topN:
def R_jaccard(self,I1,I2):
intersect = 1.0 * len(np.intersect1d(I1,I2))
if intersect == 0:
return 0
I1_g = 1.0 * len(I1) - intersect
I2_g = 1.0 * len(I2) - intersect
dow... | true |
c0ef608f42cc68fa2ab14799904987dd68c2f9aa | Python | FluffyFu/Leetcode | /547_number_of_provinces/solution2.py | UTF-8 | 509 | 3.171875 | 3 | [] | no_license | def bfs(isConnected):
n = len(isConnected)
visited = set()
res = 0
for i in range(n):
if i not in visited:
to_visit = [i]
while to_visit:
cur = to_visit.pop()
temp = []
for j, val in enumerate(isConnected[cur]):
... | true |
781ffe1a8253aacd491cd6b5c6535c686df3c1ef | Python | prashantpandey9/codesseptember2019- | /hackerearth/rotation.py | UTF-8 | 433 | 2.75 | 3 | [] | no_license | ##n=int(input())
##s=list(map(str,input()))
##t=list(map(str,input()))
##if n>=1 and n<=10**3 and len(s)==len(t):
## count=0
## match=0
## l=n
## for i in range(n-1):
## print(s[i:n-1],t[0:n-1-i])
## if s[i:n-1]==t[0:n-1-i]:
## break
##
## print(i)
n = int(input())
s = input()
... | true |
ee9361e8a34ddd236bedb3099a49521d32b74a31 | Python | pabloalarconm/linkml | /linkml/generators/prefixmapgen.py | UTF-8 | 3,535 | 2.53125 | 3 | [
"CC0-1.0"
] | permissive | """
Generate JSON-LD contexts
"""
import logging
import os
from typing import Union, TextIO, Set, Optional
import click
from jsonasobj2 import JsonObj, as_json
from rdflib import XSD
from linkml_runtime.linkml_model.meta import SchemaDefinition, ClassDefinition, SlotDefinition, Definition, Element
from linkml_runtim... | true |
ff6c76d95dac5d0ea631e0b0a547c96a753fc468 | Python | Spy7Dragon/Unsupervised-Learning-and-Dimensionality-Reduction | /comparison_generation.py | UTF-8 | 24,959 | 2.671875 | 3 | [] | no_license | import itertools
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import *
import pandas as pd
import traceback
from timeit import default_timer as timer
colors = ['red', 'orange', 'green', 'blue', 'indigo', 'violet']
def compare_cluster_values(model, data, attribute, values):
training_fe... | true |
143035dacc93c929a1be9db65b44a4992f8c8152 | Python | knighton/comma_speed | /common/dataset.py | UTF-8 | 4,565 | 2.984375 | 3 | [] | no_license | import numpy as np
class Split(object):
def __init__(self, samples_per_epoch, x_sample_shapes, x_dtypes,
y_sample_shapes, y_dtypes):
self.samples_per_epoch = samples_per_epoch
self.sample_shapes = x_sample_shapes, y_sample_shapes
self.x_sample_shapes = x_sample_shapes
... | true |
6b23ec7d907dde0d4032b866ce590d1d733f486b | Python | webclinic017/workspace_pyCharm | /divyanshu/dbHandler.py | UTF-8 | 1,675 | 2.828125 | 3 | [] | no_license | import MySQLdb
import env
from custom_logging import logger
class DBHandler:
db = ''
cursor = ''
def __init__(self, query = 'use python;'):
try:
DBHandler.db = MySQLdb.connect(env.DB_IP, env.DB_USER, env.DB_PASSWORD, env.DB_DATABASE)
logger.info('Connection created !!')
... | true |
dc0a9209205fee58f975f99970aa72227d931c47 | Python | kouui/XenICsPy | /XenicsGUI/tabs.py | UTF-8 | 994 | 2.71875 | 3 | [] | no_license | import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWidgets import QVBoxLayout, QTabWidget
from xenicsPanel import XenicsPanel
from observePanel import ObservePanel
class Tab(QWidget):
def __init__(self, parent):
super(QWidget, self).__init__(parent)
self.parent = parent
... | true |
e0abdbf31c5525240a4f0001b206a5cb5df9d751 | Python | erinnlebaron3/python | /ZipFunc.py | UTF-8 | 1,308 | 3.828125 | 4 | [] | no_license | # going to allow us to do is actually merge our lists or merge multiple lists into a set of tuples.
# many of the algorithms that you build whenever you're working with machine learning algorithms are what are called matrix matrices.
# matirx set of nested colections that can be built with Zip Function
# one important... | true |
9546f0464199595cc262bf536cbba17a80c63fad | Python | Suraj-KD/HackerRank | /python/string/Capitalize.py | UTF-8 | 277 | 2.796875 | 3 | [] | no_license | from __future__ import print_function
import sys, re
def capitalize(text):
return ''.join([ x[0].upper() + x[1:] if x.isalpha() else x for x in re.split('(\W+)', text) ])
def main():
print(capitalize(sys.stdin.read().rstrip()))
if __name__ == '__main__':
main()
| true |
923953fa43f3382207b8cb168cc75d42a9a0fab7 | Python | Asi7ho/BlackJackPP | /original/donnees.py | UTF-8 | 482 | 2.515625 | 3 | [] | no_license | """Ce fichier définit quelques données, sous la forme de variables"""
nom_carte = { 1: 'As', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8',9: '9', 10: '10', 11: 'valet', 12: 'dame', 13: 'roi' }
figure_carte = {'p': 'pique','t': 'trefle', 'c': 'carreau', 'h': 'coeur' }
deck = []
figures = [ 'p','t','c','h'... | true |
240f858ab332e2a1402ff09f095fb3cbb5d055a0 | Python | brahimmade/SVC-Streaming | /codecs/old/plots/perf/plot.py | UTF-8 | 1,662 | 2.75 | 3 | [] | no_license | import os
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams.update({'font.size': 50})
matplotlib.rcParams['figure.figsize'] = 20, 10
fig, ax = plt.subplots()
fig.tight_layout()
fig.subplots_adjust(left=0.15, top=0.96, right=0.96)
lines = open('ssim.txt', 'r')
bpp1 = []
itr = []... | true |
fedfa8bef4f8c8ea04c007140d37102df0f72a06 | Python | Mythologos/Smorg | /Bot/Cogs/Helpers/Enumerators/timekeeper.py | UTF-8 | 7,796 | 2.65625 | 3 | [] | no_license | """
This module consists of various enumerations and groups of constants relating to time.
This mainly includes classes like TimeZone which delve into what aliases relate to each UTC timezone offset
and sets of aliases or constants.
"""
from __future__ import annotations
from aenum import Enum, NamedConstant
from typ... | true |
fcd0283127a2b7dd39dee6fd6b1acb0b1281b2e8 | Python | ramankarki/learning-python | /computer_scientist/recursion/find_max.py | UTF-8 | 514 | 2.828125 | 3 | [] | no_license | from test_suite import *
print(find_max([[12],3,[4,5,10],7,8,9,[1,100]]) == 100)
test(find_max([2, 9, [1, 13], 8, 6]) == 13)
test(find_max([2, [[100, 7], 90], [1, 13], 8, 6]) == 100)
test(find_max([[[13, 7], 90], 2, [1, 100], 8, 6]) == 100)
test(find_max(["joe", ["sam", "ben"]]) == "sam")
test(find_max([2, 9, [1,... | true |
eb90c2afac1aedd1b190eee661cce07262c4a210 | Python | darraes/coding_questions | /v1/DynamicProgramming/dy_boxes_stack.py | UTF-8 | 2,835 | 3.484375 | 3 | [] | no_license | # Craking the Code Interview - Dynamic Programming
# http://www.careercup.com/question?id=5712696989188096
class Box:
def __init__(self, width, height, depth):
self._width = width
self._height = height
self._depth = depth
def __eq__(self, other):
if type(other) is typ... | true |
b75c02eaad0a4ad59a6d1328510404f4d7a4b79b | Python | millinma/lyapunov | /lyapunov-exponent.py | UTF-8 | 556 | 2.875 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
def lyapunov_exponent(r, preiterations, start_value, iterations):
# run preiterations
lyap = 0
x = start_value
for _ in range(preiterations):
#print x
x = r*x*(1-x)
for _ in range(iterations):
x = r*x*(1-x)
help_v =... | true |
a035de293fd92738506227dd34d5177178df90ce | Python | danielchung1012/Fyp | /python3/main3.py | UTF-8 | 2,312 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
from multiprocessing import Process, Value, Array
from imutils.video import VideoStream
from pyimagesearch.basicmotiondetector import BasicMotionDetector
from imutils.object_detection import non_max_suppression
from detector_model.detector import MultiPeopleDetector
from imutils import paths
import nu... | true |
4f4f3ce027f4bb978c0467ec3407427a65329c5b | Python | makhmudislamov/Matrix-Quote-Generator | /sample.py | UTF-8 | 2,244 | 3.703125 | 4 | [] | no_license | import random
from datetime import datetime
from histogram import *
def histogram_dict(word_list):
"""
Input >>> array of strings
Output >>> histogram in a dictionary format
"""
hist_dict = {}
for word in word_list:
if word not in hist_dict:
hist_dict[word] = 1
els... | true |
38a990b0822f6b29f4e72b4d16fa74ffacda27b0 | Python | BenguTercan/Memory-Game | /MemoryGame.py | UTF-8 | 2,899 | 3.171875 | 3 | [] | no_license | from tkinter import *
import time
import random
def started() :
count = 5
button.destroy()
printSmt(count)
def printSmt(count):
def numbers():
number = random.randint( 0,9 )
return number
depola_sayi = ""
for x in range ( count ) :
canvas = Canvas( width ... | true |
6ccfe2407d7e22361551794da549fe7219397de7 | Python | yuniaohappy/HeadFirstPython | /07/athletelist.py | UTF-8 | 833 | 3.515625 | 4 | [] | no_license | def sanitize(time_string):
if '-' in time_string:
splitter = '-'
elif ':' in time_string:
splitter = ':'
else:
return time_string
(mi, secs) = time_string.split(splitter)
return mi + '.' + secs
class AthleteList(list):
def __init__(self, a_name, a_dob=None, a_times=[]):
... | true |
3a1e97f3d5d48d54b418392d4ba3257e69a842b2 | Python | richard912611428iop/leetcode-py | /src/Count and Say.py | UTF-8 | 400 | 3.046875 | 3 | [
"MIT"
] | permissive | class Solution:
def foo(self, data, maxlen):
L = []
for i in range(maxlen):
data = "".join(str(len(list(g)))+str(n) for n, g in (
itertools.groupby(data)))
L.append(data)
return L
# @return a string
def countAndSay(self, n):
if n == 1:... | true |
2df408a76de81a3b8ef96cb749ff7895aed4dc01 | Python | juechen-zzz/learngit | /python/D2L_AI_Pytorch/5_2 填充和步幅.py | UTF-8 | 954 | 3.015625 | 3 | [] | no_license | import torch
from torch import nn
def comp_conv2d(conv2d, X):
X = X.view((1, 1) + X.shape)
# print(X.shape) # torch.Size([1, 1, 8, 8])
Y = conv2d(X)
return Y.view(Y.shape[2:]) # 排除不关心的前两维:批量和通道
# 注意这里是两侧分别填充1行或列,所以在两侧一共填充2行或列
conv2d = nn.Conv2d(in_channels=1, out_channels=1, kern... | true |
72a35f9ee728436280df2558812c6bf3ca1a9278 | Python | TouchPal/guldan | /app/api/models/user.py | UTF-8 | 2,719 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
from sqlalchemy import Column, String
from flask import g
from app.exc import GulDanException
from .base import Base
class User(Base):
__tablename__ = "user"
name = Column(String(64), nullable=False, unique=True)
secret_hash = Column(String(32), nullable=False) # used for login ... | true |
b95c63628c1bb6595f5a260639395e4542303331 | Python | YuliyaUt/ElGamalSecAnalyzer | /main.py | UTF-8 | 9,306 | 3.078125 | 3 | [] | no_license | import math
def get_param_by_key(params, key, message):
if (key in params) and (len(params) > (params.index(key) + 1)):
ind = params.index(key)
param = params[ind + 1]
else:
print(message)
param = input()
return param
# Euclid's algorithm
def gcd(a, b):
... | true |
2b7e784c3fa464101c7648dde144974ceedd46fd | Python | haishenming/scrapy_tt | /selenium_tt/selenium_spider.py | UTF-8 | 191 | 2.5625 | 3 | [] | no_license |
# 通过selenium拿到cookie
from selenium import webdriver
brower = webdriver.Chrome()
brower.get("http://www.baidu.com")
Cookie = brower.get_cookies()
print(Cookie)
brower.close() | true |
c5cd1f02591140965834691fb68b2090c3c253d8 | Python | d3815/other | /check_and_move_png.py | UTF-8 | 923 | 2.84375 | 3 | [] | no_license | import os
import shutil
from PIL import Image
'''
проходим по всем файлам в папке
проверяем размеры (должны быть не больше 256 по обеим сторонам)
переносим их в новую папку
'''
path_to_png_dir = '/ipad-hd'
for d, dirs, files in os.walk(os.getcwd() + path_to_png_dir):
for one_file in files:
i... | true |
994168febc671340a2b9670e750d28d7ce3210a6 | Python | niklasw/wfrp4e_rpc_flask_server | /utils.py | UTF-8 | 8,303 | 2.9375 | 3 | [] | no_license | import sys
from collections import UserDict, UserList
def Error(*args):
s = 'Error: '
for a in args:
s += f'{a} '
print(s, file=sys.stdout, flush=True)
def Info(*args):
s = '>>>>> '
for a in args:
s += f'{a} '
print(s)
def Log(*args, log_file_name='log'):
s = '>>>>> '
... | true |
c00a88f2b0d3a5c984f667f406365b2d20b01075 | Python | GlennCoding/cryptography-py | /main.py | UTF-8 | 1,347 | 3.453125 | 3 | [] | no_license | import encryption
import decryption
def check_input(a, b, message):
while True:
user_input = input(message)
if user_input == a or user_input == b:
return user_input
elif user_input == 'back':
break
else:
print('Please only enter the desired charac... | true |
1072f2264b7fd13e5535e79730a89a8afdd1b7e8 | Python | Scaravex/googlaround | /google places.py | UTF-8 | 5,553 | 2.71875 | 3 | [] | no_license | ##help place: https://developers.google.com/places/web-service/search
##download googleplaces here --> https://github.com/slimkrazy/python-google-places
#installed: googleplaces, gmaps
import json
import pandas as pd
import numpy as np
import csv
import codecs
from time import sleep
from googleplaces import GooglePla... | true |
20c95a079ea8373ef795bbba0ab6670e8c79baf2 | Python | stencila/hub | /worker/jobs/extract/__init__test.py | UTF-8 | 949 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | import pytest
from . import Extract
def test_missing_source_type():
extract = Extract()
with pytest.raises(AssertionError) as excinfo:
extract.do({})
assert "source must have a type" in str(excinfo.value)
def test_unknown_source_type():
extract = Extract()
with pytest.raises(ValueError)... | true |
781435c49f64f8d620244c25092bc99ae80f9a92 | Python | vijaykrishnav/Logistic-regression-along-with-Area-under-RUC | /Logistic regression (Area under ROC curve) with missing value imputation.py | UTF-8 | 9,520 | 3 | 3 | [] | no_license |
# coding: utf-8
# In[1]:
#getting libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as mlt
get_ipython().magic(u'matplotlib inline')
# In[2]:
#getting file
crd1=pd.read_csv('D:\\V data analytics\\sample dataset\\Dataset by Imarticus\\Data for logistic regression\\R_Module_Day_7.2_Cred... | true |
c6e38795027a96ba120768a17fda7f2d204686e4 | Python | joshbenner/mudsling | /src/mudsling/utils/migrate.py | UTF-8 | 1,419 | 3.390625 | 3 | [] | no_license | """
Migration utilities.
"""
module_name_map = {}
class_name_map = {}
class_move_map = {}
def forward_class(new_class):
"""
Creates a dynamic class whose sole function is to forward to another class.
This is useful when renaming or changing the location of a class.
If we are renaming class 'foo.Bar'... | true |
9baa9330fb6849d65e53b1d9ac94aa3b4ed51f64 | Python | ricobafica/pdsnd_github | /bikeshare.py | UTF-8 | 9,576 | 4 | 4 | [] | no_license | """
This python code provide the following information by exploring
US Bikeshare Data from Chicago, New York City and Washington:
1- Popular times of travel (i.e., occurs most often in the start time)
most common month
most common day of week
most common hour of day
2- Popular stations a... | true |
2811461faf0aea04d77b4dfa8d7a472de5d6dd48 | Python | tadams42/seveno_pyutil | /src/seveno_pyutil/logging_utilities/pretty_formatter.py | UTF-8 | 2,971 | 2.9375 | 3 | [
"MIT"
] | permissive | import logging
import colorlog
from pretty_traceback.formatting import exc_to_traceback_str
class PrettyFormatter(colorlog.ColoredFormatter):
"""
Logging formatter for pretty logs:
- can optionally colorize output
- can optionally force output to be single line
- reformats logged tracebacks
... | true |
219d41b853734b74eb3231dc254b4cdb089efab3 | Python | kristapsdzelzkalejs/eksamens | /rinka_laukums.py | UTF-8 | 132 | 3.015625 | 3 | [] | no_license | pi = 3.14
radius = int(input('Ievadi rinka radiusu :'))
laukums = pi * radius * radius
print("Apla laukums ir: {}".format(laukums))
| true |
4ddbee3e31608485b89027863d1489bc0080d6bc | Python | analysiscenter/batchflow | /batchflow/tests/config_basic_test.py | UTF-8 | 11,511 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | """
Each function tests specific Config class method.
"""
import sys
import pytest
sys.path.append('../..')
from batchflow import Config
def test_dict_init():
"""
Tests Config.__init__() using input of dictionary type.
For inner structure check Config.flatten() is used.
"""
#Slashed-structured ... | true |
d94afc4b0bdda61a009b73bb7d080b4703dcdd0c | Python | strengthen/LeetCode | /Python3/377.py | UTF-8 | 1,973 | 3.515625 | 4 | [
"MIT"
] | permissive | __________________________________________________________________________________________________
sample 32 ms submission
class Solution:
def combinationSum4(self, nums: List[int], target: int) -> int:
dp = [0] * (target + 1)
dp[0] = 1
for t in range(1, target+1):
for v in nums:... | true |
939bd11e2395e43faa4950124fcb846fe2d5abfc | Python | chengaddone/fblog | /blog/models.py | UTF-8 | 8,388 | 2.578125 | 3 | [] | no_license | # 项目的模型类
import hashlib
from .extensions import db
from datetime import datetime
from werkzeug.security import generate_password_hash, check_password_hash
class BaseModel(object):
"""模型基类,为每个模型补充创建时间与更新时间"""
create_time = db.Column(db.DateTime, default=datetime.now) # 记录创建时间
update_time = db.Column(db.D... | true |
c523a59c5f7ac6b3220eae94d30d9706dcbe5c91 | Python | LSaldyt/l33t | /microsoft/search.py | UTF-8 | 2,348 | 3.234375 | 3 | [] | no_license | # Lucas Saldyt 2019
import sys
import time
def main(args):
problem = ['abcd', '1234', 'efgd', '567c']
queries = ['ab2', 'efg', '1234dc']
problem = ['aaaaa'] * 5
queries = ['a' * 7]
print('Problem:')
for row in problem:
print(row)
for query in queries:
begin = time.time()
... | true |
35d0af616796efaf1f0046bc2ee97ddb61d04942 | Python | ArshanKhanifar/eopi_solutions | /src/arshan/problem_5_p_6_var1_arshan.py | UTF-8 | 721 | 2.96875 | 3 | [] | no_license | from protocol.problem_5_p_6_var1 import Problem5P6Var1
class Problem5P6Var1Arshan(Problem5P6Var1):
def find_longest_equal_sublist(self, int_list):
return self.max_so_far_with_lookup(int_list)
return self.brute_force_with_lookup(int_list)
def max_so_far_with_lookup(self, int_list):
m =... | true |
6873e748cc476e4ff037e318d3ee33b25098e7f9 | Python | ryandancy/project-euler | /problem67.py | UTF-8 | 1,884 | 3.921875 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Project Euler Problem 67:
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top
to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom in data/p0... | true |
f4f7e3afd8ff978199ff07a0121b788145a6fbc7 | Python | nhartland/GPPDF | /gppdf.py | UTF-8 | 5,020 | 3.171875 | 3 | [] | no_license | #! /usr/bin/env python3
"""
Gaussian Process Parton Distribution Functions (GPPDFs)
This script takes a prior (replica) PDF Set from LHAPDF and uses it to
define a Gaussian Process (GP). Rather than assuming a covariance function,
the covariance function of the prior PDF set is measured and used.
C... | true |
4d1ce270a1414c4017c6a7a0f6760e54004053a0 | Python | heyitsdsp/SONAR | /plotter.py | UTF-8 | 394 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 2 12:39:29 2020
@author: dsp
"""
import turtle
import serial
ser = serial.Serial('/dev/ttyACM0", 9600')
window = turtle.Screen()
window.bgcolor('black')
t = turtle.Turtle()
t.color('cyan')
t.pensize(3)
while(serial.available() > 0):
values ... | true |
fa7f7830eec3f0c6ea1d8aa88b558a7359011210 | Python | xzguy/LeetCode | /Problem 1001 - 1100/P1019.py | UTF-8 | 1,112 | 3.59375 | 4 | [] | no_license | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def nextLargerNodes(self, head: ListNode) -> [int]:
nums = []
while head:
nums.append(head.val)
head = head.next
... | true |
205d59a74a7f0782368c0f8fd793d80e52981638 | Python | yulyzulu/holbertonschool-machine_learning | /math/0x00-linear_algebra/100-slice_like_a_ninja.py | UTF-8 | 176 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python3
"""Module to execute functions"""
def np_slice(matrix, axes={}):
"""Function that slices a matrix along a specific axes"""
return matrix[axes]
| true |
19a3a22edccc9214638df158b6f51b3dde31246c | Python | ranjana980/Python | /function files/multiple.py | UTF-8 | 156 | 3.28125 | 3 | [] | no_license | def multiply(list):
i=0
multiple=1
while i<len(list):
multiple=multiple*list[i]
i=i+1
print(multiple)
multiply([8,2,3,-1,7]) | true |
1c6a771e4ec402adbe69ef06f897c5fb9633b509 | Python | PsychoinformaticsLab/pliers | /pliers/tests/extractors/test_misc_extractors.py | UTF-8 | 3,597 | 2.6875 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | from pliers.extractors import (MetricExtractor,
VADERSentimentExtractor,
merge_results)
from pliers.stimuli import SeriesStim, TextStim
from pliers.tests.utils import get_test_data_path
import numpy as np
import scipy
from pathlib import Path
import pytest
... | true |
6c55649ed526c1c4b41563c17f2e53c7f03c8908 | Python | ZhangSteven/trustee | /test/test_TSCF_upload.py | UTF-8 | 4,287 | 2.71875 | 3 | [] | no_license | """
Test the read_holding() method from open_holding.py
"""
import unittest2
from xlrd import open_workbook
from trustee.utility import get_current_directory
from small_program.read_file import read_file
from trustee.TSCF_upload import read_line_jones, update_position, \
get_days_matur... | true |
2c1363c165c79fac5b1372501d4f7bc9f108b42d | Python | ZX1209/gl-algorithm-practise | /leetcode-gl-python/leetcode-移动零.py | UTF-8 | 1,311 | 4.125 | 4 | [] | no_license | # leetcode-移动零.py
# 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。
# 示例:
# 输入: [0,1,0,3,12]
# 输出: [1,3,12,0,0]
# 说明:
# 必须在原数组上操作,不能拷贝额外的数组。
# 尽量减少操作次数。
"""
思路:
嗯,,原数组上操作..
减少移动次数
一般是不会用删除什么的吧..
虽说挺方便的
先用下吧..
果然高效的是直接移动啊
或者说交换下..可以
"""
class Solution(object):
def moveZeroes(self, nums):
"""
... | true |
f448bd3da735b9a1926e796dc7d825106f484051 | Python | rkomar4815/twitter_analytics | /FollowerAnalysis/fcompare.py | UTF-8 | 1,679 | 2.671875 | 3 | [] | no_license | import pandas as pd
# This section compares followers to following users
A = pd.read_csv('3_28_19 NatSecAction Following.csv', index_col=0)
print(A)
B = pd.read_csv('3_28_19 NatSecAction Followers.csv', index_col=0)
print(B)
C = pd.merge(
left=A, right=B,
how='outer', left_index=True,
right_index=True,... | true |
b96b696a609c434b12e96404940ed4ff068de0c9 | Python | quentinxxz/music-crawler | /PlayListDownloader.py | UTF-8 | 2,021 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python
#coding=utf-8
import urllib
import urllib2
import sys
from StringIO import *
import gzip
class PlayListDownloader(object):
"""This class is a http downloader to dowload
music playlist as json text"""
'''
@param timeout
@param cookie :please use the cookie when you are in... | true |
8b14d3bf16771dc7a6856a23c9e3f37cc613ada6 | Python | caitaozhan/LeetCode | /backtracking/216.combination-sum-iii.py | UTF-8 | 3,033 | 3.65625 | 4 | [] | no_license | #
# @lc app=leetcode id=216 lang=python3
#
# [216] Combination Sum III
#
# https://leetcode.com/problems/combination-sum-iii/description/
#
# algorithms
# Medium (55.78%)
# Likes: 1244
# Dislikes: 54
# Total Accepted: 180.6K
# Total Submissions: 313.9K
# Testcase Example: '3\n7'
#
#
# Find all possible combinat... | true |
40a30fa300495e099171c764d10c79c6aa02311e | Python | tomoeyukishiro/code-path | /num_range.py | UTF-8 | 629 | 3.28125 | 3 | [] | no_license | class Solution:
# @param A : list of integers
# @param B : integer
# @param C : integer
# @return an integer
def numRange(self, A, B, C):
n = len(A)
sets = []
for i in range(n):
sum = 0
j = i
while sum < B and j < n:
... | true |
675d8694002a675102e70f8df5dd1fcb7d09fa01 | Python | promila3/HackerRank | /Python/strings/stringValidators.py | UTF-8 | 941 | 3.375 | 3 | [] | no_license | # https://www.hackerrank.com/challenges/string-validators/problem?h_r=next-challenge&h_v=zen
def checkIsAlphanum(s):
for a in s:
if a.isalnum():
print("True")
return
print("False")
return
def checkIsAlpha(s):
for a in s:
if a.isalpha():
print("True")
... | true |
82990967d5f27d5d01b4dc754ff1c60b865531bf | Python | niesmo/sign-language-classification | /src/algorithm/k-means-client.py | UTF-8 | 3,393 | 2.8125 | 3 | [] | no_license | import sqlite3 as lite
import csv
import sys, os, inspect, logging
import math, collections, numpy
from sklearn.cluster import KMeans
from sklearn import datasets
from sklearn.decomposition import PCA
NUMBER_OF_CLUSTERS = 7
CONFIDENCY_PERCENT = 0.0
curr_dir = os.path.dirname(inspect.getfile(inspect.currentframe()))
... | true |
7eb0e9a2949b96d30e1f1b22d8c04c1f3b9619d7 | Python | berrybretch/ficBuster | /space/validator.py | UTF-8 | 728 | 3.15625 | 3 | [] | no_license | from urllib.parse import urlparse
import re
def validate_url(url: str) -> str:
"""
Returns url if valid or raises ValueError
params:
url:str
returns:
url:str
"""
if not url:
return ValueError("url is empty")
else:
parsed = urlparse(url)
regex = re.co... | true |
8c70fe330667dbac22b7599850cbb698458c51ce | Python | Little-girl-1992/little_code | /distance/Cosine.py | UTF-8 | 351 | 3.34375 | 3 | [] | no_license | # -*-coding:utf-8-*-
"""几何中夹角余弦可用来衡量两个向量方向的差异,
机器学习中借用这一概念来衡量样本向量之间的差异"""
from numpy import *
# 两个向量A,B
vector1=[0.2,0.3,0.5]
vector2=[0.1,0.2,0.3]
# 余弦夹角
cosV12= dot(vector1,vector2)/(linalg.norm(vector1)*linalg.norm(vector2))
print cosV12
| true |
cce8af0881f42314b41c0652c74372be9333429e | Python | Lucas-Rufino/Information-Retrieval-System-for-TV-Series | /ranking/vectorial_model.py | UTF-8 | 544 | 2.9375 | 3 | [] | no_license | import numpy as np
import math
class Vectorial_Model(object):
def __init__(self):
self.a = []
def norm (self, document):
size = [x**2 for x in document]
size = math.sqrt(sum(size))
if (size != 0):
normalized = [x/size for x in document]
else: no... | true |
ee4c2041de0632578331a050d36cc91102f77dc7 | Python | andreallorerung/peach-chatbot-alpha | /FlaskWebProject/chatbot/botinterface/rivescript_loader.py | UTF-8 | 787 | 3.265625 | 3 | [] | no_license | '''Auxiliary module to load rivescript brain information and initialize the
interpreter properly'''
import os
import rivescript
def loadBrain(interpreter, brain):
'''To load the brain at filepath'''
interpreter = _loadDirOrFile(interpreter, brain)
interpreter.sort_replies()
return interpreter
def _lo... | true |
db160e9911154f2e86df29274668349fb9e3d68a | Python | bgalgano/ClusNet | /code/old/modules/modules/GaussNet/gauss.py | UTF-8 | 3,256 | 2.625 | 3 | [] | no_license | class Profile:
def __init__(self,std,im_size):
self.mid_pixel = int(im_size/2) # 128/2
self.x, self.y = self.mid_pixel, self.mid_pixel
self.im_size = im_size
self.std = std
self.noise = False
self.lam = 0.1133929878
gkern1d = signal.gaussian(self.im_size, std... | true |
994a6e765a0c04ef4a6b7a1d17485f94f19b21dc | Python | Velu2498/Python-basics | /list tuple dictionaries.py | UTF-8 | 1,118 | 4 | 4 | [] | no_license | #Sample Code for List :
example = ["hii",2,3.2,"hellow","bii"]
print (example[3])
print (example[4])
example[0]="hay"
print (example[0])
#Sample Code for Tuples :
year_born = ("Paris Hilton", 1981)
print (year_born[0])
print (year_born[1])
#year_born[1] = 2011 __>> any modification will throw error
#Sample Code for... | true |
f1dbf3a78f1696ca0baf6182e4a995f509dbd04e | Python | bobfri/battle-snake_solo_length_challenge | /server.py | UTF-8 | 11,040 | 3.03125 | 3 | [
"MIT"
] | permissive | import os
import random
import cherrypy
"""
This is a simple Battlesnake server written in Python and was based on the starter snake from battlesnake official
For instructions see https://github.com/BattlesnakeOfficial/starter-snake-python/README.md
"""
class Board(object):
def __init__(self, maxx, maxy):
s... | true |
4b5a3e60ceb1c41913f213147dff8d00335c80d1 | Python | Xylons/Jorge_Francisco_MachineL | /P2/KmeansDownsampling.py | UTF-8 | 2,407 | 3.109375 | 3 | [] | no_license | import numpy as np
import pandas as pd
def Kmeans(X_pca, k, isPCA=True, normalize=True, bidimensional=False):
"""
Kmeans clustering method
X_pca = dataset with PCA
k = number of clusters
isPCA = if the dataset comes from PCA
normalize = if normalizing is needed
bidi... | true |
3a72b9f13532eb95299ca64e8719f124dc846799 | Python | NurbukeTeker/EmotionRecogFlaskApp | /user.py | UTF-8 | 285 | 2.8125 | 3 | [
"MIT"
] | permissive | class User(object):
def __init__(self,usermail):
self.usermail = usermail
self.isIn = False
def update(self):
self.isIn = True
def userisIn(self):
if self.isIn:
return True
else:
return False | true |
d033a9b09bd84ab8c853b331ee0585b9d6ef2cde | Python | homeworkprod/chatrelater | /tests/test_serialization.py | UTF-8 | 1,510 | 2.96875 | 3 | [
"MIT"
] | permissive | """
:Copyright: 2007-2021 Jochen Kupperschmidt
:License: MIT, see LICENSE for details.
"""
from pathlib import Path
from tempfile import mkstemp
import pytest
from chatrelater.serialization import serialize_data_to_file, load_data
def test_load_save_data(tmp_path):
"""Test saving data and then loading it again... | true |
6ee08ea5415c568a3ad38ad7fcf98191252b0e97 | Python | CyCTW/NCTU-EmbeddedSystem-108-Project | /client/module/IMU.py | UTF-8 | 788 | 2.96875 | 3 | [] | no_license | import smbus
class IMU(object):
def __init__(self):
self.bus = smbus.SMBus(1)
def write_byte(self, adr, value):
self.bus.write_byte_data(self.ADDRESS, adr, value)
def read_byte(self, adr):
return self.bus.read_byte_data(self.ADDRESS, adr)
def read_word(self, adr, rf = 1)... | true |
68fd23dbee7098b259c93593106257518fe15a0d | Python | amarsubedi/pynepal | /pynepal.py | UTF-8 | 2,636 | 3.203125 | 3 | [] | no_license | import json
# Parse all states
with open('pynepal/db/provinces.json', 'r') as json_provinces:
json_provinces = json.load(json_provinces)
# Parse all districts.
with open('pynepal/db/districts.json', 'r') as json_districts:
json_districts = json.load(json_districts)
class AbstractObj(object):
"""
A... | true |
8bdc0702abf6c3489bf8df0e759dc180e1ab4b7a | Python | phumacinha/Grafos-2020-1 | /REO1/ex1.py | UTF-8 | 1,472 | 3.359375 | 3 | [] | no_license | # N é a quantidade de casos que serão testados
N = int(input())
# Lista de listas de adjacência
grafos = []
for n in range(N):
num_vertices_arestas = input().split()
# V é a quantidade de vértices e E de arestas
V, E = int(num_vertices_arestas[0]), int(num_vertices_arestas[1])
# Lista de adjacencia ... | true |
7c46c5314d59be83ab60b0c96f22f9a114896c9b | Python | geckotian96/qbb2019-answers | /day4-afternoon/day4-homework-3.2.py | UTF-8 | 1,826 | 2.875 | 3 | [] | no_license | #!/usr/bin/env python3
"""
usage:./py <t_name> <samples_csv> <FPKMS>
create a timecourse of the given transcrips of females and males
Usage: ./day4-homework.3.2.py <t_name> <samples.csv> <replicates.csv> <c_tab dir>
"""
#./day4-homework-3.2.py FBtr0331261 ~/qbb2019/data/samples.csv ~/qbb2019/data/replicates.csv ... | true |
87f41fd077d132548299a325c335503437eec687 | Python | reazion/learning_python-1 | /loto.py | UTF-8 | 437 | 3.3125 | 3 | [] | no_license | import random
a,c = input("Выберите тип игры. '6 45', '5 36', '4 20': ").split()
def loter():
b=[]
d=[]
e=0
for i in range(1,int(c)+1):
b.append(i)
while len(d)<int(a):
e=random.choice(b)
if e not in d:
d.append(e)
print(d)
if a=="4" and c=="20":
loter()
... | true |
a752a47053de7918f89edddc9f2990dc16b98609 | Python | CrispyCabot/AIProject1 | /EightPuzzleGame_InformedSearch.py | UTF-8 | 11,699 | 3.625 | 4 | [] | no_license | import numpy as np
from EightPuzzleGame_State import State
'''
This class implement the Best-First-Search (BFS) algorithm along with the Heuristic search strategies
In this algorithm, an Open list is used to store the unexplored states and
a Closed list is used to store the visited state. Open list is a priority queu... | true |
71d03859563a368f1cca13ddc33dbc98e19cee82 | Python | emillynge/cryptogram-solver | /sub_solver.py | UTF-8 | 12,009 | 3.359375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python3.4
"""A cryptogram substitution-cipher solver."""
import argparse
import re
import functools
from copy import copy
from collections import (defaultdict, namedtuple, Counter)
from operator import itemgetter
__version__ = '0.0.1'
class NoSolutionException(Exception):
pass
@functools.lru_cache... | true |
03b1931d0f007e8ac353b56f80bbc495eddadffa | Python | wwnis7/256 | /min soo/57problems/34.py | UTF-8 | 326 | 3.984375 | 4 | [] | no_license | A = ['John Smith', 'Jackie jackson', 'Chris Jones', 'Amanda Cullen', 'Jeremy Goodwin']
for j in range(2):
print(f'There are {len(A)} employees: ')
for i in A:
print(i)
if j == 1: break
name = input('Enter an employee name to remove: ')
try:
A.remove(name)
except:
... | true |
e786e690d89cae4ed0a0bc4c6d1b7ca80d95ae73 | Python | tamer-abdulghani/iot-raspberry-aws-face-analysis | /modules/camera.py | UTF-8 | 539 | 2.625 | 3 | [] | no_license | import time
def capture_picture_from_raspberry(file_path):
from picamera import PiCamera
count = 3
for i in range(count):
print(count - i)
time.sleep(1)
with PiCamera() as camera:
camera.vflip = True
camera.hflip = True
camera.capture(file_path)
def capture_pi... | true |
d6d29034039ed5ad62021d2c05f2ed7f8051f630 | Python | jfinnson/django-test | /happy_team/templatetags/utils.py | UTF-8 | 416 | 2.671875 | 3 | [] | no_license | from django import template
register = template.Library()
@register.filter
def get_key_value(some_dict, key):
"""
Provides a filter to be used in Django Jinja2 templates.
Filter allows lookup of values within a dictionary {} via a key.
:param some_dict: Dictionary object
:param key: key value to ... | true |
df4076e66d832cab8a54cb612d6986cde977ae24 | Python | ReshadSadik/python_crawler_imdb | /imdb1.py | UTF-8 | 647 | 2.78125 | 3 | [] | no_license | import scrapy
class imdb(scrapy.Spider):
name = 'imdb_movies'
start_urls = ['https://www.imdb.com/chart/top/?ref_=nv_mv_250']
def parse(self, response):
SET_SELECTOR = 'tr'
for movies in response.css(SET_SELECTOR):
NAME_SELECTOR = '.titleColumn a ::text '
year_sele... | true |
d0247b91889decb176ec1b7ca5805805c0056694 | Python | MajikalExplosions/digitea-source-code | /server.py | UTF-8 | 2,944 | 2.578125 | 3 | [] | no_license | #app.logger.info(u'Inserting message: {}'.format(message))#See https://github.com/heroku-examples/python-websockets-chat/blob/master/chat.py
import os
import logging
import gevent
import random
from flask import Flask, render_template, request
from flask_sockets import Sockets
from datetime import datetime
#The follo... | true |
1789d3badeae2698c4efccff2270c677d7fb5823 | Python | ONSdigital/address-index-data | /DataScience/Analytics/prototype/saoSuffixAddresses.py | UTF-8 | 2,311 | 2.8125 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | #!/usr/bin/env python
"""
ONS Address Index - Secondary Address Object End Suffix Test Data
=================================================================
A simple script to attach UPRNs to a dataset with SAO end suffixes.
As the dataset is synthetic it contains AddressBase UPRNs enabling automatic
performance com... | true |
18f3e2a7704fd7b56c1515e446739afabb0eeb47 | Python | AndreaBorghesi/knowInject_transComputing | /src/extract_dep_graphs_from_json.py | UTF-8 | 11,229 | 2.78125 | 3 | [] | no_license | '''
Parse json file containing info on the structure of the benchmark and extract
the dependency graph
Andrea Borghesi
University of Bologna
2019-05-31
'''
#!/usr/bin/python3.6
import os
import numpy
import sys
import matplotlib.pyplot as plt
import matplotlib as mpl
import json
import networkx as nx
data_di... | true |
c8637ab92e487af64f14346647a25122f88deeab | Python | Lornatang/ml-alg | /Perceptro.py | UTF-8 | 1,656 | 3.265625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
np.random.seed(123)
X, y = make_blobs(n_samples=1000, centers=2)
y = y[:, np.newaxis]
X_train, X_test, y_train, y_test = train_test_split(X, y)
class Perceptron():
de... | true |
c399fba5260cc9f5c447a3093a57d812f9687431 | Python | code-lgtm/Problem-Solving | /python/usaco/chapter1/barn.py | UTF-8 | 1,261 | 3.34375 | 3 | [
"MIT"
] | permissive | """
ID: kumar.g1
LANG: PYTHON2
TASK: barn1
"""
import heapq
fin = open ('barn1.in', 'r')
fout = open ('barn1.out', 'w')
M, S, C = map(int, fin.readline().rstrip("\n").split(" "))
occupied = []
for i in range(C):
occupied.append(int(fin.readline().rstrip("\n")))
def min_stalls(m, s, c):
# No empty covered s... | true |
cfd2c1a58d7f9ac852070ff38a0f16225bc922aa | Python | thinkmpink/police-fatalities-sample | /victim_names/combine_names.py | UTF-8 | 3,404 | 3.140625 | 3 | [
"MIT"
] | permissive | import argparse, datetime as dt, getpass
from calendar import monthrange
"""
FE input: "M/D/YYYY H:M:S Victim Name"
WK input: "YYYY-MM-DD victim name"
combined_names output: (YYYY, M, D, "victim name")
"""
def combine_names(fpath):
names = set()
fe_file = "{}victim_names/fe_names.tsv".format(fpath)
wk_file... | true |
37414714d6e4baa6e609f5b09d06d71dd378ef1b | Python | cognizac/Scrapers | /CaseWestern_scraper.py | UTF-8 | 2,067 | 2.53125 | 3 | [
"MIT"
] | permissive | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: cognizac
#
# Created: 14/02/2014
# Copyright: (c) cognizac 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------
import... | true |
58515ce7d8898a9e4be81167a725a4bc86764c4b | Python | yeliu6/Web-VLE-Builder | /Web_VLE/plotting.py | UTF-8 | 1,755 | 3.015625 | 3 | [] | no_license | import pygal
def plottingIsoBar(xVals, tempListBub, tempListDew, compList, temp_units):
strTitle = "Isobaric VLE Diagram for Mixture:\n{} and {}".format(compList[0], compList[1], fontsize=18,
fontname='Times New Roman')
strY = "Temperature... | true |
7a35fb0ae7ce1891025be54c28e379aca965685d | Python | Harrison-Mitchell/Daily-Sydney-Temperature | /weather.py | UTF-8 | 3,559 | 3.3125 | 3 | [] | no_license | from PIL import Image, ImageDraw
STRIP_HEIGHT = 7 # currently (2017) makes a nice square image
IMAGE_WIDTH = 1095 # currently 365 * 3 i.e 1 day = 3px wide
temps = []
# rawTemps = []
# the constant first temperature in the file
lastTemp = "24.4"
# downloaded from http://www.bom.gov.au/climate/data/
with open("... | true |
d5aad1e44bdab50fb9535fbe785c7424f2f0422e | Python | stavan93/GoT-Death-Predictions | /src/python/Replace_Redirect_Names.py | UTF-8 | 2,410 | 2.75 | 3 | [] | no_license | import cbor
import trec_car.read_data as dat
import spacy
import csv
import os
import time
from collections import Counter
from spacy import displacy
csvfile = str(os.path.dirname(os.path.dirname(os.getcwd()))) + '/data/character-deaths.csv'
names = []
namelist = []
f = open(str(os.path.dirname(os.path.dirname(os.get... | true |
9b3fa5d1ef7bd35543db69b509517b5b8f2195ec | Python | davidohana/python-scolp | /scolp.py | UTF-8 | 7,959 | 3.078125 | 3 | [
"MIT"
] | permissive | import datetime
import numbers
from enum import Enum, auto
from typing import List, Dict
class TitleMode(Enum):
INLINE = auto()
HEADER = auto()
NONE = auto()
class Alignment(Enum):
LEFT = auto()
RIGHT = auto()
CENTER = auto()
AUTO = auto()
class Column:
# noinspection PyTypeChecker... | true |
bbbef810ef55693668ba211a9d467918fe4b8aae | Python | MarvynBailly/MarvynBailly.github.io | /games/hangman/hang_man.py | UTF-8 | 4,303 | 3.921875 | 4 | [] | no_license | """
Hangman Game
Auther: Marvyn Bailly
Version: 0.02
Play Hangman
"""
from os import system, name
import random
def loadWords():
words = []
with open('words.txt','r') as f:
for line in f:
for word in line.split():
words.append(word)
return words
def chooseWord(words):
"""
wor... | true |
2ba3f3172d806bdec196c3c89aa1c5bf6b324f67 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_117/765.py | UTF-8 | 1,585 | 2.671875 | 3 | [] | no_license | __author__ = 'Mariyan Stoyanov'
of = open('B-large.out', 'w')
f = open('B-large.in', 'r')
counter = 0
number_of_test_cases = 0
row = 0
test_cases = []
lawns_list = []
readNM = False
count_n = 0
my_lawn = []
for line in f:
if counter==0:
number_of_test_cases = int(line)
readNM = True
els... | true |
99f97360085c053aef6213bbcbc5f87bfb0c40fd | Python | HanGuo97/OpenaiBaselines | /TRPO/utils/funciton_utils.py | UTF-8 | 5,348 | 3.1875 | 3 | [] | no_license | import copy
import collections
import tensorflow as tf
def switch(condition, then_expression, else_expression):
"""Switches between two operations depending on a scalar value (int or bool).
Note that both `then_expression` and `else_expression`
should be symbolic tensors of the *same shape*.
# Argume... | true |
58e1e8448aacd2ba0805372ecf8d451724982f77 | Python | alexanu/Python_Trading_Snippets | /Technical_Indicators/relative_volatility_index.py | UTF-8 | 2,444 | 2.765625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
import yfinance as yf
yf.pdr_override()
import datetime as dt
# input
symbol = 'AAPL'
start = dt.date.today() - dt.timedelta(days = 365*2)
end = dt.date.today()
# Read data
df = yf.download(symbol... | true |
b9550b09c37574eaf9f7d145a94f7f7a26c094cf | Python | jiongyzh/data_visualisation | /scatter_squares.py | UTF-8 | 458 | 3.296875 | 3 | [] | no_license | import matplotlib.pyplot as plt
input_values = list(range(1, 11))
squares = [x**2 for x in input_values]
plt.scatter(input_values, squares, s=40, edgecolors='none', c=input_values, cmap=plt.cm.Blues)
plt.title('Square Numbers', fontsize=24)
plt.xlabel('Value', fontsize=14)
plt.ylabel('Square of Value', fontsize=14)
pl... | true |
f83e32211ef98d053b2099aac318fe8a452e5728 | Python | justolearn/python-batch-may | /covered/datatypes/set_dt.py | UTF-8 | 2,129 | 4 | 4 | [] | no_license | # s = {}
# print(type(s))
# s1 = set()
# print(type(s1))
# set1 = {"apple", "banana", "cherry"}
# set2 = {1, 5, 7, 9, 3}
# set3 = {True, False, False}
# set4 = {1, 'Apple', False, 'False', 1, 'apple'}
# # #
# print(set1)
# print(set2)
# print(set3)
# print(set4)
# print(type(set4))
#
#
# t = ('t1', 1, 'Apple', 'Apple'... | true |
89210be7137ba22768cb57013d2429cc0fe35b7d | Python | JoeyZhang111/Autoapi | /Exam/common/read_data.py | UTF-8 | 1,045 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
------------------------
@author: Joey
@file: read_data.py
@time: 2021/7/19 10:20
------------------------
"""
import xlrd,os
from common.base_dir import data_path
from conf.get_conf import ini
class GetData:
def __init__(self,path,sheetname):
self.wb = xl... | true |
d918873ff0a898ca4981da5351e5cd345db22bd6 | Python | vishalkanaujia/stem | /python-code/dutchFlag.py | UTF-8 | 582 | 3.734375 | 4 | [] | no_license | def sortArray(A, index):
pivot = A[index]
smaller, equal, larger = 0, 0, len(A)
while equal < larger:
if A[equal] < pivot:
A[equal], A[smaller] = A[smaller], A[equal]
smaller, equal = smaller + 1, equal + 1
continue
if A[equal] == pivot:
... | true |
258a9e55d2f62dba62ae50f558d4e4d0a68b8f30 | Python | chenxu0602/LeetCode | /2183.count-array-pairs-divisible-by-k.py | UTF-8 | 896 | 3.09375 | 3 | [] | no_license | #
# @lc app=leetcode id=2183 lang=python3
#
# [2183] Count Array Pairs Divisible by K
#
# @lc code=start
from collections import Counter
import math
class Solution:
def countPairs(self, nums: List[int], k: int) -> int:
# It can be shown that if n1 * n2 % k == 0, then gcd(n1, k) * gcd(n2, k) % k == 0.
... | true |