blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 616 | content_id stringlengths 40 40 | detected_licenses listlengths 0 69 | license_type stringclasses 2 values | repo_name stringlengths 5 118 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 63 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 2.91k 686M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 213 values | src_encoding stringclasses 30 values | language stringclasses 1 value | is_vendor bool 2 classes | is_generated bool 2 classes | length_bytes int64 2 10.3M | extension stringclasses 246 values | content stringlengths 2 10.3M | authors listlengths 1 1 | author_id stringlengths 0 212 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
426f32ef376e7463920f02164ba38de1cc700e70 | cae3fe972d07b7c8d86d1f94d5e19e716eccb2a3 | /robot/robot-tasks-master/task_9.py | 745b9e7ebda6ecc5114c036615ee1e63f5638dea | [
"MIT"
] | permissive | skorphil/lab_works | be57d6154828757d5209ec584e964668b47ce9af | 1bf7d1d68e3196aafd64f5e01ce3c831063e1118 | refs/heads/master | 2023-03-24T05:16:56.472920 | 2021-03-21T08:56:17 | 2021-03-21T08:56:17 | 330,754,370 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 319 | py | #!/usr/bin/python3
from pyrob.api import *
@task
def task_8_2():
pass
while wall_is_on_the_right() == False:
if wall_is_above() == False:
fill_cell()
move_right()
else:
if wall_is_above() == False:
fill_cell()
if __name__ == "__main__":
run_tasks()
| [
"skorphil@gmail.com"
] | skorphil@gmail.com |
9df8ff274ca587d7059c4acf7b9f877b5814e90e | 2d706bbc3fe440348a9f1ebbd89462c9609da66d | /examples/autoencoder/plot_ae_gmm.py | 253984534921072f7656ae2950141c370b00eaf7 | [] | no_license | ostiff/fyp2020-oss1017 | 177d33a510dee2b116190e8c8acdb12b41645ab5 | 801b811c6c5cc68a7b1dc616f1fb7b1e7290145a | refs/heads/main | 2023-06-14T21:55:51.042475 | 2021-07-13T08:36:41 | 2021-07-13T08:36:41 | 326,712,919 | 1 | 0 | null | 2021-07-02T17:46:52 | 2021-01-04T14:40:03 | CSS | UTF-8 | Python | false | false | 5,976 | py | """
Auto-encoder w/ GMM clustering
==============================
"""
import os
import pandas as pd
import numpy as np
import pickle
from torch.utils.data import DataLoader
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
from pkgname.core.AE.autoencoder import get_device, set_seed
from pkgname.utils.data_loader import load_dengue, IQR_rule
from definitions import ROOT_DIR
from tableone import TableOne
import matplotlib.pyplot as plt
import itertools
from scipy import linalg
import matplotlib as mpl
from sklearn import mixture
# --------------
# Load data
# --------------
SEED = 0
batch_size = 16
MODEL_PATH = os.path.join(ROOT_DIR, 'examples', 'autoencoder', 'sigmoid')
N_CLUSTERS = 3
# Set seed
set_seed(SEED)
# Get device
device = get_device(False)
features = ["dsource", "date", "age", "gender", "weight", "bleeding", "plt",
"shock", "haematocrit_percent", "bleeding_gum", "abdominal_pain",
"ascites", "bleeding_mucosal", "bleeding_skin", "body_temperature"]
info_feat = ["dsource", "shock", "bleeding", "bleeding_gum", "abdominal_pain", "ascites",
"bleeding_mucosal", "bleeding_skin", "gender"]
data_feat = ["age", "weight", "plt", "haematocrit_percent", "body_temperature"]
before_fill = load_dengue(usecols=['study_no'] + features)
before_fill = before_fill.loc[before_fill['age'] <= 18]
before_fill = IQR_rule(before_fill, ['plt', 'haematocrit_percent', 'body_temperature'])
df = before_fill.copy()
before_fill = before_fill.dropna(subset=data_feat + ['date'])
for feat in features:
df[feat] = before_fill.groupby('study_no')[feat].ffill().bfill()
df = df.dropna()
df = df.groupby(by="study_no", dropna=False).agg(
dsource=pd.NamedAgg(column="dsource", aggfunc="last"),
date=pd.NamedAgg(column="date", aggfunc="last"),
age=pd.NamedAgg(column="age", aggfunc="max"),
gender=pd.NamedAgg(column="gender", aggfunc="first"),
weight=pd.NamedAgg(column="weight", aggfunc=np.mean),
bleeding=pd.NamedAgg(column="bleeding", aggfunc="max"),
plt=pd.NamedAgg(column="plt", aggfunc="min"),
shock=pd.NamedAgg(column="shock", aggfunc="max"),
haematocrit_percent=pd.NamedAgg(column="haematocrit_percent", aggfunc="max"),
bleeding_gum=pd.NamedAgg(column="bleeding_gum", aggfunc="max"),
abdominal_pain=pd.NamedAgg(column="abdominal_pain", aggfunc="max"),
ascites=pd.NamedAgg(column="ascites", aggfunc="max"),
bleeding_mucosal=pd.NamedAgg(column="bleeding_mucosal", aggfunc="max"),
bleeding_skin=pd.NamedAgg(column="bleeding_skin", aggfunc="max"),
body_temperature=pd.NamedAgg(column="body_temperature", aggfunc=np.mean),
).dropna()
mapping = {'Female': 0, 'Male': 1}
df = df.replace({'gender': mapping})
train, test = train_test_split(df, test_size=0.2, random_state=SEED)
train_data = train[data_feat]
test_data = test[data_feat]
train_info = train[info_feat]
test_info = test[info_feat]
scaler = preprocessing.MinMaxScaler().fit(train_data)
train_scaled = scaler.transform(train_data.to_numpy())
test_scaled = scaler.transform(test_data.to_numpy())
loader_train = DataLoader(train_scaled, batch_size, shuffle=False)
loader_test = DataLoader(test_scaled, batch_size, shuffle=False)
model = pickle.load(open(MODEL_PATH, 'rb'))
encoded_train = model.encode_inputs(loader_train)
plt.scatter(encoded_train[:, 0], encoded_train[:, 1], c=train_info['shock'])
plt.title('AE shock in latent space (testing data)')
plt.show()
color_iter = itertools.cycle(['navy', 'c', 'cornflowerblue', 'gold',
'darkorange'])
def plot_results(X, Y_, means, covariances, index, title):
splot = plt.subplot(2, 1, 1 + index)
for i, (mean, covar, color) in enumerate(zip(
means, covariances, color_iter)):
v, w = linalg.eigh(covar)
v = 2. * np.sqrt(2.) * np.sqrt(v)
u = w[0] / linalg.norm(w[0])
# as the DP will not use every component it has access to
# unless it needs it, we shouldn't plot the redundant
# components.
if not np.any(Y_ == i):
continue
plt.scatter(X[Y_ == i, 0], X[Y_ == i, 1], .8, color=color)
# Plot an ellipse to show the Gaussian component
angle = np.arctan(u[1] / u[0])
angle = 180. * angle / np.pi # convert to degrees
ell = mpl.patches.Ellipse(mean, v[0], v[1], 180. + angle, color=color)
ell.set_clip_box(splot.bbox)
ell.set_alpha(0.5)
splot.add_artist(ell)
plt.xlim(0, 1.)
plt.ylim(0, 1)
plt.xticks(())
plt.yticks(())
plt.title(title)
# Fit a Gaussian mixture with EM using five components
gmm = mixture.GaussianMixture(n_components=N_CLUSTERS, covariance_type='full').fit(encoded_train)
plot_results(encoded_train, gmm.predict(encoded_train), gmm.means_, gmm.covariances_, 0,
'Gaussian Mixture')
# Fit a Dirichlet process Gaussian mixture using five components
dpgmm = mixture.BayesianGaussianMixture(n_components=N_CLUSTERS,
covariance_type='full').fit(encoded_train)
plot_results(encoded_train, dpgmm.predict(encoded_train), dpgmm.means_, dpgmm.covariances_, 1,
'Bayesian Gaussian Mixture with a Dirichlet process prior')
plt.show()
# Table
labels = [f"Cluster {i}" for i in range(N_CLUSTERS)]
mapping = {0: 'Female', 1: 'Male'}
table_df = train.replace({'gender': mapping})
table_df['cluster'] = dpgmm.predict(encoded_train)
columns = info_feat+data_feat
nonnormal = list(table_df[columns].select_dtypes(include='number').columns)
categorical = list(set(columns).difference(set(nonnormal)))
columns = sorted(categorical) + sorted(nonnormal)
rename = {'haematocrit_percent': 'hct',
'body_temperature': 'temperature'}
table = TableOne(table_df, columns=columns, categorical=categorical, nonnormal=nonnormal,
groupby='cluster', rename=rename, missing=False)
print(table.tabulate(tablefmt="fancy_grid"))
| [
"37678137+ostiff@users.noreply.github.com"
] | 37678137+ostiff@users.noreply.github.com |
d308ca967af8965b1ae999c429a0f3acafbdcf7b | 2fe98c2f7144b6af01c8cf06473af4cc42be60f6 | /VaccineCountNormal.py | 39648bec63ea1a07ebe3bf048e80f681a52a59e8 | [] | no_license | captain-nemo1/Vaccine-Availabilty | 7f67b4fef513d7dc5ee80256bb04c1b12729a359 | a3ce8afbf44a6afb1082e730025a5c6cfcb239ea | refs/heads/main | 2023-04-23T15:52:25.458476 | 2021-05-11T15:23:49 | 2021-05-11T15:23:49 | 365,741,143 | 2 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,122 | py | # -*- coding: utf-8 -*-
"""
Created on Sun May 9 17:19:56 2021
@author: Ashit Agarwal
"""
import requests
from datetime import date
import re
#Gets the pincode from users and checks if valid or not
#@returns: returns pincode entered
def getPincode():
correct = False
while correct == False :
pincode = input("Enter Pincode\n")
correct = bool(re.match("^[1-9][0-9]{5}$", str(pincode)))
if correct == True:
return pincode
#Gets current date
#@return : returns date today
def getCurrentDate():
dateToday = date.today()
dateToday = dateToday.strftime("%d-%m-%Y")
return dateToday
#Gets the Centers data for the entered pincode and date
#@params : pincode: pincode of the area to be looked for.
#@params : dateToday: the current date
#@returns : returns the data received if present other returns empty string
def getRequest(pincode, dateToday):
sampleUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={}&date={}".format(pincode, dateToday)
headers = {'accept': 'application/json','Accept-Language': 'hi_IN', 'User-Agent': sampleUserAgent}
response = requests.get(url, headers=headers)
if response.status_code == 200:
result = response.json()
result = result['centers']
return result
else:
print("Error Encountered")
return ""
#Finds the center that have vaccines and calls printSessionsAvailable() funtion
#to send the centers with vaccine
#@param: result: Contains data of all the centers for the pincode
def showResults(result):
centerCount = len(result)
totalCenterVaccineAvailableAt = 0
for i in range(centerCount):
nameOfCenter = result[i].get("name")
sessions = result[i].get("sessions")
sessions = list(filter(lambda x: x.get("available_capacity") > 0, sessions))
sessionsCount = len(sessions)
if(sessionsCount > 0):
print(nameOfCenter)
totalCenterVaccineAvailableAt += 1
printSessionsAvailable(sessions, sessionsCount)
print("-------------------------------------")
if totalCenterVaccineAvailableAt == 0 :
print("All slots are booked")
#Prints available vaccine count
def printSessionsAvailable(sessions, sessionsCount):
for i in range(sessionsCount):
vaccineAvailable = sessions[i].get("available_capacity")
dateAvailable = sessions[i].get("date")
ageLimit = sessions[i].get("min_age_limit")
if(vaccineAvailable > 0):
message = "On Date {} vaccines available are {} for age {}+".format(dateAvailable,vaccineAvailable, ageLimit)
print(message)
pincode = 110001
#pincode = getPincode()
dateToday = getCurrentDate()
print("Get 7 days covid vaccination data from {}".format(dateToday))
result = getRequest(pincode, dateToday)
if len(result)>0:
showResults(result)
else:
print("No Center Available") | [
"ashitagarwal89@gmail.com"
] | ashitagarwal89@gmail.com |
ed4e236be1a1d1b70d1d26ce123abfafd90b4ed0 | 3609a5cd474ca3cd6258272ecfebb9757ba33791 | /ct_detect/PyQt/QtDesigner/test2.py | ef7e3afb777376bea19e1a38e589c2080af25175 | [] | no_license | nlby/pyqt_nlby | 6d2b08e943d5ce0daafe0dad3c4d9cc9b17a30e0 | da36d9d77222bbce17b2e0cfe25316d8bf9f5cbe | refs/heads/master | 2022-09-16T02:57:15.430995 | 2020-05-31T06:53:09 | 2020-05-31T06:53:19 | 268,225,638 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,345 | py | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test2.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(776, 793)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(160, 40, 431, 331))
self.label.setFrameShape(QtWidgets.QFrame.Box)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(160, 370, 431, 331))
self.label_2.setFrameShape(QtWidgets.QFrame.Box)
self.label_2.setObjectName("label_2")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "输入图像"))
self.label_2.setText(_translate("Form", "检测结果图像"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
| [
"1029253541@qq.com"
] | 1029253541@qq.com |
84d8b4aed568c36b12ab0caa3336a3e8e0341fd2 | 66cad212e8b6fdcf667bf0cdae32f2232fe745da | /tango_with_django_project/tango_with_django_project/settings.py | 6b02153fe88df0071bd0dda9f5f6ac25029963e3 | [] | no_license | kjhurley/workspace-for-learnign | d9de334e74f53e576d6acd73ea26ae239571fb19 | e56696315059ecc4d7b2e80e6657971e4c6754b6 | refs/heads/master | 2016-08-06T02:47:10.506250 | 2014-11-25T15:22:46 | 2014-11-25T15:22:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 2,378 | py | """
Django settings for tango_with_django_project project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'mi_uc%6e(0%afjmf@lwdsb9twh!t&gnt^#0*z)j20#+vbqdk67'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rango'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'tango_with_django_project.urls'
WSGI_APPLICATION = 'tango_with_django_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASE_PATH = os.path.join(BASE_DIR, 'rango.db')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': DATABASE_PATH,
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
TEMPLATE_PATH=os.path.join(BASE_DIR,"templates")
TEMPLATE_DIRS = (
TEMPLATE_PATH,
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
STATIC_PATH = os.path.join(BASE_DIR,"static")
STATICFILES_DIRS = (
STATIC_PATH,
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,"media") | [
"kevin@hurleys.org.uk"
] | kevin@hurleys.org.uk |
3c028514945da9e202a116f85ceda520d2403fd0 | 3c73fdb451b1f8d6bd96cded694c9b02fcc89903 | /util/stats/samples.py | 2e4d6a1dd1c8ba3170cab38ccb3382564b018b65 | [
"MIT"
] | permissive | winterdl/util | a9640a4644977c53319ed3599e20b0374a4698dc | a187fe803a1a9fa81dc36e751c2813db82833e35 | refs/heads/master | 2020-05-24T20:02:54.421868 | 2019-04-29T20:29:39 | 2019-04-29T20:29:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 7,646 | py | from util.stats import *
# =====================================================
# Approximating the desired number of samples
# =====================================================
# Compute the confidence of "num_samples" samples having less than or
# equal to "max_error" at exactly 1/2. This is achieved by factoring
# the expression (sum_{i=j}^k choose(n,i) / 2^n) to reduce operations.
def _half_confidence(num_samples, max_error):
from util.math import Fraction, choose
# Calculate the maximum number of steps away from the mid-point
# that we can take *before* violating the error condition.
odd = num_samples % 2
start = (num_samples+1) // 2
# initial_error + steps * step_error <= max_error
# (max_error - initial_error) / step_error >= steps
# (max_error - initial_error) * num_samples >= steps
# knowing that step_error = 1 / num_samples
min_error = odd * Fraction(1, (2*num_samples))
steps = int((max_error - min_error) * num_samples)
# Put steps into allowable bounds.
steps = max(0, min(num_samples - start, steps))
# Handle two cases where there is no functioning confidence bound.
if (odd) and (max_error < min_error): return Fraction()
# Compute the fraction.
numerator = 1
denominator = 2**(num_samples)
# First compute the constant multiple outside of the sum.
for i in range(start+steps+1, num_samples+1): numerator *= i
for i in range(2, start+1): denominator *= i
# Compute the sum of the inner parts of the distribution.
total = 0
for i in range(start, start+steps+1):
v = 1
for j in range(i+1, start+steps+1): v *= j
for j in range(1+num_samples-i, start+1): v *= j
if (v > 1): total += v * (2 if ((i != start) or odd) else 1)
# Perform the final numerator update.
if (total > 0): numerator *= total
# Return the (reduced) fraction.
return Fraction(numerator, denominator)
# Given a list of numbers, return True if the given values provide an
# estimate to the underlying distribution with confidence bounded error.
def samples(size=None, error=None, confidence=None, at=None):
# Determine what to calculate based on what was provided.
from util.math import is_none, choose, Fraction
if is_none(size): to_calculate = "samples"
elif is_none(error): to_calculate = "error"
elif is_none(confidence): to_calculate = "confidence"
else: to_calculate = "verify"
# Default evaluation point is at (1/2), where the error is greatest.
if is_none(at): at = Fraction(1, 2)
else: at = Fraction(at)
# Set the default values for other things that were not provided.
if type(error) == type(None): error = Fraction(10, 100)
if type(confidence) == type(None): confidence = Fraction(95, 100)
# Convert error and confidence to fraction types if necessary.
if not type(error) == Fraction: error = Fraction(error)
if not type(confidence) == Fraction: confidence = Fraction(confidence)
# If the user provided something with a length, use that number.
if hasattr(size, "__len__"): size = len(size)
# \sum_{i=0}^n choose(n, i) * ( at^i (1-at)^(n-i) )
if not is_none(size):
# Compute the probability of any given observed EDF value.
prob = lambda i: choose(size, i) * (at**i * (1-at)**(size-i))
# If we are calculating the confidence or verifying, compute confidence.
if to_calculate in {"confidence", "verify"}:
if (at == 1/2): conf = _half_confidence(size, error)
else:
conf = Fraction()
steps = 0
# Sum those probabilities that are closer than "error" distance.
for i in range(size+1):
p = Fraction(i, size)
if (abs(p - at) <= error):
steps += 1
conf += prob(i)
# Return the total confidence.
if to_calculate == "confidence": return float(conf)
else: return conf >= confidence
elif to_calculate == "error":
# Store the "contained" outcomes by "allowed error".
error = Fraction()
contained = Fraction()
# Sort the percentiles by their distance from "at".
i_p = sorted(enumerate(Fraction(i,size,_normalize=False)
for i in range(size+1)),
key=lambda ip: abs(ip[1]-at))
# Cycle through percentiles, starting closest to "at" and moving out.
for step in range(len(i_p)):
# If this step has the same probability as the last, skip.
if (i_p[step][1] == i_p[step-1][1]): continue
i, p = i_p[step]
# Compute the amount of data contained by this step away.
next_contained = contained + prob(i)
# If the distance from "at" is the same for two steps, take two.
if (step+1 < len(i_p)) and (abs(at-i_p[step][1]) == abs(at-i_p[step+1][1])):
next_contained += prob( i_p[step+1][0] )
# Only update the "allowed error" if confidence is maintained.
if next_contained < confidence:
contained = next_contained
error = abs(i_p[step][1] - at)
else: break
return float(error)
else:
# Compute the number of samples required.
size, step = 2**10, 2**9
# print("Desired ----------------")
# print("error: ",error)
# print("confidence: ",confidence)
# for size in range(2, 500):
# conf_below = samples(size-1, error=error, at=at)
# conf_at = samples(size, error=error, at=at)
# print("", "size: ",size, float(f"{conf_below:.2e}"), float(f"{conf_at:.2e}"))
# exit()
under, over = 0, None
# We have the right size when any smaller size is not passable.
conf_below = samples(size=size-1, error=error, at=at)
conf_at = samples(size=size, error=error, at=at)
print("", "size: ",size, float(f"{conf_below:.2e}"), float(f"{conf_at:.2e}"))
while not (conf_below < confidence <= conf_at):
if conf_at < confidence:
# Update "under". Scale up if we haven't found "over".
under = max(under, size)
if (over == None): step *= 2
# Take the step.
size += step
else:
# Update "over". Take step. Scale down.
over = min(over if (over != None) else float('inf'), size)
size = size - step
step = step // 2
# Recompute the confidence at and below this step size.
conf_below = samples(size-1, error=error, at=at)
conf_at = samples(size, error=error, at=at)
print("", "size: ",size, float(f"{conf_below:.2e}"), float(f"{conf_at:.2e}"))
# Correct for strange sample size error that can happen bc
# of alignment of "at" and one of the sample values.
if conf_at < conf_below:
size = size-1
conf_at = conf_below
conf_below = samples(size-1, error=error, at=at)
print("", "size: ",size, float(f"{conf_below:.2e}"), float(f"{conf_at:.2e}"))
# Return the computed best sample size.
return size
| [
"thomas.ch.lux@gmail.com"
] | thomas.ch.lux@gmail.com |
d95af86586a787031ce50863eb06c8da6acecdc1 | a6d33a4f864889bec0ec21b5b8106d99a263141c | /kubernetes/models/v1/NodeSelector.py | fbb564b7d15d74932777b7343a5f6b295b17d57e | [
"Apache-2.0"
] | permissive | riconnon/kubernetes-py | bffd2a89b2f445706381c01f46c60cce804f49d6 | 42a4537876985ed105ee44b6529763ba5d57c179 | refs/heads/master | 2020-03-28T01:35:43.082333 | 2018-08-21T19:46:24 | 2018-08-21T19:46:24 | 147,515,935 | 0 | 0 | Apache-2.0 | 2018-09-05T12:42:13 | 2018-09-05T12:42:12 | null | UTF-8 | Python | false | false | 1,739 | py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.md', which is part of this source code package.
#
from kubernetes.models.v1.NodeSelectorTerm import NodeSelectorTerm
from kubernetes.utils import is_valid_list
class NodeSelector(object):
"""
https://kubernetes.io/docs/api-reference/v1.6/#nodeselector-v1-core
"""
def __init__(self, model=None):
super(NodeSelector, self).__init__()
self._node_selector_terms = []
if model is not None:
self._build_with_model(model)
def _build_with_model(self, model=None):
if 'nodeSelectorTerms' in model:
terms = []
for t in model['nodeSelectorTerms']:
term = NodeSelectorTerm(t)
terms.append(term)
self.node_selector_terms = terms
# ------------------------------------------------------------------------------------- nodeSelectorTerms
@property
def node_selector_terms(self):
return self._node_selector_terms
@node_selector_terms.setter
def node_selector_terms(self, t=None):
if not is_valid_list(t, NodeSelectorTerm):
raise SyntaxError('NodeSelector: node_selector_terms: [ {} ] is invalid.'.format(t))
self._node_selector_terms = t
# ------------------------------------------------------------------------------------- serialize
def serialize(self):
data = {}
if self.node_selector_terms:
terms = []
for t in self.node_selector_terms:
term = t.serialize()
terms.append(term)
data['nodeSelectorTerms'] = terms
return data
| [
"francis@manafont.net"
] | francis@manafont.net |
8704515eab4e9f3e970b56686ee9543e8e9d6f38 | bb2f56f394d64bb2c9d80bf54908c519cdad5561 | /github_api4_client/client.py | c2e613fe2c2adef53bebc211945e3e8409eb7f69 | [] | no_license | mikelane/Github_api4_client | a67bb20dc3a9067df3791130f25dcab20235f47b | 20477bb74bb2a276319dd40d834f623ea7259457 | refs/heads/master | 2021-08-27T20:22:19.449928 | 2017-11-28T07:17:16 | 2017-11-28T07:17:16 | 112,152,886 | 2 | 0 | null | null | null | null | UTF-8 | Python | false | false | 700 | py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A client that queries Github's API v4"""
import json
import requests
__author__ = "Michael Lane"
__email__ = "mikelane@gmail.com"
__copyright__ = "Copyright 2017, Michael Lane"
__license__ = "MIT"
class Client:
def __init__(self, token):
self.token = token
self.endpoint = 'https://api.github.com/graphql' # Github's GraphQL endpoint
self.headers = {'Authorization': f'Bearer {token}'}
def query(self, query):
assert isinstance(query, str)
data = {'query': query}
return requests.post(url=self.endpoint, data=json.dumps(data), headers=self.headers)
if __name__ == '__main__':
pass
| [
"mikelane@gmail.com"
] | mikelane@gmail.com |
8e0c664d89f9ebe5a4fcddec0508e740e4dda242 | ca7aa979e7059467e158830b76673f5b77a0f5a3 | /Python_codes/p02845/s575549372.py | 16109b9dd317744dc9ac0456caeec1497be459c4 | [] | no_license | Aasthaengg/IBMdataset | 7abb6cbcc4fb03ef5ca68ac64ba460c4a64f8901 | f33f1c5c3b16d0ea8d1f5a7d479ad288bb3f48d8 | refs/heads/main | 2023-04-22T10:22:44.763102 | 2021-05-13T17:27:22 | 2021-05-13T17:27:22 | 367,112,348 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 217 | py | N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
ans = 1
dp = [0]*3
for a in A:
ans = ans*dp.count(a) % MOD
try:
dp[dp.index(a)] += 1
except ValueError:
break
print(ans)
| [
"66529651+Aastha2104@users.noreply.github.com"
] | 66529651+Aastha2104@users.noreply.github.com |
6db71eb68c7d13251506f4ee28069a6e635d7e92 | c571444b5e879177252c9721ccc2047d4661dd0c | /viewpack/mixins.py | b42b2612d4a370223c0916241da3f2326f87b009 | [] | no_license | dbsiavichay/faclab | fdb4390544c2515bf92e0e05518f13321ab74907 | 5776f04a5dde4691f9536d2f42fdabaf4984ea45 | refs/heads/master | 2023-08-07T13:52:39.360634 | 2023-08-02T04:25:56 | 2023-08-02T04:25:56 | 106,976,972 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,611 | py | from django.shortcuts import redirect
class Inline:
instance = None
def __init__(self, formset):
self.formset = formset
self.headers = [field.label for field in formset.form.base_fields.values()]
def is_valid(self):
return self.formset.is_valid()
def save(self):
self.formset.instance = self.instance
self.formset.save()
@property
def errors(self):
return self.formset.errors
class InlineMixin:
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
inlines = self.get_inlines()
if inlines:
pack_info = context.get("pack_info", {})
pack_info.update({"inlines": inlines})
context["pack_info"] = pack_info
return context
def get_inlines(self):
kwargs = self.get_form_kwargs()
return {
name: Inline(inline_class(**kwargs))
for name, inline_class in self.pack.inlines.items()
}
def form_valid(self, form):
inlines = self.get_inlines().values()
if any([not inline.is_valid() for inline in inlines]):
form.inlines = inlines
return self.form_invalid(form)
self.object = form.save()
for inline in inlines:
inline.instance = self.object
inline.save()
return redirect(self.get_success_url())
def form_invalid(self, form):
for inline in form.inlines:
for error in inline.errors:
form.errors.update(error)
return super().form_invalid(form)
| [
"dbsiavichay@gmail.com"
] | dbsiavichay@gmail.com |
dd6bc3674d2a7a3f61dd1644cd2c052c3b730191 | 07539ecbcee0488ce4a0eb779583da3149cfac7b | /amonone/web/apps/core/models.py | 6c529a2c3088810551b9fc00644c6f20343fe60c | [
"MIT"
] | permissive | outbounder/amonone | e151584ac38222b40c314d586ebadc4e0f43fce1 | 985fa147c1d98a4f57ff33ebd37ca0d938fe674d | refs/heads/master | 2020-12-25T13:33:46.425826 | 2013-07-11T08:54:32 | 2013-07-11T08:54:32 | 11,389,227 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 257 | py | from hashlib import sha1
from amonone.web.apps.core.basemodel import BaseModel
class ServerModel(BaseModel):
def __init__(self):
super(ServerModel, self).__init__()
self.collection = self.mongo.get_collection('server')
server_model = ServerModel()
| [
"martinrusev@zoho.com"
] | martinrusev@zoho.com |
c0a1f8fe3ed53eb89e51d8f6b0ab03c11b9b516c | 53fab060fa262e5d5026e0807d93c75fb81e67b9 | /backup/user_271/ch79_2020_04_13_14_54_52_021722.py | 56f092418fe91e0cbdd5f29ebcd722db661031f9 | [] | no_license | gabriellaec/desoft-analise-exercicios | b77c6999424c5ce7e44086a12589a0ad43d6adca | 01940ab0897aa6005764fc220b900e4d6161d36b | refs/heads/main | 2023-01-31T17:19:42.050628 | 2020-12-16T05:21:31 | 2020-12-16T05:21:31 | 306,735,108 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 141 | py | def monta_dicionario(lista1,lista2):
dic={}
i=0
while i<len(lista1):
dic[lista1[i]]=lista2[i]
i+=1
return dic | [
"you@example.com"
] | you@example.com |
e995605b2c4405408a12059ca84680a733e2e75c | 986385a0cfee64d07b43befff754984a0507f69f | /tests/chain_map_test.py | 87937b5293fda5fb2e183e5cefbbb90770b0ea51 | [
"MIT"
] | permissive | mareklovci/zsur | 2fce9e15b4b83480365b2b1d35dd41c2cc37d09d | c41fbce53aa790b1f280cbca8d274845993e74f9 | refs/heads/master | 2021-09-20T04:11:09.055143 | 2018-08-03T11:03:50 | 2018-08-03T11:03:50 | 121,879,583 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 357 | py | import unittest
import zsur.chain_map
class TestChainMap(unittest.TestCase):
def setUp(self):
self.data = [(-3, 0), (3, 2), (-2, 0), (3, 3), (2, 2), (3, -2), (4, -2), (3, -3)]
def test_chainmap(self):
result = zsur.chain_map(self.data, 3.5)
self.assertEqual(result[2], 3)
if __name__ == '__main__':
unittest.main()
| [
"mareklovci@gmail.com"
] | mareklovci@gmail.com |
fada9429bd7a1b5beb6952bb7eb57f0506fbbcbd | 0606c40353c18fce7c640ed2f6fc4affb95f31a8 | /authorsnbooks/urls.py | be8f8de6e773aa7e7a3e33e3728eb7abf159905f | [] | no_license | moriakh/ejemplos_orm | fc5d0d68556a36d31df019a932a140bd23be26a3 | d83ced88fff43a1d68e2c8fa92650fcc76cd019e | refs/heads/main | 2023-07-05T13:34:41.207818 | 2021-08-12T01:23:31 | 2021-08-12T01:23:31 | 393,742,074 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 732 | py | from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
path('books', views.books_page, name="books_page"),
path('authors', views.authors_page, name="authors_page"),
path('delete_book/<book_id>', views.delete_book, name="delete_book"),
path('delete_author/<author_id>', views.delete_author, name="delete_author"),
path('delete/<author_id>/<book_id>', views.delete, name="delete"),
path('add', views.add, name="add"),
path('add_book', views.add_book, name="add_book"),
path('add_author', views.add_author, name="add_author"),
path('books/<book_id>', views.view_book, name="view_book"),
path('authors/<author_id>', views.view_author, name="view_author")
]
| [
"moriaknc@outlook.com"
] | moriaknc@outlook.com |
ffaaf86ae52bc6c16c44ee4701c6a9acacb0a9b9 | b4c61d25968af71c6098c09041dcc9872486096c | /mars/primitiveProvider.py | 2d8325a5d57ca1e17170867531c88256d91a5d08 | [] | no_license | SarielMa/cppGenerator | 7790c1d53d2aecd696674c8ed0edcbf2ca5edc07 | 6f4321366df6fa52aa205c9c5bb8669f367c8be1 | refs/heads/master | 2021-04-28T21:44:58.598559 | 2017-12-24T18:45:20 | 2017-12-24T18:45:20 | 77,735,442 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,526 | py | #!usr/bin/python
#from tasks import variable
import random
class primitiveProvider(object):
def __init__(self):
self.intl=[-100,-10,-5,-2,-1,0,1,2,5,10,100]
self.charl='asdfghjklqwertyuiopzxcvbnm'
self.floatl=[-0.5,0.0,0.1,0.5]
self.doublel=[-0.5,0.0,0.1,0.5]
self.booll=['true','false']
def isptype(self,tp):
if tp.find("int")>=0 or tp.find("float")>=0 or tp.find("double")>=0 or tp=="char" or tp=="bool" or tp=="string":
return True
else:
return False
def getv(self,tp):
if tp.find("int")>=0:
return random.randint(-100,100)
elif tp.find("float")>=0:
return self.floatl[random.randint(0,len(self.floatl)-1)]+'f'
elif tp.find("double")>=0:
return self.doublel[random.randint(0,len(self.floatl)-1)]
elif tp=="char":
return "'"+random.choice(self.charl)+"'"
elif tp=="bool":
return self.booll[random.randint(0,len(self.booll)-1)]
elif tp=="string":
s='xas'
while random.randint(0,1)==1:
s+=random.choice(self.charl)
return '"'+s+'"'
else:
return None
if __name__=="__main__":
print(primitiveProvider().isptype("string"))
print(primitiveProvider().isptype("char"))
print(primitiveProvider().isptype("bool"))
print(primitiveProvider().getv("string"))
print(primitiveProvider().getv("char"))
print(primitiveProvider().getv("bool"))
| [
"496252590@qq.com"
] | 496252590@qq.com |
f0ee434ecdf2f62a398ad6e43b34b24e53722ed9 | 8884bcd4375aa580c6dc9b0650dd2b10b183dd09 | /query/setup.py | 86490672335c2aad506cce91c0d5ec54e76df933 | [
"MIT"
] | permissive | avesus/hail | a34fb1c0fd74618e7dfba4724d34d63e89220936 | 6b61ea821e40475ebffb87cea176282a7401f427 | refs/heads/main | 2023-06-17T01:29:52.646771 | 2021-07-12T21:41:22 | 2021-07-12T21:41:22 | 385,439,062 | 1 | 0 | MIT | 2021-07-13T01:48:42 | 2021-07-13T01:48:41 | null | UTF-8 | Python | false | false | 302 | py | from setuptools import setup, find_packages
setup(
name='query',
version='0.0.2',
url='https://github.com/hail-is/hail.git',
author='Hail Team',
author_email='hail@broadinstitute.org',
description='Query service',
packages=find_packages(),
include_package_data=True,
)
| [
"noreply@github.com"
] | avesus.noreply@github.com |
103c356745c5fe170f0eff49b2bf26cd5c8b6be1 | 1e105afef56df40660a08960da4c0393908cedd9 | /docs/conf.py | 186376379f19148c6f3645878a4a5dfcd5053451 | [
"MIT"
] | permissive | xguse/big-gus-brewing-labs | 4fab5333fd69a60625d4a7e99c66a41c823f51b7 | 7536c70764765c6737e99b68e9c537fbc12f4d1f | refs/heads/master | 2021-05-04T06:37:16.797600 | 2016-10-10T15:38:21 | 2016-10-10T15:38:21 | 70,493,682 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 7,975 | py | # -*- coding: utf-8 -*-
#
# big-gus-brewing-labs documentation build configuration file, created by
# sphinx-quickstart.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'big-gus-brewing-labs'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_domain_indices = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'big-gus-brewing-labsdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index',
'big-gus-brewing-labs.tex',
u'big-gus-brewing-labs Documentation',
u"Gus Dunn", 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# If true, show page references after internal links.
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'big-gus-brewing-labs', u'big-gus-brewing-labs Documentation',
[u"Gus Dunn"], 1)
]
# If true, show URL addresses after external links.
# man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'big-gus-brewing-labs', u'big-gus-brewing-labs Documentation',
u"Gus Dunn", 'big-gus-brewing-labs',
'A re-awakening of the Big Gus Brewing Company habit of my mid 20s mixed with my aquired reproducible science and data-science affinities.', 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
# If false, no module index is generated.
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'
| [
"w.gus.dunn@gmail.com"
] | w.gus.dunn@gmail.com |
6b89c115a7d0ada88176e06f7dd23359dd66c7e3 | 1a826c11e372ac7e82f2f7314641804e7cfd1f2c | /studentapp/migrations/0003_auto_20150210_2124.py | 5e7d161f0ef1eaebd1b9f865f002c2deba321eaa | [] | no_license | alexander-vielimchanitsia/studentapp | 4ef4424c8c7bc78600e3376bba341f86281e8937 | 79af5eb0fcedb52945fc1c4439483be179f7f016 | refs/heads/master | 2021-01-22T10:03:00.607302 | 2017-07-02T21:22:50 | 2017-07-02T21:22:50 | 24,384,980 | 1 | 1 | null | null | null | null | UTF-8 | Python | false | false | 544 | py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('studentapp', '0002_auto_20150210_2123'),
]
operations = [
migrations.AlterField(
model_name='student',
name='stud_group',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='\u0413\u0440\u0443\u043f\u0430', to='studentapp.Group'),
),
]
| [
"alexander_vielimchanitsia@mail.ua"
] | alexander_vielimchanitsia@mail.ua |
3eb1c8d9a9b7bcf81d15676fc21f004af2ecd023 | dcc4c79f00c48459e92c7b7369f4824c5c4f16f9 | /python-数据结构和算法/mysort.py | 319939cc47dc520e5cfec478db4c026647eff7c9 | [] | no_license | jie123xing/python_pycharm | c21d924c46bbed9c767521949e1b0a6c3e53ab1c | c008a6ddae8811295a2234155bd5a91eb0081a89 | refs/heads/master | 2020-06-02T13:50:08.389336 | 2019-06-10T13:49:07 | 2019-06-10T13:49:07 | 191,176,676 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,730 | py | def selectsort(arr):
for i in range(len(arr)-1):
minindex = i #记录剩余数列最小索引
for j in range(i+1,len(arr)):
if arr[minindex]>arr[j]:
minindex=j #find min numberindex
if i!=minindex: #if i!=minindex,change
arr[minindex],arr[i]=arr[i],arr[minindex]
return arr
def quickSort(arr, left=None, right=None):
left = 0 if not isinstance(left,(int, float)) else left
right = len(arr)-1 if not isinstance(right,(int, float)) else right
if left < right:
partitionIndex = partition(arr, left, right)
quickSort(arr, left, partitionIndex-1)
quickSort(arr, partitionIndex+1, right)
return arr
def partition(arr, left, right):
pivot = left
index = pivot+1
i = index
while i <= right:
if arr[i] < arr[pivot]:
swap(arr, i, index)
index+=1
i+=1
swap(arr,pivot,index-1)
return index-1
def swap(arr, i, j):
arr[i], arr[j] = arr[j], arr[i]
def mergeSort(arr):
import math
if(len(arr)<2):
return arr
middle = math.floor(len(arr)/2)
left, right = arr[0:middle], arr[middle:]
return merge(mergeSort(left), mergeSort(right))
def merge(left,right):
result = []
while left and right:
if left[0] <= right[0]:
result.append(left.pop(0));
else:
result.append(right.pop(0));
while left:
result.append(left.pop(0));
while right:
result.append(right.pop(0));
return result
if __name__=='__main__':
arr=[6,98,5,78,45,68,23,2,0]
arr1=selectsort(arr)
arr2=quickSort(arr)
arr3=mergeSort(arr)
print(arr1)
print(arr2)
print(arr3)
| [
"1785544032@qq.com"
] | 1785544032@qq.com |
409887775c7f2153c9c812f9bd69f91cda5e4045 | 5381731fe8ac0cd3326f05992c7a4345d23ea295 | /testDataCerm.py | b18e36adbe1bce7c1971a8154f310cd17fd8c4b5 | [
"MIT"
] | permissive | andreagia/peaks-identification | 2acd8a61d42a9f1fef2c17619aabeb190afe7e28 | ddcc3523f9a1154f6c2f69035dde1bfb9eac0f2a | refs/heads/main | 2023-06-14T22:59:22.797151 | 2021-07-14T15:08:51 | 2021-07-14T15:08:51 | 385,978,925 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 5,793 | py |
import argparse
from datetime import datetime
import core.proxy as proxy
import core.graphics as graphics
from core.metrics import custom_accuracy
import sys
import pathlib
from utils.peacks_testannotatedV2 import TestAnnotated as DataParser
import configparser
def run_assignment(free_protein, with_ligand_protein, out_file, plot, algorithm, labeled):
print("Free: ", free_protein)
print("With ligand: ", with_ligand_protein)
free_data_filename = pathlib.PurePath(free_protein).name.split('.csv')[0]
withligand_data_filename = pathlib.PurePath(with_ligand_protein).name.split('.csv')[0]
print("Full Paths: ", free_data_filename, withligand_data_filename)
if out_file != None:
output_filename = out_file
else:
output_filename = "#"+free_data_filename+"--"+withligand_data_filename+"--"+algorithm
# In general....
# GET DATA
# load_data()
# RUN ALGORITHM
assignemts, f_peaks, wl_peaks, ACC, w_half_size = proxy.estimate_shifts(
free_protein,
with_ligand_protein,
assignment_algorithm=algorithm,
cerm_data=False,
labeled=labeled) #
#if w_half_size != None:
# output_filename=f"w{w_half_size}"+output_filename
if out_file != None:
output_filename = out_file
else:
if w_half_size != None:
output_filename = free_data_filename + "--" + withligand_data_filename + "--" + algorithm + "[w" + str(w_half_size) +"]"
else:
output_filename = "#"+free_data_filename+"--"+withligand_data_filename+"--"+algorithm
# PROCESS RESULTS
assignemts.index.name="ResidueKey"
assignemts.to_csv(output_filename+"({:.2f}).====csv".format(ACC*100), sep=';')
P_key_list = assignemts.index.tolist()
S_key_list = assignemts['assigned_to'].tolist()
assert len(P_key_list) == len(S_key_list)
wrong = 0.
ok = 0.
for j, _ in enumerate(P_key_list):
if S_key_list[j] != 'na':
if P_key_list[j] == S_key_list[j]:
ok+=1
else:
wrong+=1
acc = ok /(ok + wrong)
print("ACC: ", ACC, "///", custom_accuracy(assignemts, 'assigned_to'), "[", acc, "]")
#print("=>", output_filename, "[", acc, "]", )
# plot()
if plot == True:
graphics.plotProfile(assignemts, free_protein, with_ligand_protein, acc=acc)
graphics.plotPeaksShifts(f_peaks, wl_peaks, assignemts, free_protein, with_ligand_protein, acc=acc)
print("fine")
def main():
# args = parser.parse_args()
from data import data_info
data_cerm__ = [
["MMP12_AHA_ref.txt", "MMP12Cat_NNGH_T1_ref_300707.txt"],
["MMP12_AHA_ref.txt", "MMP12Cat_Dive_T1_ref_peaks.txt"],
["CAIIZn_000_furo_03_170317.txt", "CAIIZn_100_furo_11_170317.txt"],
["CAIIZn_0.00_sulpiride_03_040417.txt", "CAIIZn_5mM_sulpiride_19_040417.txt"],
["CAII_Zn_000_pTulpho_03_220317.txt","CAII_Zn_100f_pTulpho_18_220317.txt"],
["CAII_Zn_000_pTS_04_291216.txt", "CAII_Zn_100_pTS_15_291216.txt"],
["CAII_Zn_000_oxalate_04_221116.txt","CAII_Zn_15mM_oxalate_31_221116.txt"],
["CAIIDM_Zn_free_T1_ref_20_081020.txt", "CAII_DM_Zn_SCN_T1_ref_051020.txt"],
["CAII_DM_Co_free_onlyAssigned.txt", "CAII_DM_Co_SCN_onlyAssigned.txt"],
]
data_cerm = [
#["MMP12_AHA_ref.csv", "MMP12Cat_NNGH_T1_ref_300707.csv"],
#["MMP12_AHA_ref.csv", "MMP12Cat_Dive_T1_ref_peaks.csv"],
["MMP12Cat_AHA_T1_ref_270510.csv", "MMP12Cat_NNGH_T1_ref_300707.csv"],
["MMP12Cat_AHA_T1_ref_270510.csv", "MMP12Cat_Dive_T1_ref_peaks.csv"],
["CAIIZn_000_furo_03_170317.csv", "CAIIZn_100_furo_11_170317.csv"],
["CAIIZn_0.00_sulpiride_03_040417.csv", "CAIIZn_5mM_sulpiride_19_040417.csv"],
["CAII_Zn_000_pTulpho_03_220317.csv","CAII_Zn_100f_pTulpho_18_220317.csv"],
["CAII_Zn_000_pTS_04_291216.csv", "CAII_Zn_100_pTS_15_291216.csv"],
["CAII_Zn_000_oxalate_04_221116.csv","CAII_Zn_15mM_oxalate_31_221116.csv"],
["CAIIDM_Zn_free_T1_ref_20_081020.csv", "CAII_DM_Zn_SCN_T1_ref_051020.csv"],
["CAII_DM_Co_free_onlyAssigned.csv", "CAII_DM_Co_SCN_onlyAssigned.csv"],
]
data_dundee = [
#['Ube2T_ref_final.csv', 'ube2t_em02_5mM_manual.csv'],
['Ube2T_ref_final.csv', 'ube2T_em11_3mM_manual.csv'],
#['Ube2T_ref_final.csv', 'ube2t_em04_3mM_manual.csv'],
#['Ube2T_ref_final.csv', 'ube2t_em09_3mM_manual.csv'],
#['Ube2T_ref_final.csv', 'ube2t_em17_3mM_final.csv'],
#['Ube2T_ref_final.csv', 'ube2t_em29_3mM_manual.csv'],
#['baz2b_phd_ref_renumbered.csv', 'baz2b_vs_5-mer_20_1_renumbered.csv'],
#['baz2a_phd_ref_renumbered.csv', 'baz2a_phd_vs_5mer_64_1_renumbered.csv'],
#['baz2a_phd_ref_renumbered.csv', 'baz2a_phd_vs_10mer_8_1_renumbered.csv'],
]
demo_data = [['free.csv', 'with_ligand.csv']]
#algorithms = ['RA', 'RASmart', 'SD', 'SDSmart']
algorithms = ['RASmart']
for dataset in data_dundee:
#for dataset in demo_data:
#data_path = data_info.cerm_csv_data_path
data_path = data_info.dundee_data_path_V2
#data_path =pathlib.Path('.')
print(dataset)
file0 = dataset[0]
file1 = dataset[1]
free_peaks_file = str(data_path.joinpath(file0))
with_ligand_peaks_file = str(data_path.joinpath(file1))
print("|| ", free_peaks_file, with_ligand_peaks_file, " ||")
for algorithm in algorithms:
run_assignment(
free_peaks_file,
with_ligand_peaks_file,
out_file=None,
plot=None,
algorithm=algorithm,
labeled=True)
if __name__ == "__main__":
#main(args)
main() | [
"andreagia71@gmail.com"
] | andreagia71@gmail.com |
d77ab181936a164cc2b79bec01dea3d8b97e01ba | 3d96cee3f0c986c7195e7677d85e91dc837d8dd4 | /Web/C/3/3.6/cookie&time.py | ae48e8747c4396422144b709d0987a0c00a3df18 | [] | no_license | dannycrief/full-stack-web-dev-couse | 7faffe1c9e6c39baf03d6ee54f716e4f8b4c8733 | 0b22bc84742d8e78bd6a2e03adfbc44137f3d607 | refs/heads/master | 2023-01-12T09:25:16.378035 | 2021-03-21T16:51:18 | 2021-03-21T16:51:18 | 220,825,261 | 0 | 1 | null | 2023-01-05T12:57:14 | 2019-11-10T17:34:02 | Python | UTF-8 | Python | false | false | 641 | py | from http import cookies
from datetime import timedelta, datetime as dt
c = cookies.SimpleCookie()
c['partial_cookie'] = 'cookie_value'
c['partial_cookie']['path'] = '/pyw/test'
c['partial_cookie']['domain'] = 'skillfactory'
c['partial_cookie']['secure'] = True
c['cookie_expiring_age'] = 'expires in 5 minutes'
c['cookie_expiring_age']['max-age'] = 300 # in seconds
c['expires_at_time'] = 'cookie_value'
time_to_live = timedelta(hours=1)
expiration = (dt(2020, 2, 26, 19, 30, 14) + time_to_live)
c['expires_at_time']['expires'] = expiration.strftime('%a, %d %b %Y %H:%M:%S')
print(c)
print('==================')
print(c.js_output())
| [
"step.kozbvb@gmail.com"
] | step.kozbvb@gmail.com |
1ab267bd5ce1be177a91b3d13e9a6f809c20cdaf | a9cbd4cf03f4688f76aadb31b4e28440b8721500 | /CToF.py | 98a1ee830782d9f09d244b25a055e990b343aa5f | [] | no_license | serdarayalp/my-python-2 | d34ff1a13e2a8815b9bb2675a4c6ad23a24f5eab | 365247dccc632e8ae1478c95ddb1b461ce175f10 | refs/heads/master | 2022-11-20T05:14:01.261712 | 2020-07-15T09:59:40 | 2020-07-15T09:59:40 | 279,831,315 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 639 | py | def F2C(nDegreesF):
nDegreesF = (nDegreesF - 32) * 0.5556
return nDegreesF
def C2F(nDegreesC):
nDegreesF = (1.8 * nDegreesC) + 32
return nDegreesF
# Code to ask the user to input values for conversion:
usersTempF = raw_input('Enter a value of degrees Fahrenheit: ')
usersTempF = float(usersTempF)
convertedTempC = F2C(usersTempF)
print usersTempF, 'degrees Fahrenheit is:', convertedTempC, 'degrees Centigrade.'
usersTempC = raw_input('Enter a value of degrees Celsius: ')
usersTempC = float(usersTempC)
convertedTempF = C2F(usersTempC)
print usersTempC, 'degrees Centigrade is:', convertedTempF, 'degrees Fahrenheit.'
| [
"serdarayalp@googlemail.com"
] | serdarayalp@googlemail.com |
1ce21dc9d1aa8d796d84bc1204654729f9075f1d | 1c06fcea2f224f6e0bc8ae5a7d05c8464d3bd37a | /offerlater/wsgi.py | 7832a15c3c82f0d46145c591d59b2d99926fe8b9 | [] | no_license | dvskhamele/extract_offer_later | e25af96ec61cf9c23702c92601cc382dc09024a6 | 39b2f7b07addd0544c799012b8ed7ba43bf0b5d8 | refs/heads/master | 2022-12-09T06:03:21.286277 | 2018-10-05T06:46:15 | 2018-10-05T06:46:15 | 151,679,583 | 0 | 0 | null | 2022-12-08T01:01:22 | 2018-10-05T06:30:53 | Python | UTF-8 | Python | false | false | 489 | py | """
WSGI config for offerlater project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "offerlater.settings")
application = get_wsgi_application()
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application) | [
"dvskha@gmail.com"
] | dvskha@gmail.com |
37cfcb9a8b85eca0a5e6047b5857d5ff3525b446 | f3f3150b0c69b2e2f7ad0d38be2a2f986cccb67a | /test_ws/devel/lib/python2.7/dist-packages/test/srv/_get_uint64.py | f80451602369877cfe9bb8ea24f2291ca7e17194 | [
"MIT"
] | permissive | kylejbrown17/factory_sim | 5a9e0c1824bd48a57dbf97ff6b403e90d19a6a39 | 9da53fb68353cd1dc497b8236913229ea53f465e | refs/heads/master | 2022-12-19T11:11:02.039999 | 2020-09-25T17:40:54 | 2020-09-25T17:40:54 | 271,893,678 | 0 | 1 | MIT | 2020-09-25T17:36:11 | 2020-06-12T21:31:31 | Makefile | UTF-8 | Python | false | false | 7,256 | py | # This Python file uses the following encoding: utf-8
"""autogenerated by genpy from test/get_uint64Request.msg. Do not edit."""
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct
class get_uint64Request(genpy.Message):
_md5sum = "fbe9700edfca44c5eefb040d9b60f6d6"
_type = "test/get_uint64Request"
_has_header = False #flag to mark the presence of a Header object
_full_text = """bool ask
"""
__slots__ = ['ask']
_slot_types = ['bool']
def __init__(self, *args, **kwds):
"""
Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
ask
:param args: complete set of field values, in .msg order
:param kwds: use keyword arguments corresponding to message field names
to set specific fields.
"""
if args or kwds:
super(get_uint64Request, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.ask is None:
self.ask = False
else:
self.ask = False
def _get_types(self):
"""
internal API method
"""
return self._slot_types
def serialize(self, buff):
"""
serialize message into buffer
:param buff: buffer, ``StringIO``
"""
try:
buff.write(_get_struct_B().pack(self.ask))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize(self, str):
"""
unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str``
"""
try:
end = 0
start = end
end += 1
(self.ask,) = _get_struct_B().unpack(str[start:end])
self.ask = bool(self.ask)
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
def serialize_numpy(self, buff, numpy):
"""
serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module
"""
try:
buff.write(_get_struct_B().pack(self.ask))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize_numpy(self, str, numpy):
"""
unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module
"""
try:
end = 0
start = end
end += 1
(self.ask,) = _get_struct_B().unpack(str[start:end])
self.ask = bool(self.ask)
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
_struct_I = genpy.struct_I
def _get_struct_I():
global _struct_I
return _struct_I
_struct_B = None
def _get_struct_B():
global _struct_B
if _struct_B is None:
_struct_B = struct.Struct("<B")
return _struct_B
# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from test/get_uint64Response.msg. Do not edit."""
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct
class get_uint64Response(genpy.Message):
_md5sum = "a2c9fb44e48f75feda2746b01055cfa1"
_type = "test/get_uint64Response"
_has_header = False #flag to mark the presence of a Header object
_full_text = """uint64 value
"""
__slots__ = ['value']
_slot_types = ['uint64']
def __init__(self, *args, **kwds):
"""
Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
value
:param args: complete set of field values, in .msg order
:param kwds: use keyword arguments corresponding to message field names
to set specific fields.
"""
if args or kwds:
super(get_uint64Response, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.value is None:
self.value = 0
else:
self.value = 0
def _get_types(self):
"""
internal API method
"""
return self._slot_types
def serialize(self, buff):
"""
serialize message into buffer
:param buff: buffer, ``StringIO``
"""
try:
buff.write(_get_struct_Q().pack(self.value))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize(self, str):
"""
unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str``
"""
try:
end = 0
start = end
end += 8
(self.value,) = _get_struct_Q().unpack(str[start:end])
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
def serialize_numpy(self, buff, numpy):
"""
serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module
"""
try:
buff.write(_get_struct_Q().pack(self.value))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize_numpy(self, str, numpy):
"""
unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module
"""
try:
end = 0
start = end
end += 8
(self.value,) = _get_struct_Q().unpack(str[start:end])
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
_struct_I = genpy.struct_I
def _get_struct_I():
global _struct_I
return _struct_I
_struct_Q = None
def _get_struct_Q():
global _struct_Q
if _struct_Q is None:
_struct_Q = struct.Struct("<Q")
return _struct_Q
class get_uint64(object):
_type = 'test/get_uint64'
_md5sum = 'd531f9d37648dc4de8bf2e757ee280a0'
_request_class = get_uint64Request
_response_class = get_uint64Response
| [
"nbhak@stanford.edu"
] | nbhak@stanford.edu |
3ef61ae75e7be03fc80f5e896e1ffcf10ecbf7b1 | e1d7b5ead35d6e40d63541d02e3320a01a581055 | /notebooks/python_recap/_solutions/03-functions86.py | c7932b9ecb04b9fb5d8f4ab3904d2d71cce53eff | [
"BSD-3-Clause"
] | permissive | drdwitte/DS-python-data-analysis | 900d9f32683e5131bd6657cd6db95b8f774afe5f | 99db9f763411ae9a67ce60f5b8cc522f5e5db85b | refs/heads/master | 2021-06-13T01:13:14.455810 | 2017-01-03T21:29:45 | 2017-01-03T21:29:45 | 110,525,200 | 1 | 0 | null | 2017-11-13T09:08:55 | 2017-11-13T09:08:55 | null | UTF-8 | Python | false | false | 289 | py | def check_for_jey(checkdict, key):
"""
Function checks the presence of key in dictionary checkdict and returns an
exception if the key is already used in the dictionary
"""
if key in checkdict.keys():
raise Exception('Key already used in this dictionary') | [
"jorisvandenbossche@gmail.com"
] | jorisvandenbossche@gmail.com |
18eef5b11da13adcaf8b1e287316af1f56aec07e | 8e1cb50bcd1a152ab9d934486c36aee2a2859af4 | /src/libzip/Build.py | fc0882610af4394efb4888d1d62e7cfbf6a9a9f3 | [
"BSD-2-Clause",
"MIT"
] | permissive | sspiff/narvi | 6a7c10a323bd5a61a3e39f44808ccff03286f73f | aa56529f15be197422b23a6804040ab6d7255162 | refs/heads/master | 2021-05-15T02:35:18.435615 | 2016-08-27T18:28:25 | 2016-08-27T18:28:25 | 24,562,894 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,848 | py | #!/usr/bin/python
# Copyright (c) 2014, Brian Boylston
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@build_step('libzip', ['libcontents'], ['zipcontents'])
def build_libzip(build):
libzipfile = os.path.join(build.objroot, 'libzip', 'lib.zip')
print '\tCreating', libzipfile[len(build.sandboxroot)+1:], '...'
os.mkdir(os.path.dirname(libzipfile))
libzip = zipfile.ZipFile(libzipfile, 'w', zipfile.ZIP_DEFLATED)
for k in sorted(build.libcontents.keys()):
print '\t\t' + k
libzip.write(build.libcontents[k], k)
libzip.close()
build.zipcontents['pwhash/lib.zip'] = libzipfile
| [
"sspiff@users.noreply.github.com"
] | sspiff@users.noreply.github.com |
f7e26e7cc3c402d6b46829e91abc8e1b195e5296 | 564cf0465e12cc41a7b0b17490207aff44c320d8 | /sciwing/datasets/sprinkle_dataset.py | c5371e3c3131116f3660de2786659a5f604749fe | [
"MIT"
] | permissive | yaxche-io/sciwing | 7a329f323ab8623953081eb487e643a7cd045a09 | cb4c1413ddc3c749835e1cb80db31c0060e7a1eb | refs/heads/master | 2021-01-02T12:38:50.268422 | 2019-09-12T12:46:57 | 2019-09-12T12:46:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 7,727 | py | from typing import List, Optional
import collections
import inspect
from sciwing.datasets.classification.base_text_classification import (
BaseTextClassification,
)
from sciwing.numericalizer.numericalizer import Numericalizer
from sciwing.vocab.vocab import Vocab
from sciwing.tokenizers.word_tokenizer import WordTokenizer
from sciwing.tokenizers.character_tokenizer import CharacterTokenizer
import copy
import wrapt
import wasabi
class sprinkle_dataset:
def __init__(self, vocab_pipe=None, autoset_attrs=True, get_label_stats_table=True):
if vocab_pipe is None:
vocab_pipe = ["word_vocab"]
self.autoset_attrs = autoset_attrs
self.vocab_pipe = vocab_pipe
self.is_get_label_stats_table = get_label_stats_table
self.wrapped_cls = None
self.init_signature = None
self.filename = None
self.word_tokenization_type = None
self.word_tokenizer = None
self.word_instances = None
self.word_vocab = None
self.max_num_words = None
self.word_vocab_store_location = None
self.word_embedding_type = None
self.word_embedding_dimension = None
self.word_numericalizer = None
self.word_unk_token = None
self.word_pad_token = None
self.word_start_token = None
self.word_end_token = None
self.char_tokenizer = None
self.char_instances = None
self.char_vocab = None
self.max_num_chars = None
self.char_vocab_store_location = None
self.char_embedding_type = None
self.char_embedding_dimension = None
self.char_numericalizer = None
self.char_unk_token = None
self.char_pad_token = None
self.char_start_token = None
self.char_end_token = None
self.word_vocab_required_attributes = [
"max_num_words",
"word_vocab_store_location",
"word_embedding_type",
"word_embedding_dimension",
]
def set_word_vocab(self):
if not all(
[
attribute in dir(self)
for attribute in self.word_vocab_required_attributes
]
):
raise ValueError(
f"For building word vocab, "
f"please pass these attributes in your "
f"dataset construction {self.word_vocab_required_attributes}"
)
self.word_instances = self.word_tokenizer.tokenize_batch(self.lines)
self.word_vocab = Vocab(
instances=self.word_instances,
max_num_tokens=self.max_num_words,
unk_token=self.word_unk_token,
pad_token=self.word_pad_token,
start_token=self.word_start_token,
end_token=self.word_end_token,
store_location=self.word_vocab_store_location,
embedding_type=self.word_embedding_type,
embedding_dimension=self.word_embedding_dimension,
)
self.word_numericalizer = Numericalizer(self.word_vocab)
self.word_vocab.build_vocab()
self.word_vocab.print_stats()
def set_char_vocab(self):
self.char_instances = self.char_tokenizer.tokenize_batch(self.lines)
self.char_vocab = Vocab(
instances=self.char_instances,
max_num_tokens=1e6,
min_count=1,
store_location=self.char_vocab_store_location,
embedding_type=self.char_embedding_type,
embedding_dimension=self.char_embedding_dimension,
start_token=self.char_start_token,
end_token=self.char_end_token,
unk_token=self.char_unk_token,
pad_token=self.char_pad_token,
)
self.char_vocab.build_vocab()
# adding these to help conversion to characters later
self.char_vocab.add_tokens(
list(self.word_start_token)
+ list(self.word_end_token)
+ list(self.word_unk_token)
+ list(self.word_pad_token)
)
self.char_numericalizer = Numericalizer(vocabulary=self.char_vocab)
self.char_vocab.print_stats()
def _get_label_stats_table(self):
all_labels = []
for label in self.labels:
all_labels.extend(label.split())
labels_stats = dict(collections.Counter(all_labels))
classes = list(set(labels_stats.keys()))
classes = sorted(classes)
header = ["label index", "label name", "count"]
classname2idx = self.wrapped_cls.get_classname2idx()
rows = [
(classname2idx[class_], class_, labels_stats[class_]) for class_ in classes
]
formatted = wasabi.table(data=rows, header=header, divider=True)
return formatted
@wrapt.decorator
def __call__(self, wrapped, instance, args, kwargs):
self.wrapped_cls = wrapped
self.init_signature = inspect.signature(wrapped.__init__)
instance = wrapped(*args, **kwargs)
for idx, (name, param) in enumerate(self.init_signature.parameters.items()):
if name == "self":
continue
# These are values that must be passed
if name in [
"filename",
"dataset_type",
"max_num_words",
"max_instance_length",
"word_vocab_store_location",
]:
try:
value = args[idx]
except IndexError:
try:
value = kwargs[name]
except KeyError:
raise ValueError(
f"Dataset {self.cls.__name__} should be instantiated with {name}"
)
if self.autoset_attrs:
setattr(instance, name, value)
setattr(self, name, value)
# These can be passed but have default values
else:
try:
value = args[idx]
except IndexError:
try:
value = kwargs[name]
except KeyError:
value = param.default
if self.autoset_attrs:
setattr(instance, name, value)
setattr(self, name, value)
# set the lines and labels
self.lines, self.labels = instance.get_lines_labels(self.filename)
self.word_instances = None
self.word_vocab = None
if "word_vocab" in self.vocab_pipe:
self.word_tokenizer = WordTokenizer(self.word_tokenization_type)
self.set_word_vocab()
instance.word_tokenizer = self.word_tokenizer
instance.word_numericalizer = self.word_numericalizer
instance.word_vocab = copy.deepcopy(self.word_vocab)
instance.word_instances = copy.deepcopy(self.word_instances)
instance.num_instances = len(self.word_instances)
instance.instance_max_len = max(
[len(instance) for instance in self.word_instances]
)
if "char_vocab" in self.vocab_pipe:
self.char_tokenizer = CharacterTokenizer()
self.set_char_vocab()
instance.char_vocab = copy.deepcopy(self.char_vocab)
instance.char_instances = copy.deepcopy(self.char_instances)
instance.char_tokenizer = self.char_tokenizer
instance.char_numericalizer = self.char_numericalizer
if self.is_get_label_stats_table:
label_stats_table = self._get_label_stats_table()
instance.label_stats_table = label_stats_table
return instance
| [
"abhinav@comp.nus.edu.sg"
] | abhinav@comp.nus.edu.sg |
600eb46ce513ad28968d7a0a1e1228186929b87e | 5d2a748bd9db8c52a4defa730b8cf0d8fd2c2ed8 | /app.py | 019812b1f903261da7ea02668ebd4c3f51df7b2f | [] | no_license | motheesh/MLOPS_DVC | e3ee6f5415744cb4828c2d216ffcc8e06468e8cc | d5286fc38adf55d73284c2fc1ca3450619c5213e | refs/heads/main | 2023-07-28T09:48:00.926151 | 2021-09-17T17:47:29 | 2021-09-17T17:47:29 | 407,207,317 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,172 | py | from flask import Flask, request, render_template,jsonify,abort,g
from flask_cors import CORS, cross_origin
import config
import pandas as pd
from src.get_data import get_params
import joblib
app=Flask(__name__)
CORS(app)
app.config.from_pyfile("config.py")
@app.route("/", methods=["GET", "POST"])
def index():
labels=['fixed_acidity','volatile_acidity',
'citric_acid','residual_sugar',
'chlorides','free_sulfur_dioxide',
'total_sulfur_dioxide','density',
'pH','sulphates','alcohol']
return render_template("index.html",labels=labels)
@app.route("/predict" , methods=['POST'])
def predict():
try:
req_data=request.get_json()
df=pd.json_normalize(req_data)
params=get_params(config.params_path)
predict_model_path=params["webapp_model_dir"]["model_path"]
prediction_model=joblib.load(predict_model_path)
result=round(prediction_model.predict(df)[0],2)
return jsonify({"result":result})
except Exception as e:
return jsonify({"status":"error","error":e,"message":"Something went wrong please try again"})
if __name__=="__main__":
app.run(port=5000,debug=config.debug) | [
"motheesh96@gmail.com"
] | motheesh96@gmail.com |
2de3d4571e2e86b45aab6ec7a44b115910821e99 | b4bf4d79787f030c46620dcbd9e602e29ba90b25 | /scripts/git-feedback.py | 67c92e15bf1699b73ac51c02a85ba31278f9430f | [
"MIT"
] | permissive | earthlab/autograding-notebooks | 41eee6f6005cd45099d52983d600635b24fd0a73 | a244fcff035c4c4e21b4cc288d0fbedab63b9b80 | refs/heads/master | 2020-05-19T03:38:50.706611 | 2019-08-21T16:10:15 | 2019-08-21T16:10:15 | 184,807,148 | 1 | 1 | MIT | 2019-09-18T00:36:02 | 2019-05-03T19:06:01 | Jupyter Notebook | UTF-8 | Python | false | false | 2,729 | py | #!/usr/bin/env python3
# Script to copy nbgrader html feedback reports to feedback.html in student
# repos and push repos to github
# Based on script provided by @jedbrown
# Assumes that cwd is nbgrader course dir
import glob
import pandas as pd
import os
import shutil
import subprocess
def run_cmd(cmd,cmdargs,dry_run):
if (dry_run):
cmdargs.insert(1,'--dry-run')
print(cmd+cmdargs)
# note that commit when there aren't any changes will produce a
# non-zero exit code (even with dry-run)
subprocess.check_output(cmd + cmdargs)
def do_git_things(destdir, dest, dry_run):
gitcmd = ['git', '-C', destdir]
try:
# add
cmdargs = ['add', os.path.basename(dest)]
run_cmd(gitcmd,cmdargs,dry_run)
# commit
cmdargs = ['commit', '-mAdd feedback.html']
run_cmd(gitcmd,cmdargs,dry_run)
# push
cmdargs = ['push']
run_cmd(gitcmd,cmdargs,dry_run)
except subprocess.CalledProcessError as e:
print(e.output)
print('Skipping {}'.format(destdir))
def read_roster(filename):
roster = pd.read_csv(args.roster, usecols=('identifier', 'github_username')).set_index('identifier')
return roster
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--roster', help='CSV roster file', default='roster.csv')
parser.add_argument('--assignment', help='Name of assignment, e.g., hw1-rootfinding', required=True)
parser.add_argument('--clonedir', help='Destination directory', default='../cloned-repos')
parser.add_argument('-n', '--dry-run', help='Print git statements but do not run', action='store_true')
args = parser.parse_args()
assignment = args.assignment
clonedir = args.clonedir
roster = read_roster(args.roster)
for identikey, (github_username,) in roster.iterrows():
try:
#print("Looking in: {}".format(os.path.join('feedback', identikey, assignment)))
(source,) = glob.glob(os.path.join('feedback', identikey, assignment, '*.html'),recursive=True)
except ValueError: # Lack of feedback usually means student did not submit homework
print("No feedback found for {}".format(identikey))
continue
slug = "{}-{}".format(assignment,github_username)
destdir = os.path.join(clonedir, slug)
dest = os.path.join(destdir, 'feedback.html')
if os.path.exists(destdir):
print("Copying feedback from {} to {}".format(source,dest))
shutil.copyfile(source, dest)
else:
print('Destination directory does not exist: {}'.format(destdir))
do_git_things(destdir, dest, args.dry_run)
| [
"karen.cranston@gmail.com"
] | karen.cranston@gmail.com |
f06f88a96b52a6621019922f4da89a89ad78cfa6 | 4ac716ab21a95e5fd9f3ba21660b930a4fa81d1b | /src/tweetme/settings/base.py | 76345e48ea607c13224ce84a84fcdb815b0ecf89 | [] | no_license | kodeartisan/tweetus | b5a971a8cb1d67215eec8daccd200c76b40a3087 | 9f3f6ecc94a3c5ea16f82f69d85422046d79d495 | refs/heads/master | 2021-01-20T05:18:57.769368 | 2017-04-29T23:40:19 | 2017-04-29T23:40:19 | 89,769,481 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,116 | py | """
Django settings for tweetme project.
Generated by 'django-admin startproject' using Django 1.10.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*1h*3q6_%w())u3-ob+^@tyzwl49ru%v)y0n!7n3d%_&dy#6ii'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'tweetme.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'tweetme.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
| [
"kodeartisan@gmail.com"
] | kodeartisan@gmail.com |
e85a57fb3eb1ae24cf981201425f8807771c5477 | ca121f98fbf91cdbfe788dd3c80c627f3e3900b5 | /km-51/Meliukh_Viktoriia/project/site/main.py | 51a9b926dc0236c6e4ae1e511ccdd1c6d27e7483 | [] | no_license | VikMelyh/dbisworkshops | 36f74f931774e46b1704dc1a5c3e5e7c3c63ee3a | 95e5c1c13d2fe090357a4554fa0a70caff238517 | refs/heads/master | 2020-04-05T19:13:19.530719 | 2018-12-26T20:58:56 | 2018-12-26T20:58:56 | 157,124,295 | 0 | 1 | null | 2018-11-11T21:46:27 | 2018-11-11T21:46:26 | null | UTF-8 | Python | false | false | 7,200 | py | from flask import Flask, render_template, request, make_response, redirect, url_for, flash
from Booking import Booking
from Classroom import Classroom
from User import User
from Lesson import Lesson
from Housing import Housing
from Seat import Seat
from BookingForUser import BookingForUser
from logic.user_validation import get_user_by_id, validate, user_exist, validate_registration, create_user, \
get_bookings_byuser_id, find_classrooms, get_all_users_info, get_all_unch_users, delete_user_bookings, \
edit_user_bookings, check_user_email, create_booking, validate_book_creation, delete_user_func, create_classroom, \
edit_classroom, delete_classroom, get_lessons_data, get_housing_numbers_data, get_number_of_seats_data, \
get_user_id_data, get_lesson_id_by_number, get_user_by_name
from form.register_form import RegisterForm
import json
app = Flask(__name__)
app.secret_key = 'development key'
@app.route('/')
def index():
user_login = request.cookies.get('userID')
if user_login:
return render_template('search_page.html')
else:
return render_template('index.html')
@app.route('/login', methods=['POST'])
def login():
user_login = request.form['login']
user_pass = request.form['pass']
if user_login == 'admin':
if user_pass == '123':
return redirect(url_for('get_all_user_datas'))
# user validation here
user = get_user_by_name(user_login)
if not user:
return render_template('index.html')
if user[6] == 0:
flash('Your account is not verified yet')
return redirect(url_for('index'))
if validate(user, user_pass):
resp = make_response(render_template('search_page.html'))
resp.set_cookie('userID', user_login)
return resp
return render_template('index.html')
@app.route('/logout')
def logout():
resp = make_response(redirect(url_for('index')))
resp.set_cookie('userID', '', expires=0)
return resp
@app.route('/register', methods=['GET', 'POST'])
def register():
form = RegisterForm(request.form)
if request.method == 'GET':
return render_template('register.html', form=form)
else:
if not form.validate():
flash('incorrect data input')
return render_template('register.html', form=form)
form_data = request.form
if validate_registration(form_data):
create_user(form_data)
return render_template('check_page.html')
else:
flash('User with dis email already exist')
return render_template('register.html', form=form)
@app.route('/search')
def search_page():
return render_template('search_form_page.html')
# @app.route('/editbookings')
# def edit_personal_bookings():
# return render_template('edit_personal_bookings.html')
@app.route('/bookingconfirm')
def booking_confirmation():
user_login = request.cookies.get('userID')
if not user_login:
render_template('index.html')
user_id = get_user_id_data(user_login)
user = get_user_by_id(user_id)
booking = request.args
res = [[], []]
res[0] = user
res[1] = booking
return render_template('booking_confirm.html', res=res)
@app.route('/confirmsuccess')
def confirm_success():
return render_template('confirm_success.html')
@app.route('/bookingdeleted')
def booking_deleted():
return render_template('booking_deleted.html')
# ---------------------------------------------------------- 'api'
# ----------------------- user booking crud
@app.route('/bookingsbyuser')
def allbookings():
user_login = request.cookies.get('userID')
if not user_login:
render_template('index.html')
user_id = get_user_id_data(user_login)
res = get_bookings_byuser_id(user_id)
result_list = []
for r in res:
result_list.append(BookingForUser(r).__dict__)
return render_template('edit_personal_bookings.html', res=result_list)
@app.route('/deletebooking')
def delete_user_booking():
params = request.args['id']
delete_user_bookings(params)
return json.dumps('OK')
@app.route('/editbooking')
def edit_user_booking():
params = request.args
edit_user_bookings(params)
return json.dumps('OK')
@app.route('/book')
def booking():
user_login = request.cookies.get('userID')
if not user_login:
render_template('index.html')
user_id = get_user_id_data(user_login)
bok = request.args
lesson_id = get_lesson_id_by_number(bok['l_num'])
t = validate_book_creation(bok, lesson_id)
if t:
create_booking(bok, user_id, lesson_id)
return json.dumps('OK')
else:
return json.dumps('ALREADY EXISTS')
@app.route('/findclassrooms')
def find():
criterias = request.args
classrooms = find_classrooms(criterias)
res = []
for r in classrooms:
res.append(Classroom(r).__dict__)
return json.dumps(res, default=str)
# @app.route('/bookingconfirm')
# def booking_confirm():
@app.route('/displaysearchresult')
def display_search():
criterias = request.args
classrooms = find_classrooms(criterias)
res = [[], []]
res[1] = criterias
for r in classrooms:
res[0].append(Classroom(r).__dict__)
return render_template('display_search.html', res=res)
@app.route('/lessonsdata')
def lessons_data():
les = get_lessons_data()
res = []
for l in les:
res.append(Lesson(l).__dict__)
return json.dumps(res)
@app.route('/gethousingnumbers')
def get_housing_numbers():
housing = get_housing_numbers_data()
res = []
for h in housing:
res.append(Housing(h).__dict__)
return json.dumps(res)
@app.route('/getnumberofseats')
def get_number_of_seats():
seats = get_number_of_seats_data()
res = []
for s in seats:
res.append(Seat(s).__dict__)
return json.dumps(res)
# ----------------------------- admin users crud
@app.route('/getalluserdata')
def get_all_user_datas():
users_data = get_all_users_info()
res = []
for u in users_data:
res.append(User(u).__dict__)
return render_template('admin_page.html', res=res)
@app.route('/getalluncheckedusers')
def get_all_unchecked():
data = get_all_unch_users()
res = []
for u in data:
res.append(User(u).__dict__)
return json.dumps(res)
@app.route('/checkuser')
def check_user():
user_id = request.args['id']
check_user_email(user_id)
return json.dumps('OK')
# delete user
@app.route('/deleteuser')
def delete_user():
user_id = request.args['id']
delete_user_func(user_id)
return json.dumps('deleted')
# create classroom
@app.route('/createclassroom')
def create_class_room():
classroom = request.args
create_classroom(classroom)
return json.dumps('CREATED')
# edit classroom
@app.route('/editclassroom')
def edit_class_room():
classroom = request.args
edit_classroom(classroom)
return json.dumps('OK')
# delete classroom
@app.route('/deleteclassroom')
def delete_class_room():
c_id = request.args['id']
delete_classroom(c_id)
return json.dumps('deleted')
if __name__ == '__main__':
app.run(debug=True)
| [
"0433vikla@gmail.com"
] | 0433vikla@gmail.com |
41baf4b78a342fb0201c70320d7ad17137fe3707 | e23a4f57ce5474d468258e5e63b9e23fb6011188 | /125_algorithms/_examples/_algorithms_challenges/pybites/topics/pytest/246/test_workouts.py | a258bfe876e0aa72bb19381255b6aca8ca6de9ba | [] | no_license | syurskyi/Python_Topics | 52851ecce000cb751a3b986408efe32f0b4c0835 | be331826b490b73f0a176e6abed86ef68ff2dd2b | refs/heads/master | 2023-06-08T19:29:16.214395 | 2023-05-29T17:09:11 | 2023-05-29T17:09:11 | 220,583,118 | 3 | 2 | null | 2023-02-16T03:08:10 | 2019-11-09T02:58:47 | Python | UTF-8 | Python | false | false | 542 | py | import pytest
from workouts import print_workout_days
@pytest.mark.parametrize("arg, expected", [
('#', 'Mon, Tue, Thu, Fri\n'),
('30', 'Wed\n'),
('30 min', 'Wed\n'),
('cardio', 'Wed\n'),
('#1', 'Mon, Tue\n'),
('#2', 'Thu, Fri\n'),
('upper', 'Mon, Thu\n'),
('lower', 'Tue, Fri\n'),
('body', 'Mon, Tue, Thu, Fri\n'),
('khoo', 'No matching workout\n')
])
def test_print_workout_days(capfd, arg, expected):
print_workout_days(arg)
output = capfd.readouterr()[0]
assert output == expected | [
"sergejyurskyj@yahoo.com"
] | sergejyurskyj@yahoo.com |
3eb74c1abb66a86e7d626e33b478916afc4ea177 | 676dd5cc6454f17df4e421316c6ec389097a33f0 | /oddnumber.py | 756858cab94a3b99cc1adfa717c136d1cd1d9d73 | [] | no_license | Habiba171998/python-programming | 3078fdb93169a308abb62ed632523b8da8256547 | de2aa4bb440c773721ff5292a4794b5a6f9a50b6 | refs/heads/master | 2021-04-06T19:33:53.621743 | 2019-02-06T09:43:26 | 2019-02-06T09:43:26 | 124,640,550 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 97 | py | lower=int(input())
upper=int(input())
for i in range(lower,upper+1):
if(i%2!=0):
print(i)
| [
"noreply@github.com"
] | Habiba171998.noreply@github.com |
6f3406ba10c19ac118420f8b347f2dffced2e3cb | 2a814b1b23735fdd6e3976d655f25eb73ebb8ee2 | /cycic/baselines/random-baseline/random_baseline.py | dcd95a5296f891c2c1222e68773afdf1f62497c7 | [
"Apache-2.0"
] | permissive | allenai/mosaic-leaderboard | fa3f04a3940e95d19be860858be3bdeccdc26d6f | 4bd26c732ebb85aba7a62b3170dadbb0fedf5179 | refs/heads/master | 2023-08-03T12:00:43.462223 | 2022-08-03T16:38:14 | 2022-08-03T16:38:14 | 176,200,213 | 20 | 5 | Apache-2.0 | 2023-07-06T22:01:30 | 2019-03-18T03:46:27 | Jupyter Notebook | UTF-8 | Python | false | false | 1,476 | py | import argparse
import json
from typing import List
import random
# Parse the input file from JSONL to a list of dictionaries.
def read_jsonl_lines(input_file: str) -> List[dict]:
with open(input_file) as f:
lines = f.readlines()
return [json.loads(l.strip()) for l in lines]
choices_by_question_type = {
"multiple choice": ["0", "1", "2", "3", "4"],
"true/false": ["0", "1"],
"true/false/unknown": ["0", "1", "2"]
}
def main(input_file, output_file):
# Read the records from the test set.
test_records = read_jsonl_lines(input_file)
# Make predictions for each example in the test set.
predicted_answers = [random.choice(choices_by_question_type[r['questionType']]) for r in test_records]
# Write the predictions to the output file.
with open(output_file, "w") as f:
for p in predicted_answers:
f.write(p)
f.write("\n")
f.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='A random baseline.')
parser.add_argument('--input-file', type=str, required=True, help='Location of test records', default=None)
parser.add_argument('--output-file', type=str, required=True, help='Location of predictions', default=None)
args = parser.parse_args()
print('====Input Arguments====')
print(json.dumps(vars(args), indent=2, sort_keys=True))
print("=======================")
main(args.input_file, args.output_file)
| [
"chandrab@allenai.org"
] | chandrab@allenai.org |
081f788bef03adc37b7381ec2236b5677aa06bfb | bbd8761bb4b2f1e69b5b8fe931b426a2edd76c01 | /Introduction to Python/lesson1/task1/hello_world.py | 7845e0eb023e194e3411dc764809a060a15b7930 | [] | no_license | DmitryTsybulkin/intro-to-python | 59b79829af421aa016597a75021ca7f3447ffa39 | ddf672acf0de634798ee650ca73085ed35f17660 | refs/heads/master | 2020-04-27T22:30:11.578689 | 2019-09-13T14:06:23 | 2019-09-13T14:06:23 | 174,739,275 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 42 | py | print("Hello, world! My name is Dimitry")
| [
"tsydimasik@gmail.com"
] | tsydimasik@gmail.com |
bc22e6b3ec5d94bad43b94ae603221e809296b50 | d689675f6af44e0228a88ca67bdc890a4c462732 | /sokoban.py.dir/levels.py | a13051d295ac643ac0c1c70fad57d2fff5197692 | [] | no_license | lukacslacko/minecraft_plugins | c6219709180cd3910df9b110b157fc4aa0bd4975 | c8d45f3a1cf9469e754c87eb3e0b8c95f820c703 | refs/heads/master | 2020-04-13T23:34:05.117289 | 2019-02-16T12:29:50 | 2019-02-16T12:29:50 | 163,510,017 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 4,489 | py | # Source: http://borgar.net/programs/sokoban
levels = {
'tutorial': [
'+++++ ',
'+* + ',
'+ +O+++',
'+ O ..+',
'+++++++',
],
'level1': [
' +++++ ',
' + + ',
' +O + ',
' +++ O++ ',
' + O O + ',
'+++ + ++ + ++++++',
'+ + ++ +++++ ..+',
'+ O O ..+',
'+++++ +++ +*++ ..+',
' + +++++++++',
' +++++++ ',
],
'level2': [
'++++++++++++ ',
'+.. + +++',
'+.. + O O +',
'+.. +O++++ +',
'+.. * ++ +',
'+.. + + O ++',
'++++++ ++O O +',
' + O O O O +',
' + + +',
' ++++++++++++',
],
'level3': [
' ++++++++ ',
' + *+ ',
' + O+O ++ ',
' + O O+ ',
' ++O O + ',
'+++++++++ O + +++',
'+.... ++ O O +',
'++... O O +',
'+.... ++++++++++',
'++++++++ ',
],
'jr1-level1': [
'+++++++',
'+. .+',
'+ O +',
'+ O*O +',
'+ O +',
'+. .+',
'+++++++',
],
'jr1-level2': [
'+++++++++',
'+. .+',
'+ + + +',
'+ O +',
'+ O*O +',
'+ O +',
'+ + + +',
'+. .+',
'+++++++++',
],
'jr1-level3': [
'+++++++',
'+. .+',
'+.OOO.+',
'++O*O++',
'+.OOO.+',
'+. .+',
'+++++++',
],
'jr1-level4': [
'+++++++',
'+. .+',
'+ O*O +',
'+ +++ +',
'+ O O +',
'+. .+',
'+++++++',
],
'jr1-level5': [
'+++++++',
'+. O .+',
'+ O*O +',
'+. O .+',
'+++++++',
],
'jr1-level6': [
' +++++ ',
'++. .++',
'+.OOO.+',
'+ O*O +',
'+.OOO.+',
'++. .++',
' +++++ ',
],
'jr1-level7': [
'+++++++',
'+. O..+',
'+. O +',
'+OO+OO+',
'+ *O .+',
'+..O .+',
'+++++++',
],
'jr1-level8': [
'++++++++',
'+. O .+',
'+.OOOO.+',
'+. *O .+',
'++++++++',
],
'jr1-level9': [
'+++++++++',
'+. .+',
'+ + + +',
'+ .OOO. +',
'+ O*O +',
'+ .OOO. +',
'+ + + +',
'+. .+',
'+++++++++',
],
}
# Returns the start position of the player
def generate(level, x, y, z, wall, box, target, floor, ceiling, air, sender):
world = sender.getWorld()
loc = sender.getLocation()
start = None
for row in enumerate(level):
for col in enumerate(row[1]):
loc.setX(x + row[0])
loc.setY(y)
loc.setZ(z + col[0])
if col[1] == ' ' or col[1] == '*':
world.getBlockAt(loc).setType(floor)
loc.setY(y+3)
world.getBlockAt(loc).setType(ceiling)
loc.setY(y+1)
world.getBlockAt(loc).setType(air)
loc.setY(y+2)
world.getBlockAt(loc).setType(air)
if col[1] == '*':
start = [x + row[0], y, z + col[0]]
elif col[1] == '.':
world.getBlockAt(loc).setType(target)
loc.setY(y+3)
world.getBlockAt(loc).setType(ceiling)
loc.setY(y+1)
world.getBlockAt(loc).setType(air)
loc.setY(y+2)
world.getBlockAt(loc).setType(air)
elif col[1] == 'O':
world.getBlockAt(loc).setType(floor)
loc.setY(y+3)
world.getBlockAt(loc).setType(ceiling)
loc.setY(y+1)
world.getBlockAt(loc).setType(box)
loc.setY(y+2)
world.getBlockAt(loc).setType(air)
elif col[1] == '+':
world.getBlockAt(loc).setType(floor)
loc.setY(y+3)
world.getBlockAt(loc).setType(ceiling)
loc.setY(y+1)
world.getBlockAt(loc).setType(wall)
loc.setY(y+2)
world.getBlockAt(loc).setType(air)
return start
| [
"root@mc-spigot.europe-west4-a.c.minecraft-server-226616.internal"
] | root@mc-spigot.europe-west4-a.c.minecraft-server-226616.internal |
8188d0335bfd2c141d5aae25769dee38fb007541 | 80de7c4f2f53f6866e4ea76ebbde238835589c80 | /main.py | e88f0d78a6a5f57e8a81bea7698157bf266fad45 | [] | no_license | TCHEN621130/CarEnvision | 57e2cbf1fc235461fea2bedc073ba463fe008fdb | 4035e499e6a16d7c5c45bd98d1f1e13bd6d87773 | refs/heads/main | 2023-01-14T05:26:08.619481 | 2020-11-17T05:38:52 | 2020-11-17T05:38:52 | 303,492,108 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,132 | py | from flask import Flask, render_template, url_for, request
import requests
from textblob import TextBlob
#ML Packages
from sklearn.linear_model import Ridge
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/",methods=['POST'])
def predict():
inputData = [
#2011 2012 2013 2014 2015
[0.27, 0.2, 0.26, 0.33, 0.21], #2016 Toyota
[0.2, 0.26, 0.33, 0.21, 0.3], #2017
[0.26, 0.33, 0.21, 0.3, 0.35], #2018
[0.33, 0.21, 0.3, 0.35, 0.25], #2019
[0.21, 0.3, 0.35, 0.25, 0.33], #2020
[0.34, 0.33, 0.33, 0.35, 0.42], #2016 Lexus
[0.33, 0.33, 0.35, 0.42, 0.31], #2017
[0.33, 0.35, 0.42, 0.31, 0.36], #2018
[0.35, 0.42, 0.31, 0.36, 0.27], #2019
[0.42, 0.31, 0.36, 0.27, 0.11], #2020
[0.29, 0.38, 0.37, 0.44, 0.44], #2016 Mercedes
[0.38, 0.37, 0.44, 0.44, 0.38], #2017
[0.37, 0.44, 0.44, 0.38, 0.36], #2018
[0.44, 0.44, 0.38, 0.36, 0.32], #2019
[0.44, 0.38, 0.36, 0.32, 0.33], #2020
[0.38, 0.41, 0.28, 0.39, 0.38], #2016 AUDI
[0.41, 0.28, 0.39, 0.38, 0.37], #2017
[0.28, 0.39, 0.38, 0.37, 0.36], #2018
[0.39, 0.38, 0.37, 0.36, 0.42], #2019
[0.38, 0.37, 0.36, 0.42, 0.49], #2020
]
#value = currentPrice/releasePrice
outputData = [48, 47, 56, 85, 101, 67, 61, 71, 89, 101, 44, 53, 73, 75, 100, 34, 42, 60, 73, 101]
mlModel = make_pipeline(PolynomialFeatures(3), Ridge())
mlModel.fit(inputData, outputData)
if request.method == 'POST':
brand = request.form['brand'].lower()
model = request.form['model'].lower()
year = int(request.form['year'])
prediction = []
num = 6
#This loop will get every sentiment percentage from each year
for i in range(1, 6):
num = num - 1
url = "https://www.cars.com/research/" + str(brand) + "-" + str(model) + "-" + str(year - i) + "/consumer-reviews/"
print(url)
page = requests.get(url)
message = str(page.content)
score = 0
count = 0
begin = ""
end = ""
while 'card-text">' in message and '</p>' in message:
index1 = message.index('card-text">') + 11
index2 = message.index('</p>') - 2
s = message[index1:index2]
if s != "":
text = TextBlob(s)
print(s)
print()
score += text.sentiment.polarity
count += 1
print(count)
message = message[index2 + 4:]
avgSentiment = score/count
prediction.append(avgSentiment)
finalPredict = mlModel.predict([prediction])
my_prediction = str(finalPredict[0])[0:5] + "% of total retail price in " + str(year + 1) + "."
return render_template('results.html',prediction = my_prediction, brand = brand, model = model, year = year)
app.run(host="0.0.0.0")
| [
"noreply@github.com"
] | TCHEN621130.noreply@github.com |
18ccce646421cdd13c411dbab51d011ea580a100 | 0736073dc4cb1cd058538904e5b803c7a8bae4be | /venv/bin/pip-2.7 | a7212c0a276a2129ea20d0ed7dbfd15266970796 | [] | no_license | fraferra/angelhack | 869db14434e38deb752e914874f1b1629e68e493 | 25b7a9464f4907db3b914f9db8882bf9e964f896 | refs/heads/master | 2020-06-04T03:00:37.765388 | 2013-11-22T22:45:17 | 2013-11-22T22:45:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 298 | 7 | #!/home/fraferra/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.1','console_scripts','pip-2.7'
__requires__ = 'pip==1.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==1.1', 'console_scripts', 'pip-2.7')()
)
| [
"fraferra@cisco.com"
] | fraferra@cisco.com |
c81b6eeca4426b2b7bb6e550af9c778542b3b4ab | c71bdf7d24207c2a39c3ad7be3ede1043be81569 | /utils/image.py | 9a4ddf4ce5674186c56cbb1999696d6b912ee04f | [
"MIT"
] | permissive | Red-Eyed/dnn_models | 72056b621e7d6e186c6993edfcdfa951e985b9b9 | 66bee227e66e5432cf5ddecdc6cd18f5dcf372ba | refs/heads/master | 2020-04-10T09:55:17.578256 | 2019-09-10T09:56:58 | 2019-09-10T09:56:58 | 160,950,653 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 207 | py | import numpy as np
def max_min_norm(array: np.ndarray):
return (array - array.min()) / (array.max() - array.min())
def image_norm(img):
return (max_min_norm(img) * 255).round(0).astype(np.uint8)
| [
"vadim.stupakov@gmail.com"
] | vadim.stupakov@gmail.com |
c84347836205fcd31ebaa82214093bae97ef308a | daf0fe52ec118bf5f20781ecb2761ae5a797814d | /Godkendt kode/LightUp-r.py | 92b8d9dd86e00b6cc4d5468765067092484e460e | [] | no_license | ijji123/SaMo | 33963fdbc9cb6fb93bea78d59256dba0d437b455 | 9c75be60e55936095be0c3cce0b2bc714a936e7b | refs/heads/main | 2023-01-31T01:52:56.063621 | 2020-12-15T09:50:15 | 2020-12-15T09:50:15 | 303,104,772 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 201 | py | import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, True)
print("LED on")
time.sleep(3)
GPIO.output(18, False)
print("LED off")
| [
"noreply@github.com"
] | ijji123.noreply@github.com |
8d1d88a92305dd5d7d7bc32e3fb518ce472ad83c | 9d48d012d24ee6dc3b51c6b977be3dc1d79dfe55 | /CodeEval Challenges/checkBitPositions.py | 5e27ec959700b70f2d8acc4956ca516cd7bd9b79 | [
"MIT"
] | permissive | mailpraveens/Python-Experiments | 4a3a83a63a5397d58f3780c4f1a9dbb4803bf2dc | 0107fb30c7b3071009d37cb74d1e53de87d28231 | refs/heads/master | 2016-09-06T18:08:05.386595 | 2014-08-03T17:54:45 | 2014-08-03T17:54:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 462 | py | import sys
def check_bit_positions(n, p1, p2):
"""Checks if the first two digits of n match p1 and p2."""
binary = '{0:b}'.format(n)
if list(binary)[-p1] == list(binary)[-p2]:
print "true"
else:
print "false"
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
if not test == '\n':
#Get the two numbers, and call the method
n,a,b = [int(elem) for elem in test.split(',')]
check_bit_positions(n,a,b)
test_cases.close() | [
"mailpraveens@gmail.com"
] | mailpraveens@gmail.com |
abedf9f4625a77c24290df3049a6955779ab6452 | 1f52a776039be1b1b0bfbdffcf54668bd31205f8 | /Morse code converter.py | 02f43036c18f70870e9e0002a21cd65d0f12713f | [] | no_license | cyborgtowel/edabitproblems | d3f9eea63fb3690582d38b1fa8c272a71bb4d36a | 96dd6ecb1ba85f9788763d82c66178e0b9d72eaf | refs/heads/main | 2023-01-31T08:25:13.632673 | 2020-12-16T11:36:07 | 2020-12-16T11:36:07 | 318,176,901 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,059 | py | #Morse code converter
char_to_dots = {
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----',
'1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',
':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-',
'-': '-....-', '+': '.-.-.', '"': '.-..-.', '?': '..--..', '/': '-..-.'
}
def encode_morse(string):
morse = ''
for letter in string:
value = ord(letter)
if value >= 97 and value <= 122:
value -= 32
letter = chr(value)
if letter in char_to_dots:
morse += char_to_dots[letter] + ' '
return morse | [
"noreply@github.com"
] | cyborgtowel.noreply@github.com |
ea900577260c2521ec76f9b29686b81ea4e1632b | f734a39a0c37186e90caea597f13000823c9e67a | /leetcode/Linked List/876. Middle of the Linked List.py | 13dc5d4c1476c4d359650a53375ea3f50e48e9f1 | [
"MIT"
] | permissive | yanshengjia/algorithm | 681746e0371a82860e64a279bfe4c83545469641 | 46caaf74aeab8af74861fb5b249eb4169baf8493 | refs/heads/master | 2022-08-02T20:15:57.927418 | 2022-07-17T14:43:51 | 2022-07-17T14:43:51 | 192,160,418 | 69 | 32 | null | null | null | null | UTF-8 | Python | false | false | 1,192 | py | """
Given a non-empty, singly linked list with head node head, return a middle node of linked list.
If there are two middle nodes, return the second middle node.
Example 1:
Input: [1,2,3,4,5]
Output: Node 3 from this list (Serialization: [3,4,5])
The returned node has value 3. (The judge's serialization of this node is [3,4,5]).
Note that we returned a ListNode object ans, such that:
ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, and ans.next.next.next = NULL.
Example 2:
Input: [1,2,3,4,5,6]
Output: Node 4 from this list (Serialization: [4,5,6])
Since the list has two middle nodes with values 3 and 4, we return the second one.
Solution:
1. Output to Array
2. Fast and Slow pointers
"""
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
# Fast and Slow pointers
# One pass
# Time: O(N), >27%, where N is the length of the linked list
# Space: O(1)
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
fast, slow = head, head
while fast != None and fast.next != None:
fast = fast.next.next
slow = slow.next
return slow | [
"i@yanshengjia.com"
] | i@yanshengjia.com |
d3435b52488699116cf716d391c5465987ff63d4 | 56c85c6e597e3343847a3d59c499f82edea58292 | /mpi_SN.py | 65dd54bc5af7377d56b3a42e763b916a54811b0c | [] | no_license | chrisfrohmaier/Monte_Carlos | 9f659593de520a46de86a328c7272099668e55dd | 65394a7f44343eb64efcd359809e591517a429d9 | refs/heads/master | 2020-05-20T08:18:59.833438 | 2015-01-12T18:06:06 | 2015-01-12T18:06:06 | 29,144,301 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 6,469 | py | #Test
from mpi4py import MPI
import matplotlib
matplotlib.use('Agg')
import numpy as np
import matplotlib.pyplot as plt
from astropy.cosmology import FlatLambdaCDM
from matplotlib.patches import Circle
from shapely.geometry import Polygon, Point
from descartes.patch import PolygonPatch
from astropy.time import Time
import subprocess, brewer2mpl, math, sncosmo, psycopg2
colors = brewer2mpl.get_map('Set3', 'Qualitative', 12).mpl_colors
import time as TI
##Connecting to the Database
conn = psycopg2.connect(host='srv01050.soton.ac.uk', user='frohmaier', password='rates', database='frohmaier')
cur = conn.cursor()
conn2 = psycopg2.connect(host='srv01050.soton.ac.uk', user='frohmaier', password='rates', database='frohmaier')
cur2=conn2.cursor()
conn3 = psycopg2.connect(host='srv01050.soton.ac.uk', user='frohmaier', password='rates', database='frohmaier')
cur3 = conn3.cursor()
cur.execute("SELECT DISTINCT ON (ujd) ujd from obs ORDER BY ujd;")
d=cur.fetchall()
dates=[]
for i in range(len(d)):
dates.append([int(i), float(d[i][0])])
all_data=np.array(dates)
#print all_data
cur.close()
def Create_Date_Array(peak_date,date_array):
date_a, index=Find_Nearest_Date(peak_date,date_array)
Sn_Dates=[]
min_array, min_date_index=Find_Nearest_Date(peak_date-19,date_array)
max_array, max_date_index=Find_Nearest_Date(peak_date+51, date_array)
for i in range(min_date_index,max_date_index):
#print i
Sn_Dates.append(date_array[i][1])
return Sn_Dates
def Find_Nearest_Date(date_ujd,nupy_array):
idx=(np.abs(nupy_array[:,1]-date_ujd)).argmin()
#print 'Index: ', idx
return nupy_array[idx], idx
def Random_Gen_RA_DEC_MJD(date):
Good=False
while Good==False:
RA=np.random.uniform(-0.52,-0.452)
DEC=np.random.uniform(-0.350,-0.278)
cord=Point(RA,DEC)
area_p=Polygon([(-0.482, -0.350),(-0.453, -0.331),(-0.48722712, -0.2789),(-0.516, -0.2972)])
if cord.within(area_p)==True:
Peak_Date=np.random.uniform(min(date[:,1])-50,max(date[:,1])+20)
Good=True
return RA, DEC, Peak_Date
def pol_2_cart(ra,dec):
ra_r=np.radians(ra)
dec_r=np.radians(dec)
x=np.cos(dec_r)*np.cos(ra_r)#*math.sin(math.pi/2.0-dec_r)
#y=math.sin(ra_r)*math.sin(math.pi/2.0-dec_r)
y=np.cos(dec_r)*np.sin(ra_r)
#print x,y
return x,y
def cart_2_pol(x,y):
ra_r=np.arctan(y/x)
dec_r=np.arccos(np.sqrt(y**2. + x**2.))
ra=np.degrees(ra_r)
dec=np.degrees(dec_r)
return ra+180., dec
def which_ccd(ujd, ra, dec):
cur2.execute("SELECT * from obs where ujd=%s;",(float(ujd),))
m=cur2.fetchall()
for ln in m:
ujd=float(ln[0])
seeing_new=float(ln[1])
ub1_zp_new=float(ln[2])
lmt_mag_new=float(ln[3])
ccdid=int(ln[4])
goodpixarea=float(ln[5])
ra_ul=float(ln[6])
dec_ul=float(ln[7])
x_ul,y_ul=pol_2_cart(ra_ul,dec_ul)
ra_ur=float(ln[8])
dec_ur=float(ln[9])
x_ur,y_ur=pol_2_cart(ra_ur,dec_ur)
ra_lr=float(ln[10])
dec_lr=float(ln[11])
x_lr,y_lr=pol_2_cart(ra_lr,dec_lr)
ra_ll=float(ln[12])
dec_ll=float(ln[13])
x_ll,y_ll=pol_2_cart(ra_ll,dec_ll)
ccd_polygon=Polygon([(x_ul,y_ul),(x_ur,y_ur),(x_lr,y_lr),(x_ll,y_ll)])
sn_object= Point((ra, dec))
if ccd_polygon.contains(sn_object)==True:
return ccdid, 1-(goodpixarea/0.6603)
return 99.9, 1.
bpass=np.loadtxt('PTF48R.dat')
wavelength=bpass[:,0]
transmission=bpass[:,1]
band=sncosmo.Bandpass(wavelength,transmission, name='ptf48r')
sncosmo.registry.register(band, force=True)
def Gen_SN(peak_time, redshift, colour,x_1, date):
source=sncosmo.get_source('salt2',version='2.4') #Importing SALT2 Model
model=sncosmo.Model(source=source)
alpha=0.141
beta=3.101
int_dis=np.random.normal(0.,0.15)
mabs= -19.05 - alpha*x_1 + beta*colour + int_dis
model.set(z=redshift,t0=peak_time,x1=x_1, c=colour) #Setting redshift
model.set_source_peakabsmag(mabs,'bessellb','ab', cosmo=FlatLambdaCDM(H0=70,Om0=0.3)) #Fixing my peak absolute magnitude
#model.set(x1=x_1, c=colour)
band=sncosmo.get_bandpass('ptf48r') #Retrieving the ptf48r bandpass
time=Create_Date_Array(peak_time,date) #setting an arbitrary time span to cover the model
maglc=model.bandmag('ptf48r','ab',time) #Creating a magnitude array of the lightcurve
fluxlc=model.bandflux('ptf48r',time) #Creating a flux array of the lightcurve
absmagb=model.source_peakabsmag('bessellb','ab', cosmo=FlatLambdaCDM(H0=70,Om0=0.3))
absmag_r=model.source_peakabsmag('ptf48r','ab', cosmo=FlatLambdaCDM(H0=70,Om0=0.3))
return peak_time, time, maglc, fluxlc, absmagb, absmag_r, redshift, colour, x_1, int_dis #returns
nproc = MPI.COMM_WORLD.Get_size()
# number of processes
my_rank = MPI.COMM_WORLD.Get_rank()
# The number/rank of this process
my_node = MPI.Get_processor_name()
# Node where this MPI process runs
N_MODELS_TOTAL = 1000 # total number of models to run
n_models = N_MODELS_TOTAL / nproc
# number of models for each thread
my_nmin = (my_rank * n_models)
my_nmax = my_nmin + n_models
time_init = TI.time()
for i in range( my_nmin, my_nmax):
ra,dec,peak_date=Random_Gen_RA_DEC_MJD(all_data)
xone=np.random.uniform(-3.0,3.0)
color=np.random.uniform(-0.3,0.3)
zedshift=np.random.uniform(0.0,0.1)
ra1,dec1=cart_2_pol(ra,dec)
#print zedshift
peak_time, time, maglc, fluxlc, absmagb, absmag_r, redshift, colour, x_1, int_dis=Gen_SN(peak_date, zedshift, color,xone, all_data)
##Inserting the Values into the sne table
#print 'Doing CCD Shit'
probs=[]
t_ccd=[]
for j in range(0,len(time)):
#print time[i]
#this_ccd, not_detect_prob=which_ccd(time[j], ra, dec)
probs.append(0)
t_ccd.append(this_ccd)
#print this_ccd
#print probs
total_prob_not=np.prod(probs)
cur = conn.cursor()
#print maglc, time
cur.execute("INSERT INTO sne (peak_date, ra, dec, absolute_mag, redshift, x1, color, int_dispersion, prob_not) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s) returning sn_id",(peak_time,ra1,dec1,absmag_r,redshift,x_1, colour, int_dis,total_prob_not))
sn_id=cur.fetchone()
print 'This is the SN ID: ', sn_id[0]
for k in range(0, len(time)):
cur3.execute("INSERT INTO sim_epoch (sn_id, ujd, ra, dec, magnitude, ccd, prob_not_detected) VALUES (%s,%s,%s,%s,%s,%s,%s)", (sn_id[0], float(time[k]), ra1, dec1, maglc[k], t_ccd[k], probs[k]))
conn3.commit()
#print len(time), len(probs)
#print 'Total Not Prob: ', total_prob_not
conn.commit()
time2 = TI.time()
time_tot = time2 - time_init
# always call this when finishing up
MPI.Finalize()
cur.close()
cur2.close()
cur3.close()
conn.close()
conn2.close()
conn3.close()
print "Time to do 10 million:", time_tot
| [
"cf5g09@cyan03.(none)"
] | cf5g09@cyan03.(none) |
ebd0ac1291f69956d047a9776759e5741c301ee7 | 93022749a35320a0c5d6dad4db476b1e1795e318 | /issm/solve.py | 6f9568eb7b81f3043ed44d1722203d67d58f6351 | [
"BSD-3-Clause"
] | permissive | pf4d/issm_python | 78cd88e9ef525bc74e040c1484aaf02e46c97a5b | 6bf36016cb0c55aee9bf3f7cf59694cc5ce77091 | refs/heads/master | 2022-01-17T16:20:20.257966 | 2019-07-10T17:46:31 | 2019-07-10T17:46:31 | 105,887,661 | 2 | 3 | null | null | null | null | UTF-8 | Python | false | false | 5,652 | py | import datetime
import os
import shutil
from issm.pairoptions import pairoptions
from issm.ismodelselfconsistent import ismodelselfconsistent
from issm.marshall import marshall
from issm.waitonlock import waitonlock
from issm.loadresultsfromcluster import loadresultsfromcluster
def solve(md,solutionstring,*args):
"""
SOLVE - apply solution sequence for this model
Usage:
md=solve(md,solutionstring,varargin)
where varargin is a list of paired arguments of string OR enums
solution types available comprise:
- 'Stressbalance' or 'sb'
- 'Masstransport' or 'mt'
- 'Thermal' or 'th'
- 'Steadystate' or 'ss'
- 'Transient' or 'tr'
- 'Balancethickness' or 'mc'
- 'Balancevelocity' or 'bv'
- 'BedSlope' or 'bsl'
- 'SurfaceSlope' or 'ssl'
- 'Hydrology' or 'hy'
- 'DamageEvolution' or 'da'
- 'Gia' or 'gia'
- 'Sealevelrise' or 'slr'
extra options:
- loadonly : does not solve. only load results
- checkconsistency : 'yes' or 'no' (default is 'yes'), ensures checks on consistency of model
- restart: 'directory name (relative to the execution directory) where the restart file is located.
Examples:
md=solve(md,'Stressbalance');
md=solve(md,'sb');
"""
#recover and process solve options
if solutionstring.lower() == 'sb' or solutionstring.lower() == 'stressbalance':
solutionstring = 'StressbalanceSolution';
elif solutionstring.lower() == 'mt' or solutionstring.lower() == 'masstransport':
solutionstring = 'MasstransportSolution';
elif solutionstring.lower() == 'th' or solutionstring.lower() == 'thermal':
solutionstring = 'ThermalSolution';
elif solutionstring.lower() == 'st' or solutionstring.lower() == 'steadystate':
solutionstring = 'SteadystateSolution';
elif solutionstring.lower() == 'tr' or solutionstring.lower() == 'transient':
solutionstring = 'TransientSolution';
elif solutionstring.lower() == 'mc' or solutionstring.lower() == 'balancethickness':
solutionstring = 'BalancethicknessSolution';
elif solutionstring.lower() == 'bv' or solutionstring.lower() == 'balancevelocity':
solutionstring = 'BalancevelocitySolution';
elif solutionstring.lower() == 'bsl' or solutionstring.lower() == 'bedslope':
solutionstring = 'BedSlopeSolution';
elif solutionstring.lower() == 'ssl' or solutionstring.lower() == 'surfaceslope':
solutionstring = 'SurfaceSlopeSolution';
elif solutionstring.lower() == 'hy' or solutionstring.lower() == 'hydrology':
solutionstring = 'HydrologySolution';
elif solutionstring.lower() == 'da' or solutionstring.lower() == 'damageevolution':
solutionstring = 'DamageEvolutionSolution';
elif solutionstring.lower() == 'gia' or solutionstring.lower() == 'gia':
solutionstring = 'GiaSolution';
elif solutionstring.lower() == 'slr' or solutionstring.lower() == 'sealevelrise':
solutionstring = 'SealevelriseSolution';
else:
raise ValueError("solutionstring '%s' not supported!" % solutionstring)
options=pairoptions('solutionstring',solutionstring,*args)
#recover some fields
md.private.solution=solutionstring
cluster=md.cluster
if options.getfieldvalue('batch','no')=='yes':
batch=1
else:
batch=0;
#check model consistency
if options.getfieldvalue('checkconsistency','yes')=='yes':
print "checking model consistency"
ismodelselfconsistent(md)
#First, build a runtime name that is unique
restart=options.getfieldvalue('restart','')
if restart == 1:
pass #do nothing
else:
if restart:
md.private.runtimename=restart
else:
if options.getfieldvalue('runtimename',True):
c=datetime.datetime.now()
md.private.runtimename="%s-%02i-%02i-%04i-%02i-%02i-%02i-%i" % (md.miscellaneous.name,c.month,c.day,c.year,c.hour,c.minute,c.second,os.getpid())
else:
md.private.runtimename=md.miscellaneous.name
#if running qmu analysis, some preprocessing of dakota files using models
#fields needs to be carried out.
if md.qmu.isdakota:
md=preqmu(md,options)
#Do we load results only?
if options.getfieldvalue('loadonly',False):
md=loadresultsfromcluster(md)
return md
#Write all input files
marshall(md) # bin file
md.toolkits.ToolkitsFile(md.miscellaneous.name+'.toolkits') # toolkits file
cluster.BuildQueueScript(md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof,md.qmu.isdakota,md.transient.isoceancoupling) # queue file
#Stop here if batch mode
if options.getfieldvalue('batch','no')=='yes':
print 'batch mode requested: not launching job interactively'
print 'launch solution sequence on remote cluster by hand'
return md
#Upload all required files:
modelname = md.miscellaneous.name
filelist = [modelname+'.bin ',modelname+'.toolkits ',modelname+'.queue ']
if md.qmu.isdakota:
filelist.append(modelname+'.qmu.in')
if not restart:
cluster.UploadQueueJob(md.miscellaneous.name,md.private.runtimename,filelist)
#Launch job
cluster.LaunchQueueJob(md.miscellaneous.name,md.private.runtimename,filelist,restart,batch)
#wait on lock
if md.settings.waitonlock>0:
#we wait for the done file
islock=waitonlock(md)
if islock==0: #no results to be loaded
print 'The results must be loaded manually with md=loadresultsfromcluster(md).'
else: #load results
print 'loading results from cluster'
md=loadresultsfromcluster(md)
#post processes qmu results if necessary
if md.qmu.isdakota:
if not strncmpi(options['keep'],'y',1):
shutil.rmtree('qmu'+str(os.getpid()))
return md
| [
"cummings.evan@gmail.com"
] | cummings.evan@gmail.com |
a5ceb6f80537f70a81d040c035f117f32ca3ae68 | fa0d3f4f013519d2fae720fb3f5e41f809ec57da | /58city/test.py | 657612af1f54c9ebe9744cac0b5bad57813dab46 | [] | no_license | mktsyy/codes | e722fa0ae690cdfded3f3ba0299022f82613e18b | f7a49fa49b943e3111ba290c960624c8df5989f0 | refs/heads/master | 2021-01-10T06:44:25.093477 | 2019-01-16T15:34:54 | 2019-01-16T15:34:54 | 52,073,390 | 1 | 2 | null | null | null | null | UTF-8 | Python | false | false | 645 | py | #-*-coding:utf-8-*-
from pynput.mouse import Button, Controller
import time
import win32clipboard as w
import win32con
from controlKeyboard import doKeyboard,altUp,down,enter,LaoGongTV,ctrlTab,ctrlW,space,ctrlV,keyFill,ctrlShiftI
mouse = Controller()
def setText(aString):
w.OpenClipboard()
w.EmptyClipboard()
w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
w.CloseClipboard()
for i in range(100):
mouse.position = (1702,1006)
mouse.click(Button.left,1)
time.sleep(0.5)
codes = '''
document.getElementsByClassName("p-txt")[%s].innerText;
''' % str(i)
setText(codes)
ctrlV()
# time.sleep(2)
enter() | [
"mktsyy@gmail.com"
] | mktsyy@gmail.com |
ac41a5b9c7adf355884bd7205ef75b79508e0bea | 4b1e4894323a62c584ae3e62e2f382d786b25bce | /utils.py | dd47b644b2a3b9ca2e2b032155d3ff957db88ac3 | [] | no_license | slensgra/subvideo_capture | c62c2999147a2a7a8ab27d62c61d86a80f6ade63 | 7714785aedceacfc967d8d14d857bd67f5413ced | refs/heads/master | 2022-06-20T04:52:00.253741 | 2020-05-12T15:32:37 | 2020-05-12T15:32:37 | 263,377,618 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 2,701 | py | import cv2
import numpy
import argparse
import sys
def initialize_argument_parser():
parser = argparse.ArgumentParser(description="Displays and saves a subvideo of a given video stream (file, or ROS topic)")
parser.add_argument("--width", type=int, required=True, help="Width of the subvideo in the original video")
parser.add_argument("--height", type=int, required=True, help="Height of the subvideo in the original video")
parser.add_argument("--min_corner_x", type=int, required=True, help="X coordinate of the minimum corner of the view window")
parser.add_argument("--min_corner_y", type=int, required=True, help="Y coordinate of the minimum corner of the view window")
parser.add_argument("--scale_factor", type=int, required=True, help="Each pixel in the original image is expanded to a scale_factor by scale_factor square in the expanded image.")
parser.add_argument("--outfile", type=str, help="Output the expanded video stream to this file")
parser.add_argument("--directory", type=str, help="Directory to pull frame files from. Used by subvideo_from_files.py. Must end in a '/'")
parser.add_argument("--file_regex", type=str, help="Regex used to select files from the given directory. Used by subvideo_from_files.py")
parser.add_argument("--topic", type=str, help="ROS topic to pull images from. Used by subvideo_from_ROS.py")
return parser
def draw_corners(image, corners, color, min_corner_x, min_corner_y, width, height, scale_factor):
for corner in corners:
if all(corner >= numpy.array([min_corner_x, min_corner_y])):
if all(corner < numpy.array([min_corner_x + width, min_corner_y + height])):
corner_scaled = corner - numpy.array([min_corner_x, min_corner_y])
corner_scaled = float(scale_factor) * corner_scaled
cv2.circle(image, tuple(map(int, corner_scaled)), 2, color, 2)
def cut_and_scale_image(raw_image, min_corner_x, min_corner_y, width, height, scale_factor, unrefined_corners=None, refined_corners=None):
cropped_image = raw_image[min_corner_y:min_corner_y+height, min_corner_x:min_corner_x+width]
scaled_image = cv2.resize(
cropped_image,
(scale_factor*width, scale_factor*height),
interpolation=cv2.INTER_NEAREST
)
scaled_image_color = scaled_image
if unrefined_corners is not None:
draw_corners(scaled_image, unrefined_corners, (255, 0, 255), min_corner_x, min_corner_y, width, height, scale_factor)
if refined_corners is not None:
draw_corners(scaled_image, refined_corners, (255, 0, 0), min_corner_x, min_corner_y, width, height, scale_factor)
return scaled_image_color
| [
"sam.lensgraf@gmail.com"
] | sam.lensgraf@gmail.com |
94f4c30e67ba04994fc431d78aff167bbd09e15d | d920018c7b7760ef6d170c1485041bcbb079216d | /kryptos/rc4-web-step.py | de57a490aafc07447200966caf8d577683a0bbae | [] | no_license | nutty-guineapig/htb-pub | 36cb2dd1ba5f40689618212f5de6fa8ebcbd69ce | d9706a40af44fa48f931b5eb0910627e726d4ea5 | refs/heads/master | 2021-06-10T00:10:02.015756 | 2021-06-02T05:51:23 | 2021-06-02T05:51:23 | 181,233,445 | 0 | 0 | null | 2021-04-20T16:14:11 | 2019-04-13T22:06:18 | Python | UTF-8 | Python | false | false | 2,501 | py | #!/usr/bin/python3
#-- RC4 Decryptor script --
# After step 1 re: Injection on the connection string and making the server authenticate against a database that we own
# We are presented with a page that lets you encrypt a file in either modes AES or RC4. The file input is a # remote URL.
# Objective: Can we decrypt remote files, then can we decrypt whatever is on http:/127.0.0.1 from enumeration
# Issue: After encrypting multiple files in rc4, we see that the the ciphertext is always the same
# This indiciates that the keystream is being reused and always starts from the beginning
# So we can do the following:
# Standard use case - p1 xor keystream = c1
# Then store c1 in a file
# Since keystream is reused then we can do c1 xor keystream = p1
# script will just replay encrypted content
# Create a directory "files" eg /htb/kryptos/files
# this will be used to hold our encrypted content
import requests as req
import sys
from bs4 import BeautifulSoup
import base64
import urllib.parse
ip = myip
port = myport
#take cookie first from first arg
cookieValue = sys.argv[1]
#take url to send from second arg
urlForFile = sys.argv[2]
#set cookie
cookies = {'PHPSESSID': cookieValue}
#static url of endpoint
urlToRequest = 'http://10.10.10.129/encrypt.php?cipher=RC4&url='
#our url we gonna request also for safety lets url encode
finalUrl = urlToRequest+urllib.parse.quote(urlForFile)
print (finalUrl)
#make the requests
r = req.get(finalUrl, cookies=cookies)
#lets parse the response
soup = BeautifulSoup(r.text, 'html.parser')
b64output = soup.find(id='output')
encryptedContents = b64output.contents[0]
#base64 decode and save to file in files/test5.txt
try:
file_content = base64.b64decode(encryptedContents)
with open("files/test5.txt", "wb+") as f:
f.write(file_content)
f.close()
except Exception as e:
print (str(e))
#make a new request to retrieve the file (test5.txt) -- this will effectively decrypt whatever we initially requested since the keystream is reused.. and we're xoring ciphertext with keystream, producing the plaintext
test5Url = urlToRequest+'http://' + ip +':' + port+ '/test5.txt'
r2 = req.get(test5Url, cookies=cookies)
#now lets beautify the contents, since it'll prob be html
soup = BeautifulSoup(r2.text, 'html.parser')
b64output = soup.find(id='output')
b64DecryptedContents = b64output.contents[0]
decryptedContents = BeautifulSoup(base64.b64decode(b64DecryptedContents), 'html.parser')
print (decryptedContents.prettify())
| [
"37027195+guineapiggy@users.noreply.github.com"
] | 37027195+guineapiggy@users.noreply.github.com |
4abdb96cfed188337be3daf7218afd40e08e0611 | 50b88d55bd2cecd177eedb9bfe3b9c2703b99bfe | /data_processing/frame_randomizer.py | b6f6984b9c05d7a788f977f2cf19bffeae4b6e56 | [
"MIT"
] | permissive | djpetti/isl-gazecapture | a6f271bf4d29f3a6a6e82faca4ce01f467709137 | de0d955d25640facc5d72099fa92a4391643b405 | refs/heads/master | 2021-04-27T20:25:13.045132 | 2019-01-31T05:44:22 | 2019-01-31T05:44:22 | 122,378,447 | 12 | 5 | MIT | 2019-01-31T05:44:23 | 2018-02-21T18:50:18 | Java | UTF-8 | Python | false | false | 1,958 | py | import random
class FrameRandomizer(object):
""" Class that stores and randomizes frame data. """
def __init__(self):
# Create dictionary of sessions.
self.__sessions = []
self.__total_examples = 0
# This is a list of indices representing all sessions in the dataset in
# random order.
self.__random_sessions = None
def __build_random_sessions(self):
""" Builds the random sessions list after all sessions have been added. """
self.__random_sessions = []
for i, session in enumerate(self.__sessions):
self.__random_sessions.extend([i] * session.num_valid())
# Shuffle the data in the session.
session.shuffle()
# Shuffle all of them.
random.shuffle(self.__random_sessions)
def add_session(self, session):
""" Add data for one session.
Args:
session: The session to add. """
self.__total_examples += session.num_valid()
self.__sessions.append(session)
def get_random_example(self):
""" Draws a random example from the session pool. It raises a ValueError if
there is no more data left.
Returns:
The next random example, including the features and extracted face crop,
in the following order: crop, bytes features, float features, int
features. """
if self.__random_sessions is None:
# Build the session pick list.
self.__build_random_sessions()
if (len(self.__sessions) == 0 or len(self.__random_sessions) == 0):
# No more data.
raise ValueError("Session pool has no more data.")
# First, pick a random session.
session_key = self.__random_sessions.pop()
session = self.__sessions[session_key]
# Now, pick a random example from within that session.
crop, bytes_f, float_f, int_f = session.get_random()
return (crop, bytes_f, float_f, int_f)
def get_num_examples(self):
"""
Returns:
The total number of examples. """
return self.__total_examples
| [
"djpetti@gmail.com"
] | djpetti@gmail.com |
ff93a47c3ed1b221744bcd2ee5b4762dbbf4ae78 | b73535890e08bc087be1fbf809cc9c4b87f894da | /Assignment1/Assessment1.py | 4f6130eecba2043206be8d386dbc197da74e6084 | [] | no_license | lumpop1/CP1404PRAC | 848761ce55a4e5fa857fd2f86e3c5b1abc9afdbb | af0fbb7b098ada0dc33a5cf67b17def7d065b1f8 | refs/heads/master | 2020-04-09T11:17:39.422805 | 2019-01-08T05:40:42 | 2019-01-08T05:40:42 | 160,304,507 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,410 | py | import csv
import pandas
csvFile=open("temp.csv", "r")
reader = csv.reader(csvFile)
content = []
for line in csvFile:
print(line)
def main():
Songs = pandas.read_csv('temp.csv')
print("Songs To Learn 1.0 - by Jianjian Chen \n", len(Songs.index), "Ward songs loaded")
choseMenu = str(input('Menu:''\nL - List songs''\nA - Add new song''\nC - Complete a song''\nQ - Quit')).upper()
judgemenu(choseMenu)
def judgemenu(choseMenu):
while choseMenu != 'L' and choseMenu != 'A' and choseMenu != 'C' and choseMenu != 'Q':
print('Invalid menu choice.')
choseMenu = str(input('Menu:''\nL - List songs''\nA - Add new song''\nC - Complete a song''\nQ - Quit')).upper()
while choseMenu == 'L':
import pandas
list1 = pandas.read_csv('temp.csv',usecols=[0,1,2,3])
list1['Learned'].fillna((' '),inplace=True)
print(list1)
print(len(list1[list1['Learned']==' ']),'songs learned',len(list1[list1['Learned']=='*']),'songs still to learn')
choseMenu = str(input('Menu:''\nL - List songs''\nA - Add new song''\nC - Complete a song''\nQ - Quit')).upper()
judgemenu(choseMenu)
while choseMenu == 'A':
import csv
title = input("Title: ")
while title == "":
title = input("Input can not be blank\nTitle: ")
artist = input("Artist: ")
while artist == "":
artist = input("Input can not be blank\nArtist: ")
year = input("Year: ")
while year.isalpha():
print("Invalid input; enter a valid number")
year = input("Year: ")
while int(year) <= 0:
print("Number must be >= 0")
year = input("Year: ")
required = "n"
Learned = '*'
if Learned=='*':
required='y'
New_song = [Learned,title, artist, year, required]
Songs_csv = open("temp.csv", "a", newline="")
writer = csv.writer(Songs_csv)
writer.writerow(New_song)
Songs_csv.close()
print(title, "by", artist, "(", year, ") added to song list")
choseMenu = str(input('Menu:''\nL - List songs''\nA - Add new song''\nC - Complete a song''\nQ - Quit')).upper()
judgemenu(choseMenu)
while choseMenu == 'C':
import pandas
df = pandas.read_csv('temp.csv')
if '*' in list(df['Learned']):
chose_num = input('Enter the number of a song to mark as learned')
if chose_num:
print('Input can not be blank,try again')
chose_num = int(input('Enter the number of a song to mark as learned'))
elif chose_num < 0:
print('Input can not be blank,try again')
chose_num = int(input('Enter the number of a song to mark as learned'))
df.iat[chose_num,0]=' '
df.to_csv("temp.csv", index=False)
print(df.iat[chose_num,1],'learned')
else:
print('No more songs to learn')
choseMenu = str(input('Menu:''\nL - List songs''\nA - Add new song''\nC - Complete a song''\nQ - Quit')).upper()
judgemenu(choseMenu)
while choseMenu=='Q':
import pandas
Songs = pandas.read_csv('temp.csv')
print(len(Songs.index), "saved to temp.csv"'\nHave a nice day :)')
exit()
main() | [
"noreply@github.com"
] | lumpop1.noreply@github.com |
05214e0e4aa20a963f23b7faae9d5bcd0c55f0cf | 1d3bb895bc989e326e0c7b96c2a9c03d7c6627e2 | /src/api/test/setup_tests.py | 9ca69c09db57d4cf7db81f99222da12b9ed79aa1 | [] | no_license | jyrihogman/todo-app | a80bef1fe61aa54af2d267e2055dc7da21366463 | e41fdf6fdddbeffd7990429c80eb31ccd45cc474 | refs/heads/main | 2023-04-06T21:20:05.696029 | 2021-04-25T21:15:05 | 2021-04-25T21:15:05 | 356,906,822 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,576 | py | import boto3
import json
TABLE_NAME = "Todos"
uuids = []
def get_todos():
with open("db.json") as json_file:
return json.load(json_file)["todos"]
def create_table():
dynamo = boto3.client("dynamodb")
dynamo.create_table(
TableName=TABLE_NAME,
AttributeDefinitions=[
{
'AttributeName': 'Id',
'AttributeType': 'S'
},
{
'AttributeName': 'IdRange',
'AttributeType': 'N'
},
],
KeySchema=[
{
'AttributeName': 'Id',
'KeyType': 'HASH'
},
{
'AttributeName': 'IdRange',
'KeyType': 'RANGE'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
for num, todo in enumerate(get_todos()):
dynamo.put_item(
TableName=TABLE_NAME,
Item={
"Id": {
"S": f"testing_id_{num}"
},
"IdRange": {
"N": todo["idRange"]
},
"Title": {
"S": todo["title"]
},
"Description": {
"S": todo["description"]
},
"IsDone": {
"BOOL": todo["isDone"]
},
"Date": {
"S": todo["date"]
}
}
)
| [
"jyrihogman@gmail.com"
] | jyrihogman@gmail.com |
99c67e0451761edd9fd8566c1c5826773bf6b3ec | 96ebb8cd58b36e07ad9f01a79e8e3b1bce1e3649 | /manage.py | 7986b77abb2c448407eb2b016900dbddf2b35487 | [] | no_license | mbanot/stanview | b0a1f23bf7b277d9a2f72fd4c0ca2d7684b04d3d | 81fb7638db3eabf6399dba11b94182229e49ee5f | refs/heads/master | 2023-03-13T10:52:00.782310 | 2021-03-04T14:08:54 | 2021-03-04T14:08:54 | 344,492,115 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 662 | py | #!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'zolapp.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
| [
"tmmmbano@gmail.com"
] | tmmmbano@gmail.com |
638c8184e37f2a7596cc64bea241a41383f168fa | 4ee78f0e8db8f8d814896c635be0449961119ddf | /parameter.py | 6aa73dba5c84f86b556588b1f7ccf1df603a8723 | [] | no_license | DerrickPikachu/MyFirstGAN | 5552b4eaa2cd4bf6a06f1dc45a9c4310891c53f5 | 61bf37ebdfc69e6f3d060e4af01ed0ee269abd05 | refs/heads/master | 2023-07-17T20:25:31.816755 | 2021-08-23T17:19:04 | 2021-08-23T17:19:04 | 398,039,781 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 842 | py | import torch.cuda
from torch import nn, optim
# Root directory for dataset
dataroot = "data/celeba"
# Number of workers for dataloader
workers = 1
# Batch size during training
batch_size = 32
# Spatial size of training images. All images will be resized to this
# size using a transformer.
image_size = 64
# Number of channels in the training images. For color images this is 3
nc = 3
# Size of z latent vector (i.e. size of generator input)
nz = 100
# Size of feature maps in generator
ngf = 64
# Size of feature maps in discriminator
ndf = 64
# Number of training epochs
num_epochs = 100
# Learning rate for optimizers
lr = 0.0002
# Beta1 hyperparam for Adam optimizers
beta1 = 0.5
# Number of GPUs available. Use 0 for CPU mode.
ngpu = 1
device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu") | [
"derrfgh4563@gmail.com"
] | derrfgh4563@gmail.com |
1b7677a54be603036724e7d67f128e87baee3d5d | 4bba68477b57ccbd9e8c3bf1622fc3fb4c07034a | /texar/modules/decoders/xlnet_decoder_test.py | cdc51d775a727ca3cd8d684de1febe2cf2cf0054 | [
"Apache-2.0"
] | permissive | TPNguyen/texar-pytorch | 9ed56e2983ee1e055c5eb9c14856f967906e96f5 | d212ab01e427da00cd4210344cc18e0d88a16e50 | refs/heads/master | 2020-06-25T06:56:59.791929 | 2019-07-28T01:00:33 | 2019-07-28T01:00:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,778 | py | """
Unit tests for XLNet decoder.
"""
import unittest
import torch
from texar.modules.decoders.xlnet_decoder import *
from texar.utils.test import pretrained_test
class XLNetDecoderTest(unittest.TestCase):
r"""Tests :class:`~texar.modules.XLNetDecoder`
"""
def setUp(self) -> None:
self.batch_size = 2
self.max_length = 3
self.start_tokens = torch.zeros(
self.batch_size, self.max_length, dtype=torch.long)
@pretrained_test
def test_hparams(self):
r"""Tests the priority of the decoder arch parameters.
"""
# case 1: set "pretrained_mode_name" by constructor argument
hparams = {
"pretrained_model_name": "xlnet-large-cased",
}
decoder = XLNetDecoder(pretrained_model_name="xlnet-base-cased",
hparams=hparams)
self.assertEqual(decoder.hparams.num_layers, 12)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
# case 2: set "pretrained_mode_name" by hparams
hparams = {
"pretrained_model_name": "xlnet-large-cased",
"num_layers": 6,
}
decoder = XLNetDecoder(hparams=hparams)
self.assertEqual(decoder.hparams.num_layers, 24)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
# case 3: set to None in both hparams and constructor argument
hparams = {
"pretrained_model_name": None,
"num_layers": 6,
}
decoder = XLNetDecoder(hparams=hparams)
self.assertEqual(decoder.hparams.num_layers, 6)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
# case 4: using default hparams
decoder = XLNetDecoder()
self.assertEqual(decoder.hparams.num_layers, 12)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
@pretrained_test
def test_trainable_variables(self):
r"""Tests the functionality of automatically collecting trainable
variables.
"""
# case 1
decoder = XLNetDecoder()
self.assertEqual(len(decoder.trainable_variables), 182 + 1)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
# case 2
hparams = {
"pretrained_model_name": "xlnet-large-cased",
}
decoder = XLNetDecoder(hparams=hparams)
self.assertEqual(len(decoder.trainable_variables), 362 + 1)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
# case 3
hparams = {
"pretrained_model_name": None,
"num_layers": 6
}
decoder = XLNetDecoder(hparams=hparams)
self.assertEqual(len(decoder.trainable_variables), 92 + 1)
_, _ = decoder(start_tokens=self.start_tokens,
end_token=1, max_decoding_length=self.max_length)
@pretrained_test
def test_decode_infer_sample(self):
r"""Tests train_greedy."""
hparams = {
"pretrained_model_name": None,
}
decoder = XLNetDecoder(hparams=hparams)
decoder.train()
inputs = torch.randint(32000, (self.batch_size, self.max_length))
outputs, _ = decoder(
inputs, max_decoding_length=self.max_length, end_token=2)
self.assertIsInstance(outputs, XLNetDecoderOutput)
if __name__ == "__main__":
unittest.main()
| [
"huzecong@gmail.com"
] | huzecong@gmail.com |
ed7adc09c26d904b775eb821936224e58720993f | 1c4bfecb65285b25d5a0bbd0dd61aabc33e5b023 | /Day 16/day16.py | f78324ccc481c47aee6a8bab33f3948f5d8cdff0 | [] | no_license | RaulVS14/adventofcode2020 | e3abce815daf7d030d101eda385cc60e9c585933 | ec01c088ad4b8d09a75522575971a2bb02cfe28c | refs/heads/master | 2023-02-04T22:08:38.802445 | 2020-12-21T15:40:03 | 2020-12-21T15:40:03 | 317,475,877 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 761 | py | from day_16_functions import get_sum_of_invalid_field_numbers, get_multiplied_departure_field_numbers_from_your_ticket, \
get_order_label_list
from helpers.helpers import output_test_result, output_result
if __name__ == "__main__":
# Part 1
print(output_test_result(71 == get_sum_of_invalid_field_numbers("test_input.txt"), 16, 1))
print(output_result(get_sum_of_invalid_field_numbers("input.txt"), 16, 1))
# Part 2
print(output_test_result(['row', 'class', 'seat'] == get_order_label_list("test_input.txt")[0], 16, 2.1))
print(output_test_result(['row', 'class', 'seat'] == get_order_label_list("test_input2.txt")[0], 16, 2.2))
print(output_result(get_multiplied_departure_field_numbers_from_your_ticket("input.txt"), 16, 2))
| [
"raul.muser@gmail.com"
] | raul.muser@gmail.com |
9bbf9007ff690de3538ee65f2650bc8c9b1b236e | d4bc18b44dba3ecfb06a09ba6406d82d1162da21 | /Lessons/08.10/logical.py | 71dd9209371d91db96f4c43528a0e9e96f722495 | [] | no_license | VitaliStanilevich/Md-PT1-40-21 | 367d4ab51895d6c2cbb7f2c99dbd63368ce9519c | 656ded42fb36434b8f3c7cd0aa17660bb2699973 | refs/heads/main | 2023-08-24T14:53:18.753697 | 2021-10-20T18:40:55 | 2021-10-20T18:40:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 511 | py | num = 10
if num > 0:
print("positive")
elif num == 0:
print("zero")
# if num == 0:
# print("zero")
else:
print("negative")
print("positive") if num > 0 else print("zero") if num == 0 else print("negative")
if num >= 0:
if num == 0:
print("zero")
else:
print("positive")
else:
print("negative")
print("zero") if num == 0 else print("positive") if num >= 0 else print("negative")
# x = 10 if num >= 0 else -10
# if num >= 0:
# x = 10
# else:
# x = -10 | [
"Mikita_Tsiarentsyeu@epam.com"
] | Mikita_Tsiarentsyeu@epam.com |
5b43351087ccdff0802e538ca93f5ebdb419fc2a | eed9012c437bdcf46ddea1fa9a46d84ee00275ae | /venv/Lib/site-packages/setuptools/extension.py | 2bf4b0c99d9516cf5a6a6b99ae7b64b7c206b9dd | [] | no_license | afreencoder/pythonspeech | dc75548052557e62001555c6147e7051f1b6b4e0 | f059d5cc0280c3eb6daedb68504d7ff293cd1556 | refs/heads/master | 2021-05-22T19:53:40.104622 | 2020-04-04T18:46:25 | 2020-04-04T18:46:25 | 253,066,795 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,726 | py | import re
import functools
import distutils.core
import distutils.errors
import distutils.extension
from setuptools.extern.six.moves import map
from .monkey import get_unpatched
def _have_cython():
"""
Return True if Cython can be imported.
"""
cython_impl = 'Cython.Distutils.build_ext'
try:
# from (cython_impl) import build_ext
__import__(cython_impl, fromlist=['build_ext']).build_ext
return True
except Exception:
pass
return False
# for compatibility
have_pyrex = _have_cython
_Extension = get_unpatched(distutils.core.Extension)
class Extension(_Extension):
"""Extension that uses '.c' files in place of '.pyx' files"""
def __init__(self, name, sources, *args, **kw):
# The *args is needed for compatibility as calls may use positional
# arguments. py_limited_api may be set only via keyword.
self.py_limited_api = kw.pop("py_limited_api", False)
_Extension.__init__(self, name, sources, *args, **kw)
def _convert_pyx_sources_to_lang(self):
"""
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
"""
if _have_cython():
# the build has Cython, so allow it to compile the .pyx files
return
lang = self.language or ''
target_ext = '.cpp' if lang.lower() == '' else '.c'
sub = functools.partial(re.sub, '.pyx$', target_ext)
self.sources = list(map(sub, self.sources))
class Library(Extension):
"""Just like a regular Extension, but built as a library instead"""
| [
"afreen.sft@gmail.com"
] | afreen.sft@gmail.com |
83020e7b885b73925fc4aedbd8b35e711c077254 | a38379baffede6c9012263c91eb25d7baf4e880d | /create_lex.py | 7ccdf6c6b2abb51d922432a32837f52c0fc7168c | [] | no_license | stebranchi/LUS_Midterm | 375c9f30bc30f0f6c757d5de0b611a97e378a714 | 61821984619ad829a2256dcf739c150eace71273 | refs/heads/master | 2020-05-07T22:40:43.584239 | 2019-04-12T08:22:20 | 2019-04-12T08:22:20 | 180,955,096 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 2,150 | py | from string import ascii_lowercase, ascii_uppercase
import math
f = open('lex.lex', 'w')
train = open('NL2SparQL4NLU.train.conll.txt', 'r')
i = 1
s = set()
f.write('epsilon\t0\n')
for l in train:
words = l.split()
if words:
s.add(words[0])
tag = words[1]
if tag[len(tag)-1] == '$':
tag = tag[:len(tag)-1]
s.add(tag)
for item in s:
f.write(item + '\t' + str(i) +'\n')
i+=1
f.write('<space>\t' + str(i) + '\n')
i+=1
f.write('<unk>\t' + str(i))
f.close()
train.close()
f = open('POS.counts', 'w')
train = open('NL2SparQL4NLU.train.conll.txt', 'r')
i = 1
lex_pos = dict()
for l in train:
words = l.split()
if words:
tag = words[1]
if tag[len(tag)-1] == '$':
tag = tag[:len(tag)-1]
if tag in lex_pos:
lex_pos[tag] += 1
else:
lex_pos[tag] = 1
for key, value in lex_pos.items():
f.write(key + '\t' + str(value) + '\n')
i+=1
f.close()
train.close()
f = open('TOK_POS.counts', 'w')
train = open('NL2SparQL4NLU.train.conll.txt', 'r')
i = 1
lex_tok_pos = dict()
for l in train:
words = l.split()
if words:
tag = words[1]
if tag[len(tag)-1] == '$':
tag = tag[:len(tag)-1]
concat = words[0] + ' ' + tag
if concat in lex_tok_pos:
lex_tok_pos[concat] += 1
else:
lex_tok_pos[concat] = 1
for key, value in lex_tok_pos.items():
f.write(key + '\t' + str(value) + '\n')
i+=1
f.close()
train.close()
f = open('TOK_POS.probs','w')
for key, value in lex_tok_pos.items():
pos_tag = key.split()
prob = float(lex_tok_pos[key] / lex_pos[pos_tag[1]])
f.write(str(key) + '\t' + str(prob) + '\n')
f.close()
f = open('TOK_POS.probs','r')
out = open('probs_fst.txt', 'w')
for l in f:
words = l.split()
out.write('0\t0\t' + str(words[0]) + '\t' + str(words[1]) + '\t' + str(-math.log(float(words[2]))) + '\n')
out.write('0')
f.close()
out.close()
out = open('unk.txt', 'w')
prob = -math.log(1/38)
for key, value in lex_pos.items():
out.write('0\t0\t<unk>\t' + key + '\t' + str(prob) + '\n')
out.write('0')
out.close()
out = open('test1.txt', 'w')
out.write('star of Thor')
out.close()
| [
"ste.branchi@gmail.com"
] | ste.branchi@gmail.com |
cf109e7cf9cfecaf4ee0b9dae24be68429555429 | dfa2c7f96039b746046162eec2372b632f9a8f25 | /train_vgg_en.py | 2ef8b3d6925ec7418c4cea78d1d1fd505b755d0f | [
"MIT"
] | permissive | RuiLiFeng/FGAN | 33a2c198191409b55185f964ede5b72bf44de9f1 | ba22b428170b2d04422a01eb76da2b31471c5ae5 | refs/heads/master | 2020-07-30T19:34:00.565334 | 2019-10-29T12:45:47 | 2019-10-29T12:45:47 | 210,334,295 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 7,484 | py | """ BigGAN: The Authorized Unofficial PyTorch release
Code by A. Brock and A. Andonian
This code is an unofficial reimplementation of
"Large-Scale GAN Training for High Fidelity Natural Image Synthesis,"
by A. Brock, J. Donahue, and K. Simonyan (arXiv 1809.11096).
Let's go.
"""
import functools
from tqdm import tqdm
import torch
import torch.nn as nn
import torch.nn.functional as F
# Import my stuff
from Metric import inception_utils
from Utils import utils, vae_utils
from Training import train_fns
from sync_batchnorm import patch_replication_callback
from Network.VaeGAN.Encoder import Encoder
from Network.BigGAN.BigGAN import Generator
# The main training file. Config is a dictionary specifying the configuration
# of this training run.
def run(config):
# Update the config dict as necessary
# This is for convenience, to add settings derived from the user-specified
# configuration into the config-dict (e.g. inferring the number of classes
# and size of the images from the dataset, passing in a pytorch object
# for the activation specified as a string)
config['resolution'] = utils.imsize_dict[config['dataset']]
config['n_classes'] = utils.nclass_dict[config['dataset']]
config['G_activation'] = utils.activation_dict[config['G_nl']]
config['D_activation'] = utils.activation_dict[config['D_nl']]
# By default, skip init if resuming training.
if config['resume']:
print('Skipping initialization for training resumption...')
config['skip_init'] = True
config = vae_utils.update_config_roots(config)
device = 'cuda'
# Seed RNG
utils.seed_rng(config['seed'])
# Prepare root folders if necessary
utils.prepare_root(config)
# Setup cudnn.benchmark for free speed
torch.backends.cudnn.benchmark = True
experiment_name = (config['experiment_name'] if config['experiment_name']
else utils.name_from_config(config))
print('Experiment name is %s' % experiment_name)
# Next, build the model
G = Generator(**{**config, 'skip_init': True, 'no_optim': True}).to(device)
print('Loading pretrained G for dir %s ...' % config['pretrained_G_dir'])
pretrained_dict = torch.load(config['pretrained_G_dir'])
G_dict = G.state_dict()
pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in G_dict}
G_dict.update(pretrained_dict)
G.load_state_dict(G_dict)
E = Encoder(**config).to(device)
utils.toggle_grad(G, False)
utils.toggle_grad(E, True)
class G_E(nn.Module):
def __init__(self):
super(G_E, self).__init__()
self.G = G
self.E = E
def forward(self, w, y):
with torch.no_grad():
net = self.G(w, self.G.shared(y))
net = self.E(net)
return net
GE = G_E()
# If using EMA, prepare it
if config['ema']:
print('Preparing EMA for E with decay of {}'.format(config['ema_decay']))
E_ema = Encoder(**{**config, 'skip_init': True,
'no_optim': True}).to(device)
e_ema = utils.ema(E, E_ema, config['ema_decay'], config['ema_start'])
else:
E_ema, e_ema = None, None
print(G)
print(E)
print('Number of params in G: {} E: {}'.format(
*[sum([p.data.nelement() for p in net.parameters()]) for net in [G, E]]))
# Prepare state dict, which holds things like epoch # and itr #
state_dict = {'itr': 0, 'epoch': 0, 'save_num': 0, 'save_best_num': 0,
'best_IS': 0, 'best_FID': 999999, 'config': config}
# If loading from a pre-trained model, load weights
if config['resume']:
print('Loading weights...')
vae_utils.load_weights([E], state_dict,
config['weights_root'], experiment_name,
config['load_weights'] if config['load_weights'] else None,
[e_ema] if config['ema'] else None)
# If parallel, parallelize the GD module
if config['parallel']:
GE = nn.DataParallel(GE)
if config['cross_replica']:
patch_replication_callback(GE)
# Prepare loggers for stats; metrics holds test metrics,
# lmetrics holds any desired training metrics.
train_metrics_fname = '%s/%s' % (config['logs_root'], experiment_name)
print('Training Metrics will be saved to {}'.format(train_metrics_fname))
train_log = utils.MyLogger(train_metrics_fname,
reinitialize=(not config['resume']),
logstyle=config['logstyle'])
# Write metadata
utils.write_metadata(config['logs_root'], experiment_name, config, state_dict)
G_batch_size = max(config['G_batch_size'], config['batch_size'])
z_, y_ = utils.prepare_z_y(G_batch_size, G.dim_z, config['n_classes'],
device=device, fp16=config['G_fp16'])
def train():
E.optim.zero_grad()
z_.sample_()
y_.sample_()
net = GE(z_[:config['batch_size']], y_[:config['batch_size']])
loss = F.l1_loss(z_[:config['batch_size']], net)
loss.backward()
if config["E_ortho"] > 0.0:
print('using modified ortho reg in E')
utils.ortho(E, config['E_ortho'])
E.optim.step()
out = {'loss': float(loss.item())}
return out
print('Beginning training at epoch %d...' % state_dict['epoch'])
# Train for specified number of epochs, although we mostly track G iterations.
for epoch in range(state_dict['epoch'], config['num_epochs']):
for i in range(100000):
# Increment the iteration counter
state_dict['itr'] += 1
# Make sure G and D are in training mode, just in case they got set to eval
# For D, which typically doesn't have BN, this shouldn't matter much.
G.train()
E.train()
if config['ema']:
E_ema.train()
metrics = train()
train_log.log(itr=int(state_dict['itr']), **metrics)
# Every sv_log_interval, log singular values
if (config['sv_log_interval'] > 0) and (not (state_dict['itr'] % config['sv_log_interval'])):
train_log.log(itr=int(state_dict['itr']),
**{**utils.get_SVs(G, 'G'), **utils.get_SVs(E, 'E')})
# If using my progbar, print metrics.
if config['pbar'] == 'mine':
print(', '.join(['itr: %d' % state_dict['itr']]
+ ['%s : %+4.3f' % (key, metrics[key])
for key in metrics]), end=' ')
# Save weights and copies as configured at specified interval
if not (state_dict['itr'] % config['save_every']):
vae_utils.save_weights([E], state_dict, config['weights_root'],
experiment_name, 'copy%d' % state_dict['save_num'],
[E_ema if config['ema'] else None])
state_dict['save_num'] = (state_dict['save_num'] + 1) % config['num_save_copies']
# Increment epoch counter at end of epoch
state_dict['epoch'] += 1
def main():
# parse command line and run
parser = utils.prepare_parser()
config = vars(parser.parse_args())
print(config)
run(config)
if __name__ == '__main__':
main() | [
"frl1996@mail.ustc.edu.cn"
] | frl1996@mail.ustc.edu.cn |
281e9a22cb539e56fcdae3068e150352f7d6bcd8 | 8d0d406eb3bc0839a4570aad5ca4f8cb2ceca3f5 | /lib/ultrasonic.py | 588f89b89cf1501d93ed2753982f674def1a959f | [] | no_license | Rafvermeylen/Build2 | 1843dfc29eb57af4fc7cb5a39bb38623d7e9af90 | d0f7da4b6855e27d006041bd3ca9066282855e9a | refs/heads/main | 2023-04-10T09:14:32.353143 | 2021-04-22T08:27:58 | 2021-04-22T08:27:58 | 360,445,992 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 681 | py | # ---- Imports ----
from machine import UART
# ---- Setup ----
uart = UART(1)
# ---- Code ----
def measurement():
uart.init(baudrate=9600, bits=8, parity=None, stop=1, timeout_chars=100,
pins=('P3', 'P4'))
header_bytes = uart.read(1)
while(header_bytes != b'\xff'):
header_bytes = uart.read(1)
high = int(uart.read(1)[0])
low = int(uart.read(1)[0])
sum = int(uart.read(1)[0])
distance = (high*256) + low
if distance < 30:
print("Hold your horses, buckaroo! That's way too close!")
else:
in_cm = distance / 10
print("Distance: " + str(in_cm) + " cm")
return distance
| [
"noreply@github.com"
] | Rafvermeylen.noreply@github.com |
d0960dc5f6ed3fa19b1ed7f58fa31677ac4e9e1f | fd9b11b08d4878919ec42421253f483fc52a31cc | /main/models.py | e8f3a236c1151915434ad86983eb7298946d0d41 | [] | no_license | aditj/qaik | 579893912ad4960c3532bc5476a353c0002b7bc3 | 93e13f68aaf63aaa1cc45d783ef89de97ef7e123 | refs/heads/main | 2023-04-12T08:36:52.832811 | 2021-04-26T20:52:23 | 2021-04-26T20:52:23 | 356,635,097 | 1 | 1 | null | 2021-04-24T20:58:32 | 2021-04-10T16:20:44 | HTML | UTF-8 | Python | false | false | 1,822 | py | from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
class UserProfile(models.Model):
user=models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
bio=models.TextField(blank=True,default='')
dob=models.DateField(blank=True,null=True)
perc_objectionble=models.FloatField(default=0)
def get_followers(self):
followers=Following.objects.filter(following=self)
output=[]
for f in followers:
output.append(f.follower.user.username)
return output
class QAIT(models.Model):
content=models.CharField(max_length=140)
by=models.ForeignKey(UserProfile,on_delete=models.CASCADE)
date=models.DateField(auto_created=True,auto_now_add=True)
time=models.TimeField(auto_created=True,auto_now_add=True)
perc_objectionble=models.FloatField(default=0)
def get_like_no(self):
return Like.objects.filter(qait=self).count()
def get_reply_no(self):
return Reply.objects.filter(reply_to=self).count()
class Reply(QAIT):
reply_to=models.ForeignKey(QAIT,on_delete=models.CASCADE,related_name="parent_qait")
class Like(models.Model):
qait=models.ForeignKey(QAIT,on_delete=models.CASCADE)
liker=models.ForeignKey(UserProfile,on_delete=models.CASCADE)
class Following(models.Model):
follower=models.ForeignKey(UserProfile,on_delete=models.CASCADE,related_name="follower")
following= models.ForeignKey(UserProfile,on_delete=models.CASCADE,related_name="following")
class Hashtag(models.Model):
title=models.CharField(max_length=50)
count=models.IntegerField(default=0)
class HashtagTweets(models.Model):
hashtag=models.ForeignKey(Hashtag,on_delete=models.CASCADE)
associated_qait=models.ForeignKey(QAIT,on_delete=models.CASCADE)
| [
"aditjain1980@gmail.com"
] | aditjain1980@gmail.com |
f1a7294eab456b87d9b7f4eed6f4205013b784ef | d1e9e904eacd91cc08d76646edf17dced72c0d94 | /GamesAPI/settings.py | 94feb6880296218927c9c9164e0182bafffb0897 | [] | no_license | thonnycleuton/GamesAPI | 59c86c7562be4c09e120c010114e1495ada26079 | 004513fa0bd45877cb5dc76e6eebe7ce78d34667 | refs/heads/master | 2021-01-19T14:27:46.197720 | 2018-05-21T19:59:36 | 2018-05-21T19:59:36 | 100,906,230 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,211 | py | """
Django settings for GamesAPI project.
Generated by 'django-admin startproject' using Django 1.11.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '12-@w9_3nc=a=a5o4eiq(6+o4esnmpw&sd0-ol1ujrmgjsw&6!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'games.apps.GamesConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'GamesAPI.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'GamesAPI.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
| [
"thonnycleuton@gmail.com"
] | thonnycleuton@gmail.com |
371eaae16186960201e80bb6d9592aeab3c20d3f | 45e376ae66b78b17788b1d3575b334b2cb1d0b1c | /checkov/kubernetes/checks/resource/k8s/KubeletStreamingConnectionIdleTimeout.py | e16eb9d02a976a7c0eb9f9c1bf564fb63abf0a44 | [
"Apache-2.0"
] | permissive | bridgecrewio/checkov | aeb8febed2ed90e61d5755f8f9d80b125362644d | e64cbd27ffb6f09c2c9f081b45b7a821a3aa1a4d | refs/heads/main | 2023-08-31T06:57:21.990147 | 2023-08-30T23:01:47 | 2023-08-30T23:01:47 | 224,386,599 | 5,929 | 1,056 | Apache-2.0 | 2023-09-14T20:10:23 | 2019-11-27T08:55:14 | Python | UTF-8 | Python | false | false | 900 | py | from typing import Any, Dict
from checkov.common.models.enums import CheckResult
from checkov.kubernetes.checks.resource.base_container_check import BaseK8sContainerCheck
class KubeletStreamingConnectionIdleTimeout(BaseK8sContainerCheck):
def __init__(self) -> None:
# CIS-1.6 4.2.5
id = "CKV_K8S_143"
name = "Ensure that the --streaming-connection-idle-timeout argument is not set to 0"
super().__init__(name=name, id=id)
def scan_container_conf(self, metadata: Dict[str, Any], conf: Dict[str, Any]) -> CheckResult:
self.evaluated_container_keys = ["command"]
if conf.get("command"):
if "kubelet" in conf["command"]:
if "--streaming-connection-idle-timeout=0" in conf["command"]:
return CheckResult.FAILED
return CheckResult.PASSED
check = KubeletStreamingConnectionIdleTimeout()
| [
"noreply@github.com"
] | bridgecrewio.noreply@github.com |
9d990bda2fc62af61f7f130b0df0456ea591e94f | 75d87febb5142a79e095cdb339480706bf9d9aaa | /wlasna_usr/usr/pkg/bin/pydoc2.7 | bf5e96158337d8127267c83b56d3067cec5adac7 | [] | no_license | heroarthur/Minix | fcc6cbcc4b9622e4d60372d48a10f540da29893b | 9ad1e2fa153376ebbde56167b372807fd68b9670 | refs/heads/master | 2020-03-18T07:06:54.082284 | 2018-06-12T17:00:29 | 2018-06-12T17:00:29 | 134,433,383 | 0 | 1 | null | null | null | null | UTF-8 | Python | false | false | 82 | 7 | #!/usr/pkg/bin/python2.7
import pydoc
if __name__ == '__main__':
pydoc.cli()
| [
"you@example.com"
] | you@example.com |
7789e54acc02fe0277ff80ce14efbcdc4ee6e7f1 | 4cc9985900c7f2b3ff41c7b15f1cd4f5e8fd36f5 | /cartpole.py | 1193790020d213d158312343236e9e91fad708f8 | [] | no_license | Rahul-Mallapur/cartpole-neuralnetwork | c24d3b1684a81c1ea6cfeadbc8fe68b900e82759 | ca4c7ec02c17945a0810278a83f7d26e33a88589 | refs/heads/master | 2021-01-25T01:21:51.852628 | 2017-06-20T12:35:27 | 2017-06-20T12:35:27 | 94,750,828 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 4,455 | py | import gym
import random
import numpy as np
import statistics
from collections import Counter
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
#setup the Cartpole environment
env = gym.make("CartPole-v0")
env.reset()
#----------Explore CartPole-------------#
#exploring the observations, rewards, actions
def explore_cartpole():
for i_episode in range(2):
observation = env.reset()
for t in range(100):
env.render()
print(observation)
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
print("Action: ", action, "Rewards", reward)
if done:
print("Episode finished after {} timesteps".format(t+1))
break
#explore_cartpole()
#----------Collect Training Data-------------#
#collect data from successful games by running x games
#successful would be say, lasting more than 100 frames
num_games = 20000
num_episodes = 201 #game would end at 200 episodes
min_score = 75
def initial_games():
train_data = []
train_scores = []
#running our initial set of games
for _ in range(num_games):
game_data = []
prev_obs = []
score = 0
#running the game, frame by frame
for _ in range(num_episodes):
#choosing actions: randomly
action = random.randrange(0,2)
observation, reward, done, info = env.step(action)
if len(prev_obs) > 0:
game_data.append([prev_obs, action])
prev_obs = observation
score += reward
if done:
#print("Score was: ", score)
break
#if the score was above the threshold
#we will save the game in our training data
#hence training on the better games
if score >= min_score :
train_scores.append(score)
#converting the data into one-hot output
for i in game_data:
if i[1] == 0:
output = [1, 0]
else:
output = [0, 1]
train_data.append([i[0], output])
env.reset()
return train_data
#----------Build the FC NN model-------------#
#building a simple multi-layer fully connected model
#this model can be generally used to play games like cartpole
#would try training the model on other games in OpenAI environment
def nn_model(input_size):
network = input_data(shape=[None, input_size, 1], name='input')
network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)
network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)
network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.8)
network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)
network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)
network = fully_connected(network, 2, activation='softmax')
network = regression(network, optimizer='adam', learning_rate=1e-3, loss='categorical_crossentropy', name='targets')
model = tflearn.DNN(network, tensorboard_dir='log')
return model
#----------Train the model-------------#
def train_model(train_data, model=False):
x = np.array([i[0] for i in train_data]).reshape(-1, len(train_data[0][0]),1)
y = [i[1] for i in train_data]
if not model:
model = nn_model(input_size = len(x[0]))
model.fit({'input': x}, {'targets': y}, n_epoch = 5, snapshot_step=500,
show_metric = True, run_id = 'openai_learning')
return model
train_data = initial_games()
#print("Size of training data",len(train_data))
model = train_model(train_data)
#----------Predict actions for the games-------------#
num_final_games = 10
target_episodes = 201
all_rewards = []
all_actions = []
for _ in range(num_final_games):
total_score = 0
prev_obs = []
env.reset()
for _ in range(target_episodes):
#env.render()
#instead of randomly choosing the action, predict the actions
if len(prev_obs) == 0:
action = random.randrange(0,2)
else:
action = np.argmax(model.predict(prev_obs.reshape(-1,len(prev_obs),1))[0])
all_actions.append(action)
#let's run the game
observation, reward, done, info = env.step(action)
prev_obs = observation
total_score += reward
if done:
break
all_rewards.append(total_score)
#----------Print results-------------#
print('Average reward:',np.mean(all_rewards), '+-', np.std(all_rewards))
print('Max reward:', max(all_rewards))
| [
"rahul.mallapur@gmail.com"
] | rahul.mallapur@gmail.com |
a0becb9dc092adcc0f8e303940625644b72e1b10 | ca7aa979e7059467e158830b76673f5b77a0f5a3 | /Python_codes/p02260/s412559133.py | 8c84ef67f65a718272f86806feae9173e7892bbe | [] | no_license | Aasthaengg/IBMdataset | 7abb6cbcc4fb03ef5ca68ac64ba460c4a64f8901 | f33f1c5c3b16d0ea8d1f5a7d479ad288bb3f48d8 | refs/heads/main | 2023-04-22T10:22:44.763102 | 2021-05-13T17:27:22 | 2021-05-13T17:27:22 | 367,112,348 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 260 | py | N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
minj = i
for j in range(i+1,N):
if A[j] < A[minj]:
minj = j
if i != minj:
A[i],A[minj] = A[minj],A[i]
cnt += 1
print(*A)
print(cnt)
| [
"66529651+Aastha2104@users.noreply.github.com"
] | 66529651+Aastha2104@users.noreply.github.com |
da8fa44710b31c0971532d774f37cde1ae7626d2 | c132527e1efc635541099f5df80a98fca9da4b5f | /listings/migrations/0001_initial.py | e380ec4d03864933db389b55985fb0695c720206 | [] | no_license | Sam-Macpherson/sublet-shark-api | 572264f18a828fd33594a660844757701b2ff304 | e5a11e07677af0582c6320212edbe0fdb4da436a | refs/heads/main | 2023-07-13T20:08:52.241134 | 2021-08-17T00:08:57 | 2021-08-17T00:08:57 | 317,647,215 | 1 | 0 | null | 2021-02-23T18:02:33 | 2020-12-01T19:32:42 | Python | UTF-8 | Python | false | false | 2,252 | py | # Generated by Django 3.1.3 on 2020-11-27 15:09
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Listing',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('accommodation_type', models.IntegerField(choices=[(1, 'Apartment'), (2, 'House'), (3, 'Condominium')], default=1, help_text='The type of building the listing is for.')),
('start_date', models.DateField(help_text='The first date that the subletter may move in.')),
('end_date', models.DateField(help_text='The date by which the subletter must leave.')),
('address', models.CharField(help_text='The string representation of the address of the building the listing is for.', max_length=255)),
('additional_info', models.TextField(blank=True, help_text='Optional additional information about the listing that is not covered by the other fields.')),
],
options={
'ordering': ['start_date'],
},
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('bed_type', models.IntegerField(choices=[(1, 'Single'), (2, 'Double'), (3, 'Queen'), (4, 'King')], default=1, help_text='The type of bed that this room is equipped with.')),
('ensuite', models.BooleanField(default=False, help_text='A boolean to indicate whether or not this room has an ensuite bathroom.')),
('minifridge', models.BooleanField(default=False, help_text='A boolean to indicate whether or not this room comes with a mini-fridge.')),
('listing', models.ForeignKey(help_text='The listing that this room belongs to.', on_delete=django.db.models.deletion.CASCADE, related_name='rooms', to='listings.listing')),
],
options={
'abstract': False,
},
),
]
| [
"noreply@github.com"
] | Sam-Macpherson.noreply@github.com |
0bb1a10058afecd744ec2b28d9a2dbf6c63e20f9 | 53b595f955097148a5da5f669520789abcb3e107 | /banking.py | 2829e312b2d8efd1f8ab9c925e27b19a55f305e8 | [] | no_license | snitivan/Bank-account | 53dfab4b0a390aabbb31350a2897407646ca5921 | 333a300e4594a3a4d8b7c9cc8a0c7e17095c6761 | refs/heads/master | 2022-11-05T00:57:34.225390 | 2020-07-06T16:36:08 | 2020-07-06T16:36:08 | 277,595,105 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 5,264 | py | import sqlite3
import random
accounts = {}
account = ''
def create_an_account():
card_MII = '400000'
pin = str(random.randint(0, 9)) + str(random.randint(0, 9)) + str(random.randint(0, 9)) + str(random.randint(0, 9))
for i in range(9):
card_MII += str(random.randint(0, 9))
check_sum = str(luhn_algorithm(card_MII))
card_MII += check_sum
print('''Your card has been created
Your card number:''')
print(card_MII)
print('Your card PIN:')
print(pin)
cur.execute(f'INSERT INTO card(number, pin) VALUES ({card_MII}, {pin});')
conn.commit()
accounts[card_MII] = str(pin)
def log_into_account():
global stop, account
card_n = input('Enter your card number:\n> ')
pin = input('Enter your pin:\n> ')
cur.execute(f'SELECT number, pin FROM card;')
zz = cur.fetchall()
for num in zz:
if card_n in num[0]:
if pin == num[1]:
account = card_n
print('You have successfully logged in!')
return True
else:
print('Wrong card number or PIN!')
return
print('Wrong card number or PIN!')
def transfer():
global account
tr_card = input('Transfer\nEnter card number:\n> ')
lst_card = [int(x) for x in tr_card[:-1]]
odd_list = []
for ind, num in enumerate(lst_card):
if ind % 2 == 0:
z = num * 2
if z > 9:
odd_list.append(z - 9)
else:
odd_list.append(z)
else:
odd_list.append(num)
summ = sum(odd_list)
summ_a = summ
while summ_a % 10 != 0:
summ_a += 1
check_n = summ_a - summ
#print('Checking system', check_n, tr_card[-1])
if str(check_n) == tr_card[-1]:
cur.execute(f'SELECT number, balance FROM card;')
zz = cur.fetchall()
for kk in zz:
if tr_card in kk[0]:
money = input('Enter how much money you want to transfer:\n> ')
#print(kk[1])
for acc in zz:
if account in acc[0]:
if int(money) <= acc[1]:
cur.execute(f'UPDATE card SET balance = balance + {int(money)} WHERE number = {tr_card};')
cur.execute(f'UPDATE card SET balance = balance - {int(money)} WHERE number = {account};')
conn.commit()
print('Success!\n')
return
else:
print('Not enough money!')
return
print('Such a card does not exist.')
else:
print('Probably you made mistake in the card number. Please try again!\n')
def account_in_operations():
global stop, account
while True:
print('''1. Balance
2. Add income
3. Do transfer
4. Close account
5. Log out
0. Exit''')
operation = input()
if operation == '1':
cur.execute(f'SELECT number, balance FROM card;')
zz = cur.fetchall()
for num in zz:
if account in num[0]:
print(f'Balance {num[1]}')
elif operation == '2':
deposit = int(input('Enter income:\n> '))
#print(deposit, account)
#print(f'UPDATE card SET balance = {deposit} WHERE number = {account};')
cur.execute(f'UPDATE card SET balance = balance + {deposit} WHERE number = {account};')
conn.commit()
elif operation == '3':
transfer()
elif operation == '4':
cur.execute(f'SELECT number, balance FROM card;')
zz = cur.fetchall()
for num in zz:
if account in num[0]:
cur.execute(f'DELETE FROM card WHERE number = {account};')
conn.commit()
elif operation == '5':
print('You have successfully logged out!')
return True
elif operation == '0':
return False
def luhn_algorithm(card_m):
lst_card = [int(x) for x in card_m]
odd_list = []
for ind, num in enumerate(lst_card):
if ind % 2 == 0:
z = num * 2
if z > 9:
odd_list.append(z - 9)
else:
odd_list.append(z)
else:
odd_list.append(num)
summ = sum(odd_list)
summ_a = summ
while summ_a % 10 != 0:
summ_a += 1
return summ_a - summ
if __name__ == '__main__':
conn = sqlite3.connect('card.s3db')
cur = conn.cursor()
try:
#cur.execute('DROP TABLE card')
cur.execute('''CREATE TABLE card(
id INTEGER,
number TEXT,
pin TEXT,
balance INTEGER DEFAULT 0
);''')
conn.commit()
except sqlite3.OperationalError:
pass
stop = True
while stop:
print(
'''1. Create an account
2. Log into account
0. Exit''')
key = input('> ')
if key == '1':
create_an_account()
elif key == '2':
if log_into_account():
stop = account_in_operations()
elif key == '0':
print('Bye!')
stop = False
| [
"noreply@github.com"
] | snitivan.noreply@github.com |
7a85fbc6fc1643ab2e4946542643a104ce265ad6 | 8739db99c7481620790e3bc2269fa72da3daa305 | /branch/models.py | d3ce32d26c9c0abd7d64c9af47b470cea69f8d09 | [] | no_license | kamiwana/redbutton_server | ca57a6fa60187ec3a4ce68331c70c88de402e97f | 33135f0173a83cc7f41fa566c7cb9b91c2cf49b6 | refs/heads/master | 2022-12-16T06:01:50.417307 | 2020-09-14T16:52:26 | 2020-09-14T16:52:26 | 181,593,030 | 0 | 0 | null | 2022-12-07T23:53:33 | 2019-04-16T01:40:03 | Python | UTF-8 | Python | false | false | 1,106 | py | from django.db import models
# Create your models here.django_migrations
class Branch(models.Model):
branch_code = models.CharField(max_length=10,blank=False)
branch_name = models.CharField(max_length=20,blank=False)
branch_user = models.CharField(max_length=20, null=True, blank=True)
branch_address = models.CharField(max_length=255, null=True, blank=True)
phone_number = models.CharField(max_length=20, null=True, blank=True)
game_cnt = models.IntegerField(null=True, blank=True, default=0)
is_together = models.BooleanField()
is_note = models.BooleanField()
is_forbidden_word= models.BooleanField()
is_desc_request = models.BooleanField()
forbidden_word_cnt=models.IntegerField(null=True, blank=True, default=0)
forbidden_word_scope = models.IntegerField(null=True, blank=True, default=0)
system_volume = models.IntegerField(null=True, blank=True, default=0)
user = models.CharField(max_length=150, null=True, blank=True)
last_date = models.DateTimeField(auto_created=True,auto_now=True)
class Meta:
ordering = ['-branch_code']
| [
"kamiwanan@gmail.com"
] | kamiwanan@gmail.com |
1c95fb2a9920644a3ae11fe96f3994b794ce7d9d | eff764f5f77ca85caff2f9801748583d26a80d76 | /loops/kind_of_fizz_buzz_but_it_is_numbers.py | d37b18e2adb975383947c310ff613ea38f6b4436 | [] | no_license | tomekregulski/python-practice | 3be401a7813219fbe3fc9afe9cfc77d20156021c | 442d95eae2648231c941640899d9ff40c819f1b7 | refs/heads/main | 2023-07-06T04:56:14.788300 | 2021-08-10T20:54:12 | 2021-08-10T20:54:12 | 394,456,928 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 159 | py | for num in range (1, 21):
if num == 4 or num == 13:
print(f"{num} is unlucky")
elif num % 2 == 0:
print(f"{num} is even")
else:
print(f"{num} is odd") | [
"75456264+tomekregulski@users.noreply.github.com"
] | 75456264+tomekregulski@users.noreply.github.com |
503b94c2c787897176e342e8e2b5d4f9a4f63fc0 | 4898bf1929c6f25cd0c393debbf10cd9d85e8e02 | /dda_blog/admin.py | 174392da2b36a845d7ad59c8267734de147cb3aa | [
"Apache-2.0"
] | permissive | bogdan19adrian/b2b_festival | cb12c2137b5e4e30a6dfcf1bcf154b414bfd934e | 31700e5cebcd96a24b67889079492223c27e1a6f | refs/heads/master | 2020-06-04T21:28:05.733521 | 2020-03-31T19:02:08 | 2020-03-31T19:02:08 | 192,198,179 | 0 | 0 | Apache-2.0 | 2020-03-31T19:02:49 | 2019-06-16T14:05:30 | CSS | UTF-8 | Python | false | false | 391 | py | from django.contrib import admin
# Register your models here.
from dda_blog.models import Post, Category
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'slug', 'status', 'created_on')
list_filter = ("status",)
search_fields = ['title', 'content']
prepopulated_fields = {'slug': ('title',)}
admin.site.register(Post, PostAdmin)
admin.site.register(Category)
| [
"bogdan19adrian@gmail.com"
] | bogdan19adrian@gmail.com |
e8300499cac31bd2f59a82f05e00243f930a15e2 | 95777efa86b8a4800a9ddbdf38d4ffd1a3a3df0d | /4_create_assignment_test.py | f8eb5dd9c8d8865ac3d618d3646c9568ad6111d4 | [] | no_license | brennamcgrail/Exercise-7.1 | 67c682844db8e54d6b750bf0798471c1b43bf023 | 347ba0428e5118a2e40ded21cf38bd5edc5a5462 | refs/heads/main | 2023-01-01T17:37:36.348115 | 2020-10-14T01:46:57 | 2020-10-14T01:46:57 | 303,868,099 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 632 | py | import pytest
import System
#Tests if the program can handle a wrong username
def test_create_assignment(grading_system):
username = 'calyam'
password = '#yeet'
grading_system.login(username,password)
grading_system.usr.create_assignment('newAssignment', '02/18/20', 'cloud_computing')
grading_system.reload_data()
courses = grading_system.courses
if courses['cloud_computing']['assignments']['newAssignment']['due_date'] != '02/18/20':
assert False
@pytest.fixture
def grading_system():
gradingSystem = System.System()
gradingSystem.load_data()
return gradingSystem
| [
"noreply@github.com"
] | brennamcgrail.noreply@github.com |
21ac64b86ac01f6127eaad12d421b0674bb34137 | 09e57dd1374713f06b70d7b37a580130d9bbab0d | /benchmark/startQiskit_QC2241.py | 87a2f56dc78c4e74a541488325ff64371e14e705 | [
"BSD-3-Clause"
] | permissive | UCLA-SEAL/QDiff | ad53650034897abb5941e74539e3aee8edb600ab | d968cbc47fe926b7f88b4adf10490f1edd6f8819 | refs/heads/main | 2023-08-05T04:52:24.961998 | 2021-09-19T02:56:16 | 2021-09-19T02:56:16 | 405,159,939 | 2 | 0 | null | null | null | null | UTF-8 | Python | false | false | 4,242 | py | # qubit number=4
# total number=34
import cirq
import qiskit
from qiskit import IBMQ
from qiskit.providers.ibmq import least_busy
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import BasicAer, execute, transpile
from pprint import pprint
from qiskit.test.mock import FakeVigo
from math import log2
import numpy as np
import networkx as nx
def bitwise_xor(s: str, t: str) -> str:
length = len(s)
res = []
for i in range(length):
res.append(str(int(s[i]) ^ int(t[i])))
return ''.join(res[::-1])
def bitwise_dot(s: str, t: str) -> str:
length = len(s)
res = 0
for i in range(length):
res += int(s[i]) * int(t[i])
return str(res % 2)
def build_oracle(n: int, f) -> QuantumCircuit:
# implement the oracle O_f
# NOTE: use multi_control_toffoli_gate ('noancilla' mode)
# https://qiskit.org/documentation/_modules/qiskit/aqua/circuits/gates/multi_control_toffoli_gate.html
# https://quantumcomputing.stackexchange.com/questions/3943/how-do-you-implement-the-toffoli-gate-using-only-single-qubit-and-cnot-gates
# https://quantumcomputing.stackexchange.com/questions/2177/how-can-i-implement-an-n-bit-toffoli-gate
controls = QuantumRegister(n, "ofc")
target = QuantumRegister(1, "oft")
oracle = QuantumCircuit(controls, target, name="Of")
for i in range(2 ** n):
rep = np.binary_repr(i, n)
if f(rep) == "1":
for j in range(n):
if rep[j] == "0":
oracle.x(controls[j])
oracle.mct(controls, target[0], None, mode='noancilla')
for j in range(n):
if rep[j] == "0":
oracle.x(controls[j])
# oracle.barrier()
return oracle
def make_circuit(n:int,f) -> QuantumCircuit:
# circuit begin
input_qubit = QuantumRegister(n,"qc")
classical = ClassicalRegister(n, "qm")
prog = QuantumCircuit(input_qubit, classical)
prog.h(input_qubit[3]) # number=19
prog.cz(input_qubit[0],input_qubit[3]) # number=20
prog.h(input_qubit[3]) # number=21
prog.cx(input_qubit[0],input_qubit[3]) # number=23
prog.x(input_qubit[3]) # number=24
prog.cx(input_qubit[0],input_qubit[3]) # number=25
prog.cx(input_qubit[0],input_qubit[3]) # number=17
prog.rx(-0.48380526865282825,input_qubit[3]) # number=26
prog.h(input_qubit[1]) # number=2
prog.y(input_qubit[3]) # number=18
prog.h(input_qubit[2]) # number=3
prog.h(input_qubit[3]) # number=4
prog.y(input_qubit[3]) # number=12
prog.h(input_qubit[0]) # number=5
oracle = build_oracle(n-1, f)
prog.append(oracle.to_gate(),[input_qubit[i] for i in range(n-1)]+[input_qubit[n-1]])
prog.h(input_qubit[1]) # number=6
prog.h(input_qubit[2]) # number=7
prog.h(input_qubit[1]) # number=31
prog.cz(input_qubit[0],input_qubit[1]) # number=32
prog.h(input_qubit[1]) # number=33
prog.x(input_qubit[1]) # number=29
prog.cx(input_qubit[0],input_qubit[1]) # number=30
prog.h(input_qubit[3]) # number=8
prog.h(input_qubit[0]) # number=9
prog.y(input_qubit[2]) # number=10
prog.x(input_qubit[2]) # number=22
prog.y(input_qubit[2]) # number=11
prog.x(input_qubit[0]) # number=13
prog.x(input_qubit[0]) # number=14
# circuit end
for i in range(n):
prog.measure(input_qubit[i], classical[i])
return prog
if __name__ == '__main__':
a = "111"
b = "0"
f = lambda rep: bitwise_xor(bitwise_dot(a, rep), b)
prog = make_circuit(4,f)
IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q')
provider.backends()
backend = least_busy(provider.backends(filters=lambda x: x.configuration().n_qubits >= 2 and not x.configuration().simulator and x.status().operational == True))
sample_shot =8000
info = execute(prog, backend=backend, shots=sample_shot).result().get_counts()
backend = FakeVigo()
circuit1 = transpile(prog,backend,optimization_level=2)
writefile = open("../data/startQiskit_QC2241.csv","w")
print(info,file=writefile)
print("results end", file=writefile)
print(circuit1.__len__(),file=writefile)
print(circuit1,file=writefile)
writefile.close()
| [
"wangjiyuan123@yeah.net"
] | wangjiyuan123@yeah.net |
15f03cbe0d8bc9ba507d693b84f41925dab71fb5 | ab38e5600f5baefe542fe75c33c334683990930a | /train.py | da41afc6559627498bd8f17bc3e68850959cd76f | [] | no_license | maddigit/DeepSinger | 956c9ba8316bcbe95e57f7c4ec2c2c300e9cd7b0 | bb468ed4b669a2dc3c8eb56089d031def1677cc6 | refs/heads/main | 2023-08-23T13:59:24.584090 | 2021-09-23T09:07:12 | 2021-09-23T09:07:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 11,092 | py | import argparse
import pprint
import torch
import torch.nn as nn
import torch.optim as optim
import torch_optimizer as custom_optim
from torch.utils.data import DataLoader, random_split
import ignite.distributed as idist
import pandas as pd
from alignment.trainer import SingleTrainer,MaximumLikelihoodEstimationEngine
from alignment.dataloader import LJSpeechDataset,RandomBucketBatchSampler,TextAudioCollate
from alignment.Tokenizer import tokenizer,pho_tokenizer
from alignment.model.lyrics_alignment import alignment_model
def define_argparser(is_continue=False):
p = argparse.ArgumentParser()
if is_continue:
p.add_argument(
'--load_fn',
required=True,
help='Model file name to continue.'
)
p.add_argument(
'--model_fn',
required=not is_continue,
help='Model file name to save. Additional information would be annotated to the file name.'
)
p.add_argument(
'--music_dir',
required=not is_continue ,
help='music folder path'
)
p.add_argument(
'--bpe_model',
help='bpe_model file name',
default=None
)
p.add_argument(
'--train_f',
required=not is_continue,
help='Training set file name'
)
p.add_argument(
'--valid_f',
required=not is_continue,
help='validation set file name'
)
p.add_argument(
'--gpu_id',
type=int,
default=-1,
help='GPU ID to train. Currently, GPU parallel is not supported. -1 for CPU. Default=%(default)s'
)
p.add_argument(
'--batch_size',
type=int,
default=32,
help='Mini batch size for gradient descent. Default=%(default)s'
)
p.add_argument(
'--valid_batch_size',
type=int,
default=32,
help='Mini batch size for gradient descent. Default=%(default)s'
)
p.add_argument(
'--n_epochs',
type=int,
default=20,
help='Number of epochs to train. Default=%(default)s'
)
p.add_argument(
'--verbose',
type=int,
default=2,
help='VERBOSE_SILENT, VERBOSE_EPOCH_WISE, VERBOSE_BATCH_WISE = 0, 1, 2. Default=%(default)s'
)
p.add_argument(
'--init_epoch',
required=is_continue,
type=int,
default=1,
help='Set initial epoch number, which can be useful in continue training. Default=%(default)s'
)
p.add_argument(
'--max_ratio',
required=is_continue,
type=float,
default=0.1,
help='Set initial max_ratio, for greedy training Default=%(default)s'
)
p.add_argument(
'--dropout',
type=float,
default=.1,
help='Dropout rate. Default=%(default)s'
)
p.add_argument(
'--tbtt_step',
type=int,
default=40,
help='tbtt_step. Default=%(default)s'
)
p.add_argument(
'--W',
type=int,
default=120,
help='W. Default=%(default)s'
)
p.add_argument(
'--word_vec_size',
type=int,
default=512,
help='Word embedding vector dimension. Default=%(default)s'
)
p.add_argument(
'--en_hs',
type=int,
default=512,
help='encoder Hidden size'
)
p.add_argument(
'--de_hs',
type=int,
default=1024,
help='decoder Hidden size'
)
p.add_argument(
'--attention_rnn_dim',
type=int,
default=1024,
help='attention_rnn_dim'
)
p.add_argument(
'--attention_dim',
type=int,
default=256,
help='attention dim size'
)
p.add_argument(
'--location_feature_dim',
type=int,
default=128,
help='location_feature dim size'
)
p.add_argument(
'--lr',
type=float,
default=1.,
help='Initial learning rate. Default=%(default)s',
)
p.add_argument(
'--lr_step',
type=int,
default=0,
help='Number of epochs for each learning rate decay. Default=%(default)s',
)
p.add_argument(
'--lr_gamma',
type=float,
default=.5,
help='Learning rate decay rate. Default=%(default)s',
)
p.add_argument(
'--lr_decay_start',
type=int,
default=10,
help='Learning rate decay start at. Default=%(default)s',
)
p.add_argument(
'--lr_decay_end',
type=int,
default=10,
help='Learning rate decay end at. Default=%(default)s',
)
p.add_argument(
'--use_adam',
action='store_true',
help='Use Adam as optimizer instead of SGD. Other lr arguments should be changed.',
)
p.add_argument(
'--multi_gpu',
action='store_true',
help='multi-gpu',
)
p.add_argument(
'--log_dir',
type=str,
default='../tensorboard'
)
p.add_argument(
'--nohup',
action='store_true',
help='for better background logging',
)
p.add_argument(
'--use_autocast',
action='store_true',
help='Turn-off Automatic Mixed Precision (AMP), which speed-up training.',
)
p.add_argument(
'--init_scale',
type = float,
default=2.**16,
help = 'init scale of grad scaler' #https://github.com/pytorch/pytorch/issues/40497
)
config = p.parse_args()
return config
def get_model(input_size, output_size, config):
model = alignment_model(
input_size,
output_size,
config.word_vec_size,
config.en_hs,
config.de_hs,
config.attention_dim,
config.location_feature_dim,
config.dropout
)
return model
def get_crit(output_size, pad_index):
# Default weight for loss equals to 1, but we don't need to get loss for PAD token.
# Thus, set a weight for PAD to zero.
loss_weight = torch.ones(output_size)
loss_weight[pad_index] = 0.
# Instead of using Cross-Entropy loss,
# we can use Negative Log-Likelihood(NLL) loss with log-probability.
crit = nn.NLLLoss(
weight=loss_weight,
reduction='mean'
)
return crit
def get_optimizer(model, config):
if config.use_adam:
optimizer = optim.Adam(
model.parameters(),
lr=config.lr,
weight_decay=1e-6,
eps = 1e-6
)
else:
optimizer = optim.RMSprop(
model.parameters(),
lr=config.lr,
weight_decay=1e-6
)
return optimizer
def get_scheduler(optimizer, config):
if config.lr_step > 0:
lr_scheduler = optim.lr_scheduler.MultiStepLR(
optimizer,
milestones=[i for i in range(
max(0, config.lr_decay_start - 1),
config.lr_decay_end -1,
config.lr_step
)],
gamma=config.lr_gamma,
last_epoch=config.init_epoch - 1 if config.init_epoch > 1 else -1,
)
else:
lr_scheduler = None
return lr_scheduler
def add_graph(model,tb_logger,dataloader):
with torch.no_grad():
data = iter(dataloader).next()
device = next(model.parameters()).device
x,mask,x_length = data[0][0][:2,:,:500].to(device),data[0][1][:2,:500].to(device),data[0][2] #tensor,mask,length
y,_ = (data[1][0][:,:-1][:2,:10].to(device),data[1][1])
tb_logger.writer.add_graph(model=model,input_to_model=((x,mask),y) ,verbose=True)
def main(config, model_weight=None, opt_weight=None, scaler_weight = None):
def print_config(config):
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(vars(config))
print_config(config)
if config.bpe_model is not None:
tok = tokenizer(config.bpe_model)
else:
tok = pho_tokenizer()
train_data = pd.read_csv(f'{config.train_f}', sep='\t',
usecols=['video_name', 'lyrics'],
)
valid_data = pd.read_csv(f'{config.valid_f}', sep='\t',
usecols=['video_name', 'lyrics'],
)
train_data = train_data.sample(frac=1).reset_index(drop=True)
train_dataset = LJSpeechDataset(config.music_dir,train_data,tok = tok )
valid_dataset = LJSpeechDataset(config.music_dir,valid_data,tok = tok )
#train_dataset,valid_dataset = random_split(dataset,[config.train_size,config.valid_size]) #,generator=torch.Generator().manual_seed(42)'''
train_batch_sampler = RandomBucketBatchSampler(train_dataset, batch_size=config.batch_size, drop_last=False)
valid_batch_sampler = RandomBucketBatchSampler(valid_dataset, batch_size=config.batch_size, drop_last=False)
collate_fn = TextAudioCollate()
train_dataloader = DataLoader(train_dataset, batch_sampler=train_batch_sampler,collate_fn=collate_fn)
valid_dataloader = DataLoader(valid_dataset, batch_sampler=valid_batch_sampler,collate_fn=collate_fn)
#print(tok.vocab)
#print('-' * 80)
input_size, output_size = 128, len(tok.vocab)
model = get_model(input_size, output_size, config)
crit = get_crit(output_size, tok.pad)
if model_weight is not None:
model.load_state_dict(model_weight)
# Pass models to GPU device if it is necessary.
if config.multi_gpu:
model = nn.DataParallel(model)
model.cuda()
crit.cuda()
if config.gpu_id >= 0 and not config.multi_gpu:
model.cuda(config.gpu_id)
crit.cuda(config.gpu_id)
#train_dataloader = DataLoader(train_dataset, batch_sampler=train_batch_sampler,collate_fn=collate_fn)
#valid_dataloader = DataLoader(valid_dataset, batch_sampler=valid_batch_sampler,collate_fn=collate_fn)
optimizer = get_optimizer(model, config)
if opt_weight is not None and (config.use_adam or config.use_radam):
optimizer.load_state_dict(opt_weight)
lr_scheduler = get_scheduler(optimizer, config)
if config.verbose >= 2:
print(model)
print(crit)
print(optimizer)
# Start training. This function maybe equivalant to 'fit' function in Keras.
mle_trainer = SingleTrainer(MaximumLikelihoodEstimationEngine, config)
#add_graph(model,mle_trainer.tb_logger,valid_dataloader)
#mle_trainer.tb_logger.writer.add_graph(model=model,input_to_model=,verbose=True)
mle_trainer.tb_logger.writer.add_text('hp',str(config),0)
mle_trainer.train(
model,
crit,
optimizer,
train_loader=train_dataloader,
valid_loader=valid_dataloader,
n_epochs=config.n_epochs,
lr_scheduler=lr_scheduler,
scaler_weight = scaler_weight,
)
mle_trainer.tb_logger.close()
if __name__ == '__main__':
config = define_argparser()
main(config) | [
"67096173+Ldoun@users.noreply.github.com"
] | 67096173+Ldoun@users.noreply.github.com |
c02d3e512f42eb9a168a9d3a790ac5dee9e6579e | 6df2615de7ed690fd900e3d31e34f0f3876f1e91 | /python/multithread.py | 4a95976c80ef1169ab0a93b8678e16d1c8a55753 | [] | no_license | renwotao/exercise | fae4a98800e5a490a3c1a006b4b93aaeeb8f784a | 417b01ac8f1815bb17dc8ad89bd908176483395f | refs/heads/master | 2020-05-21T13:47:30.146718 | 2016-11-16T02:41:20 | 2016-11-16T02:41:20 | 63,961,039 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 3,675 | py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
'''
multithreads
Python两种模块:_thread和threading
_thread是低级模块
threading是高级模块,对_thread进行了封装
'''
import time, threading
# 新线程执行的代码
def loop():
print('thread %s is running...' % threading.current_thread().name)
n = 0
while n < 5:
n = n + 1
print('thread %s >>>> %s' % (threading.current_thread().name, n))
time.sleep(1)
print('thread %s ended.' % threading.current_thread().name)
print('thread %s is running...' % threading.current_thread().name)
t = threading.Thread(target=loop, name='LoopThread')
t.start()
t.join()
print('Thread %s ended.', threading.current_thread().name)
'''
Lock
'''
import time, threading
# 假定这是你的银行存款
balance = 0
def change_it(n):
# 先存取后取,结果应该为0
global balance
balance = balance + n
balance = balance - n
def run_thread(n):
for i in range(100000):
change_it(n)
t1 = threading.Thread(target=run_thread, args=(5,))
t2 = threading.Thread(target=run_thread, args=(8,))
t1.start()
t2.start()
t1.join()
t2.join()
print(balance)
balance = 0
lock = threading.Lock()
def run_thread1(n):
for i in range(100000):
# 先要获取锁
lock.acquire()
try:
# 放心地改
change_it(n)
finally:
# 改完了一定释放锁
lock.release()
t1 = threading.Thread(target=run_thread1, args=(5,))
t2 = threading.Thread(target=run_thread1, args=(8,))
t1.start()
t2.start()
t1.join()
t2.join()
print(balance)
'''
多核CPU
'''
'''
如果你不幸拥有一个多核CPU,你肯定在想,多核应该可以同时执行多个线程。
如果写一个死循环的话,会出现什么情况呢?
打开Mac OS X的Activity Monitor,或者Windows的Task Manager,
都可以监控某个进程的CPU使用率。
我们可以监控到一个死循环线程会100%占用一个CPU。
如果有两个死循环线程,在多核CPU中,可以监控到会占用200%的CPU,
也就是占用两个CPU核心。
要想把N核CPU的核心全部跑满,就必须启动N个死循环线程。
'''
# 死循环
import threading, multiprocessing
def loop():
x = 0
while True:
x = x^1
for i in range(multiprocessing.cpu_count()):
t = threading.Thread(target=loop)
t.start()
'''
启动与CPU核心数量相同的N个线程,在4核CPU上可以监控到CPU占用率仅有102%, 也就是仅使用了一核。
但是用C、C++或Java来改写相同的死循环,直接可以把全部核心跑满,
4核就跑到400%,8核就跑到800%,为什么Python不行呢?
因为Python的线程虽然是真正的线程,但解释器执行代码时,
有一个GIL锁:Global Interpreter Lock,任何Python线程执行前,
必须先获得GIL锁,然后,每执行100条字节码,解释器就自动释放GIL锁,
让别的线程有机会执行。
这个GIL全局锁实际上把所有线程的执行代码都给上了锁,
所以,多线程在Python中只能交替执行,即使100个线程跑在100核CPU上,
也只能用到1个核。
GIL是Python解释器设计的历史遗留问题,
通常我们用的解释器是官方实现的CPython,
要真正利用多核,除非重写一个不带GIL的解释器。
所以,在Python中,可以使用多线程,但不要指望能有效利用多核。
如果一定要通过多线程利用多核,那只能通过C扩展来实现,
不过这样就失去了Python简单易用的特点。
不过,也不用过于担心,Python虽然不能利用多线程实现多核任务,
但可以通过多进程实现多核任务。
多个Python进程有各自独立的GIL锁,互不影响。
'''
| [
"852443964@qq.com"
] | 852443964@qq.com |
0645492703ba86450f286c62b45bfe3b7cccccde | f62f02648bd86d16282209bfc2418bd220b5a20d | /filesystems/tests/common.py | 0f5ae7bda574f5867a72bfab27aa85e92d6f90f1 | [
"MIT"
] | permissive | Python3pkg/Filesystems | 5eaca86705288efedab804746530107bd0839438 | 724689713379fcf8059d4fdcaa51ab0035ff9792 | refs/heads/master | 2021-01-21T17:30:06.912092 | 2017-05-21T13:36:38 | 2017-05-21T13:36:38 | 91,959,754 | 0 | 0 | null | 2017-05-21T13:36:36 | 2017-05-21T13:36:36 | null | UTF-8 | Python | false | false | 29,176 | py | import errno
import os
from pyrsistent import s
from filesystems import Path, exceptions
from filesystems._path import RelativePath
class TestFS(object):
def test_open_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with fs.open(tempdir.descendant("unittesting"), "wb") as f:
f.write(b"some things!")
with fs.open(tempdir.descendant("unittesting")) as g:
self.assertEqual(g.read(), b"some things!")
def test_open_read_non_existing_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with self.assertRaises(exceptions.FileNotFound) as e:
fs.open(tempdir.descendant("unittesting"))
self.assertEqual(
str(e.exception), (
os.strerror(errno.ENOENT) +
": " +
str(tempdir.descendant("unittesting"))
),
)
def test_open_read_non_existing_nested_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with self.assertRaises(exceptions.FileNotFound) as e:
fs.open(tempdir.descendant("unittesting", "file"))
self.assertEqual(
str(e.exception), (
os.strerror(errno.ENOENT) +
": " +
str(tempdir.descendant("unittesting", "file"))
)
)
def test_open_append_non_existing_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with fs.open(tempdir.descendant("unittesting"), "ab") as f:
f.write(b"some ")
with fs.open(tempdir.descendant("unittesting"), "ab") as f:
f.write(b"things!")
with fs.open(tempdir.descendant("unittesting")) as g:
self.assertEqual(g.read(), b"some things!")
def test_open_append_non_existing_nested_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with self.assertRaises(exceptions.FileNotFound) as e:
fs.open(tempdir.descendant("unittesting", "file"), "ab")
self.assertEqual(
str(e.exception), (
os.strerror(errno.ENOENT) +
": " +
str(tempdir.descendant("unittesting", "file"))
)
)
def test_create_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with fs.create(tempdir.descendant("unittesting")) as f:
f.write(b"some things!")
with fs.open(tempdir.descendant("unittesting")) as g:
self.assertEqual(g.read(), b"some things!")
def test_create_file_existing_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with fs.create(tempdir.descendant("unittesting")):
pass
with self.assertRaises(exceptions.FileExists) as e:
fs.create(tempdir.descendant("unittesting"))
self.assertEqual(
str(e.exception), (
os.strerror(errno.EEXIST) +
": " +
str(tempdir.descendant("unittesting"))
),
)
def test_create_file_existing_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
fs.create_directory(tempdir.descendant("unittesting"))
with self.assertRaises(exceptions.FileExists) as e:
fs.create(tempdir.descendant("unittesting"))
self.assertEqual(
str(e.exception), (
os.strerror(errno.EEXIST) +
": " +
str(tempdir.descendant("unittesting"))
),
)
def test_create_file_existing_link(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
with self.assertRaises(exceptions.FileExists) as e:
fs.create(to)
self.assertEqual(
str(e.exception), os.strerror(errno.EEXIST) + ": " + str(to),
)
def test_create_non_existing_nested_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with self.assertRaises(exceptions.FileNotFound) as e:
fs.create(tempdir.descendant("unittesting", "file"))
self.assertEqual(
str(e.exception), (
os.strerror(errno.ENOENT) +
": " +
str(tempdir.descendant("unittesting", "file"))
)
)
def test_remove(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("directory")
fs.create_directory(directory)
a = directory.descendant("a")
b = directory.descendant("b")
c = directory.descendant("b", "c")
d = directory.descendant("d")
fs.touch(path=a)
fs.create_directory(path=b)
fs.touch(path=c)
fs.touch(path=d)
fs.remove(directory)
self.assertEqual(fs.children(path=tempdir), s())
def test_remove_non_existing_thing(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
child = tempdir.descendant("child")
with self.assertRaises(exceptions.FileNotFound) as e:
fs.remove(path=child)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(child),
)
def test_link(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.touch(source)
fs.link(source=source, to=to)
self.assertEqual(
dict(
exists=fs.exists(path=to),
is_dir=fs.is_dir(path=to),
is_file=fs.is_file(path=to),
is_link=fs.is_link(path=to),
), dict(
exists=True,
is_dir=False,
is_file=True,
is_link=True,
),
)
def test_link_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.create_directory(source)
fs.link(source=source, to=to)
self.assertEqual(
dict(
exists=fs.exists(path=to),
is_dir=fs.is_dir(path=to),
is_file=fs.is_file(path=to),
is_link=fs.is_link(path=to),
), dict(
exists=True,
is_dir=True,
is_file=False,
is_link=True,
),
)
def test_link_nonexisting_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
self.assertEqual(
dict(
exists=fs.exists(path=to),
is_dir=fs.is_dir(path=to),
is_file=fs.is_file(path=to),
is_link=fs.is_link(path=to),
), dict(
exists=False,
is_dir=False,
is_file=False,
is_link=True,
),
)
def test_link_existing(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
with self.assertRaises(exceptions.FileExists) as e:
fs.link(source=source, to=to)
self.assertEqual(
str(e.exception),
os.strerror(errno.EEXIST) + ": " + str(to),
)
def test_link_existing_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.touch(path=to)
with self.assertRaises(exceptions.FileExists) as e:
fs.link(source=source, to=to)
self.assertEqual(
str(e.exception),
os.strerror(errno.EEXIST) + ": " + str(to),
)
def test_link_existing_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.create_directory(path=to)
with self.assertRaises(exceptions.FileExists) as e:
fs.link(source=source, to=to)
self.assertEqual(
str(e.exception),
os.strerror(errno.EEXIST) + ": " + str(to),
)
def test_link_nonexistant(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
self.assertEqual(
dict(
exists=fs.exists(path=to),
is_dir=fs.is_dir(path=to),
is_file=fs.is_file(path=to),
is_link=fs.is_link(path=to),
), dict(
exists=False,
is_dir=False,
is_file=False,
is_link=True,
),
)
def test_multiple_links(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source = tempdir.descendant("source")
first = tempdir.descendant("first")
second = tempdir.descendant("second")
third = tempdir.descendant("third")
fs.link(source=source, to=first)
fs.link(source=first, to=second)
fs.link(source=second, to=third)
with fs.open(source, "wb") as f:
f.write(b"some things way over here!")
self.assertEqual(fs.contents_of(third), b"some things way over here!")
def test_link_child(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.create_directory(source)
fs.link(source=source, to=to)
self.assertEqual(
fs.realpath(to.descendant("child")),
source.descendant("child"),
)
def test_link_descendant_of_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source = tempdir.descendant("source")
not_a_dir = tempdir.descendant("dir")
fs.touch(not_a_dir)
with self.assertRaises(exceptions.NotADirectory) as e:
fs.link(source=source, to=not_a_dir.descendant("to"))
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOTDIR) + ": " + str(not_a_dir),
)
def test_circular_links(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
stuck = tempdir.descendant("stuck")
on = tempdir.descendant("on")
loop = tempdir.descendant("loop")
fs.link(source=stuck, to=on)
fs.link(source=on, to=loop)
fs.link(source=loop, to=stuck)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.realpath(stuck)
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(stuck),
)
def test_direct_circular_link(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
loop = tempdir.descendant("loop")
fs.link(source=loop, to=loop)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.realpath(loop)
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(loop),
)
def test_link_into_a_circle(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
dont = tempdir.descendant("dont")
fall = tempdir.descendant("fall")
into = tempdir.descendant("into")
the = tempdir.descendant("the")
hole = tempdir.descendant("hole")
fs.link(source=fall, to=dont)
fs.link(source=into, to=fall)
fs.link(source=the, to=into)
fs.link(source=the, to=hole)
fs.link(source=hole, to=the)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.realpath(dont)
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(the),
)
def test_circular_loop_child(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
loop = tempdir.descendant("loop")
fs.link(source=loop, to=loop)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.realpath(loop.descendant("child"))
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(loop),
)
def test_read_from_link(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
with fs.open(source, "wb") as f:
f.write(b"some things over here!")
self.assertEqual(fs.contents_of(to), b"some things over here!")
def test_write_to_link(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
with fs.open(to, "wb") as f:
f.write(b"some things over here!")
self.assertEqual(fs.contents_of(source), b"some things over here!")
def test_write_to_created_child(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.create_directory(source)
fs.link(source=source, to=to)
child = to.descendant("child")
with fs.create(child) as f:
f.write(b"some things over here!")
self.assertEqual(fs.contents_of(child), b"some things over here!")
def test_read_from_loop(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
loop = tempdir.descendant("loop")
fs.link(source=loop, to=loop)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.open(path=loop)
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(loop),
)
def test_write_to_loop(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
loop = tempdir.descendant("loop")
fs.link(source=loop, to=loop)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.open(path=loop, mode="wb")
self.assertEqual(
str(e.exception),
os.strerror(errno.ELOOP) + ": " + str(loop),
)
def test_create_loop_descendant(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
loop = tempdir.descendant("loop")
fs.link(source=loop, to=loop)
with self.assertRaises(exceptions.SymbolicLoop) as e:
fs.create(path=loop.descendant("child", "path"))
# We'd really like the first one, but on a real native FS, looking for
# it would be a race condition, so we allow the latter.
acceptable = {
os.strerror(errno.ELOOP) + ": " + str(loop),
os.strerror(errno.ELOOP) + ": " + str(loop.descendant("child")),
}
self.assertIn(str(e.exception), acceptable)
def test_link_nonexistant_parent(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source = tempdir.descendant("source")
orphan = tempdir.descendant("nonexistant", "orphan")
with self.assertRaises(exceptions.FileNotFound) as e:
fs.link(source=source, to=orphan)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(orphan.parent()),
)
def test_realpath(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
source, to = tempdir.descendant("source"), tempdir.descendant("to")
fs.link(source=source, to=to)
self.assertEqual(fs.realpath(to), source)
def test_realpath_relative(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source, to = RelativePath("source", "dir"), tempdir.descendant("to")
fs.link(source=source, to=to)
self.assertEqual(
fs.realpath(to),
to.sibling("source").descendant("dir"),
)
def test_realpath_normal_path(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
tempdir = fs.realpath(tempdir)
source = tempdir.descendant("source")
self.assertEqual(fs.realpath(source), source)
def test_remove_does_not_follow_directory_links(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("directory")
fs.create_directory(path=directory)
fs.touch(directory.descendant("a"))
link = tempdir.descendant("link")
fs.link(source=directory, to=link)
self.assertTrue(fs.is_link(path=link))
fs.remove(path=link)
self.assertEqual(
fs.children(path=directory), s(directory.descendant("a")),
)
def test_create_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("dir")
self.assertFalse(fs.is_dir(path=directory))
fs.create_directory(path=directory)
self.assertEqual(
dict(
exists=fs.exists(path=directory),
is_dir=fs.is_dir(path=directory),
is_file=fs.is_file(path=directory),
is_link=fs.is_link(path=directory),
),
dict(exists=True, is_dir=True, is_file=False, is_link=False),
)
def test_create_existing_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("dir")
fs.create_directory(path=directory)
self.assertTrue(fs.is_dir(path=directory))
with self.assertRaises(exceptions.FileExists) as e:
fs.create_directory(path=directory)
self.assertEqual(
str(e.exception),
os.strerror(errno.EEXIST) + ": " + str(directory),
)
def test_create_existing_directory_from_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
not_a_dir = tempdir.descendant("not_a_dir")
fs.touch(not_a_dir)
with self.assertRaises(exceptions.FileExists) as e:
fs.create_directory(path=not_a_dir)
self.assertEqual(
str(e.exception),
os.strerror(errno.EEXIST) + ": " + str(not_a_dir),
)
def test_create_directory_parent_does_not_exist(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("some", "child", "dir")
self.assertFalse(fs.is_dir(path=directory.parent()))
with self.assertRaises(exceptions.FileNotFound) as e:
fs.create_directory(path=directory)
# Putting the first dir that doesn't exist would require some
# traversal, so just stick with the parent for now.
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(directory.parent()),
)
def test_remove_empty_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("dir")
fs.create_directory(path=directory)
self.assertTrue(fs.is_dir(path=directory))
fs.remove_empty_directory(path=directory)
self.assertFalse(fs.is_dir(path=directory))
def test_remove_nonempty_empty_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
nonempty = tempdir.descendant("dir")
fs.create_directory(path=nonempty)
fs.create_directory(nonempty.descendant("dir2"))
self.assertTrue(fs.is_dir(path=nonempty))
with self.assertRaises(exceptions.DirectoryNotEmpty) as e:
fs.remove_empty_directory(path=nonempty)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOTEMPTY) + ": " + str(nonempty),
)
def test_remove_nonexisting_empty_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("dir")
self.assertFalse(fs.is_dir(path=directory))
with self.assertRaises(exceptions.FileNotFound) as e:
fs.remove_empty_directory(path=directory)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(directory),
)
def test_remove_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
child = tempdir.descendant("child")
fs.touch(path=child)
self.assertTrue(fs.exists(path=child))
fs.remove_file(path=child)
self.assertFalse(fs.exists(path=child))
def test_remove_nonexisting_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
child = tempdir.descendant("child")
self.assertFalse(fs.is_file(path=child))
with self.assertRaises(exceptions.FileNotFound) as e:
fs.remove_file(path=child)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(child),
)
def test_remove_nonexisting_file_nonexisting_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
child = tempdir.descendant("dir", "child")
self.assertFalse(fs.is_file(path=child))
with self.assertRaises(exceptions.FileNotFound) as e:
fs.remove_file(path=child)
self.assertEqual(
str(e.exception), os.strerror(errno.ENOENT) + ": " + str(child),
)
def test_non_existing_file_types(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
nonexistant = tempdir.descendant("solipsism")
self.assertEqual(
dict(
exists=fs.exists(path=nonexistant),
is_dir=fs.is_dir(path=nonexistant),
is_file=fs.is_file(path=nonexistant),
is_link=fs.is_link(path=nonexistant),
),
dict(exists=False, is_dir=False, is_file=False, is_link=False),
)
def test_list_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
a = tempdir.descendant("a")
b = tempdir.descendant("b")
c = tempdir.descendant("b", "c")
fs.touch(path=a)
fs.create_directory(path=b)
fs.touch(path=c)
self.assertEqual(set(fs.list_directory(tempdir)), {"a", "b"})
def test_list_empty_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
self.assertEqual(set(fs.list_directory(tempdir)), set())
def test_list_non_existing_directory(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
directory = tempdir.descendant("dir")
self.assertFalse(fs.is_dir(path=directory))
with self.assertRaises(exceptions.FileNotFound) as e:
fs.list_directory(directory)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOENT) + ": " + str(directory),
)
def test_list_file(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
not_a_dir = tempdir.descendant("not_a_dir")
fs.touch(not_a_dir)
with self.assertRaises(exceptions.NotADirectory) as e:
fs.list_directory(not_a_dir)
self.assertEqual(
str(e.exception),
os.strerror(errno.ENOTDIR) + ": " + str(not_a_dir),
)
def test_touch(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
child = tempdir.descendant("a")
self.assertFalse(fs.exists(path=child))
fs.touch(path=child)
self.assertEqual(
dict(
exists=fs.exists(path=child),
is_dir=fs.is_dir(path=child),
is_file=fs.is_file(path=child),
is_link=fs.is_link(path=child),
),
dict(exists=True, is_dir=False, is_file=True, is_link=False),
)
def test_children(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
a = tempdir.descendant("a")
b = tempdir.descendant("b")
c = tempdir.descendant("b", "c")
d = tempdir.descendant("d")
fs.touch(path=a)
fs.create_directory(path=b)
fs.touch(path=c)
fs.link(source=c, to=d)
self.assertEqual(fs.children(path=tempdir), s(a, b, d))
def test_glob_children(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
a = tempdir.descendant("a")
b = tempdir.descendant("b")
c = tempdir.descendant("b", "c")
abc = tempdir.descendant("abc")
fedcba = tempdir.descendant("fedcba")
fs.touch(path=a)
fs.create_directory(path=b)
fs.touch(path=c)
fs.touch(path=abc)
fs.touch(path=fedcba)
self.assertEqual(
fs.glob_children(path=tempdir, glob="*b*"),
s(b, abc, fedcba),
)
def test_contents_of(self):
fs = self.FS()
tempdir = fs.temporary_directory()
self.addCleanup(fs.remove, tempdir)
with fs.open(tempdir.descendant("unittesting"), "wb") as f:
f.write(b"some more things!")
self.assertEqual(
fs.contents_of(tempdir.descendant("unittesting")),
b"some more things!",
)
# With how crazy computers are, I'm not actually 100% sure that
# these tests for the behavior of the root directory will always be
# the case. But, onward we go.
def test_root_always_exists(self):
fs = self.FS()
self.assertTrue(fs.exists(Path.root()))
def test_realpath_root(self):
fs = self.FS()
self.assertEqual(fs.realpath(Path.root()), Path.root())
| [
"Julian@GrayVines.com"
] | Julian@GrayVines.com |
c528ef9e16b0893e000ac1b3027d055e2bf45e5e | 036eb141eb01079823f7d6796aef034ac4eea456 | /data.py | 43a98a41d033447e52a7452af5f51e4515448da3 | [] | no_license | 106071002/test | c0f4687698a8861adb988c28dd3b3ef2617e9203 | a3f35f55ba2eb6257bd8d0e44ee83baabe2a8677 | refs/heads/main | 2023-04-01T00:42:32.322128 | 2021-04-09T13:41:14 | 2021-04-09T13:41:14 | 355,942,377 | 0 | 0 | null | 2021-04-09T13:41:15 | 2021-04-08T14:35:35 | Python | UTF-8 | Python | false | false | 9,387 | py | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 27 10:24:01 2021
@author: Bear
"""
from abc import ABCMeta, abstractmethod
from event import MarketEvent
import os, os.path
import numpy as np
import pandas as pd
import time
import datetime
###data handler
class DataHandler(object):
"""
DataHandler is an abstract base class providing an interface for
all subsequent (inherited) data handlers (both live and historic).
The goal of a (derived) DataHandler object is to output a generated
set of bars (OHLCVI) for each symbol requested.
This will replicate how a live strategy would function as current
market data would be sent "down the pipe". Thus a historic and live
system will be treated identically by the rest of the backtesting suite.
"""
__metaclass__ = ABCMeta
@abstractmethod
def get_latest_bar(self, symbol):
"""
Returns the last bar updated.
"""
raise NotImplementedError("Should implement get_latest_bar()")
@abstractmethod
def get_latest_bars(self, symbol, N=1):
"""
Returns the last N bars updated.
"""
raise NotImplementedError("Should implement get_latest_bars()")
@abstractmethod
def get_latest_bar_datetime(self, symbol):
"""
Returns a Python datetime object for the last bar.
"""
raise NotImplementedError("Should implement get_latest_bar_datetime()")
@abstractmethod
def get_latest_bar_value(self, symbol, val_type):
"""
Returns one of the Open, High, Low, Close, Volume or OI
from the last bar.
"""
raise NotImplementedError("Should implement get_latest_bar_value()")
@abstractmethod
def get_latest_bars_values(self, symbol, val_type, N=1):
"""
Returns the last N bar values from the
latest_symbol list, or N-k if less available.
"""
raise NotImplementedError("Should implement get_latest_bars_values()")
@abstractmethod
def update_bars(self):
"""
Pushes the latest bars to the bars_queue for each symbol
in a tuple OHLCVI format: (datetime, open, high, low,
close, volume, open interest).
"""
raise NotImplementedError("Should implement update_bars()")
class HistoricCSVDataHandler(DataHandler):
"""
HistoricCSVDataHandler is designed to read CSV files for
each requested symbol from disk and provide an interface
to obtain the "latest" bar in a manner identical to a live
trading interface.
"""
def __init__(self, events, csv_dir, symbol_list):
"""
Initialises the historic data handler by requesting
the location of the CSV files and a list of symbols.
It will be assumed that all files are of the form
’symbol.csv’, where symbol is a string in the list.
Parameters:
events - The Event Queue.
csv_dir - Absolute directory path to the CSV files.
symbol_list - A list of symbol strings.
"""
self.events = events
self.csv_dir = csv_dir
self.symbol_list = symbol_list
self.symbol_data = {}
self.latest_symbol_data = {}
self.continue_backtest = True
self._open_convert_csv_files()
def _open_convert_csv_files(self):
"""
Opens the CSV files from the data directory, converting
them into pandas DataFrames within a symbol dictionary.
For this handler it will be assumed that the data is
taken from Yahoo. Thus its format will be respected.
"""
data_start_date = datetime.datetime(2020,12,17,8,46,0)
data_end_date = datetime.datetime(2021,3,31,12,8,0)
periods = int((data_end_date - data_start_date).days *24*60 + (data_end_date - data_start_date).seconds / 60)
standard_date = [] #只有年月日
standard_df = pd.read_csv("TXFF1.csv") #用來當標準時間的CSV
standard_datetime = standard_df["Date"] #年月日時分秒
standard_datetime.index = pd.DatetimeIndex(standard_datetime)
standard_datetime_day = list(standard_datetime.between_time("8:46:0","13:45:0")) #只取日盤時間
standard_datetime = standard_datetime_day
standard_datetime.sort()
standard_datetime = pd.Series(standard_datetime)
for i in range(0,len(standard_datetime)):
standard_date.append(standard_datetime[i][0:10])
standard_date = list(set(standard_date)) #避免重複
standard_date.sort()
start_date_index = standard_date.index(str(data_start_date)[0:10]) #找出起始日在standart_date的index
standard_date = standard_date[start_date_index:len(standard_date)]
temp = []
for i in range(0,periods+1):
minute = (data_start_date + datetime.timedelta(minutes=i)).strftime("%Y-%m-%d %H:%M:%S")
temp.append(minute)
#只取日盤時間
temp = pd.Series(temp)
temp.index = pd.DatetimeIndex(temp)
temp_day = list(temp.between_time("8:46:0","13:45:0"))
temp = temp_day
temp.sort()
for i in range(len(temp)-1,-1,-1):
if temp[i][0:10] not in standard_date: #如果日期不在標準日期裡面就拿掉 第一層判斷
temp.remove(temp[i]) #去掉temp[i]元素
time_index = pd.DatetimeIndex(temp)
for s in self.symbol_list:
# Load the CSV file with no header information, indexed on date
self.symbol_data[s] = pd.io.parsers.read_csv(
os.path.join(self.csv_dir, '%s.csv' % s),
header=0, index_col=0, parse_dates=True,
names=[
'datetime', 'open', 'high',
'low', 'close', 'adj_close', 'volume'
]
).sort_index()
# Set the latest symbol_data to None
self.latest_symbol_data[s] = []
# Reindex the dataframes
for s in self.symbol_list:
self.symbol_data[s] = self.symbol_data[s].reindex(
index=time_index,method="pad").fillna(0).iterrows()
def _get_new_bar(self, symbol):
"""
Returns the latest bar from the data feed.
"""
for b in self.symbol_data[symbol]:
yield b
def get_latest_bar(self, symbol):
"""
Returns the last bar from the latest_symbol list.
"""
try:
bars_list = self.latest_symbol_data[symbol]
except KeyError:
print("That symbol is not available in the historical data set.")
raise
else:
return bars_list[-1]
def get_latest_bars(self, symbol, N=1):
"""
Returns the last N bars from the latest_symbol list,
or N-k if less available.
"""
try:
bars_list = self.latest_symbol_data[symbol]
except KeyError:
print("That symbol is not available in the historical data set.")
raise
else:
return bars_list[-N:]
def get_latest_bar_datetime(self, symbol):
"""
Returns a Python datetime object for the last bar.
"""
try:
bars_list = self.latest_symbol_data[symbol]
except KeyError:
print("That symbol is not available in the historical data set.")
raise
else:
return bars_list[-1][0]
def get_latest_bar_value(self, symbol, val_type):
"""
Returns one of the Open, High, Low, Close, Volume or OI
values from the pandas Bar series object.
"""
try:
bars_list = self.latest_symbol_data[symbol]
except KeyError:
print("That symbol is not available in the historical data set.")
raise
else:
return getattr(bars_list[-1][1], val_type)
def get_latest_bars_values(self, symbol, val_type, N=1):
"""
Returns the last N bar values from the
latest_symbol list, or N-k if less available.
"""
try:
bars_list = self.get_latest_bars(symbol, N)
except KeyError:
print("That symbol is not available in the historical data set.")
raise
else:
return np.array([getattr(b[1], val_type) for b in bars_list])
def update_bars(self):
"""
Pushes the latest bar to the latest_symbol_data structure
for all symbols in the symbol list.
"""
for s in self.symbol_list:
try:
bar = next(self._get_new_bar(s))
except StopIteration:
self.continue_backtest = False
else:
if bar is not None:
self.latest_symbol_data[s].append(bar)
self.events.put(MarketEvent())
| [
"noreply@github.com"
] | 106071002.noreply@github.com |
d6bbfa71ab64d7232673f42c79ea4342919a73a6 | ebde4a33826e09d27a3123ff746b9cc0ca834ff2 | /mob_tracker/migrations/0006_auto_20180607_2015.py | c63fda75ddaa14f2b35ec36c8453d0db0c566fb9 | [] | no_license | cippero/mob | 009af7eeea9b9a18ccefde1cb7b6d3eaebd495cb | 94fb49fbe2bc6e71b823b08503244da884a8513a | refs/heads/master | 2022-12-11T09:54:08.201582 | 2018-11-13T22:59:33 | 2018-11-13T22:59:33 | 136,075,300 | 0 | 0 | null | 2022-12-08T02:19:14 | 2018-06-04T19:51:38 | Python | UTF-8 | Python | false | false | 589 | py | # Generated by Django 2.0.3 on 2018-06-08 03:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mob_tracker', '0005_auto_20180607_1610'),
]
operations = [
migrations.AlterField(
model_name='entry',
name='description',
field=models.TextField(blank=True, default=None),
),
migrations.AlterField(
model_name='entry',
name='subcategory',
field=models.CharField(blank=True, default=None, max_length=100),
),
]
| [
"gilwein@gmail.com"
] | gilwein@gmail.com |
34c06de3d2b630b8d50143e483d55083cfa54e93 | f8732f8c438d620f99864f10962bee76c638f735 | /ESP/socket_ESP2ESP_STA.py | 518aaeabc9be3f29d475697ee7fa1d12265c77e4 | [] | no_license | clarkyehpccu/PythonWork | 4ce48e755d37a557b83dd4276ac02721f1a144ae | 2c6756c722e7007949423988c33c6e04713412d3 | refs/heads/master | 2021-06-25T12:48:06.470890 | 2021-03-12T06:37:01 | 2021-03-12T06:37:01 | 208,383,128 | 2 | 0 | null | 2021-03-11T08:54:13 | 2019-09-14T03:26:59 | Python | UTF-8 | Python | false | false | 740 | py | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 25 11:10:27 2020
@author: clark
"""
#COM4 STA
import network
import time
import socket
myap=network.WLAN(network.AP_IF)
myap.active(0) #關閉192.168.4.1
myap.ifconfig()
mysta=network.WLAN(network.STA_IF)
mysta.active(True)
mysta.connect('MicroPython-e47c74', 'micropythoN')# micropythoN
mysta.ifconfig()
#-----
while True:
mysocket = socket.socket()
mysocket.connect(('192.168.4.1',8268)) # ('192.168.1.4',8266)
msg = input('Please input a message(Exit to quit):')
if msg.upper() == 'EXIT':
break
mysocket.send(msg.encode('utf-8'))
print("get:" + mysocket.recv(128).decode('utf-8') )
mysocket.close();
print('Close Socket')
print('-----END------')
| [
"ybc3@ulive.pccu.edu.tw"
] | ybc3@ulive.pccu.edu.tw |
8f270738cff1f46acd30fe69371cc6974d469105 | 0a150a2170949dbb5968644e8f661a0476e3a30b | /alfanous-0.7.28/alfanous-0.7.28/Support/whoosh/reading.py | 6044db58418e884b2cbb9bcc9127769e86ba95e0 | [] | no_license | mubashir-dev/AlQuran_Recitation_Recognition | 5ecebfd55d645beefec5ca5b9a5735cf91a4f5a3 | ad6fffb6e499e89ebd0517069cd700671f636e61 | refs/heads/master | 2022-12-24T20:32:40.617376 | 2020-09-24T16:56:06 | 2020-09-24T16:56:06 | 298,332,743 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 14,867 | py | #===============================================================================
# Copyright 2007 Matt Chaput
#
# 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 in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
"""This module contains classes that allow reading from an index.
"""
from bisect import bisect_right
from heapq import heapify, heapreplace, heappop, nlargest
from alfanous.Support.whoosh.fields import UnknownFieldError
from alfanous.Support.whoosh.util import ClosableMixin
from alfanous.Support.whoosh.postings import MultiPostingReader
# Exceptions
class TermNotFound(Exception):
pass
# Base class
class IndexReader(ClosableMixin):
"""Do not instantiate this object directly. Instead use Index.reader().
"""
def __contains__(self, term):
"""Returns True if the given term tuple (fieldid, text) is
in this reader.
"""
raise NotImplementedError
def close(self):
"""Closes the open files associated with this reader.
"""
raise NotImplementedError
def has_deletions(self):
"""Returns True if the underlying index/segment has deleted
documents.
"""
raise NotImplementedError
def is_deleted(self, docnum):
"""Returns True if the given document number is marked deleted.
"""
raise NotImplementedError
def stored_fields(self, docnum):
"""Returns the stored fields for the given document number.
"""
raise NotImplementedError
def all_stored_fields(self):
"""Yields the stored fields for all documents.
"""
raise NotImplementedError
def doc_count_all(self):
"""Returns the total number of documents, DELETED OR UNDELETED,
in this reader.
"""
raise NotImplementedError
def doc_count(self):
"""Returns the total number of UNDELETED documents in this reader.
"""
raise NotImplementedError
def scorable(self, fieldid):
"""Returns true if the given field stores field lengths.
"""
return self.schema[fieldid].scorable
def fieldname_to_num(self, fieldname):
return self.schema.name_to_number(fieldname)
def field_length(self, fieldid):
"""Returns the total number of terms in the given field. This is used
by some scoring algorithms.
"""
raise NotImplementedError
def doc_field_length(self, docnum, fieldid):
"""Returns the number of terms in the given field in the given
document. This is used by some scoring algorithms.
"""
raise NotImplementedError
def doc_field_lengths(self, docnum):
"""Returns an array corresponding to the lengths of the scorable fields
in the given document. It's up to the caller to correlate the positions
of the numbers in the array with the scorable fields in the schema.
"""
raise NotImplementedError
def has_vector(self, docnum, fieldid):
"""Returns True if the given document has a term vector for the given
field.
"""
raise NotImplementedError
def postings(self, fieldid, text, exclude_docs=None):
"""Returns a :class:`~whoosh.postings.PostingReader` for the postings
of the given term.
>>> pr = searcher.postings("content", "render")
>>> pr.skip_to(10)
>>> pr.id
12
:param fieldid: the field name or field number of the term.
:param text: the text of the term.
:exclude_docs: an optional BitVector of documents to exclude from the
results, or None to not exclude any documents.
:rtype: :class:`whoosh.postings.PostingReader`
"""
raise NotImplementedError
def vector(self, docnum, fieldid):
"""Returns a :class:`~whoosh.postings.PostingReader` object for the
given term vector.
>>> docnum = searcher.document_number(path=u'/a/b/c')
>>> v = searcher.vector(docnum, "content")
>>> v.all_as("frequency")
[(u"apple", 3), (u"bear", 2), (u"cab", 2)]
:param docnum: the document number of the document for which you want
the term vector.
:param fieldid: the field name or field number of the field for which
you want the term vector.
:rtype: :class:`whoosh.postings.PostingReader`
"""
raise NotImplementedError
def vector_as(self, astype, docnum, fieldid):
"""Returns an iterator of (termtext, value) pairs for the terms in the
given term vector. This is a convenient shortcut to calling vector()
and using the PostingReader object when all you want are the terms
and/or values.
>>> docnum = searcher.document_number(path=u'/a/b/c')
>>> searcher.vector_as("frequency", docnum, "content")
[(u"apple", 3), (u"bear", 2), (u"cab", 2)]
:param docnum: the document number of the document for which you want
the term vector.
:param fieldid: the field name or field number of the field for which
you want the term vector.
:param astype: a string containing the name of the format you want the
term vector's data in, for example "weights".
"""
vec = self.vector(docnum, fieldid)
return vec.all_as(astype)
def format(self, fieldid):
"""Returns the Format object corresponding to the given field name.
"""
if fieldid in self.schema:
return self.schema[fieldid].format
else:
raise UnknownFieldError(fieldid)
def __iter__(self):
"""Yields (fieldnum, text, docfreq, indexfreq) tuples for each term in
the reader, in lexical order.
"""
raise NotImplementedError
def doc_frequency(self, fieldid, text):
"""Returns how many documents the given term appears in.
"""
raise NotImplementedError
def frequency(self, fieldid, text):
"""Returns the total number of instances of the given term in the
collection.
"""
raise NotImplementedError
def iter_from(self, fieldnum, text):
"""Yields (field_num, text, doc_freq, index_freq) tuples for all terms
in the reader, starting at the given term.
"""
raise NotImplementedError
def expand_prefix(self, fieldid, prefix):
"""Yields terms in the given field that start with the given prefix.
"""
fieldid = self.schema.to_number(fieldid)
for fn, t, _, _ in self.iter_from(fieldid, prefix):
if fn != fieldid or not t.startswith(prefix):
return
yield t
def all_terms(self):
"""Yields (fieldname, text) tuples for every term in the index.
"""
num2name = self.schema.number_to_name
current_fieldnum = None
current_fieldname = None
for fn, t, _, _ in self:
# Only call self.schema.number_to_name when the
# field number changes.
if fn != current_fieldnum:
current_fieldnum = fn
current_fieldname = num2name(fn)
yield (current_fieldname, t)
def iter_field(self, fieldid, prefix=''):
"""Yields (text, doc_freq, index_freq) tuples for all terms in the
given field.
"""
fieldid = self.schema.to_number(fieldid)
for fn, t, docfreq, freq in self.iter_from(fieldid, prefix):
if fn != fieldid:
return
yield t, docfreq, freq
def iter_prefix(self, fieldid, prefix):
"""Yields (field_num, text, doc_freq, index_freq) tuples for all terms
in the given field with a certain prefix.
"""
fieldid = self.schema.to_number(fieldid)
for fn, t, docfreq, colfreq in self.iter_from(fieldid, prefix):
if fn != fieldid or not t.startswith(prefix):
return
yield (t, docfreq, colfreq)
def most_frequent_terms(self, fieldid, number=5, prefix=''):
"""Returns the top 'number' most frequent terms in the given field as a
list of (frequency, text) tuples.
"""
return nlargest(number, ((tf, token)
for token, _, tf
in self.iter_prefix(fieldid, prefix)))
def most_distinctive_terms(self, fieldid, number=5, prefix=None):
"""Returns the top 'number' terms with the highest ``tf*idf`` scores as
a list of (score, text) tuples.
"""
return nlargest(number, ((tf * (1.0 / df), token)
for token, df, tf
in self.iter_prefix(fieldid, prefix)))
def lexicon(self, fieldid):
"""Yields all terms in the given field.
"""
for t, _, _ in self.iter_field(fieldid):
yield t
# Multisegment reader class
class MultiReader(IndexReader):
"""Do not instantiate this object directly. Instead use Index.reader().
"""
def __init__(self, readers, doc_offsets, schema):
self.readers = readers
self.doc_offsets = doc_offsets
self.schema = schema
self._scorable_fields = self.schema.scorable_fields()
self.is_closed = False
def __contains__(self, term):
return any(r.__contains__(term) for r in self.readers)
def __iter__(self):
return self._merge_iters([iter(r) for r in self.readers])
def has_deletions(self):
return any(r.has_deletions() for r in self.readers)
def is_deleted(self):
segmentnum, segmentdoc = self._segment_and_doc
return self.readers[segmentnum].is_deleted(segmentdoc)
def stored_fields(self, docnum):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].stored_fields(segmentdoc)
def all_stored_fields(self):
for reader in self.readers:
for result in reader.all_stored_fields():
yield result
def close(self):
for d in self.readers:
d.close()
self.is_closed = True
def doc_count_all(self):
return sum(dr.doc_count_all() for dr in self.readers)
def doc_count(self):
return sum(dr.doc_count() for dr in self.readers)
def field_length(self, fieldnum):
return sum(dr.field_length(fieldnum) for dr in self.readers)
def doc_field_length(self, docnum, fieldid):
fieldid = self.schema.to_number(fieldid)
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].doc_field_length(segmentdoc, fieldid)
def doc_field_lengths(self, docnum):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].doc_field_lengths(segmentdoc)
def unique_count(self, docnum):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].unique_count(segmentdoc)
def _document_segment(self, docnum):
return max(0, bisect_right(self.doc_offsets, docnum) - 1)
def _segment_and_docnum(self, docnum):
segmentnum = self._document_segment(docnum)
offset = self.doc_offsets[segmentnum]
return segmentnum, docnum - offset
def has_vector(self, docnum, fieldid):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].has_vector(segmentdoc, fieldid)
def postings(self, fieldid, text, exclude_docs=None):
format = self.schema[fieldid].format
postreaders = []
docoffsets = []
for i, r in enumerate(self.readers):
if (fieldid, text) in r:
postreaders.append(r.postings(fieldid, text,
exclude_docs=exclude_docs))
docoffsets.append(self.doc_offsets[i])
if not postreaders:
raise TermNotFound(fieldid, text)
else:
return MultiPostingReader(format, postreaders, docoffsets)
def vector(self, docnum, fieldid):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].vector(segmentdoc, fieldid)
def vector_as(self, astype, docnum, fieldid):
segmentnum, segmentdoc = self._segment_and_docnum(docnum)
return self.readers[segmentnum].vector_as(astype, segmentdoc, fieldid)
def iter_from(self, fieldnum, text):
return self._merge_iters([r.iter_from(fieldnum, text)
for r in self.readers])
def doc_frequency(self, fieldnum, text):
return sum(r.doc_frequency(fieldnum, text) for r in self.readers)
def frequency(self, fieldnum, text):
return sum(r.frequency(fieldnum, text) for r in self.readers)
def _merge_iters(self, iterlist):
# Merge-sorts terms coming from a list of
# term iterators (IndexReader.__iter__() or
# IndexReader.iter_from()).
# Fill in the list with the head term from each iterator.
# infos is a list of [headterm, iterator] lists.
current = []
for it in iterlist:
fnum, text, docfreq, termcount = it.next()
current.append((fnum, text, docfreq, termcount, it))
heapify(current)
# Number of active iterators
active = len(current)
while active > 0:
# Peek at the first term in the sorted list
fnum, text = current[0][:2]
docfreq = 0
termcount = 0
# Add together all terms matching the first term in the list.
while current and current[0][0] == fnum and current[0][1] == text:
docfreq += current[0][2]
termcount += current[0][3]
it = current[0][4]
try:
fn, t, df, tc = it.next()
heapreplace(current, (fn, t, df, tc, it))
except StopIteration:
heappop(current)
active -= 1
# Yield the term with the summed doc frequency and term count.
yield (fnum, text, docfreq, termcount)
| [
"57100481+SardarMubashirAli@users.noreply.github.com"
] | 57100481+SardarMubashirAli@users.noreply.github.com |
485b9e2a8ec17400df95a3e03fedeb9c48f90075 | f20e965e19b749e84281cb35baea6787f815f777 | /Phys/Phys/NeuroBayesTools/python/NeuroBayesTools/BhhNetTrigger.py | 81e881067a822883293382acc9528b09c0a2e04d | [] | no_license | marromlam/lhcb-software | f677abc9c6a27aa82a9b68c062eab587e6883906 | f3a80ecab090d9ec1b33e12b987d3d743884dc24 | refs/heads/master | 2020-12-23T15:26:01.606128 | 2016-04-08T15:48:59 | 2016-04-08T15:48:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 92,234 | py | NetConfig = { '2010Tuning' : [ 101206.,
61012276., -1., 17., 16., 1., 0., 612., 0., 1., 4., 3., 100.,
0.00993321929, 100., 0., 5., 16., 3882., 4284., 31., 1647., 1847.,
2087., 2087., 2072., 2087., 2103., 0., 3610., -1., -1., -1., -1., -1.,
-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.
, -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,
-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.
, -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
, 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1.00004113, 1.09142387, 1.17184639, 1.2093693, 1.22437894,
1.23932469, 1.25443637, 1.26974058, 1.28500223, 1.30005527, 1.31534362,
1.33046508, 1.34543204, 1.36071908, 1.37605262, 1.3912909, 1.40652525,
1.42149055, 1.43702841, 1.45241475, 1.46785438, 1.48314166, 1.49857259,
1.51376498, 1.52929521, 1.54469955, 1.5601747, 1.57590926, 1.5915606,
1.60707617, 1.62248373, 1.6382947, 1.65391231, 1.66975927, 1.68530536,
1.70127618, 1.71698856, 1.73295438, 1.74886942, 1.76467836, 1.78035927,
1.79623616, 1.81234562, 1.82855105, 1.84464025, 1.86088812, 1.87704372,
1.89330077, 1.90958869, 1.92602825, 1.94231153, 1.95888138, 1.97573793,
1.99290109, 2.00997305, 2.02718639, 2.04490805, 2.06254458, 2.07996416,
2.09785676, 2.11587858, 2.13431215, 2.15276694, 2.17137122, 2.19077826,
2.20972967, 2.22922015, 2.24877095, 2.26917553, 2.28934145, 2.31002951,
2.33122063, 2.35257292, 2.37469268, 2.3973639, 2.42056966, 2.44426179,
2.46856833, 2.49389505, 2.52007151, 2.54765511, 2.57700014, 2.60965872,
2.64667559, 2.68919754, 2.73767614, 2.79157209, 2.85130095, 2.91843653,
2.99336743, 3.07831335, 3.17476511, 3.28713322, 3.42184663, 3.57965899,
3.77473903, 4.02718973, 4.36364126, 4.87709665, 5.82846355, 34.6666489,
-202.449905, -83.5268478, -70.2305984, -61.7472496, -55.5144997, -50.4909515,
-46.2129517, -42.4908524, -39.2141495, -36.2180481, -33.4629517, -30.8884506,
-28.4778996, -26.20825, -24.0736504, -22.0564499, -20.1489487, -18.3780003,
-16.6923504, -15.0632, -13.5348492, -12.0580502, -10.6373005, -9.29405022,
-8.02275085, -6.77789974, -5.62069988, -4.60305023, -3.63820004, -2.80805016,
-2.08150005, -1.45904994, -0.938149989, -0.4921, -0.104199998, 0.282000005,
0.4727, 0.665600002, 0.870800018, 1.08560002, 1.3053, 1.53030002,
1.76545, 2.01029992, 2.26869988, 2.54250002, 2.82455015, 3.12505007,
3.45055008, 3.80360007, 4.18370008, 4.59140015, 5.02759981, 5.4836998,
5.97609997, 6.50029993, 7.0559001, 7.64190006, 8.26029968, 8.9110508,
9.58135033, 10.2833996, 11.0038996, 11.7457504, 12.5173492, 13.3025999,
14.1125002, 14.9491005, 15.7912502, 16.6497993, 17.5163498, 18.4244995,
19.3451004, 20.2938995, 21.2561989, 22.2480507, 23.2558994, 24.2960014,
25.3487015, 26.4576492, 27.5931511, 28.7782497, 30.0228004, 31.3022995,
32.6691513, 34.0904503, 35.6079483, 37.2268982, 38.9731979, 40.8227501,
42.8618011, 45.1114502, 47.5674515, 50.2867508, 53.4091988, 57.0221481,
61.1503983, 66.2315521, 73.0017014, 83.5948029, 187.8396, -226.245697,
-86.3375549, -73.1066513, -64.6753998, -58.2957497, -53.2058487, -48.9390488,
-45.1978531, -41.871048, -38.8252983, -36.0633011, -33.4945526, -31.0841007,
-28.8397999, -26.6828995, -24.6514511, -22.6987991, -20.8975487, -19.2009506,
-17.569149, -15.99685, -14.5082998, -13.0834503, -11.7513504, -10.44835,
-9.19680023, -7.99679995, -6.85545015, -5.80074978, -4.80945015, -3.91120005,
-3.09210014, -2.38150001, -1.76664996, -1.24160004, -0.803049982, -0.439350009
, -0.138600007, 0.204300001, 0.334199995, 0.469300002, 0.615999997,
0.766900003, 0.928149998, 1.10300004, 1.28815007, 1.48599994, 1.69760001
, 1.93274999, 2.18470001, 2.45499992, 2.75075006, 3.06489992, 3.40724993
, 3.77995014, 4.18120003, 4.61149979, 5.06510019, 5.55725002, 6.09369993
, 6.66730022, 7.2730999, 7.90570021, 8.57830048, 9.29609966, 10.0500507,
10.8325005, 11.64995, 12.4697495, 13.3267002, 14.2276001, 15.1407509,
16.0732994, 17.0247002, 18.0250511, 19.0405998, 20.0658493, 21.1340504,
22.2262001, 23.3575001, 24.4978504, 25.7070007, 26.9584999, 28.2453499,
29.5905495, 31.0135002, 32.5134506, 34.1013985, 35.8283997, 37.7227478,
39.8028984, 42.0707474, 44.5892487, 47.3984489, 50.6020508, 54.2639008,
58.5676003, 63.7483521, 70.6222534, 81.3361511, 185.519196, 1.50156903,
1.99424219, 2.08023214, 2.15380836, 2.21823502, 2.27655363, 2.32969904,
2.37851048, 2.42444253, 2.4663868, 2.50626278, 2.54301643, 2.57729864,
2.60955048, 2.63930035, 2.66704035, 2.69408321, 2.72065926, 2.74657202,
2.77199888, 2.79760742, 2.82303977, 2.84843302, 2.87413311, 2.89990664,
2.92589545, 2.9520154, 2.97793031, 3.003824, 3.02987981, 3.05620003,
3.08275819, 3.10961819, 3.13684106, 3.16407204, 3.19192195, 3.21961808,
3.24830341, 3.27724075, 3.30630207, 3.33575487, 3.36534882, 3.39540672,
3.4265027, 3.45720434, 3.48889399, 3.52151704, 3.55454302, 3.58757687,
3.62180853, 3.65591908, 3.69112921, 3.72628689, 3.76178908, 3.79905844,
3.83659744, 3.87501764, 3.9143281, 3.95512366, 3.99616575, 4.03822899,
4.08249903, 4.12624645, 4.17207909, 4.21841431, 4.26639748, 4.31479979,
4.36520147, 4.41724205, 4.46985912, 4.52511406, 4.58144999, 4.64054728,
4.70098829, 4.76587677, 4.83144569, 4.89954901, 4.97256184, 5.04874849,
5.12855101, 5.21228218, 5.30101299, 5.3981657, 5.50002861, 5.6085062,
5.72632313, 5.85274029, 5.99485493, 6.15542412, 6.32990551, 6.52580118,
6.75147438, 7.00908279, 7.30552387, 7.6652956, 8.10787201, 8.67226791,
9.43075752, 10.5537281, 12.7403107, 126.420212, 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1.,
1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 0.142102748,
0.519136071, 0.570073247, 0.603694797, 0.629985571, 0.651470184,
0.670458734, 0.686659694, 0.702017486, 0.716109514, 0.729187608,
0.741616666, 0.752890468, 0.763873816, 0.774634004, 0.784817874,
0.794773877, 0.80442214, 0.813703775, 0.822921515, 0.831615746,
0.840259314, 0.848707199, 0.857085824, 0.865117669, 0.873148561,
0.88124305, 0.889174223, 0.896773875, 0.904379725, 0.912007928,
0.919665694, 0.927294493, 0.934858441, 0.942365527, 0.949806869,
0.957283735, 0.964854836, 0.972287178, 0.979751348, 0.987293839,
0.99474442, 1.00227261, 1.00986409, 1.01742339, 1.02512622, 1.03270328,
1.0405128, 1.04845619, 1.05642319, 1.06440568, 1.07262087, 1.08086252,
1.08906758, 1.09748292, 1.10622001, 1.11495233, 1.12401557, 1.1329813,
1.14208961, 1.15131402, 1.16108406, 1.17088962, 1.18128991, 1.19188142,
1.20264864, 1.21358252, 1.2248615, 1.23687387, 1.24936199, 1.2621038,
1.2754662, 1.28908491, 1.30381775, 1.31974816, 1.33635831, 1.35411477,
1.37282515, 1.39316225, 1.41462636, 1.43838525, 1.46495056, 1.49406123,
1.52658486, 1.56329954, 1.60552633, 1.65592086, 1.71631312, 1.79009366,
1.88136137, 1.99600148, 2.14356685, 2.33227396, 2.55738139, 2.82716513,
3.1425643, 3.48584175, 3.8429327, 4.21601868, 4.60012627, 4.99995947,
3.38415342E-12, 0.000282733585, 0.00112458819, 0.00251947902,
0.00445513567, 0.00693309493, 0.0099208951, 0.0135118281, 0.0177269951,
0.0223744269, 0.0276195388, 0.0334060267, 0.0397297032, 0.046703238,
0.0543626845, 0.0625478551, 0.0713912249, 0.0808623582, 0.0908679664,
0.101319239, 0.112672448, 0.124664083, 0.137137532, 0.150479347,
0.164312303, 0.178893149, 0.194093049, 0.209897459, 0.226400435,
0.243581921, 0.261640787, 0.280563921, 0.300258934, 0.320756316,
0.341690898, 0.364019811, 0.38718611, 0.411317229, 0.436239839,
0.461432397, 0.487984419, 0.515400112, 0.543962955, 0.574071169,
0.605325699, 0.63777101, 0.670731902, 0.704720974, 0.741224885,
0.778333008, 0.817280531, 0.856399059, 0.8981359, 0.941115856,
0.98546052, 1.03236127, 1.07998717, 1.12996459, 1.18176043, 1.23610353,
1.29278731, 1.3518939, 1.4125911, 1.47613144, 1.54343402, 1.6128701,
1.68494904, 1.76037252, 1.83852077, 1.92080677, 2.00921822, 2.09963083,
2.19654131, 2.29807901, 2.40395951, 2.51364565, 2.63135242, 2.75651693,
2.88894463, 3.03199959, 3.18537903, 3.34976864, 3.52341223, 3.71190977,
3.91505837, 4.13725471, 4.38217926, 4.65022612, 4.95169353, 5.28165054,
5.64960861, 6.06702852, 6.56206512, 7.13750553, 7.82591248, 8.66059113,
9.71693039, 11.1221695, 13.1050425, 16.2539597, 24.9987087, 0.129531115,
0.520613551, 0.572010517, 0.605002999, 0.630808473, 0.652298689,
0.670890152, 0.687441826, 0.70262295, 0.7166605, 0.729556203,
0.741816401, 0.753426373, 0.764683127, 0.775344431, 0.785585642,
0.795523107, 0.804735541, 0.814213276, 0.823185086, 0.831870794,
0.840492487, 0.848981977, 0.857317209, 0.865620792, 0.873659849,
0.881666064, 0.889469266, 0.897236705, 0.904927909, 0.912579715,
0.920231581, 0.927806616, 0.935518384, 0.943076253, 0.950685143,
0.958160043, 0.965603411, 0.973191738, 0.980548739, 0.988178074,
0.995800972, 1.00337267, 1.01100421, 1.01862586, 1.02626348, 1.03398752,
1.04173839, 1.04962373, 1.05763841, 1.06556833, 1.07365787, 1.08194971,
1.0904026, 1.09881926, 1.10734415, 1.11600447, 1.12486207, 1.13375604,
1.14299309, 1.15247726, 1.16215277, 1.17224622, 1.18232834, 1.19286847,
1.20363379, 1.21485758, 1.22617376, 1.2381916, 1.25062203, 1.26345897,
1.27716064, 1.29131579, 1.30635989, 1.32187283, 1.33816338, 1.35562027,
1.37454438, 1.39458561, 1.41658807, 1.44032669, 1.46656489, 1.49558973,
1.52843702, 1.56575525, 1.60870361, 1.6581949, 1.71798873, 1.79180264,
1.88182616, 1.9965744, 2.14149404, 2.32384109, 2.5487504, 2.82411575,
3.14118528, 3.48486233, 3.84548807, 4.21660995, 4.59751511, 4.99996853,
19.4087296, 25.4377613, 27.6059151, 29.2971878, 30.7556133, 32.1059647,
33.3479424, 34.5459137, 35.7015762, 36.8063431, 37.8613052, 38.9173622,
39.9556122, 40.9686661, 41.9684029, 42.9560699, 43.9272766, 44.9040947,
45.8790207, 46.8373032, 47.8035049, 48.7863083, 49.7773933, 50.7604218,
51.7290878, 52.7013855, 53.6818695, 54.6536789, 55.656414, 56.6663055,
57.671463, 58.6978226, 59.7269745, 60.7609024, 61.8080521, 62.8637695,
63.94981, 65.0307465, 66.127121, 67.2239838, 68.3466339, 69.5037231,
70.6646423, 71.8328552, 73.0204468, 74.2419434, 75.4799194, 76.7160873,
77.9661789, 79.2500839, 80.5688477, 81.89711, 83.2555084, 84.6536102,
86.0647507, 87.5108948, 88.9666595, 90.4742813, 92.0347519, 93.5868378,
95.1812592, 96.8300934, 98.4956512, 100.217842, 101.97995, 103.764084,
105.602112, 107.490501, 109.465897, 111.492302, 113.526764, 115.676163,
117.864151, 120.137756, 122.469551, 124.875664, 127.40892, 130.037018,
132.796509, 135.673203, 138.72287, 141.859222, 145.227676, 148.75415,
152.41449, 156.356659, 160.491211, 164.954987, 169.765442, 175.091415,
180.841064, 187.315277, 194.434296, 202.697754, 212.189056, 223.326385,
237.155121, 254.855377, 280.527893, 323.637421, 2954.40723,
0.00743769063, 0.0115492251, 0.0118634617, 0.0120786065, 0.0122482888,
0.01239614, 0.0125240656, 0.0126407063, 0.0127480738, 0.0128482692,
0.0129452441, 0.013036225, 0.0131238718, 0.0132085998, 0.0132891107,
0.0133673064, 0.0134427007, 0.0135176294, 0.0135890264, 0.0136604607,
0.0137309171, 0.0138005484, 0.0138676576, 0.0139365308, 0.0140055567,
0.0140732676, 0.0141403032, 0.0142063219, 0.0142731955, 0.0143394452,
0.0144064743, 0.014473496, 0.0145406956, 0.0146087464, 0.0146761928,
0.0147433821, 0.0148107838, 0.0148797408, 0.0149487201, 0.0150187537,
0.0150878448, 0.0151599739, 0.0152321123, 0.0153046437, 0.0153782088,
0.0154548455, 0.0155302063, 0.0156079894, 0.0156865269, 0.0157663934,
0.015846394, 0.0159306843, 0.0160153806, 0.0161016304, 0.0161916278,
0.0162805095, 0.0163737014, 0.0164667815, 0.0165640712, 0.0166624933,
0.0167619511, 0.0168661401, 0.0169750601, 0.0170863681, 0.017202137,
0.0173210017, 0.0174436755, 0.017572403, 0.0177038722, 0.0178422909,
0.0179876424, 0.0181368366, 0.0182941407, 0.0184594337, 0.0186356716,
0.018815767, 0.0190100558, 0.0192123, 0.0194217451, 0.0196510125,
0.0198936928, 0.0201544203, 0.0204365794, 0.020741377, 0.0210726149,
0.0214436166, 0.0218426473, 0.0222824514, 0.0227790698, 0.0233238712,
0.0239414275, 0.0246171597, 0.0253745317, 0.0262170974, 0.0271643419,
0.028266903, 0.0295946561, 0.0314019844, 0.0339140967, 0.0380133577,
0.363816142, 3.21376348E-07, 0.00760889892, 0.0152924843, 0.0230381675,
0.0306898542, 0.0383430012, 0.0460027196, 0.0536233336, 0.0612316541,
0.0687741786, 0.0763916597, 0.0841424316, 0.0918294787, 0.0996271148,
0.107410371, 0.11515674, 0.122921251, 0.130767524, 0.138628334,
0.146350294, 0.154082745, 0.161727592, 0.169650763, 0.177437946,
0.185221612, 0.192985982, 0.200708658, 0.208569884, 0.216375187,
0.224184573, 0.232050627, 0.239992872, 0.247843578, 0.25576371,
0.263562739, 0.271502227, 0.279401511, 0.287448645, 0.295441866,
0.303353399, 0.311395824, 0.319437891, 0.32748729, 0.335421294,
0.343496919, 0.351509929, 0.359547138, 0.367821753, 0.375988722,
0.384183943, 0.392411828, 0.400577068, 0.408812702, 0.416988611,
0.425332487, 0.433530867, 0.441809207, 0.450076759, 0.458386898,
0.466668487, 0.474873215, 0.483199954, 0.491596818, 0.500084996,
0.508355319, 0.516611576, 0.524987161, 0.533455014, 0.541962147,
0.550590158, 0.559071183, 0.567596912, 0.576164484, 0.584680319,
0.593361974, 0.602172732, 0.61096549, 0.619667768, 0.628496766,
0.637336016, 0.646057367, 0.654975474, 0.663833559, 0.672900915,
0.682195544, 0.691353738, 0.700937212, 0.710605681, 0.720600367,
0.731039882, 0.741741359, 0.752634525, 0.763985991, 0.775720656,
0.787998855, 0.801048338, 0.81501174, 0.830159843, 0.847559094,
0.870505631, 0.982612491, 5.02329556E-08, 0.000415576418, 0.000829821744,
0.00124693313, 0.00165741425, 0.00207269029, 0.00248174276, 0.00289657572
, 0.00330750155, 0.00372295454, 0.00414021919, 0.00455017295,
0.00496787252, 0.00538918748, 0.00581192505, 0.0062372135, 0.0066608456,
0.00709421607, 0.007527282, 0.00796275958, 0.0084014982, 0.00884393044,
0.00928677619, 0.00973718148, 0.0101825334, 0.0106316637, 0.0110858884,
0.0115455147, 0.0120078847, 0.0124635035, 0.0129298288, 0.0133995749,
0.0138721168, 0.0143584283, 0.0148535892, 0.015349335, 0.0158485621,
0.016358465, 0.0168736745, 0.0173968896, 0.0179317743, 0.018461369,
0.0190002769, 0.0195506364, 0.0201080963, 0.0206740201, 0.0212466232,
0.0218265541, 0.0224218722, 0.0230241567, 0.0236327983, 0.0242545418,
0.0248871334, 0.0255328603, 0.0262046698, 0.026880037, 0.0275605377,
0.0282498542, 0.0289692767, 0.0297174975, 0.0304708146, 0.0312537551,
0.032048706, 0.0328597128, 0.033698678, 0.034546148, 0.0354047567,
0.0363013968, 0.0372410752, 0.0382090211, 0.0391925424, 0.0402108505,
0.0412777513, 0.0423656814, 0.0434994996, 0.0446655452, 0.0458989963,
0.0471796021, 0.048489742, 0.0498493016, 0.051297918, 0.0528078526,
0.0543856025, 0.055998899, 0.0576835684, 0.0594575182, 0.0613515414,
0.0633271635, 0.0653871596, 0.0675362274, 0.0697773993, 0.0721266419,
0.0746091753, 0.0772514492, 0.0800085068, 0.0828687549, 0.085852094,
0.0891013518, 0.0925650224, 0.0961344987, 0.0999999344, 10.0000095,
10.2987146, 10.59799, 10.8938398, 11.19946, 11.5045547, 11.8106508,
12.1205006, 12.4337606, 12.7587147, 13.0906553, 13.4221153, 13.7593498,
14.1073151, 14.4568806, 14.8088503, 15.1689644, 15.5387402, 15.912015,
16.2950249, 16.6853065, 17.0756245, 17.4794235, 17.893755, 18.3227463,
18.7565804, 19.1965752, 19.65131, 20.1047859, 20.5735855, 21.0478306,
21.5394402, 22.0505333, 22.5559902, 23.0886154, 23.6331654, 24.1774387,
24.7468395, 25.3493099, 25.940321, 26.5575714, 27.1779747, 27.8075352,
28.4667206, 29.1494255, 29.8432465, 30.5379753, 31.265831, 32.0099182,
32.7649689, 33.5685654, 34.3561783, 35.1798706, 36.038063, 36.8960114,
37.7665405, 38.6888847, 39.6414604, 40.6093903, 41.5877304, 42.6122971,
43.6568604, 44.7687302, 45.9209557, 47.1045609, 48.3256378, 49.565033,
50.8618088, 52.2439499, 53.6647148, 55.121666, 56.6155815, 58.2068253,
59.8191299, 61.5454597, 63.3019257, 65.1419296, 67.0623932, 69.0699768,
71.170845, 73.4009857, 75.6967926, 78.184021, 80.784668, 83.575882,
86.5962067, 89.8058777, 93.1854324, 96.8468933, 100.863602, 105.292465,
110.233955, 115.697098, 121.891678, 129.067566, 137.580383, 147.949799,
161.893494, 181.693329, 217.042877, 1133.23022, 0.00375784328,
0.325329781, 0.465211451, 0.574806213, 0.667730689, 0.748778462,
0.825972795, 0.896715403, 0.963867903, 1.03004861, 1.09326148,
1.15303123, 1.21106958, 1.26936197, 1.32598281, 1.38124812, 1.43685567,
1.49155188, 1.54449224, 1.59704041, 1.65028524, 1.70309997, 1.75610375,
1.80875492, 1.86206031, 1.91594982, 1.96832037, 2.02062058, 2.07324314,
2.12570143, 2.17878962, 2.23205805, 2.28470898, 2.33815956, 2.39169359,
2.4453423, 2.49951839, 2.55428982, 2.60909057, 2.66436458, 2.71976948,
2.77649784, 2.83276224, 2.88957405, 2.94762373, 3.00572395, 3.06531572,
3.1245389, 3.18488765, 3.24687481, 3.30791306, 3.37037587, 3.43342543,
3.49697661, 3.56054211, 3.62659478, 3.69213867, 3.75753069, 3.82571363,
3.89573717, 3.96804547, 4.04007721, 4.11593723, 4.19194698, 4.26915169,
4.34959221, 4.43333292, 4.51871777, 4.60601377, 4.69890499, 4.79209137,
4.88799095, 4.98818398, 5.09319115, 5.20368385, 5.31828976, 5.43810034,
5.56311703, 5.69217873, 5.83085918, 5.97809887, 6.13367701, 6.3005228,
6.47500324, 6.66090679, 6.85817146, 7.0758853, 7.30930853, 7.56132126,
7.8382535, 8.14327621, 8.48712063, 8.87477112, 9.31063652, 9.82712269,
10.4544029, 11.2235661, 12.2621498, 13.7872133, 16.6024017, 123.712173,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0.589679182, 0.0376591384, -0.447209388, 0.374616414, 0.0498777591,
0.187417805, -0.25863713, 0.209820181, 0.0208952222, -0.0498140715,
0.0824461803, 0.0118436199, -0.232750192, 0.15836069, -0.269979894,
-0.494585961, 0.334843218, -0.428861678, 0.246420056, -0.0458202586,
0.0909270495, -0.320753723, 0.00960158557, -0.369611591, 0.11648953,
-0.229797557, -0.168579981, 0.156059891, -0.16975835, 0.0263780802,
0.075740546, 0.321585149, 0.544746995, 0.233129516, -0.104017191,
0.0418687239, -0.461738199, 0.0123978397, 0.0971589163, -0.0857340246,
0.424874812, -0.272968918, 0.164350584, -0.120424278, 0.0220332406,
-0.342039764, -0.159560919, 0.24399823, 0.332778901, -0.0754300877,
-0.0787262917, 0.23037295, 0.275939316, -0.106694996, 0.0167701356,
0.0705646276, -0.0308357682, -0.473042935, -0.227190837, -0.503179967,
-0.25704053, -0.0527211241, -0.0633651614, 0.139276832, 0.22436671,
0.502274215, 0.154740855, -0.00690953014, 0.307616353, -0.68159163,
-0.0303726606, -0.0581580848, 0.132453173, 0.00480699493, -0.00766423298,
0.118196718, -0.0197046995, 0.297098935, 0.145398647, 0.24162145,
0.639214277, 0.185015857, -0.00692750048, -0.0854841918, 0.551571548,
-0.210782632, -0.0400972515, 0.130950987, 0.0132281566, -0.00886664353,
0.300290078, 0.115378052, 0.258027315, 0.211492643, -0.424613982,
-0.108547546, 0.145837501, -0.0116827991, -0.155427113, -0.300498128,
-0.657397211, -0.121308804, 0.0994502306, 0.022088157, -3.69223039E-06,
-0.0135546122, -0.413222909, 0.00824019406, 0.298627883, 0.0994765684,
-0.212917551, -0.0174895562, 0.624613404, -0.0187581684, 0.0304361619,
0.0184052363, 0.0865578726, 0.45088467, -0.0258314814, 0.284720212,
-0.117560625, 0.131948352, -0.212004423, 0.215040013, -0.418155789,
-0.0459111407, 0.20929423, -0.0102500031, 0.723367572, 0.330552697,
-0.00507040415, -0.116175361, 0.102647193, 0.0112082437, 3.44139371E-05,
-0.0781869218, 0.126240462, 0.0224128719, 0.114268005, 0.387898773,
-0.291508734, 0.193898663, 0.0123639051, -0.0219826661, 0.0304689296,
-0.017715795, -0.588792443, -0.0632286817, 0.581766486, 0.0186127312,
-0.0724128261, 0.358395249, -0.00319130439, 0.136078596, -0.276221782,
0.108018659, 0.386534899, 0.0805043355, -0.317034841, -0.0584203713,
0.382696748, 0.397108555, 0.153128445, 0.413863212, 0.0334362797,
0.204103887, 0.408194095, -0.0499456711, 0.273805141, 0.422427446,
-0.250089765, 0.350165963, -0.0996855125, 0.0418080576, -0.0273693483,
0.0298845097, 0.144049734, -0.0700824559, -0.500385761, 0.247536138,
0.00712845335, -0.362538487, -0.0294790138, 0.407589555, 0.0611586235,
-0.184001997, -0.00713463267, -0.648448944, -0.0888725892, 0.019800907,
0.108103313, 0.100981452, 0.354732841, 0.0329374187, -0.293748945,
-0.205720156, 0.179086879, 0.227587998, 0.164513558, 0.248302504,
-0.140048221, -0.355964035, 0.00297334185, 0.275167465, 0.0393173732,
-0.334581792, 0.564784884, -0.144539297, 0.330138624, -0.0261879135,
-0.0730047897, -0.280051887, 0.0158143565, 0.33678174, -0.185827106,
0.126083136, -0.0633425415, -0.228127092, -0.0778715014, -0.00029856895,
0.0755996779, -0.0313258208, -0.482899219, 0.0911607891, 0.664698303,
0.75497824, 1.56103969, 0.738247454, 2.59386945, 1.16184258, 0.992345452
, 0.637653649, 0.12583375, 0.826117694, 0.976408839, 0.845964372,
1.2093569, 1.80792534, 0.457278579, 0.173073024, 8., 17., 9., 13.,
16., 11., 12., 15., 10., 14., 2., 3., 7., 5., 4., 6., 16., 10.,
34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 18., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
18., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 1., -999., -0.768632531, 0., 0., 2., 0., 1., 0.291729242,
-3.42783618, 2., 0., 1., 0.289156437, -3.4583354, 0., 0., 0., 0., 0.,
0., 0., 0., 0., 1.36312878, 1.31304562, -0.12443123, -1.15954232,
-1.55052853, -1.53503263, -1.38179421, -1.25302541, -1.2022146, -1.21548676,
-1.25402737, -1.28240669, -1.28127956, -1.24851191, -1.19399333, -1.13254905,
-1.0778203, -1.03846931, -1.0169158, -1.01010442, -1.01148534, -1.0133847,
-1.00910568, -0.994352639, -0.967825294, -0.931043088, -0.887595713,
-0.842088819, -0.799050093, -0.762014031, -0.732933342, -0.711973369,
-0.697669387, -0.687370002, -0.677847385, -0.665946782, -0.64915818,
-0.626020908, -0.596308112, -0.560981989, -0.521950066, -0.481674403,
-0.442713469, -0.407274336, -0.376845241, -0.351965874, -0.33216235,
-0.316049904, -0.30158028, -0.286389887, -0.26818946, -0.245133922,
-0.216115266, -0.180933744, -0.140323058, -0.0958241522, -0.0495342426,
-0.00376430852, 0.0393363088, 0.0781308487, 0.111764878, 0.14031063,
0.164758459, 0.186855361, 0.208812267, 0.232923701, 0.261165589,
0.294833571, 0.33429423, 0.378894269, 0.427056193, 0.476558447,
0.524952292, 0.570056677, 0.610432923, 0.645746648, 0.676926494,
0.706073403, 0.736104906, 0.770189762, 0.811082363, 0.86050415,
0.9187451, 0.984628737, 1.0559144, 1.13008797, 1.20536518, 1.28156233,
1.36043632, 1.44511342, 1.53846753, 1.64075053, 1.74744153, 1.84896576,
1.93423009, 1.99902987, 2.05685353, 2.14108062, 2.27038455, 2.31772685,
1.93173921, 1.49091828, 1.09202111, 0.800718546, 0.575493217,
0.372987598, 0.175622284, -0.0126954569, -0.179216266, -0.312967509,
-0.410220116, -0.475189179, -0.517683506, -0.549543083, -0.581283689,
-0.619784057, -0.667313159, -0.721797884, -0.777989089, -0.82909441,
-0.868464708, -0.891005874, -0.894112229, -0.87803936, -0.845744967,
-0.802302837, -0.7540434, -0.707590222, -0.668944061, -0.642741024,
-0.631765008, -0.636748672, -0.656456709, -0.688006997, -0.727360964,
-0.769905627, -0.811043978, -0.846720278, -0.873828053, -0.890460908,
-0.895996869, -0.891022503, -0.877123475, -0.856580615, -0.832017303,
-0.806043863, -0.780943573, -0.75843066, -0.739505351, -0.724410176,
-0.712686419, -0.703311801, -0.694895744, -0.685900271, -0.674858809,
-0.660561204, -0.642183602, -0.619350553, -0.592124283, -0.560926557,
-0.526411772, -0.489305675, -0.450243115, -0.409625471, -0.367521077,
-0.323624939, -0.277285606, -0.227595776, -0.173532739, -0.114131093,
-0.0486580692, 0.0232368167, 0.101424225, 0.185267374, 0.273680121,
0.365259588, 0.458478928, 0.551912546, 0.644451618, 0.735465527,
0.82488203, 0.913145304, 1.0010612, 1.08954573, 1.17932761, 1.27067137,
1.36322296, 1.45603478, 1.54783583, 1.63752222, 1.72477663, 1.81061482,
1.89757168, 1.98921847, 2.08879137, 2.19706178, 2.31029034, 2.42039943,
2.52158761, 2.63085747, 2.24603486, 1.82751012, 1.45556891, 1.17786491,
0.963365853, 0.774090946, 0.588937461, 0.404835135, 0.229611665,
0.0739926323, -0.0541105829, -0.152274475, -0.223658353, -0.275442183,
-0.316546917, -0.355396658, -0.398210049, -0.44805637, -0.504690409,
-0.565039933, -0.624135494, -0.676246047, -0.716003954, -0.739346564,
-0.744158685, -0.73056823, -0.700893939, -0.659300029, -0.611233771,
-0.562741697, -0.519760489, -0.487472266, -0.469788402, -0.469010532,
-0.485690355, -0.51868248, -0.565369844, -0.622019291, -0.68422401,
-0.747374594, -0.807111263, -0.859714866, -0.902399182, -0.933486879,
-0.952460766, -0.959894538, -0.957282782, -0.946792841, -0.930970669,
-0.912435532, -0.893593192, -0.876396894, -0.86217612, -0.851547658,
-0.844409943, -0.840016425, -0.837115288, -0.834134221, -0.829385936,
-0.821272671, -0.808461487, -0.790014505, -0.76545763, -0.734784186,
-0.698392332, -0.65696907, -0.611336708, -0.562284648, -0.510407448,
-0.455978513, -0.398875773, -0.338574678, -0.274212658, -0.204724029,
-0.129020572, -0.0462047085, 0.0442258269, 0.142212182, 0.247042552,
0.357356638, 0.47126773, 0.586588383, 0.701141953, 0.813114047,
0.921385527, 1.02576923, 1.12709785, 1.22709596, 1.32803822, 1.43222785,
1.54140627, 1.65626562, 1.77627933, 1.90007353, 2.02640796, 2.15557694,
2.29043674, 2.43528581, 2.5892458, 2.72843146, -2.33062434, -2.54310632,
-2.44330549, -2.27365041, -2.12341142, -2.00666237, -1.90801513, -1.80707204,
-1.68947148, -1.55003834, -1.39177191, -1.22307193, -1.05465841, -0.89695251,
-0.758267999, -0.643848062, -0.55564791, -0.492667586, -0.451634437,
-0.427841753, -0.415988028, -0.410912186, -0.408146769, -0.40427503,
-0.397081345, -0.385532558, -0.369621247, -0.350124031, -0.328315616,
-0.305681497, -0.283664763, -0.263464928, -0.245905474, -0.231371224,
-0.21981208, -0.210800096, -0.20362708, -0.197423637, -0.191282809,
-0.184376344, -0.176046133, -0.165868193, -0.153680548, -0.139579609,
-0.123883374, -0.107073866, -0.0897233188, -0.0724141151, -0.0556646287,
-0.0398652367, -0.0252347831, -0.0117989006, 0.000607976923, 0.0123154027,
0.023772981, 0.0354915373, 0.0479783192, 0.0616733879, 0.0768961608,
0.0938056558, 0.112382978, 0.13243553, 0.15362601, 0.175519705,
0.197648957, 0.219587386, 0.24102056, 0.261812508, 0.282055467,
0.302093327, 0.322519958, 0.344150692, 0.367961884, 0.39501372,
0.42635569, 0.462931931, 0.505490184, 0.554513037, 0.610169888,
0.672302067, 0.740436971, 0.813825548, 0.891494334, 0.972298861,
1.05497062, 1.13814282, 1.22037041, 1.30015254, 1.37599909, 1.44658625,
1.51106143, 1.56951892, 1.6236099, 1.67708743, 1.73581159, 1.80625892,
1.89083159, 1.9771204, 2.01657152, 1.8856045, 0.894850433, 0.891827703,
0.888895094, 0.884796441, 0.879191995, 0.872239888, 0.864316881,
0.855841935, 0.847172618, 0.838556528, 0.830116868, 0.821867287,
0.813732088, 0.805577338, 0.797241449, 0.788562775, 0.77940017,
0.76965028, 0.759257436, 0.74821645, 0.736570776, 0.724407971,
0.711849689, 0.699040532, 0.686136067, 0.673291147, 0.66064781,
0.648327291, 0.636420071, 0.624982297, 0.614031494, 0.603547633,
0.593473256, 0.583718717, 0.574167013, 0.564680338, 0.555109918,
0.545301378, 0.53510499, 0.524382532, 0.513013244, 0.500902355,
0.487982184, 0.474216163, 0.459599614, 0.444159806, 0.427951962,
0.411056042, 0.393572003, 0.375613362, 0.357299626, 0.338748187,
0.320068747, 0.30135572, 0.282680541, 0.264086992, 0.245587423,
0.22715804, 0.208740979, 0.190241843, 0.171532854, 0.15245685,
0.132831633, 0.112456478, 0.0911183283, 0.0685988069, 0.0446808301,
0.019154951, -0.00817742199, -0.0375004262, -0.0689843744, -0.102787472,
-0.139062792, -0.177966222, -0.219669119, -0.264373899, -0.312330425,
-0.363856971, -0.419357985, -0.479342908, -0.544442415, -0.61541748,
-0.693160534, -0.778686702, -0.873108983, -0.977593303, -1.09329486,
-1.22126317, -1.36231768, -1.51688671, -1.6848079, -1.86508405, -2.05558991,
-2.25274062, -2.45110202, -2.64295864, -2.8178401, -2.96200967, -3.05792737,
-3.08370733, 0.731923342, 0.759903133, 0.76490289, 0.759779453,
0.752022266, 0.745488286, 0.741687834, 0.740722477, 0.741941512,
0.744385183, 0.747071147, 0.74915719, 0.750022173, 0.749289215,
0.746808767, 0.742622197, 0.736914814, 0.729966223, 0.722101867,
0.713655233, 0.704936862, 0.696210682, 0.687680721, 0.679486215,
0.67170161, 0.664340436, 0.657368481, 0.650710821, 0.64426738,
0.63792336, 0.63156116, 0.625068605, 0.618347228, 0.611317813,
0.603919923, 0.596117198, 0.587891102, 0.579241037, 0.570178926,
0.560724437, 0.550899386, 0.540722847, 0.530206203, 0.519351065,
0.508143425, 0.496554255, 0.484539628, 0.472038925, 0.458979726,
0.445279181, 0.430848271, 0.415595859, 0.399434, 0.382281393,
0.364066124, 0.344732761, 0.324240923, 0.302566856, 0.279706389,
0.255670398, 0.230483949, 0.204182044, 0.176804751, 0.148392215,
0.118978329, 0.0885848328, 0.0572153479, 0.0248502102, -0.00855846424,
-0.0430901311, -0.0788576305, -0.116008744, -0.154725939, -0.195224032,
-0.237749934, -0.282580286, -0.330020547, -0.380405039, -0.434100807,
-0.491512865, -0.55309546, -0.619367242, -0.690929174, -0.768490076,
-0.852891982, -0.945133924, -1.04639673, -1.15804827, -1.28163481, -1.41883242
, -1.57135189, -1.74077094, -1.92825794, -2.13417268, -2.35747576, -2.59490991
, -2.83988261, -3.08097291, -3.29996228, -3.46929717, 0.904188454,
0.923205078, 0.922559857, 0.911120057, 0.894749165, 0.877109647,
0.860289097, 0.845292687, 0.832413375, 0.821510792, 0.812211335,
0.804048896, 0.796557903, 0.789329171, 0.782039285, 0.774459898,
0.766455948, 0.757971287, 0.749013603, 0.739633858, 0.729911566,
0.719935536, 0.709790289, 0.699547768, 0.689258516, 0.678947508,
0.668614924, 0.658237219, 0.647769868, 0.637153327, 0.626319587,
0.615198076, 0.603722155, 0.591833949, 0.579491854, 0.566671133,
0.553369761, 0.539606333, 0.525422215, 0.510878503, 0.496052533,
0.481035769, 0.465926349, 0.450825006, 0.435827792, 0.421022266,
0.406478107, 0.392246336, 0.37834993, 0.364784181, 0.351512522,
0.338465303, 0.325541764, 0.312608868, 0.299508929, 0.286059618,
0.272062063, 0.257307947, 0.241584793, 0.224685192, 0.206413209,
0.186592653, 0.16507332, 0.141735315, 0.11649365, 0.0892990306,
0.0601380542, 0.0290296469, -0.00398136023, -0.0388331227, -0.0754582807,
-0.113798596, -0.153822422, -0.195542485, -0.239038914, -0.284477681,
-0.332132727, -0.382404804, -0.435837775, -0.493127972, -0.555131853,
-0.622860134, -0.697463274, -0.780203581, -0.87241143, -0.975420773,
-1.09048867, -1.21868396, -1.36075437, -1.51696134, -1.68688381, -1.86918855,
-2.06136012, -2.25940299, -2.45749617, -2.64761472, -2.81911325, -2.95827603,
-3.0478313, -3.06644869, 1.20307076, 1.09115648, 1.04633653, 1.03358579,
1.03177023, 1.02934897, 1.02111959, 1.00579751, 0.984284759, 0.958469748
, 0.930433452, 0.901985645, 0.874410927, 0.848398805, 0.824063718,
0.801051795, 0.778668702, 0.75602603, 0.732179403, 0.706245184,
0.677499294, 0.645444453, 0.609844267, 0.570740998, 0.528438509,
0.483474314, 0.436570585, 0.388580233, 0.340422571, 0.293025523,
0.247261286, 0.203897178, 0.163548633, 0.126650289, 0.0934319794,
0.063908115, 0.0378863774, 0.0149782905, -0.00537483813, -0.0238682423,
-0.0412961952, -0.0585039482, -0.0763492361, -0.0956494138, -0.117148764,
-0.141469434, -0.169091269, -0.200321957, -0.235283643, -0.27391094,
-0.315951884, -0.360987246, -0.408447742, -0.457650661, -0.507834435,
-0.558199883, -0.607952833, -0.656351864, -0.702746928, -0.746615887,
-0.787595212, -0.825501323, -0.860338926, -0.892302394, -0.921754122,
-0.949203849, -0.975264013, -1.00059533, -1.0258497, -1.05159736, -1.07825661,
-1.10602176, -1.13479853, -1.16414833, -1.19325101, -1.22088623, -1.24544728,
-1.26497638, -1.27724731, -1.2798686, -1.27042961, -1.24667335, -1.20668352,
-1.14908206, -1.07320249, -0.979227722, -0.868227899, -0.742080033,
-0.603177547, -0.453871608, -0.295545876, -0.127202243, 0.0565644093,
0.268381774, 0.531873345, 0.886630893, 1.39462829, 2.14838052,
3.28116703, 4.97975779, -1.85910678, -1.0560683, -0.588106811, -0.322019815,
-0.170433193, -0.0783835202, -0.0132316351, 0.0427980311, 0.0980138332,
0.155071408, 0.213586479, 0.271840662, 0.327841133, 0.37990573,
0.426933557, 0.468465269, 0.504618704, 0.535959542, 0.563340783,
0.58775872, 0.610211492, 0.631602585, 0.652663291, 0.673911393,
0.695639968, 0.717922449, 0.740637124, 0.763505876, 0.786138952,
0.808075964, 0.828832507, 0.847942233, 0.864982963, 0.879608333,
0.891564488, 0.900694251, 0.906944275, 0.910357893, 0.911062956,
0.909259975, 0.90519768, 0.89916122, 0.891445637, 0.882337034,
0.872096241, 0.860940874, 0.849033058, 0.836468518, 0.82327348,
0.809400558, 0.794730842, 0.779080093, 0.762207508, 0.743826091,
0.723621547, 0.701266468, 0.676436603, 0.648832738, 0.618198991,
0.584338069, 0.547131002, 0.50654763, 0.462654382, 0.415621549,
0.365723044, 0.313325047, 0.258874774, 0.202877834, 0.145868599,
0.0883743912, 0.0308736227, -0.0262509324, -0.0827635825, -0.138621509,
-0.194023654, -0.249443933, -0.30565691, -0.363741398, -0.425056636,
-0.491192102, -0.563877761, -0.644853175, -0.735696673, -0.837613404,
-0.9511922, -1.07613993, -1.21103072, -1.35309625, -1.49811244, -1.64046657,
-1.77349901, -1.89026177, -1.98485625, -2.05459666, -2.10325766, -2.14577556,
-2.21482968, -2.36984587, -2.70906067, -3.38544321, 1.0543834, 1.03784013,
1.02603948, 1.01785862, 1.0123421, 1.00868607, 1.00621986, 1.00439298,
1.00276041, 1.00096822, 0.998743415, 0.995882094, 0.992238343,
0.987717211, 0.98226577, 0.975863278, 0.968518138, 0.960258245,
0.951128364, 0.941184163, 0.930486917, 0.919102371, 0.907095671,
0.894529283, 0.881460965, 0.867942929, 0.854017973, 0.839720309,
0.825075448, 0.810098469, 0.794794083, 0.779156506, 0.763170719,
0.746812165, 0.730048299, 0.712837994, 0.69513315, 0.676879346,
0.658017755, 0.638485491, 0.61821723, 0.597145319, 0.575201333,
0.552319527, 0.528433263, 0.50348103, 0.477403611, 0.450147033,
0.421663254, 0.391910046, 0.360852748, 0.328464121, 0.294724882,
0.259623885, 0.223159745, 0.185338631, 0.146176293, 0.10569676,
0.0639320686, 0.020922279, -0.0232840143, -0.0686326101, -0.115062624,
-0.162508905, -0.210900694, -0.260165095, -0.310226798, -0.361009479,
-0.412437499, -0.464437246, -0.51693815, -0.569874823, -0.623187244,
-0.676823497, -0.730740905, -0.784906685, -0.839301288, -0.893916726,
-0.948761225, -1.00385678, -1.05924356, -1.11497831, -1.17113638, -1.22781134,
-1.28511631, -1.34318244, -1.40215957, -1.46221626, -1.52353764, -1.58632398,
-1.65079081, -1.71716452, -1.78568089, -1.85658169, -1.93011189, -2.00651336,
-2.08602238, -2.16886234, -2.25523782, -2.34532809, 0.94519043, 0.959568083,
0.966865838, 0.968939841, 0.967293084, 0.963123858, 0.957368135,
0.950738668, 0.943759382, 0.936796427, 0.930086493, 0.923759758,
0.917862952, 0.91237694, 0.90723443, 0.90233171, 0.897542655,
0.892728627, 0.887745142, 0.88245064, 0.876710236, 0.870401025,
0.863414645, 0.855659127, 0.847061038, 0.837564468, 0.827132225,
0.815744936, 0.803398848, 0.790105879, 0.775891781, 0.760792315,
0.744853973, 0.728129685, 0.710677922, 0.692559421, 0.67383635,
0.654569447, 0.634816468, 0.614630282, 0.5940575, 0.573137522,
0.551900148, 0.530366302, 0.50854528, 0.486436337, 0.464027137,
0.441293538, 0.418200076, 0.394701362, 0.370739669, 0.346248657,
0.321152329, 0.295366943, 0.268801183, 0.241358206, 0.212935954,
0.183429778, 0.15273276, 0.12073651, 0.0873348713, 0.0524229743,
0.0158997029, -0.0223312341, -0.0623599812, -0.104269415, -0.148134217,
-0.194019198, -0.241979495, -0.292058855, -0.344289541, -0.398691267,
-0.455271453, -0.51402384, -0.574929357, -0.637954831, -0.703054368,
-0.770167589, -0.839220703, -0.910124719, -0.982777894, -1.05706358,
-1.13284934, -1.20998824, -1.28831625, -1.36765015, -1.44778836, -1.52850676,
-1.60955644, -1.69066012, -1.77150738, -1.85175049, -1.93099594, -2.00880003,
-2.08465791, -2.15799403, -2.22815108, -2.29437518, -2.35580111, -2.41143489,
-2.84198213, -2.75509667, -2.60650134, -2.43973017, -2.27556634, -2.12166762,
-1.97885692, -1.84503067, -1.71740568, -1.59366333, -1.47237384, -1.35301566,
-1.23577619, -1.12127268, -1.01027739, -0.903494, -0.801405787, -0.704194844,
-0.611727715, -0.52359426, -0.439176649, -0.357742518, -0.278538734,
-0.200874463, -0.124197155, -0.0481353067, 0.0274707396, 0.102568761,
0.176913038, 0.25009647, 0.321599692, 0.390841156, 0.457231462,
0.520225823, 0.57936424, 0.634304941, 0.684847832, 0.730937183,
0.772663176, 0.81023711, 0.843974769, 0.874254644, 0.901488781,
0.926079512, 0.948391259, 0.968710005, 0.987228096, 1.00402629,
1.01907492, 1.03222895, 1.04325485, 1.05184746, 1.05766726, 1.06036878,
1.05963767, 1.05523396, 1.04701293, 1.03495193, 1.01916504, 0.999903917,
0.977547109, 0.95257771, 0.925547779, 0.897032857, 0.86757791,
0.837645769, 0.807555735, 0.777439594, 0.747197688, 0.716480911,
0.684681654, 0.650961876, 0.614295959, 0.573545694, 0.527561367,
0.475291997, 0.415926248, 0.349018395, 0.274615377, 0.193357497,
0.106532089, 0.0160786733, -0.0754881352, -0.165231153, -0.250041664,
-0.326964647, -0.393602461, -0.44853127, -0.491689354, -0.524614453,
-0.550412953, -0.573239803, -0.597050667, -0.623271108, -0.646965086,
-0.650948584, -0.597184837, -0.414635181, 0.0174217429, 0.891813695,
-0.304170549, -0.341749221, -0.400073707, -0.462677002, -0.521114469,
-0.571860969, -0.61420387, -0.648859084, -0.677112579, -0.700324595,
-0.719679832, -0.736092091, -0.750202537, -0.762424946, -0.773008227,
-0.782100558, -0.789799631, -0.796191096, -0.801368773, -0.805443525,
-0.808538675, -0.81078285, -0.812294781, -0.8131724, -0.813481331,
-0.813248694, -0.812461615, -0.811069369, -0.808992743, -0.806133628,
-0.80238837, -0.797663391, -0.791887462, -0.785024345, -0.777080953,
-0.768112302, -0.758222818, -0.747561455, -0.736312687, -0.724685967,
-0.712898552, -0.701158226, -0.68964529, -0.678493559, -0.6677742,
-0.657481313, -0.647522032, -0.637711644, -0.62777251, -0.617340803,
-0.605976343, -0.59318018, -0.578414917, -0.561128974, -0.540784955,
-0.516885579, -0.489001989, -0.456798762, -0.420054555, -0.378677994,
-0.33271724, -0.282361358, -0.227933332, -0.169876769, -0.108732142,
-0.0451084934, 0.0203531794, 0.0870156214, 0.154289871, 0.22167021,
0.288771957, 0.355357885, 0.421358228, 0.486875117, 0.552179039,
0.617684066, 0.683913529, 0.751450598, 0.820878208, 0.892711222,
0.967332602, 1.04493213, 1.12545907, 1.208601, 1.29379392, 1.3802669,
1.46713686, 1.55354309, 1.63881612, 1.72266972, 1.80537951, 1.88789988,
1.97184789, 2.05925155, 2.15191984, 2.25024652, 2.3512063, 2.44522381,
2.51151991, 2.51144338, -0.324507773, -0.0100730099, 0.212595731,
0.115782835, -0.309224129, 0.0287670791, 0.437439919, 0.0678506047,
0.279760033, 0.052107919, -0.163112298, -0.194944933, 0.451724321,
0.0388525911, 0.406209856, 0.121580981, -0.715826988, -0.0319328643,
0.311695516, 0.338755369, 0.627177894, -0.464114845, 0.324271709,
0.0389084779, 0.0352730639, -0.290229827, 0.0513392985, 0.483316272,
0.545512378, 0.169077322, -0.510569274, -0.0918811038, -0.837317109,
0.0881491229, -0.312004536, -0.0846198425, 0.569627941, 0.0436681695,
0.219994351, -0.346916914, -0.106705695, 0.173962429, -0.0170347337,
-0.218399197, -0.446436197, 0.0509389974, 0.339441955, 0.242616415,
-0.546337247, -0.0958422199, -0.713817358, 0.311913013, 1.14705527,
0.397561461, 0.267605752, 0.188948348, 0.533919752, -0.0749290213,
-0.0816372409, -0.0331152864, -0.320875764, -1.01544619, -0.892698467,
-0.913032413, -0.519562304, -0.0368671045, -0.337352931, 0.201267987,
-0.776821196, 0.0708615258, 0.12346264, 0.0953902379, -0.478530228,
-0.0823657066, 0.0594585575, 0.269613534, 0.395835668, -0.105873697,
-0.0469804667, -0.197502539, 0.269758672, -0.209411666, -0.449868381,
0.260881394, 0.256491631, -0.0877740905, 0.061269097, 0.0832838416,
0.0576878116, -0.118024163, 0.00765369507, -0.0398623869, -0.388134569,
-0.149010211, -0.423613101, -0.25565806, 0.451832354, 0.355658412,
0.0214269646, -0.230682477, -0.0149910953, 0.380849928, -0.306408495,
0.400312215, 0.301443428, 0.282768697, -0.184724927, -0.377421498,
-0.330481112, -0.515957952, -0.35446927, 0.0796418339, 0.443365127,
0.107516579, -0.225315481, 0.0574304685, -0.123232424, 0.730647862,
-0.421298683, 0.415355206, 0.252031326, 0.591951549, 0.387580693,
-0.613377035, -0.731806815, -0.554510951, 0.463800251, -0.0262743998,
0.920350254, 0.00242885854, 0.778557062, 0.0527283363, 1.34531558,
0.196790814, 0.601848304, 0.173304781, 0.111600012, 0.12978968,
-0.16425629, -0.31943202, -0.486880392, 0.587081552, -0.179733455,
-0.238811031, -0.127629861, -0.170877367, 0.443677902, -0.095898509,
0.0168475788, -0.718917668, 0.321737528, -0.175686583, 0.0840111971,
-0.554515719, 0.290828764, 0.372208893, 0.287187725, -0.0518759824,
0.108054675, -0.000311982731, -0.15853925, -0.130470067, 0.316211045,
0.0831222236, -0.538945317, -0.19382599, -0.289251298, 0.200144812,
0.156209424, -0.0391450338, -0.577017784, -0.444424629, 0.0777638704,
0.188607812, 0.10253571, -0.471738607, 0.0641957074, 0.157147527,
-0.2855452, -0.0786468089, -0.201158509, -0.306872755, -0.109316938,
-0.280169934, 0.872118235, -0.148118854, 0.0984185636, -0.0700103045,
0.239182383, 0.285160482, -0.488274902, -0.00933549833, 0.545306683,
0.0626672059, 0.027626941, 0.0267513376, -1.03754473, -0.198290423,
-0.00102022907, -0.368376702, -0.343240052, -0.632851005, 0.196405813,
0.536037683, -0.350623429, 0.40716964, -0.107340381, 0.345079333,
0.469906449, 0.338468611, -0.453297913, -0.0739216357, 0.0467567034,
0.461068094, -0.160082787, 0.497217566, -0.279842377, 0.363415122,
-0.10913451, -0.29468891, -0.331709802, -0.558547258, 0.160443336,
-0.0460716598, 0.0538362563, -0.761142671, -0.077894412, -0.284335792,
-0.403073877, 0.0338715613, -0.468643963, 0.0161597952, 0.113606088,
-0.29971534, -0.038956482, -0.0347634479, 0.185433254, 0.352169335,
-0.138840154, 0.240390122, -0.0579954721, 0.497457862, -0.40284887,
0.348515511, -0.699572504, -0.113885336, -0.55491209, -0.109947152,
0.269954383, -0.403579265, 0.453704715, 0.464997888, 0.286628455,
-0.14358224, 0.110590696, -0.23578614, -0.254948974, 0.698491573,
1.30243969, 1.1306622, -0.737738788, 0.0816895291, -0.558588982,
-0.807650626, 1.94767666, 0.386632413, -0.584027171, 0.27698493,
-1.03660154, -0.58167398, -0.471945256, -0.849208951, 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., -9.1875124, -6.42450333, -5.96532249, -5.67300463, -5.43688297,
-5.23971272, -5.0614996, -4.89768124, -4.74745941, -4.6034956, -4.4663229,
-4.33180141, -4.19788074, -4.07115889, -3.9456234, -3.82388163, -3.70279408,
-3.58082795, -3.46087694, -3.3453908, -3.22732639, -3.11220813, -2.99768162,
-2.88330364, -2.77009416, -2.65900803, -2.54704571, -2.43747139, -2.32922173,
-2.22321701, -2.1157999, -2.01047897, -1.90651214, -1.80090797, -1.69935226,
-1.5982976, -1.4987011, -1.3993516, -1.30009222, -1.20333159, -1.10870337,
-1.0151608, -0.922822893, -0.830027461, -0.738119006, -0.648173213,
-0.558235526, -0.471156955, -0.384537965, -0.298740327, -0.214362755,
-0.129278556, -0.0439845249, 0.0402664021, 0.125317842, 0.21039477,
0.294077158, 0.37831974, 0.462773323, 0.546216547, 0.630921364,
0.715930581, 0.801375985, 0.888196707, 0.975105464, 1.06195211,
1.15006685, 1.23782551, 1.32751346, 1.41678798, 1.50729084, 1.59818673,
1.68891943, 1.7829957, 1.87588632, 1.97041225, 2.06622458, 2.16310406,
2.26053286, 2.36031437, 2.46095538, 2.56330824, 2.66625023, 2.7729845,
2.88141823, 2.99096107, 3.10285378, 3.21790767, 3.33646345, 3.4622643,
3.59331298, 3.73188639, 3.88348842, 4.0509367, 4.23666859, 4.44616985,
4.69292259, 4.99111986, 5.35662842, 5.87686682, 8.48309517, 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., -6.74885941, -5.76031065, -5.53535128, -5.45297289,
-5.20708275, -5.11752367, -4.86957169, -4.75320435, -4.50376701, -4.48180532,
-4.41535378, -4.34167719, -4.0428977, -3.83092117, -3.79880476, -3.7420702,
-3.57510209, -3.49495983, -3.41374707, -3.27617621, -3.10805321, -3.02398539,
-2.99954152, -2.90222073, -2.77528691, -2.65016484, -2.48727226, -2.42235136,
-2.25141573, -2.212744, -2.05510974, -1.94916701, -1.87482166, -1.77200294,
-1.6561923, -1.54709351, -1.48501313, -1.37759519, -1.24580562, -1.15827918,
-1.04046559, -0.971088767, -0.881113768, -0.798927188, -0.697367549,
-0.584742546, -0.501146495, -0.374856412, -0.322853804, -0.223083079,
-0.144063592, -0.0602909923, 0.0397500992, 0.115367174, 0.228794694,
0.289339125, 0.341676533, 0.439245373, 0.518141031, 0.609671593,
0.69497335, 0.78889966, 0.883933425, 0.958156586, 0.997998595,
1.10412896, 1.19553924, 1.32861102, 1.42539096, 1.46098518, 1.53676558,
1.67094791, 1.75577176, 1.83582592, 1.92800093, 2.04108596, 2.08880138,
2.22898722, 2.27767086, 2.40089869, 2.50452352, 2.55356765, 2.74462366,
2.78191924, 2.92504835, 2.97524047, 3.22806525, 3.33549786, 3.37026811,
3.50910044, 3.64906693, 3.80241966, 3.86045527, 3.9999578, 4.23922634,
4.29587555, 4.65534306, 5.16330051, 5.27664709, 6.25985003,
0.],
'2010TuningNoPID' : [
101206.,
93012232., 1., 13., 12., 1., 0., 612., 0., 1., 4., 3., 100.,
0.0110810343, 100., 0., 5., 12., 2988., 3390., 31., 1243., 1443.,
1575., 1575., 1564., 1575., 1587., 0., 2832., -1., -1., -1., -1., -1.,
-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.
, -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,
-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., 1.
, 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
, 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1.00003481, 1.07727289, 1.14767623, 1.20310295, 1.21861267
, 1.23379171, 1.2492677, 1.26479292, 1.28061676, 1.29590189, 1.31135392,
1.32710373, 1.34253311, 1.3583101, 1.3741256, 1.38980937, 1.40567422,
1.42104459, 1.43706703, 1.45295215, 1.46901977, 1.48483586, 1.50091302,
1.51667905, 1.53244424, 1.54844284, 1.56442416, 1.5807457, 1.59684789,
1.61271286, 1.62879586, 1.64454126, 1.66083145, 1.67701483, 1.69319689,
1.709692, 1.72589898, 1.74242032, 1.75908327, 1.77540708, 1.79162061,
1.80809498, 1.8248713, 1.8413986, 1.85793757, 1.87466502, 1.8911345,
1.90782917, 1.92477107, 1.94140005, 1.95823467, 1.97546446, 1.99299383,
2.01020598, 2.02757549, 2.04531217, 2.06305075, 2.08070374, 2.09865522,
2.11696243, 2.13531303, 2.15379286, 2.17227888, 2.19155264, 2.21070623,
2.23025656, 2.24986792, 2.27030444, 2.29031515, 2.31110525, 2.33215141,
2.35318804, 2.37516022, 2.39765692, 2.42045975, 2.44387197, 2.46784019,
2.49270487, 2.51822853, 2.54525685, 2.57422113, 2.60541391, 2.6409502,
2.68155193, 2.72730923, 2.77914357, 2.83607268, 2.8990159, 2.97074056,
3.04899764, 3.13833308, 3.24010658, 3.35891533, 3.49672914, 3.66486049,
3.87325621, 4.13283825, 4.48470688, 5.02815914, 6.04052448, 41.9010544,
3.38415342E-12, 0.000281941902, 0.0011116825, 0.00248584314,
0.00440504914, 0.00690073799, 0.0098899696, 0.0134580508, 0.0176145229,
0.022245463, 0.0274786092, 0.033295922, 0.0395452306, 0.0465165041,
0.0540933236, 0.062280871, 0.0711010545, 0.080457814, 0.0903840959,
0.100815788, 0.11217051, 0.124018684, 0.136521518, 0.149700522,
0.163527489, 0.177850187, 0.192899823, 0.208797395, 0.225239739,
0.242594466, 0.26077351, 0.279279113, 0.298704207, 0.319050938,
0.339984715, 0.362641871, 0.385789603, 0.409947217, 0.434971035,
0.460445464, 0.487190276, 0.514643431, 0.543290377, 0.573132753,
0.604499519, 0.637207627, 0.670012355, 0.704187691, 0.74097985,
0.778266668, 0.817388892, 0.856536508, 0.899003983, 0.941918254,
0.986330628, 1.03321886, 1.08087885, 1.13130569, 1.18323386, 1.23763084,
1.29436779, 1.35357761, 1.41510367, 1.47911167, 1.54710603, 1.61745262,
1.6901052, 1.76563406, 1.84512925, 1.92813182, 2.01669335, 2.10902452,
2.20705318, 2.30882597, 2.4147253, 2.52633476, 2.64711022, 2.77321243,
2.90695524, 3.0531292, 3.20744252, 3.37282705, 3.54987288, 3.74345541,
3.9513483, 4.17798662, 4.43015575, 4.70443392, 5.01206303, 5.34947491,
5.73037481, 6.17492962, 6.68863535, 7.28062153, 7.98445129, 8.84578133,
9.94101143, 11.390008, 13.4135838, 16.5791588, 24.9987087, 1.50156903,
2.00307846, 2.09890318, 2.17771816, 2.24707985, 2.30873775, 2.36301565,
2.41292, 2.45877194, 2.50189066, 2.54110909, 2.57689738, 2.61064816,
2.64116144, 2.66970658, 2.69717169, 2.7243135, 2.7509439, 2.77712297,
2.80289626, 2.82869053, 2.85441208, 2.88035727, 2.90656948, 2.93315315,
2.95953083, 2.98538828, 3.01180029, 3.03803539, 3.06470823, 3.0912571,
3.11832571, 3.14525127, 3.17249537, 3.20006609, 3.22823954, 3.25690269,
3.28630519, 3.31523085, 3.34448338, 3.37465715, 3.40529442, 3.43606925,
3.46706891, 3.49911189, 3.53161478, 3.56458187, 3.59798574, 3.63201284,
3.66683102, 3.70140815, 3.73656225, 3.77225113, 3.80959201, 3.84691238,
3.88529396, 3.92448902, 3.96496296, 4.00600433, 4.04721785, 4.0912919,
4.1350193, 4.18006706, 4.22610283, 4.27405453, 4.32191563, 4.37098551,
4.42228794, 4.47454309, 4.52893543, 4.5843091, 4.64277506, 4.7030201,
4.76672554, 4.83148909, 4.89833736, 4.96984673, 5.04451561, 5.12228155,
5.20454979, 5.29182577, 5.38406944, 5.48218918, 5.58703232, 5.69953823,
5.82258844, 5.95734835, 6.10807514, 6.27261639, 6.45592594, 6.66064072,
6.89605808, 7.166399, 7.47835541, 7.86581707, 8.34029007, 8.94047737,
9.74941254, 10.9876194, 13.4075489, 733.357117, 0.129531115, 0.517928481
, 0.568748355, 0.601330042, 0.626978993, 0.648293197, 0.666753709,
0.68316704, 0.698064208, 0.711832821, 0.724631548, 0.73676765,
0.74820745, 0.759248078, 0.769867539, 0.779805779, 0.789640546,
0.798804402, 0.807888985, 0.816927254, 0.825624168, 0.834156752,
0.842364132, 0.850556374, 0.858607769, 0.866603136, 0.874313474,
0.881996155, 0.889632165, 0.897184849, 0.904601991, 0.911946177,
0.919360042, 0.926679969, 0.934072554, 0.94150579, 0.948828042,
0.956036329, 0.963270128, 0.970649362, 0.977842748, 0.985231161,
0.992548704, 0.999884248, 1.00734472, 1.0146358, 1.022053, 1.02948225,
1.03704143, 1.04468131, 1.05235076, 1.06013727, 1.06792295, 1.07587337,
1.08379805, 1.09201741, 1.10029209, 1.10867453, 1.11734962, 1.1260829,
1.13495159, 1.14403915, 1.15346074, 1.1629622, 1.17282867, 1.18285298,
1.19311833, 1.20372224, 1.21462786, 1.22590256, 1.23787272, 1.250157,
1.26275539, 1.27614439, 1.29001999, 1.30491138, 1.32029676, 1.336393,
1.35390973, 1.37272048, 1.39297199, 1.4146812, 1.43801689, 1.46424592,
1.49291945, 1.52599216, 1.56344199, 1.60699606, 1.65808725, 1.71993005,
1.79736662, 1.89456892, 2.01914358, 2.18325233, 2.40043688, 2.6747992,
3.03690052, 3.46057272, 3.94001126, 4.44757366, 4.99996853, 0.105510935,
0.516392112, 0.56723702, 0.600480258, 0.626388311, 0.647411287,
0.666279078, 0.682709694, 0.697698712, 0.711579621, 0.724323988,
0.736511588, 0.747929335, 0.758640766, 0.769103765, 0.779163361,
0.788847804, 0.798338175, 0.807543457, 0.816302061, 0.825052977,
0.833454967, 0.841806471, 0.850085616, 0.858062804, 0.86584264,
0.873626471, 0.881566167, 0.889212847, 0.896672785, 0.904055357,
0.911453128, 0.918884754, 0.926179528, 0.933482409, 0.940758824,
0.948016584, 0.955156803, 0.962581515, 0.969777822, 0.977041662,
0.984406948, 0.991770983, 0.999035895, 1.00647557, 1.01382065, 1.0212189
, 1.02855575, 1.03611946, 1.0436995, 1.05159187, 1.0594089, 1.06719804,
1.07518601, 1.08313608, 1.09122443, 1.09952807, 1.10813785, 1.1166718,
1.12555754, 1.13438177, 1.14343905, 1.15251422, 1.16201973, 1.17166138,
1.18173099, 1.19204903, 1.20262635, 1.21347713, 1.22466958, 1.2365644,
1.24883723, 1.26130271, 1.27451921, 1.28809583, 1.30267704, 1.31845152,
1.33481991, 1.35221171, 1.37066913, 1.39073384, 1.4123168, 1.43582523,
1.46193147, 1.49150646, 1.52422643, 1.56083906, 1.60362566, 1.65535879,
1.71749055, 1.79438317, 1.89218211, 2.01765895, 2.18292665, 2.40090132,
2.67638493, 3.02852917, 3.45101953, 3.92518806, 4.44516754, 4.99995947,
0.00375784328, 0.329874635, 0.470496655, 0.580663323, 0.675050735,
0.758422971, 0.837026119, 0.909703493, 0.977797389, 1.04497945,
1.10911143, 1.17069972, 1.23060739, 1.28967357, 1.3472712, 1.40350318,
1.46037507, 1.5151515, 1.5689193, 1.62308311, 1.67721105, 1.73055923,
1.78409028, 1.83721757, 1.89144838, 1.945737, 1.99817359, 2.05253458,
2.10534263, 2.15964627, 2.21329784, 2.26723194, 2.32120466, 2.37542796,
2.42936659, 2.48375225, 2.5384388, 2.59395528, 2.65021396, 2.70568419,
2.76229429, 2.81950569, 2.8773632, 2.93539095, 2.99449658, 3.05413985,
3.11408854, 3.17520857, 3.23688221, 3.29798746, 3.36146832, 3.42446756,
3.48870993, 3.55290794, 3.62045336, 3.68750668, 3.75417304, 3.82335734,
3.89330149, 3.9659338, 4.03887463, 4.11537552, 4.19219875, 4.271101,
4.35159111, 4.43653965, 4.52224064, 4.60878277, 4.70206261, 4.79496479,
4.89081907, 4.99081039, 5.09389877, 5.20301485, 5.31581974, 5.43375111,
5.55740356, 5.68595076, 5.8223381, 5.96651268, 6.11886215, 6.27835369,
6.45032692, 6.63247108, 6.82482815, 7.03203678, 7.25530148, 7.49945068,
7.76623154, 8.0531311, 8.37495422, 8.73260498, 9.13615799, 9.59765911,
10.146965, 10.8113842, 11.6372585, 12.7581367, 14.4203281, 17.4896984,
733.734558, 0.00789215695, 0.0115266219, 0.0118293595, 0.0120413862,
0.012210086, 0.0123532694, 0.0124805532, 0.0125945052, 0.0126990089,
0.0127974711, 0.0128893256, 0.0129801771, 0.013065828, 0.0131497746,
0.0132289976, 0.0133051183, 0.0133789089, 0.0134509075, 0.0135218836,
0.0135900937, 0.0136584323, 0.013726077, 0.0137923975, 0.013858323,
0.0139236338, 0.0139898844, 0.0140555669, 0.0141209234, 0.0141852871,
0.0142504107, 0.0143153779, 0.0143796075, 0.0144450571, 0.0145104397,
0.0145754749, 0.0146415439, 0.0147080179, 0.014773733, 0.0148412706,
0.0149086677, 0.0149777513, 0.015046712, 0.0151163964, 0.0151874926,
0.0152587257, 0.0153319668, 0.0154073145, 0.0154830422, 0.0155592524,
0.0156368222, 0.0157143325, 0.0157936215, 0.015875902, 0.015960779,
0.0160471611, 0.016136162, 0.0162274316, 0.0163198821, 0.0164153185,
0.0165121146, 0.0166122876, 0.0167125687, 0.0168179944, 0.0169272795,
0.0170397349, 0.0171579812, 0.017277902, 0.0174033083, 0.0175351016,
0.0176692232, 0.0178115666, 0.0179580525, 0.018112693, 0.0182780903,
0.0184505694, 0.0186337829, 0.0188235808, 0.0190267693, 0.0192432776,
0.0194673575, 0.0197099186, 0.019973062, 0.0202545822, 0.0205609463,
0.020892011, 0.0212631691, 0.0216654204, 0.0221139751, 0.0226119403,
0.0231757015, 0.0238044988, 0.0245023891, 0.0252891518, 0.0261644889,
0.0271442123, 0.0282937363, 0.0296893436, 0.0315692276, 0.0342516825,
0.0387175232, 3.06886721, 3.21376348E-07, 0.00728885503, 0.0147214048,
0.0221650153, 0.0296188425, 0.0370316431, 0.0444694608, 0.0519358516,
0.0593171716, 0.0666400641, 0.0739949495, 0.0815066844, 0.0889736116,
0.096493423, 0.104047403, 0.11149846, 0.11914102, 0.126623765,
0.134317204, 0.141791463, 0.149337471, 0.156827867, 0.164375812,
0.172000706, 0.179574445, 0.187131673, 0.194694698, 0.202135384,
0.209812731, 0.217417702, 0.22502099, 0.232659981, 0.240469471,
0.248129636, 0.255863905, 0.263459861, 0.271139741, 0.278869748,
0.286647201, 0.294421166, 0.302116454, 0.309855789, 0.317750037,
0.325559855, 0.333409965, 0.341273963, 0.349111497, 0.357113987,
0.365011007, 0.372961164, 0.381050169, 0.389054656, 0.397197068,
0.405248463, 0.413279116, 0.421412826, 0.429524839, 0.437793553,
0.445974648, 0.454166472, 0.46239537, 0.470510274, 0.478828162,
0.487012923, 0.495403945, 0.503780663, 0.512046099, 0.520347595,
0.528839469, 0.537282169, 0.545853198, 0.554639637, 0.563186169,
0.5719769, 0.580648363, 0.589313865, 0.598329484, 0.60746026,
0.616383851, 0.625391245, 0.634353697, 0.643480778, 0.652821898,
0.661935747, 0.67145896, 0.681159139, 0.690823793, 0.700936913,
0.711190462, 0.721795261, 0.732922196, 0.744603395, 0.75650537,
0.768905163, 0.781929255, 0.79573977, 0.810392857, 0.826968193,
0.845579863, 0.870221019, 0.999999583, 5.02329556E-08, 0.000411332527,
0.000816632644, 0.001229994, 0.00163276284, 0.00204276526, 0.00245128013,
0.00286058243, 0.00326782791, 0.00367669016, 0.00409064442, 0.00449852645
, 0.00490704644, 0.00532017462, 0.00573714077, 0.00615087943,
0.00657205703, 0.00699829683, 0.00742139295, 0.00785348751, 0.00828923285
, 0.00872432813, 0.00915993005, 0.0096020624, 0.010046497, 0.0104887914,
0.0109320227, 0.0113869077, 0.0118444161, 0.0122986138, 0.0127600729,
0.0132243186, 0.0136888633, 0.0141657013, 0.0146538885, 0.015148785,
0.0156422257, 0.0161411054, 0.0166519284, 0.0171660632, 0.0176943988,
0.0182241499, 0.0187572986, 0.0193053316, 0.0198568646, 0.0204226635,
0.0209843684, 0.021566011, 0.022158701, 0.0227447767, 0.0233439952,
0.0239612982, 0.0245880894, 0.0252365079, 0.0258955844, 0.0265757963,
0.0272480082, 0.0279419795, 0.0286562108, 0.0293863043, 0.0301391631,
0.0309058316, 0.0316943601, 0.0324870422, 0.0333190039, 0.0341725424,
0.0350327119, 0.0359188318, 0.0368531495, 0.0377974883, 0.0387985669,
0.0397970006, 0.0408556163, 0.0419478938, 0.043065235, 0.0442255437,
0.0454281643, 0.0466991663, 0.0480257124, 0.0493829623, 0.0508184507,
0.0523261763, 0.0539012961, 0.0555426702, 0.0572355427, 0.0590034053,
0.0608959496, 0.0628312901, 0.0648870021, 0.0670434386, 0.069293052,
0.0716472119, 0.0741176531, 0.0767750442, 0.0795389563, 0.0824729055,
0.0855053961, 0.0888369456, 0.0923867524, 0.0960267037, 0.099998571,
19.4087296, 25.4331131, 27.5691681, 29.2334671, 30.6571407, 31.9847107,
33.1879578, 34.3548279, 35.4730759, 36.5515518, 37.6040421, 38.6203461,
39.6331406, 40.6282806, 41.6050644, 42.5709572, 43.5276604, 44.4774475,
45.4060555, 46.3465347, 47.2960243, 48.2376022, 49.1783791, 50.1319237,
51.0807877, 52.0249786, 52.9820442, 53.9233017, 54.8861237, 55.867527,
56.8560944, 57.8343735, 58.8460922, 59.859993, 60.8830948, 61.9143066,
62.9749031, 64.0488586, 65.1051788, 66.193985, 67.2842712, 68.4049301,
69.5398254, 70.6950226, 71.8497238, 73.0302582, 74.2522736, 75.4810791,
76.7125168, 77.9598999, 79.2576141, 80.5695877, 81.9052505, 83.2706146,
84.684494, 86.1218796, 87.575943, 89.0622253, 90.6100311, 92.1830597,
93.7730713, 95.4182053, 97.0992584, 98.8164368, 100.587196, 102.385178,
104.26593, 106.214935, 108.205505, 110.260162, 112.409119, 114.59935,
116.873306, 119.220367, 121.670647, 124.174232, 126.824799, 129.586182,
132.493774, 135.497162, 138.703796, 142.051666, 145.612396, 149.321106,
153.271011, 157.513016, 162.015656, 166.90033, 172.118164, 177.867615,
184.17865, 191.237061, 199.137405, 208.322968, 218.735306, 231.443542,
247.19133, 267.641022, 297.274536, 349.502808, 9709.80566, 10.0000305,
10.3115501, 10.6248951, 10.9402199, 11.2527695, 11.5722694, 11.8882504,
12.2093353, 12.5366001, 12.8689947, 13.2043495, 13.54496, 13.8900404,
14.2461243, 14.5964546, 14.9593792, 15.3207893, 15.6915646, 16.0659904,
16.4513245, 16.8436604, 17.2427406, 17.6487198, 18.0676003, 18.4944954,
18.925745, 19.3696156, 19.8390846, 20.3008003, 20.7718201, 21.2610359,
21.75527, 22.2627258, 22.7823601, 23.3181496, 23.8687191, 24.4279003,
24.9903641, 25.5804062, 26.1656208, 26.7688751, 27.3908348, 28.0240974,
28.6811409, 29.3482742, 30.0246086, 30.7279243, 31.4413109, 32.1794739,
32.9479752, 33.7355537, 34.5289078, 35.3397064, 36.1874695, 37.035614,
37.9202042, 38.8295212, 39.765522, 40.7363434, 41.7169724, 42.7469025,
43.8149986, 44.9053154, 46.0294571, 47.1929054, 48.393734, 49.6308403,
50.9010468, 52.2364655, 53.6578293, 55.1125259, 56.6316833, 58.171814,
59.7827835, 61.4697495, 63.2465057, 65.0879517, 67.0377121, 69.0664673,
71.1800385, 73.4238586, 75.7827988, 78.3006744, 80.973175, 83.8608093,
86.945816, 90.2106628, 93.8297272, 97.6941223, 101.94384, 106.696198,
111.957458, 117.78479, 124.509018, 132.311523, 141.826599, 153.394073,
168.650177, 191.103226, 232.901489, 8347.1709, 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0.742046297, -0.193825096,
0.26935032, -0.0112220673, -0.139426708, 0.400887549, 0.207419217,
0.221283212, -0.104353227, -0.0207283534, -0.235933185, -0.046839077,
0.436740875, 0.529047787, 0.0074962182, -0.108223349, 0.26456356,
-0.164883673, -0.148617476, 0.62583369, 0.0489163101, 0.045555573,
-0.534350276, -0.424330831, 0.403833836, -0.0249867495, 0.095751904,
0.469853312, -0.0373936482, -0.134467408, -0.302458525, 0.0670275241,
-0.159130663, -0.0596224368, 0.0087965671, 0.000988492393, 0.71028316,
0.471915424, 0.147789344, 0.0649461299, 0.447168022, 0.111513153,
-0.0215594936, 0.1739012, -0.0374674909, 0.00964532606, -0.00101886794,
-0.694522858, 0.428120434, 0.151782572, 0.0651607513, 0.432450533,
0.106009319, -0.00607924769, 0.327537477, -0.00418151962, 0.576973438,
-0.368335813, -0.0280906036, 0.185975209, 0.507367432, -0.075104475,
-0.169892803, -0.297387987, -0.254510015, -0.225602284, 0.131597117,
0.0448794104, -0.0602750108, 0.0251164325, 0.309067428, 0.0746701807,
0.531479001, -0.502920508, 0.0146714346, 0.550310194, 0.191963866,
-0.348021239, 0.225748733, -0.152041763, -0.00144933793, -0.518725038,
0.139853299, 0.48748672, 0.433346272, 0.0130696474, 0.282052398,
-0.104920819, -0.022232933, -0.449751109, -0.55003494, -0.0061757802,
-0.0841662511, 0.366514206, -0.069879286, -0.119887538, 0.570462286,
-0.0507414229, -0.0773218721, 0.132044882, 0.0327192694, -0.138720408,
0.0451527089, -0.171223655, 0.195209339, -0.606050909, 0.122684009,
-0.208020791, 0.623383641, 0.280281961, 0.0173130129, -0.0473364033,
0.0165055878, 0.0939709321, -0.343658864, 0.220585451, 0.148301542,
-0.15775466, -0.15736258, -0.392212659, 0.772090375, 0.694772005,
0.163519815, 0.116907328, 0.857465923, 1.02819228, 2.41673899,
1.36556721, 1.12114978, 1.74948835, 0.409734756, 0.972483695, 5., 4.,
8., 9., 12., 7., 13., 10., 11., 3., 6., 2., 12., 10., 34., 10.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 34., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 34., 10.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0.79275161, 1.17488647, 0.00462734606,
-1.00988352, -1.50691402, -1.60607457, -1.51605046, -1.39115417, -1.30553579,
-1.27290559, -1.27569675, -1.288463, -1.291448, -1.27547538, -1.24110425,
-1.19503188, -1.14599919, -1.10154474, -1.06615698, -1.0408119, -1.02355015,
-1.01063406, -0.997845173, -0.98158884, -0.959611952, -0.931273878,
-0.897416353, -0.859946012, -0.821271956, -0.783736885, -0.749153197,
-0.718513072, -0.69189775, -0.668572724, -0.647223771, -0.626271367,
-0.60419929, -0.579836786, -0.552551031, -0.522325039, -0.489721477,
-0.455744475, -0.421634078, -0.388631433, -0.357753903, -0.329618543,
-0.304338276, -0.28150481, -0.260257721, -0.239425793, -0.217716262,
-0.193920672, -0.167105734, -0.136759415, -0.102871075, -0.0659305677,
-0.0268512908, 0.013173772, 0.052860558, 0.091038242, 0.12683478,
0.159818813, 0.190070227, 0.218169227, 0.245101511, 0.272094607,
0.300407857, 0.331111044, 0.364887863, 0.401903093, 0.441756099,
0.483540744, 0.526007056, 0.567804217, 0.607769191, 0.645208657,
0.680124044, 0.713323474, 0.746391594, 0.781501114, 0.821086705,
0.86743331, 0.922250926, 0.986330569, 1.05936909, 1.14001453, 1.22615421
, 1.31537437, 1.40548098, 1.49490345, 1.58282554, 1.6689527, 1.75300586,
1.83427048, 1.91172266, 1.98523259, 2.05762291, 2.13525176, 2.22006989,
2.27695537, 0.705645561, 0.713001788, 0.720336676, 0.725448787,
0.727912605, 0.728181243, 0.727020681, 0.725181639, 0.7232337,
0.721507907, 0.720108271, 0.718955934, 0.717852533, 0.716540992,
0.714760959, 0.71229136, 0.70897913, 0.704752207, 0.699623168,
0.693681121, 0.687078893, 0.680009663, 0.67269218, 0.665343761,
0.658165634, 0.651326776, 0.644949138, 0.639105797, 0.633812726,
0.629034102, 0.624684751, 0.620638847, 0.616740048, 0.612811744,
0.608669043, 0.60412848, 0.599020302, 0.593194842, 0.586530685,
0.578937829, 0.570360124, 0.560773849, 0.550188124, 0.53863889,
0.526183665, 0.512895107, 0.498855382, 0.484146357, 0.468845457,
0.453018963, 0.436716259, 0.41996637, 0.402776569, 0.385131836,
0.366993457, 0.348304331, 0.328988969, 0.308960736, 0.28812331,
0.266379446, 0.243632317, 0.21979095, 0.194774047, 0.168512389,
0.140947431, 0.112034149, 0.0817367435, 0.0500256903, 0.0168724321,
-0.0177542437, -0.0538983792, -0.091621682, -0.131011263, -0.172187611,
-0.21531193, -0.260592759, -0.30829218, -0.358733237, -0.412306517,
-0.469475597, -0.5307886, -0.5968858, -0.668512523, -0.746532798, -0.831944168
, -0.925888717, -1.02966547, -1.1447264, -1.27265489, -1.41511273, -1.57373285
, -1.74993932, -1.94464993, -2.1578331, -2.38784146, -2.63046288, -2.87758732,
-3.11537886, -3.32179546, -3.46330237, -2.4160738, -2.44235706, -2.39227605,
-2.28823614, -2.14827704, -1.98672688, -1.81477225, -1.64096332, -1.4716537,
-1.31138468, -1.16321659, -1.02901566, -0.909701586, -0.80545491, -0.715896487
, -0.640235186, -0.577393472, -0.526108027, -0.485013306, -0.452707738,
-0.427806169, -0.408979356, -0.394982874, -0.384678304, -0.37704581,
-0.371191442, -0.36634922, -0.3618792, -0.35726288, -0.352094948, -0.346075267
, -0.338998526, -0.330742568, -0.321258068, -0.310556948, -0.298701316,
-0.285792589, -0.271962434, -0.257362872, -0.242158055, -0.226517081,
-0.210606441, -0.194584921, -0.178599238, -0.162778482, -0.147232339,
-0.13204813, -0.117289186, -0.102993153, -0.0891724899, -0.0758145228,
-0.0628810525, -0.0503100976, -0.0380175188, -0.0258979816, -0.0138273472,
-0.00166445028, 0.0107467258, 0.0235740766, 0.0369957909, 0.0511971898,
0.066369921, 0.0827072337, 0.100404337, 0.119654469, 0.140648499,
0.16357173, 0.188603163, 0.215914637, 0.245668918, 0.278018028,
0.313104957, 0.351059556, 0.391999453, 0.436031163, 0.48324573,
0.533720016, 0.587515771, 0.644676566, 0.705224931, 0.769160926,
0.836455643, 0.907046437, 0.980826855, 1.05763853, 1.13725483,
1.21936631, 1.30355859, 1.38928533, 1.47583616, 1.56229818, 1.6475085,
1.72999537, 1.80791342, 1.87896121, 1.94028878, 1.98838401, 2.01894617,
2.02673221, 2.00538659, 0.829770327, 0.884494424, 0.884960473,
0.863213956, 0.836949229, 0.81461817, 0.799057424, 0.789983213,
0.785648227, 0.783880591, 0.782685876, 0.780543506, 0.77650398,
0.770163894, 0.761565983, 0.751078546, 0.739260077, 0.726746798,
0.71415323, 0.702004075, 0.690686464, 0.680430651, 0.671306133,
0.663237154, 0.65602541, 0.649383187, 0.642968655, 0.636419296,
0.629383028, 0.621549487, 0.612666726, 0.602561295, 0.591141641,
0.578404069, 0.564426303, 0.549361169, 0.53341943, 0.516859353,
0.499963224, 0.483024538, 0.466326177, 0.450125784, 0.434641451,
0.420038551, 0.40642339, 0.393835664, 0.382249743, 0.37157616,
0.361664563, 0.352316231, 0.343290895, 0.334322095, 0.325128019,
0.315429151, 0.304957688, 0.29347378, 0.280772895, 0.266696036,
0.25113529, 0.234034657, 0.215389267, 0.195239708, 0.173665315,
0.150770009, 0.126672268, 0.101485699, 0.0753060356, 0.0481937155,
0.0201574415, -0.00885500293, -0.0389681198, -0.0703818277, -0.103372447,
-0.138285682, -0.17552717, -0.215546563, -0.258819848, -0.305829823,
-0.357048601, -0.412923872, -0.473876059, -0.540306211, -0.612619758,
-0.691271663, -0.776831686, -0.870067179, -0.972046793, -1.08424127,
-1.20861387, -1.34766459, -1.50438523, -1.68206441, -1.88384724, -2.11195326,
-2.36637092, -2.64285111, -2.92993069, -3.20466924, -3.42667723, -3.52995825,
0.828915238, 0.860562861, 0.858765364, 0.846152008, 0.833059132,
0.822946608, 0.815857291, 0.810500383, 0.805405736, 0.799465835,
0.792110264, 0.783265293, 0.773220301, 0.762462199, 0.751527727,
0.740889132, 0.730881095, 0.72167176, 0.713260055, 0.705507636,
0.698174417, 0.690969467, 0.683595479, 0.675787151, 0.667342901,
0.658141315, 0.648147881, 0.637410641, 0.626047254, 0.614227653,
0.602149129, 0.590015709, 0.57801342, 0.566294909, 0.554961622,
0.54405874, 0.533570707, 0.523423254, 0.513493419, 0.503618062,
0.493610501, 0.483274549, 0.472420245, 0.460880011, 0.448516786,
0.435237855, 0.420996547, 0.405795276, 0.389684588, 0.372755319,
0.355129898, 0.336954057, 0.318383753, 0.299571991, 0.280658692,
0.261759996, 0.242960855, 0.224308938, 0.205811501, 0.187437445,
0.169118792, 0.150754452, 0.132218644, 0.113365591, 0.0940359682,
0.0740626603, 0.0532746613, 0.031494651, 0.00854093768, -0.0157793388,
-0.0416762866, -0.0693850443, -0.0991747305, -0.131355301, -0.166282848,
-0.204361066, -0.246038839, -0.291801006, -0.342157662, -0.39762643,
-0.458718121, -0.525924385, -0.59971422, -0.680544317, -0.768893957,
-0.865320981, -0.970554233, -1.08560765, -1.21191406, -1.35145056, -1.50681627
, -1.68119335, -1.87807786, -2.1006465, -2.35052037, -2.62564206, -2.91685843,
-3.20268416, -3.4415338, -3.56056476, -0.283341914, -0.35271436, -0.414448112,
-0.469242185, -0.517795086, -0.560780704, -0.598831892, -0.632528186,
-0.66239053, -0.688876927, -0.712383389, -0.733246028, -0.751745582,
-0.768112779, -0.782533765, -0.795158029, -0.806104243, -0.81546694,
-0.823322594, -0.829735935, -0.834763885, -0.838460088, -0.840879023,
-0.842077374, -0.842116714, -0.841064155, -0.838992, -0.83597821, -0.832104743
, -0.827456057, -0.822117031, -0.816171229, -0.809696913, -0.802765906,
-0.795440435, -0.787770033, -0.77978909, -0.771515906, -0.76294893,
-0.754066706, -0.744826794, -0.735164404, -0.724993348, -0.71420598,
-0.702674806, -0.690253735, -0.676781356, -0.662081957, -0.645970762,
-0.628255606, -0.608743191, -0.587240696, -0.563562274, -0.537532926,
-0.508992851, -0.47780174, -0.443842798, -0.407027245, -0.367296547,
-0.324625611, -0.279025286, -0.230542108, -0.179260105, -0.125299171,
-0.0688132346, -0.00998795871, 0.0509634316, 0.1138051, 0.178285256,
0.244143173, 0.311116576, 0.378952384, 0.447414935, 0.516294003,
0.585419416, 0.654667199, 0.723969638, 0.7933231, 0.862795472,
0.932527065, 1.00273335, 1.07370329, 1.14578784, 1.21938825, 1.29493606,
1.37286079, 1.45355594, 1.53732467, 1.62432206, 1.71447337, 1.80738509,
1.90223026, 1.99761546, 2.09142733, 2.18064857, 2.2611475, 2.32743669,
2.37239623, 2.38695407, 2.35973358, -3.67520356, -2.66596103, -2.05883956,
-1.69530404, -1.47172296, -1.32307327, -1.21074486, -1.11359394, -1.02151239,
-0.930915773, -0.841692269, -0.755220473, -0.673174262, -0.596864283,
-0.526957512, -0.463433981, -0.40567553, -0.352633923, -0.303013027,
-0.255446643, -0.20864819, -0.161522761, -0.113241315, -0.0632783622,
-0.0114182141, 0.0422690585, 0.0974633619, 0.153648168, 0.210172281,
0.266308993, 0.321310967, 0.374466598, 0.425141186, 0.472812653,
0.517089546, 0.557734191, 0.594658613, 0.627920508, 0.657713652,
0.684348464, 0.708226144, 0.729812324, 0.749609828, 0.768131137,
0.785862505, 0.80324626, 0.820647955, 0.83834219, 0.85649395,
0.875149846, 0.894226134, 0.913518131, 0.932701588, 0.951342344,
0.968921244, 0.98485297, 0.998513818, 1.00927734, 1.01654601, 1.01978672
, 1.01857102, 1.01260185, 1.00174499, 0.986050904, 0.965765655,
0.941332996, 0.913380742, 0.882693291, 0.850167692, 0.816754639,
0.783381462, 0.750865459, 0.719808459, 0.69050163, 0.66281724,
0.636117876, 0.60918355, 0.580178976, 0.546650529, 0.505602002,
0.453619599, 0.387094378, 0.302525938, 0.196912572, 0.0682238564,
-0.0840704963, -0.258455902, -0.450872838, -0.65435487, -0.85893935,
-1.05202806, -1.21943605, -1.3474406, -1.42623985, -1.45530772, -1.45129764,
-1.45926273, -1.56816566, -1.93182683, -2.79673791, 0.971784413, 0.982211888
, 0.989517093, 0.994264126, 0.996920645, 0.997871697, 0.997429013,
0.995842874, 0.993310392, 0.989982784, 0.985973299, 0.981364548,
0.976212204, 0.970552802, 0.964406669, 0.957780659, 0.950673342,
0.943077981, 0.934981704, 0.92637223, 0.917234063, 0.907554984,
0.897322118, 0.886525929, 0.875158966, 0.863215148, 0.850691795,
0.837588847, 0.823907077, 0.80964905, 0.794817626, 0.779416084,
0.763448536, 0.746916294, 0.729820848, 0.712159336, 0.693928421,
0.675119996, 0.655723155, 0.635722399, 0.615098, 0.593826234,
0.571878672, 0.549221337, 0.525817752, 0.501625776, 0.476599395,
0.450691134, 0.423847407, 0.396016032, 0.367141455, 0.337168097,
0.306039661, 0.273703963, 0.240108117, 0.205205381, 0.168951675,
0.131309733, 0.0922490358, 0.0517472178, 0.00979106314, -0.0336231552,
-0.0784876421, -0.124783084, -0.172477618, -0.221526504, -0.271872461,
-0.323443294, -0.376156002, -0.429913938, -0.484609008, -0.540123284,
-0.596329629, -0.65309453, -0.710280716, -0.767749906, -0.825366557,
-0.88300252, -0.940542221, -0.997887015, -1.05496407, -1.11173201, -1.16818881
, -1.224383, -1.28042161, -1.33648181, -1.39282584, -1.44981003, -1.50790346,
-1.56770217, -1.62994647, -1.6955415, -1.76557398, -1.84133816, -1.92435777,
-2.01641011, -2.11955523, -2.23616385, -2.36894703, -2.52099109, 0.93668133,
0.935175896, 0.933292329, 0.931097567, 0.928642631, 0.925963581,
0.923083842, 0.920016706, 0.916765869, 0.913326561, 0.909688413,
0.905834615, 0.901745617, 0.89739722, 0.89276439, 0.887820005,
0.882535696, 0.876884282, 0.870838642, 0.864372611, 0.857460856,
0.850080609, 0.842211306, 0.833833396, 0.824930847, 0.815489173,
0.805496752, 0.794944286, 0.783824503, 0.772132993, 0.759865642,
0.747022152, 0.733602464, 0.71960777, 0.705041289, 0.689905286,
0.674203396, 0.657938898, 0.641114831, 0.623732924, 0.60579437,
0.587298036, 0.568241298, 0.548619449, 0.52842474, 0.507646501,
0.486270815, 0.464279622, 0.44165203, 0.418361902, 0.394379526,
0.369669944, 0.344193876, 0.317907572, 0.290761411, 0.262702525,
0.233672097, 0.203606561, 0.172438681, 0.140096426, 0.106504098,
0.0715819672, 0.0352484621, -0.00258185389, -0.0419955142, -0.083080709,
-0.125925615, -0.1706177, -0.217243135, -0.265885502, -0.316624522,
-0.369534642, -0.42468363, -0.482130677, -0.541925728, -0.604106963,
-0.668698728, -0.735709548, -0.805131257, -0.876933455, -0.951064587,
-1.02744758, -1.10597706, -1.18651676, -1.26889682, -1.35290825, -1.43830335,
-1.52478933, -1.61202502, -1.69961751, -1.78711772, -1.87401676, -1.95973885,
-2.04364085, -2.12500381, -2.20303011, -2.27683663, -2.34545064, -2.40780234,
-2.46272111, 0.179437339, 0.0503808185, -0.0459162705, -0.11627432,
-0.166475922, -0.201378316, -0.225016817, -0.240703389, -0.251116216,
-0.25838089, -0.264144719, -0.269647568, -0.275779337, -0.283138424,
-0.29208234, -0.302771449, -0.31520921, -0.329276949, -0.344766349,
-0.361406058, -0.378882945, -0.396863788, -0.415011942, -0.43299976,
-0.450521052, -0.46729821, -0.483088911, -0.497691154, -0.510945261,
-0.522735357, -0.532987833, -0.541672111, -0.548795879, -0.554402828,
-0.558570087, -0.561399579, -0.563018441, -0.56356889, -0.56320864,
-0.562098622, -0.560404778, -0.558288932, -0.555904388, -0.553392828,
-0.550879836, -0.548472404, -0.546253085, -0.544281602, -0.542589188,
-0.541179955, -0.540028989, -0.53908354, -0.538262963, -0.537457705,
-0.536535859, -0.535341144, -0.533697307, -0.53141135, -0.528276384,
-0.524075866, -0.51858902, -0.511590898, -0.502860069, -0.492182076,
-0.479352087, -0.464177817, -0.446484357, -0.426115483, -0.402933776,
-0.376822591, -0.347686112, -0.315443844, -0.280031234, -0.241391331,
-0.199469298, -0.154201299, -0.105504684, -0.0532614738, 0.00269911624,
0.062617965, 0.126833156, 0.19580768, 0.270159394, 0.350701898,
0.438473642, 0.534799218, 0.641325176, 0.760086894, 0.893568158,
1.04476655, 1.21727085, 1.41534495, 1.64401197, 1.9091599, 2.2176404,
2.57738686, 2.99753308, 3.48855448, 4.062397, 4.73264265, -2.80896831,
-2.71265268, -2.60491037, -2.48912787, -2.36927962, -2.24895692, -2.13089848,
-2.0168376, -1.90756619, -1.8031019, -1.70290983, -1.60612285, -1.51174521,
-1.41881275, -1.32650936, -1.23424256, -1.1416719, -1.04871202, -0.955503047,
-0.862369001, -0.769761741, -0.678206325, -0.588244677, -0.500392079,
-0.415096819, -0.332715124, -0.253497928, -0.177587748, -0.105024762,
-0.0357645229, 0.030305028, 0.0933331028, 0.153485358, 0.210917711,
0.26575318, 0.318067253, 0.3678734, 0.415121615, 0.459697425,
0.501431525, 0.540111959, 0.575503647, 0.607367873, 0.635484159,
0.65967834, 0.6798383, 0.695937276, 0.708044708, 0.716332376,
0.721085191, 0.722688138, 0.721615016, 0.718415201, 0.713687956,
0.708048403, 0.702101886, 0.696407497, 0.691442668, 0.687577784,
0.685044289, 0.683915138, 0.684096634, 0.685325623, 0.687172174,
0.689065039, 0.690322101, 0.690185666, 0.687881112, 0.682664216,
0.673885703, 0.661052287, 0.643878996, 0.622346282, 0.596725762,
0.567610681, 0.535903573, 0.502799392, 0.46973294, 0.438291401,
0.410119087, 0.38678363, 0.369631052, 0.359635711, 0.357248336,
0.362278879, 0.373806506, 0.390171051, 0.409053266, 0.427687019,
0.443235457, 0.453379393, 0.457137078, 0.455986023, 0.45528686,
0.46608001, 0.507252574, 0.608097494, 0.811259985, 1.17603958,
1.78199589, -0.466446131, -0.406253785, -0.187750444, 0.209844604,
0.107990727, -0.0358100347, 0.707622051, 0.038985692, 0.0842018649,
-0.0160823073, 0.169486806, -0.173175141, 0.426457494, 0.213268265,
0.387625426, 0.0895364955, -0.0733063295, 0.180744663, 0.340561956,
0.508553922, 0.412114531, -0.286214411, -0.19690372, 0.156221986,
-0.0461156294, -0.0330572836, -0.155376285, -0.132778212, 0.270281553,
-0.0307805669, 0.113753147, -0.270257652, -0.4857485, 0.0570595153,
-0.0830436349, 0.185570806, 0.521060646, 0.31423223, 0.00699479599,
0.0253034141, -0.0518701337, -0.26441592, -0.746383846, -0.212740317,
0.0692374855, -0.126614943, 0.0864981338, 0.240692869, 0.103879191,
-0.378956825, -0.323072344, 0.195747882, 0.460536182, 0.212230459,
0.260719687, 0.0193789359, 0.232112244, -0.101696707, -0.0246305577,
-0.0572436042, -0.934716046, -1.02910948, 0.269048303, -0.433322608,
-0.178773567, -0.358017862, -0.734189272, -0.281088501, -0.229478195,
-0.528334796, 0.346018761, 0.0801536962, -0.388144851, 0.0076266923,
-0.00770473015, 0.0919953138, -0.0262573939, -0.0519930571, 0.620597601,
0.0500325933, 0.208724648, -0.0133896004, -0.100959517, 0.349831909,
0.264384627, -0.239772052, -0.029438382, 0.164830178, 0.0383137986,
0.021168856, -0.0402870104, 0.019597711, -0.377092421, -0.147742614,
-0.331852764, -0.271914423, 0.402443022, 0.506712914, 0.515151024,
-0.167991802, -0.00580040552, -0.025443878, -0.832010806, 0.207648322,
-0.0452438332, 0.281653225, -0.298157185, -0.193581358, -0.370397955,
-0.591762304, -0.327108651, 0.219983131, 0.194949538, -0.0278544296,
-0.1405292, -0.0213419981, 0.0704645589, 0.315012395, -0.0480981283,
0.389037549, 0.623779476, 0.757817149, -0.175042927, 0.327892333,
-0.17313002, 0.0891248286, 0.627812564, 0.0530447252, 0.434176207,
0.38765201, 0.153125882, -0.0163927041, 0.204355508, -0.269910097,
0.14590694, -0.155103996, 0.0618448704, 0.144087374, 0.640090048,
0.204906747, 0.453650087, 0.294538528, 0.357660383, 0.166788429,
1.10515392, 0.433218926, -0.0206853691, -1.11152053, -0.0992550999,
-0.665447235, 0.584787548, -0.203686967, -0.560903728, -0.280764282,
1.06721151, 0.593813181, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -5.37400723
, -3.90561724, -3.55815721, -3.31320286, -3.11864543, -2.9496994, -2.80808902,
-2.6787765, -2.55990076, -2.452075, -2.35100937, -2.25726819, -2.16852808,
-2.08339119, -2.00153875, -1.92375672, -1.84923196, -1.77531242, -1.70363331,
-1.63485408, -1.56733048, -1.50123453, -1.43669176, -1.37367582, -1.31132555,
-1.25032187, -1.19035721, -1.13233948, -1.07396865, -1.01763785, -0.961020947,
-0.906530678, -0.853343666, -0.801216722, -0.74853766, -0.696519196,
-0.645119011, -0.595181286, -0.545216322, -0.495675564, -0.446374863,
-0.397496939, -0.350188136, -0.302638829, -0.254665852, -0.207550004,
-0.160300195, -0.114350885, -0.0687696636, -0.0221715569, 0.0232543051,
0.0687215179, 0.114494279, 0.159247905, 0.203141451, 0.248655587,
0.292547464, 0.335876912, 0.379597247, 0.42361629, 0.466982454,
0.511221409, 0.555893421, 0.600845337, 0.644742131, 0.689860404,
0.734682977, 0.780003309, 0.825417697, 0.871976912, 0.918766379,
0.966502309, 1.01503134, 1.06433916, 1.11468863, 1.16676474, 1.21885848,
1.27310073, 1.32988369, 1.38788939, 1.44831753, 1.512187, 1.57920337,
1.65041542, 1.72738755, 1.80963421, 1.89822793, 1.99175727, 2.09175062,
2.19958019, 2.31501055, 2.44124174, 2.58088827, 2.73281479, 2.90365648,
3.09504557, 3.30091381, 3.52286029, 3.76274276, 4.031528, 4.66624975,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., -4.95366001, -3.97529364, -3.6574719,
-3.35132074, -3.12077951, -3.09174991, -2.73993802, -2.68978763, -2.49411845,
-2.42771244, -2.30053377, -2.19804311, -2.09019899, -2.05023456, -1.94513845,
-1.85135186, -1.80399036, -1.73069668, -1.66227949, -1.62534654, -1.52811205,
-1.44605649, -1.36440039, -1.33486462, -1.25299954, -1.16210556, -1.14539337,
-1.08676445, -1.03010845, -0.922261059, -0.909424484, -0.880106807,
-0.798850179, -0.773977041, -0.727495313, -0.643043756, -0.618658304,
-0.517703533, -0.49705869, -0.431398392, -0.417050421, -0.361222267,
-0.33680433, -0.264482677, -0.254115283, -0.228339016, -0.126844525,
-0.110061109, -0.0689505339, -0.0256831646, 0.076263845, 0.115463793,
0.17902112, 0.180507421, 0.226157308, 0.283525407, 0.304602981,
0.353158891, 0.367289543, 0.432169497, 0.464802504, 0.536869645,
0.595712006, 0.616080344, 0.651097536, 0.684794664, 0.769542813,
0.808092833, 0.866930008, 0.885917425, 0.970525384, 0.993862152,
1.04498959, 1.08357453, 1.13507724, 1.19997907, 1.26573884, 1.30804586,
1.36410236, 1.36963809, 1.43740606, 1.49221456, 1.54712379, 1.58875966,
1.70847499, 1.79166031, 1.92441225, 2.05205631, 2.16736221, 2.26595545,
2.39917994, 2.51080942, 2.70500135, 2.8135891, 2.85916543, 3.1871717,
3.47076082, 3.73248386, 4.00855446, 4.86941957,
0.]
}
| [
"jonesc@hep.phy.cam.ac.uk"
] | jonesc@hep.phy.cam.ac.uk |
afd206939e99742b1595a09be624787d0205feb3 | e25ff4345513f36352f069ab0c4f59fa306fb177 | /build/effort_controllers/catkin_generated/pkg.develspace.context.pc.py | 8473a000a08bf8d59e121bbcae2536fd5c281e69 | [] | no_license | gistleejongwon/drone_with_arm | db9b40faac17bf59d21803ec3480f45dfec2a395 | ad2abc0283362085379f112cbb66bf34a4a43419 | refs/heads/master | 2023-06-27T20:47:44.827312 | 2021-08-03T05:27:50 | 2021-08-03T05:27:50 | 387,333,909 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 693 | py | # generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/jongwon/catkin_ws/src/ros_controllers/effort_controllers/include".split(';') if "/home/jongwon/catkin_ws/src/ros_controllers/effort_controllers/include" != "" else []
PROJECT_CATKIN_DEPENDS = "angles;controller_interface;control_msgs;control_toolbox;forward_command_controller;realtime_tools;urdf".replace(';', ' ')
PKG_CONFIG_LIBRARIES_WITH_PREFIX = "-leffort_controllers".split(';') if "-leffort_controllers" != "" else []
PROJECT_NAME = "effort_controllers"
PROJECT_SPACE_DIR = "/home/jongwon/catkin_ws/devel/.private/effort_controllers"
PROJECT_VERSION = "0.17.2"
| [
"jongwonlee@gist.ac.kr"
] | jongwonlee@gist.ac.kr |
959e28340b4a983535bf120dad4048c148998f68 | c404eaef31d01f7e978e950335cb30660b441d2b | /egs/msra_ner/seq_label/v1/local/change_data_format.py | 9ba919290e064cf634e72a8815ba9d74c2cf2daa | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | luffywalf/delta | 14acf19cf0a089760b5d179d3b518a8b4c931557 | 7eb4e3be578a680737616efff6858d280595ff48 | refs/heads/master | 2020-07-31T09:01:00.415226 | 2019-10-10T05:07:20 | 2019-10-10T05:07:20 | 210,553,403 | 1 | 0 | Apache-2.0 | 2019-09-24T08:38:15 | 2019-09-24T08:38:12 | null | UTF-8 | Python | false | false | 2,582 | py | # Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd.
# All rights reserved.
#
# 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 in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
import sys
from absl import logging
def change_data_format(files):
for data_file_in in files:
if data_file_in == sys.argv[3]:
logging.info("Change data format: {}".format(data_file_in))
data_file_out = data_file_in.replace(".in", ".out")
with open(data_file_out, "w", encoding="utf-8") as output_file:
with open(data_file_in, "r", encoding="utf-8") as file_input:
for line in file_input.readlines():
word = list(line.strip())
if len(line.strip()) != 0:
output_file.write(' '.join(word) + "\n")
return
logging.info("Change data format: {}".format(data_file_in))
data_file_out = data_file_in.replace(".in", ".out")
words, labels = [], []
with open(data_file_out, "w", encoding="utf-8") as output_file:
with open(data_file_in, "r", encoding="utf-8") as file_input:
for line in file_input.readlines():
word = line.strip().split('\t')[0]
label = line.strip().split('\t')[-1]
# here we dont do "DOCSTART" check
if len(line.strip()) == 0:
l = [label for label in labels if len(label) > 0]
w = [word for word in words if len(word) > 0]
assert len(l) == len(w)
l, w = ' '.join(l), ' '.join(w)
output_file.write(l + "\t" + w + "\n")
words, labels = [], []
words.append(word)
labels.append(label)
logging.info("Change data done: {}".format(data_file_out))
if __name__ == '__main__':
logging.set_verbosity(logging.INFO)
if len(sys.argv) != 4:
logging.error("Usage python {} train_file, dev_file, test_file".format(sys.argv[0]))
sys.exit(-1)
train_file = sys.argv[1]
dev_file = sys.argv[2]
test_file = sys.argv[3]
files = [train_file, dev_file, test_file]
change_data_format(files)
| [
"kunhan@didichuxing.com"
] | kunhan@didichuxing.com |
b12db8646c343951c304e5f35a240e9192f454b5 | ea96407c1d4b061e34715e5f398f2c386af97c93 | /serie8/ex3_2.py | 6dbb694670ee4ba498e2995854570ca1c84e7168 | [
"MIT"
] | permissive | roctubre/compmath | 03208c6d7daac3cfea6b00741cbb1b32f5045df2 | 06b287b2d24d6f033c60defb5a70d97e045644ad | refs/heads/master | 2021-02-19T03:03:24.753468 | 2020-05-24T09:23:02 | 2020-05-24T09:23:02 | 245,270,689 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 536 | py | import numpy as np
def chessboard(n, display = True):
"""
Creates a chessboard-matrix with dimensions n times n
To account for uneven matrices, first a 2n times 2n matrix is created, then
only the upper left part of the matrix (n times n) is sliced out
"""
even_row = np.array([1,0]*n)
uneven_row = np.array([0,1]*n)
stacked = np.row_stack((even_row, uneven_row)*n)
matrix = stacked[:n,:n]
if display:
print(matrix)
return matrix
if __name__ == "__main__":
chessboard(7) | [
"robertryan.chavez@hotmail.com"
] | robertryan.chavez@hotmail.com |
b74e9d05063075be9b5d6c47915ac631e30587a5 | f83a3b6767544c17274784b51f33993e3faece89 | /backend/api/urls.py | 417bfb2585a17fea4389cc46c814591eeb18c2e1 | [] | no_license | KaizakiRyu/cmpt-470-final-project-Price-Monitor-App | b43bd2b840b1a2510347c1f24fc9bbbd08f62a21 | f41166801b856d89c5df5a4521ac4f14822df080 | refs/heads/master | 2023-08-09T06:03:37.044215 | 2023-07-26T20:08:57 | 2023-07-26T20:08:57 | 336,707,647 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 285 | py | # from django.urls import path
# from .views import (
# registration_view
# )
# from rest_framework.authtoken import views
# app_name = "api"
# urlpatterns = [
# path('register', registration_view, name='register'),
# path('api-token-auth/', views.obtain_auth_token)
# ] | [
"leom@sfu.ca"
] | leom@sfu.ca |
b792549d1af24b7d31eb830bf6dd9db1c6a022ab | 99f8ff7cf3aea28e69f91543548a33688a7c4eee | /interpreter/atom_table.py | 0ba23eaa95fe138303629e7f3edee5f20beee52e | [] | no_license | tzwenn/pyrlang | 4d5ff6649c00ad6fcca4cc4f92d24a914fc286bb | ec3543f543c08446c4bb358f2b1bcd0cff64e582 | refs/heads/master | 2020-03-23T20:09:51.091174 | 2018-07-23T14:05:47 | 2018-07-23T14:23:12 | 142,025,380 | 2 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,090 | py | from pyrlang.interpreter.datatypes.atom import W_AtomObject, W_BoolAtomObject
class Atom_Table:
def __init__(self):
self._str_table = ['nil']
self._obj_table = [W_AtomObject(0)]
self.TRUE_ATOM = self.get_obj_at(self.register_str('true', True))
self.FALSE_ATOM = self.get_obj_at(self.register_str('false', True))
def search_index(self, s):
for i in range(len(self._str_table)):
if self.get_str_at(i) == s:
return i
return -1
def get_obj_at(self, idx):
return self._obj_table[idx]
def get_str_at(self, idx):
return self._str_table[idx]
def register_str(self, s, is_bool = False):
idx = self.search_index(s)
if idx == -1:
new_idx = len(self._str_table)
self._str_table.append(s)
if is_bool:
self._obj_table.append(W_BoolAtomObject(new_idx))
else:
self._obj_table.append(W_AtomObject(new_idx))
return new_idx
else:
return idx
def register_atoms(self, atoms):
for s in atoms:
self.register_str(s)
def get_obj_from_str(self, s):
idx = self.register_str(s)
return self._obj_table[idx]
global_atom_table = Atom_Table()
| [
"hrc706@gmail.com"
] | hrc706@gmail.com |
0780dbdfb71c10da0e058dedd0808ea3025e309b | 262ff29e5d1c9e8754cf615d661131bd5a65664d | /hw5.py | f7c81e3a71467a685ee85a8ef79ae84828c25e58 | [] | no_license | wenbin-lin/Systems_Engineering | 1daf36981afe0a07bc05260770445b245cd86e7e | 8e91d2f7d09fb88d418234f94041c2f6dddf34f8 | refs/heads/master | 2022-05-19T03:03:25.989088 | 2019-07-17T15:50:35 | 2019-07-17T15:50:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 2,545 | py | import numpy as np
import math
import scipy.io as scio
import scipy.stats as stats
data_path = './counties.mat'
def load_data(path):
data_file = scio.loadmat(path)
data = data_file['data']
X = data[:, :-1]
y = data[:, -1]
return X, y
def pca_compress(data, rerr):
X_bar = np.mean(data, axis=0)
X_sigma = np.std(data, axis=0)
X_norm = (data - X_bar) / X_sigma
eigen_values, eigen_vectors = np.linalg.eigh(np.matmul(X_norm.transpose(), X_norm))
ev_sum = np.sum(eigen_values)
sum = 0.0
counter = 0
while sum / ev_sum < rerr:
sum += eigen_values[counter]
counter += 1
counter -= 1
if counter < X.shape[1]:
print('dimension compressed from %d to %d' % (X.shape[1], X.shape[1] - counter))
pcs = eigen_vectors[:, counter:]
cprs_data = np.matmul(X_norm, pcs)
cprs_c = [X_bar, X_sigma]
return pcs, cprs_data, cprs_c
def pca_reconstruct(pcs, cprs_data, cprs_c):
recon_data = cprs_data @ pcs.transpose() * cprs_c[1] + cprs_c[0]
return recon_data
def linear_regresstion(X, y, rerr, alpha):
pcs, cprs_data, cprs_c = pca_compress(X, rerr)
recon_data = pca_reconstruct(pcs, cprs_data, cprs_c)
y_bar = np.mean(y, axis=0)
y_sigma = np.std(y, axis=0)
y_norm = (y - y_bar) / y_sigma
b_hat = np.linalg.inv(cprs_data.transpose() @ cprs_data) \
@ cprs_data.transpose() @ y_norm.reshape(y_norm.size, 1)
weight = pcs @ b_hat * y_sigma / cprs_c[1].reshape(-1, 1)
bias = y_bar - cprs_c[0] @ weight
result_str = 'y = '
for i in range(pcs.shape[0]):
result_str += '(%.6f * x%d) + ' % (weight[i], i + 1)
result_str += '(%.6f)' % (bias)
print(result_str)
y_hat = (X @ weight + bias).squeeze()
ESS = np.sum(np.multiply(y_hat - y_bar, y_hat - y_bar))
RSS = np.sum(np.multiply(y - y_hat, y - y_hat))
F = (X.shape[0] - X.shape[1] - 1) * ESS / (X.shape[1] * RSS)
F_alpha = stats.f.isf(q=alpha, dfn=X.shape[1], dfd=X.shape[0] - X.shape[1] - 1)
print('F = %.2f' % (F))
print('F_alpha = %.2f' % (F_alpha))
if F > F_alpha:
print('Y and X have linear relationship')
S_sigma = math.sqrt(RSS / (X.shape[0] - X.shape[1] - 1))
interval = S_sigma * stats.norm.isf(alpha / 2)
print('confidence interval is %.4f' % interval)
else:
print('Y and X do not have linear relationship')
if __name__ == '__main__':
rerr = 0.05
alpha = 0.05
X, y = load_data(data_path)
print(X.shape )
linear_regresstion(X, y, rerr, alpha)
| [
"723172572@qq.com"
] | 723172572@qq.com |
f304291f2301789b4cb05de6a24fca2ba9c637e9 | d2a2f0c43beab087945198749d0be7cd02c9d5e8 | /articles/admin.py | ce70d85d87950d39bedce7a8674ec3078810590e | [] | no_license | beczkowb/blog | 18b339777ec139a26adee18dc4153f2c1cf6e0b4 | 9b5944a5fbd294345ae9c7c2a94b1801d03e5c5c | refs/heads/master | 2021-03-19T13:05:50.989536 | 2015-02-19T19:18:10 | 2015-02-19T19:18:10 | 30,605,891 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 631 | py | from django.contrib import admin
from django import forms
from pagedown.widgets import AdminPagedownWidget
from .models import Article, Tag, Category, BlogName, Owner, Greeting
class ArticleForm(forms.ModelForm):
class Meta:
model = Article
fields = ['title', 'preface', 'content', 'category', 'tags', ]
widgets = {
'content': AdminPagedownWidget
}
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
form = ArticleForm
admin.site.register(Tag)
admin.site.register(Category)
admin.site.register(BlogName)
admin.site.register(Owner)
admin.site.register(Greeting)
| [
"beczkowb@gmail.com"
] | beczkowb@gmail.com |
57d416c221a528cdf691d2f632ed2671f3ba4e76 | bc33abf80f11c4df023d6b1f0882bff1e30617cf | /Python/socket/user_2.py | fc00e17b5a9301706593cf13f7e6242b712fabfc | [] | no_license | pkuzhd/ALL | 0fad250c710b4804dfd6f701d8f45381ee1a5d11 | c18525decdfa70346ec32ca2f47683951f4c39e0 | refs/heads/master | 2022-07-11T18:20:26.435897 | 2019-11-20T13:25:24 | 2019-11-20T13:25:24 | 119,031,607 | 0 | 0 | null | 2022-06-21T21:10:42 | 2018-01-26T09:19:23 | C++ | UTF-8 | Python | false | false | 795 | py | import socket, threading
import time
def tcplink(sock, addr):
print('Accept new connection from %s:%s...' % addr)
sock.send(b'Welcome!')
while True:
data = sock.recv(1024)
time.sleep(1)
if not data or data.decode('utf-8') == 'exit':
break
sock.send(('Hello, %s!' % data.decode('utf-8')).encode('utf-8'))
sock.close()
print('Connection from %s:%s closed.' % addr)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('192.168.1.101', 9999))
s.listen(5)
print('Waiting for connection...')
'''
while True:
# 接受一个新连接:
print(1)
sock, addr = s.accept()
print((1, sock, addr))
# 创建新线程来处理TCP连接:
t = threading.Thread(target=tcplink, args=(sock, addr))
t.start()'''
| [
"pkuzhd@pku.edu.cn"
] | pkuzhd@pku.edu.cn |
2e77868a2c5f19118ab7c98d9b3fd9aa03722787 | 83658462e9e6fac166a3bc52e41080c6e550846d | /Site/role/views.py | d736ffa13534d830e5f6811026b991db30de2c98 | [] | no_license | yanchengxin2018/history | ea8937a9acfeb91339bf8a00ba84d7b7fb98d24b | 53eab1d97250f42feea0b9b7facd1279696cb1bf | refs/heads/master | 2020-05-19T16:19:44.406734 | 2019-05-06T01:39:49 | 2019-05-06T01:39:49 | 185,104,331 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,634 | py | from django.shortcuts import render
from rest_framework.viewsets import GenericViewSet as G,mixins as M
from Questionnaire.models import SchoolMaster as SchoolSchoolMasterModle
from role.serializers import SchoolSchoolHeadSerializer
from django.conf import settings
from django.db.models import Q
#创造一个校长
class CreateSchoolHeadViewSet(G):
def list(self,request):
create_user='{}/api/Questionnaire_Users/'.format(settings.ROOT_URL)
bind_role='{}/api/Questionnaire_UsersRoles/'.format(settings.ROOT_URL)
bind_school='{}/role/schoolschoolhead/'.format(settings.ROOT_URL)
data={'create_user':create_user,'bind_role':bind_role,'bind_school':bind_school,}
return render(request,'createschoolhead.html',data)
#创造一个用户并绑定到角色
class CreateUserRoleViewSet(G):
def list(self,request):
create_user='{}/api/Questionnaire_Users/'.format(settings.ROOT_URL)
bind_role='{}/api/Questionnaire_UsersRoles/'.format(settings.ROOT_URL)
data={'create_user':create_user,'bind_role':bind_role,}
return render(request,'createuserrole.html',data)
#绑定用户和学校
class SchoolSchoolHeadViewSet(G,M.ListModelMixin,M.CreateModelMixin):
queryset = SchoolSchoolMasterModle.objects.all().order_by('id')
serializer_class =SchoolSchoolHeadSerializer
def get_queryset(self):
queryset=super().get_queryset()
find=self.request.GET.get('查询',None)
if find:
queryset=queryset.filter(Q(user_obj__name__contains=find)|Q(user_obj__mobile__contains=find))
return queryset.order_by('id')
| [
"631826964@qq.com"
] | 631826964@qq.com |
aa07ccf730b9e38669c19f247d6997777381104a | 5b8dff132570a110b16762422cac45a108439f05 | /geoportal/c2cgeoportal_geoportal/lib/cacheversion.py | 288ea78eed8288f4adb84436d49325daafa09762 | [
"BSD-2-Clause-Views"
] | permissive | pfirpfel/c2cgeoportal | 84dcbe0b8cd8f91321a4e313e3bedce12a0790ec | b54ff4a3f59c88f97627040154b44e1e984b76a9 | refs/heads/master | 2021-09-13T00:53:21.067994 | 2017-10-18T07:29:58 | 2017-10-18T07:29:58 | 107,403,270 | 0 | 0 | null | 2017-10-18T12:10:07 | 2017-10-18T12:10:07 | null | UTF-8 | Python | false | false | 3,003 | py | # -*- coding: utf-8 -*-
# Copyright (c) 2011-2017, Camptocamp SA
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
import uuid
from urllib.parse import urljoin
from c2cgeoportal_geoportal import CACHE_PATH
from c2cgeoportal_geoportal.lib.caching import get_region
cache_region = get_region()
@cache_region.cache_on_arguments()
def get_cache_version():
"""Return a cache version that is regenerate after each cache invalidation"""
return uuid.uuid4().hex
def version_cache_buster(request, subpath, kw): # pragma: no cover
return urljoin(get_cache_version() + "/", subpath), kw
class CachebusterTween:
""" Get back the cachebuster URL. """
def __init__(self, handler, registry):
self.handler = handler
def __call__(self, request):
path = request.path_info.split("/")
if path[1] in CACHE_PATH:
# remove the cache buster
path.pop(2)
request.path_info = "/" .join(path)
response = self.handler(request)
if path[1] in CACHE_PATH:
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Headers"] = "X-Requested-With, Content-Type"
return response
class VersionCache:
_value = None
_cache = None
def uptodate(self):
return self._cache == get_cache_version()
def get(self):
return self._value if self.uptodate() else None
def set(self, value):
self._value = value
self._cache = get_cache_version()
| [
"stephane.brunner@camptocamp.com"
] | stephane.brunner@camptocamp.com |
eb93ce2bbc86ab342cc62c77e0afa41e5f68e5ef | 01b80cab4c0e97a759d3d77bf311b40ce91698ce | /mlp.py | 24b0017d148b63edbf2b4a0fff73e68e4695f0b4 | [] | no_license | Saltfarmer/Pembelajaran-Mesin | 0156c5e676aa8ae84992a970d9d802b923ff9023 | 89168d2926be2c0ddfd799e383b553989b1be177 | refs/heads/master | 2020-04-07T08:58:10.370331 | 2018-09-13T05:52:00 | 2018-09-13T05:52:00 | 124,198,707 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 6,490 | py | import math
import random
import copy
import matplotlib.pyplot as plt
def __convertDataStructure__(attr) :
try :
attr = float(attr)
except :
if attr == 'Iris-setosa' :
attr = 0
elif attr == 'Iris-versicolor' :
attr = 0.5
else :
attr = 1
finally :
return attr
def __readData__() :
data = []
try :
file = open('iris.data')
for line in file :
data.append([__convertDataStructure__(attribute) for attribute in line.strip().split(',')])
finally :
file.close()
return data
def __randomWeight__() :
global layers, neurons
hiddenLayers = 1
layers = hiddenLayers + 1
outputNeuron = 1
neurons = [random.randint(1, 10) for _ in range(hiddenLayers)]
neurons.append(outputNeuron)
weight = [[] for _ in range(layers)]
for layer in range(layers) :
for _ in range(neurons[layer]) :
if layer == 0 :
weight[layer].append([random.random() for _ in range(len(dataSet[0]))])
else :
weight[layer].append([random.random() for _ in range(neurons[layer - 1] + 1)])
return weight
def __initData__() :
global dataSet, learningRate, epoch
learningRate = 0.1
epoch = 100
dataSet = __readData__()
return __randomWeight__()
def __plotGraphics__(*errors) :
for error in errors :
plt.plot(error[0]['Training'], label=error[1] + ' Training')
plt.plot(error[0]['Validation'], label=error[1] + ' Validation')
plt.legend(loc='upper right')
plt.xlabel('Epoch')
plt.ylabel('Error')
plt.show()
def __errorFunction__(fact, prediction) :
avg = 0.0
for pred in prediction :
avg += ((fact - pred) ** 2) / 2
return avg / len(prediction)
def __activationFunction__(target, mode='sigmoid') :
if mode == 'sigmoid' :
return 1 / (1 + math.exp(-target))
else :
return math.exp(-target) / (1 + math.exp(-target))
def __targetFunction__(data, weight) :
sum = 0.0
for i in range(len(data) - 1) :
sum += data[i] * weight[i]
sum += weight[len(data) - 1]
return sum
def __deltaFunctionFWD__(attr, prediction, fact) :
return (prediction - fact) * (1 - prediction) * prediction * attr
def __updateFeedForward__(data, weight, prediction, fact) :
for i in range(len(data) - 1) :
weight[i] -= learningRate *__deltaFunctionFWD__(data[i], prediction, fact)
return weight
def __deltaFunctionBP__(tau, data) :
return tau * data
def __updateBackPropagation__(data, weight, prediction):
tau = [[] for _ in range(layers)]
for layer in range(layers - 1, -1, -1) :
for neuron in range(neurons[layer]) :
pred = prediction[layer][neuron]
if layer == layers - 1 :
fact = data[len(data) - 1]
tau[layer].append((fact - pred) * (1 - pred) * pred)
else :
total = 0.0
for nextNeuron in range(neurons[layer + 1]) :
total += tau[layer + 1][nextNeuron] * weight[layer + 1][nextNeuron][neuron]
tau[layer].append(total * pred * (1 - pred))
dataUsed = data[0:len(data) - 1] if layer == 0 else prediction[layer - 1]
for dataPrev in range(len(dataUsed)) : # Update Weight
weight[layer][neuron][dataPrev] -= learningRate * __deltaFunctionBP__(tau[layer][neuron], dataUsed[dataPrev])
weight[layer][neuron][len(dataUsed)] -= learningRate * __deltaFunctionBP__(tau[layer][neuron], 1)
return weight
def __training__(data, weight, error, mode='FWD') :
prediction = [[] for _ in range(layers)]
fact = data[len(data) - 1]
for layer in range(layers) :
for neuron in range(neurons[layer]) :
dataUsed = data if layer == 0 else prediction[layer - 1]
target = __targetFunction__(dataUsed, weight[layer][neuron])
prediction[layer].append(__activationFunction__(target))
if mode == 'FWD' :
weight[layer][neuron] = __updateFeedForward__(dataUsed, weight[layer][neuron], prediction[layer][neuron], fact)
if mode == 'BP' :
weight = __updateBackPropagation__(data, weight, prediction)
return weight, error + __errorFunction__(fact, prediction[layers - 1])
def __validation__(data, weight) :
prediction = [[] for _ in range(layers)]
fact = data[len(data) - 1]
for layer in range(layers) :
for neuron in range(neurons[layer]) :
dataUsed = data if layer == 0 else prediction[layer - 1]
target = __targetFunction__(dataUsed, weight[layer][neuron])
prediction[layer].append(__activationFunction__(target))
return __errorFunction__(fact, prediction[layers - 1])
def __crossValidation__(n_data, weight) :
size = len(dataSet) // n_data
weightFeedForward = copy.deepcopy(weight)
weightBackPropagation = copy.deepcopy(weight)
nTraining = n_data * (n_data -1) * size
nValidation = n_data * size
subData = [dataSet[start:start + size] for start in range(0, len(dataSet), size)]
errorFWD = {'Training':[], 'Validation':[]}
errorBP = {'Training':[], 'Validation':[]}
for _ in range(epoch) :
errorTrainingFWD, errorValidationFWD = (0.0, 0.0)
errorTrainingBP, errorValidationBP = (0.0, 0.0)
for dataValidation in subData :
for dataTraining in subData :
if dataTraining != dataValidation :
for data in dataTraining :
weightFeedForward, errorTrainingFWD = __training__(data, weightFeedForward, errorTrainingFWD, mode='FWD')
weightBackPropagation, errorTrainingBP = __training__(data, weightBackPropagation, errorTrainingBP, mode='BP')
for data in dataValidation :
errorValidationFWD += __validation__(data, weightFeedForward)
errorValidationBP += __validation__(data, weightBackPropagation)
errorFWD['Training'].append(errorTrainingFWD / nTraining)
errorFWD['Validation'].append(errorValidationFWD / nValidation)
errorBP['Training'].append(errorTrainingBP / nTraining)
errorBP['Validation'].append(errorValidationBP / nValidation)
__plotGraphics__([errorFWD, 'FeedForward'], [errorBP, 'BackPropagation'])
def __main__() :
weight = __initData__()
__crossValidation__(5, weight)
__main__() | [
"noreply@github.com"
] | Saltfarmer.noreply@github.com |
c03586a750a4165937b31e9458ec1b99be6e1039 | 5c6fc477af787def5379c1c67b2296f32f2a519e | /regular/trieHelper.py | 322de07d14d9cf36c21fa8918076a39032b7dca1 | [] | no_license | vogelb2/multiMutant | 8956651c8ed67757cd8a453a88e19e63b0197566 | bd435d5276a5fd60616e6c5c73c5e71277a7b868 | refs/heads/master | 2022-10-27T01:56:57.241457 | 2020-06-05T20:29:37 | 2020-06-05T20:29:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 1,446 | py | #Trie Helper, this file was created by William Tian on May 22nd, 2020.
#doubleMutation.py is dependent on this, unless the code for redundant sequence checking is all commented out.
#A basic and bare Trie for the purpose of doubleMutation.py.
#Be advised when inserting into the trie. Wrong input will give unexpected results and and throw no error.
class trieNode:
def __init__(self):
self.children = [None] * 20
#Lower case because most of the FASTA sequence is lower case.
#The order is alphabetical from the amino acid's name, not their abbreviation.
map = {
'a':0,
'r':1,
'n':2,
'd':3,
'c':4,
'q':5,
'e':6,
'g':7,
'h':8,
'i':9,
'l':10,
'k':11,
'm':12,
'f':13,
'p':14,
's':15,
't':16,
'w':17,
'y':18,
'v':19
}
class trieHelper:
def __init__(self):
self.root=self.getNode()
def getNode(self):
return trieNode()
#Inserts the sequence into the Trie
#Returns True if the sequence already exists (which means it's a redundant sequence)
#Returns False if this sequence is unique
def insertNode(self, seq):
found = True
currNode = self.root
for c in seq:
i = map.get(c)
if not currNode.children[i]:
currNode.children[i] = self.getNode()
found = False
currNode = currNode.children[i]
return found
| [
"tianw@wwu.edu"
] | tianw@wwu.edu |
5786c30e275052644684034550f5af5890b13917 | ca7aa979e7059467e158830b76673f5b77a0f5a3 | /Python_codes/p03573/s591062548.py | 72050d80dfe7c931589196c68ab1643d549b86ee | [] | no_license | Aasthaengg/IBMdataset | 7abb6cbcc4fb03ef5ca68ac64ba460c4a64f8901 | f33f1c5c3b16d0ea8d1f5a7d479ad288bb3f48d8 | refs/heads/main | 2023-04-22T10:22:44.763102 | 2021-05-13T17:27:22 | 2021-05-13T17:27:22 | 367,112,348 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 81 | py | a, b, c = map(int, input().split())
print(c if a == b else (a if b == c else b))
| [
"66529651+Aastha2104@users.noreply.github.com"
] | 66529651+Aastha2104@users.noreply.github.com |
cac1d63c50a395c73ace10977020982d55f60021 | 75349dcec19d19314583797c113cb9c4b48dedc8 | /2020/day-1/day1.py | 0bdb8afa7d345874f4bc08c0bfdfdb6421318086 | [
"Unlicense"
] | permissive | smolsbs/aoc | 9b153462762b9c7c029ebc7a01efefb045b331d2 | ceaf3384190c6b63fae862076b7aff0ecec1d0f1 | refs/heads/master | 2023-05-24T06:43:07.443754 | 2023-05-23T21:43:45 | 2023-05-23T21:43:45 | 181,240,823 | 2 | 1 | Unlicense | 2023-05-23T21:43:46 | 2019-04-13T23:57:46 | Python | UTF-8 | Python | false | false | 549 | py | #!/usr/bin/env python3
def main():
with open('input', 'r') as fp:
data = {int(x) for x in fp.readlines()}
# O(n)
for i in data:
# subtract i from 2020 and see if it's in data
v = 2020 - i
if v in data:
print("part 1: {}".format(v*i))
break
# O(n^2)
for v1 in data:
for v2 in data:
v3 = 2020 - (v1+v2)
if v3 in data:
print("part 2: {}".format(v1*v2*v3))
return
if __name__ == '__main__':
main() | [
"smol.sarabs@gmail.com"
] | smol.sarabs@gmail.com |
1cc15e0e99f4ad8369db7da77a8b56ca7b6bb9f8 | 0b9622c6d67ddcb252a7a4dd9b38d493dfc9a25f | /APLpy/APLpy-0.9.8/tests/test_init_image.py | 428ec441635d54e5fa8cba7ccad6080164ce344d | [
"MIT"
] | permissive | d80b2t/python | eff2b19a69b55d73c4734fb9bc115be1d2193e2d | 73603b90996221e0bcd239f9b9f0458b99c6dc44 | refs/heads/master | 2020-05-21T20:43:54.501991 | 2017-12-24T12:55:59 | 2017-12-24T12:55:59 | 61,330,956 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 4,718 | py | import os
import matplotlib
matplotlib.use('Agg')
from aplpy import FITSFigure
import pytest
import numpy as np
import pyfits
from helpers import generate_file, generate_hdu, generate_wcs
# The tests in this file check that the initialization and basic plotting do
# not crash for FITS files with 2 dimensions. No reference images are
# required here.
header_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/2d_fits')
HEADERS = [os.path.join(header_dir, '1904-66_AIR.hdr'),
os.path.join(header_dir, '1904-66_AIT.hdr'),
os.path.join(header_dir, '1904-66_ARC.hdr'),
os.path.join(header_dir, '1904-66_AZP.hdr'),
os.path.join(header_dir, '1904-66_BON.hdr'),
os.path.join(header_dir, '1904-66_CAR.hdr'),
os.path.join(header_dir, '1904-66_CEA.hdr'),
os.path.join(header_dir, '1904-66_COD.hdr'),
os.path.join(header_dir, '1904-66_COE.hdr'),
os.path.join(header_dir, '1904-66_COO.hdr'),
os.path.join(header_dir, '1904-66_COP.hdr'),
os.path.join(header_dir, '1904-66_CSC.hdr'),
os.path.join(header_dir, '1904-66_CYP.hdr'),
os.path.join(header_dir, '1904-66_HPX.hdr'),
os.path.join(header_dir, '1904-66_MER.hdr'),
os.path.join(header_dir, '1904-66_MOL.hdr'),
os.path.join(header_dir, '1904-66_NCP.hdr'),
os.path.join(header_dir, '1904-66_PAR.hdr'),
os.path.join(header_dir, '1904-66_PCO.hdr'),
os.path.join(header_dir, '1904-66_QSC.hdr'),
os.path.join(header_dir, '1904-66_SFL.hdr'),
os.path.join(header_dir, '1904-66_SIN.hdr'),
os.path.join(header_dir, '1904-66_STG.hdr'),
os.path.join(header_dir, '1904-66_SZP.hdr'),
os.path.join(header_dir, '1904-66_TAN.hdr'),
os.path.join(header_dir, '1904-66_TSC.hdr'),
os.path.join(header_dir, '1904-66_ZEA.hdr'),
os.path.join(header_dir, '1904-66_ZPN.hdr')]
REFERENCE = os.path.join(header_dir, '1904-66_TAN.hdr')
CAR_REFERENCE = os.path.join(header_dir, '1904-66_CAR.hdr')
VALID_DIMENSIONS = [(0, 1), (1, 0)]
INVALID_DIMENSIONS = [None, (1,), (0, 2), (-4, 2), (1, 1), (2, 2), (1, 2, 3)]
# Test initialization through a filename
def test_file_init(tmpdir):
filename = generate_file(REFERENCE, str(tmpdir))
f = FITSFigure(filename)
f.show_grayscale()
f.close()
# Test initialization through an HDU object
def test_hdu_init():
hdu = generate_hdu(REFERENCE)
f = FITSFigure(hdu)
f.show_grayscale()
f.close()
# Test initialization through a WCS object
def test_wcs_init():
wcs = generate_wcs(REFERENCE)
f = FITSFigure(wcs)
f.show_grayscale()
f.close()
# Test initialization through an HDU object (no WCS)
def test_hdu_nowcs_init():
data = np.zeros((16, 16))
hdu = pyfits.PrimaryHDU(data)
f = FITSFigure(hdu)
f.show_grayscale()
f.close()
# Test initalization through a Numpy array (no WCS)
def test_numpy_nowcs_init():
data = np.zeros((16, 16))
f = FITSFigure(data)
f.show_grayscale()
f.close()
# Now check initialization with valid and invalid dimensions. We just need to
# tes with HDU objects since we already tested that reading from files is ok.
# Test initialization with valid dimensions
@pytest.mark.parametrize(('dimensions'), VALID_DIMENSIONS)
def test_init_dimensions_valid(dimensions):
hdu = generate_hdu(REFERENCE)
f = FITSFigure(hdu, dimensions=dimensions)
f.show_grayscale()
f.close()
# Test initialization with invalid dimensions
@pytest.mark.parametrize(('dimensions'), INVALID_DIMENSIONS)
def test_init_dimensions_invalid(dimensions):
hdu = generate_hdu(REFERENCE)
with pytest.raises(ValueError):
FITSFigure(hdu, dimensions=dimensions)
# Now check initialization of different WCS projections, and we check only
# valid dimensions
valid_parameters = []
for h in HEADERS:
for d in VALID_DIMENSIONS:
valid_parameters.append((h, d))
@pytest.mark.parametrize(('header', 'dimensions'), valid_parameters)
def test_init_extensive_wcs(header, dimensions):
hdu = generate_hdu(header)
if 'CAR' in header:
f = FITSFigure(hdu, dimensions=dimensions, convention='calabretta')
else:
f = FITSFigure(hdu, dimensions=dimensions)
f.show_grayscale()
f.add_grid()
f.close()
# Check that for CAR projections, an exception is raised if no convention is specified
@pytest.mark.parametrize(('dimensions'), VALID_DIMENSIONS)
def test_init_car_invalid(dimensions):
hdu = generate_hdu(CAR_REFERENCE)
with pytest.raises(Exception):
FITSFigure(hdu, dimensions=dimensions)
| [
"npross@lbl.gov"
] | npross@lbl.gov |
774e207de9d8003cfcff2498c78b6a6273c20274 | 6124906be6ce1f7fa6b9eeac78540ca1499970d7 | /LHP_Dashboard/wsgi.py | 91079f02d6b3bab152b453eda680e71dc0dff953 | [] | no_license | nmenescardi/LHP_Dashboard | bf566c0eadd37b638c0f5490a2da0c7bf1f6ebde | f04b3e937d829dfd0ef791866d91d4224638de9a | refs/heads/main | 2023-04-22T03:31:39.430385 | 2021-05-17T13:53:56 | 2021-05-17T13:53:56 | 362,476,729 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 403 | py | """
WSGI config for LHP_Dashboard project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'LHP_Dashboard.settings')
application = get_wsgi_application()
| [
"nicolasmenescardi@hotmail.com"
] | nicolasmenescardi@hotmail.com |
cecb81a555decf3c52e8b6b12c8480db176691fe | fe9ca2362816bf488cc77b3430a4da72527e281b | /inventory/wsgi.py | 6eeddce413b5a00b57928a4f4b3277d1924d6200 | [] | no_license | vainotuisk/inventor | e86575f094cb813565813a27700b884ef407ce2d | d235f076059d8c355192c551f2858f420176f340 | refs/heads/master | 2016-09-03T02:34:05.639211 | 2015-06-22T19:10:48 | 2015-06-22T19:10:48 | 37,758,391 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 393 | py | """
WSGI config for inventory project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "inventory.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
| [
"vainotuisk@gmail.com"
] | vainotuisk@gmail.com |
e0ccf8b1f3bc94061622322cd516e3d7badd7950 | ab8264fa9e45bb363fde400ee8d22b4859be6c77 | /devel/lib/python2.7/dist-packages/cvg_sim_msgs/msg/_PositionXYCommand.py | cf32ae78bc2c28b64a54ef074c7f8fdfdbc4aac0 | [] | no_license | aslab/mrt | 77f594f16e380a8c4d99fb70ab777b8f5bc04892 | 7f87e0c7f9b37a7137f914121c171077fa693442 | refs/heads/master | 2020-11-24T05:52:23.645894 | 2019-12-14T09:07:59 | 2019-12-14T09:07:59 | 227,994,160 | 1 | 0 | null | null | null | null | UTF-8 | Python | false | false | 6,169 | py | # This Python file uses the following encoding: utf-8
"""autogenerated by genpy from cvg_sim_msgs/PositionXYCommand.msg. Do not edit."""
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct
import std_msgs.msg
class PositionXYCommand(genpy.Message):
_md5sum = "7b4d52af2aa98221d9bb260976d6a201"
_type = "cvg_sim_msgs/PositionXYCommand"
_has_header = True #flag to mark the presence of a Header object
_full_text = """Header header
float32 x
float32 y
================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data
# in a particular coordinate frame.
#
# sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id
"""
__slots__ = ['header','x','y']
_slot_types = ['std_msgs/Header','float32','float32']
def __init__(self, *args, **kwds):
"""
Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
header,x,y
:param args: complete set of field values, in .msg order
:param kwds: use keyword arguments corresponding to message field names
to set specific fields.
"""
if args or kwds:
super(PositionXYCommand, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.header is None:
self.header = std_msgs.msg.Header()
if self.x is None:
self.x = 0.
if self.y is None:
self.y = 0.
else:
self.header = std_msgs.msg.Header()
self.x = 0.
self.y = 0.
def _get_types(self):
"""
internal API method
"""
return self._slot_types
def serialize(self, buff):
"""
serialize message into buffer
:param buff: buffer, ``StringIO``
"""
try:
_x = self
buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
_x = self.header.frame_id
length = len(_x)
if python3 or type(_x) == unicode:
_x = _x.encode('utf-8')
length = len(_x)
if python3:
buff.write(struct.pack('<I%sB'%length, length, *_x))
else:
buff.write(struct.pack('<I%ss'%length, length, _x))
_x = self
buff.write(_struct_2f.pack(_x.x, _x.y))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize(self, str):
"""
unpack serialized message in str into this message instance
:param str: byte array of serialized message, ``str``
"""
try:
if self.header is None:
self.header = std_msgs.msg.Header()
end = 0
_x = self
start = end
end += 12
(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
start = end
end += 4
(length,) = _struct_I.unpack(str[start:end])
start = end
end += length
if python3:
self.header.frame_id = str[start:end].decode('utf-8')
else:
self.header.frame_id = str[start:end]
_x = self
start = end
end += 8
(_x.x, _x.y,) = _struct_2f.unpack(str[start:end])
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
def serialize_numpy(self, buff, numpy):
"""
serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module
"""
try:
_x = self
buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
_x = self.header.frame_id
length = len(_x)
if python3 or type(_x) == unicode:
_x = _x.encode('utf-8')
length = len(_x)
if python3:
buff.write(struct.pack('<I%sB'%length, length, *_x))
else:
buff.write(struct.pack('<I%ss'%length, length, _x))
_x = self
buff.write(_struct_2f.pack(_x.x, _x.y))
except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def deserialize_numpy(self, str, numpy):
"""
unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module
"""
try:
if self.header is None:
self.header = std_msgs.msg.Header()
end = 0
_x = self
start = end
end += 12
(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
start = end
end += 4
(length,) = _struct_I.unpack(str[start:end])
start = end
end += length
if python3:
self.header.frame_id = str[start:end].decode('utf-8')
else:
self.header.frame_id = str[start:end]
_x = self
start = end
end += 8
(_x.x, _x.y,) = _struct_2f.unpack(str[start:end])
return self
except struct.error as e:
raise genpy.DeserializationError(e) #most likely buffer underfill
_struct_I = genpy.struct_I
_struct_3I = struct.Struct("<3I")
_struct_2f = struct.Struct("<2f")
| [
"ricardo.sanz@upm.es"
] | ricardo.sanz@upm.es |
0a19bb4e898b86c7f3c1a0980f6693385f8b791a | ca7aa979e7059467e158830b76673f5b77a0f5a3 | /Python_codes/p03156/s347695758.py | 66bfe5e4e4dc1000936c750336bc658ef2eb1af6 | [] | no_license | Aasthaengg/IBMdataset | 7abb6cbcc4fb03ef5ca68ac64ba460c4a64f8901 | f33f1c5c3b16d0ea8d1f5a7d479ad288bb3f48d8 | refs/heads/main | 2023-04-22T10:22:44.763102 | 2021-05-13T17:27:22 | 2021-05-13T17:27:22 | 367,112,348 | 0 | 0 | null | null | null | null | UTF-8 | Python | false | false | 228 | py | n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
ca=0
cb=0
cc=0
for i in range(n):
if p[i]<=a:
ca+=1
elif a<p[i] and p[i]<=b:
cb+=1
else:
cc+=1
print(min(ca,cb,cc)) | [
"66529651+Aastha2104@users.noreply.github.com"
] | 66529651+Aastha2104@users.noreply.github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.