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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
00c947838ccf102767e4876990a0244ceb7f2d46 | Python | thaisribeiro/heimdall | /heimdall_bank_validate/bank_validate.py | UTF-8 | 919 | 2.8125 | 3 | [
"MIT"
] | permissive | import re
from heimdall_bank_validate.base_validate_error import InvalidCodeBank
class BankValidate():
def __init__(self, **kwargs):
self.bank_code = kwargs.get('bank_code')
def start(self):
switcher = {
'001': 'Banco do Brasil',
'237': 'Bradesco',
'341': 'I... | true |
8d4e296c9fa74a71f70ada0b77ddf9997c9a86b4 | Python | NLPProjectGroup34/CSCI-544-GROUP-34 | /WordNet_Similarity/similaritytoscore.py | UTF-8 | 1,553 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import division
import numpy as np
import pandas as pd
from sklearn import datasets, linear_model
from math import ceil
similarity_score = {}
train_data = {}
test_data = {}
check_data = {}
def get_data(file_name):
data = pd.read_csv(file_name)
simscr = {}
for key, similarity, ... | true |
e81413d8d762901b138cac49489069fb31a33513 | Python | dpradhan25/Robotics-Tasks-2021 | /Ravindra-Nag/Python-task/task-1.py | UTF-8 | 3,732 | 4.03125 | 4 | [] | no_license | import random
def generate():
"""generates a random 4-digit number
Returns:
int: random 4-digit number
"""
num = 0
for i in range(4):
num = num*10 + random.randint(1,9);
return num
def convert_to_list(num):
""" Converts str to list conaining each character
Args:
... | true |
8b4bcffe2f26337b6b55da86ad4780859ee88236 | Python | RussellMoore1987/resources | /python/MIS-5400/mod_3/mod_3_hmwk.py | UTF-8 | 3,557 | 4.28125 | 4 | [] | no_license | ######################################################
# MIS 5400
# Module 3 Homework
#
# INSTRUCTIONS
# 1) Write code to to complete exercises below.
# 2) Save the file and submit it using Canvas.
######################################################
'''
MIS 5400 Module 3 Homework
'''
###############
# Exer... | true |
dac84a11afac59adcb1e01fc40df517af573a943 | Python | vstarman/python_codes | /20day/mini_web.py | UTF-8 | 3,609 | 2.640625 | 3 | [] | no_license | import sys, socket, re, multiprocessing
g_static_document_root = "./static"
g_dynamic_document_root = "./dynamic"
class WSGIServer(object):
"""WSGI服务的类"""
def __init__(self, port, app):
self.app = app
self.web_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.web_... | true |
1857206bc95b5baf9cb4d35a3f841ad38de1022d | Python | caohaitao/PythonTest | /pytorch/net.py | UTF-8 | 816 | 3.234375 | 3 | [] | no_license | __author__ = 'ck_ch'
# -*- coding: utf-8 -*-
import torch
import torch.nn.functional as F # 激励函数都在这
class Net(torch.nn.Module): # 继承 torch 的 Module
def __init__(self, n_feature, n_hidden, n_output):
super(Net, self).__init__() # 继承 __init__ 功能
# 定义每层用什么样的形式
self.hidden = t... | true |
7ad9df338a87d057042c116e88daf02b2268d916 | Python | tmu-nlp/100knock2016 | /yui/chapter03/knock22.py | UTF-8 | 329 | 3.234375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# カテゴリ名の抽出
# 記事のカテゴリ名を(行単位ではなく名前で)抽出せよ.
import json
import re
for line in open("wiki_uk_category.txt", "r"):
extract_name = re.search('Category:(?P<name>.*)]]',line)
if extract_name:
print(extract_name.group('name'))
| true |
f5c6cbc93a215c050063e22cb84b553c4263a78d | Python | brianchiang-tw/leetcode | /No_0700_Search in a Binary Search Tree/search_in_a_binary_search_tree_iterative.py | UTF-8 | 1,996 | 4.5 | 4 | [
"MIT"
] | permissive | '''
Description:
Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Return the subtree rooted with that node. If such node doesn't exist, you should return NULL.
For example,
Given the tree:
4
/ \
2 ... | true |
4b257fb9e1b2af17087d822cbaa0f4f90d9f8f7a | Python | Andrey0563/Kolocvium | /№ 24.py | UTF-8 | 555 | 3.59375 | 4 | [] | no_license | '''
№24
Знайти суму елементів масиву цілих чисел, які діляться на 5 і на 8
одночасно. Розмірність масиву - 30. Заповнення масиву здійснити випадковими
числами від 500 до 1000.
Дужак Андрій 122-Г
'''
import random
import numpy as np
a = np.zeros(30, dtype=int)
s = 0
for i in range(len(a)):
a[i] = (random.randint(500... | true |
3389c6d311d8c25736df0caf83665d4d06f8f05b | Python | hanguyen0/MITx-6.00.1x | /hangman3.py | UTF-8 | 794 | 4.09375 | 4 | [
"Giftware"
] | permissive | '''
>>> lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's']
>>> print(getAvailableLetters(lettersGuessed))
abcdfghjlmnoqtuvwxyz
Hint: You might consider using string.ascii_lowercase, which is a string comprised of all lowercase letters:
>>> import string
>>> print(string.ascii_lowercase)
abcdefghijklmnopqrstuvwxyz
'''
imp... | true |
aeea9a3d315ccdf474870f32510702ebc804de5f | Python | harshitandro/Python-Instrumentation | /utils/callbacks/base_callbacks.py | UTF-8 | 2,314 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | import threading
def start_callback(source, handler_callback, *args, **kwargs):
"""Callback which is called before the start of any instrumented method/function.
The args to this callback are the args passed to the instrumented method/function."""
threadID = threading.current_thread().ident
if handler... | true |
ef506526bb69643df462e446ce40925762085b0e | Python | jsong00505/CodingStudy | /coursera/algorithms/part1/week3/mergesort/bottom_up_mergesort.py | UTF-8 | 1,191 | 3.0625 | 3 | [
"MIT"
] | permissive | class BottomUpMergesort:
def sort(self, a):
size = 1
res = []
while size < len(a):
lo = 0
while lo <= len(a):
mid = min(lo + size, len(a))
hi = min(lo + 2 * size, len(a))
left = a[lo:mid]
right = a[mid:hi... | true |
76df1fc3b7e0dfa57bbc89abbfdfaba56bbc8085 | Python | mutater/euclid | /proposition 03.02.py | UTF-8 | 653 | 3.03125 | 3 | [] | no_license | import pygame, sys, math
from pygame.locals import *
from euclidMath import Math
pygame.init()
Math = Math()
screen = pygame.display.set_mode((600, 600))
screen.fill((255, 255, 255))
# If two point be taken on the edge of a circle, a line connecting those points will always be inside the circle
a = (250, 350)
b = ... | true |
1f1d8556eb23c3d30ec6b6566fa31093032a1e38 | Python | Jinmin-Goh/Codeforces | /#635_Div_2/C.py | UTF-8 | 1,023 | 3.109375 | 3 | [] | no_license | # Contest No.: 635
# Problem No.: C
# Solver: JEMINI
# Date: 20200416
import sys
def main():
n, k = map(int, input().split())
graph = {}
for _ in range(n - 1):
a, b = map(int, sys.stdin.readline().split())
if a not in graph:
graph[a] = [b]
else:
... | true |
645b489167c5bb7081abe3eb08ce17650751a9f6 | Python | brainmentorspvtltd/MSIT_CorePython | /web-crawling.py | UTF-8 | 917 | 2.734375 | 3 | [] | no_license | # pip install bs4
# pip install lxml
# import bs4
from bs4 import BeautifulSoup as BS
from urllib.request import urlopen
# import urllib.request as req
URL = "https://www.indeed.co.in/jobs?q=python&l="
response = urlopen(URL)
# print(response)
# htmlSourceCode = bs4.BeautifulSoup(response, "lxml")
htmlSourceCode = BS... | true |
bfbe221dbf6d5ceddba342558a8ff4f11d595f0f | Python | tehamalab/tarakimu | /tests/test_cli.py | UTF-8 | 1,092 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `tarakimu` CLI."""
from click.testing import CliRunner
from tarakimu import cli
def test_command_line_interface():
"""Test the CLI."""
runner = CliRunner()
result = runner.invoke(cli.cli)
assert result.exit_code == 0
assert 'cli' in res... | true |
df034fff35b41d8eeb19befd49d3d49c747ed782 | Python | daydreamer2023/Healing-POEs-ICML | /Code/bayesian_benchmarks_modular/bayesian_benchmarks/tasks/classification.py | UTF-8 | 4,981 | 2.53125 | 3 | [] | no_license | """
A classification task, which can be either binary or multiclass.
Metrics reported are test loglikelihood, classification accuracy. Also the predictions are stored for
analysis of calibration etc.
"""
import sys
sys.path.append('../')
import argparse
import numpy as np
from scipy.stats import multinomial
fro... | true |
7f9307a3ec6dd67aef0561be876f4bea67163063 | Python | RobWillison/RiverLeveML | /MapCoordConversion/MeteoxConversion.py | UTF-8 | 1,892 | 2.96875 | 3 | [] | no_license | from convertbng.util import convert_bng, convert_lonlat
import db_config
import math
def getMapPixelData():
return [[320, 350], 680 / 70, 1100 / 130]
def eastNorthToPixel(easting, northing):
startCoord, xStep, yStep = getMapPixelData()
pixelX = (xStep * easting) + startCoord[0]
pixelY = (yStep * nort... | true |
13d21d38d5c7db2e4154f6cdef6f8fb711d19c99 | Python | cfrancois7/pynom2rdf | /pyio2rdf/isic2rdf.py | UTF-8 | 6,468 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | # python3
"""Transform ISIC classifications into RDF and JSON-LD
Notes:
-----
This package allows to transform ISIC classification (*.txt) into RDF and JSON-LD.
It can transform the ISIC classification into centrally registered identifier
(CRID) and into classes.
The package is compatible with the IEO ontology[1].
[... | true |
3af246a8bacf037c63799f8ef54b66d1b98f5ac3 | Python | Luoyer-ly/Bj_pm2.5_predict | /build_network.py | UTF-8 | 4,087 | 2.796875 | 3 | [] | no_license | import numpy as np
def initialize_coef_deep(layers):
layer_size = len(layers)
parameters = {}
for i in range(1, layer_size):
parameters["W" + str(i)] = np.random.randn(layers[i], layers[i - 1]) * 0.01
parameters["b" + str(i)] = np.zeros((layers[i], 1))
return parameters
def forward_p... | true |
c21d65456ef72f0bd762d6c8230d2c12f20a6008 | Python | y-oksaku/Competitive-Programming | /AtCoder/abc/154e_2.py | UTF-8 | 408 | 2.796875 | 3 | [] | no_license | from functools import lru_cache
N = input()
K = int(input())
@lru_cache(maxsize=None)
def search(d, cnt, isLess):
if d == len(N):
return cnt == K
a = int(N[d])
if isLess:
return search(d + 1, cnt + 1, isLess) * 9 + search(d + 1, cnt, isLess)
ret = 0
for i in range(a + 1):
... | true |
db875462e0e0f488bb9774ae633c369a264a7895 | Python | poojataksande9211/python_data | /python_tutorial/excercise_3/demo.py | UTF-8 | 1,868 | 4.53125 | 5 | [] | no_license | #list chapter summery
#list=list is a data structure that can hold any type of data
#create a list
words=["word1","word2"]
#u can store anything insight list
#----------------------------------------
# mixed=[1,2,3,[4,5,6],"seven",8.0,None] #None is a special value
# #list is a ordered collection of items
# print(mixed... | true |
34fdf72375de1f3098254062039a9133d5ffa3f4 | Python | wsdhrqqc/Machine-learning | /aml_nn.py | UTF-8 | 3,039 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 8 19:31:28 2020
@author: qingn
"""
import tensorflow as tf
import pandas as pd
import numpy as np
import pickle
import timeit
import matplotlib.pyplot as plt
from tensorflow import keras
import os
import time
# from IPython.core.interactiveshell ... | true |
1b27a6c98ff849f9aa98ea945492c06d60fa5ccb | Python | sarvparteek/Data-structures-And-Algorithms | /fastQueue.py | UTF-8 | 2,571 | 3.984375 | 4 | [] | no_license | __author__ = 'sarvps'
'''
Author: Sarv Parteek Singh
Course: CISC 610
Term: Late Summer
Data Structures & Algorithms by Miller
Quiz 1, Problem 4
Brief: Implements a queue such that both enqueue and dequeue have O(1) performance on average.
In this case, it means that most of the ti... | true |
229de51935ad7e61acb817bb509fa458436673dd | Python | jasontwright/coursera | /pythonlearn/week06/sandbox.py | UTF-8 | 643 | 3.078125 | 3 | [] | no_license | fruit = 'banana'
letter = fruit[1]
print letter
n = 3
w = fruit[n - 1]
print w
print len(fruit)
index = 0
while index < len(fruit) :
letter = fruit[index]
print index,letter
index = index + 1
for letter in fruit :
print letter
word = 'banana'
count = 0
for letter in word :
if letter == 'a' :
count = ... | true |
cf807423201df091b6c63486b19ce446b7fd57ad | Python | Brendan-Bu/Awesome-Note | /about_window.py | UTF-8 | 3,677 | 2.59375 | 3 | [] | no_license | from PyQt5.Qt import *
from html_window import HtmlWindow
import os
class About(QWidget):
def __init__(self, parent=None):
super(About, self).__init__(parent)
self.setWindowTitle('About')
self.setObjectName("About")
self.setWindowIcon(QIcon('image/app.png'))
self.resize(40... | true |
b6b782eb51db1d16135f2729f1e91a3e6e42a794 | Python | vladopp/Programming101 | /week2/2/generate_numbers.py | UTF-8 | 263 | 2.8125 | 3 | [] | no_license | from sys import argv
from random import randint
def main():
script, filename, n = argv
f = open(filename, 'w')
n = int(n)
while n:
f.write(str(randint(0, 999)))
f.write(" ")
n -= 1
if __name__ == '__main__':
main()
| true |
cd86d1d003e3c0efabfb2d6175b443c5d297f96d | Python | anju-netty/pylearning | /hands_on_exercise.py | UTF-8 | 1,263 | 4.75 | 5 | [] | no_license | """Intro to Python - Part 1 - Hands-On Exercise."""
import math
import random
# TODO: Write a print statement that displays both the type and value of `pi`
pi = math.pi
print("Type of pi is {} and value of pi is {}".format(type(pi),pi))
# TODO: Write a conditional to print out if `i` is less than or greater than ... | true |
1a1f5f6a577b073164e66375c4543f44aee18c57 | Python | elenaisnanocat/Algorithm | /SWEA/algorithm수업_1/swea_12166_NUMBER OF INVERSION.py | UTF-8 | 675 | 2.875 | 3 | [] | no_license | def merge_sort(s, e):
global A, result
if s == e - 1:
return
mid = (s + e) // 2
l = s
r = mid
merge_sort(s, mid)
merge_sort(mid, e)
merged_arr = []
while l < mid and r < e:
if A[l] > A[r]:
merged_arr.append(A[r])
r += 1
result += ... | true |
51eadb13ff6e6bf3585c4d1a3de1b77959230490 | Python | elpenor23/SotaStats | /utils/database.py | UTF-8 | 1,813 | 2.9375 | 3 | [] | no_license | #!/usr/bin/python3
import mysql.connector
from mysql.connector import errorcode
def connect_to_db():
""" connects to the db """
try:
db = mysql.connector.connect(user='user',
password='*****',
host='localhost',
... | true |
07e462e863a7c18b4b9b40a8d83ae668d01b31c0 | Python | juliafox8/cm-codes | /Lab_2/q1.py | UTF-8 | 832 | 3.375 | 3 | [] | no_license | import tkinter
from tkinter import Canvas
def olympic_rings():
window = tkinter.Tk()
c = Canvas(window, width = 600, height = 400)
#blue
c.create_oval(10, 10, 50, 50, fill= "blue")
c.create_oval(15, 15, 45, 45, fill = "white")
#black
c.create_oval(50, 10, 90, 50, fill = "... | true |
9c10ba82d4e6dafc369a6394b60c66fc584bab53 | Python | ErmantrautJoel/Python | /Funciones de Tkinter.py | UTF-8 | 973 | 3.515625 | 4 | [] | no_license | # Funciones de la libreria GUI Tkinter
# FUNCIONES DEL BOTON
import sys # Funcion sys.exit que cierra el programa
from Tkinter import * # Importa todas la funciones de la libreria
button = Button(None, text='Hello World', command=sys.exit) # arg1:ventana, arg2:texto arg3:funcion
button.pack() # Empaquetado
... | true |
57192b4770035ed1b081672d62a8fc501b760637 | Python | somjeat/pythainlp | /pythainlp/romanization/royin.py | UTF-8 | 21,893 | 2.59375 | 3 | [
"Apache-2.0",
"Swift-exception"
] | permissive | # -*- coding: utf-8 -*-
from __future__ import absolute_import,division,unicode_literals,print_function
'''
โมดูลถอดเสียงไทยเป็นอังกฤษ
พัฒนาต่อจาก new-thai.py
พัฒนาโดย นาย วรรณพงษ์ ภัททิยไพบูลย์
เริ่มพัฒนา 20 มิ.ย. 2560
'''
from pythainlp.tokenize import word_tokenize
from pythainlp.tokenize import tcc
#from pythain... | true |
b6f7b5ad8a2610a2d9794e84cc8e1fe8a60d25ec | Python | madhavchekka/SortingAlgos | /randomquicksort.py | UTF-8 | 1,623 | 4.0625 | 4 | [] | no_license | import random as r
def randomquicksort(a):
# define a helper funtion to partition the list
# Pass the array, start index, end index to the partition
# Set the first element as pivot_elem
def partition(a,start=0,end=len(a)-1):
print(f'newrecursion, start = {start} and end={end}')
if s... | true |
c697463449ec2f84c259cffef637e55564efc0ae | Python | testpushkarchauhan92/bharath_python_core_advanced | /Lesson08Functions/P012KeywordArguments.py | UTF-8 | 263 | 4.0625 | 4 | [] | no_license | def average(a,b):
print('a : ', a)
print('b : ', b)
return (a+b)/2
# Old Way
# print(average(10,90))
# New Way
print(average(a=10,b=90))
# Sequence does not matter if we use keyword a b. This is called 'Keyword Arguments'
print(average(b=10,a=90))
| true |
8f39213348160ab0c475ea808f8d162d90f37c59 | Python | BaronJake/python4biologists | /chapt_6/chapt6.py | UTF-8 | 2,299 | 4.03125 | 4 | [] | no_license | """
various conditional statement practice problems with input coming from .csv file
"""
# function to return AT content
def at_content(seq):
""" function to return AT content"""
seq = seq.upper()
AT_content = seq.count("A") + seq.count("T")
return AT_content / len(seq)
# opens file and stores lines ... | true |
94a794900f35ef10cfff035b3fd0d4206f8f72ce | Python | ccharlesgb/mapt | /backend/app/core/config.py | UTF-8 | 2,331 | 2.796875 | 3 | [] | no_license | import logging
import os
from typing import Any, Dict, List, Type, Union
from pydantic import BaseSettings, validator
_env_prefix = "mapt_"
class Config(BaseSettings):
app_env: str
root_log_level: int = logging.INFO
title: str = "Mapt"
description: str = "Shape file uploader/sharing application"
... | true |
dc62863a9c9f7d3655f1685ab433e19edac3eb05 | Python | souravsaraf2000/Linear-Search | /python37-linear-search/python37-linear-search.py | UTF-8 | 359 | 3.96875 | 4 | [
"MIT"
] | permissive | n=int(input("Enter size of array : "))
arr=[]
flag=0
print('Enter array elements : ')
for i in range(n):
n=arr.append(int(input()))
key=int(input("Enter element to be searched for : "))
for x in arr:
if(x==key):
print('Found at index : ',arr.index(x))
flag=1
break
else:
flag=... | true |
9acd762fc1d5e9de92582a5e56a4a1d8260afdf1 | Python | Noonayah/Projet_Fil_Rouge | /ServerWiki.py | UTF-8 | 397 | 2.8125 | 3 | [] | no_license | # coding: utf-8
import socket
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind(('', 8080))
while True:
socket.listen(5)
client, address = socket.accept()
print ("{} se connecte".format(address))
response = client.recv(255)
if response != "":
print (r... | true |
bae61eaa2c1cc330ab82d74b39e1dcb8b792be09 | Python | ochinchina/my-tools | /kube-tmpl.py | UTF-8 | 6,135 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
import functools
import jinja2
import json
import argparse
import os
import requests
import tempfile
import yaml
class NameItem:
def __init__( self, name ):
self.name = name
self.index = -1
if name.endswith( ']' ):
pos = name.rfind('[' )
if pos != ... | true |
b98b17f03d18bf4d624cd3e9887a93b703e22919 | Python | christopher-burke/programs | /file_searcher/main.py | UTF-8 | 2,024 | 3.453125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
"""File Searcher App."""
import os
import glob
from collections import namedtuple
SearchResult = namedtuple('SearchResult',
'file, line, text')
def main():
"""File Searcher App main function entry."""
folder = get_folder_from_user()
if not folder:
... | true |
af53d5ff30f8b51c8734b4468b36cbb7b11cf713 | Python | Gaurab6003/sbttk | /src/main/python/test_database.py | UTF-8 | 3,295 | 2.671875 | 3 | [] | no_license | import unittest
from decimal import Decimal
from sqlalchemy import exc
from database import engine, Base, Session, Member, RinLagani, SawaAsuli
class TestDatabase(unittest.TestCase):
def setUp(self):
# print('Running setup')
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)... | true |
c79eba5db67a5c98ebe6da22024fa0a29d850b9f | Python | Aasthaengg/IBMdataset | /Python_codes/p03241/s599321379.py | UTF-8 | 338 | 2.765625 | 3 | [] | no_license | from math import sqrt
from bisect import bisect_left
N,M = map(int,input().split())
t = M
#約数全列挙
for i in range(1,int(sqrt(M))+2,1):
if M % i ==0:
count = 0
if M % i == 0:
if N <= i and i <= t:
t = i
if N <= M//i and M//i <= t:
t = M//i
pri... | true |
3fe5737dcea48671a2c28dbab57da0f25e6720d8 | Python | zhinan18/Python3 | /code/base/lesson16/listing_16-6.py | UTF-8 | 368 | 2.796875 | 3 | [] | no_license | # Listing_22-6.py
# Copyright Warren & Csrter Sande, 2013
# Released under MIT license http://www.opensource.org/licenses/mit-license.php
# Version $version ----------------------------
# Using pickle to store a list to a file
import pickle
my_list = ['Fred', 73, 'Hello there']
pickle_file = open('my_p.pkl', 'wb')
... | true |
36a293245802a115ea44d14ede771e1fa3a80155 | Python | konradmaleckipl/python_bootcamp_20180825 | /zjazd4/praca_z_json/p1.py | UTF-8 | 455 | 3.46875 | 3 | [] | no_license | import json
obj1 = ['AAA', 2, 3, ['Konrad', 'Magda']]
print(json.dumps(obj1))
print(type(json.dumps(obj1)))
#zapis do pliku
with open('example.json', 'w', encoding='utf-8') as f:
json.dump(obj1, f)
#otwarcie pliku
with open('example.json', 'r', encoding='utf-8') as f:
data = json.load(f)
print(data)
... | true |
77e0490149f5f140fe4efe5a537a3680cf1fc836 | Python | toowzh/coalition-3 | /coalition3/visualisation/TRTcells.py | UTF-8 | 25,511 | 2.53125 | 3 | [] | no_license | """ [COALITION3] Plotting locations of TRT cells within training dictionary
and histograms of different TRT statistics"""
from __future__ import division
from __future__ import print_function
import os
import datetime
import shapefile
import numpy as np
import pandas as pd
import matplotlib.pylab as pl... | true |
16e426cbd7218d41d68a049791bfe3ce3946ca6c | Python | Aguacaneitor/FreeCodeCamp_Answers_Scientific-Computing-with-Python | /Area_Calculator.py | UTF-8 | 2,218 | 3.953125 | 4 | [] | no_license | class Rectangle:
def __init__(self, width,height):
self.height = height
self.width = width
def set_width(self, width):
self.width = width
def set_height(self, height):
self.height = height
def get_area(self):
return (self.width*self.height)
def get_pe... | true |
8782123b4e6bc660392736a9f94c57f4e4978111 | Python | nikitaj11/Python-Programs | /functions.py | UTF-8 | 387 | 3.984375 | 4 | [] | no_license | def add(a,b):
return a+b
def sub(a,b):
return a-b
import sys
while 1:
print(" 1.Addition \n 2. subtraction ")
choice = int(input("Enter vhoice: "))
a = int(input("Enter 1st no: "))
b = int(input("Enter 2nd no: "))
if choice == 1:
c = add(a,b)
print(c)
elif choice == 2:
... | true |
217476e044b1e563a11df3fdeceeaad86ca1a23d | Python | xuetinga/python- | /程序设计大赛习题/程序设计大赛第五题.py | UTF-8 | 1,024 | 3.84375 | 4 | [] | no_license | # 众所知周,毛学姐是一只学渣,只能代表软件学院的最低水平,有一天,他在研究《高等数论》的时候,发现了一个很神奇的现象,于是毛学姐发明了一个有趣的游戏:两人各说一个数字分别为a和b,如果a能包含b的所有质数因子,那么A就获胜。于是毛学姐找来两个好基友让他们进行人肉debug,但是当数字太大的时候,两个朋友的脑算速度就有点跟不上了。聪明的你已经识破了这个游戏的内容,请你写出这个程序,帮毛学姐debug。如果A获胜输出“Yes”,否则输出“No”。
# Input
# 输入一行,有两个用空格隔开的整数,分别为n和m(1 <= n, m <= 105)。
#
# Output
# 每行输出“Yes”或 “No”。
#
# Sample ... | true |
98f16273686006a29df2664b80b121ec132f7415 | Python | rsakh/qbb2019-answers | /day1-homework/day1-exercise-#4.py | UTF-8 | 510 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env python3
#count number of alignments
import sys
#argument you put right after $. and 1 refers to second argument
if len(sys.argv)>1:
f = open(sys.argv[1])
else:
f = sys.stdin
chromosome = []
for line in f:
# filter lines that begin with @
if line.startswith("@"):
continue
... | true |
541bf3d8d6ebd8de3bbe251ff16506ffdab14701 | Python | jacobfelknor/practice_interview_questions | /2019-12/bank/justify_text.py | UTF-8 | 1,058 | 4.15625 | 4 | [] | no_license | # This problem was asked by Palantir.
# Write an algorithm to justify text. Given a sequence of words
# and an integer line length k, return a list of strings which
# represents each line, fully justified.
# More specifically, you should have as many words as possible
# in each line. There should be at least one spac... | true |
31c149f659a8340cc0bd51f40dfd226f9ec80ed4 | Python | Aasthaengg/IBMdataset | /Python_codes/p02984/s175304233.py | UTF-8 | 225 | 2.8125 | 3 | [] | no_license | N = int(input())
A = list(map(int, input().split()))
R = []
tmp = 0
pm = -1
for i in range(N):
pm *= -1
tmp += A[i] * pm
R.append(tmp)
for i in range(1, N):
tmp = 2 * A[i-1] - R[i-1]
R.append(tmp)
print(*R) | true |
ff1ae4cb5e687cd223b14355a2720d0af7387149 | Python | dwblair/packing | /brown5.py | UTF-8 | 2,523 | 2.84375 | 3 | [] | no_license | from numpy import *
import random
#### general brownian dynamics params #####
L=250 #system size, compatible with size of display in processing
N=20 #number of particles
r=20 #particle radius
t=0 #time
maxt=10000 #max time
stepSize=r/10. #random step size
dt=.1 #timestep
gamma=5. #friction coeff
kbt=2.5 # KbT
MAXFORC... | true |
8a9d4e2286df6557f4f8752696b94a4b32b40f81 | Python | Ishan2K1/Class-XII | /Q3.py | UTF-8 | 565 | 3.828125 | 4 | [] | no_license | n=int(input("Enter number here: "))
factor=[]
for i in range(1,n+1):
if n%i==0:
factor.append(i)
def factors(n):
return factor
print(factors(n))
def isPrimeNo(n):
if len(factor)==2:
print("It is a prime number")
else:
print("It is not a prime number")
isPrimeNo(n)
if len(factor)>... | true |
370e29763b3eace9ef4a0d458f039fcf8a2e567a | Python | swernerx/konstrukteur | /konstrukteur/HtmlParser.py | UTF-8 | 860 | 2.71875 | 3 | [
"MIT"
] | permissive | #
# Konstrukteur - Static Site Generator
# Copyright 2013-2014 Sebastian Fastner
# Copyright 2014 Sebastian Werner
#
__all__ = ["parse"]
from bs4 import BeautifulSoup
def parse(filename):
"""HTML Parser class for Konstrukteur."""
page = {}
parsedContent = BeautifulSoup(open(filename, "rt").read())
... | true |
289f2785c64848326896e88053c75b8b35ff878d | Python | ajayrot/Python7to8am | /FileHandling/Demo8.py | UTF-8 | 161 | 3.171875 | 3 | [] | no_license |
import os.path as pa
fname = input("File Name with ext : ")
bo = pa.exists(fname)
if bo:
print(open(fname).read())
else:
print("File not Available")
| true |
16d47ae39c50ec3da246e7d4bd09dbef4f39f962 | Python | MyloTuT/IntroToPython | /Excercise/Ex3/ex3.12.py | UTF-8 | 360 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python3
counter = 0
t_file = open('../python_data/FF_abbreviated.txt')
for line in t_file:
year = line[0:4]
if year == '1928':
lines = line.split()
ymd = lines[1]
counter += 1
convert_ymd = float(ymd)
double_ymd = convert_ymd * 2
print(counter, c... | true |
ce5ae88f1b0444b5e28b8b9f4d8d8098e6036009 | Python | pietrotortella/py_ml_exercises | /linear regression mv.py | UTF-8 | 1,968 | 2.953125 | 3 | [] | no_license | import numpy as np
import os
import matplotlib.pyplot as plt
def get_data(filename):
data = np.genfromtxt(filename, delimiter=',')
N_attributes = data.shape[1] - 1
X = data[:, :N_attributes]
Y = data[:, N_attributes]
return X, Y
def normalize_data(Z):
mu = np.mean(Z, 0)
sigma = np.std(Z... | true |
c0075a0af39249d59748613123d8dcb02242413f | Python | thabo-div2/python_EOMP | /TestLotto.py | UTF-8 | 277 | 2.546875 | 3 | [] | no_license | import unittest, lotto_page
import random
class TestLotto(unittest.TestCase):
def testLotto(self):
lotto = random.sample((1, 5), 3)
self.assertEqual(5, (lotto), "Generate random numbers")
if __name__ == '__lotto_page__':
unittest.main()
| true |
c12b8459be08df85e0511d2b6940c1d3c9944df3 | Python | appsjit/testament | /LeetCode/soljit/s034_firstLastPosInArray.py | UTF-8 | 662 | 3.40625 | 3 | [] | no_license | class Solution(object):
def searchRange(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
first = -1
last = -1
for i in range(len(nums)):
if nums[i] == target:
first = i
b... | true |
0a6c7d235ff29b46369c8bfe327cccd9e5a5e271 | Python | XAlearnerer/PythonLearning | /GAME_AlienInvasion/game_functions.py | UTF-8 | 3,997 | 2.734375 | 3 | [] | no_license | import sys;
import pygame;
from bullet import Bullet
from alien import Alien
def check_keydown(event, ai_setting, screen, ship, bullets):
if event.key == pygame.K_RIGHT:
# ship.rect.centerx += 1;
ship.moving_right = True;
elif event.key == pygame.K_LEFT:
ship.moving_left = True;
e... | true |
2b725962ed2184c9cb5c37fe4c52f33b213fe25d | Python | ra2003/CustomTkinter | /customtkinter/customtkinter_entry.py | UTF-8 | 4,738 | 2.765625 | 3 | [
"CC0-1.0"
] | permissive | import tkinter
from .customtkinter_frame import CTkFrame
from .appearance_mode_tracker import AppearanceModeTracker
from .customtkinter_color_manager import CTkColorManager
class CTkEntry(tkinter.Frame):
def __init__(self,
master=None,
bg_color=None,
fg_color=CT... | true |
bf0d37ba5d32db0fa62516fd803003dd4e6466a5 | Python | gwillz/epevents | /tests/event.py | UTF-8 | 1,257 | 3.03125 | 3 | [
"CC-BY-4.0"
] | permissive | import unittest, threading
from epevents import Event
class Event_test(unittest.TestCase):
def setUp(self):
self.event = Event()
def tearDown(self):
self.event = None
def test_regular(self):
self.event.add(lambda s, a: a)
self.event.add(lambda s, b: b)
... | true |
557707a17eadc7f8aa1bea685c771cd1da96077d | Python | huizhang-zhang/mytools | /app/wechatmessage2.py | UTF-8 | 2,944 | 2.609375 | 3 | [] | no_license | """
Version: Python3.5
Author: OniOn
Site: http://www.cnblogs.com/TM0831/
Time: 2018/12/27 14:49
微信定时推送消息(非网页版微信登陆的方式)
"""
import json,datetime
import requests,sxtwl,itchat
from wxpy import TEXT
import time
class WechatMessage:
def __init__(self):
self.name = ""
#获得对应的农历
def getYMD(self):
... | true |
4b844bbc6df3d81f65b3cb17604d99d09f19e693 | Python | opportunity356/interview-preparation | /data_structures/array/cycle_shift.py | UTF-8 | 747 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'opportunity356'
def cycle_shift_right(a, n, k):
"""
Function shifts array a on k positions right
:param a: array
:param n: length of array
:param k: the value of shift
:return:
"""
cnt = 0
i = start = 0
curr = a[i]
... | true |
20eeff7fca119b7f1e88a287deb7c47e071f532f | Python | Abdulbasith1211/100-days-of-code-python-edition- | /day_002.py | UTF-8 | 5,533 | 4.40625 | 4 | [] | no_license |
# Python program to illustrate
# while loop
count = 0
while (count < 5):
count = count + 1
print("COYG")
#Python program to illustrate
# combining else with while
count = 0
while (count <= 5):
count = count + 1
print("COYG")
else:
print("COYG AGAIN")
# Python program to illustrate for... | true |
845f0196db724cf24ad4eb09d31a7a7f70b0b2e4 | Python | acdaly/LED-controller | /archive/OStest.py | UTF-8 | 738 | 2.546875 | 3 | [] | no_license | import os
import os
def listFiles(path):
#from notes
if (os.path.isdir(path) == False):
# base case: not a folder, but a file, so return singleton list with its path
return [os.path.abspath('.') + "/" + path]
else:
# recursive case: it's a folder, return list of all paths
f... | true |
6c3d56a24f69c43bcbaf6ed629946fa6fa1aeaaa | Python | sojunhwi/Python | /2920 음계.py | UTF-8 | 186 | 3.453125 | 3 | [] | no_license | # https://www.acmicpc.net/problem/2920
a = input().split()
if a == sorted(a):
print('ascending')
elif a == sorted(a,reverse = True):
print('descending')
else:
print('mixed') | true |
6707f403e78678bfddc73e3ad80a82c934947c2f | Python | 2dvodcast/Data-Science-1 | /TrueCar/diff.py | UTF-8 | 2,200 | 3.1875 | 3 | [] | no_license | '''This script reads in 2 data files and outputs the differences between the two files to a
CSV file.'''
import pandas as pd
def report_diff(x):
return x[0] if x[0] == x[1] else '{} | {}'.format(*x)
def main():
old_df = pd.read_csv('bike_data_20110921.csv')
new_df = pd.read_csv('bike_data_20140821.csv')
... | true |
8af4f5b1068912a9284f90d8d8b4d59a0aaf8b0e | Python | dclegalhackers/regulations-parser | /regparser/notice/diff.py | UTF-8 | 6,796 | 2.53125 | 3 | [] | no_license | #vim: set encoding=utf-8
from itertools import takewhile
import re
from lxml import etree
from regparser.grammar import amdpar, tokens
from regparser.tree import struct
from regparser.tree.xml_parser.reg_text import build_section
def clear_between(xml_node, start_char, end_char):
"""Gets rid of any content (inc... | true |
42963a16ade44800f9d0c694d4dea90a07756598 | Python | TracyCuiCan/ULMFIT-in-Tensorflow | /layers/mixture_of_softmaxes.py | UTF-8 | 1,875 | 2.609375 | 3 | [] | no_license | import tensorflow as tf
class MixtureOfSoftmaxes():
def __init__(self, k, h_size, embeddings):
self.k = k
self.h_size = h_size
self.embed_size = embeddings.shape[1]
self.embeddings = embeddings
self.build()
def build(self):
self.Whk = tf.Variable(tf.ran... | true |
9f6990c98aa26853d168bd92a17e70c23225c162 | Python | FXXDEV/CalculatorRMI-REST | /python/client.py | UTF-8 | 1,028 | 3.5625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
import Pyro.util
import Pyro.core
Pyro.core.initClient()
calc = Pyro.core.getProxyForURI("PYRONAME://simple")
print("Selecione a operação.")
print("1.Adição")
print("2.Subtração")
print("3.Multiplicação")
print("4.Divisão")
print("5.Potenciação")
while True:
choiceList = [1,2,3,4,5]
ch... | true |
b117a1292900a91fdffa931de930570bd851c5d3 | Python | RicardoBalderas/algoritmosaleatorios | /collector/python/collector.py | UTF-8 | 902 | 3.46875 | 3 | [] | no_license | import random
tries = 1000 # Times the algorithm will be ran.
ncoupons = 50 # Number of coupons.
boxeslist = [] # List of opnened boxes per try.
expected = 0.0 # Expected number of boxed to get all coupons.
mean = 0.0 # Mean number of boxes opened in all tries.
for i in range (1, ncoupons + 1):
... | true |
5cb85614f88bf0cb0f81c860925f7c9adee5a8fb | Python | Glaceon31/NMTPhraseDecoding | /thumt/scripts/src2null_prob.py | UTF-8 | 1,858 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# coding=utf-8
# Copyright 2018 The THUMT Authors
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import operator
import os
import json
def parseargs():
msg = "get probability table for source word to null"
us... | true |
f76b76010801a5726eee49f212aabeb0da877e23 | Python | MinistereSupRecherche/bso | /scripts/process_publications.py | UTF-8 | 3,135 | 2.5625 | 3 | [
"MIT"
] | permissive | import requests
import math
import datetime
from joblib import Parallel, delayed
APP_URL = "http://0.0.0.0:5000/publications"
APP_URL_DATA = "http://0.0.0.0:5000/publications"
YEAR_START = 2013
YEAR_END = 2013
header = {'Authorization': 'Basic YWRtaW46ZGF0YUVTUjIwMTk='}
NB_JOBS = 10 # nb jobs in parrallel
def updat... | true |
a39a5dca097ecfee0f9ea8426d9a3ede94d95fc1 | Python | xiphodon/ML_demo | /ML_demo_03.py | UTF-8 | 5,342 | 3.375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/2/15 19:04
# @Author : GuoChang
# @Site : https://github.com/xiphodon
# @File : ML_demo_03.py
# @Software: PyCharm Community Edition
# 梯度下降
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import Li... | true |
50916c279cf170b471609bfc23efb70022917812 | Python | gjkood/analyze_this | /gen_test_data.py | UTF-8 | 877 | 3.109375 | 3 | [] | no_license | import string
import random
import argparse
MAX_COL_SIZE=65535
col_data = ''
def gen_column_data(col_size):
if col_size > MAX_COL_SIZE:
col_size = MAX_COL_SIZE
return string.zfill('0', col_size)
def gen_line(num_cols, col_size, delimiter):
global col_data
if len(col_data) == 0: #Avoid calli... | true |
629120037844197c2f4749e324cc135036d18eee | Python | manoj2509/Python-Practice | /CLRS/2.1-4 Array Int Sum.py | UTF-8 | 384 | 3.59375 | 4 | [] | no_license | __author__ = 'Mj'
#Sum of 2 n-digit numbers. Numbers are stored in list
a = input().strip()
b = input().strip()
c = list()
n = len(a)
carry = 0
for i in range(n-1, -1, -1):
temp = int(a[i]) + int(b[i]) + carry
if(temp > 10 ):
carry = 1
c.insert(0, temp - 10)
else:
carry = 0
c... | true |
c329deb202536ea1b23d010fc21c75bc132c2944 | Python | bufan77/InterviewQuestion | /1.py | UTF-8 | 990 | 3.40625 | 3 | [] | no_license | # i = 1
# while i < 6:
# j = 0
# while j < i:
# print('*', end='')
# j += 1
# print('')
# i += 1
# i = 1
# while i <=9:
# j = 1
# while j <= i:
# print('%d * %d = %d'%(i, j, i*j), end='\t')
# j += 1
# i += 1
# print('')
# dict = {'name':'xiaomin','age':... | true |
517dce0cbeedd6cb5c1cfdd41856955a72ee977a | Python | life-efficient/The-Month-of-ML | /day_10-pre-trained_networks.py | UTF-8 | 3,335 | 2.875 | 3 | [] | no_license | import torch
import pandas as pd
import torchvision.models as models
from PIL import Image
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms
import matplotlib.pyplot as plt
import numpy as np
id_to_classname = {574:'golf ball', 471:'cannon', 455:'bottlecap'}
class ClassificationDatas... | true |
5d0db1b5d7c31d202f8f264df633a9b80849ed1c | Python | zeno17/LessIsMore | /run_measure_loss.py | UTF-8 | 4,419 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 30 14:53:43 2021
"""
import argparse
import os
import pickle
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from transformers import AutoModelForMaskedLM
from transformers import BertTokenizer
from transformers import DataCollatorForWholeWord... | true |
3a136fd7649bc67fc8d16b4273efc65c9886d1e8 | Python | AkihikoWatanabe/ApproxAP | /libs/updater.py | UTF-8 | 1,974 | 2.796875 | 3 | [] | no_license | # coding=utf-8
"""
A python implementation of ApproxAP.
"""
import numpy as np
import scipy.sparse as sp
from joblib import Parallel, delayed
from tqdm import tqdm
from update_func_approxap import approx_ap
class Updater():
""" This class support ApproxAP updater.
"""
def __init__(self, eta=0.01, alpha... | true |
2092f12fa3c47b9c2bb809ff9a53161d21ffb130 | Python | cat4er/cl-srv-app | /chat/Lesson2/task2.py | UTF-8 | 1,807 | 3.46875 | 3 | [] | no_license | # ### 2. Задание на закрепление знаний по модулю json.
# Есть файл orders в формате JSON с информацией о заказах. Написать скрипт, автоматизирующий его заполнение данными.
# Для этого:
# Создать функцию write_order_to_json(), в которую передается 5 параметров — товар (item), количество (quantity),
# цена (price), покуп... | true |
323a98e466671ee8d7437ce3498daa5b765d6893 | Python | SebastianKuhn/OOPBallers | /Loser_Groups/Group_2/SourceFiles/MainProject/Calculation.py | UTF-8 | 2,279 | 3.578125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import division
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from MainProject.priceCollection import priceCollection
from MainProject.tweetCollection import tweetCollection
class Calculation:
def __init__(self):
self.Te... | true |
17cd27e9b65eb07e70c57d7eb4e792b99c59af64 | Python | luliyucoordinate/Leetcode | /src/0239-Sliding-Window-Maximum/0239.py | UTF-8 | 576 | 3.0625 | 3 | [] | no_license | class Solution:
def maxSlidingWindow(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: List[int]
"""
if not nums:
return list()
res, stack = list(), list()
for i, val in enumerate(nums):
while stack and num... | true |
37aec3222fd48326e27d87cfb35c0df7757fdce6 | Python | sentimentinvestor/sentipy | /tests/sentipy_tests.py | UTF-8 | 5,363 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """Tests various methods of the SentiPy module."""
import os
import unittest
# vcrpy is untyped
# Therefore, ignore all vcr decorators
import vcr # type: ignore[import]
from beartype import beartype
from sentipy._typing_imports import ListType
from sentipy.sentipy import Sentipy
class SentipyTestCase(unittest.Tes... | true |
7cf245f2204839793e0edd98c66afd1c4e0f8743 | Python | bsadoski/entra21 | /aula3/poo.py | UTF-8 | 582 | 4.34375 | 4 | [] | no_license | # Criando uma classe
class Cachorro:
# atributo de classe
especie = "Canis familiaris"
# inicialização da classe
def __init__(self, nome, idade):
# atributos de instancia
self.nome = nome
self.idade = idade
# alterando a descrição
#def __str__(self):
# return... | true |
e2b809fe02db0631f9bfd0e1f42f457592a90c97 | Python | SuperLouV/CS559A | /HW03/HW03P2FLD.py | UTF-8 | 2,221 | 3.25 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project -> File :CS559A -> HW03P2FLD
@IDE :PyCharm
@Author :Yilin Lou
@Date :5/2/20 4:11 下午
@Group :Stevens Institute of technology
'''
import numpy as np
import matplotlib.pyplot as plt
D1 = np.array([[-2, 1],
[-5, -4],
[-3, 1],
... | true |
2be07d537c39a9b1a1e139f2018d18cb04d77949 | Python | rg-github-hub/TaskManager2049 | /test.py | UTF-8 | 32 | 2.84375 | 3 | [] | no_license |
l=[1,2,3,4,5]
l[:10:2]
print(l) | true |
bfdf0b4ac72fe7cb54a0ed40d445e1eff9c6daa2 | Python | shraddhalokhande/PythonProject | /test/Python-SQL-Project-CodeBase-DS-DE/Python-SQL-Project-CodeBase-DS-DE/Python-SQL-Project-CodeBase-DS-DE/Python_SQL_Project_CodeBase-DS-DE.py | UTF-8 | 7,245 | 2.625 | 3 | [] | no_license | import argparse as agp
import getpass
import os
from myTools import MSSQL_DBConnector as mssql
from myTools import DBConnector as dbc
import myTools.ContentObfuscation as ce
try:
import pandas as pd
except:
mi.installModule("pandas")
import pandas as pd
def printSplashScreen():
print("************... | true |
291a7e4622a9d0f7f232faea93d50d1f5fae1bdf | Python | PratishtaRao/Big-_Data_Analysis | /HW_08/HW_08_Rao_Pratishta.py | UTF-8 | 6,977 | 3.390625 | 3 | [] | no_license | """
Title: HW_08_Rao_Pratishta.py
Course: CSCI 720
Date: 03/31/2019
Author: Pratishta Prakash Rao, Srikanth Lakshminarayan
Description: Code to implement the agglomeration clustering
"""
from haversine import haversine
from geopy.geocoders import Nominatim
import pandas
from geopy.extra.rate_limiter import RateLimite... | true |
935cbadee487b30ef52a219ac0f542b71dc7bf9f | Python | liuweiping2020/pyml | /src/modeler/birnnmodel.py | UTF-8 | 2,264 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | from modeler.tfmodel import TFModel
import tensorflow as tf
class BiRNNModel(TFModel):
def __init__(self):
self.learning_rate = 0.01
self.batch_size = 128
self.display_step = 10
self.n_input = 28 # MNIST data input (img shape: 28*28)
self.n_steps = 28 # timesteps
... | true |
b68493d09c05690a30127f0126d168e1928ba893 | Python | icebale-coder/pyneng | /exercises/06_control_structures/task_6_2.py | UTF-8 | 1,506 | 3.6875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Задание 6.2
Запросить у пользователя ввод IP-адреса в формате 10.0.1.1
В зависимости от типа адреса (описаны ниже), вывести на стандартный поток вывода:
'unicast' - если первый байт в диапазоне 1-223
'multicast' - если первый байт в диапазоне 224-239
'local broadcast' - если IP-адр... | true |
03c417b1ac4373aefb9d93e33145f5d375c16800 | Python | alifahriander/ethz-clustering | /findAssignments.py | UTF-8 | 1,443 | 2.59375 | 3 | [] | no_license | import os
import argparse
import scipy.stats as stats
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from collections import Counter
from matplotlib.pyplot import rcParams
parser = argparse.ArgumentParser()
parser.add_argument("--path", type=str)
args = parser.parse_args()... | true |
67b05986df7fd5fff69dc6988ab3e4154b210ea2 | Python | minrivertea/kungfupeople | /newsletter/multipart_email.py | UTF-8 | 1,468 | 2.65625 | 3 | [] | no_license | ## Taken from http://www.rossp.org/blog/2007/oct/25/easy-multi-part-e-mails-django/
## but butchered a bit
from django.core.mail import EmailMultiAlternatives
from django.conf import settings
def send_multipart_mail(text_part, html_part, subject, recipients,
sender=None, fail_silently=False,... | true |
8092e03fdf68949cd7b45be7de50647a67d91eb6 | Python | AMALj248/Wine_Quality | /Wine_qlty.py | UTF-8 | 2,432 | 3.609375 | 4 | [] | no_license | #IMPORTING THE REQUIRED LIBRARIES
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
import seaborn as sns
wine = pd.read_csv('winequality-red.csv')
#seeing a few values of the csv files
wine.head()
wine.info()
print(wine.isnull())
#since we find there is no ... | true |
ce44097b0789984a65b44b9b8eff2241b567f325 | Python | lisisis/stars | /eg | UTF-8 | 1,507 | 2.984375 | 3 | [] | no_license | import struct
import time
def ReadFloat(*args):
for n, m in args:
n, m = '%04x' % n, '%04x' % m
v = n + m
y_bytes = v.decode('hex')
y = struct.unpack('!f', y_bytes)[0]
y = round(y, 6)
return y
def WriteFloat(value):
y_bytes = struct.pack('!f', value)
y_hex = y_bytes.encode('h... | true |
3805a5fd64d88298bc446af23c1950b2b4229bb6 | Python | Corkster919/GabScraper | /scrape_posts.py | UTF-8 | 4,526 | 2.703125 | 3 | [] | no_license | """ Scrapes Gab.ai posts. """
# pylint: disable=unsubscriptable-object
import argparse
import json
import os
import random
import sys
import time
import traceback
import mechanize
def shuffle_posts(min_num, max_num):
""" Generates a scraping order. """
post_numbers = range(min_num, max_num)
random.shuffle(post_nu... | true |
d3c8559fe38e82755f03c6d5e9a157a31777ba88 | Python | sanapagarkar/Advertisement-Optimizer | /ts.py | UTF-8 | 854 | 3.0625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset= pd.read_csv('Ads_CTR_Optimisation.csv')
#Implementing Thompson Sampling
import random
d=10
N=10000
ads_selected=[]
noOfRewards1 = [0]*d
noOfRewards0 = [0]*d
totalReward=0
for n in range(0,N):
max_random = 0
ad = 0
for i in ran... | true |
b2bbd64925e9a727fac50f7f7da5f8f9d71d7a9c | Python | datairahub/dscompass-back | /src/protection_defenders/defenders_auth/middlewares.py | UTF-8 | 597 | 2.578125 | 3 | [] | no_license | from django.conf import settings
class CookieJWTMiddleware:
"""
CookieJWTMiddleware
If a refresh token cookie is present on the request,
add the token to request.refresh to handle it later
"""
def __init__(self, get_response):
self.cookie_name = settings.SIMPLE_JWT['COOKIE_REFRESH_KEY... | true |