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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b576d5876e519b3a3a6d02f022e7e7865c272f49 | Python | geeveekee/100_days_of_Code | /d37/d37.py | UTF-8 | 587 | 2.9375 | 3 | [] | no_license | from flask import Flask, render_template
from datetime import date
import requests
app = Flask(__name__)
@app.route('/')
def home_page():
todays_date = date.today()
name = "GeeKee"
return render_template("index.html", date=todays_date, name=name)
@app.route('/guess/<name>')
def guess_gender_age(name):
... | true |
903143506be8747ab0f77bdf7e650eb28b85cfe5 | Python | PlumpMath/DesignPatterns-440 | /comportamentais/observer/observador/observadores/porcentoObserver.py | UTF-8 | 550 | 2.90625 | 3 | [] | no_license | from observador.dadosObserver import DadosObserver
class PorcentoObserver(DadosObserver):
def __init__(self, dados):
super().__init__(dados)
def atualiza(self):
soma = self.dados.pega_estado().valorA + self.dados.pega_estado().valorB + self.dados.pega_estado().valorC
print("Porcentage... | true |
e64997039ca53bbf05208e1f3ed3a3a25dc9e61e | Python | aasseman/mi-prometheus | /models/simple_cnn/simple_cnn.py | UTF-8 | 8,097 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) IBM Corporation 2018
#
# 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
#
# U... | true |
40812a5284e6b2e0e0e570f0efaca8e83a47e832 | Python | mlivingston40/Twilio-Attribution-Webhook | /lambda_function.py | UTF-8 | 2,170 | 2.703125 | 3 | [] | no_license | from googleSheet import GoogleSheet
import datetime
import os
## Can set these up as encrypted variables in AWS lambda console and grab using os ##
#TWILIO_SMS_URL = "https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json"
TWILIO_ACCOUNT_SID = os.environ.get("TWILIO_ACCOUNT_SID")
TWILIO_AUTH_TOKEN = os.environ.ge... | true |
00a430d8138fcc60462234e2d15191639ffaa934 | Python | ustimenv/ProductAnalysis | /track.py | UTF-8 | 5,084 | 2.734375 | 3 | [] | no_license | from collections import OrderedDict
import numpy as np
from scipy.spatial.distance import cdist
from utils.imgUtils import ImgUtils
# we track based only on the y-ordinate: the conveyor is moving vertically so x-displacement is meaningless
# with PostCool, y decreases,
# with raw - increases
class Tracker:
d... | true |
da093bea6a7e26c76e37a380d16d12343e05088c | Python | Bhavyashu/WellcomeML | /tests/test_sent2vec.py | UTF-8 | 645 | 2.53125 | 3 | [
"MIT"
] | permissive | import pytest
from wellcomeml.ml.sent2vec_vectorizer import Sent2VecVectorizer
@pytest.mark.skip(reason="Consumes too much memory")
def test_fit_transform():
X = [
"Malaria is a disease that kills people",
"Heart problems comes first in the global burden of disease",
"Wellcome also funds ... | true |
780a258e6a4ba05e902747789d1152c948052dbb | Python | jbjw/QJM_Wargame | /scripts/db_formation.py | UTF-8 | 2,129 | 3.34375 | 3 | [] | no_license | from collections import Counter
# future work I want to do here is to combine the formation_group and
# formation objects such that any formation can have sub-formations
# generic formation class
class formation():
def __init__(self, name, equipment, personnel):
self.name = name
self.equipment = e... | true |
b3d610724ae5c9289de92db12c87192b198f12c1 | Python | bopopescu/meerkat | /docs/device_template.py | UTF-8 | 3,597 | 3.125 | 3 | [
"MIT"
] | permissive | """Meerkat Device Driver Template
2019 Colin Dietrich
Minimal attributes and methods for a device driver.
tl;dr instance base.DeviceData, add a Writer, self.get and self.write methods
"""
from meerkat import base, tools
from meerkat.data import CSVWriter, JSONWriter
class ExampleDevice:
def __init__(self, bus_n,... | true |
8cebc43293eadd1432d08be67e5436d09257667b | Python | Saifullahshaikh/-IPU-Intensive-Programming-Unit-01 | /2 Python Programming Examples on Mathematical Expressions/31 Compute Value of Euler's Number.py | UTF-8 | 219 | 3.625 | 4 | [] | no_license | def Eulers(n):
e = 1
for i in range(1,n+1):
factorial=1
for j in range(1,i+1):
factorial*=j
e+=(1/factorial)
return e
n= eval(input('Enter a number: '))
print(Eulers(n))
| true |
3edae8433c31286d0df3a1effa88f29edad33ed2 | Python | Aidan-Cao/Python_Projects | /tkinter calc.py | UTF-8 | 4,883 | 3.765625 | 4 | [] | no_license |
from tkinter import * # Button, Tk, Entry, StringVar
# globally variable
expression = ""
# combine key inputs into expression then set to String Variable named equation. ref ln61/62
def press(num):
# re-define the global variable
global expression
# concatenate strings
expression = expres... | true |
e94a9bc61ff5d3315f79fd3a811cca199d1a235f | Python | gabriellaec/desoft-analise-exercicios | /backup/user_291/ch1_2019_03_01_11_01_01_930476.py | UTF-8 | 115 | 2.921875 | 3 | [] | no_license | def calcula_valor_devido(valor_emprestado, meses, juros):
y = valor_emprestado*(1 + juros)**meses
return y
| true |
78c8cce25002ef606115ee8fb4d5bc8110347e2f | Python | JerryHDev/Functional-Programming | /Chapter 4/4_6.py | UTF-8 | 2,007 | 3.25 | 3 | [] | no_license | from graphics import *
def main():
#gets principal input
win = GraphWin('Investment Growth Chart', 320, 240)
text = Text(Point(130,120),"Principal:")
text.draw(win)
input = Entry(Point(220,120),10)
input.setText('0.0');input.draw(win)
rect = Rectangle(Point(130,180), Point(190,220))
rec... | true |
ff500932ddc5cdbea3fbe3fd3a03998b107d9c0f | Python | mithlesh-patel/Disaster-Response-Project | /data/process_data.py | UTF-8 | 3,121 | 3.6875 | 4 | [] | no_license | # Importing required libraries
import sys
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
def load_data(messages_filepath, categories_filepath):
'''Takes 2 csv files as input and retunrs a pandas dataframe after joining data from both the files'''
# Load meesage file into data... | true |
5917c505e4d58b1e637c7a2dde9b1050a299bf00 | Python | Sadaku1993/handson-rl | /algorithm/q_learning/cartpole.py | UTF-8 | 4,388 | 3.234375 | 3 | [] | no_license | #coding:utf-8
"""
CartPole-v0
Observation:
Type: Box(4)
Num Observation Min Max
0 Cart Position -4.8 4.8
1 Cart Velocity -Inf Inf
2 Pole Angle -24ยฐ 24ยฐ
3 Pole Velocity A... | true |
3f1d7f119200d008cc98dbcf82338ccefea8c9a2 | Python | Eerini/NewEgg-Webscrape | /NEFeatured.py | UTF-8 | 2,629 | 2.890625 | 3 | [] | no_license | from bs4 import BeautifulSoup
import requests
import csv
from NEFrontPage import NewEggItems
class FeaturedItems:
def __init__(self):
self.f_page = NewEggItems()
self.choose = None
self.f_page.categorySelect()
def chooseCategory(self):
self.choose = input('Type category name:... | true |
11fc594be7e9e4a3d8a0e21be0627cd74818bd11 | Python | jamiebull1/pywind | /pywind/ofgem/Station.py | UTF-8 | 3,240 | 2.96875 | 3 | [] | no_license | # coding=utf-8
#
# Copyright 2013 david reid <zathrasorama@gmail.com>
#
# 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 by... | true |
b199b662f68e04d4a1e3956dd554e8c8ccfbe51a | Python | liviusceastlivii/Problema | /problema.py | UTF-8 | 559 | 2.78125 | 3 | [] | no_license | with open("Sirul.txt","r") as f:
sir=f.readline()
q=0
r=0
n=0
m=0
for i in sir:
if ord(i) in range(65,91):
q+=1
with open("Majucsule.txt","w") as f:
f.write(str(q))
for i in sir:
if ord(i) in range(97,123):
r+=1
with open("Minuscule.txt","w") as f:
f.write(str(... | true |
c9ec5aeb599fd040f253f12b31ea35d80e73f54b | Python | Kaina-Ribeiro/uri_python | /1146.py | UTF-8 | 144 | 3.796875 | 4 | [] | no_license | while(True):
n = int(input())
if (n == 0): break
for i in range(1, n+1):
if(i == n):
print(i)
else:
print(i, end=' ') | true |
c3ebc9bbaf6bfc14fbb27aa1577ada6e96600cf7 | Python | adam147g/ASD_exercises_solutions | /Colloquiums/2016-2017/Colloquium_2/Exercise_3.py | UTF-8 | 1,327 | 3.890625 | 4 | [
"MIT"
] | permissive | # Dany jest zbiรณr przedziaลรณw otwartych A = [(a[1], b[1]), ..., (a[n], b[n])]. Proszฤ zaproponowaฤ
# algorytm, ktรณry znajduje taki zbiรณr X, X โ [1, ..., n] ลผe:
# (a) |X| = k (gdzie k โ N to dany parametr wejลciowy),
# (b) dla kaลผdych i, j โ X, przedziaลy (a[i], b[i]) oraz (a[j], b[j]) nie nachodzฤ
na siebie... | true |
b068fdd4ce1989681f79106245e2e33e13d9dde1 | Python | SophieHau/War-game-exercise | /game.py | UTF-8 | 1,696 | 4.21875 | 4 | [] | no_license | from cards import *
class Game():
def __init__(self):
self.deck = Deck()
self.user_hand = Hand()
self.computer_hand = Hand()
self.user_points = 0
self.computer_points = 0
def create_hands(self):
self.deck.shuffle()
self.draw = input("The deck has been shuffled, write 'd' to draw your hand: ")
if sel... | true |
6413ca8b1a3bf788e95edf39d5fc1ef7546e75ad | Python | Onebrownsound/CodeEval.com_Challenges | /NthFibNumber.py | UTF-8 | 381 | 2.90625 | 3 | [] | no_license | import sys
def openfile(file):
with open(file,'r') as f:
emptylist=[]
for line in f:
emptylist.append(int(line))
for elem in emptylist:
print(F(elem))
def F(n):
if n == 0: return 0
elif n == 1: return 1
else: return F(n-1)+F(n-2)... | true |
07f618ca4c6f01c796c1ec222d47625ca06e51e2 | Python | Withoutdistrict/Rien | /newTest.py | UTF-8 | 902 | 3.25 | 3 | [] | no_license | # """
# =================
# An animated image
# =================
#
# This example demonstrates how to animate an image.
# """
# import numpy as np
# import matplotlib.pyplot as plt
# import matplotlib.animation as animation
#
# fig = plt.figure()
#
#
# def f(x, y):
# return np.sin(x) + np.cos(y)
#
# x = np.linspac... | true |
7f472355d9d071a31495dfe4eda4b6db99efc0b5 | Python | MAPLE-Robot-Subgoaling/IPT | /data/HW5/hw5_371.py | UTF-8 | 453 | 3.78125 | 4 | [] | no_license | def main():
boxWidth = int(input("Please enter the width of the box: "))
boxHeight = int(input("Please enter the height of the box: "))
boxOut = input("Please enter the symbol for the box outline: ")
boxFill = input("Please enter a symbol for the box fill: ")
w = boxWidth
h = boxHeight
o = b... | true |
492a8e8ca81e1396573b35b7c782bba239c04951 | Python | MingzhouHuCU/hw0 | /hw0.py | UTF-8 | 177 | 2.671875 | 3 | [] | no_license | import csv
liquor = open('iowa-liquor-sample.csv')
l = csv.reader(liquor)
count = 0
for rows in l:
if rows[11].lower() == 'single malt scotch':
count += 1
print count
| true |
684603596068a97e4e3b7e77860d744dc0f359f3 | Python | mlflow/mlflow | /examples/sklearn_autolog/linear_regression.py | UTF-8 | 705 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | from pprint import pprint
import numpy as np
from sklearn.linear_model import LinearRegression
from utils import fetch_logged_data
import mlflow
def main():
# enable autologging
mlflow.sklearn.autolog()
# prepare training data
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.arra... | true |
687a421fe828c840b8b7790d53b5afb8c1d6221a | Python | ming404/json2csv | /json2csv | UTF-8 | 1,741 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import json,csv
import argparse
import logging
from flatten_json import flatten
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
# create logger
log... | true |
a6e97b9a537333a1af6b9ec713072ea84d1a947d | Python | 13aksh/leetcode | /python/container_with_most_water.py | UTF-8 | 316 | 3.0625 | 3 | [] | no_license | from typing import List
class Solution:
def maxArea(self, height: List[int]) -> int:
l: int
l, r = 0, len(height) - 1
result = 0
while l < r:
area = (r - l) * (min(height[r], height[l]))
if area > result:
result = area
if height[r] > height[l]:
l += 1
else:
r -= 1
return result
| true |
8235306dd74f454622d78a4ee24d20ad44161cb2 | Python | LucasBalbinoSS/Exercicios-Python | /ExerciciosPython/ex001.py | UTF-8 | 47 | 2.53125 | 3 | [
"MIT"
] | permissive | msg = '\033[1;31mOlรก Mundo\033[1;32m!'
print(msg)
| true |
b5878702b026170cdf764f332f55571077056583 | Python | lishaizhe/knowledge | /P23-StockCode.py | UTF-8 | 5,049 | 2.765625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding:utf-8 -*-
# 1.้ฆๅ
ๆ่ทฏไธบ่ทๅๆๆ่ก็ฅจไปฃ็
# 2.่ทๅๆฏๅชไปฃ่กจๅฏนๅบ็ๆๆไฟกๆฏ
# 3.
import json
import tushare as ts
from pandas import Series,DataFrame
import pandas as pd
debug=1
#ๅฎไนไฟๅญๆไปถ็่ทฏๅพ
stock_item_path="/Users/lishuaizhe/Documents/knowledge/stock_name.json"
#DataFrame่ฝฌๆขไธบๅญๅ
ธๅ
def df_to_dic( code, stockData_df ... | true |
2d60d22109d742b535d52af76843975fa8c3f375 | Python | uceflg/opentera | /teraserver/python/services/BureauActif/tests/api_me.py | UTF-8 | 2,472 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"PostgreSQL",
"LicenseRef-scancode-other-permissive",
"Python-2.0",
"BSD-3-Clause"
] | permissive | from requests import get
class Config:
hostname = 'localhost'
port = 40075
servicename = '/bureau'
# User endpoints
user_login_endpoint = '/api/user/login'
# Device endpoints
device_login_endpoint = '/api/device/login'
# Participant endpoints
participant_login_endpoint = '/api/p... | true |
ed6ed637a1e5d8324e72ccb7af001d978286aa79 | Python | gmareske/py-vidya | /pyvidya/animations/boxdraw.py | UTF-8 | 680 | 3.125 | 3 | [] | no_license | from baseanimation import BaseAnimation
class BoxDraw(BaseAnimation):
name = 'Box Draw'
def __init__(self,x,y,height,width,border,delay):
self.x, self.y, self.height, self.width = x,y,height,width
self.delay = delay
self.horiz = self.make_line(border,width-1)
self.vert = self.make_line(border[::-1],height-... | true |
0b7644369ed38494f088add6b92ce63125bd5936 | Python | IanSudbery/MBB380 | /lecture10/error.py~ | UTF-8 | 791 | 3.84375 | 4 | [] | no_license | #!/usr/bin/env python
import sys, os
def read_col(filename, column_number):
''' A function that reads one column from a file and
returns the contents of that column as a list'''
# first open the file
if os.path.isfile(filename):
fh = open(filename)
else:
print ("%s is not a file.... | true |
6b1857e0213c19bcce01936f4b6b484c8c290cf3 | Python | TheJacksonLaboratory/phenix-service | /post_processing/gr50_metrics.py | UTF-8 | 4,388 | 2.734375 | 3 | [] | no_license | """
This file is a slightly modified version of the `gr_metrics` code available here:
https://github.com/datarail/gr_metrics/blob/master/SRC/python/gr50/__init__.py
from commit e583df61a888cd3e8ba74bdfcf8ea13f817e67a3
"""
import pandas as pd
import numpy as np
import scipy.optimize, scipy.stats
def logistic(x, param... | true |
90c6b4fabe84f2cd3a9671ad9623baf4ae14aaec | Python | sayantansatpati/data-acquisition-storage | /acquire-store-analyze-tweets-s3-mongo/analyze.py | UTF-8 | 7,445 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
__author__ = 'ssatpati'
from util.config import Config
from util.mongo import Mongo
import collections
import itertools
import tweepy
import time
import os
from util import log
from nltk import *
logger = log.get_logger(__name__)
class Analyze(object):
DB_STREAM = "db_streamT"
DB_TWE... | true |
e926e6605161c049f438c406d1dd16bb9f6622da | Python | ChanduArepalli/flask-api-project-template | /app/accounts/models.py | UTF-8 | 680 | 2.5625 | 3 | [] | no_license | from ..extensions import db
from datetime import datetime
from werkzeug.security import generate_password_hash
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String, unique=True, nullable=False)
password_hash = db.Column(db.String, nullable=False)
joined = db.... | true |
984fdc8a593f4cac02c3fa4213d335626e51912e | Python | agzsoftsi/AirBnB_clone | /tests/test_models/test_amenity.py | UTF-8 | 1,402 | 2.6875 | 3 | [] | no_license | #!/usr/bin/python3
"""
Contains the Amenity unittest.
"""
import os
import pep8
import unittest
from datetime import datetime
from models.amenity import Amenity
class test_amenity(unittest.TestCase):
"""Tests amenity class"""
@classmethod
def setUpClass(cls):
'''set up before every test method... | true |
0e616882309f36b55b91cae36d0c848a44059091 | Python | ichimunemasa/MachineLearning | /DecisionTree/treepredict.py | UTF-8 | 7,205 | 2.9375 | 3 | [] | no_license | #-*- coding: utf-8 -*-
my_data=[['slashdot','USA','yes',18,'None'],
['google','France','yes',23,'Premium'],
['digg','USA','yes',24,'Basic'],
['kiwtobes','France','yes',23,'Basic'],
['google','UK','no',21,'Premium'],
['(direct)','New Zealand','no',12,'None'],
['(dir... | true |
e7edf12d92aeaee5c0e0e11b01782d3fa6ed96c0 | Python | MikaelTornwall/dd2424_project | /rbm_dae/RBM.py | UTF-8 | 1,998 | 2.953125 | 3 | [] | no_license | import torch
class RBM():
def __init__(self, visible_dim, hidden_dim, gaussian_hidden_distribution=False):
self.visible_dim = visible_dim
self.hidden_dim = hidden_dim
self.gaussian_hidden_distribution = gaussian_hidden_distribution
# intialize parameters
self.W = torch.rand... | true |
0c24fd995a5a9483e3ceacb64bd53c2ab87cbb28 | Python | asnewton/ObjectOriented_Python | /Classmethod_and_Staticmethod.py | UTF-8 | 1,639 | 3.90625 | 4 | [] | no_license | class Employee:
raise_amt = 1.04
no_of_emp = 0
def __init__(self, firstName, lastName, sex, age, pay):
self.firstName = firstName
self.lastName = lastName
self.sex = sex
self.age = age
self.pay = pay
self.email = firstName + '.' + lastName + '@email.com'
... | true |
296c02285fee603619dceaba90b45798ed05e36b | Python | saibaldasprivate/machine-learning-course | /demos/logistic_regression/logistic_regression_example_1.py | UTF-8 | 4,784 | 3.921875 | 4 | [] | no_license | """
Classification in Spark
The intent of this blog is to demonstrate binary
classification in pySpark. The various steps involved in
developing a classification model in pySpark are as follows:
1) Initialize a Spark session
2) Download and read the the dataset
3) Developing initial understanding about the data
4... | true |
b39c796f7936c5e836ac1b225b3241bcfb7440a1 | Python | KAIST-CS408E/Pathfinder-endpoints | /chalicelib/responses/planner.py | UTF-8 | 1,303 | 2.75 | 3 | [] | no_license | from collections import OrderedDict
class Planner:
def __init__(self, data):
self.ret = OrderedDict()
self.ret["boardData"] = OrderedDict()
self.ret["currentSemester"] = None
for pair in data:
rel = pair[0]["data"]
rel_t = pair[0]["metadata"]["type"].upper(... | true |
4d5046066f9ff77889a5daf3336c51ee16f00467 | Python | junhaobearxiong/PAGS---Probabilistic-Approach-to-Genome-Similarity | /SimpleSketches.py | UTF-8 | 1,218 | 3.34375 | 3 | [] | no_license | from Sketches import Sketches
'''
A simple implementation of Sketches
Store the kmer and the number of time it occurs in a dict
'''
class SimpleSketches(Sketches) :
def __init__(self, size) :
self.kmerMap = {}
super().__init__(size)
def addKmer(self, kmer) :
if (self... | true |
eaa8b9987859478260510db4d937b49dfeb563c4 | Python | yvesjordan06/automata-brains | /Models/Tests/Transition_test.py | UTF-8 | 851 | 3.125 | 3 | [
"MIT"
] | permissive | import unittest
from Models.Transition import Transition, Etat
class AlphabetTestCase(unittest.TestCase):
def setUp(self):
self.a = Etat('a')
self.b = Etat('b')
self.t = Transition(self.a,'',self.b);
def test_verification(self):
self.assertEqual(self.t, Transition(self.a,'โฌ',s... | true |
625df80c86c849e6e7caca1bca78798f7e1c2ac1 | Python | splinterpi/nero | /pi/temp_s/maxminTemp.py | UTF-8 | 281 | 2.75 | 3 | [] | no_license | #! /usr/bin/env python
f = open('/home/reesd/temp_data.log','r')
lines = f.readlines()
temp = []
for line in lines:
temp.append(line.split( )[2])
temp = map(float, temp)
max = max(temp)
min = min(temp)
print 'min: ',
print min,
print ' C'
print 'max: ',
print max,
print ' C'
| true |
4b4e3e21e7f641c60831d660f66de489687aa602 | Python | budidino/multiverse | /customSongNames.py | UTF-8 | 1,912 | 2.546875 | 3 | [] | no_license | import glob # directory listing
import hashlib # sha1
import json
from collections import defaultdict
customSongsDir = 'C:/Program Files (x86)/Steam/steamapps/common/Beat Saber/Beat Saber_Data/CustomLevels/'
songsDict = defaultdict()
folders = [f for f in glob.glob(f"{customSongsDir}*/")]
for folder in folders:... | true |
6b00601dacba87fe5ab01da6745b1209d5852fa5 | Python | LiamDroog/LibsGUI | /StageLauncher.py | UTF-8 | 3,805 | 2.71875 | 3 | [] | no_license | import tkinter as tk
from StageClass import LIBS_2AxisStage
import serial.tools.list_ports
import os
class StageLauncher:
"""
Provides ability to launch and control the 2 axis
stage currently installed in the LIBS setup over
USB. Take care not to send it into the endstops,
eh?
# Author: Liam ... | true |
b78b1ce2e2126b913e753f33ad74eb2a82148acb | Python | matheusldaraujo/cse491-serverz | /cse491-serverz-hw7-imageapp/server_matheus.py | UTF-8 | 3,748 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python
# @john3209 I reviewed this, it looks great
import random
import socket
import StringIO
from urlparse import urlparse
import sys
import quixote
import imageapp
imageapp.setup()
p = imageapp.create_publisher()
wsgi_app = quixote.get_wsgi_app()
def handle_connection(conn,host,port):
receive... | true |
acb46d2c5412c6fbcc547f40a7658b35d3c40b59 | Python | peroon/MachineLearning | /Python/Graph/vis.py | UTF-8 | 257 | 2.84375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
greenhounds = 500
labs = 500
grey_height = 28 + 4 * np.random.randn(greenhounds)
lab_height = 24 + 4 * np.random.randn(labs)
plt.hist([grey_height, lab_height], stacked=True, color=['b', 'r'])
plt.show() | true |
e23289b87121a5ebf0f3cc327ca564317ebcd0d5 | Python | csmetrics/influencemap | /webapp/graph.py | UTF-8 | 2,769 | 2.859375 | 3 | [] | no_license | import os, sys, json
import numpy as np
from operator import itemgetter
class ReferenceFlower:
def __init__(self, data):
self.reference_flower = data
def calculate_node_size(self, original_node, new_sum):
o_sum = original_node["sum"]
o_size = original_node["size"]
new_size = (o... | true |
6934a107ac16ca707abd6e8ff43003fbad9ade5e | Python | KoliosterNikolayIliev/Softuni_education | /Fundamentals2020/Final Exam 04.04.2020/Problem 2. Fancy Barcodes.py | UTF-8 | 451 | 3.21875 | 3 | [] | no_license | import re
n = int(input())
for _ in range(n):
line = input()
pattern = r"^(@\#+\b)([A-Z]{1}([a-zA-Z|0-9]{4,})([A-Z]))(@\#+)"
matches = re.match(pattern, line)
if matches:
text = matches.group(2)
group = ""
for i in text:
if i.isdigit():
group += i
... | true |
cfec9da794a23a03b945a53ca8e0912d1010c1df | Python | codevr7/project_euler | /distinct_prime_factors.py | UTF-8 | 1,928 | 4 | 4 | [] | no_license | # A function for finding first "input" numbers to have "input" distinct primes
def con_dist_prime(con, diff):
n = 3 ; dist_prime = [] # Initial values
while True: # While program running
if is_dist_prime(n, diff): # If value has distinct prime factors
curr = True
dist_prime.appe... | true |
fc55926e763a0b8ca283ca757ee5ce988dba23ec | Python | michaelyhuang23/SqueezeNet | /preprocessing.py | UTF-8 | 1,761 | 2.703125 | 3 | [] | no_license | import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms,datasets
from torch.utils.data import DataLoader, random_split
import cv2
class Graying(object):
def __init__(self):
super(Graying)
def __call__(self, image):
if image.shape[0]==1:
image = i... | true |
d0ae3b389bbf6d5a899c25d5dc3597055fa7fbf5 | Python | UpCoder/ISBI_LiverLesionDetection | /models/research/astronet/light_curve_util/periodic_event.py | UTF-8 | 2,826 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | # Copyright 2018 The TensorFlow Authors.
#
# 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 by applicable law or agreed to ... | true |
aae3f5c817f826d9063f6259fa70434a6fdcecce | Python | pepinu/practise | /CA/Hexagonal Grid.py | UTF-8 | 465 | 3.296875 | 3 | [] | no_license | from math import sqrt as p
def distance(x):
return p(x[0]**2 + x[1]**2)
d = {
'A': [1, 0],
'B': [0.5, p(3)/2],
'C': [-0.5, p(3)/2],
'D': [-1, 0],
'E': [-0.5, -p(3)/2],
'F': [0.5, -p(3)/2]
}
result = []
times = input()
for i in range(times):
pos = [0, 0]
moves = raw_input()
... | true |
f1aa194f5a01a3a19944059c82f71b3381ff2c68 | Python | astrax/Astro-Boy | /scripts/Rayleigh_2D_V3.py | UTF-8 | 1,647 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import division
from numpy import pi, linspace,meshgrid
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import scipy.special as ss
from mpl_toolkits.mplot3d import axes3d
def Rayleigh_2d(lamda=600,r=0.1*1.E-3,d= 5*1.E-3,D = 2):
a= 10 * 1.E-2
k=(2.*pi)/(lamda *... | true |
cde5c77a602a6635da74092d23a691945b902c0b | Python | jhgdike/rate_limiter | /nsq_manager/__init__.py | UTF-8 | 3,202 | 2.53125 | 3 | [
"MIT"
] | permissive | # coding=utf-8
from queue import Queue, Empty, Full
import datetime
import logging
import time
from threading import Thread
from nsq import Reader, Writer
class NsqReaderThread(Thread):
def __init__(self, topic, channel, msg_handler, reader_num=1):
self.topic = topic
self.channel = channel
... | true |
d9766adcd460da3b50e3d4734fea1a04f9bfa0c0 | Python | eternidad33/csp | /Python/็ฌฌ3้ข/ๆจกๆฟ็ๆ็ณป็ป.py | UTF-8 | 1,288 | 3.375 | 3 | [
"AFL-3.0"
] | permissive | #!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: Vigilr
@file: ๆจกๆฟ็ๆ็ณป็ป.py
@date: 2020-09-01
@Editor: PyCharm
@desc:
"""
# ๆจกๆฟ็ๆ็ณป็ป
# reๆญฃๅ่กจ่พพๅผๅน้
import re
def ๆจกๆฟ็ๆ็ณป็ป():
global var_dict
m, n = map(int, input().split())
temple = [] # ๆจกๆฟ
for i in range(m):
temple.append(input())
var_dict =... | true |
eff1d49c27a0d83c6f1c944d9cce32f00b039638 | Python | sjogleka/General_codes | /matrixQueries.py | UTF-8 | 1,989 | 3.21875 | 3 | [] | no_license | import math
def createMatrix(n,m):
Matrix = [[x*y for x in range(1,n+1)] for y in range(1,m+1)]
return Matrix
def matrixquery(n,m,queries):
result=[]
min_row=1
row=[]
min_column=1
col=[]
for query in queries:
if query[0] == 0:
result.append((min_row)*(min_column))
... | true |
e6bdfd84a5909dd0bd2e221eb7bfe4394ec950eb | Python | ColinWan/Stanford-CS330N | /Assignment 1/hw1.py | UTF-8 | 3,590 | 2.765625 | 3 | [] | no_license | import numpy as np
import random
import tensorflow as tf
from load_data import DataGenerator
from tensorflow.python.platform import flags
from tensorflow.keras import layers
FLAGS = flags.FLAGS
flags.DEFINE_integer(
'num_classes', 5, 'number of classes used in classification (e.g. 5-way classification).')
flags.... | true |
89c4cea1346006ba7ace4083f23fd3b88c21451c | Python | damienpuig/Dissertation | /System/Representation/Services/valueservice.py | UTF-8 | 3,172 | 2.6875 | 3 | [] | no_license | from mongoengine import *
from bson.objectid import ObjectId
from Objects.device import Device
from Objects.value import Value
from Objects.result import Result
from Objects.qoc import QoC
from Services.servicebase import ServiceBase
#Value service
#
#Basic implementation of a service executing queries
#to the mongo... | true |
13ef68f2720dc9151301ca0422286030d7a52ceb | Python | stepsei/sql | /insert_using_with.py | UTF-8 | 241 | 2.59375 | 3 | [] | no_license | import sqlite3
with sqlite3.connect("new.db") as connection:
c = connection.cursor()
c.execute("INSERT INTO population VALUES('New Town City',\
'NT', 4500345)")
c.execute("INSERT INTO population VALUES('San Accra',\
'TE', 5679893)")
| true |
c49abb8e6e3b2f34b4cf873c39172b8877099bca | Python | garibaldu/multicauseRBM | /Marcus/rbm.py | UTF-8 | 12,163 | 2.9375 | 3 | [
"MIT"
] | permissive | import math, time
import numpy as np
import matplotlib.pyplot as plt
import numpy.random as rng
from scipy.special import expit as sigmoid
np.set_printoptions(precision=2)
def inverse_sigmoid(prob1):
return np.log(prob1/(1-prob1))
class RBM(object):
"""
An RBM has weights, visible biases, and hidden bias... | true |
c3cc2d86133e4145227a7d983067d06fed531425 | Python | bercik29/pythoncourse | /watermark.py | UTF-8 | 361 | 2.828125 | 3 | [] | no_license | #!/usr/bin/python3
from PIL import Image, ImageDraw, ImageFont
import sys
try:
sid = Image.open("sid.jpg")
except:
print("Unable to load image")
sys.exit(1)
idraw = ImageDraw.Draw(sid)
text = "Sid Vicious"
font = ImageFont.truetype("arial.ttf", size=90)
idraw.text((10, 10), text, ... | true |
a18ea72cce75a785f616a1e871dd2f4eaa9aec40 | Python | arghyabi/app_killer_for_linux | /appKiller.py | UTF-8 | 1,510 | 2.953125 | 3 | [] | no_license | import json
import os
import sys
import re
def check_user():
if os.getuid() != 0:
print("Permission Denied\nRun as Super User")
sys.exit()
def read_conf(conf):
with open(conf, 'r') as conf_file:
data = conf_file.read()
obj = json.loads(data)
return obj
def get_app_name(obj):
return obj["app_name"]
de... | true |
b4daee4ef64a0d6d48ded7a8a97ffb3a4c506fac | Python | joancostacosta/Python | /app/principal.py | UTF-8 | 3,363 | 2.921875 | 3 | [] | no_license | # CALCUL DE DIETES
# importem libreries externes
import numpy as np
import random as rnd
import matplotlib.pyplot as plt
# importem moduls interns
import moduls.restriccions as rst
import moduls.funcactivacio as fac
import moduls.utils as utl
import moduls.funcost as cst
# definim variables i estructures globals
JR ... | true |
dfeb78a8618a60bd0e467e5ef262cb0e6d8624e3 | Python | Michal30026/MIW | /wprowadzenie_do_pythona2/wprowadzenie_do_pythona_2.py | UTF-8 | 2,892 | 3.578125 | 4 | [] | no_license | # Zadanie 1
a_list = [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
b_list = [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
ab_list = []
def zad1 ( a_list , b_list ):
ab_list = [ i dla i , j w wyliczeniu ( a_list ), jeลli i % 2 == 0 ]
ab_list + = [ i dla i , j w wyliczeniu ( b_list ), jeลli ... | true |
88e874b162c55ae25fcfb23a16aa56bc5d60443b | Python | SensorTeam/finder-mk1 | /circle_filter.py | UTF-8 | 960 | 3.5625 | 4 | [] | no_license | import cv2
import math
from config import *
#Input: List of contours
#Output: List of contours filtered so that only sufficiently circular contours remain
def circle_filter(contours):
print("Applying circle filter to contours...")
#Initialise empty list for new contours
contours_new = []
#Loop over each contour in... | true |
b9236a2b0da5b03a0ab44b0b29649a7d216822f3 | Python | alexmitchell/Amoeba | /amoeba.py | UTF-8 | 842 | 2.78125 | 3 | [] | no_license | #! /usr/bin/env python3
import pyglet
import pyglet.gl as pgl
import gui as GUI
window = pyglet.window.Window()
pgl.glClearColor(1,1,1,1)
gui = GUI.Gui(window)
@window.event
def on_draw():
window.clear()
gui.draw()
@window.event
def on_mouse_press(x, y, button, modifiers):
gui.handle_mouse_press(float... | true |
eff51154867a681dbfd559262cdc11f45ad090e9 | Python | adarshsaraf123/hackerrank_solutions | /Bishop War/bish.py | UTF-8 | 2,561 | 3.015625 | 3 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
debug = False
key_ca = lambda x: len(columns_available[x])
if debug:
def print_attacked(level, attacked):
print
for row in attacked:
print level*'\t', row
attacks = [(-1,-1),(-1,1),(1, 1), (1,-1)]
def depth_first_search(posx, posy, attacked,... | true |
b266a3c12873df8b0d7fabcd27224552966d5fae | Python | sk8terboy/WoodStove | /servomotor.py | UTF-8 | 2,381 | 2.875 | 3 | [] | no_license | import time
import pigpio
import subprocess
from subprocess import DEVNULL
from ina219 import INA219
class ServoMotor:
__MIN_ANGLE = 0.0
__MAX_ANGLE = 201.2
__LINEAR_COEF = (__MAX_ANGLE - __MIN_ANGLE) / 100.0
__LINEAR_OFFSET = __MAX_ANGLE - (100.0 * __LINEAR_COEF)
__MIN_PULSE = 550
__MAX_PU... | true |
dc57e2b7a406cd0be8ec3baee176ccd4dc075d00 | Python | juanhunterjn/analisadorDeCodigos | /rotulador.py | UTF-8 | 4,742 | 3.015625 | 3 | [] | no_license | import re
import dicionario
from datetime import datetime
def whriteInLog(log, li_num, lexema):
arquivo = open("log_programa.txt", "a")
arquivo.write(" -> line ")
arquivo.write(str(li_num))
arquivo.write(": ")
arquivo.write(log)
arquivo.write(": Lexema : ")
arquivo.write(lexema)
return a... | true |
56a9f999411234cf193b877845c2e34083b680b5 | Python | abdulwagab/Demopygit | /list.py | UTF-8 | 283 | 4.09375 | 4 | [] | no_license | def pylist(x):
list = [5] # it consists of 5 list
for list in range(4): # using for loop to get the string values
x = input("Enter your names: ").split() #variable assignment to the input
print(x) #print the values
pylist('x') # calling that function | true |
c1f71553e08a009b9427cdc9ceb89fe0c79623a0 | Python | Jouramie/design-3 | /unit_tests/d3_network/test_encoder.py | UTF-8 | 2,153 | 3.015625 | 3 | [] | no_license | from unittest import TestCase
from src.d3_network.command import Command
from src.d3_network.encoder import DictionaryEncoder
from src.d3_network.network_exception import MessageNotReceivedYet
class TestDictionaryEncoder(TestCase):
def test_when_encode_then_return_byte_string(self):
message = {'command'... | true |
d52dede73fbfccd85aaeede97a911e109feadb5b | Python | laippmiles/Code_python3.5 | /Exercise/ex40_ๆจกๅใ็ฑปใๅฏน่ฑก.py | UTF-8 | 834 | 3.890625 | 4 | [] | no_license | class song:
#python2ไธญไธไธ่ก่ฆๅไฝclass song(object)๏ผ๏ผ่ฟๆฏๅ
ณไบtypeๅobject็ๅๅฒ้ฎ้ข
# py3ไปฅๅๅทฒ็ปๆฒกๅฟ
่ฆๅจๅฃฐๆobjectไบ๏ผobjectๆไธบไบๆๆ็ฑป็ๅบ็ฑป๏ผไธ็ฉไน็น๏ผ๏ผ
def __init__(self,lyrics):
self.lyrics = lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print(line)
def end(self):
print('-'*30)
Happy_b... | true |
2aaef765a2954e6e276d57efad9b4e528e30a814 | Python | Aasthaengg/IBMdataset | /Python_codes/p03208/s976331894.py | UTF-8 | 203 | 2.890625 | 3 | [] | no_license | n,k = map(int,input().split())
h = []
for _ in range(n):
tmp = int(input())
h.append(tmp)
h.sort()
ans = []
for i in range(n-k+1):
tmp = h[i+k-1] - h[i]
ans.append(tmp)
print(min(ans)) | true |
02f1a63d88649b3e778905e51a5f4a3f74386b1e | Python | artkpv/code-dojo | /_other/tt/practice/pr.py | UTF-8 | 2,092 | 3.25 | 3 | [] | no_license | #!python3
"""
Author: w1ld [at] inbox [dot] ru
"""
from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
# import unittest
def read_int():
return int(input().strip())
def read_int_array():
return [int(i) for i in input().strip().split(' '... | true |
ec5d360290a66c215c43e179bf3a3f2c5a97d883 | Python | AbhinavBansal/diagnosticapp | /windows/checkver.py | UTF-8 | 950 | 2.671875 | 3 | [] | no_license | import sys
import os
import re
import datetime
# make sure version number embedded in the code is the same as version
# number given as argument. to be used as a verification check in build
# script
APP_VER_RE = 'APP_VER = "([^"]+)"'
ver_file_and_regex = [("Form1.cs", APP_VER_RE)]
def get_regex_in_file... | true |
9174aea54edcd64c775630eccae5c62ecc214a39 | Python | bbleckel/NN-vs-SVD | /svd_project.py | UTF-8 | 6,112 | 2.609375 | 3 | [] | no_license |
# coding: utf-8
# how-to:
# ~$ source ~/tensorflow/bin/activate
# In[22]:
import xlwt
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.optimizers import SGD
from numpy.linalg import matrix_rank
from PIL import Image
import matplotlib.pyplot as plt
import scipy.misc
impor... | true |
93eee8d21a566c6ab39b64eecec495d0ee5feb7c | Python | MusicLang/musiclang | /musiclang/analyze/voice_separation.py | UTF-8 | 8,840 | 3.21875 | 3 | [
"BSD-2-Clause"
] | permissive | import numpy as np
"""
The algorithm is based on this paper :
HMM-Based Voice Separation of MIDI
Performance
Andrew McLeod
University of Edinburgh
Mark Steedman
University of Edinburgh
https://homepages.inf.ed.ac.uk/steedman/papers/music/VoiceSeparation.pdf
Tunable parameters :
- sigp
- gmin
- sigg
- snew
"""
from ... | true |
a7394b696a021603265ab03f7ae0584a2e349f34 | Python | luckydonald/DictObject | /DictObject/autosave/__init__.py | UTF-8 | 6,405 | 3.125 | 3 | [] | no_license | try:
from .. import DictObject
except (ImportError, ValueError):
from DictObject import DictObject, DictObjectList
from luckydonaldUtils.encoding import to_native as n
# end try
import os
import json
import logging
__author__ = 'luckydonald'
logger = logging.getLogger(__name__)
class AutosaveDictObject(... | true |
e6c05512613396abf3aeab42f47761d1fa765c54 | Python | AaronCHH/B_PYTHON | /Python็จๅผ่จญ่จๅพๅ
ฅ้ๅฐ้ฒ้ๆ็จ/SF_PyIntroAdv/ch5/5-2-while-sum.py | UTF-8 | 209 | 3.734375 | 4 | [] | no_license | s = int(input('่ซ่ผธๅ
ฅๅ ็ธฝ้ๅงๅผ๏ผ'))
e = int(input('่ซ่ผธๅ
ฅๅ ็ธฝ็ตๆญขๅผ๏ผ'))
inc = int(input('่ซ่ผธๅ
ฅ้ๅขๆธๅผ๏ผ'))
sum = 0
i = s
while(i < e):
sum = sum + i
i = i + inc
print(sum) | true |
e75d259f8dfd5accf2b59a4b58f821209c904cfc | Python | rakshamarskole/Area-and-Filename | /area.py | UTF-8 | 161 | 4.0625 | 4 | [] | no_license | from math import pi
r=float(input("Enter the radius of the circle: "))
print("The area of the cicle with radius of the circle "+ str(r)+"is: " +str(pi*r**2))
| true |
a4c9a38c36bd103547dc0ac24caddad8a0692312 | Python | mirek186/intakectf-2021-public | /Miscellaneous/AI/solve.py | UTF-8 | 394 | 2.515625 | 3 | [] | no_license | import tensorflow as tf
one_step_model = tf.keras.models.load_model("model")
one_step_reloaded = tf.saved_model.load("one_step")
states = None
next_char = tf.constant(["\n"])
result = [next_char]
for n in range(100):
next_char, states = one_step_reloaded.generate_one_step(next_char, states=states)
result.app... | true |
d2a9b112cb832e81214fa6dc8d8f805257a1d795 | Python | savitaavenkat/BigData_assignments | /A5/temp_range.py | UTF-8 | 2,838 | 2.734375 | 3 | [] | no_license | import sys
from pyspark.sql import SparkSession, functions, types
from pyspark.sql.functions import *
spark = SparkSession.builder.appName('Weather DataFrame+Python').getOrCreate()
assert sys.version_info >= (3, 5) # make sure we have Pythonspark = SparkSession.builder.appName('example code').getOrCreate() 3.5+
assert... | true |
a5f8b401d2a99e965a9d853e9d49a1d1398b4f63 | Python | gxmls/Python_Leetcode | /Offer 05.py | UTF-8 | 460 | 3.421875 | 3 | [] | no_license | '''
่ฏทๅฎ็ฐไธไธชๅฝๆฐ๏ผๆๅญ็ฌฆไธฒ s ไธญ็ๆฏไธช็ฉบๆ ผๆฟๆขๆ"%20"ใ
็คบไพ 1๏ผ
่พๅ
ฅ๏ผs = "We are happy."
่พๅบ๏ผ"We%20are%20happy."
ๆฅๆบ๏ผๅๆฃ๏ผLeetCode๏ผ
้พๆฅ๏ผhttps://leetcode-cn.com/problems/ti-huan-kong-ge-lcof
่ไฝๆๅฝ้ขๆฃ็ฝ็ปๆๆใๅไธ่ฝฌ่ฝฝ่ฏท่็ณปๅฎๆนๆๆ๏ผ้ๅไธ่ฝฌ่ฝฝ่ฏทๆณจๆๅบๅคใ
'''
class Solution:
def replaceSpace(self, s: str) -> str:
return s.replace(' ','%20')
| true |
689e54954fdae0d7a43aaf93f7ef0af7da38e1de | Python | gurramdeepika/python_programming | /PycharmProjects/no1/17_Day/login.py | UTF-8 | 637 | 2.65625 | 3 | [] | no_license | from flask import Flask,redirect,url_for,request
app = Flask(__name__)
@app.route('/sucess/<name>') #/hello - will work only with /hello and /hello/ will work for both
def sucess(name):
return 'welcome %s'%name
@app.route('/login',methods = ['POST','GET'])
def login():
if request.method == 'POST':
u... | true |
081fc27c16306d44ae84ecb06c14811e886e026d | Python | srinayak666/python | /basic_python/ControlStructure.py | UTF-8 | 2,568 | 4.21875 | 4 | [] | no_license | import math
for i in range(1,10,2):
print(i)
print([x*x for x in range(1,10)])
print([(x if x%2==0 else "NA") for x in range(1,100)])
#While Condition
counter = 1
while counter <= 5:
print("Hello, world")
counter = counter + 1
#For condition-1
for item in [1,3,6,2,5]:
print(item)
#For Condition-2... | true |
03243aa0e5a337c4d0b7d2afd89b208e9dd190b6 | Python | apollo2030/CarND-Traffic-Sign-Classifier-Project | /LeNet_keras.py | UTF-8 | 772 | 2.71875 | 3 | [
"MIT"
] | permissive | from keras.models import Sequential
from keras.layers.core import Dense, Activation, Flatten, Dropout
from keras.layers.convolutional import Conv2D
from keras.layers.pooling import MaxPooling2D
def get_keras_model():
model = Sequential()
#1st Layer - Add a flatten layer
model.add(Conv2D(32, 3, input_shape... | true |
dd70737cffe7d9ca536c29398b073180f1fe5bde | Python | ayabdi/NLCA_CURIE_Discord | /shared_db_svc.py | UTF-8 | 4,313 | 2.640625 | 3 | [
"MIT"
] | permissive | import sqlite3
import flask
import json
from flask import request
import logging
from time import sleep, time
from random import seed, uniform
log = logging.getLogger("werkzeug")
log.setLevel(logging.ERROR)
app = flask.Flask("shared DB")
dbfile = "shared_db.sqlite"
def start_db(dbcon, dbcur):
dbcur.execute("CRE... | true |
90ad748c76ec1c78b7b868f66194aeb4d1750687 | Python | BryanNilsen/C40-KeahuaArboretum | /environments/forest.py | UTF-8 | 737 | 3.75 | 4 | [] | no_license | from .environment import Environment
class Forest(Environment):
def __init__(self, name):
Environment.__init__(self, name, animal_max=20, plant_max=32)
def animal_count(self):
return f"This place has {len(self.animals)} animals in it"
def add_animal(self, animal):
try:
... | true |
31fa2e76c910079dcabe6a800d3fbdd9d52ae6ef | Python | iterait/emloop | /emloop/tests/hooks/save_file_test.py | UTF-8 | 933 | 2.90625 | 3 | [
"MIT"
] | permissive | """
Module with simple hook saving files to the output dir test case (see :py:class:`emloop.hooks.SaveFile`).
"""
import os
import pytest
from emloop.hooks import SaveFile
def test_saving_file(tmpdir):
dir = os.path.join(tmpdir, 'files-to-save')
os.makedirs(dir)
file1 = os.path.join(dir, 'file1.txt')
... | true |
2622546ebbe52947534d6808bed4402c1ff228e8 | Python | devdave/txWeb | /examples/to_update/tictactoe/test_game.py | UTF-8 | 2,377 | 2.84375 | 3 | [
"MIT"
] | permissive | import json
from server import Game, MapCellState, IGameSession, handle_do
from twisted.web.test.requesthelper import DummyRequest
class MockRequest(DummyRequest):
def getSession(self, component=None):
session = DummyRequest.getSession(self)
if component is not None:
return session.ge... | true |
976c6b4237fb0f14f8b0c6b23d403415ce9e51f1 | Python | liyuliang001/cpp_helper | /cpp_class_gen.py | UTF-8 | 656 | 2.71875 | 3 | [] | no_license | import sys
def firstToUpper(s):
return s[0].upper() + s[1:].lower()
if __name__ == "__main__":
if len(sys.argv) != 2:
print "usage: python cpp_class_gen.py <class_name>"
sys.exit(0)
name = sys.argv[1]
tokens = name.split('_')
cpp = open("%s.cpp"%name,"w")
cpp.write('#include "%s.hpp"'%name)
cpp.close()
m... | true |
7da0d14584a6b8d84692e4a1521234a36617794c | Python | SsserGO/les | /src/ordering/md.py | UTF-8 | 849 | 3.046875 | 3 | [] | no_license |
from networkx import Graph
from md import md_ordering
def minimum_degree_ordering(g):
xadj = [0]
adjncy = []
adjacency = g.adjacency_list()
for i in range(len(adjacency)):
adj = adjacency[i]
if adj:
assert max(adj) < len(adjacency)
adjncy += map(int, adj)
xa... | true |
7376cf43df27a81a4da15432ca3dd4424763bd4a | Python | YUHANYU/Dongpu_Expriment | /tra_rnn/train_valid.py | UTF-8 | 12,937 | 2.546875 | 3 | [] | no_license | """
่ฝจ่ฟนLSTMๆจกๅ็่ฎญ็ปๅ้ช่ฏ
"""
import os
import datetime
import sys
from sklearn.metrics import precision_score, accuracy_score, recall_score, f1_score
import torch
from torch import nn
from torch import optim
import torch.nn.functional as Func
from torch.utils.data import DataLoader
from config import Config
config = Conf... | true |
9b1de9aefa901ae1f56d31fc1a4d668375d36d34 | Python | nmtarr/SEWoodyWetlandAnalysis | /MakeTopSpProtectionTable.py | UTF-8 | 3,470 | 3.171875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Unlicense",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 5 10:05:44 2018 by nmtarr
Description: Code for combining protection and overlay info for top
species.
"""
import pandas as pd
# Import packages
import pandas as pd
pd.set_option('display.max_rows', 700)
pd.set_option('display.max_columns', 10)
pd.set_option('display.wid... | true |
12e322a9cd06608002e93fe00573c5c43e299f82 | Python | skdkfk8758/DamoaCrawler | /build/lib/Crawler/TotalpostDAO.py | UTF-8 | 1,406 | 2.59375 | 3 | [] | no_license |
"""
DB์ ์ ๊ทผ ๋ฐ ์
๋ ฅ, ์ญ์ , ์์ ํ๋ ํด๋์ค
์ค๋ณต๋ ๋ด์ฉ์ DB์ ๊ฐฑ์ ํ๊ณ
๋ด์ฉ์ด ์์ผ๋ฉด ์ถ๊ฐ๋จ
2017.10.06
- DB : link์ index ๋ง๋ค์ด์ checkDate() ์๋ ํฅ์
"""
import pymysql
from Crawler.spiders.Setting import *
from Crawler.DBConfig import *
class TotalpostDAO:
# DB์ ์์ ์ํด ์ปค๋ฅ์
์ป๋ ๋ถ๋ถ
def __init__(self):
try:
self.conn = pym... | true |
bcc767f1e513482a6f27b4cdb15fd0a298c4b999 | Python | bangerterdallas/portfolio | /List_Comprehension_Bubble_Sort/assn15-task2.py | UTF-8 | 1,103 | 4.09375 | 4 | [] | no_license | def bubbleSort(inputList):
loop = True
while loop:
loop = False
for j in range(len(inputList) - 1):
if inputList[j] > inputList[j + 1]:
inputList[j], inputList[j + 1] = inputList[j + 1], inputList[j]
loop = True
def main():
numberList = []... | true |
a48ae8f95690e8e5bc11588238f65258c770ff5a | Python | metaganal/scripts | /Hello_world.py | UTF-8 | 337 | 3.578125 | 4 | [] | no_license | """
Print "Hello World" n times
"""
import argparse
import sys
parser = argparse.ArgumentParser("Print 'Hello World' n times")
parser.add_argument("integers", metavar="N", type=int, help="How many times 'Hello World' should be printed")
args = parser.parse_args()
for i in range(args.integers):
sys.stdout.writ... | true |
2e47f813aaa9d52355089210da8d5b024411a8a8 | Python | xtaq/lewen-spider | /lewen/spiders/deep_spider.py | UTF-8 | 2,442 | 2.515625 | 3 | [] | no_license | # coding=utf-8
import scrapy
import urlparse
import time
import logging
from scrapy.http import Request
from scrapy.selector import Selector
from lewen.items import LewenItem
from scrapy.spiders import CrawlSpider, Rule
__author__ = 'xt'
class DeepSpider(CrawlSpider):
name = 'deep'
def __init__(self, rule)... | true |